muse/book-reading-clip-lamp

A Wi‑Fi/USB‑C ESP32‑S3 reading lamp with OV5640 camera, microphone, speaker amplifier, rechargeable Li‑Po power management, six-LED boost light, USB protection/charging detection, and a clip/gooseneck enclosure with external FlexPIFA antenna.

Version
0.4.3
License
unset
Stars
0

enclosure-viewer.bundle.js

var JW="179",p8={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},l8={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},QW=0,fQ=1,$W=2;var hQ=1,ZW=2,U8=3,d8=0,g0=1,j0=2,m8=0,E6=1,bQ=2,xQ=3,gQ=4,WW=5,f9=100,HW=101,YW=102,XW=103,KW=104,UW=200,GW=201,qW=202,EW=203,NW=204,OW=205,FW=206,RW=207,kW=208,MW=209,DW=210,LW=211,VW=212,zW=213,BW=214,K7=0,U7=1,G7=2,N6=3,q7=4,E7=5,N7=6,O7=7,CW=0,_W=1,wW=2,_8=0,IW=1,PW=2,TW=3,F7=4,AW=5,SW=6,jW=7;var h9=301,X9=302,R7=303,k7=304,O6=306,b9=1000,M7=1001,D7=1002,w8=1003,L7=1004;var K9=1005;var W8=1006,x9=1007;var I8=1008;var u8=1009,yW=1010,vW=1011,F6=1012,pQ=1013,g9=1014,c8=1015,R6=1016,lQ=1017,dQ=1018,p9=1020,fW=35902,hW=1021,bW=1022,G8=1023,V7=1026,k6=1027,xW=1028,mQ=1029,gW=1030,uQ=1031;var cQ=1033,z7=33776,B7=33777,C7=33778,_7=33779,nQ=35840,sQ=35841,oQ=35842,iQ=35843,aQ=36196,rQ=37492,tQ=37496,eQ=37808,J$=37809,Q$=37810,$$=37811,Z$=37812,W$=37813,H$=37814,Y$=37815,X$=37816,K$=37817,U$=37818,G$=37819,q$=37820,E$=37821,w7=36492,N$=36494,O$=36495,pW=36283,F$=36284,R$=36285,k$=36286;var M$=2300,I7=2301;var D$=0,M6=1,l9=2;var lW=3201;var dW=0,mW=1,U9="",q8="srgb",T0="srgb-linear",L$="linear",W0="srgb";var uW=512,cW=513,nW=514,V$=515,sW=516,oW=517,iW=518,aW=519;var z$="300 es",B$=2000;class P8{addEventListener(J,Q){if(this._listeners===void 0)this._listeners={};let $=this._listeners;if($[J]===void 0)$[J]=[];if($[J].indexOf(Q)===-1)$[J].push(Q)}hasEventListener(J,Q){let $=this._listeners;if($===void 0)return!1;return $[J]!==void 0&&$[J].indexOf(Q)!==-1}removeEventListener(J,Q){let $=this._listeners;if($===void 0)return;let Z=$[J];if(Z!==void 0){let W=Z.indexOf(Q);if(W!==-1)Z.splice(W,1)}}dispatchEvent(J){let Q=this._listeners;if(Q===void 0)return;let $=Q[J.type];if($!==void 0){J.target=this;let Z=$.slice(0);for(let W=0,H=Z.length;W<H;W++)Z[W].call(this,J);J.target=null}}}var B0=["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"],MZ=1234567,G6=Math.PI/180,W9=180/Math.PI;function $8(){let J=Math.random()*4294967295|0,Q=Math.random()*4294967295|0,$=Math.random()*4294967295|0,Z=Math.random()*4294967295|0;return(B0[J&255]+B0[J>>8&255]+B0[J>>16&255]+B0[J>>24&255]+"-"+B0[Q&255]+B0[Q>>8&255]+"-"+B0[Q>>16&15|64]+B0[Q>>24&255]+"-"+B0[$&63|128]+B0[$>>8&255]+"-"+B0[$>>16&255]+B0[$>>24&255]+B0[Z&255]+B0[Z>>8&255]+B0[Z>>16&255]+B0[Z>>24&255]).toLowerCase()}function xJ(J,Q,$){return Math.max(Q,Math.min($,J))}function C$(J,Q){return(J%Q+Q)%Q}function PY(J,Q,$,Z,W){return Z+(J-Q)*(W-Z)/($-Q)}function TY(J,Q,$){if(J!==Q)return($-J)/(Q-J);else return 0}function q6(J,Q,$){return(1-$)*J+$*Q}function AY(J,Q,$,Z){return q6(J,Q,1-Math.exp(-$*Z))}function SY(J,Q=1){return Q-Math.abs(C$(J,Q*2)-Q)}function jY(J,Q,$){if(J<=Q)return 0;if(J>=$)return 1;return J=(J-Q)/($-Q),J*J*(3-2*J)}function yY(J,Q,$){if(J<=Q)return 0;if(J>=$)return 1;return J=(J-Q)/($-Q),J*J*J*(J*(J*6-15)+10)}function vY(J,Q){return J+Math.floor(Math.random()*(Q-J+1))}function fY(J,Q){return J+Math.random()*(Q-J)}function hY(J){return J*(0.5-Math.random())}function bY(J){if(J!==void 0)MZ=J;let Q=MZ+=1831565813;return Q=Math.imul(Q^Q>>>15,Q|1),Q^=Q+Math.imul(Q^Q>>>7,Q|61),((Q^Q>>>14)>>>0)/4294967296}function xY(J){return J*G6}function gY(J){return J*W9}function pY(J){return(J&J-1)===0&&J!==0}function lY(J){return Math.pow(2,Math.ceil(Math.log(J)/Math.LN2))}function dY(J){return Math.pow(2,Math.floor(Math.log(J)/Math.LN2))}function mY(J,Q,$,Z,W){let{cos:H,sin:Y}=Math,X=H($/2),K=Y($/2),U=H((Q+Z)/2),G=Y((Q+Z)/2),q=H((Q-Z)/2),E=Y((Q-Z)/2),O=H((Z-Q)/2),k=Y((Z-Q)/2);switch(W){case"XYX":J.set(X*G,K*q,K*E,X*U);break;case"YZY":J.set(K*E,X*G,K*q,X*U);break;case"ZXZ":J.set(K*q,K*E,X*G,X*U);break;case"XZX":J.set(X*G,K*k,K*O,X*U);break;case"YXY":J.set(K*O,X*G,K*k,X*U);break;case"ZYZ":J.set(K*k,K*O,X*G,X*U);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+W)}}function Q8(J,Q){switch(Q.constructor){case Float32Array:return J;case Uint32Array:return J/4294967295;case Uint16Array:return J/65535;case Uint8Array:return J/255;case Int32Array:return Math.max(J/2147483647,-1);case Int16Array:return Math.max(J/32767,-1);case Int8Array:return Math.max(J/127,-1);default:throw Error("Invalid component type.")}}function aJ(J,Q){switch(Q.constructor){case Float32Array:return J;case Uint32Array:return Math.round(J*4294967295);case Uint16Array:return Math.round(J*65535);case Uint8Array:return Math.round(J*255);case Int32Array:return Math.round(J*2147483647);case Int16Array:return Math.round(J*32767);case Int8Array:return Math.round(J*127);default:throw Error("Invalid component type.")}}var D6={DEG2RAD:G6,RAD2DEG:W9,generateUUID:$8,clamp:xJ,euclideanModulo:C$,mapLinear:PY,inverseLerp:TY,lerp:q6,damp:AY,pingpong:SY,smoothstep:jY,smootherstep:yY,randInt:vY,randFloat:fY,randFloatSpread:hY,seededRandom:bY,degToRad:xY,radToDeg:gY,isPowerOfTwo:pY,ceilPowerOfTwo:lY,floorPowerOfTwo:dY,setQuaternionFromProperEuler:mY,normalize:aJ,denormalize:Q8};class PJ{constructor(J=0,Q=0){PJ.prototype.isVector2=!0,this.x=J,this.y=Q}get width(){return this.x}set width(J){this.x=J}get height(){return this.y}set height(J){this.y=J}set(J,Q){return this.x=J,this.y=Q,this}setScalar(J){return this.x=J,this.y=J,this}setX(J){return this.x=J,this}setY(J){return this.y=J,this}setComponent(J,Q){switch(J){case 0:this.x=Q;break;case 1:this.y=Q;break;default:throw Error("index is out of range: "+J)}return this}getComponent(J){switch(J){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+J)}}clone(){return new this.constructor(this.x,this.y)}copy(J){return this.x=J.x,this.y=J.y,this}add(J){return this.x+=J.x,this.y+=J.y,this}addScalar(J){return this.x+=J,this.y+=J,this}addVectors(J,Q){return this.x=J.x+Q.x,this.y=J.y+Q.y,this}addScaledVector(J,Q){return this.x+=J.x*Q,this.y+=J.y*Q,this}sub(J){return this.x-=J.x,this.y-=J.y,this}subScalar(J){return this.x-=J,this.y-=J,this}subVectors(J,Q){return this.x=J.x-Q.x,this.y=J.y-Q.y,this}multiply(J){return this.x*=J.x,this.y*=J.y,this}multiplyScalar(J){return this.x*=J,this.y*=J,this}divide(J){return this.x/=J.x,this.y/=J.y,this}divideScalar(J){return this.multiplyScalar(1/J)}applyMatrix3(J){let Q=this.x,$=this.y,Z=J.elements;return this.x=Z[0]*Q+Z[3]*$+Z[6],this.y=Z[1]*Q+Z[4]*$+Z[7],this}min(J){return this.x=Math.min(this.x,J.x),this.y=Math.min(this.y,J.y),this}max(J){return this.x=Math.max(this.x,J.x),this.y=Math.max(this.y,J.y),this}clamp(J,Q){return this.x=xJ(this.x,J.x,Q.x),this.y=xJ(this.y,J.y,Q.y),this}clampScalar(J,Q){return this.x=xJ(this.x,J,Q),this.y=xJ(this.y,J,Q),this}clampLength(J,Q){let $=this.length();return this.divideScalar($||1).multiplyScalar(xJ($,J,Q))}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(J){return this.x*J.x+this.y*J.y}cross(J){return this.x*J.y-this.y*J.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(J){let Q=Math.sqrt(this.lengthSq()*J.lengthSq());if(Q===0)return Math.PI/2;let $=this.dot(J)/Q;return Math.acos(xJ($,-1,1))}distanceTo(J){return Math.sqrt(this.distanceToSquared(J))}distanceToSquared(J){let Q=this.x-J.x,$=this.y-J.y;return Q*Q+$*$}manhattanDistanceTo(J){return Math.abs(this.x-J.x)+Math.abs(this.y-J.y)}setLength(J){return this.normalize().multiplyScalar(J)}lerp(J,Q){return this.x+=(J.x-this.x)*Q,this.y+=(J.y-this.y)*Q,this}lerpVectors(J,Q,$){return this.x=J.x+(Q.x-J.x)*$,this.y=J.y+(Q.y-J.y)*$,this}equals(J){return J.x===this.x&&J.y===this.y}fromArray(J,Q=0){return this.x=J[Q],this.y=J[Q+1],this}toArray(J=[],Q=0){return J[Q]=this.x,J[Q+1]=this.y,J}fromBufferAttribute(J,Q){return this.x=J.getX(Q),this.y=J.getY(Q),this}rotateAround(J,Q){let $=Math.cos(Q),Z=Math.sin(Q),W=this.x-J.x,H=this.y-J.y;return this.x=W*$-H*Z+J.x,this.y=W*Z+H*$+J.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class y0{constructor(J=0,Q=0,$=0,Z=1){this.isQuaternion=!0,this._x=J,this._y=Q,this._z=$,this._w=Z}static slerpFlat(J,Q,$,Z,W,H,Y){let X=$[Z+0],K=$[Z+1],U=$[Z+2],G=$[Z+3],q=W[H+0],E=W[H+1],O=W[H+2],k=W[H+3];if(Y===0){J[Q+0]=X,J[Q+1]=K,J[Q+2]=U,J[Q+3]=G;return}if(Y===1){J[Q+0]=q,J[Q+1]=E,J[Q+2]=O,J[Q+3]=k;return}if(G!==k||X!==q||K!==E||U!==O){let M=1-Y,N=X*q+K*E+U*O+G*k,F=N>=0?1:-1,C=1-N*N;if(C>Number.EPSILON){let _=Math.sqrt(C),v=Math.atan2(_,N*F);M=Math.sin(M*v)/_,Y=Math.sin(Y*v)/_}let L=Y*F;if(X=X*M+q*L,K=K*M+E*L,U=U*M+O*L,G=G*M+k*L,M===1-Y){let _=1/Math.sqrt(X*X+K*K+U*U+G*G);X*=_,K*=_,U*=_,G*=_}}J[Q]=X,J[Q+1]=K,J[Q+2]=U,J[Q+3]=G}static multiplyQuaternionsFlat(J,Q,$,Z,W,H){let Y=$[Z],X=$[Z+1],K=$[Z+2],U=$[Z+3],G=W[H],q=W[H+1],E=W[H+2],O=W[H+3];return J[Q]=Y*O+U*G+X*E-K*q,J[Q+1]=X*O+U*q+K*G-Y*E,J[Q+2]=K*O+U*E+Y*q-X*G,J[Q+3]=U*O-Y*G-X*q-K*E,J}get x(){return this._x}set x(J){this._x=J,this._onChangeCallback()}get y(){return this._y}set y(J){this._y=J,this._onChangeCallback()}get z(){return this._z}set z(J){this._z=J,this._onChangeCallback()}get w(){return this._w}set w(J){this._w=J,this._onChangeCallback()}set(J,Q,$,Z){return this._x=J,this._y=Q,this._z=$,this._w=Z,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(J){return this._x=J.x,this._y=J.y,this._z=J.z,this._w=J.w,this._onChangeCallback(),this}setFromEuler(J,Q=!0){let{_x:$,_y:Z,_z:W,_order:H}=J,Y=Math.cos,X=Math.sin,K=Y($/2),U=Y(Z/2),G=Y(W/2),q=X($/2),E=X(Z/2),O=X(W/2);switch(H){case"XYZ":this._x=q*U*G+K*E*O,this._y=K*E*G-q*U*O,this._z=K*U*O+q*E*G,this._w=K*U*G-q*E*O;break;case"YXZ":this._x=q*U*G+K*E*O,this._y=K*E*G-q*U*O,this._z=K*U*O-q*E*G,this._w=K*U*G+q*E*O;break;case"ZXY":this._x=q*U*G-K*E*O,this._y=K*E*G+q*U*O,this._z=K*U*O+q*E*G,this._w=K*U*G-q*E*O;break;case"ZYX":this._x=q*U*G-K*E*O,this._y=K*E*G+q*U*O,this._z=K*U*O-q*E*G,this._w=K*U*G+q*E*O;break;case"YZX":this._x=q*U*G+K*E*O,this._y=K*E*G+q*U*O,this._z=K*U*O-q*E*G,this._w=K*U*G-q*E*O;break;case"XZY":this._x=q*U*G-K*E*O,this._y=K*E*G-q*U*O,this._z=K*U*O+q*E*G,this._w=K*U*G+q*E*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+H)}if(Q===!0)this._onChangeCallback();return this}setFromAxisAngle(J,Q){let $=Q/2,Z=Math.sin($);return this._x=J.x*Z,this._y=J.y*Z,this._z=J.z*Z,this._w=Math.cos($),this._onChangeCallback(),this}setFromRotationMatrix(J){let Q=J.elements,$=Q[0],Z=Q[4],W=Q[8],H=Q[1],Y=Q[5],X=Q[9],K=Q[2],U=Q[6],G=Q[10],q=$+Y+G;if(q>0){let E=0.5/Math.sqrt(q+1);this._w=0.25/E,this._x=(U-X)*E,this._y=(W-K)*E,this._z=(H-Z)*E}else if($>Y&&$>G){let E=2*Math.sqrt(1+$-Y-G);this._w=(U-X)/E,this._x=0.25*E,this._y=(Z+H)/E,this._z=(W+K)/E}else if(Y>G){let E=2*Math.sqrt(1+Y-$-G);this._w=(W-K)/E,this._x=(Z+H)/E,this._y=0.25*E,this._z=(X+U)/E}else{let E=2*Math.sqrt(1+G-$-Y);this._w=(H-Z)/E,this._x=(W+K)/E,this._y=(X+U)/E,this._z=0.25*E}return this._onChangeCallback(),this}setFromUnitVectors(J,Q){let $=J.dot(Q)+1;if($<0.00000001)if($=0,Math.abs(J.x)>Math.abs(J.z))this._x=-J.y,this._y=J.x,this._z=0,this._w=$;else this._x=0,this._y=-J.z,this._z=J.y,this._w=$;else this._x=J.y*Q.z-J.z*Q.y,this._y=J.z*Q.x-J.x*Q.z,this._z=J.x*Q.y-J.y*Q.x,this._w=$;return this.normalize()}angleTo(J){return 2*Math.acos(Math.abs(xJ(this.dot(J),-1,1)))}rotateTowards(J,Q){let $=this.angleTo(J);if($===0)return this;let Z=Math.min(1,Q/$);return this.slerp(J,Z),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(J){return this._x*J._x+this._y*J._y+this._z*J._z+this._w*J._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 J=this.length();if(J===0)this._x=0,this._y=0,this._z=0,this._w=1;else J=1/J,this._x=this._x*J,this._y=this._y*J,this._z=this._z*J,this._w=this._w*J;return this._onChangeCallback(),this}multiply(J){return this.multiplyQuaternions(this,J)}premultiply(J){return this.multiplyQuaternions(J,this)}multiplyQuaternions(J,Q){let{_x:$,_y:Z,_z:W,_w:H}=J,Y=Q._x,X=Q._y,K=Q._z,U=Q._w;return this._x=$*U+H*Y+Z*K-W*X,this._y=Z*U+H*X+W*Y-$*K,this._z=W*U+H*K+$*X-Z*Y,this._w=H*U-$*Y-Z*X-W*K,this._onChangeCallback(),this}slerp(J,Q){if(Q===0)return this;if(Q===1)return this.copy(J);let $=this._x,Z=this._y,W=this._z,H=this._w,Y=H*J._w+$*J._x+Z*J._y+W*J._z;if(Y<0)this._w=-J._w,this._x=-J._x,this._y=-J._y,this._z=-J._z,Y=-Y;else this.copy(J);if(Y>=1)return this._w=H,this._x=$,this._y=Z,this._z=W,this;let X=1-Y*Y;if(X<=Number.EPSILON){let E=1-Q;return this._w=E*H+Q*this._w,this._x=E*$+Q*this._x,this._y=E*Z+Q*this._y,this._z=E*W+Q*this._z,this.normalize(),this}let K=Math.sqrt(X),U=Math.atan2(K,Y),G=Math.sin((1-Q)*U)/K,q=Math.sin(Q*U)/K;return this._w=H*G+this._w*q,this._x=$*G+this._x*q,this._y=Z*G+this._y*q,this._z=W*G+this._z*q,this._onChangeCallback(),this}slerpQuaternions(J,Q,$){return this.copy(J).slerp(Q,$)}random(){let J=2*Math.PI*Math.random(),Q=2*Math.PI*Math.random(),$=Math.random(),Z=Math.sqrt(1-$),W=Math.sqrt($);return this.set(Z*Math.sin(J),Z*Math.cos(J),W*Math.sin(Q),W*Math.cos(Q))}equals(J){return J._x===this._x&&J._y===this._y&&J._z===this._z&&J._w===this._w}fromArray(J,Q=0){return this._x=J[Q],this._y=J[Q+1],this._z=J[Q+2],this._w=J[Q+3],this._onChangeCallback(),this}toArray(J=[],Q=0){return J[Q]=this._x,J[Q+1]=this._y,J[Q+2]=this._z,J[Q+3]=this._w,J}fromBufferAttribute(J,Q){return this._x=J.getX(Q),this._y=J.getY(Q),this._z=J.getZ(Q),this._w=J.getW(Q),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(J){return this._onChangeCallback=J,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class A{constructor(J=0,Q=0,$=0){A.prototype.isVector3=!0,this.x=J,this.y=Q,this.z=$}set(J,Q,$){if($===void 0)$=this.z;return this.x=J,this.y=Q,this.z=$,this}setScalar(J){return this.x=J,this.y=J,this.z=J,this}setX(J){return this.x=J,this}setY(J){return this.y=J,this}setZ(J){return this.z=J,this}setComponent(J,Q){switch(J){case 0:this.x=Q;break;case 1:this.y=Q;break;case 2:this.z=Q;break;default:throw Error("index is out of range: "+J)}return this}getComponent(J){switch(J){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+J)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(J){return this.x=J.x,this.y=J.y,this.z=J.z,this}add(J){return this.x+=J.x,this.y+=J.y,this.z+=J.z,this}addScalar(J){return this.x+=J,this.y+=J,this.z+=J,this}addVectors(J,Q){return this.x=J.x+Q.x,this.y=J.y+Q.y,this.z=J.z+Q.z,this}addScaledVector(J,Q){return this.x+=J.x*Q,this.y+=J.y*Q,this.z+=J.z*Q,this}sub(J){return this.x-=J.x,this.y-=J.y,this.z-=J.z,this}subScalar(J){return this.x-=J,this.y-=J,this.z-=J,this}subVectors(J,Q){return this.x=J.x-Q.x,this.y=J.y-Q.y,this.z=J.z-Q.z,this}multiply(J){return this.x*=J.x,this.y*=J.y,this.z*=J.z,this}multiplyScalar(J){return this.x*=J,this.y*=J,this.z*=J,this}multiplyVectors(J,Q){return this.x=J.x*Q.x,this.y=J.y*Q.y,this.z=J.z*Q.z,this}applyEuler(J){return this.applyQuaternion(DZ.setFromEuler(J))}applyAxisAngle(J,Q){return this.applyQuaternion(DZ.setFromAxisAngle(J,Q))}applyMatrix3(J){let Q=this.x,$=this.y,Z=this.z,W=J.elements;return this.x=W[0]*Q+W[3]*$+W[6]*Z,this.y=W[1]*Q+W[4]*$+W[7]*Z,this.z=W[2]*Q+W[5]*$+W[8]*Z,this}applyNormalMatrix(J){return this.applyMatrix3(J).normalize()}applyMatrix4(J){let Q=this.x,$=this.y,Z=this.z,W=J.elements,H=1/(W[3]*Q+W[7]*$+W[11]*Z+W[15]);return this.x=(W[0]*Q+W[4]*$+W[8]*Z+W[12])*H,this.y=(W[1]*Q+W[5]*$+W[9]*Z+W[13])*H,this.z=(W[2]*Q+W[6]*$+W[10]*Z+W[14])*H,this}applyQuaternion(J){let Q=this.x,$=this.y,Z=this.z,W=J.x,H=J.y,Y=J.z,X=J.w,K=2*(H*Z-Y*$),U=2*(Y*Q-W*Z),G=2*(W*$-H*Q);return this.x=Q+X*K+H*G-Y*U,this.y=$+X*U+Y*K-W*G,this.z=Z+X*G+W*U-H*K,this}project(J){return this.applyMatrix4(J.matrixWorldInverse).applyMatrix4(J.projectionMatrix)}unproject(J){return this.applyMatrix4(J.projectionMatrixInverse).applyMatrix4(J.matrixWorld)}transformDirection(J){let Q=this.x,$=this.y,Z=this.z,W=J.elements;return this.x=W[0]*Q+W[4]*$+W[8]*Z,this.y=W[1]*Q+W[5]*$+W[9]*Z,this.z=W[2]*Q+W[6]*$+W[10]*Z,this.normalize()}divide(J){return this.x/=J.x,this.y/=J.y,this.z/=J.z,this}divideScalar(J){return this.multiplyScalar(1/J)}min(J){return this.x=Math.min(this.x,J.x),this.y=Math.min(this.y,J.y),this.z=Math.min(this.z,J.z),this}max(J){return this.x=Math.max(this.x,J.x),this.y=Math.max(this.y,J.y),this.z=Math.max(this.z,J.z),this}clamp(J,Q){return this.x=xJ(this.x,J.x,Q.x),this.y=xJ(this.y,J.y,Q.y),this.z=xJ(this.z,J.z,Q.z),this}clampScalar(J,Q){return this.x=xJ(this.x,J,Q),this.y=xJ(this.y,J,Q),this.z=xJ(this.z,J,Q),this}clampLength(J,Q){let $=this.length();return this.divideScalar($||1).multiplyScalar(xJ($,J,Q))}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(J){return this.x*J.x+this.y*J.y+this.z*J.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(J){return this.normalize().multiplyScalar(J)}lerp(J,Q){return this.x+=(J.x-this.x)*Q,this.y+=(J.y-this.y)*Q,this.z+=(J.z-this.z)*Q,this}lerpVectors(J,Q,$){return this.x=J.x+(Q.x-J.x)*$,this.y=J.y+(Q.y-J.y)*$,this.z=J.z+(Q.z-J.z)*$,this}cross(J){return this.crossVectors(this,J)}crossVectors(J,Q){let{x:$,y:Z,z:W}=J,H=Q.x,Y=Q.y,X=Q.z;return this.x=Z*X-W*Y,this.y=W*H-$*X,this.z=$*Y-Z*H,this}projectOnVector(J){let Q=J.lengthSq();if(Q===0)return this.set(0,0,0);let $=J.dot(this)/Q;return this.copy(J).multiplyScalar($)}projectOnPlane(J){return XQ.copy(this).projectOnVector(J),this.sub(XQ)}reflect(J){return this.sub(XQ.copy(J).multiplyScalar(2*this.dot(J)))}angleTo(J){let Q=Math.sqrt(this.lengthSq()*J.lengthSq());if(Q===0)return Math.PI/2;let $=this.dot(J)/Q;return Math.acos(xJ($,-1,1))}distanceTo(J){return Math.sqrt(this.distanceToSquared(J))}distanceToSquared(J){let Q=this.x-J.x,$=this.y-J.y,Z=this.z-J.z;return Q*Q+$*$+Z*Z}manhattanDistanceTo(J){return Math.abs(this.x-J.x)+Math.abs(this.y-J.y)+Math.abs(this.z-J.z)}setFromSpherical(J){return this.setFromSphericalCoords(J.radius,J.phi,J.theta)}setFromSphericalCoords(J,Q,$){let Z=Math.sin(Q)*J;return this.x=Z*Math.sin($),this.y=Math.cos(Q)*J,this.z=Z*Math.cos($),this}setFromCylindrical(J){return this.setFromCylindricalCoords(J.radius,J.theta,J.y)}setFromCylindricalCoords(J,Q,$){return this.x=J*Math.sin(Q),this.y=$,this.z=J*Math.cos(Q),this}setFromMatrixPosition(J){let Q=J.elements;return this.x=Q[12],this.y=Q[13],this.z=Q[14],this}setFromMatrixScale(J){let Q=this.setFromMatrixColumn(J,0).length(),$=this.setFromMatrixColumn(J,1).length(),Z=this.setFromMatrixColumn(J,2).length();return this.x=Q,this.y=$,this.z=Z,this}setFromMatrixColumn(J,Q){return this.fromArray(J.elements,Q*4)}setFromMatrix3Column(J,Q){return this.fromArray(J.elements,Q*3)}setFromEuler(J){return this.x=J._x,this.y=J._y,this.z=J._z,this}setFromColor(J){return this.x=J.r,this.y=J.g,this.z=J.b,this}equals(J){return J.x===this.x&&J.y===this.y&&J.z===this.z}fromArray(J,Q=0){return this.x=J[Q],this.y=J[Q+1],this.z=J[Q+2],this}toArray(J=[],Q=0){return J[Q]=this.x,J[Q+1]=this.y,J[Q+2]=this.z,J}fromBufferAttribute(J,Q){return this.x=J.getX(Q),this.y=J.getY(Q),this.z=J.getZ(Q),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let J=Math.random()*Math.PI*2,Q=Math.random()*2-1,$=Math.sqrt(1-Q*Q);return this.x=$*Math.cos(J),this.y=Q,this.z=$*Math.sin(J),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var XQ=new A,DZ=new y0;class fJ{constructor(J,Q,$,Z,W,H,Y,X,K){if(fJ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],J!==void 0)this.set(J,Q,$,Z,W,H,Y,X,K)}set(J,Q,$,Z,W,H,Y,X,K){let U=this.elements;return U[0]=J,U[1]=Z,U[2]=Y,U[3]=Q,U[4]=W,U[5]=X,U[6]=$,U[7]=H,U[8]=K,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(J){let Q=this.elements,$=J.elements;return Q[0]=$[0],Q[1]=$[1],Q[2]=$[2],Q[3]=$[3],Q[4]=$[4],Q[5]=$[5],Q[6]=$[6],Q[7]=$[7],Q[8]=$[8],this}extractBasis(J,Q,$){return J.setFromMatrix3Column(this,0),Q.setFromMatrix3Column(this,1),$.setFromMatrix3Column(this,2),this}setFromMatrix4(J){let Q=J.elements;return this.set(Q[0],Q[4],Q[8],Q[1],Q[5],Q[9],Q[2],Q[6],Q[10]),this}multiply(J){return this.multiplyMatrices(this,J)}premultiply(J){return this.multiplyMatrices(J,this)}multiplyMatrices(J,Q){let $=J.elements,Z=Q.elements,W=this.elements,H=$[0],Y=$[3],X=$[6],K=$[1],U=$[4],G=$[7],q=$[2],E=$[5],O=$[8],k=Z[0],M=Z[3],N=Z[6],F=Z[1],C=Z[4],L=Z[7],_=Z[2],v=Z[5],w=Z[8];return W[0]=H*k+Y*F+X*_,W[3]=H*M+Y*C+X*v,W[6]=H*N+Y*L+X*w,W[1]=K*k+U*F+G*_,W[4]=K*M+U*C+G*v,W[7]=K*N+U*L+G*w,W[2]=q*k+E*F+O*_,W[5]=q*M+E*C+O*v,W[8]=q*N+E*L+O*w,this}multiplyScalar(J){let Q=this.elements;return Q[0]*=J,Q[3]*=J,Q[6]*=J,Q[1]*=J,Q[4]*=J,Q[7]*=J,Q[2]*=J,Q[5]*=J,Q[8]*=J,this}determinant(){let J=this.elements,Q=J[0],$=J[1],Z=J[2],W=J[3],H=J[4],Y=J[5],X=J[6],K=J[7],U=J[8];return Q*H*U-Q*Y*K-$*W*U+$*Y*X+Z*W*K-Z*H*X}invert(){let J=this.elements,Q=J[0],$=J[1],Z=J[2],W=J[3],H=J[4],Y=J[5],X=J[6],K=J[7],U=J[8],G=U*H-Y*K,q=Y*X-U*W,E=K*W-H*X,O=Q*G+$*q+Z*E;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);let k=1/O;return J[0]=G*k,J[1]=(Z*K-U*$)*k,J[2]=(Y*$-Z*H)*k,J[3]=q*k,J[4]=(U*Q-Z*X)*k,J[5]=(Z*W-Y*Q)*k,J[6]=E*k,J[7]=($*X-K*Q)*k,J[8]=(H*Q-$*W)*k,this}transpose(){let J,Q=this.elements;return J=Q[1],Q[1]=Q[3],Q[3]=J,J=Q[2],Q[2]=Q[6],Q[6]=J,J=Q[5],Q[5]=Q[7],Q[7]=J,this}getNormalMatrix(J){return this.setFromMatrix4(J).invert().transpose()}transposeIntoArray(J){let Q=this.elements;return J[0]=Q[0],J[1]=Q[3],J[2]=Q[6],J[3]=Q[1],J[4]=Q[4],J[5]=Q[7],J[6]=Q[2],J[7]=Q[5],J[8]=Q[8],this}setUvTransform(J,Q,$,Z,W,H,Y){let X=Math.cos(W),K=Math.sin(W);return this.set($*X,$*K,-$*(X*H+K*Y)+H+J,-Z*K,Z*X,-Z*(-K*H+X*Y)+Y+Q,0,0,1),this}scale(J,Q){return this.premultiply(KQ.makeScale(J,Q)),this}rotate(J){return this.premultiply(KQ.makeRotation(-J)),this}translate(J,Q){return this.premultiply(KQ.makeTranslation(J,Q)),this}makeTranslation(J,Q){if(J.isVector2)this.set(1,0,J.x,0,1,J.y,0,0,1);else this.set(1,0,J,0,1,Q,0,0,1);return this}makeRotation(J){let Q=Math.cos(J),$=Math.sin(J);return this.set(Q,-$,0,$,Q,0,0,0,1),this}makeScale(J,Q){return this.set(J,0,0,0,Q,0,0,0,1),this}equals(J){let Q=this.elements,$=J.elements;for(let Z=0;Z<9;Z++)if(Q[Z]!==$[Z])return!1;return!0}fromArray(J,Q=0){for(let $=0;$<9;$++)this.elements[$]=J[$+Q];return this}toArray(J=[],Q=0){let $=this.elements;return J[Q]=$[0],J[Q+1]=$[1],J[Q+2]=$[2],J[Q+3]=$[3],J[Q+4]=$[4],J[Q+5]=$[5],J[Q+6]=$[6],J[Q+7]=$[7],J[Q+8]=$[8],J}clone(){return new this.constructor().fromArray(this.elements)}}var KQ=new fJ;function _$(J){for(let Q=J.length-1;Q>=0;--Q)if(J[Q]>=65535)return!0;return!1}function v9(J){return document.createElementNS("http://www.w3.org/1999/xhtml",J)}function rW(){let J=v9("canvas");return J.style.display="block",J}var LZ={};function H9(J){if(J in LZ)return;LZ[J]=!0,console.warn(J)}function tW(J,Q,$){return new Promise(function(Z,W){function H(){switch(J.clientWaitSync(Q,J.SYNC_FLUSH_COMMANDS_BIT,0)){case J.WAIT_FAILED:W();break;case J.TIMEOUT_EXPIRED:setTimeout(H,$);break;default:Z()}}setTimeout(H,$)})}var VZ=new fJ().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),zZ=new fJ().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function uY(){let J={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(W,H,Y){if(this.enabled===!1||H===Y||!H||!Y)return W;if(this.spaces[H].transfer==="srgb")W.r=z8(W.r),W.g=z8(W.g),W.b=z8(W.b);if(this.spaces[H].primaries!==this.spaces[Y].primaries)W.applyMatrix3(this.spaces[H].toXYZ),W.applyMatrix3(this.spaces[Y].fromXYZ);if(this.spaces[Y].transfer==="srgb")W.r=y9(W.r),W.g=y9(W.g),W.b=y9(W.b);return W},workingToColorSpace:function(W,H){return this.convert(W,this.workingColorSpace,H)},colorSpaceToWorking:function(W,H){return this.convert(W,H,this.workingColorSpace)},getPrimaries:function(W){return this.spaces[W].primaries},getTransfer:function(W){if(W==="")return"linear";return this.spaces[W].transfer},getLuminanceCoefficients:function(W,H=this.workingColorSpace){return W.fromArray(this.spaces[H].luminanceCoefficients)},define:function(W){Object.assign(this.spaces,W)},_getMatrix:function(W,H,Y){return W.copy(this.spaces[H].toXYZ).multiply(this.spaces[Y].fromXYZ)},_getDrawingBufferColorSpace:function(W){return this.spaces[W].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(W=this.workingColorSpace){return this.spaces[W].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(W,H){return H9("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),J.workingToColorSpace(W,H)},toWorkingColorSpace:function(W,H){return H9("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),J.colorSpaceToWorking(W,H)}},Q=[0.64,0.33,0.3,0.6,0.15,0.06],$=[0.2126,0.7152,0.0722],Z=[0.3127,0.329];return J.define({["srgb-linear"]:{primaries:Q,whitePoint:Z,transfer:"linear",toXYZ:VZ,fromXYZ:zZ,luminanceCoefficients:$,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:Q,whitePoint:Z,transfer:"srgb",toXYZ:VZ,fromXYZ:zZ,luminanceCoefficients:$,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),J}var lJ=uY();function z8(J){return J<0.04045?J*0.0773993808:Math.pow(J*0.9478672986+0.0521327014,2.4)}function y9(J){return J<0.0031308?J*12.92:1.055*Math.pow(J,0.41666)-0.055}var D9;class w${static getDataURL(J,Q="image/png"){if(/^data:/i.test(J.src))return J.src;if(typeof HTMLCanvasElement>"u")return J.src;let $;if(J instanceof HTMLCanvasElement)$=J;else{if(D9===void 0)D9=v9("canvas");D9.width=J.width,D9.height=J.height;let Z=D9.getContext("2d");if(J instanceof ImageData)Z.putImageData(J,0,0);else Z.drawImage(J,0,0,J.width,J.height);$=D9}return $.toDataURL(Q)}static sRGBToLinear(J){if(typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&J instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&J instanceof ImageBitmap){let Q=v9("canvas");Q.width=J.width,Q.height=J.height;let $=Q.getContext("2d");$.drawImage(J,0,0,J.width,J.height);let Z=$.getImageData(0,0,J.width,J.height),W=Z.data;for(let H=0;H<W.length;H++)W[H]=z8(W[H]/255)*255;return $.putImageData(Z,0,0),Q}else if(J.data){let Q=J.data.slice(0);for(let $=0;$<Q.length;$++)if(Q instanceof Uint8Array||Q instanceof Uint8ClampedArray)Q[$]=Math.floor(z8(Q[$]/255)*255);else Q[$]=z8(Q[$]);return{data:Q,width:J.width,height:J.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),J}}var cY=0;class L6{constructor(J=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cY++}),this.uuid=$8(),this.data=J,this.dataReady=!0,this.version=0}getSize(J){let Q=this.data;if(Q instanceof HTMLVideoElement)J.set(Q.videoWidth,Q.videoHeight,0);else if(Q instanceof VideoFrame)J.set(Q.displayHeight,Q.displayWidth,0);else if(Q!==null)J.set(Q.width,Q.height,Q.depth||0);else J.set(0,0,0);return J}set needsUpdate(J){if(J===!0)this.version++}toJSON(J){let Q=J===void 0||typeof J==="string";if(!Q&&J.images[this.uuid]!==void 0)return J.images[this.uuid];let $={uuid:this.uuid,url:""},Z=this.data;if(Z!==null){let W;if(Array.isArray(Z)){W=[];for(let H=0,Y=Z.length;H<Y;H++)if(Z[H].isDataTexture)W.push(UQ(Z[H].image));else W.push(UQ(Z[H]))}else W=UQ(Z);$.url=W}if(!Q)J.images[this.uuid]=$;return $}}function UQ(J){if(typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&J instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&J instanceof ImageBitmap)return w$.getDataURL(J);else if(J.data)return{data:Array.from(J.data),width:J.width,height:J.height,type:J.data.constructor.name};else return console.warn("THREE.Texture: Unable to serialize Texture."),{}}var nY=0,GQ=new A;class E0 extends P8{constructor(J=E0.DEFAULT_IMAGE,Q=E0.DEFAULT_MAPPING,$=1001,Z=1001,W=1006,H=1008,Y=1023,X=1009,K=E0.DEFAULT_ANISOTROPY,U=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:nY++}),this.uuid=$8(),this.name="",this.source=new L6(J),this.mipmaps=[],this.mapping=Q,this.channel=0,this.wrapS=$,this.wrapT=Z,this.magFilter=W,this.minFilter=H,this.anisotropy=K,this.format=Y,this.internalFormat=null,this.type=X,this.offset=new PJ(0,0),this.repeat=new PJ(1,1),this.center=new PJ(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fJ,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=U,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=J&&J.depth&&J.depth>1?!0:!1,this.pmremVersion=0}get width(){return this.source.getSize(GQ).x}get height(){return this.source.getSize(GQ).y}get depth(){return this.source.getSize(GQ).z}get image(){return this.source.data}set image(J=null){this.source.data=J}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(J,Q){this.updateRanges.push({start:J,count:Q})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(J){return this.name=J.name,this.source=J.source,this.mipmaps=J.mipmaps.slice(0),this.mapping=J.mapping,this.channel=J.channel,this.wrapS=J.wrapS,this.wrapT=J.wrapT,this.magFilter=J.magFilter,this.minFilter=J.minFilter,this.anisotropy=J.anisotropy,this.format=J.format,this.internalFormat=J.internalFormat,this.type=J.type,this.offset.copy(J.offset),this.repeat.copy(J.repeat),this.center.copy(J.center),this.rotation=J.rotation,this.matrixAutoUpdate=J.matrixAutoUpdate,this.matrix.copy(J.matrix),this.generateMipmaps=J.generateMipmaps,this.premultiplyAlpha=J.premultiplyAlpha,this.flipY=J.flipY,this.unpackAlignment=J.unpackAlignment,this.colorSpace=J.colorSpace,this.renderTarget=J.renderTarget,this.isRenderTargetTexture=J.isRenderTargetTexture,this.isArrayTexture=J.isArrayTexture,this.userData=JSON.parse(JSON.stringify(J.userData)),this.needsUpdate=!0,this}setValues(J){for(let Q in J){let $=J[Q];if($===void 0){console.warn(`THREE.Texture.setValues(): parameter '${Q}' has value of undefined.`);continue}let Z=this[Q];if(Z===void 0){console.warn(`THREE.Texture.setValues(): property '${Q}' does not exist.`);continue}if(Z&&$&&(Z.isVector2&&$.isVector2))Z.copy($);else if(Z&&$&&(Z.isVector3&&$.isVector3))Z.copy($);else if(Z&&$&&(Z.isMatrix3&&$.isMatrix3))Z.copy($);else this[Q]=$}}toJSON(J){let Q=J===void 0||typeof J==="string";if(!Q&&J.textures[this.uuid]!==void 0)return J.textures[this.uuid];let $={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(J).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};if(Object.keys(this.userData).length>0)$.userData=this.userData;if(!Q)J.textures[this.uuid]=$;return $}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(J){if(this.mapping!==300)return J;if(J.applyMatrix3(this.matrix),J.x<0||J.x>1)switch(this.wrapS){case 1000:J.x=J.x-Math.floor(J.x);break;case 1001:J.x=J.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(J.x)%2)===1)J.x=Math.ceil(J.x)-J.x;else J.x=J.x-Math.floor(J.x);break}if(J.y<0||J.y>1)switch(this.wrapT){case 1000:J.y=J.y-Math.floor(J.y);break;case 1001:J.y=J.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(J.y)%2)===1)J.y=Math.ceil(J.y)-J.y;else J.y=J.y-Math.floor(J.y);break}if(this.flipY)J.y=1-J.y;return J}set needsUpdate(J){if(J===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(J){if(J===!0)this.pmremVersion++}}E0.DEFAULT_IMAGE=null;E0.DEFAULT_MAPPING=300;E0.DEFAULT_ANISOTROPY=1;class sJ{constructor(J=0,Q=0,$=0,Z=1){sJ.prototype.isVector4=!0,this.x=J,this.y=Q,this.z=$,this.w=Z}get width(){return this.z}set width(J){this.z=J}get height(){return this.w}set height(J){this.w=J}set(J,Q,$,Z){return this.x=J,this.y=Q,this.z=$,this.w=Z,this}setScalar(J){return this.x=J,this.y=J,this.z=J,this.w=J,this}setX(J){return this.x=J,this}setY(J){return this.y=J,this}setZ(J){return this.z=J,this}setW(J){return this.w=J,this}setComponent(J,Q){switch(J){case 0:this.x=Q;break;case 1:this.y=Q;break;case 2:this.z=Q;break;case 3:this.w=Q;break;default:throw Error("index is out of range: "+J)}return this}getComponent(J){switch(J){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+J)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(J){return this.x=J.x,this.y=J.y,this.z=J.z,this.w=J.w!==void 0?J.w:1,this}add(J){return this.x+=J.x,this.y+=J.y,this.z+=J.z,this.w+=J.w,this}addScalar(J){return this.x+=J,this.y+=J,this.z+=J,this.w+=J,this}addVectors(J,Q){return this.x=J.x+Q.x,this.y=J.y+Q.y,this.z=J.z+Q.z,this.w=J.w+Q.w,this}addScaledVector(J,Q){return this.x+=J.x*Q,this.y+=J.y*Q,this.z+=J.z*Q,this.w+=J.w*Q,this}sub(J){return this.x-=J.x,this.y-=J.y,this.z-=J.z,this.w-=J.w,this}subScalar(J){return this.x-=J,this.y-=J,this.z-=J,this.w-=J,this}subVectors(J,Q){return this.x=J.x-Q.x,this.y=J.y-Q.y,this.z=J.z-Q.z,this.w=J.w-Q.w,this}multiply(J){return this.x*=J.x,this.y*=J.y,this.z*=J.z,this.w*=J.w,this}multiplyScalar(J){return this.x*=J,this.y*=J,this.z*=J,this.w*=J,this}applyMatrix4(J){let Q=this.x,$=this.y,Z=this.z,W=this.w,H=J.elements;return this.x=H[0]*Q+H[4]*$+H[8]*Z+H[12]*W,this.y=H[1]*Q+H[5]*$+H[9]*Z+H[13]*W,this.z=H[2]*Q+H[6]*$+H[10]*Z+H[14]*W,this.w=H[3]*Q+H[7]*$+H[11]*Z+H[15]*W,this}divide(J){return this.x/=J.x,this.y/=J.y,this.z/=J.z,this.w/=J.w,this}divideScalar(J){return this.multiplyScalar(1/J)}setAxisAngleFromQuaternion(J){this.w=2*Math.acos(J.w);let Q=Math.sqrt(1-J.w*J.w);if(Q<0.0001)this.x=1,this.y=0,this.z=0;else this.x=J.x/Q,this.y=J.y/Q,this.z=J.z/Q;return this}setAxisAngleFromRotationMatrix(J){let Q,$,Z,W,H=0.01,Y=0.1,X=J.elements,K=X[0],U=X[4],G=X[8],q=X[1],E=X[5],O=X[9],k=X[2],M=X[6],N=X[10];if(Math.abs(U-q)<0.01&&Math.abs(G-k)<0.01&&Math.abs(O-M)<0.01){if(Math.abs(U+q)<0.1&&Math.abs(G+k)<0.1&&Math.abs(O+M)<0.1&&Math.abs(K+E+N-3)<0.1)return this.set(1,0,0,0),this;Q=Math.PI;let C=(K+1)/2,L=(E+1)/2,_=(N+1)/2,v=(U+q)/4,w=(G+k)/4,T=(O+M)/4;if(C>L&&C>_)if(C<0.01)$=0,Z=0.707106781,W=0.707106781;else $=Math.sqrt(C),Z=v/$,W=w/$;else if(L>_)if(L<0.01)$=0.707106781,Z=0,W=0.707106781;else Z=Math.sqrt(L),$=v/Z,W=T/Z;else if(_<0.01)$=0.707106781,Z=0.707106781,W=0;else W=Math.sqrt(_),$=w/W,Z=T/W;return this.set($,Z,W,Q),this}let F=Math.sqrt((M-O)*(M-O)+(G-k)*(G-k)+(q-U)*(q-U));if(Math.abs(F)<0.001)F=1;return this.x=(M-O)/F,this.y=(G-k)/F,this.z=(q-U)/F,this.w=Math.acos((K+E+N-1)/2),this}setFromMatrixPosition(J){let Q=J.elements;return this.x=Q[12],this.y=Q[13],this.z=Q[14],this.w=Q[15],this}min(J){return this.x=Math.min(this.x,J.x),this.y=Math.min(this.y,J.y),this.z=Math.min(this.z,J.z),this.w=Math.min(this.w,J.w),this}max(J){return this.x=Math.max(this.x,J.x),this.y=Math.max(this.y,J.y),this.z=Math.max(this.z,J.z),this.w=Math.max(this.w,J.w),this}clamp(J,Q){return this.x=xJ(this.x,J.x,Q.x),this.y=xJ(this.y,J.y,Q.y),this.z=xJ(this.z,J.z,Q.z),this.w=xJ(this.w,J.w,Q.w),this}clampScalar(J,Q){return this.x=xJ(this.x,J,Q),this.y=xJ(this.y,J,Q),this.z=xJ(this.z,J,Q),this.w=xJ(this.w,J,Q),this}clampLength(J,Q){let $=this.length();return this.divideScalar($||1).multiplyScalar(xJ($,J,Q))}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(J){return this.x*J.x+this.y*J.y+this.z*J.z+this.w*J.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(J){return this.normalize().multiplyScalar(J)}lerp(J,Q){return this.x+=(J.x-this.x)*Q,this.y+=(J.y-this.y)*Q,this.z+=(J.z-this.z)*Q,this.w+=(J.w-this.w)*Q,this}lerpVectors(J,Q,$){return this.x=J.x+(Q.x-J.x)*$,this.y=J.y+(Q.y-J.y)*$,this.z=J.z+(Q.z-J.z)*$,this.w=J.w+(Q.w-J.w)*$,this}equals(J){return J.x===this.x&&J.y===this.y&&J.z===this.z&&J.w===this.w}fromArray(J,Q=0){return this.x=J[Q],this.y=J[Q+1],this.z=J[Q+2],this.w=J[Q+3],this}toArray(J=[],Q=0){return J[Q]=this.x,J[Q+1]=this.y,J[Q+2]=this.z,J[Q+3]=this.w,J}fromBufferAttribute(J,Q){return this.x=J.getX(Q),this.y=J.getY(Q),this.z=J.getZ(Q),this.w=J.getW(Q),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class I$ extends P8{constructor(J=1,Q=1,$={}){super();$=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},$),this.isRenderTarget=!0,this.width=J,this.height=Q,this.depth=$.depth,this.scissor=new sJ(0,0,J,Q),this.scissorTest=!1,this.viewport=new sJ(0,0,J,Q);let Z={width:J,height:Q,depth:$.depth},W=new E0(Z);this.textures=[];let H=$.count;for(let Y=0;Y<H;Y++)this.textures[Y]=W.clone(),this.textures[Y].isRenderTargetTexture=!0,this.textures[Y].renderTarget=this;this._setTextureOptions($),this.depthBuffer=$.depthBuffer,this.stencilBuffer=$.stencilBuffer,this.resolveDepthBuffer=$.resolveDepthBuffer,this.resolveStencilBuffer=$.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=$.depthTexture,this.samples=$.samples,this.multiview=$.multiview}_setTextureOptions(J={}){let Q={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(J.mapping!==void 0)Q.mapping=J.mapping;if(J.wrapS!==void 0)Q.wrapS=J.wrapS;if(J.wrapT!==void 0)Q.wrapT=J.wrapT;if(J.wrapR!==void 0)Q.wrapR=J.wrapR;if(J.magFilter!==void 0)Q.magFilter=J.magFilter;if(J.minFilter!==void 0)Q.minFilter=J.minFilter;if(J.format!==void 0)Q.format=J.format;if(J.type!==void 0)Q.type=J.type;if(J.anisotropy!==void 0)Q.anisotropy=J.anisotropy;if(J.colorSpace!==void 0)Q.colorSpace=J.colorSpace;if(J.flipY!==void 0)Q.flipY=J.flipY;if(J.generateMipmaps!==void 0)Q.generateMipmaps=J.generateMipmaps;if(J.internalFormat!==void 0)Q.internalFormat=J.internalFormat;for(let $=0;$<this.textures.length;$++)this.textures[$].setValues(Q)}get texture(){return this.textures[0]}set texture(J){this.textures[0]=J}set depthTexture(J){if(this._depthTexture!==null)this._depthTexture.renderTarget=null;if(J!==null)J.renderTarget=this;this._depthTexture=J}get depthTexture(){return this._depthTexture}setSize(J,Q,$=1){if(this.width!==J||this.height!==Q||this.depth!==$){this.width=J,this.height=Q,this.depth=$;for(let Z=0,W=this.textures.length;Z<W;Z++)this.textures[Z].image.width=J,this.textures[Z].image.height=Q,this.textures[Z].image.depth=$,this.textures[Z].isArrayTexture=this.textures[Z].image.depth>1;this.dispose()}this.viewport.set(0,0,J,Q),this.scissor.set(0,0,J,Q)}clone(){return new this.constructor().copy(this)}copy(J){this.width=J.width,this.height=J.height,this.depth=J.depth,this.scissor.copy(J.scissor),this.scissorTest=J.scissorTest,this.viewport.copy(J.viewport),this.textures.length=0;for(let Q=0,$=J.textures.length;Q<$;Q++){this.textures[Q]=J.textures[Q].clone(),this.textures[Q].isRenderTargetTexture=!0,this.textures[Q].renderTarget=this;let Z=Object.assign({},J.textures[Q].image);this.textures[Q].source=new L6(Z)}if(this.depthBuffer=J.depthBuffer,this.stencilBuffer=J.stencilBuffer,this.resolveDepthBuffer=J.resolveDepthBuffer,this.resolveStencilBuffer=J.resolveStencilBuffer,J.depthTexture!==null)this.depthTexture=J.depthTexture.clone();return this.samples=J.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class T8 extends I${constructor(J=1,Q=1,$={}){super(J,Q,$);this.isWebGLRenderTarget=!0}}class P7 extends E0{constructor(J=null,Q=1,$=1,Z=1){super(null);this.isDataArrayTexture=!0,this.image={data:J,width:Q,height:$,depth:Z},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(J){this.layerUpdates.add(J)}clearLayerUpdates(){this.layerUpdates.clear()}}class P$ extends E0{constructor(J=null,Q=1,$=1,Z=1){super(null);this.isData3DTexture=!0,this.image={data:J,width:Q,height:$,depth:Z},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class A0{constructor(J=new A(1/0,1/0,1/0),Q=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=J,this.max=Q}set(J,Q){return this.min.copy(J),this.max.copy(Q),this}setFromArray(J){this.makeEmpty();for(let Q=0,$=J.length;Q<$;Q+=3)this.expandByPoint(r0.fromArray(J,Q));return this}setFromBufferAttribute(J){this.makeEmpty();for(let Q=0,$=J.count;Q<$;Q++)this.expandByPoint(r0.fromBufferAttribute(J,Q));return this}setFromPoints(J){this.makeEmpty();for(let Q=0,$=J.length;Q<$;Q++)this.expandByPoint(J[Q]);return this}setFromCenterAndSize(J,Q){let $=r0.copy(Q).multiplyScalar(0.5);return this.min.copy(J).sub($),this.max.copy(J).add($),this}setFromObject(J,Q=!1){return this.makeEmpty(),this.expandByObject(J,Q)}clone(){return new this.constructor().copy(this)}copy(J){return this.min.copy(J.min),this.max.copy(J.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(J){return this.isEmpty()?J.set(0,0,0):J.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(J){return this.isEmpty()?J.set(0,0,0):J.subVectors(this.max,this.min)}expandByPoint(J){return this.min.min(J),this.max.max(J),this}expandByVector(J){return this.min.sub(J),this.max.add(J),this}expandByScalar(J){return this.min.addScalar(-J),this.max.addScalar(J),this}expandByObject(J,Q=!1){J.updateWorldMatrix(!1,!1);let $=J.geometry;if($!==void 0){let W=$.getAttribute("position");if(Q===!0&&W!==void 0&&J.isInstancedMesh!==!0)for(let H=0,Y=W.count;H<Y;H++){if(J.isMesh===!0)J.getVertexPosition(H,r0);else r0.fromBufferAttribute(W,H);r0.applyMatrix4(J.matrixWorld),this.expandByPoint(r0)}else{if(J.boundingBox!==void 0){if(J.boundingBox===null)J.computeBoundingBox();h6.copy(J.boundingBox)}else{if($.boundingBox===null)$.computeBoundingBox();h6.copy($.boundingBox)}h6.applyMatrix4(J.matrixWorld),this.union(h6)}}let Z=J.children;for(let W=0,H=Z.length;W<H;W++)this.expandByObject(Z[W],Q);return this}containsPoint(J){return J.x>=this.min.x&&J.x<=this.max.x&&J.y>=this.min.y&&J.y<=this.max.y&&J.z>=this.min.z&&J.z<=this.max.z}containsBox(J){return this.min.x<=J.min.x&&J.max.x<=this.max.x&&this.min.y<=J.min.y&&J.max.y<=this.max.y&&this.min.z<=J.min.z&&J.max.z<=this.max.z}getParameter(J,Q){return Q.set((J.x-this.min.x)/(this.max.x-this.min.x),(J.y-this.min.y)/(this.max.y-this.min.y),(J.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(J){return J.max.x>=this.min.x&&J.min.x<=this.max.x&&J.max.y>=this.min.y&&J.min.y<=this.max.y&&J.max.z>=this.min.z&&J.min.z<=this.max.z}intersectsSphere(J){return this.clampPoint(J.center,r0),r0.distanceToSquared(J.center)<=J.radius*J.radius}intersectsPlane(J){let Q,$;if(J.normal.x>0)Q=J.normal.x*this.min.x,$=J.normal.x*this.max.x;else Q=J.normal.x*this.max.x,$=J.normal.x*this.min.x;if(J.normal.y>0)Q+=J.normal.y*this.min.y,$+=J.normal.y*this.max.y;else Q+=J.normal.y*this.max.y,$+=J.normal.y*this.min.y;if(J.normal.z>0)Q+=J.normal.z*this.min.z,$+=J.normal.z*this.max.z;else Q+=J.normal.z*this.max.z,$+=J.normal.z*this.min.z;return Q<=-J.constant&&$>=-J.constant}intersectsTriangle(J){if(this.isEmpty())return!1;this.getCenter($6),b6.subVectors(this.max,$6),L9.subVectors(J.a,$6),V9.subVectors(J.b,$6),z9.subVectors(J.c,$6),v8.subVectors(V9,L9),f8.subVectors(z9,V9),J9.subVectors(L9,z9);let Q=[0,-v8.z,v8.y,0,-f8.z,f8.y,0,-J9.z,J9.y,v8.z,0,-v8.x,f8.z,0,-f8.x,J9.z,0,-J9.x,-v8.y,v8.x,0,-f8.y,f8.x,0,-J9.y,J9.x,0];if(!qQ(Q,L9,V9,z9,b6))return!1;if(Q=[1,0,0,0,1,0,0,0,1],!qQ(Q,L9,V9,z9,b6))return!1;return x6.crossVectors(v8,f8),Q=[x6.x,x6.y,x6.z],qQ(Q,L9,V9,z9,b6)}clampPoint(J,Q){return Q.copy(J).clamp(this.min,this.max)}distanceToPoint(J){return this.clampPoint(J,r0).distanceTo(J)}getBoundingSphere(J){if(this.isEmpty())J.makeEmpty();else this.getCenter(J.center),J.radius=this.getSize(r0).length()*0.5;return J}intersect(J){if(this.min.max(J.min),this.max.min(J.max),this.isEmpty())this.makeEmpty();return this}union(J){return this.min.min(J.min),this.max.max(J.max),this}applyMatrix4(J){if(this.isEmpty())return this;return R8[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(J),R8[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(J),R8[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(J),R8[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(J),R8[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(J),R8[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(J),R8[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(J),R8[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(J),this.setFromPoints(R8),this}translate(J){return this.min.add(J),this.max.add(J),this}equals(J){return J.min.equals(this.min)&&J.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(J){return this.min.fromArray(J.min),this.max.fromArray(J.max),this}}var R8=[new A,new A,new A,new A,new A,new A,new A,new A],r0=new A,h6=new A0,L9=new A,V9=new A,z9=new A,v8=new A,f8=new A,J9=new A,$6=new A,b6=new A,x6=new A,Q9=new A;function qQ(J,Q,$,Z,W){for(let H=0,Y=J.length-3;H<=Y;H+=3){Q9.fromArray(J,H);let X=W.x*Math.abs(Q9.x)+W.y*Math.abs(Q9.y)+W.z*Math.abs(Q9.z),K=Q.dot(Q9),U=$.dot(Q9),G=Z.dot(Q9);if(Math.max(-Math.max(K,U,G),Math.min(K,U,G))>X)return!1}return!0}var sY=new A0,Z6=new A,EQ=new A;class p0{constructor(J=new A,Q=-1){this.isSphere=!0,this.center=J,this.radius=Q}set(J,Q){return this.center.copy(J),this.radius=Q,this}setFromPoints(J,Q){let $=this.center;if(Q!==void 0)$.copy(Q);else sY.setFromPoints(J).getCenter($);let Z=0;for(let W=0,H=J.length;W<H;W++)Z=Math.max(Z,$.distanceToSquared(J[W]));return this.radius=Math.sqrt(Z),this}copy(J){return this.center.copy(J.center),this.radius=J.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(J){return J.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(J){return J.distanceTo(this.center)-this.radius}intersectsSphere(J){let Q=this.radius+J.radius;return J.center.distanceToSquared(this.center)<=Q*Q}intersectsBox(J){return J.intersectsSphere(this)}intersectsPlane(J){return Math.abs(J.distanceToPoint(this.center))<=this.radius}clampPoint(J,Q){let $=this.center.distanceToSquared(J);if(Q.copy(J),$>this.radius*this.radius)Q.sub(this.center).normalize(),Q.multiplyScalar(this.radius).add(this.center);return Q}getBoundingBox(J){if(this.isEmpty())return J.makeEmpty(),J;return J.set(this.center,this.center),J.expandByScalar(this.radius),J}applyMatrix4(J){return this.center.applyMatrix4(J),this.radius=this.radius*J.getMaxScaleOnAxis(),this}translate(J){return this.center.add(J),this}expandByPoint(J){if(this.isEmpty())return this.center.copy(J),this.radius=0,this;Z6.subVectors(J,this.center);let Q=Z6.lengthSq();if(Q>this.radius*this.radius){let $=Math.sqrt(Q),Z=($-this.radius)*0.5;this.center.addScaledVector(Z6,Z/$),this.radius+=Z}return this}union(J){if(J.isEmpty())return this;if(this.isEmpty())return this.copy(J),this;if(this.center.equals(J.center)===!0)this.radius=Math.max(this.radius,J.radius);else EQ.subVectors(J.center,this.center).setLength(J.radius),this.expandByPoint(Z6.copy(J.center).add(EQ)),this.expandByPoint(Z6.copy(J.center).sub(EQ));return this}equals(J){return J.center.equals(this.center)&&J.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(J){return this.radius=J.radius,this.center.fromArray(J.center),this}}var k8=new A,NQ=new A,g6=new A,h8=new A,OQ=new A,p6=new A,FQ=new A;class n8{constructor(J=new A,Q=new A(0,0,-1)){this.origin=J,this.direction=Q}set(J,Q){return this.origin.copy(J),this.direction.copy(Q),this}copy(J){return this.origin.copy(J.origin),this.direction.copy(J.direction),this}at(J,Q){return Q.copy(this.origin).addScaledVector(this.direction,J)}lookAt(J){return this.direction.copy(J).sub(this.origin).normalize(),this}recast(J){return this.origin.copy(this.at(J,k8)),this}closestPointToPoint(J,Q){Q.subVectors(J,this.origin);let $=Q.dot(this.direction);if($<0)return Q.copy(this.origin);return Q.copy(this.origin).addScaledVector(this.direction,$)}distanceToPoint(J){return Math.sqrt(this.distanceSqToPoint(J))}distanceSqToPoint(J){let Q=k8.subVectors(J,this.origin).dot(this.direction);if(Q<0)return this.origin.distanceToSquared(J);return k8.copy(this.origin).addScaledVector(this.direction,Q),k8.distanceToSquared(J)}distanceSqToSegment(J,Q,$,Z){NQ.copy(J).add(Q).multiplyScalar(0.5),g6.copy(Q).sub(J).normalize(),h8.copy(this.origin).sub(NQ);let W=J.distanceTo(Q)*0.5,H=-this.direction.dot(g6),Y=h8.dot(this.direction),X=-h8.dot(g6),K=h8.lengthSq(),U=Math.abs(1-H*H),G,q,E,O;if(U>0)if(G=H*X-Y,q=H*Y-X,O=W*U,G>=0)if(q>=-O)if(q<=O){let k=1/U;G*=k,q*=k,E=G*(G+H*q+2*Y)+q*(H*G+q+2*X)+K}else q=W,G=Math.max(0,-(H*q+Y)),E=-G*G+q*(q+2*X)+K;else q=-W,G=Math.max(0,-(H*q+Y)),E=-G*G+q*(q+2*X)+K;else if(q<=-O)G=Math.max(0,-(-H*W+Y)),q=G>0?-W:Math.min(Math.max(-W,-X),W),E=-G*G+q*(q+2*X)+K;else if(q<=O)G=0,q=Math.min(Math.max(-W,-X),W),E=q*(q+2*X)+K;else G=Math.max(0,-(H*W+Y)),q=G>0?W:Math.min(Math.max(-W,-X),W),E=-G*G+q*(q+2*X)+K;else q=H>0?-W:W,G=Math.max(0,-(H*q+Y)),E=-G*G+q*(q+2*X)+K;if($)$.copy(this.origin).addScaledVector(this.direction,G);if(Z)Z.copy(NQ).addScaledVector(g6,q);return E}intersectSphere(J,Q){k8.subVectors(J.center,this.origin);let $=k8.dot(this.direction),Z=k8.dot(k8)-$*$,W=J.radius*J.radius;if(Z>W)return null;let H=Math.sqrt(W-Z),Y=$-H,X=$+H;if(X<0)return null;if(Y<0)return this.at(X,Q);return this.at(Y,Q)}intersectsSphere(J){if(J.radius<0)return!1;return this.distanceSqToPoint(J.center)<=J.radius*J.radius}distanceToPlane(J){let Q=J.normal.dot(this.direction);if(Q===0){if(J.distanceToPoint(this.origin)===0)return 0;return null}let $=-(this.origin.dot(J.normal)+J.constant)/Q;return $>=0?$:null}intersectPlane(J,Q){let $=this.distanceToPlane(J);if($===null)return null;return this.at($,Q)}intersectsPlane(J){let Q=J.distanceToPoint(this.origin);if(Q===0)return!0;if(J.normal.dot(this.direction)*Q<0)return!0;return!1}intersectBox(J,Q){let $,Z,W,H,Y,X,K=1/this.direction.x,U=1/this.direction.y,G=1/this.direction.z,q=this.origin;if(K>=0)$=(J.min.x-q.x)*K,Z=(J.max.x-q.x)*K;else $=(J.max.x-q.x)*K,Z=(J.min.x-q.x)*K;if(U>=0)W=(J.min.y-q.y)*U,H=(J.max.y-q.y)*U;else W=(J.max.y-q.y)*U,H=(J.min.y-q.y)*U;if($>H||W>Z)return null;if(W>$||isNaN($))$=W;if(H<Z||isNaN(Z))Z=H;if(G>=0)Y=(J.min.z-q.z)*G,X=(J.max.z-q.z)*G;else Y=(J.max.z-q.z)*G,X=(J.min.z-q.z)*G;if($>X||Y>Z)return null;if(Y>$||$!==$)$=Y;if(X<Z||Z!==Z)Z=X;if(Z<0)return null;return this.at($>=0?$:Z,Q)}intersectsBox(J){return this.intersectBox(J,k8)!==null}intersectTriangle(J,Q,$,Z,W){OQ.subVectors(Q,J),p6.subVectors($,J),FQ.crossVectors(OQ,p6);let H=this.direction.dot(FQ),Y;if(H>0){if(Z)return null;Y=1}else if(H<0)Y=-1,H=-H;else return null;h8.subVectors(this.origin,J);let X=Y*this.direction.dot(p6.crossVectors(h8,p6));if(X<0)return null;let K=Y*this.direction.dot(OQ.cross(h8));if(K<0)return null;if(X+K>H)return null;let U=-Y*h8.dot(FQ);if(U<0)return null;return this.at(U/H,W)}applyMatrix4(J){return this.origin.applyMatrix4(J),this.direction.transformDirection(J),this}equals(J){return J.origin.equals(this.origin)&&J.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class vJ{constructor(J,Q,$,Z,W,H,Y,X,K,U,G,q,E,O,k,M){if(vJ.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],J!==void 0)this.set(J,Q,$,Z,W,H,Y,X,K,U,G,q,E,O,k,M)}set(J,Q,$,Z,W,H,Y,X,K,U,G,q,E,O,k,M){let N=this.elements;return N[0]=J,N[4]=Q,N[8]=$,N[12]=Z,N[1]=W,N[5]=H,N[9]=Y,N[13]=X,N[2]=K,N[6]=U,N[10]=G,N[14]=q,N[3]=E,N[7]=O,N[11]=k,N[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 vJ().fromArray(this.elements)}copy(J){let Q=this.elements,$=J.elements;return Q[0]=$[0],Q[1]=$[1],Q[2]=$[2],Q[3]=$[3],Q[4]=$[4],Q[5]=$[5],Q[6]=$[6],Q[7]=$[7],Q[8]=$[8],Q[9]=$[9],Q[10]=$[10],Q[11]=$[11],Q[12]=$[12],Q[13]=$[13],Q[14]=$[14],Q[15]=$[15],this}copyPosition(J){let Q=this.elements,$=J.elements;return Q[12]=$[12],Q[13]=$[13],Q[14]=$[14],this}setFromMatrix3(J){let Q=J.elements;return this.set(Q[0],Q[3],Q[6],0,Q[1],Q[4],Q[7],0,Q[2],Q[5],Q[8],0,0,0,0,1),this}extractBasis(J,Q,$){return J.setFromMatrixColumn(this,0),Q.setFromMatrixColumn(this,1),$.setFromMatrixColumn(this,2),this}makeBasis(J,Q,$){return this.set(J.x,Q.x,$.x,0,J.y,Q.y,$.y,0,J.z,Q.z,$.z,0,0,0,0,1),this}extractRotation(J){let Q=this.elements,$=J.elements,Z=1/B9.setFromMatrixColumn(J,0).length(),W=1/B9.setFromMatrixColumn(J,1).length(),H=1/B9.setFromMatrixColumn(J,2).length();return Q[0]=$[0]*Z,Q[1]=$[1]*Z,Q[2]=$[2]*Z,Q[3]=0,Q[4]=$[4]*W,Q[5]=$[5]*W,Q[6]=$[6]*W,Q[7]=0,Q[8]=$[8]*H,Q[9]=$[9]*H,Q[10]=$[10]*H,Q[11]=0,Q[12]=0,Q[13]=0,Q[14]=0,Q[15]=1,this}makeRotationFromEuler(J){let Q=this.elements,$=J.x,Z=J.y,W=J.z,H=Math.cos($),Y=Math.sin($),X=Math.cos(Z),K=Math.sin(Z),U=Math.cos(W),G=Math.sin(W);if(J.order==="XYZ"){let q=H*U,E=H*G,O=Y*U,k=Y*G;Q[0]=X*U,Q[4]=-X*G,Q[8]=K,Q[1]=E+O*K,Q[5]=q-k*K,Q[9]=-Y*X,Q[2]=k-q*K,Q[6]=O+E*K,Q[10]=H*X}else if(J.order==="YXZ"){let q=X*U,E=X*G,O=K*U,k=K*G;Q[0]=q+k*Y,Q[4]=O*Y-E,Q[8]=H*K,Q[1]=H*G,Q[5]=H*U,Q[9]=-Y,Q[2]=E*Y-O,Q[6]=k+q*Y,Q[10]=H*X}else if(J.order==="ZXY"){let q=X*U,E=X*G,O=K*U,k=K*G;Q[0]=q-k*Y,Q[4]=-H*G,Q[8]=O+E*Y,Q[1]=E+O*Y,Q[5]=H*U,Q[9]=k-q*Y,Q[2]=-H*K,Q[6]=Y,Q[10]=H*X}else if(J.order==="ZYX"){let q=H*U,E=H*G,O=Y*U,k=Y*G;Q[0]=X*U,Q[4]=O*K-E,Q[8]=q*K+k,Q[1]=X*G,Q[5]=k*K+q,Q[9]=E*K-O,Q[2]=-K,Q[6]=Y*X,Q[10]=H*X}else if(J.order==="YZX"){let q=H*X,E=H*K,O=Y*X,k=Y*K;Q[0]=X*U,Q[4]=k-q*G,Q[8]=O*G+E,Q[1]=G,Q[5]=H*U,Q[9]=-Y*U,Q[2]=-K*U,Q[6]=E*G+O,Q[10]=q-k*G}else if(J.order==="XZY"){let q=H*X,E=H*K,O=Y*X,k=Y*K;Q[0]=X*U,Q[4]=-G,Q[8]=K*U,Q[1]=q*G+k,Q[5]=H*U,Q[9]=E*G-O,Q[2]=O*G-E,Q[6]=Y*U,Q[10]=k*G+q}return Q[3]=0,Q[7]=0,Q[11]=0,Q[12]=0,Q[13]=0,Q[14]=0,Q[15]=1,this}makeRotationFromQuaternion(J){return this.compose(oY,J,iY)}lookAt(J,Q,$){let Z=this.elements;if(b0.subVectors(J,Q),b0.lengthSq()===0)b0.z=1;if(b0.normalize(),b8.crossVectors($,b0),b8.lengthSq()===0){if(Math.abs($.z)===1)b0.x+=0.0001;else b0.z+=0.0001;b0.normalize(),b8.crossVectors($,b0)}return b8.normalize(),l6.crossVectors(b0,b8),Z[0]=b8.x,Z[4]=l6.x,Z[8]=b0.x,Z[1]=b8.y,Z[5]=l6.y,Z[9]=b0.y,Z[2]=b8.z,Z[6]=l6.z,Z[10]=b0.z,this}multiply(J){return this.multiplyMatrices(this,J)}premultiply(J){return this.multiplyMatrices(J,this)}multiplyMatrices(J,Q){let $=J.elements,Z=Q.elements,W=this.elements,H=$[0],Y=$[4],X=$[8],K=$[12],U=$[1],G=$[5],q=$[9],E=$[13],O=$[2],k=$[6],M=$[10],N=$[14],F=$[3],C=$[7],L=$[11],_=$[15],v=Z[0],w=Z[4],T=Z[8],x=Z[12],z=Z[1],V=Z[5],j=Z[9],m=Z[13],l=Z[2],c=Z[6],i=Z[10],u=Z[14],r=Z[3],g=Z[7],ZJ=Z[11],UJ=Z[15];return W[0]=H*v+Y*z+X*l+K*r,W[4]=H*w+Y*V+X*c+K*g,W[8]=H*T+Y*j+X*i+K*ZJ,W[12]=H*x+Y*m+X*u+K*UJ,W[1]=U*v+G*z+q*l+E*r,W[5]=U*w+G*V+q*c+E*g,W[9]=U*T+G*j+q*i+E*ZJ,W[13]=U*x+G*m+q*u+E*UJ,W[2]=O*v+k*z+M*l+N*r,W[6]=O*w+k*V+M*c+N*g,W[10]=O*T+k*j+M*i+N*ZJ,W[14]=O*x+k*m+M*u+N*UJ,W[3]=F*v+C*z+L*l+_*r,W[7]=F*w+C*V+L*c+_*g,W[11]=F*T+C*j+L*i+_*ZJ,W[15]=F*x+C*m+L*u+_*UJ,this}multiplyScalar(J){let Q=this.elements;return Q[0]*=J,Q[4]*=J,Q[8]*=J,Q[12]*=J,Q[1]*=J,Q[5]*=J,Q[9]*=J,Q[13]*=J,Q[2]*=J,Q[6]*=J,Q[10]*=J,Q[14]*=J,Q[3]*=J,Q[7]*=J,Q[11]*=J,Q[15]*=J,this}determinant(){let J=this.elements,Q=J[0],$=J[4],Z=J[8],W=J[12],H=J[1],Y=J[5],X=J[9],K=J[13],U=J[2],G=J[6],q=J[10],E=J[14],O=J[3],k=J[7],M=J[11],N=J[15];return O*(+W*X*G-Z*K*G-W*Y*q+$*K*q+Z*Y*E-$*X*E)+k*(+Q*X*E-Q*K*q+W*H*q-Z*H*E+Z*K*U-W*X*U)+M*(+Q*K*G-Q*Y*E-W*H*G+$*H*E+W*Y*U-$*K*U)+N*(-Z*Y*U-Q*X*G+Q*Y*q+Z*H*G-$*H*q+$*X*U)}transpose(){let J=this.elements,Q;return Q=J[1],J[1]=J[4],J[4]=Q,Q=J[2],J[2]=J[8],J[8]=Q,Q=J[6],J[6]=J[9],J[9]=Q,Q=J[3],J[3]=J[12],J[12]=Q,Q=J[7],J[7]=J[13],J[13]=Q,Q=J[11],J[11]=J[14],J[14]=Q,this}setPosition(J,Q,$){let Z=this.elements;if(J.isVector3)Z[12]=J.x,Z[13]=J.y,Z[14]=J.z;else Z[12]=J,Z[13]=Q,Z[14]=$;return this}invert(){let J=this.elements,Q=J[0],$=J[1],Z=J[2],W=J[3],H=J[4],Y=J[5],X=J[6],K=J[7],U=J[8],G=J[9],q=J[10],E=J[11],O=J[12],k=J[13],M=J[14],N=J[15],F=G*M*K-k*q*K+k*X*E-Y*M*E-G*X*N+Y*q*N,C=O*q*K-U*M*K-O*X*E+H*M*E+U*X*N-H*q*N,L=U*k*K-O*G*K+O*Y*E-H*k*E-U*Y*N+H*G*N,_=O*G*X-U*k*X-O*Y*q+H*k*q+U*Y*M-H*G*M,v=Q*F+$*C+Z*L+W*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/v;return J[0]=F*w,J[1]=(k*q*W-G*M*W-k*Z*E+$*M*E+G*Z*N-$*q*N)*w,J[2]=(Y*M*W-k*X*W+k*Z*K-$*M*K-Y*Z*N+$*X*N)*w,J[3]=(G*X*W-Y*q*W-G*Z*K+$*q*K+Y*Z*E-$*X*E)*w,J[4]=C*w,J[5]=(U*M*W-O*q*W+O*Z*E-Q*M*E-U*Z*N+Q*q*N)*w,J[6]=(O*X*W-H*M*W-O*Z*K+Q*M*K+H*Z*N-Q*X*N)*w,J[7]=(H*q*W-U*X*W+U*Z*K-Q*q*K-H*Z*E+Q*X*E)*w,J[8]=L*w,J[9]=(O*G*W-U*k*W-O*$*E+Q*k*E+U*$*N-Q*G*N)*w,J[10]=(H*k*W-O*Y*W+O*$*K-Q*k*K-H*$*N+Q*Y*N)*w,J[11]=(U*Y*W-H*G*W-U*$*K+Q*G*K+H*$*E-Q*Y*E)*w,J[12]=_*w,J[13]=(U*k*Z-O*G*Z+O*$*q-Q*k*q-U*$*M+Q*G*M)*w,J[14]=(O*Y*Z-H*k*Z-O*$*X+Q*k*X+H*$*M-Q*Y*M)*w,J[15]=(H*G*Z-U*Y*Z+U*$*X-Q*G*X-H*$*q+Q*Y*q)*w,this}scale(J){let Q=this.elements,$=J.x,Z=J.y,W=J.z;return Q[0]*=$,Q[4]*=Z,Q[8]*=W,Q[1]*=$,Q[5]*=Z,Q[9]*=W,Q[2]*=$,Q[6]*=Z,Q[10]*=W,Q[3]*=$,Q[7]*=Z,Q[11]*=W,this}getMaxScaleOnAxis(){let J=this.elements,Q=J[0]*J[0]+J[1]*J[1]+J[2]*J[2],$=J[4]*J[4]+J[5]*J[5]+J[6]*J[6],Z=J[8]*J[8]+J[9]*J[9]+J[10]*J[10];return Math.sqrt(Math.max(Q,$,Z))}makeTranslation(J,Q,$){if(J.isVector3)this.set(1,0,0,J.x,0,1,0,J.y,0,0,1,J.z,0,0,0,1);else this.set(1,0,0,J,0,1,0,Q,0,0,1,$,0,0,0,1);return this}makeRotationX(J){let Q=Math.cos(J),$=Math.sin(J);return this.set(1,0,0,0,0,Q,-$,0,0,$,Q,0,0,0,0,1),this}makeRotationY(J){let Q=Math.cos(J),$=Math.sin(J);return this.set(Q,0,$,0,0,1,0,0,-$,0,Q,0,0,0,0,1),this}makeRotationZ(J){let Q=Math.cos(J),$=Math.sin(J);return this.set(Q,-$,0,0,$,Q,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(J,Q){let $=Math.cos(Q),Z=Math.sin(Q),W=1-$,H=J.x,Y=J.y,X=J.z,K=W*H,U=W*Y;return this.set(K*H+$,K*Y-Z*X,K*X+Z*Y,0,K*Y+Z*X,U*Y+$,U*X-Z*H,0,K*X-Z*Y,U*X+Z*H,W*X*X+$,0,0,0,0,1),this}makeScale(J,Q,$){return this.set(J,0,0,0,0,Q,0,0,0,0,$,0,0,0,0,1),this}makeShear(J,Q,$,Z,W,H){return this.set(1,$,W,0,J,1,H,0,Q,Z,1,0,0,0,0,1),this}compose(J,Q,$){let Z=this.elements,W=Q._x,H=Q._y,Y=Q._z,X=Q._w,K=W+W,U=H+H,G=Y+Y,q=W*K,E=W*U,O=W*G,k=H*U,M=H*G,N=Y*G,F=X*K,C=X*U,L=X*G,_=$.x,v=$.y,w=$.z;return Z[0]=(1-(k+N))*_,Z[1]=(E+L)*_,Z[2]=(O-C)*_,Z[3]=0,Z[4]=(E-L)*v,Z[5]=(1-(q+N))*v,Z[6]=(M+F)*v,Z[7]=0,Z[8]=(O+C)*w,Z[9]=(M-F)*w,Z[10]=(1-(q+k))*w,Z[11]=0,Z[12]=J.x,Z[13]=J.y,Z[14]=J.z,Z[15]=1,this}decompose(J,Q,$){let Z=this.elements,W=B9.set(Z[0],Z[1],Z[2]).length(),H=B9.set(Z[4],Z[5],Z[6]).length(),Y=B9.set(Z[8],Z[9],Z[10]).length();if(this.determinant()<0)W=-W;J.x=Z[12],J.y=Z[13],J.z=Z[14],t0.copy(this);let K=1/W,U=1/H,G=1/Y;return t0.elements[0]*=K,t0.elements[1]*=K,t0.elements[2]*=K,t0.elements[4]*=U,t0.elements[5]*=U,t0.elements[6]*=U,t0.elements[8]*=G,t0.elements[9]*=G,t0.elements[10]*=G,Q.setFromRotationMatrix(t0),$.x=W,$.y=H,$.z=Y,this}makePerspective(J,Q,$,Z,W,H,Y=2000,X=!1){let K=this.elements,U=2*W/(Q-J),G=2*W/($-Z),q=(Q+J)/(Q-J),E=($+Z)/($-Z),O,k;if(X)O=W/(H-W),k=H*W/(H-W);else if(Y===2000)O=-(H+W)/(H-W),k=-2*H*W/(H-W);else if(Y===2001)O=-H/(H-W),k=-H*W/(H-W);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+Y);return K[0]=U,K[4]=0,K[8]=q,K[12]=0,K[1]=0,K[5]=G,K[9]=E,K[13]=0,K[2]=0,K[6]=0,K[10]=O,K[14]=k,K[3]=0,K[7]=0,K[11]=-1,K[15]=0,this}makeOrthographic(J,Q,$,Z,W,H,Y=2000,X=!1){let K=this.elements,U=2/(Q-J),G=2/($-Z),q=-(Q+J)/(Q-J),E=-($+Z)/($-Z),O,k;if(X)O=1/(H-W),k=H/(H-W);else if(Y===2000)O=-2/(H-W),k=-(H+W)/(H-W);else if(Y===2001)O=-1/(H-W),k=-W/(H-W);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+Y);return K[0]=U,K[4]=0,K[8]=0,K[12]=q,K[1]=0,K[5]=G,K[9]=0,K[13]=E,K[2]=0,K[6]=0,K[10]=O,K[14]=k,K[3]=0,K[7]=0,K[11]=0,K[15]=1,this}equals(J){let Q=this.elements,$=J.elements;for(let Z=0;Z<16;Z++)if(Q[Z]!==$[Z])return!1;return!0}fromArray(J,Q=0){for(let $=0;$<16;$++)this.elements[$]=J[$+Q];return this}toArray(J=[],Q=0){let $=this.elements;return J[Q]=$[0],J[Q+1]=$[1],J[Q+2]=$[2],J[Q+3]=$[3],J[Q+4]=$[4],J[Q+5]=$[5],J[Q+6]=$[6],J[Q+7]=$[7],J[Q+8]=$[8],J[Q+9]=$[9],J[Q+10]=$[10],J[Q+11]=$[11],J[Q+12]=$[12],J[Q+13]=$[13],J[Q+14]=$[14],J[Q+15]=$[15],J}}var B9=new A,t0=new vJ,oY=new A(0,0,0),iY=new A(1,1,1),b8=new A,l6=new A,b0=new A,BZ=new vJ,CZ=new y0;class Z8{constructor(J=0,Q=0,$=0,Z=Z8.DEFAULT_ORDER){this.isEuler=!0,this._x=J,this._y=Q,this._z=$,this._order=Z}get x(){return this._x}set x(J){this._x=J,this._onChangeCallback()}get y(){return this._y}set y(J){this._y=J,this._onChangeCallback()}get z(){return this._z}set z(J){this._z=J,this._onChangeCallback()}get order(){return this._order}set order(J){this._order=J,this._onChangeCallback()}set(J,Q,$,Z=this._order){return this._x=J,this._y=Q,this._z=$,this._order=Z,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(J){return this._x=J._x,this._y=J._y,this._z=J._z,this._order=J._order,this._onChangeCallback(),this}setFromRotationMatrix(J,Q=this._order,$=!0){let Z=J.elements,W=Z[0],H=Z[4],Y=Z[8],X=Z[1],K=Z[5],U=Z[9],G=Z[2],q=Z[6],E=Z[10];switch(Q){case"XYZ":if(this._y=Math.asin(xJ(Y,-1,1)),Math.abs(Y)<0.9999999)this._x=Math.atan2(-U,E),this._z=Math.atan2(-H,W);else this._x=Math.atan2(q,K),this._z=0;break;case"YXZ":if(this._x=Math.asin(-xJ(U,-1,1)),Math.abs(U)<0.9999999)this._y=Math.atan2(Y,E),this._z=Math.atan2(X,K);else this._y=Math.atan2(-G,W),this._z=0;break;case"ZXY":if(this._x=Math.asin(xJ(q,-1,1)),Math.abs(q)<0.9999999)this._y=Math.atan2(-G,E),this._z=Math.atan2(-H,K);else this._y=0,this._z=Math.atan2(X,W);break;case"ZYX":if(this._y=Math.asin(-xJ(G,-1,1)),Math.abs(G)<0.9999999)this._x=Math.atan2(q,E),this._z=Math.atan2(X,W);else this._x=0,this._z=Math.atan2(-H,K);break;case"YZX":if(this._z=Math.asin(xJ(X,-1,1)),Math.abs(X)<0.9999999)this._x=Math.atan2(-U,K),this._y=Math.atan2(-G,W);else this._x=0,this._y=Math.atan2(Y,E);break;case"XZY":if(this._z=Math.asin(-xJ(H,-1,1)),Math.abs(H)<0.9999999)this._x=Math.atan2(q,K),this._y=Math.atan2(Y,W);else this._x=Math.atan2(-U,E),this._y=0;break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+Q)}if(this._order=Q,$===!0)this._onChangeCallback();return this}setFromQuaternion(J,Q,$){return BZ.makeRotationFromQuaternion(J),this.setFromRotationMatrix(BZ,Q,$)}setFromVector3(J,Q=this._order){return this.set(J.x,J.y,J.z,Q)}reorder(J){return CZ.setFromEuler(this),this.setFromQuaternion(CZ,J)}equals(J){return J._x===this._x&&J._y===this._y&&J._z===this._z&&J._order===this._order}fromArray(J){if(this._x=J[0],this._y=J[1],this._z=J[2],J[3]!==void 0)this._order=J[3];return this._onChangeCallback(),this}toArray(J=[],Q=0){return J[Q]=this._x,J[Q+1]=this._y,J[Q+2]=this._z,J[Q+3]=this._order,J}_onChange(J){return this._onChangeCallback=J,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Z8.DEFAULT_ORDER="XYZ";class T7{constructor(){this.mask=1}set(J){this.mask=(1<<J|0)>>>0}enable(J){this.mask|=1<<J|0}enableAll(){this.mask=-1}toggle(J){this.mask^=1<<J|0}disable(J){this.mask&=~(1<<J|0)}disableAll(){this.mask=0}test(J){return(this.mask&J.mask)!==0}isEnabled(J){return(this.mask&(1<<J|0))!==0}}var aY=0,_Z=new A,C9=new y0,M8=new vJ,d6=new A,W6=new A,rY=new A,tY=new y0,wZ=new A(1,0,0),IZ=new A(0,1,0),PZ=new A(0,0,1),TZ={type:"added"},eY={type:"removed"},_9={type:"childadded",child:null},RQ={type:"childremoved",child:null};class Z0 extends P8{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:aY++}),this.uuid=$8(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Z0.DEFAULT_UP.clone();let J=new A,Q=new Z8,$=new y0,Z=new A(1,1,1);function W(){$.setFromEuler(Q,!1)}function H(){Q.setFromQuaternion($,void 0,!1)}Q._onChange(W),$._onChange(H),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:J},rotation:{configurable:!0,enumerable:!0,value:Q},quaternion:{configurable:!0,enumerable:!0,value:$},scale:{configurable:!0,enumerable:!0,value:Z},modelViewMatrix:{value:new vJ},normalMatrix:{value:new fJ}}),this.matrix=new vJ,this.matrixWorld=new vJ,this.matrixAutoUpdate=Z0.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Z0.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new T7,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(J){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(J),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(J){return this.quaternion.premultiply(J),this}setRotationFromAxisAngle(J,Q){this.quaternion.setFromAxisAngle(J,Q)}setRotationFromEuler(J){this.quaternion.setFromEuler(J,!0)}setRotationFromMatrix(J){this.quaternion.setFromRotationMatrix(J)}setRotationFromQuaternion(J){this.quaternion.copy(J)}rotateOnAxis(J,Q){return C9.setFromAxisAngle(J,Q),this.quaternion.multiply(C9),this}rotateOnWorldAxis(J,Q){return C9.setFromAxisAngle(J,Q),this.quaternion.premultiply(C9),this}rotateX(J){return this.rotateOnAxis(wZ,J)}rotateY(J){return this.rotateOnAxis(IZ,J)}rotateZ(J){return this.rotateOnAxis(PZ,J)}translateOnAxis(J,Q){return _Z.copy(J).applyQuaternion(this.quaternion),this.position.add(_Z.multiplyScalar(Q)),this}translateX(J){return this.translateOnAxis(wZ,J)}translateY(J){return this.translateOnAxis(IZ,J)}translateZ(J){return this.translateOnAxis(PZ,J)}localToWorld(J){return this.updateWorldMatrix(!0,!1),J.applyMatrix4(this.matrixWorld)}worldToLocal(J){return this.updateWorldMatrix(!0,!1),J.applyMatrix4(M8.copy(this.matrixWorld).invert())}lookAt(J,Q,$){if(J.isVector3)d6.copy(J);else d6.set(J,Q,$);let Z=this.parent;if(this.updateWorldMatrix(!0,!1),W6.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)M8.lookAt(W6,d6,this.up);else M8.lookAt(d6,W6,this.up);if(this.quaternion.setFromRotationMatrix(M8),Z)M8.extractRotation(Z.matrixWorld),C9.setFromRotationMatrix(M8),this.quaternion.premultiply(C9.invert())}add(J){if(arguments.length>1){for(let Q=0;Q<arguments.length;Q++)this.add(arguments[Q]);return this}if(J===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",J),this;if(J&&J.isObject3D)J.removeFromParent(),J.parent=this,this.children.push(J),J.dispatchEvent(TZ),_9.child=J,this.dispatchEvent(_9),_9.child=null;else console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",J);return this}remove(J){if(arguments.length>1){for(let $=0;$<arguments.length;$++)this.remove(arguments[$]);return this}let Q=this.children.indexOf(J);if(Q!==-1)J.parent=null,this.children.splice(Q,1),J.dispatchEvent(eY),RQ.child=J,this.dispatchEvent(RQ),RQ.child=null;return this}removeFromParent(){let J=this.parent;if(J!==null)J.remove(this);return this}clear(){return this.remove(...this.children)}attach(J){if(this.updateWorldMatrix(!0,!1),M8.copy(this.matrixWorld).invert(),J.parent!==null)J.parent.updateWorldMatrix(!0,!1),M8.multiply(J.parent.matrixWorld);return J.applyMatrix4(M8),J.removeFromParent(),J.parent=this,this.children.push(J),J.updateWorldMatrix(!1,!0),J.dispatchEvent(TZ),_9.child=J,this.dispatchEvent(_9),_9.child=null,this}getObjectById(J){return this.getObjectByProperty("id",J)}getObjectByName(J){return this.getObjectByProperty("name",J)}getObjectByProperty(J,Q){if(this[J]===Q)return this;for(let $=0,Z=this.children.length;$<Z;$++){let H=this.children[$].getObjectByProperty(J,Q);if(H!==void 0)return H}return}getObjectsByProperty(J,Q,$=[]){if(this[J]===Q)$.push(this);let Z=this.children;for(let W=0,H=Z.length;W<H;W++)Z[W].getObjectsByProperty(J,Q,$);return $}getWorldPosition(J){return this.updateWorldMatrix(!0,!1),J.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(J){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(W6,J,rY),J}getWorldScale(J){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(W6,tY,J),J}getWorldDirection(J){this.updateWorldMatrix(!0,!1);let Q=this.matrixWorld.elements;return J.set(Q[8],Q[9],Q[10]).normalize()}raycast(){}traverse(J){J(this);let Q=this.children;for(let $=0,Z=Q.length;$<Z;$++)Q[$].traverse(J)}traverseVisible(J){if(this.visible===!1)return;J(this);let Q=this.children;for(let $=0,Z=Q.length;$<Z;$++)Q[$].traverseVisible(J)}traverseAncestors(J){let Q=this.parent;if(Q!==null)J(Q),Q.traverseAncestors(J)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(J){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||J){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,J=!0}let Q=this.children;for(let $=0,Z=Q.length;$<Z;$++)Q[$].updateMatrixWorld(J)}updateWorldMatrix(J,Q){let $=this.parent;if(J===!0&&$!==null)$.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);if(Q===!0){let Z=this.children;for(let W=0,H=Z.length;W<H;W++)Z[W].updateWorldMatrix(!1,!0)}}toJSON(J){let Q=J===void 0||typeof J==="string",$={};if(Q)J={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},$.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let Z={};if(Z.uuid=this.uuid,Z.type=this.type,this.name!=="")Z.name=this.name;if(this.castShadow===!0)Z.castShadow=!0;if(this.receiveShadow===!0)Z.receiveShadow=!0;if(this.visible===!1)Z.visible=!1;if(this.frustumCulled===!1)Z.frustumCulled=!1;if(this.renderOrder!==0)Z.renderOrder=this.renderOrder;if(Object.keys(this.userData).length>0)Z.userData=this.userData;if(Z.layers=this.layers.mask,Z.matrix=this.matrix.toArray(),Z.up=this.up.toArray(),this.matrixAutoUpdate===!1)Z.matrixAutoUpdate=!1;if(this.isInstancedMesh){if(Z.type="InstancedMesh",Z.count=this.count,Z.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)Z.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(Z.type="BatchedMesh",Z.perObjectFrustumCulled=this.perObjectFrustumCulled,Z.sortObjects=this.sortObjects,Z.drawRanges=this._drawRanges,Z.reservedRanges=this._reservedRanges,Z.geometryInfo=this._geometryInfo.map((Y)=>({...Y,boundingBox:Y.boundingBox?Y.boundingBox.toJSON():void 0,boundingSphere:Y.boundingSphere?Y.boundingSphere.toJSON():void 0})),Z.instanceInfo=this._instanceInfo.map((Y)=>({...Y})),Z.availableInstanceIds=this._availableInstanceIds.slice(),Z.availableGeometryIds=this._availableGeometryIds.slice(),Z.nextIndexStart=this._nextIndexStart,Z.nextVertexStart=this._nextVertexStart,Z.geometryCount=this._geometryCount,Z.maxInstanceCount=this._maxInstanceCount,Z.maxVertexCount=this._maxVertexCount,Z.maxIndexCount=this._maxIndexCount,Z.geometryInitialized=this._geometryInitialized,Z.matricesTexture=this._matricesTexture.toJSON(J),Z.indirectTexture=this._indirectTexture.toJSON(J),this._colorsTexture!==null)Z.colorsTexture=this._colorsTexture.toJSON(J);if(this.boundingSphere!==null)Z.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)Z.boundingBox=this.boundingBox.toJSON()}function W(Y,X){if(Y[X.uuid]===void 0)Y[X.uuid]=X.toJSON(J);return X.uuid}if(this.isScene){if(this.background){if(this.background.isColor)Z.background=this.background.toJSON();else if(this.background.isTexture)Z.background=this.background.toJSON(J).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)Z.environment=this.environment.toJSON(J).uuid}else if(this.isMesh||this.isLine||this.isPoints){Z.geometry=W(J.geometries,this.geometry);let Y=this.geometry.parameters;if(Y!==void 0&&Y.shapes!==void 0){let X=Y.shapes;if(Array.isArray(X))for(let K=0,U=X.length;K<U;K++){let G=X[K];W(J.shapes,G)}else W(J.shapes,X)}}if(this.isSkinnedMesh){if(Z.bindMode=this.bindMode,Z.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)W(J.skeletons,this.skeleton),Z.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let Y=[];for(let X=0,K=this.material.length;X<K;X++)Y.push(W(J.materials,this.material[X]));Z.material=Y}else Z.material=W(J.materials,this.material);if(this.children.length>0){Z.children=[];for(let Y=0;Y<this.children.length;Y++)Z.children.push(this.children[Y].toJSON(J).object)}if(this.animations.length>0){Z.animations=[];for(let Y=0;Y<this.animations.length;Y++){let X=this.animations[Y];Z.animations.push(W(J.animations,X))}}if(Q){let Y=H(J.geometries),X=H(J.materials),K=H(J.textures),U=H(J.images),G=H(J.shapes),q=H(J.skeletons),E=H(J.animations),O=H(J.nodes);if(Y.length>0)$.geometries=Y;if(X.length>0)$.materials=X;if(K.length>0)$.textures=K;if(U.length>0)$.images=U;if(G.length>0)$.shapes=G;if(q.length>0)$.skeletons=q;if(E.length>0)$.animations=E;if(O.length>0)$.nodes=O}return $.object=Z,$;function H(Y){let X=[];for(let K in Y){let U=Y[K];delete U.metadata,X.push(U)}return X}}clone(J){return new this.constructor().copy(this,J)}copy(J,Q=!0){if(this.name=J.name,this.up.copy(J.up),this.position.copy(J.position),this.rotation.order=J.rotation.order,this.quaternion.copy(J.quaternion),this.scale.copy(J.scale),this.matrix.copy(J.matrix),this.matrixWorld.copy(J.matrixWorld),this.matrixAutoUpdate=J.matrixAutoUpdate,this.matrixWorldAutoUpdate=J.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=J.matrixWorldNeedsUpdate,this.layers.mask=J.layers.mask,this.visible=J.visible,this.castShadow=J.castShadow,this.receiveShadow=J.receiveShadow,this.frustumCulled=J.frustumCulled,this.renderOrder=J.renderOrder,this.animations=J.animations.slice(),this.userData=JSON.parse(JSON.stringify(J.userData)),Q===!0)for(let $=0;$<J.children.length;$++){let Z=J.children[$];this.add(Z.clone())}return this}}Z0.DEFAULT_UP=new A(0,1,0);Z0.DEFAULT_MATRIX_AUTO_UPDATE=!0;Z0.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var e0=new A,D8=new A,kQ=new A,L8=new A,w9=new A,I9=new A,AZ=new A,MQ=new A,DQ=new A,LQ=new A,VQ=new sJ,zQ=new sJ,BQ=new sJ;class o0{constructor(J=new A,Q=new A,$=new A){this.a=J,this.b=Q,this.c=$}static getNormal(J,Q,$,Z){Z.subVectors($,Q),e0.subVectors(J,Q),Z.cross(e0);let W=Z.lengthSq();if(W>0)return Z.multiplyScalar(1/Math.sqrt(W));return Z.set(0,0,0)}static getBarycoord(J,Q,$,Z,W){e0.subVectors(Z,Q),D8.subVectors($,Q),kQ.subVectors(J,Q);let H=e0.dot(e0),Y=e0.dot(D8),X=e0.dot(kQ),K=D8.dot(D8),U=D8.dot(kQ),G=H*K-Y*Y;if(G===0)return W.set(0,0,0),null;let q=1/G,E=(K*X-Y*U)*q,O=(H*U-Y*X)*q;return W.set(1-E-O,O,E)}static containsPoint(J,Q,$,Z){if(this.getBarycoord(J,Q,$,Z,L8)===null)return!1;return L8.x>=0&&L8.y>=0&&L8.x+L8.y<=1}static getInterpolation(J,Q,$,Z,W,H,Y,X){if(this.getBarycoord(J,Q,$,Z,L8)===null){if(X.x=0,X.y=0,"z"in X)X.z=0;if("w"in X)X.w=0;return null}return X.setScalar(0),X.addScaledVector(W,L8.x),X.addScaledVector(H,L8.y),X.addScaledVector(Y,L8.z),X}static getInterpolatedAttribute(J,Q,$,Z,W,H){return VQ.setScalar(0),zQ.setScalar(0),BQ.setScalar(0),VQ.fromBufferAttribute(J,Q),zQ.fromBufferAttribute(J,$),BQ.fromBufferAttribute(J,Z),H.setScalar(0),H.addScaledVector(VQ,W.x),H.addScaledVector(zQ,W.y),H.addScaledVector(BQ,W.z),H}static isFrontFacing(J,Q,$,Z){return e0.subVectors($,Q),D8.subVectors(J,Q),e0.cross(D8).dot(Z)<0?!0:!1}set(J,Q,$){return this.a.copy(J),this.b.copy(Q),this.c.copy($),this}setFromPointsAndIndices(J,Q,$,Z){return this.a.copy(J[Q]),this.b.copy(J[$]),this.c.copy(J[Z]),this}setFromAttributeAndIndices(J,Q,$,Z){return this.a.fromBufferAttribute(J,Q),this.b.fromBufferAttribute(J,$),this.c.fromBufferAttribute(J,Z),this}clone(){return new this.constructor().copy(this)}copy(J){return this.a.copy(J.a),this.b.copy(J.b),this.c.copy(J.c),this}getArea(){return e0.subVectors(this.c,this.b),D8.subVectors(this.a,this.b),e0.cross(D8).length()*0.5}getMidpoint(J){return J.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(J){return o0.getNormal(this.a,this.b,this.c,J)}getPlane(J){return J.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(J,Q){return o0.getBarycoord(J,this.a,this.b,this.c,Q)}getInterpolation(J,Q,$,Z,W){return o0.getInterpolation(J,this.a,this.b,this.c,Q,$,Z,W)}containsPoint(J){return o0.containsPoint(J,this.a,this.b,this.c)}isFrontFacing(J){return o0.isFrontFacing(this.a,this.b,this.c,J)}intersectsBox(J){return J.intersectsTriangle(this)}closestPointToPoint(J,Q){let $=this.a,Z=this.b,W=this.c,H,Y;w9.subVectors(Z,$),I9.subVectors(W,$),MQ.subVectors(J,$);let X=w9.dot(MQ),K=I9.dot(MQ);if(X<=0&&K<=0)return Q.copy($);DQ.subVectors(J,Z);let U=w9.dot(DQ),G=I9.dot(DQ);if(U>=0&&G<=U)return Q.copy(Z);let q=X*G-U*K;if(q<=0&&X>=0&&U<=0)return H=X/(X-U),Q.copy($).addScaledVector(w9,H);LQ.subVectors(J,W);let E=w9.dot(LQ),O=I9.dot(LQ);if(O>=0&&E<=O)return Q.copy(W);let k=E*K-X*O;if(k<=0&&K>=0&&O<=0)return Y=K/(K-O),Q.copy($).addScaledVector(I9,Y);let M=U*O-E*G;if(M<=0&&G-U>=0&&E-O>=0)return AZ.subVectors(W,Z),Y=(G-U)/(G-U+(E-O)),Q.copy(Z).addScaledVector(AZ,Y);let N=1/(M+k+q);return H=k*N,Y=q*N,Q.copy($).addScaledVector(w9,H).addScaledVector(I9,Y)}equals(J){return J.a.equals(this.a)&&J.b.equals(this.b)&&J.c.equals(this.c)}}var eW={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},x8={h:0,s:0,l:0},m6={h:0,s:0,l:0};function CQ(J,Q,$){if($<0)$+=1;if($>1)$-=1;if($<0.16666666666666666)return J+(Q-J)*6*$;if($<0.5)return Q;if($<0.6666666666666666)return J+(Q-J)*6*(0.6666666666666666-$);return J}class jJ{constructor(J,Q,$){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(J,Q,$)}set(J,Q,$){if(Q===void 0&&$===void 0){let Z=J;if(Z&&Z.isColor)this.copy(Z);else if(typeof Z==="number")this.setHex(Z);else if(typeof Z==="string")this.setStyle(Z)}else this.setRGB(J,Q,$);return this}setScalar(J){return this.r=J,this.g=J,this.b=J,this}setHex(J,Q="srgb"){return J=Math.floor(J),this.r=(J>>16&255)/255,this.g=(J>>8&255)/255,this.b=(J&255)/255,lJ.colorSpaceToWorking(this,Q),this}setRGB(J,Q,$,Z=lJ.workingColorSpace){return this.r=J,this.g=Q,this.b=$,lJ.colorSpaceToWorking(this,Z),this}setHSL(J,Q,$,Z=lJ.workingColorSpace){if(J=C$(J,1),Q=xJ(Q,0,1),$=xJ($,0,1),Q===0)this.r=this.g=this.b=$;else{let W=$<=0.5?$*(1+Q):$+Q-$*Q,H=2*$-W;this.r=CQ(H,W,J+0.3333333333333333),this.g=CQ(H,W,J),this.b=CQ(H,W,J-0.3333333333333333)}return lJ.colorSpaceToWorking(this,Z),this}setStyle(J,Q="srgb"){function $(W){if(W===void 0)return;if(parseFloat(W)<1)console.warn("THREE.Color: Alpha component of "+J+" will be ignored.")}let Z;if(Z=/^(\w+)\(([^\)]*)\)/.exec(J)){let W,H=Z[1],Y=Z[2];switch(H){case"rgb":case"rgba":if(W=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(Y))return $(W[4]),this.setRGB(Math.min(255,parseInt(W[1],10))/255,Math.min(255,parseInt(W[2],10))/255,Math.min(255,parseInt(W[3],10))/255,Q);if(W=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(Y))return $(W[4]),this.setRGB(Math.min(100,parseInt(W[1],10))/100,Math.min(100,parseInt(W[2],10))/100,Math.min(100,parseInt(W[3],10))/100,Q);break;case"hsl":case"hsla":if(W=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(Y))return $(W[4]),this.setHSL(parseFloat(W[1])/360,parseFloat(W[2])/100,parseFloat(W[3])/100,Q);break;default:console.warn("THREE.Color: Unknown color model "+J)}}else if(Z=/^\#([A-Fa-f\d]+)$/.exec(J)){let W=Z[1],H=W.length;if(H===3)return this.setRGB(parseInt(W.charAt(0),16)/15,parseInt(W.charAt(1),16)/15,parseInt(W.charAt(2),16)/15,Q);else if(H===6)return this.setHex(parseInt(W,16),Q);else console.warn("THREE.Color: Invalid hex color "+J)}else if(J&&J.length>0)return this.setColorName(J,Q);return this}setColorName(J,Q="srgb"){let $=eW[J.toLowerCase()];if($!==void 0)this.setHex($,Q);else console.warn("THREE.Color: Unknown color "+J);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(J){return this.r=J.r,this.g=J.g,this.b=J.b,this}copySRGBToLinear(J){return this.r=z8(J.r),this.g=z8(J.g),this.b=z8(J.b),this}copyLinearToSRGB(J){return this.r=y9(J.r),this.g=y9(J.g),this.b=y9(J.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(J="srgb"){return lJ.workingToColorSpace(C0.copy(this),J),Math.round(xJ(C0.r*255,0,255))*65536+Math.round(xJ(C0.g*255,0,255))*256+Math.round(xJ(C0.b*255,0,255))}getHexString(J="srgb"){return("000000"+this.getHex(J).toString(16)).slice(-6)}getHSL(J,Q=lJ.workingColorSpace){lJ.workingToColorSpace(C0.copy(this),Q);let{r:$,g:Z,b:W}=C0,H=Math.max($,Z,W),Y=Math.min($,Z,W),X,K,U=(Y+H)/2;if(Y===H)X=0,K=0;else{let G=H-Y;switch(K=U<=0.5?G/(H+Y):G/(2-H-Y),H){case $:X=(Z-W)/G+(Z<W?6:0);break;case Z:X=(W-$)/G+2;break;case W:X=($-Z)/G+4;break}X/=6}return J.h=X,J.s=K,J.l=U,J}getRGB(J,Q=lJ.workingColorSpace){return lJ.workingToColorSpace(C0.copy(this),Q),J.r=C0.r,J.g=C0.g,J.b=C0.b,J}getStyle(J="srgb"){lJ.workingToColorSpace(C0.copy(this),J);let{r:Q,g:$,b:Z}=C0;if(J!=="srgb")return`color(${J} ${Q.toFixed(3)} ${$.toFixed(3)} ${Z.toFixed(3)})`;return`rgb(${Math.round(Q*255)},${Math.round($*255)},${Math.round(Z*255)})`}offsetHSL(J,Q,$){return this.getHSL(x8),this.setHSL(x8.h+J,x8.s+Q,x8.l+$)}add(J){return this.r+=J.r,this.g+=J.g,this.b+=J.b,this}addColors(J,Q){return this.r=J.r+Q.r,this.g=J.g+Q.g,this.b=J.b+Q.b,this}addScalar(J){return this.r+=J,this.g+=J,this.b+=J,this}sub(J){return this.r=Math.max(0,this.r-J.r),this.g=Math.max(0,this.g-J.g),this.b=Math.max(0,this.b-J.b),this}multiply(J){return this.r*=J.r,this.g*=J.g,this.b*=J.b,this}multiplyScalar(J){return this.r*=J,this.g*=J,this.b*=J,this}lerp(J,Q){return this.r+=(J.r-this.r)*Q,this.g+=(J.g-this.g)*Q,this.b+=(J.b-this.b)*Q,this}lerpColors(J,Q,$){return this.r=J.r+(Q.r-J.r)*$,this.g=J.g+(Q.g-J.g)*$,this.b=J.b+(Q.b-J.b)*$,this}lerpHSL(J,Q){this.getHSL(x8),J.getHSL(m6);let $=q6(x8.h,m6.h,Q),Z=q6(x8.s,m6.s,Q),W=q6(x8.l,m6.l,Q);return this.setHSL($,Z,W),this}setFromVector3(J){return this.r=J.x,this.g=J.y,this.b=J.z,this}applyMatrix3(J){let Q=this.r,$=this.g,Z=this.b,W=J.elements;return this.r=W[0]*Q+W[3]*$+W[6]*Z,this.g=W[1]*Q+W[4]*$+W[7]*Z,this.b=W[2]*Q+W[5]*$+W[8]*Z,this}equals(J){return J.r===this.r&&J.g===this.g&&J.b===this.b}fromArray(J,Q=0){return this.r=J[Q],this.g=J[Q+1],this.b=J[Q+2],this}toArray(J=[],Q=0){return J[Q]=this.r,J[Q+1]=this.g,J[Q+2]=this.b,J}fromBufferAttribute(J,Q){return this.r=J.getX(Q),this.g=J.getY(Q),this.b=J.getZ(Q),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var C0=new jJ;jJ.NAMES=eW;var JX=0;class l0 extends P8{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:JX++}),this.uuid=$8(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new jJ(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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(J){if(this._alphaTest>0!==J>0)this.version++;this._alphaTest=J}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(J){if(J===void 0)return;for(let Q in J){let $=J[Q];if($===void 0){console.warn(`THREE.Material: parameter '${Q}' has value of undefined.`);continue}let Z=this[Q];if(Z===void 0){console.warn(`THREE.Material: '${Q}' is not a property of THREE.${this.type}.`);continue}if(Z&&Z.isColor)Z.set($);else if(Z&&Z.isVector3&&($&&$.isVector3))Z.copy($);else this[Q]=$}}toJSON(J){let Q=J===void 0||typeof J==="string";if(Q)J={textures:{},images:{}};let $={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if($.uuid=this.uuid,$.type=this.type,this.name!=="")$.name=this.name;if(this.color&&this.color.isColor)$.color=this.color.getHex();if(this.roughness!==void 0)$.roughness=this.roughness;if(this.metalness!==void 0)$.metalness=this.metalness;if(this.sheen!==void 0)$.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)$.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)$.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)$.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1)$.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)$.specular=this.specular.getHex();if(this.specularIntensity!==void 0)$.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)$.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)$.shininess=this.shininess;if(this.clearcoat!==void 0)$.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)$.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)$.clearcoatMap=this.clearcoatMap.toJSON(J).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)$.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(J).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)$.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(J).uuid,$.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.dispersion!==void 0)$.dispersion=this.dispersion;if(this.iridescence!==void 0)$.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)$.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)$.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)$.iridescenceMap=this.iridescenceMap.toJSON(J).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)$.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(J).uuid;if(this.anisotropy!==void 0)$.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)$.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)$.anisotropyMap=this.anisotropyMap.toJSON(J).uuid;if(this.map&&this.map.isTexture)$.map=this.map.toJSON(J).uuid;if(this.matcap&&this.matcap.isTexture)$.matcap=this.matcap.toJSON(J).uuid;if(this.alphaMap&&this.alphaMap.isTexture)$.alphaMap=this.alphaMap.toJSON(J).uuid;if(this.lightMap&&this.lightMap.isTexture)$.lightMap=this.lightMap.toJSON(J).uuid,$.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)$.aoMap=this.aoMap.toJSON(J).uuid,$.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)$.bumpMap=this.bumpMap.toJSON(J).uuid,$.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)$.normalMap=this.normalMap.toJSON(J).uuid,$.normalMapType=this.normalMapType,$.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)$.displacementMap=this.displacementMap.toJSON(J).uuid,$.displacementScale=this.displacementScale,$.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)$.roughnessMap=this.roughnessMap.toJSON(J).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)$.metalnessMap=this.metalnessMap.toJSON(J).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)$.emissiveMap=this.emissiveMap.toJSON(J).uuid;if(this.specularMap&&this.specularMap.isTexture)$.specularMap=this.specularMap.toJSON(J).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)$.specularIntensityMap=this.specularIntensityMap.toJSON(J).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)$.specularColorMap=this.specularColorMap.toJSON(J).uuid;if(this.envMap&&this.envMap.isTexture){if($.envMap=this.envMap.toJSON(J).uuid,this.combine!==void 0)$.combine=this.combine}if(this.envMapRotation!==void 0)$.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)$.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)$.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)$.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)$.gradientMap=this.gradientMap.toJSON(J).uuid;if(this.transmission!==void 0)$.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)$.transmissionMap=this.transmissionMap.toJSON(J).uuid;if(this.thickness!==void 0)$.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)$.thicknessMap=this.thicknessMap.toJSON(J).uuid;if(this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0)$.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)$.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)$.size=this.size;if(this.shadowSide!==null)$.shadowSide=this.shadowSide;if(this.sizeAttenuation!==void 0)$.sizeAttenuation=this.sizeAttenuation;if(this.blending!==1)$.blending=this.blending;if(this.side!==0)$.side=this.side;if(this.vertexColors===!0)$.vertexColors=!0;if(this.opacity<1)$.opacity=this.opacity;if(this.transparent===!0)$.transparent=!0;if(this.blendSrc!==204)$.blendSrc=this.blendSrc;if(this.blendDst!==205)$.blendDst=this.blendDst;if(this.blendEquation!==100)$.blendEquation=this.blendEquation;if(this.blendSrcAlpha!==null)$.blendSrcAlpha=this.blendSrcAlpha;if(this.blendDstAlpha!==null)$.blendDstAlpha=this.blendDstAlpha;if(this.blendEquationAlpha!==null)$.blendEquationAlpha=this.blendEquationAlpha;if(this.blendColor&&this.blendColor.isColor)$.blendColor=this.blendColor.getHex();if(this.blendAlpha!==0)$.blendAlpha=this.blendAlpha;if(this.depthFunc!==3)$.depthFunc=this.depthFunc;if(this.depthTest===!1)$.depthTest=this.depthTest;if(this.depthWrite===!1)$.depthWrite=this.depthWrite;if(this.colorWrite===!1)$.colorWrite=this.colorWrite;if(this.stencilWriteMask!==255)$.stencilWriteMask=this.stencilWriteMask;if(this.stencilFunc!==519)$.stencilFunc=this.stencilFunc;if(this.stencilRef!==0)$.stencilRef=this.stencilRef;if(this.stencilFuncMask!==255)$.stencilFuncMask=this.stencilFuncMask;if(this.stencilFail!==7680)$.stencilFail=this.stencilFail;if(this.stencilZFail!==7680)$.stencilZFail=this.stencilZFail;if(this.stencilZPass!==7680)$.stencilZPass=this.stencilZPass;if(this.stencilWrite===!0)$.stencilWrite=this.stencilWrite;if(this.rotation!==void 0&&this.rotation!==0)$.rotation=this.rotation;if(this.polygonOffset===!0)$.polygonOffset=!0;if(this.polygonOffsetFactor!==0)$.polygonOffsetFactor=this.polygonOffsetFactor;if(this.polygonOffsetUnits!==0)$.polygonOffsetUnits=this.polygonOffsetUnits;if(this.linewidth!==void 0&&this.linewidth!==1)$.linewidth=this.linewidth;if(this.dashSize!==void 0)$.dashSize=this.dashSize;if(this.gapSize!==void 0)$.gapSize=this.gapSize;if(this.scale!==void 0)$.scale=this.scale;if(this.dithering===!0)$.dithering=!0;if(this.alphaTest>0)$.alphaTest=this.alphaTest;if(this.alphaHash===!0)$.alphaHash=!0;if(this.alphaToCoverage===!0)$.alphaToCoverage=!0;if(this.premultipliedAlpha===!0)$.premultipliedAlpha=!0;if(this.forceSinglePass===!0)$.forceSinglePass=!0;if(this.wireframe===!0)$.wireframe=!0;if(this.wireframeLinewidth>1)$.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!=="round")$.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!=="round")$.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading===!0)$.flatShading=!0;if(this.visible===!1)$.visible=!1;if(this.toneMapped===!1)$.toneMapped=!1;if(this.fog===!1)$.fog=!1;if(Object.keys(this.userData).length>0)$.userData=this.userData;function Z(W){let H=[];for(let Y in W){let X=W[Y];delete X.metadata,H.push(X)}return H}if(Q){let W=Z(J.textures),H=Z(J.images);if(W.length>0)$.textures=W;if(H.length>0)$.images=H}return $}clone(){return new this.constructor().copy(this)}copy(J){this.name=J.name,this.blending=J.blending,this.side=J.side,this.vertexColors=J.vertexColors,this.opacity=J.opacity,this.transparent=J.transparent,this.blendSrc=J.blendSrc,this.blendDst=J.blendDst,this.blendEquation=J.blendEquation,this.blendSrcAlpha=J.blendSrcAlpha,this.blendDstAlpha=J.blendDstAlpha,this.blendEquationAlpha=J.blendEquationAlpha,this.blendColor.copy(J.blendColor),this.blendAlpha=J.blendAlpha,this.depthFunc=J.depthFunc,this.depthTest=J.depthTest,this.depthWrite=J.depthWrite,this.stencilWriteMask=J.stencilWriteMask,this.stencilFunc=J.stencilFunc,this.stencilRef=J.stencilRef,this.stencilFuncMask=J.stencilFuncMask,this.stencilFail=J.stencilFail,this.stencilZFail=J.stencilZFail,this.stencilZPass=J.stencilZPass,this.stencilWrite=J.stencilWrite;let Q=J.clippingPlanes,$=null;if(Q!==null){let Z=Q.length;$=Array(Z);for(let W=0;W!==Z;++W)$[W]=Q[W].clone()}return this.clippingPlanes=$,this.clipIntersection=J.clipIntersection,this.clipShadows=J.clipShadows,this.shadowSide=J.shadowSide,this.colorWrite=J.colorWrite,this.precision=J.precision,this.polygonOffset=J.polygonOffset,this.polygonOffsetFactor=J.polygonOffsetFactor,this.polygonOffsetUnits=J.polygonOffsetUnits,this.dithering=J.dithering,this.alphaTest=J.alphaTest,this.alphaHash=J.alphaHash,this.alphaToCoverage=J.alphaToCoverage,this.premultipliedAlpha=J.premultipliedAlpha,this.forceSinglePass=J.forceSinglePass,this.visible=J.visible,this.toneMapped=J.toneMapped,this.userData=JSON.parse(JSON.stringify(J.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(J){if(J===!0)this.version++}}class E8 extends l0{constructor(J){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new jJ(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 Z8,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(J)}copy(J){return super.copy(J),this.color.copy(J.color),this.map=J.map,this.lightMap=J.lightMap,this.lightMapIntensity=J.lightMapIntensity,this.aoMap=J.aoMap,this.aoMapIntensity=J.aoMapIntensity,this.specularMap=J.specularMap,this.alphaMap=J.alphaMap,this.envMap=J.envMap,this.envMapRotation.copy(J.envMapRotation),this.combine=J.combine,this.reflectivity=J.reflectivity,this.refractionRatio=J.refractionRatio,this.wireframe=J.wireframe,this.wireframeLinewidth=J.wireframeLinewidth,this.wireframeLinecap=J.wireframeLinecap,this.wireframeLinejoin=J.wireframeLinejoin,this.fog=J.fog,this}}var q0=new A,u6=new PJ,QX=0;class F0{constructor(J,Q,$=!1){if(Array.isArray(J))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:QX++}),this.name="",this.array=J,this.itemSize=Q,this.count=J!==void 0?J.length/Q:0,this.normalized=$,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(J){if(J===!0)this.version++}setUsage(J){return this.usage=J,this}addUpdateRange(J,Q){this.updateRanges.push({start:J,count:Q})}clearUpdateRanges(){this.updateRanges.length=0}copy(J){return this.name=J.name,this.array=new J.array.constructor(J.array),this.itemSize=J.itemSize,this.count=J.count,this.normalized=J.normalized,this.usage=J.usage,this.gpuType=J.gpuType,this}copyAt(J,Q,$){J*=this.itemSize,$*=Q.itemSize;for(let Z=0,W=this.itemSize;Z<W;Z++)this.array[J+Z]=Q.array[$+Z];return this}copyArray(J){return this.array.set(J),this}applyMatrix3(J){if(this.itemSize===2)for(let Q=0,$=this.count;Q<$;Q++)u6.fromBufferAttribute(this,Q),u6.applyMatrix3(J),this.setXY(Q,u6.x,u6.y);else if(this.itemSize===3)for(let Q=0,$=this.count;Q<$;Q++)q0.fromBufferAttribute(this,Q),q0.applyMatrix3(J),this.setXYZ(Q,q0.x,q0.y,q0.z);return this}applyMatrix4(J){for(let Q=0,$=this.count;Q<$;Q++)q0.fromBufferAttribute(this,Q),q0.applyMatrix4(J),this.setXYZ(Q,q0.x,q0.y,q0.z);return this}applyNormalMatrix(J){for(let Q=0,$=this.count;Q<$;Q++)q0.fromBufferAttribute(this,Q),q0.applyNormalMatrix(J),this.setXYZ(Q,q0.x,q0.y,q0.z);return this}transformDirection(J){for(let Q=0,$=this.count;Q<$;Q++)q0.fromBufferAttribute(this,Q),q0.transformDirection(J),this.setXYZ(Q,q0.x,q0.y,q0.z);return this}set(J,Q=0){return this.array.set(J,Q),this}getComponent(J,Q){let $=this.array[J*this.itemSize+Q];if(this.normalized)$=Q8($,this.array);return $}setComponent(J,Q,$){if(this.normalized)$=aJ($,this.array);return this.array[J*this.itemSize+Q]=$,this}getX(J){let Q=this.array[J*this.itemSize];if(this.normalized)Q=Q8(Q,this.array);return Q}setX(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.array[J*this.itemSize]=Q,this}getY(J){let Q=this.array[J*this.itemSize+1];if(this.normalized)Q=Q8(Q,this.array);return Q}setY(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.array[J*this.itemSize+1]=Q,this}getZ(J){let Q=this.array[J*this.itemSize+2];if(this.normalized)Q=Q8(Q,this.array);return Q}setZ(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.array[J*this.itemSize+2]=Q,this}getW(J){let Q=this.array[J*this.itemSize+3];if(this.normalized)Q=Q8(Q,this.array);return Q}setW(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.array[J*this.itemSize+3]=Q,this}setXY(J,Q,$){if(J*=this.itemSize,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array);return this.array[J+0]=Q,this.array[J+1]=$,this}setXYZ(J,Q,$,Z){if(J*=this.itemSize,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array),Z=aJ(Z,this.array);return this.array[J+0]=Q,this.array[J+1]=$,this.array[J+2]=Z,this}setXYZW(J,Q,$,Z,W){if(J*=this.itemSize,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array),Z=aJ(Z,this.array),W=aJ(W,this.array);return this.array[J+0]=Q,this.array[J+1]=$,this.array[J+2]=Z,this.array[J+3]=W,this}onUpload(J){return this.onUploadCallback=J,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let J={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};if(this.name!=="")J.name=this.name;if(this.usage!==35044)J.usage=this.usage;return J}}class A7 extends F0{constructor(J,Q,$){super(new Uint16Array(J),Q,$)}}class S7 extends F0{constructor(J,Q,$){super(new Uint32Array(J),Q,$)}}class i0 extends F0{constructor(J,Q,$){super(new Float32Array(J),Q,$)}}var $X=0,s0=new vJ,_Q=new Z0,P9=new A,x0=new A0,H6=new A0,L0=new A;class d0 extends P8{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$X++}),this.uuid=$8(),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(J){if(Array.isArray(J))this.index=new((_$(J))?S7:A7)(J,1);else this.index=J;return this}setIndirect(J){return this.indirect=J,this}getIndirect(){return this.indirect}getAttribute(J){return this.attributes[J]}setAttribute(J,Q){return this.attributes[J]=Q,this}deleteAttribute(J){return delete this.attributes[J],this}hasAttribute(J){return this.attributes[J]!==void 0}addGroup(J,Q,$=0){this.groups.push({start:J,count:Q,materialIndex:$})}clearGroups(){this.groups=[]}setDrawRange(J,Q){this.drawRange.start=J,this.drawRange.count=Q}applyMatrix4(J){let Q=this.attributes.position;if(Q!==void 0)Q.applyMatrix4(J),Q.needsUpdate=!0;let $=this.attributes.normal;if($!==void 0){let W=new fJ().getNormalMatrix(J);$.applyNormalMatrix(W),$.needsUpdate=!0}let Z=this.attributes.tangent;if(Z!==void 0)Z.transformDirection(J),Z.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this}applyQuaternion(J){return s0.makeRotationFromQuaternion(J),this.applyMatrix4(s0),this}rotateX(J){return s0.makeRotationX(J),this.applyMatrix4(s0),this}rotateY(J){return s0.makeRotationY(J),this.applyMatrix4(s0),this}rotateZ(J){return s0.makeRotationZ(J),this.applyMatrix4(s0),this}translate(J,Q,$){return s0.makeTranslation(J,Q,$),this.applyMatrix4(s0),this}scale(J,Q,$){return s0.makeScale(J,Q,$),this.applyMatrix4(s0),this}lookAt(J){return _Q.lookAt(J),_Q.updateMatrix(),this.applyMatrix4(_Q.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(P9).negate(),this.translate(P9.x,P9.y,P9.z),this}setFromPoints(J){let Q=this.getAttribute("position");if(Q===void 0){let $=[];for(let Z=0,W=J.length;Z<W;Z++){let H=J[Z];$.push(H.x,H.y,H.z||0)}this.setAttribute("position",new i0($,3))}else{let $=Math.min(J.length,Q.count);for(let Z=0;Z<$;Z++){let W=J[Z];Q.setXYZ(Z,W.x,W.y,W.z||0)}if(J.length>Q.count)console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");Q.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new A0;let J=this.attributes.position,Q=this.morphAttributes.position;if(J&&J.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(J!==void 0){if(this.boundingBox.setFromBufferAttribute(J),Q)for(let $=0,Z=Q.length;$<Z;$++){let W=Q[$];if(x0.setFromBufferAttribute(W),this.morphTargetsRelative)L0.addVectors(this.boundingBox.min,x0.min),this.boundingBox.expandByPoint(L0),L0.addVectors(this.boundingBox.max,x0.max),this.boundingBox.expandByPoint(L0);else this.boundingBox.expandByPoint(x0.min),this.boundingBox.expandByPoint(x0.max)}}else this.boundingBox.makeEmpty();if(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(){if(this.boundingSphere===null)this.boundingSphere=new p0;let J=this.attributes.position,Q=this.morphAttributes.position;if(J&&J.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new A,1/0);return}if(J){let $=this.boundingSphere.center;if(x0.setFromBufferAttribute(J),Q)for(let W=0,H=Q.length;W<H;W++){let Y=Q[W];if(H6.setFromBufferAttribute(Y),this.morphTargetsRelative)L0.addVectors(x0.min,H6.min),x0.expandByPoint(L0),L0.addVectors(x0.max,H6.max),x0.expandByPoint(L0);else x0.expandByPoint(H6.min),x0.expandByPoint(H6.max)}x0.getCenter($);let Z=0;for(let W=0,H=J.count;W<H;W++)L0.fromBufferAttribute(J,W),Z=Math.max(Z,$.distanceToSquared(L0));if(Q)for(let W=0,H=Q.length;W<H;W++){let Y=Q[W],X=this.morphTargetsRelative;for(let K=0,U=Y.count;K<U;K++){if(L0.fromBufferAttribute(Y,K),X)P9.fromBufferAttribute(J,K),L0.add(P9);Z=Math.max(Z,$.distanceToSquared(L0))}}if(this.boundingSphere.radius=Math.sqrt(Z),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 J=this.index,Q=this.attributes;if(J===null||Q.position===void 0||Q.normal===void 0||Q.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:$,normal:Z,uv:W}=Q;if(this.hasAttribute("tangent")===!1)this.setAttribute("tangent",new F0(new Float32Array(4*$.count),4));let H=this.getAttribute("tangent"),Y=[],X=[];for(let T=0;T<$.count;T++)Y[T]=new A,X[T]=new A;let K=new A,U=new A,G=new A,q=new PJ,E=new PJ,O=new PJ,k=new A,M=new A;function N(T,x,z){K.fromBufferAttribute($,T),U.fromBufferAttribute($,x),G.fromBufferAttribute($,z),q.fromBufferAttribute(W,T),E.fromBufferAttribute(W,x),O.fromBufferAttribute(W,z),U.sub(K),G.sub(K),E.sub(q),O.sub(q);let V=1/(E.x*O.y-O.x*E.y);if(!isFinite(V))return;k.copy(U).multiplyScalar(O.y).addScaledVector(G,-E.y).multiplyScalar(V),M.copy(G).multiplyScalar(E.x).addScaledVector(U,-O.x).multiplyScalar(V),Y[T].add(k),Y[x].add(k),Y[z].add(k),X[T].add(M),X[x].add(M),X[z].add(M)}let F=this.groups;if(F.length===0)F=[{start:0,count:J.count}];for(let T=0,x=F.length;T<x;++T){let z=F[T],V=z.start,j=z.count;for(let m=V,l=V+j;m<l;m+=3)N(J.getX(m+0),J.getX(m+1),J.getX(m+2))}let C=new A,L=new A,_=new A,v=new A;function w(T){_.fromBufferAttribute(Z,T),v.copy(_);let x=Y[T];C.copy(x),C.sub(_.multiplyScalar(_.dot(x))).normalize(),L.crossVectors(v,x);let V=L.dot(X[T])<0?-1:1;H.setXYZW(T,C.x,C.y,C.z,V)}for(let T=0,x=F.length;T<x;++T){let z=F[T],V=z.start,j=z.count;for(let m=V,l=V+j;m<l;m+=3)w(J.getX(m+0)),w(J.getX(m+1)),w(J.getX(m+2))}}computeVertexNormals(){let J=this.index,Q=this.getAttribute("position");if(Q!==void 0){let $=this.getAttribute("normal");if($===void 0)$=new F0(new Float32Array(Q.count*3),3),this.setAttribute("normal",$);else for(let q=0,E=$.count;q<E;q++)$.setXYZ(q,0,0,0);let Z=new A,W=new A,H=new A,Y=new A,X=new A,K=new A,U=new A,G=new A;if(J)for(let q=0,E=J.count;q<E;q+=3){let O=J.getX(q+0),k=J.getX(q+1),M=J.getX(q+2);Z.fromBufferAttribute(Q,O),W.fromBufferAttribute(Q,k),H.fromBufferAttribute(Q,M),U.subVectors(H,W),G.subVectors(Z,W),U.cross(G),Y.fromBufferAttribute($,O),X.fromBufferAttribute($,k),K.fromBufferAttribute($,M),Y.add(U),X.add(U),K.add(U),$.setXYZ(O,Y.x,Y.y,Y.z),$.setXYZ(k,X.x,X.y,X.z),$.setXYZ(M,K.x,K.y,K.z)}else for(let q=0,E=Q.count;q<E;q+=3)Z.fromBufferAttribute(Q,q+0),W.fromBufferAttribute(Q,q+1),H.fromBufferAttribute(Q,q+2),U.subVectors(H,W),G.subVectors(Z,W),U.cross(G),$.setXYZ(q+0,U.x,U.y,U.z),$.setXYZ(q+1,U.x,U.y,U.z),$.setXYZ(q+2,U.x,U.y,U.z);this.normalizeNormals(),$.needsUpdate=!0}}normalizeNormals(){let J=this.attributes.normal;for(let Q=0,$=J.count;Q<$;Q++)L0.fromBufferAttribute(J,Q),L0.normalize(),J.setXYZ(Q,L0.x,L0.y,L0.z)}toNonIndexed(){function J(Y,X){let{array:K,itemSize:U,normalized:G}=Y,q=new K.constructor(X.length*U),E=0,O=0;for(let k=0,M=X.length;k<M;k++){if(Y.isInterleavedBufferAttribute)E=X[k]*Y.data.stride+Y.offset;else E=X[k]*U;for(let N=0;N<U;N++)q[O++]=K[E++]}return new F0(q,U,G)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let Q=new d0,$=this.index.array,Z=this.attributes;for(let Y in Z){let X=Z[Y],K=J(X,$);Q.setAttribute(Y,K)}let W=this.morphAttributes;for(let Y in W){let X=[],K=W[Y];for(let U=0,G=K.length;U<G;U++){let q=K[U],E=J(q,$);X.push(E)}Q.morphAttributes[Y]=X}Q.morphTargetsRelative=this.morphTargetsRelative;let H=this.groups;for(let Y=0,X=H.length;Y<X;Y++){let K=H[Y];Q.addGroup(K.start,K.count,K.materialIndex)}return Q}toJSON(){let J={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(J.uuid=this.uuid,J.type=this.type,this.name!=="")J.name=this.name;if(Object.keys(this.userData).length>0)J.userData=this.userData;if(this.parameters!==void 0){let X=this.parameters;for(let K in X)if(X[K]!==void 0)J[K]=X[K];return J}J.data={attributes:{}};let Q=this.index;if(Q!==null)J.data.index={type:Q.array.constructor.name,array:Array.prototype.slice.call(Q.array)};let $=this.attributes;for(let X in $){let K=$[X];J.data.attributes[X]=K.toJSON(J.data)}let Z={},W=!1;for(let X in this.morphAttributes){let K=this.morphAttributes[X],U=[];for(let G=0,q=K.length;G<q;G++){let E=K[G];U.push(E.toJSON(J.data))}if(U.length>0)Z[X]=U,W=!0}if(W)J.data.morphAttributes=Z,J.data.morphTargetsRelative=this.morphTargetsRelative;let H=this.groups;if(H.length>0)J.data.groups=JSON.parse(JSON.stringify(H));let Y=this.boundingSphere;if(Y!==null)J.data.boundingSphere=Y.toJSON();return J}clone(){return new this.constructor().copy(this)}copy(J){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let Q={};this.name=J.name;let $=J.index;if($!==null)this.setIndex($.clone());let Z=J.attributes;for(let K in Z){let U=Z[K];this.setAttribute(K,U.clone(Q))}let W=J.morphAttributes;for(let K in W){let U=[],G=W[K];for(let q=0,E=G.length;q<E;q++)U.push(G[q].clone(Q));this.morphAttributes[K]=U}this.morphTargetsRelative=J.morphTargetsRelative;let H=J.groups;for(let K=0,U=H.length;K<U;K++){let G=H[K];this.addGroup(G.start,G.count,G.materialIndex)}let Y=J.boundingBox;if(Y!==null)this.boundingBox=Y.clone();let X=J.boundingSphere;if(X!==null)this.boundingSphere=X.clone();return this.drawRange.start=J.drawRange.start,this.drawRange.count=J.drawRange.count,this.userData=J.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}var SZ=new vJ,$9=new n8,c6=new p0,jZ=new A,n6=new A,s6=new A,o6=new A,wQ=new A,i6=new A,yZ=new A,a6=new A;class _0 extends Z0{constructor(J=new d0,Q=new E8){super();this.isMesh=!0,this.type="Mesh",this.geometry=J,this.material=Q,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(J,Q){if(super.copy(J,Q),J.morphTargetInfluences!==void 0)this.morphTargetInfluences=J.morphTargetInfluences.slice();if(J.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},J.morphTargetDictionary);return this.material=Array.isArray(J.material)?J.material.slice():J.material,this.geometry=J.geometry,this}updateMorphTargets(){let Q=this.geometry.morphAttributes,$=Object.keys(Q);if($.length>0){let Z=Q[$[0]];if(Z!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let W=0,H=Z.length;W<H;W++){let Y=Z[W].name||String(W);this.morphTargetInfluences.push(0),this.morphTargetDictionary[Y]=W}}}}getVertexPosition(J,Q){let $=this.geometry,Z=$.attributes.position,W=$.morphAttributes.position,H=$.morphTargetsRelative;Q.fromBufferAttribute(Z,J);let Y=this.morphTargetInfluences;if(W&&Y){i6.set(0,0,0);for(let X=0,K=W.length;X<K;X++){let U=Y[X],G=W[X];if(U===0)continue;if(wQ.fromBufferAttribute(G,J),H)i6.addScaledVector(wQ,U);else i6.addScaledVector(wQ.sub(Q),U)}Q.add(i6)}return Q}raycast(J,Q){let $=this.geometry,Z=this.material,W=this.matrixWorld;if(Z===void 0)return;if($.boundingSphere===null)$.computeBoundingSphere();if(c6.copy($.boundingSphere),c6.applyMatrix4(W),$9.copy(J.ray).recast(J.near),c6.containsPoint($9.origin)===!1){if($9.intersectSphere(c6,jZ)===null)return;if($9.origin.distanceToSquared(jZ)>(J.far-J.near)**2)return}if(SZ.copy(W).invert(),$9.copy(J.ray).applyMatrix4(SZ),$.boundingBox!==null){if($9.intersectsBox($.boundingBox)===!1)return}this._computeIntersections(J,Q,$9)}_computeIntersections(J,Q,$){let Z,W=this.geometry,H=this.material,Y=W.index,X=W.attributes.position,K=W.attributes.uv,U=W.attributes.uv1,G=W.attributes.normal,q=W.groups,E=W.drawRange;if(Y!==null)if(Array.isArray(H))for(let O=0,k=q.length;O<k;O++){let M=q[O],N=H[M.materialIndex],F=Math.max(M.start,E.start),C=Math.min(Y.count,Math.min(M.start+M.count,E.start+E.count));for(let L=F,_=C;L<_;L+=3){let v=Y.getX(L),w=Y.getX(L+1),T=Y.getX(L+2);if(Z=r6(this,N,J,$,K,U,G,v,w,T),Z)Z.faceIndex=Math.floor(L/3),Z.face.materialIndex=M.materialIndex,Q.push(Z)}}else{let O=Math.max(0,E.start),k=Math.min(Y.count,E.start+E.count);for(let M=O,N=k;M<N;M+=3){let F=Y.getX(M),C=Y.getX(M+1),L=Y.getX(M+2);if(Z=r6(this,H,J,$,K,U,G,F,C,L),Z)Z.faceIndex=Math.floor(M/3),Q.push(Z)}}else if(X!==void 0)if(Array.isArray(H))for(let O=0,k=q.length;O<k;O++){let M=q[O],N=H[M.materialIndex],F=Math.max(M.start,E.start),C=Math.min(X.count,Math.min(M.start+M.count,E.start+E.count));for(let L=F,_=C;L<_;L+=3){let v=L,w=L+1,T=L+2;if(Z=r6(this,N,J,$,K,U,G,v,w,T),Z)Z.faceIndex=Math.floor(L/3),Z.face.materialIndex=M.materialIndex,Q.push(Z)}}else{let O=Math.max(0,E.start),k=Math.min(X.count,E.start+E.count);for(let M=O,N=k;M<N;M+=3){let F=M,C=M+1,L=M+2;if(Z=r6(this,H,J,$,K,U,G,F,C,L),Z)Z.faceIndex=Math.floor(M/3),Q.push(Z)}}}}function ZX(J,Q,$,Z,W,H,Y,X){let K;if(Q.side===1)K=Z.intersectTriangle(Y,H,W,!0,X);else K=Z.intersectTriangle(W,H,Y,Q.side===0,X);if(K===null)return null;a6.copy(X),a6.applyMatrix4(J.matrixWorld);let U=$.ray.origin.distanceTo(a6);if(U<$.near||U>$.far)return null;return{distance:U,point:a6.clone(),object:J}}function r6(J,Q,$,Z,W,H,Y,X,K,U){J.getVertexPosition(X,n6),J.getVertexPosition(K,s6),J.getVertexPosition(U,o6);let G=ZX(J,Q,$,Z,n6,s6,o6,yZ);if(G){let q=new A;if(o0.getBarycoord(yZ,n6,s6,o6,q),W)G.uv=o0.getInterpolatedAttribute(W,X,K,U,q,new PJ);if(H)G.uv1=o0.getInterpolatedAttribute(H,X,K,U,q,new PJ);if(Y){if(G.normal=o0.getInterpolatedAttribute(Y,X,K,U,q,new A),G.normal.dot(Z.direction)>0)G.normal.multiplyScalar(-1)}let E={a:X,b:K,c:U,normal:new A,materialIndex:0};o0.getNormal(n6,s6,o6,E.normal),G.face=E,G.barycoord=q}return G}class d9 extends d0{constructor(J=1,Q=1,$=1,Z=1,W=1,H=1){super();this.type="BoxGeometry",this.parameters={width:J,height:Q,depth:$,widthSegments:Z,heightSegments:W,depthSegments:H};let Y=this;Z=Math.floor(Z),W=Math.floor(W),H=Math.floor(H);let X=[],K=[],U=[],G=[],q=0,E=0;O("z","y","x",-1,-1,$,Q,J,H,W,0),O("z","y","x",1,-1,$,Q,-J,H,W,1),O("x","z","y",1,1,J,$,Q,Z,H,2),O("x","z","y",1,-1,J,$,-Q,Z,H,3),O("x","y","z",1,-1,J,Q,$,Z,W,4),O("x","y","z",-1,-1,J,Q,-$,Z,W,5),this.setIndex(X),this.setAttribute("position",new i0(K,3)),this.setAttribute("normal",new i0(U,3)),this.setAttribute("uv",new i0(G,2));function O(k,M,N,F,C,L,_,v,w,T,x){let z=L/w,V=_/T,j=L/2,m=_/2,l=v/2,c=w+1,i=T+1,u=0,r=0,g=new A;for(let ZJ=0;ZJ<i;ZJ++){let UJ=ZJ*V-m;for(let TJ=0;TJ<c;TJ++){let mJ=TJ*z-j;g[k]=mJ*F,g[M]=UJ*C,g[N]=l,K.push(g.x,g.y,g.z),g[k]=0,g[M]=0,g[N]=v>0?1:-1,U.push(g.x,g.y,g.z),G.push(TJ/w),G.push(1-ZJ/T),u+=1}}for(let ZJ=0;ZJ<T;ZJ++)for(let UJ=0;UJ<w;UJ++){let TJ=q+UJ+c*ZJ,mJ=q+UJ+c*(ZJ+1),Y0=q+(UJ+1)+c*(ZJ+1),d=q+(UJ+1)+c*ZJ;X.push(TJ,mJ,d),X.push(mJ,Y0,d),r+=6}Y.addGroup(E,r,x),E+=r,q+=u}}copy(J){return super.copy(J),this.parameters=Object.assign({},J.parameters),this}static fromJSON(J){return new d9(J.width,J.height,J.depth,J.widthSegments,J.heightSegments,J.depthSegments)}}function G9(J){let Q={};for(let $ in J){Q[$]={};for(let Z in J[$]){let W=J[$][Z];if(W&&(W.isColor||W.isMatrix3||W.isMatrix4||W.isVector2||W.isVector3||W.isVector4||W.isTexture||W.isQuaternion))if(W.isRenderTargetTexture)console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),Q[$][Z]=null;else Q[$][Z]=W.clone();else if(Array.isArray(W))Q[$][Z]=W.slice();else Q[$][Z]=W}}return Q}function w0(J){let Q={};for(let $=0;$<J.length;$++){let Z=G9(J[$]);for(let W in Z)Q[W]=Z[W]}return Q}function WX(J){let Q=[];for(let $=0;$<J.length;$++)Q.push(J[$].clone());return Q}function T$(J){let Q=J.getRenderTarget();if(Q===null)return J.outputColorSpace;if(Q.isXRRenderTarget===!0)return Q.texture.colorSpace;return lJ.workingColorSpace}var JH={clone:G9,merge:w0},HX=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,YX=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class N8 extends l0{constructor(J){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=HX,this.fragmentShader=YX,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,J!==void 0)this.setValues(J)}copy(J){return super.copy(J),this.fragmentShader=J.fragmentShader,this.vertexShader=J.vertexShader,this.uniforms=G9(J.uniforms),this.uniformsGroups=WX(J.uniformsGroups),this.defines=Object.assign({},J.defines),this.wireframe=J.wireframe,this.wireframeLinewidth=J.wireframeLinewidth,this.fog=J.fog,this.lights=J.lights,this.clipping=J.clipping,this.extensions=Object.assign({},J.extensions),this.glslVersion=J.glslVersion,this}toJSON(J){let Q=super.toJSON(J);Q.glslVersion=this.glslVersion,Q.uniforms={};for(let Z in this.uniforms){let H=this.uniforms[Z].value;if(H&&H.isTexture)Q.uniforms[Z]={type:"t",value:H.toJSON(J).uuid};else if(H&&H.isColor)Q.uniforms[Z]={type:"c",value:H.getHex()};else if(H&&H.isVector2)Q.uniforms[Z]={type:"v2",value:H.toArray()};else if(H&&H.isVector3)Q.uniforms[Z]={type:"v3",value:H.toArray()};else if(H&&H.isVector4)Q.uniforms[Z]={type:"v4",value:H.toArray()};else if(H&&H.isMatrix3)Q.uniforms[Z]={type:"m3",value:H.toArray()};else if(H&&H.isMatrix4)Q.uniforms[Z]={type:"m4",value:H.toArray()};else Q.uniforms[Z]={value:H}}if(Object.keys(this.defines).length>0)Q.defines=this.defines;Q.vertexShader=this.vertexShader,Q.fragmentShader=this.fragmentShader,Q.lights=this.lights,Q.clipping=this.clipping;let $={};for(let Z in this.extensions)if(this.extensions[Z]===!0)$[Z]=!0;if(Object.keys($).length>0)Q.extensions=$;return Q}}class j7 extends Z0{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vJ,this.projectionMatrix=new vJ,this.projectionMatrixInverse=new vJ,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(J,Q){return super.copy(J,Q),this.matrixWorldInverse.copy(J.matrixWorldInverse),this.projectionMatrix.copy(J.projectionMatrix),this.projectionMatrixInverse.copy(J.projectionMatrixInverse),this.coordinateSystem=J.coordinateSystem,this}getWorldDirection(J){return super.getWorldDirection(J).negate()}updateMatrixWorld(J){super.updateMatrixWorld(J),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(J,Q){super.updateWorldMatrix(J,Q),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}var g8=new A,vZ=new PJ,fZ=new PJ;class O0 extends j7{constructor(J=50,Q=1,$=0.1,Z=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=J,this.zoom=1,this.near=$,this.far=Z,this.focus=10,this.aspect=Q,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(J,Q){return super.copy(J,Q),this.fov=J.fov,this.zoom=J.zoom,this.near=J.near,this.far=J.far,this.focus=J.focus,this.aspect=J.aspect,this.view=J.view===null?null:Object.assign({},J.view),this.filmGauge=J.filmGauge,this.filmOffset=J.filmOffset,this}setFocalLength(J){let Q=0.5*this.getFilmHeight()/J;this.fov=W9*2*Math.atan(Q),this.updateProjectionMatrix()}getFocalLength(){let J=Math.tan(G6*0.5*this.fov);return 0.5*this.getFilmHeight()/J}getEffectiveFOV(){return W9*2*Math.atan(Math.tan(G6*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(J,Q,$){g8.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),Q.set(g8.x,g8.y).multiplyScalar(-J/g8.z),g8.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),$.set(g8.x,g8.y).multiplyScalar(-J/g8.z)}getViewSize(J,Q){return this.getViewBounds(J,vZ,fZ),Q.subVectors(fZ,vZ)}setViewOffset(J,Q,$,Z,W,H){if(this.aspect=J/Q,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=J,this.view.fullHeight=Q,this.view.offsetX=$,this.view.offsetY=Z,this.view.width=W,this.view.height=H,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let J=this.near,Q=J*Math.tan(G6*0.5*this.fov)/this.zoom,$=2*Q,Z=this.aspect*$,W=-0.5*Z,H=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:X,fullHeight:K}=H;W+=H.offsetX*Z/X,Q-=H.offsetY*$/K,Z*=H.width/X,$*=H.height/K}let Y=this.filmOffset;if(Y!==0)W+=J*Y/this.getFilmWidth();this.projectionMatrix.makePerspective(W,W+Z,Q,Q-$,J,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(J){let Q=super.toJSON(J);if(Q.object.fov=this.fov,Q.object.zoom=this.zoom,Q.object.near=this.near,Q.object.far=this.far,Q.object.focus=this.focus,Q.object.aspect=this.aspect,this.view!==null)Q.object.view=Object.assign({},this.view);return Q.object.filmGauge=this.filmGauge,Q.object.filmOffset=this.filmOffset,Q}}var T9=-90,A9=1;class A$ extends Z0{constructor(J,Q,$){super();this.type="CubeCamera",this.renderTarget=$,this.coordinateSystem=null,this.activeMipmapLevel=0;let Z=new O0(T9,A9,J,Q);Z.layers=this.layers,this.add(Z);let W=new O0(T9,A9,J,Q);W.layers=this.layers,this.add(W);let H=new O0(T9,A9,J,Q);H.layers=this.layers,this.add(H);let Y=new O0(T9,A9,J,Q);Y.layers=this.layers,this.add(Y);let X=new O0(T9,A9,J,Q);X.layers=this.layers,this.add(X);let K=new O0(T9,A9,J,Q);K.layers=this.layers,this.add(K)}updateCoordinateSystem(){let J=this.coordinateSystem,Q=this.children.concat(),[$,Z,W,H,Y,X]=Q;for(let K of Q)this.remove(K);if(J===2000)$.up.set(0,1,0),$.lookAt(1,0,0),Z.up.set(0,1,0),Z.lookAt(-1,0,0),W.up.set(0,0,-1),W.lookAt(0,1,0),H.up.set(0,0,1),H.lookAt(0,-1,0),Y.up.set(0,1,0),Y.lookAt(0,0,1),X.up.set(0,1,0),X.lookAt(0,0,-1);else if(J===2001)$.up.set(0,-1,0),$.lookAt(-1,0,0),Z.up.set(0,-1,0),Z.lookAt(1,0,0),W.up.set(0,0,1),W.lookAt(0,1,0),H.up.set(0,0,-1),H.lookAt(0,-1,0),Y.up.set(0,-1,0),Y.lookAt(0,0,1),X.up.set(0,-1,0),X.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+J);for(let K of Q)this.add(K),K.updateMatrixWorld()}update(J,Q){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:$,activeMipmapLevel:Z}=this;if(this.coordinateSystem!==J.coordinateSystem)this.coordinateSystem=J.coordinateSystem,this.updateCoordinateSystem();let[W,H,Y,X,K,U]=this.children,G=J.getRenderTarget(),q=J.getActiveCubeFace(),E=J.getActiveMipmapLevel(),O=J.xr.enabled;J.xr.enabled=!1;let k=$.texture.generateMipmaps;$.texture.generateMipmaps=!1,J.setRenderTarget($,0,Z),J.render(Q,W),J.setRenderTarget($,1,Z),J.render(Q,H),J.setRenderTarget($,2,Z),J.render(Q,Y),J.setRenderTarget($,3,Z),J.render(Q,X),J.setRenderTarget($,4,Z),J.render(Q,K),$.texture.generateMipmaps=k,J.setRenderTarget($,5,Z),J.render(Q,U),J.setRenderTarget(G,q,E),J.xr.enabled=O,$.texture.needsPMREMUpdate=!0}}class y7 extends E0{constructor(J=[],Q=301,$,Z,W,H,Y,X,K,U){super(J,Q,$,Z,W,H,Y,X,K,U);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(J){this.image=J}}class S$ extends T8{constructor(J=1,Q={}){super(J,J,Q);this.isWebGLCubeRenderTarget=!0;let $={width:J,height:J,depth:1},Z=[$,$,$,$,$,$];this.texture=new y7(Z),this._setTextureOptions(Q),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(J,Q){this.texture.type=Q.type,this.texture.colorSpace=Q.colorSpace,this.texture.generateMipmaps=Q.generateMipmaps,this.texture.minFilter=Q.minFilter,this.texture.magFilter=Q.magFilter;let $={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},Z=new d9(5,5,5),W=new N8({name:"CubemapFromEquirect",uniforms:G9($.uniforms),vertexShader:$.vertexShader,fragmentShader:$.fragmentShader,side:1,blending:0});W.uniforms.tEquirect.value=Q;let H=new _0(Z,W),Y=Q.minFilter;if(Q.minFilter===1008)Q.minFilter=1006;return new A$(1,10,this).update(J,H),Q.minFilter=Y,H.geometry.dispose(),H.material.dispose(),this}clear(J,Q=!0,$=!0,Z=!0){let W=J.getRenderTarget();for(let H=0;H<6;H++)J.setRenderTarget(this,H),J.clear(Q,$,Z);J.setRenderTarget(W)}}class X8 extends Z0{constructor(){super();this.isGroup=!0,this.type="Group"}}var XX={type:"move"};class V6{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new X8,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new X8,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new X8,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A;return this._grip}dispatchEvent(J){if(this._targetRay!==null)this._targetRay.dispatchEvent(J);if(this._grip!==null)this._grip.dispatchEvent(J);if(this._hand!==null)this._hand.dispatchEvent(J);return this}connect(J){if(J&&J.hand){let Q=this._hand;if(Q)for(let $ of J.hand.values())this._getHandJoint(Q,$)}return this.dispatchEvent({type:"connected",data:J}),this}disconnect(J){if(this.dispatchEvent({type:"disconnected",data:J}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(J,Q,$){let Z=null,W=null,H=null,Y=this._targetRay,X=this._grip,K=this._hand;if(J&&Q.session.visibilityState!=="visible-blurred"){if(K&&J.hand){H=!0;for(let k of J.hand.values()){let M=Q.getJointPose(k,$),N=this._getHandJoint(K,k);if(M!==null)N.matrix.fromArray(M.transform.matrix),N.matrix.decompose(N.position,N.rotation,N.scale),N.matrixWorldNeedsUpdate=!0,N.jointRadius=M.radius;N.visible=M!==null}let U=K.joints["index-finger-tip"],G=K.joints["thumb-tip"],q=U.position.distanceTo(G.position),E=0.02,O=0.005;if(K.inputState.pinching&&q>E+O)K.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:J.handedness,target:this});else if(!K.inputState.pinching&&q<=E-O)K.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:J.handedness,target:this})}else if(X!==null&&J.gripSpace){if(W=Q.getPose(J.gripSpace,$),W!==null){if(X.matrix.fromArray(W.transform.matrix),X.matrix.decompose(X.position,X.rotation,X.scale),X.matrixWorldNeedsUpdate=!0,W.linearVelocity)X.hasLinearVelocity=!0,X.linearVelocity.copy(W.linearVelocity);else X.hasLinearVelocity=!1;if(W.angularVelocity)X.hasAngularVelocity=!0,X.angularVelocity.copy(W.angularVelocity);else X.hasAngularVelocity=!1}}if(Y!==null){if(Z=Q.getPose(J.targetRaySpace,$),Z===null&&W!==null)Z=W;if(Z!==null){if(Y.matrix.fromArray(Z.transform.matrix),Y.matrix.decompose(Y.position,Y.rotation,Y.scale),Y.matrixWorldNeedsUpdate=!0,Z.linearVelocity)Y.hasLinearVelocity=!0,Y.linearVelocity.copy(Z.linearVelocity);else Y.hasLinearVelocity=!1;if(Z.angularVelocity)Y.hasAngularVelocity=!0,Y.angularVelocity.copy(Z.angularVelocity);else Y.hasAngularVelocity=!1;this.dispatchEvent(XX)}}}if(Y!==null)Y.visible=Z!==null;if(X!==null)X.visible=W!==null;if(K!==null)K.visible=H!==null;return this}_getHandJoint(J,Q){if(J.joints[Q.jointName]===void 0){let $=new X8;$.matrixAutoUpdate=!1,$.visible=!1,J.joints[Q.jointName]=$,J.add($)}return J.joints[Q.jointName]}}class v7 extends Z0{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Z8,this.environmentIntensity=1,this.environmentRotation=new Z8,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(J,Q){if(super.copy(J,Q),J.background!==null)this.background=J.background.clone();if(J.environment!==null)this.environment=J.environment.clone();if(J.fog!==null)this.fog=J.fog.clone();if(this.backgroundBlurriness=J.backgroundBlurriness,this.backgroundIntensity=J.backgroundIntensity,this.backgroundRotation.copy(J.backgroundRotation),this.environmentIntensity=J.environmentIntensity,this.environmentRotation.copy(J.environmentRotation),J.overrideMaterial!==null)this.overrideMaterial=J.overrideMaterial.clone();return this.matrixAutoUpdate=J.matrixAutoUpdate,this}toJSON(J){let Q=super.toJSON(J);if(this.fog!==null)Q.object.fog=this.fog.toJSON();if(this.backgroundBlurriness>0)Q.object.backgroundBlurriness=this.backgroundBlurriness;if(this.backgroundIntensity!==1)Q.object.backgroundIntensity=this.backgroundIntensity;if(Q.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1)Q.object.environmentIntensity=this.environmentIntensity;return Q.object.environmentRotation=this.environmentRotation.toArray(),Q}}class z6{constructor(J,Q){this.isInterleavedBuffer=!0,this.array=J,this.stride=Q,this.count=J!==void 0?J.length/Q:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=$8()}onUploadCallback(){}set needsUpdate(J){if(J===!0)this.version++}setUsage(J){return this.usage=J,this}addUpdateRange(J,Q){this.updateRanges.push({start:J,count:Q})}clearUpdateRanges(){this.updateRanges.length=0}copy(J){return this.array=new J.array.constructor(J.array),this.count=J.count,this.stride=J.stride,this.usage=J.usage,this}copyAt(J,Q,$){J*=this.stride,$*=Q.stride;for(let Z=0,W=this.stride;Z<W;Z++)this.array[J+Z]=Q.array[$+Z];return this}set(J,Q=0){return this.array.set(J,Q),this}clone(J){if(J.arrayBuffers===void 0)J.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=$8();if(J.arrayBuffers[this.array.buffer._uuid]===void 0)J.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let Q=new this.array.constructor(J.arrayBuffers[this.array.buffer._uuid]),$=new this.constructor(Q,this.stride);return $.setUsage(this.usage),$}onUpload(J){return this.onUploadCallback=J,this}toJSON(J){if(J.arrayBuffers===void 0)J.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=$8();if(J.arrayBuffers[this.array.buffer._uuid]===void 0)J.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));return{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}var P0=new A;class m9{constructor(J,Q,$,Z=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=J,this.itemSize=Q,this.offset=$,this.normalized=Z}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(J){this.data.needsUpdate=J}applyMatrix4(J){for(let Q=0,$=this.data.count;Q<$;Q++)P0.fromBufferAttribute(this,Q),P0.applyMatrix4(J),this.setXYZ(Q,P0.x,P0.y,P0.z);return this}applyNormalMatrix(J){for(let Q=0,$=this.count;Q<$;Q++)P0.fromBufferAttribute(this,Q),P0.applyNormalMatrix(J),this.setXYZ(Q,P0.x,P0.y,P0.z);return this}transformDirection(J){for(let Q=0,$=this.count;Q<$;Q++)P0.fromBufferAttribute(this,Q),P0.transformDirection(J),this.setXYZ(Q,P0.x,P0.y,P0.z);return this}getComponent(J,Q){let $=this.array[J*this.data.stride+this.offset+Q];if(this.normalized)$=Q8($,this.array);return $}setComponent(J,Q,$){if(this.normalized)$=aJ($,this.array);return this.data.array[J*this.data.stride+this.offset+Q]=$,this}setX(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.data.array[J*this.data.stride+this.offset]=Q,this}setY(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.data.array[J*this.data.stride+this.offset+1]=Q,this}setZ(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.data.array[J*this.data.stride+this.offset+2]=Q,this}setW(J,Q){if(this.normalized)Q=aJ(Q,this.array);return this.data.array[J*this.data.stride+this.offset+3]=Q,this}getX(J){let Q=this.data.array[J*this.data.stride+this.offset];if(this.normalized)Q=Q8(Q,this.array);return Q}getY(J){let Q=this.data.array[J*this.data.stride+this.offset+1];if(this.normalized)Q=Q8(Q,this.array);return Q}getZ(J){let Q=this.data.array[J*this.data.stride+this.offset+2];if(this.normalized)Q=Q8(Q,this.array);return Q}getW(J){let Q=this.data.array[J*this.data.stride+this.offset+3];if(this.normalized)Q=Q8(Q,this.array);return Q}setXY(J,Q,$){if(J=J*this.data.stride+this.offset,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array);return this.data.array[J+0]=Q,this.data.array[J+1]=$,this}setXYZ(J,Q,$,Z){if(J=J*this.data.stride+this.offset,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array),Z=aJ(Z,this.array);return this.data.array[J+0]=Q,this.data.array[J+1]=$,this.data.array[J+2]=Z,this}setXYZW(J,Q,$,Z,W){if(J=J*this.data.stride+this.offset,this.normalized)Q=aJ(Q,this.array),$=aJ($,this.array),Z=aJ(Z,this.array),W=aJ(W,this.array);return this.data.array[J+0]=Q,this.data.array[J+1]=$,this.data.array[J+2]=Z,this.data.array[J+3]=W,this}clone(J){if(J===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let Q=[];for(let $=0;$<this.count;$++){let Z=$*this.data.stride+this.offset;for(let W=0;W<this.itemSize;W++)Q.push(this.data.array[Z+W])}return new F0(new this.array.constructor(Q),this.itemSize,this.normalized)}else{if(J.interleavedBuffers===void 0)J.interleavedBuffers={};if(J.interleavedBuffers[this.data.uuid]===void 0)J.interleavedBuffers[this.data.uuid]=this.data.clone(J);return new m9(J.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(J){if(J===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let Q=[];for(let $=0;$<this.count;$++){let Z=$*this.data.stride+this.offset;for(let W=0;W<this.itemSize;W++)Q.push(this.data.array[Z+W])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:Q,normalized:this.normalized}}else{if(J.interleavedBuffers===void 0)J.interleavedBuffers={};if(J.interleavedBuffers[this.data.uuid]===void 0)J.interleavedBuffers[this.data.uuid]=this.data.toJSON(J);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var hZ=new A,bZ=new sJ,xZ=new sJ,KX=new A,gZ=new vJ,t6=new A,IQ=new p0,pZ=new vJ,PQ=new n8;class f7 extends _0{constructor(J,Q){super(J,Q);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new vJ,this.bindMatrixInverse=new vJ,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let J=this.geometry;if(this.boundingBox===null)this.boundingBox=new A0;this.boundingBox.makeEmpty();let Q=J.getAttribute("position");for(let $=0;$<Q.count;$++)this.getVertexPosition($,t6),this.boundingBox.expandByPoint(t6)}computeBoundingSphere(){let J=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new p0;this.boundingSphere.makeEmpty();let Q=J.getAttribute("position");for(let $=0;$<Q.count;$++)this.getVertexPosition($,t6),this.boundingSphere.expandByPoint(t6)}copy(J,Q){if(super.copy(J,Q),this.bindMode=J.bindMode,this.bindMatrix.copy(J.bindMatrix),this.bindMatrixInverse.copy(J.bindMatrixInverse),this.skeleton=J.skeleton,J.boundingBox!==null)this.boundingBox=J.boundingBox.clone();if(J.boundingSphere!==null)this.boundingSphere=J.boundingSphere.clone();return this}raycast(J,Q){let $=this.material,Z=this.matrixWorld;if($===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(IQ.copy(this.boundingSphere),IQ.applyMatrix4(Z),J.ray.intersectsSphere(IQ)===!1)return;if(pZ.copy(Z).invert(),PQ.copy(J.ray).applyMatrix4(pZ),this.boundingBox!==null){if(PQ.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(J,Q,PQ)}getVertexPosition(J,Q){return super.getVertexPosition(J,Q),this.applyBoneTransform(J,Q),Q}bind(J,Q){if(this.skeleton=J,Q===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),Q=this.matrixWorld;this.bindMatrix.copy(Q),this.bindMatrixInverse.copy(Q).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let J=new sJ,Q=this.geometry.attributes.skinWeight;for(let $=0,Z=Q.count;$<Z;$++){J.fromBufferAttribute(Q,$);let W=1/J.manhattanLength();if(W!==1/0)J.multiplyScalar(W);else J.set(1,0,0,0);Q.setXYZW($,J.x,J.y,J.z,J.w)}}updateMatrixWorld(J){if(super.updateMatrixWorld(J),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(J,Q){let $=this.skeleton,Z=this.geometry;bZ.fromBufferAttribute(Z.attributes.skinIndex,J),xZ.fromBufferAttribute(Z.attributes.skinWeight,J),hZ.copy(Q).applyMatrix4(this.bindMatrix),Q.set(0,0,0);for(let W=0;W<4;W++){let H=xZ.getComponent(W);if(H!==0){let Y=bZ.getComponent(W);gZ.multiplyMatrices($.bones[Y].matrixWorld,$.boneInverses[Y]),Q.addScaledVector(KX.copy(hZ).applyMatrix4(gZ),H)}}return Q.applyMatrix4(this.bindMatrixInverse)}}class B6 extends Z0{constructor(){super();this.isBone=!0,this.type="Bone"}}class h7 extends E0{constructor(J=null,Q=1,$=1,Z,W,H,Y,X,K=1003,U=1003,G,q){super(null,H,Y,X,K,U,Z,W,G,q);this.isDataTexture=!0,this.image={data:J,width:Q,height:$},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var lZ=new vJ,UX=new vJ;class C6{constructor(J=[],Q=[]){this.uuid=$8(),this.bones=J.slice(0),this.boneInverses=Q,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let J=this.bones,Q=this.boneInverses;if(this.boneMatrices=new Float32Array(J.length*16),Q.length===0)this.calculateInverses();else if(J.length!==Q.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let $=0,Z=this.bones.length;$<Z;$++)this.boneInverses.push(new vJ)}}calculateInverses(){this.boneInverses.length=0;for(let J=0,Q=this.bones.length;J<Q;J++){let $=new vJ;if(this.bones[J])$.copy(this.bones[J].matrixWorld).invert();this.boneInverses.push($)}}pose(){for(let J=0,Q=this.bones.length;J<Q;J++){let $=this.bones[J];if($)$.matrixWorld.copy(this.boneInverses[J]).invert()}for(let J=0,Q=this.bones.length;J<Q;J++){let $=this.bones[J];if($){if($.parent&&$.parent.isBone)$.matrix.copy($.parent.matrixWorld).invert(),$.matrix.multiply($.matrixWorld);else $.matrix.copy($.matrixWorld);$.matrix.decompose($.position,$.quaternion,$.scale)}}}update(){let J=this.bones,Q=this.boneInverses,$=this.boneMatrices,Z=this.boneTexture;for(let W=0,H=J.length;W<H;W++){let Y=J[W]?J[W].matrixWorld:UX;lZ.multiplyMatrices(Y,Q[W]),lZ.toArray($,W*16)}if(Z!==null)Z.needsUpdate=!0}clone(){return new C6(this.bones,this.boneInverses)}computeBoneTexture(){let J=Math.sqrt(this.bones.length*4);J=Math.ceil(J/4)*4,J=Math.max(J,4);let Q=new Float32Array(J*J*4);Q.set(this.boneMatrices);let $=new h7(Q,J,J,1023,1015);return $.needsUpdate=!0,this.boneMatrices=Q,this.boneTexture=$,this}getBoneByName(J){for(let Q=0,$=this.bones.length;Q<$;Q++){let Z=this.bones[Q];if(Z.name===J)return Z}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(J,Q){this.uuid=J.uuid;for(let $=0,Z=J.bones.length;$<Z;$++){let W=J.bones[$],H=Q[W];if(H===void 0)console.warn("THREE.Skeleton: No bone found with UUID:",W),H=new B6;this.bones.push(H),this.boneInverses.push(new vJ().fromArray(J.boneInverses[$]))}return this.init(),this}toJSON(){let J={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};J.uuid=this.uuid;let Q=this.bones,$=this.boneInverses;for(let Z=0,W=Q.length;Z<W;Z++){let H=Q[Z];J.bones.push(H.uuid);let Y=$[Z];J.boneInverses.push(Y.toArray())}return J}}class Y9 extends F0{constructor(J,Q,$,Z=1){super(J,Q,$);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=Z}copy(J){return super.copy(J),this.meshPerAttribute=J.meshPerAttribute,this}toJSON(){let J=super.toJSON();return J.meshPerAttribute=this.meshPerAttribute,J.isInstancedBufferAttribute=!0,J}}var S9=new vJ,dZ=new vJ,e6=[],mZ=new A0,GX=new vJ,Y6=new _0,X6=new p0;class b7 extends _0{constructor(J,Q,$){super(J,Q);this.isInstancedMesh=!0,this.instanceMatrix=new Y9(new Float32Array($*16),16),this.instanceColor=null,this.morphTexture=null,this.count=$,this.boundingBox=null,this.boundingSphere=null;for(let Z=0;Z<$;Z++)this.setMatrixAt(Z,GX)}computeBoundingBox(){let J=this.geometry,Q=this.count;if(this.boundingBox===null)this.boundingBox=new A0;if(J.boundingBox===null)J.computeBoundingBox();this.boundingBox.makeEmpty();for(let $=0;$<Q;$++)this.getMatrixAt($,S9),mZ.copy(J.boundingBox).applyMatrix4(S9),this.boundingBox.union(mZ)}computeBoundingSphere(){let J=this.geometry,Q=this.count;if(this.boundingSphere===null)this.boundingSphere=new p0;if(J.boundingSphere===null)J.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let $=0;$<Q;$++)this.getMatrixAt($,S9),X6.copy(J.boundingSphere).applyMatrix4(S9),this.boundingSphere.union(X6)}copy(J,Q){if(super.copy(J,Q),this.instanceMatrix.copy(J.instanceMatrix),J.morphTexture!==null)this.morphTexture=J.morphTexture.clone();if(J.instanceColor!==null)this.instanceColor=J.instanceColor.clone();if(this.count=J.count,J.boundingBox!==null)this.boundingBox=J.boundingBox.clone();if(J.boundingSphere!==null)this.boundingSphere=J.boundingSphere.clone();return this}getColorAt(J,Q){Q.fromArray(this.instanceColor.array,J*3)}getMatrixAt(J,Q){Q.fromArray(this.instanceMatrix.array,J*16)}getMorphAt(J,Q){let $=Q.morphTargetInfluences,Z=this.morphTexture.source.data.data,W=$.length+1,H=J*W+1;for(let Y=0;Y<$.length;Y++)$[Y]=Z[H+Y]}raycast(J,Q){let $=this.matrixWorld,Z=this.count;if(Y6.geometry=this.geometry,Y6.material=this.material,Y6.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(X6.copy(this.boundingSphere),X6.applyMatrix4($),J.ray.intersectsSphere(X6)===!1)return;for(let W=0;W<Z;W++){this.getMatrixAt(W,S9),dZ.multiplyMatrices($,S9),Y6.matrixWorld=dZ,Y6.raycast(J,e6);for(let H=0,Y=e6.length;H<Y;H++){let X=e6[H];X.instanceId=W,X.object=this,Q.push(X)}e6.length=0}}setColorAt(J,Q){if(this.instanceColor===null)this.instanceColor=new Y9(new Float32Array(this.instanceMatrix.count*3).fill(1),3);Q.toArray(this.instanceColor.array,J*3)}setMatrixAt(J,Q){Q.toArray(this.instanceMatrix.array,J*16)}setMorphAt(J,Q){let $=Q.morphTargetInfluences,Z=$.length+1;if(this.morphTexture===null)this.morphTexture=new h7(new Float32Array(Z*this.count),Z,this.count,1028,1015);let W=this.morphTexture.source.data.data,H=0;for(let K=0;K<$.length;K++)H+=$[K];let Y=this.geometry.morphTargetsRelative?1:1-H,X=Z*J;W[X]=Y,W.set($,X+1)}updateMorphTargets(){}dispose(){if(this.dispatchEvent({type:"dispose"}),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var TQ=new A,qX=new A,EX=new fJ;class J8{constructor(J=new A(1,0,0),Q=0){this.isPlane=!0,this.normal=J,this.constant=Q}set(J,Q){return this.normal.copy(J),this.constant=Q,this}setComponents(J,Q,$,Z){return this.normal.set(J,Q,$),this.constant=Z,this}setFromNormalAndCoplanarPoint(J,Q){return this.normal.copy(J),this.constant=-Q.dot(this.normal),this}setFromCoplanarPoints(J,Q,$){let Z=TQ.subVectors($,Q).cross(qX.subVectors(J,Q)).normalize();return this.setFromNormalAndCoplanarPoint(Z,J),this}copy(J){return this.normal.copy(J.normal),this.constant=J.constant,this}normalize(){let J=1/this.normal.length();return this.normal.multiplyScalar(J),this.constant*=J,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(J){return this.normal.dot(J)+this.constant}distanceToSphere(J){return this.distanceToPoint(J.center)-J.radius}projectPoint(J,Q){return Q.copy(J).addScaledVector(this.normal,-this.distanceToPoint(J))}intersectLine(J,Q){let $=J.delta(TQ),Z=this.normal.dot($);if(Z===0){if(this.distanceToPoint(J.start)===0)return Q.copy(J.start);return null}let W=-(J.start.dot(this.normal)+this.constant)/Z;if(W<0||W>1)return null;return Q.copy(J.start).addScaledVector($,W)}intersectsLine(J){let Q=this.distanceToPoint(J.start),$=this.distanceToPoint(J.end);return Q<0&&$>0||$<0&&Q>0}intersectsBox(J){return J.intersectsPlane(this)}intersectsSphere(J){return J.intersectsPlane(this)}coplanarPoint(J){return J.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(J,Q){let $=Q||EX.getNormalMatrix(J),Z=this.coplanarPoint(TQ).applyMatrix4(J),W=this.normal.applyMatrix3($).normalize();return this.constant=-Z.dot(W),this}translate(J){return this.constant-=J.dot(this.normal),this}equals(J){return J.normal.equals(this.normal)&&J.constant===this.constant}clone(){return new this.constructor().copy(this)}}var Z9=new p0,NX=new PJ(0.5,0.5),J7=new A;class _6{constructor(J=new J8,Q=new J8,$=new J8,Z=new J8,W=new J8,H=new J8){this.planes=[J,Q,$,Z,W,H]}set(J,Q,$,Z,W,H){let Y=this.planes;return Y[0].copy(J),Y[1].copy(Q),Y[2].copy($),Y[3].copy(Z),Y[4].copy(W),Y[5].copy(H),this}copy(J){let Q=this.planes;for(let $=0;$<6;$++)Q[$].copy(J.planes[$]);return this}setFromProjectionMatrix(J,Q=2000,$=!1){let Z=this.planes,W=J.elements,H=W[0],Y=W[1],X=W[2],K=W[3],U=W[4],G=W[5],q=W[6],E=W[7],O=W[8],k=W[9],M=W[10],N=W[11],F=W[12],C=W[13],L=W[14],_=W[15];if(Z[0].setComponents(K-H,E-U,N-O,_-F).normalize(),Z[1].setComponents(K+H,E+U,N+O,_+F).normalize(),Z[2].setComponents(K+Y,E+G,N+k,_+C).normalize(),Z[3].setComponents(K-Y,E-G,N-k,_-C).normalize(),$)Z[4].setComponents(X,q,M,L).normalize(),Z[5].setComponents(K-X,E-q,N-M,_-L).normalize();else if(Z[4].setComponents(K-X,E-q,N-M,_-L).normalize(),Q===2000)Z[5].setComponents(K+X,E+q,N+M,_+L).normalize();else if(Q===2001)Z[5].setComponents(X,q,M,L).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+Q);return this}intersectsObject(J){if(J.boundingSphere!==void 0){if(J.boundingSphere===null)J.computeBoundingSphere();Z9.copy(J.boundingSphere).applyMatrix4(J.matrixWorld)}else{let Q=J.geometry;if(Q.boundingSphere===null)Q.computeBoundingSphere();Z9.copy(Q.boundingSphere).applyMatrix4(J.matrixWorld)}return this.intersectsSphere(Z9)}intersectsSprite(J){Z9.center.set(0,0,0);let Q=NX.distanceTo(J.center);return Z9.radius=0.7071067811865476+Q,Z9.applyMatrix4(J.matrixWorld),this.intersectsSphere(Z9)}intersectsSphere(J){let Q=this.planes,$=J.center,Z=-J.radius;for(let W=0;W<6;W++)if(Q[W].distanceToPoint($)<Z)return!1;return!0}intersectsBox(J){let Q=this.planes;for(let $=0;$<6;$++){let Z=Q[$];if(J7.x=Z.normal.x>0?J.max.x:J.min.x,J7.y=Z.normal.y>0?J.max.y:J.min.y,J7.z=Z.normal.z>0?J.max.z:J.min.z,Z.distanceToPoint(J7)<0)return!1}return!0}containsPoint(J){let Q=this.planes;for(let $=0;$<6;$++)if(Q[$].distanceToPoint(J)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class w6 extends l0{constructor(J){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new jJ(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(J)}copy(J){return super.copy(J),this.color.copy(J.color),this.map=J.map,this.linewidth=J.linewidth,this.linecap=J.linecap,this.linejoin=J.linejoin,this.fog=J.fog,this}}var Y7=new A,X7=new A,uZ=new vJ,K6=new n8,Q7=new p0,AQ=new A,cZ=new A;class u9 extends Z0{constructor(J=new d0,Q=new w6){super();this.isLine=!0,this.type="Line",this.geometry=J,this.material=Q,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(J,Q){return super.copy(J,Q),this.material=Array.isArray(J.material)?J.material.slice():J.material,this.geometry=J.geometry,this}computeLineDistances(){let J=this.geometry;if(J.index===null){let Q=J.attributes.position,$=[0];for(let Z=1,W=Q.count;Z<W;Z++)Y7.fromBufferAttribute(Q,Z-1),X7.fromBufferAttribute(Q,Z),$[Z]=$[Z-1],$[Z]+=Y7.distanceTo(X7);J.setAttribute("lineDistance",new i0($,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(J,Q){let $=this.geometry,Z=this.matrixWorld,W=J.params.Line.threshold,H=$.drawRange;if($.boundingSphere===null)$.computeBoundingSphere();if(Q7.copy($.boundingSphere),Q7.applyMatrix4(Z),Q7.radius+=W,J.ray.intersectsSphere(Q7)===!1)return;uZ.copy(Z).invert(),K6.copy(J.ray).applyMatrix4(uZ);let Y=W/((this.scale.x+this.scale.y+this.scale.z)/3),X=Y*Y,K=this.isLineSegments?2:1,U=$.index,q=$.attributes.position;if(U!==null){let E=Math.max(0,H.start),O=Math.min(U.count,H.start+H.count);for(let k=E,M=O-1;k<M;k+=K){let N=U.getX(k),F=U.getX(k+1),C=$7(this,J,K6,X,N,F,k);if(C)Q.push(C)}if(this.isLineLoop){let k=U.getX(O-1),M=U.getX(E),N=$7(this,J,K6,X,k,M,O-1);if(N)Q.push(N)}}else{let E=Math.max(0,H.start),O=Math.min(q.count,H.start+H.count);for(let k=E,M=O-1;k<M;k+=K){let N=$7(this,J,K6,X,k,k+1,k);if(N)Q.push(N)}if(this.isLineLoop){let k=$7(this,J,K6,X,O-1,E,O-1);if(k)Q.push(k)}}}updateMorphTargets(){let Q=this.geometry.morphAttributes,$=Object.keys(Q);if($.length>0){let Z=Q[$[0]];if(Z!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let W=0,H=Z.length;W<H;W++){let Y=Z[W].name||String(W);this.morphTargetInfluences.push(0),this.morphTargetDictionary[Y]=W}}}}}function $7(J,Q,$,Z,W,H,Y){let X=J.geometry.attributes.position;if(Y7.fromBufferAttribute(X,W),X7.fromBufferAttribute(X,H),$.distanceSqToSegment(Y7,X7,AQ,cZ)>Z)return;AQ.applyMatrix4(J.matrixWorld);let U=Q.ray.origin.distanceTo(AQ);if(U<Q.near||U>Q.far)return;return{distance:U,point:cZ.clone().applyMatrix4(J.matrixWorld),index:Y,face:null,faceIndex:null,barycoord:null,object:J}}var nZ=new A,sZ=new A;class x7 extends u9{constructor(J,Q){super(J,Q);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let J=this.geometry;if(J.index===null){let Q=J.attributes.position,$=[];for(let Z=0,W=Q.count;Z<W;Z+=2)nZ.fromBufferAttribute(Q,Z),sZ.fromBufferAttribute(Q,Z+1),$[Z]=Z===0?0:$[Z-1],$[Z+1]=$[Z]+nZ.distanceTo(sZ);J.setAttribute("lineDistance",new i0($,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class g7 extends u9{constructor(J,Q){super(J,Q);this.isLineLoop=!0,this.type="LineLoop"}}class I6 extends l0{constructor(J){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new jJ(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(J)}copy(J){return super.copy(J),this.color.copy(J.color),this.map=J.map,this.alphaMap=J.alphaMap,this.size=J.size,this.sizeAttenuation=J.sizeAttenuation,this.fog=J.fog,this}}var oZ=new vJ,vQ=new n8,Z7=new p0,W7=new A;class p7 extends Z0{constructor(J=new d0,Q=new I6){super();this.isPoints=!0,this.type="Points",this.geometry=J,this.material=Q,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(J,Q){return super.copy(J,Q),this.material=Array.isArray(J.material)?J.material.slice():J.material,this.geometry=J.geometry,this}raycast(J,Q){let $=this.geometry,Z=this.matrixWorld,W=J.params.Points.threshold,H=$.drawRange;if($.boundingSphere===null)$.computeBoundingSphere();if(Z7.copy($.boundingSphere),Z7.applyMatrix4(Z),Z7.radius+=W,J.ray.intersectsSphere(Z7)===!1)return;oZ.copy(Z).invert(),vQ.copy(J.ray).applyMatrix4(oZ);let Y=W/((this.scale.x+this.scale.y+this.scale.z)/3),X=Y*Y,K=$.index,G=$.attributes.position;if(K!==null){let q=Math.max(0,H.start),E=Math.min(K.count,H.start+H.count);for(let O=q,k=E;O<k;O++){let M=K.getX(O);W7.fromBufferAttribute(G,M),iZ(W7,M,X,Z,J,Q,this)}}else{let q=Math.max(0,H.start),E=Math.min(G.count,H.start+H.count);for(let O=q,k=E;O<k;O++)W7.fromBufferAttribute(G,O),iZ(W7,O,X,Z,J,Q,this)}}updateMorphTargets(){let Q=this.geometry.morphAttributes,$=Object.keys(Q);if($.length>0){let Z=Q[$[0]];if(Z!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let W=0,H=Z.length;W<H;W++){let Y=Z[W].name||String(W);this.morphTargetInfluences.push(0),this.morphTargetDictionary[Y]=W}}}}}function iZ(J,Q,$,Z,W,H,Y){let X=vQ.distanceSqToPoint(J);if(X<$){let K=new A;vQ.closestPointToPoint(J,K),K.applyMatrix4(Z);let U=W.ray.origin.distanceTo(K);if(U<W.near||U>W.far)return;H.push({distance:U,distanceToRay:Math.sqrt(X),point:K,index:Q,face:null,faceIndex:null,barycoord:null,object:Y})}}class l7 extends E0{constructor(J,Q,$=1014,Z,W,H,Y=1003,X=1003,K,U=1026,G=1){if(U!==1026&&U!==1027)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let q={width:J,height:Q,depth:G};super(q,Z,W,H,Y,X,U,$,K);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(J){return super.copy(J),this.source=new L6(Object.assign({},J.image)),this.compareFunction=J.compareFunction,this}toJSON(J){let Q=super.toJSON(J);if(this.compareFunction!==null)Q.compareFunction=this.compareFunction;return Q}}class P6 extends d0{constructor(J=1,Q=1,$=1,Z=1){super();this.type="PlaneGeometry",this.parameters={width:J,height:Q,widthSegments:$,heightSegments:Z};let W=J/2,H=Q/2,Y=Math.floor($),X=Math.floor(Z),K=Y+1,U=X+1,G=J/Y,q=Q/X,E=[],O=[],k=[],M=[];for(let N=0;N<U;N++){let F=N*q-H;for(let C=0;C<K;C++){let L=C*G-W;O.push(L,-F,0),k.push(0,0,1),M.push(C/Y),M.push(1-N/X)}}for(let N=0;N<X;N++)for(let F=0;F<Y;F++){let C=F+K*N,L=F+K*(N+1),_=F+1+K*(N+1),v=F+1+K*N;E.push(C,L,v),E.push(L,_,v)}this.setIndex(E),this.setAttribute("position",new i0(O,3)),this.setAttribute("normal",new i0(k,3)),this.setAttribute("uv",new i0(M,2))}copy(J){return super.copy(J),this.parameters=Object.assign({},J.parameters),this}static fromJSON(J){return new P6(J.width,J.height,J.widthSegments,J.heightSegments)}}class c9 extends l0{constructor(J){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new jJ(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jJ(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new PJ(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Z8,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(J)}copy(J){return super.copy(J),this.defines={STANDARD:""},this.color.copy(J.color),this.roughness=J.roughness,this.metalness=J.metalness,this.map=J.map,this.lightMap=J.lightMap,this.lightMapIntensity=J.lightMapIntensity,this.aoMap=J.aoMap,this.aoMapIntensity=J.aoMapIntensity,this.emissive.copy(J.emissive),this.emissiveMap=J.emissiveMap,this.emissiveIntensity=J.emissiveIntensity,this.bumpMap=J.bumpMap,this.bumpScale=J.bumpScale,this.normalMap=J.normalMap,this.normalMapType=J.normalMapType,this.normalScale.copy(J.normalScale),this.displacementMap=J.displacementMap,this.displacementScale=J.displacementScale,this.displacementBias=J.displacementBias,this.roughnessMap=J.roughnessMap,this.metalnessMap=J.metalnessMap,this.alphaMap=J.alphaMap,this.envMap=J.envMap,this.envMapRotation.copy(J.envMapRotation),this.envMapIntensity=J.envMapIntensity,this.wireframe=J.wireframe,this.wireframeLinewidth=J.wireframeLinewidth,this.wireframeLinecap=J.wireframeLinecap,this.wireframeLinejoin=J.wireframeLinejoin,this.flatShading=J.flatShading,this.fog=J.fog,this}}class m0 extends c9{constructor(J){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new PJ(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return xJ(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(Q){this.ior=(1+0.4*Q)/(1-0.4*Q)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new jJ(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new jJ(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new jJ(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(J)}get anisotropy(){return this._anisotropy}set anisotropy(J){if(this._anisotropy>0!==J>0)this.version++;this._anisotropy=J}get clearcoat(){return this._clearcoat}set clearcoat(J){if(this._clearcoat>0!==J>0)this.version++;this._clearcoat=J}get iridescence(){return this._iridescence}set iridescence(J){if(this._iridescence>0!==J>0)this.version++;this._iridescence=J}get dispersion(){return this._dispersion}set dispersion(J){if(this._dispersion>0!==J>0)this.version++;this._dispersion=J}get sheen(){return this._sheen}set sheen(J){if(this._sheen>0!==J>0)this.version++;this._sheen=J}get transmission(){return this._transmission}set transmission(J){if(this._transmission>0!==J>0)this.version++;this._transmission=J}copy(J){return super.copy(J),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=J.anisotropy,this.anisotropyRotation=J.anisotropyRotation,this.anisotropyMap=J.anisotropyMap,this.clearcoat=J.clearcoat,this.clearcoatMap=J.clearcoatMap,this.clearcoatRoughness=J.clearcoatRoughness,this.clearcoatRoughnessMap=J.clearcoatRoughnessMap,this.clearcoatNormalMap=J.clearcoatNormalMap,this.clearcoatNormalScale.copy(J.clearcoatNormalScale),this.dispersion=J.dispersion,this.ior=J.ior,this.iridescence=J.iridescence,this.iridescenceMap=J.iridescenceMap,this.iridescenceIOR=J.iridescenceIOR,this.iridescenceThicknessRange=[...J.iridescenceThicknessRange],this.iridescenceThicknessMap=J.iridescenceThicknessMap,this.sheen=J.sheen,this.sheenColor.copy(J.sheenColor),this.sheenColorMap=J.sheenColorMap,this.sheenRoughness=J.sheenRoughness,this.sheenRoughnessMap=J.sheenRoughnessMap,this.transmission=J.transmission,this.transmissionMap=J.transmissionMap,this.thickness=J.thickness,this.thicknessMap=J.thicknessMap,this.attenuationDistance=J.attenuationDistance,this.attenuationColor.copy(J.attenuationColor),this.specularIntensity=J.specularIntensity,this.specularIntensityMap=J.specularIntensityMap,this.specularColor.copy(J.specularColor),this.specularColorMap=J.specularColorMap,this}}class j$ extends l0{constructor(J){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(J)}copy(J){return super.copy(J),this.depthPacking=J.depthPacking,this.map=J.map,this.alphaMap=J.alphaMap,this.displacementMap=J.displacementMap,this.displacementScale=J.displacementScale,this.displacementBias=J.displacementBias,this.wireframe=J.wireframe,this.wireframeLinewidth=J.wireframeLinewidth,this}}class y$ extends l0{constructor(J){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(J)}copy(J){return super.copy(J),this.map=J.map,this.alphaMap=J.alphaMap,this.displacementMap=J.displacementMap,this.displacementScale=J.displacementScale,this.displacementBias=J.displacementBias,this}}function H7(J,Q){if(!J||J.constructor===Q)return J;if(typeof Q.BYTES_PER_ELEMENT==="number")return new Q(J);return Array.prototype.slice.call(J)}function OX(J){return ArrayBuffer.isView(J)&&!(J instanceof DataView)}function FX(J){function Q(W,H){return J[W]-J[H]}let $=J.length,Z=Array($);for(let W=0;W!==$;++W)Z[W]=W;return Z.sort(Q),Z}function aZ(J,Q,$){let Z=J.length,W=new J.constructor(Z);for(let H=0,Y=0;Y!==Z;++H){let X=$[H]*Q;for(let K=0;K!==Q;++K)W[Y++]=J[X+K]}return W}function QH(J,Q,$,Z){let W=1,H=J[0];while(H!==void 0&&H[Z]===void 0)H=J[W++];if(H===void 0)return;let Y=H[Z];if(Y===void 0)return;if(Array.isArray(Y))do{if(Y=H[Z],Y!==void 0)Q.push(H.time),$.push(...Y);H=J[W++]}while(H!==void 0);else if(Y.toArray!==void 0)do{if(Y=H[Z],Y!==void 0)Q.push(H.time),Y.toArray($,$.length);H=J[W++]}while(H!==void 0);else do{if(Y=H[Z],Y!==void 0)Q.push(H.time),$.push(Y);H=J[W++]}while(H!==void 0)}class s8{constructor(J,Q,$,Z){this.parameterPositions=J,this._cachedIndex=0,this.resultBuffer=Z!==void 0?Z:new Q.constructor($),this.sampleValues=Q,this.valueSize=$,this.settings=null,this.DefaultSettings_={}}evaluate(J){let Q=this.parameterPositions,$=this._cachedIndex,Z=Q[$],W=Q[$-1];$:{J:{let H;Q:{Z:if(!(J<Z)){for(let Y=$+2;;){if(Z===void 0){if(J<W)break Z;return $=Q.length,this._cachedIndex=$,this.copySampleValue_($-1)}if($===Y)break;if(W=Z,Z=Q[++$],J<Z)break J}H=Q.length;break Q}if(!(J>=W)){let Y=Q[1];if(J<Y)$=2,W=Y;for(let X=$-2;;){if(W===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if($===X)break;if(Z=W,W=Q[--$-1],J>=W)break J}H=$,$=0;break Q}break $}while($<H){let Y=$+H>>>1;if(J<Q[Y])H=Y;else $=Y+1}if(Z=Q[$],W=Q[$-1],W===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(Z===void 0)return $=Q.length,this._cachedIndex=$,this.copySampleValue_($-1)}this._cachedIndex=$,this.intervalChanged_($,W,Z)}return this.interpolate_($,W,J,Z)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(J){let Q=this.resultBuffer,$=this.sampleValues,Z=this.valueSize,W=J*Z;for(let H=0;H!==Z;++H)Q[H]=$[W+H];return Q}interpolate_(){throw Error("call to abstract method")}intervalChanged_(){}}class v$ extends s8{constructor(J,Q,$,Z){super(J,Q,$,Z);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(J,Q,$){let Z=this.parameterPositions,W=J-2,H=J+1,Y=Z[W],X=Z[H];if(Y===void 0)switch(this.getSettings_().endingStart){case 2401:W=J,Y=2*Q-$;break;case 2402:W=Z.length-2,Y=Q+Z[W]-Z[W+1];break;default:W=J,Y=$}if(X===void 0)switch(this.getSettings_().endingEnd){case 2401:H=J,X=2*$-Q;break;case 2402:H=1,X=$+Z[1]-Z[0];break;default:H=J-1,X=Q}let K=($-Q)*0.5,U=this.valueSize;this._weightPrev=K/(Q-Y),this._weightNext=K/(X-$),this._offsetPrev=W*U,this._offsetNext=H*U}interpolate_(J,Q,$,Z){let W=this.resultBuffer,H=this.sampleValues,Y=this.valueSize,X=J*Y,K=X-Y,U=this._offsetPrev,G=this._offsetNext,q=this._weightPrev,E=this._weightNext,O=($-Q)/(Z-Q),k=O*O,M=k*O,N=-q*M+2*q*k-q*O,F=(1+q)*M+(-1.5-2*q)*k+(-0.5+q)*O+1,C=(-1-E)*M+(1.5+E)*k+0.5*O,L=E*M-E*k;for(let _=0;_!==Y;++_)W[_]=N*H[U+_]+F*H[K+_]+C*H[X+_]+L*H[G+_];return W}}class f$ extends s8{constructor(J,Q,$,Z){super(J,Q,$,Z)}interpolate_(J,Q,$,Z){let W=this.resultBuffer,H=this.sampleValues,Y=this.valueSize,X=J*Y,K=X-Y,U=($-Q)/(Z-Q),G=1-U;for(let q=0;q!==Y;++q)W[q]=H[K+q]*G+H[X+q]*U;return W}}class h$ extends s8{constructor(J,Q,$,Z){super(J,Q,$,Z)}interpolate_(J){return this.copySampleValue_(J-1)}}class u0{constructor(J,Q,$,Z){if(J===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(Q===void 0||Q.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+J);this.name=J,this.times=H7(Q,this.TimeBufferType),this.values=H7($,this.ValueBufferType),this.setInterpolation(Z||this.DefaultInterpolation)}static toJSON(J){let Q=J.constructor,$;if(Q.toJSON!==this.toJSON)$=Q.toJSON(J);else{$={name:J.name,times:H7(J.times,Array),values:H7(J.values,Array)};let Z=J.getInterpolation();if(Z!==J.DefaultInterpolation)$.interpolation=Z}return $.type=J.ValueTypeName,$}InterpolantFactoryMethodDiscrete(J){return new h$(this.times,this.values,this.getValueSize(),J)}InterpolantFactoryMethodLinear(J){return new f$(this.times,this.values,this.getValueSize(),J)}InterpolantFactoryMethodSmooth(J){return new v$(this.times,this.values,this.getValueSize(),J)}setInterpolation(J){let Q;switch(J){case 2300:Q=this.InterpolantFactoryMethodDiscrete;break;case 2301:Q=this.InterpolantFactoryMethodLinear;break;case 2302:Q=this.InterpolantFactoryMethodSmooth;break}if(Q===void 0){let $="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(J!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error($);return console.warn("THREE.KeyframeTrack:",$),this}return this.createInterpolant=Q,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}}getValueSize(){return this.values.length/this.times.length}shift(J){if(J!==0){let Q=this.times;for(let $=0,Z=Q.length;$!==Z;++$)Q[$]+=J}return this}scale(J){if(J!==1){let Q=this.times;for(let $=0,Z=Q.length;$!==Z;++$)Q[$]*=J}return this}trim(J,Q){let $=this.times,Z=$.length,W=0,H=Z-1;while(W!==Z&&$[W]<J)++W;while(H!==-1&&$[H]>Q)--H;if(++H,W!==0||H!==Z){if(W>=H)H=Math.max(H,1),W=H-1;let Y=this.getValueSize();this.times=$.slice(W,H),this.values=this.values.slice(W*Y,H*Y)}return this}validate(){let J=!0,Q=this.getValueSize();if(Q-Math.floor(Q)!==0)console.error("THREE.KeyframeTrack: Invalid value size in track.",this),J=!1;let $=this.times,Z=this.values,W=$.length;if(W===0)console.error("THREE.KeyframeTrack: Track is empty.",this),J=!1;let H=null;for(let Y=0;Y!==W;Y++){let X=$[Y];if(typeof X==="number"&&isNaN(X)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,Y,X),J=!1;break}if(H!==null&&H>X){console.error("THREE.KeyframeTrack: Out of order keys.",this,Y,X,H),J=!1;break}H=X}if(Z!==void 0){if(OX(Z))for(let Y=0,X=Z.length;Y!==X;++Y){let K=Z[Y];if(isNaN(K)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,Y,K),J=!1;break}}}return J}optimize(){let J=this.times.slice(),Q=this.values.slice(),$=this.getValueSize(),Z=this.getInterpolation()===2302,W=J.length-1,H=1;for(let Y=1;Y<W;++Y){let X=!1,K=J[Y],U=J[Y+1];if(K!==U&&(Y!==1||K!==J[0]))if(!Z){let G=Y*$,q=G-$,E=G+$;for(let O=0;O!==$;++O){let k=Q[G+O];if(k!==Q[q+O]||k!==Q[E+O]){X=!0;break}}}else X=!0;if(X){if(Y!==H){J[H]=J[Y];let G=Y*$,q=H*$;for(let E=0;E!==$;++E)Q[q+E]=Q[G+E]}++H}}if(W>0){J[H]=J[W];for(let Y=W*$,X=H*$,K=0;K!==$;++K)Q[X+K]=Q[Y+K];++H}if(H!==J.length)this.times=J.slice(0,H),this.values=Q.slice(0,H*$);else this.times=J,this.values=Q;return this}clone(){let J=this.times.slice(),Q=this.values.slice(),Z=new this.constructor(this.name,J,Q);return Z.createInterpolant=this.createInterpolant,Z}}u0.prototype.ValueTypeName="";u0.prototype.TimeBufferType=Float32Array;u0.prototype.ValueBufferType=Float32Array;u0.prototype.DefaultInterpolation=2301;class o8 extends u0{constructor(J,Q,$){super(J,Q,$)}}o8.prototype.ValueTypeName="bool";o8.prototype.ValueBufferType=Array;o8.prototype.DefaultInterpolation=2300;o8.prototype.InterpolantFactoryMethodLinear=void 0;o8.prototype.InterpolantFactoryMethodSmooth=void 0;class d7 extends u0{constructor(J,Q,$,Z){super(J,Q,$,Z)}}d7.prototype.ValueTypeName="color";class B8 extends u0{constructor(J,Q,$,Z){super(J,Q,$,Z)}}B8.prototype.ValueTypeName="number";class b$ extends s8{constructor(J,Q,$,Z){super(J,Q,$,Z)}interpolate_(J,Q,$,Z){let W=this.resultBuffer,H=this.sampleValues,Y=this.valueSize,X=($-Q)/(Z-Q),K=J*Y;for(let U=K+Y;K!==U;K+=4)y0.slerpFlat(W,0,H,K-Y,H,K,X);return W}}class A8 extends u0{constructor(J,Q,$,Z){super(J,Q,$,Z)}InterpolantFactoryMethodLinear(J){return new b$(this.times,this.values,this.getValueSize(),J)}}A8.prototype.ValueTypeName="quaternion";A8.prototype.InterpolantFactoryMethodSmooth=void 0;class i8 extends u0{constructor(J,Q,$){super(J,Q,$)}}i8.prototype.ValueTypeName="string";i8.prototype.ValueBufferType=Array;i8.prototype.DefaultInterpolation=2300;i8.prototype.InterpolantFactoryMethodLinear=void 0;i8.prototype.InterpolantFactoryMethodSmooth=void 0;class C8 extends u0{constructor(J,Q,$,Z){super(J,Q,$,Z)}}C8.prototype.ValueTypeName="vector";class m7{constructor(J="",Q=-1,$=[],Z=2500){if(this.name=J,this.tracks=$,this.duration=Q,this.blendMode=Z,this.uuid=$8(),this.duration<0)this.resetDuration()}static parse(J){let Q=[],$=J.tracks,Z=1/(J.fps||1);for(let H=0,Y=$.length;H!==Y;++H)Q.push(kX($[H]).scale(Z));let W=new this(J.name,J.duration,Q,J.blendMode);return W.uuid=J.uuid,W}static toJSON(J){let Q=[],$=J.tracks,Z={name:J.name,duration:J.duration,tracks:Q,uuid:J.uuid,blendMode:J.blendMode};for(let W=0,H=$.length;W!==H;++W)Q.push(u0.toJSON($[W]));return Z}static CreateFromMorphTargetSequence(J,Q,$,Z){let W=Q.length,H=[];for(let Y=0;Y<W;Y++){let X=[],K=[];X.push((Y+W-1)%W,Y,(Y+1)%W),K.push(0,1,0);let U=FX(X);if(X=aZ(X,1,U),K=aZ(K,1,U),!Z&&X[0]===0)X.push(W),K.push(K[0]);H.push(new B8(".morphTargetInfluences["+Q[Y].name+"]",X,K).scale(1/$))}return new this(J,-1,H)}static findByName(J,Q){let $=J;if(!Array.isArray(J)){let Z=J;$=Z.geometry&&Z.geometry.animations||Z.animations}for(let Z=0;Z<$.length;Z++)if($[Z].name===Q)return $[Z];return null}static CreateClipsFromMorphTargetSequences(J,Q,$){let Z={},W=/^([\w-]*?)([\d]+)$/;for(let Y=0,X=J.length;Y<X;Y++){let K=J[Y],U=K.name.match(W);if(U&&U.length>1){let G=U[1],q=Z[G];if(!q)Z[G]=q=[];q.push(K)}}let H=[];for(let Y in Z)H.push(this.CreateFromMorphTargetSequence(Y,Z[Y],Q,$));return H}static parseAnimation(J,Q){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!J)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let $=function(G,q,E,O,k){if(E.length!==0){let M=[],N=[];if(QH(E,M,N,O),M.length!==0)k.push(new G(q,M,N))}},Z=[],W=J.name||"default",H=J.fps||30,Y=J.blendMode,X=J.length||-1,K=J.hierarchy||[];for(let G=0;G<K.length;G++){let q=K[G].keys;if(!q||q.length===0)continue;if(q[0].morphTargets){let E={},O;for(O=0;O<q.length;O++)if(q[O].morphTargets)for(let k=0;k<q[O].morphTargets.length;k++)E[q[O].morphTargets[k]]=-1;for(let k in E){let M=[],N=[];for(let F=0;F!==q[O].morphTargets.length;++F){let C=q[O];M.push(C.time),N.push(C.morphTarget===k?1:0)}Z.push(new B8(".morphTargetInfluence["+k+"]",M,N))}X=E.length*H}else{let E=".bones["+Q[G].name+"]";$(C8,E+".position",q,"pos",Z),$(A8,E+".quaternion",q,"rot",Z),$(C8,E+".scale",q,"scl",Z)}}if(Z.length===0)return null;return new this(W,X,Z,Y)}resetDuration(){let J=this.tracks,Q=0;for(let $=0,Z=J.length;$!==Z;++$){let W=this.tracks[$];Q=Math.max(Q,W.times[W.times.length-1])}return this.duration=Q,this}trim(){for(let J=0;J<this.tracks.length;J++)this.tracks[J].trim(0,this.duration);return this}validate(){let J=!0;for(let Q=0;Q<this.tracks.length;Q++)J=J&&this.tracks[Q].validate();return J}optimize(){for(let J=0;J<this.tracks.length;J++)this.tracks[J].optimize();return this}clone(){let J=[];for(let Q=0;Q<this.tracks.length;Q++)J.push(this.tracks[Q].clone());return new this.constructor(this.name,this.duration,J,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function RX(J){switch(J.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return B8;case"vector":case"vector2":case"vector3":case"vector4":return C8;case"color":return d7;case"quaternion":return A8;case"bool":case"boolean":return o8;case"string":return i8}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+J)}function kX(J){if(J.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let Q=RX(J.type);if(J.times===void 0){let $=[],Z=[];QH(J.keys,$,Z,"value"),J.times=$,J.values=Z}if(Q.parse!==void 0)return Q.parse(J);else return new Q(J.name,J.times,J.values,J.interpolation)}var K8={enabled:!1,files:{},add:function(J,Q){if(this.enabled===!1)return;this.files[J]=Q},get:function(J){if(this.enabled===!1)return;return this.files[J]},remove:function(J){delete this.files[J]},clear:function(){this.files={}}};class x${constructor(J,Q,$){let Z=this,W=!1,H=0,Y=0,X=void 0,K=[];this.onStart=void 0,this.onLoad=J,this.onProgress=Q,this.onError=$,this.abortController=new AbortController,this.itemStart=function(U){if(Y++,W===!1){if(Z.onStart!==void 0)Z.onStart(U,H,Y)}W=!0},this.itemEnd=function(U){if(H++,Z.onProgress!==void 0)Z.onProgress(U,H,Y);if(H===Y){if(W=!1,Z.onLoad!==void 0)Z.onLoad()}},this.itemError=function(U){if(Z.onError!==void 0)Z.onError(U)},this.resolveURL=function(U){if(X)return X(U);return U},this.setURLModifier=function(U){return X=U,this},this.addHandler=function(U,G){return K.push(U,G),this},this.removeHandler=function(U){let G=K.indexOf(U);if(G!==-1)K.splice(G,2);return this},this.getHandler=function(U){for(let G=0,q=K.length;G<q;G+=2){let E=K[G],O=K[G+1];if(E.global)E.lastIndex=0;if(E.test(U))return O}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}var $H=new x$;class S8{constructor(J){this.manager=J!==void 0?J:$H,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(J,Q){let $=this;return new Promise(function(Z,W){$.load(J,Z,Q,W)})}parse(){}setCrossOrigin(J){return this.crossOrigin=J,this}setWithCredentials(J){return this.withCredentials=J,this}setPath(J){return this.path=J,this}setResourcePath(J){return this.resourcePath=J,this}setRequestHeader(J){return this.requestHeader=J,this}abort(){return this}}S8.DEFAULT_MATERIAL_NAME="__DEFAULT";var V8={};class ZH extends Error{constructor(J,Q){super(J);this.response=Q}}class T6 extends S8{constructor(J){super(J);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(J,Q,$,Z){if(J===void 0)J="";if(this.path!==void 0)J=this.path+J;J=this.manager.resolveURL(J);let W=K8.get(`file:${J}`);if(W!==void 0)return this.manager.itemStart(J),setTimeout(()=>{if(Q)Q(W);this.manager.itemEnd(J)},0),W;if(V8[J]!==void 0){V8[J].push({onLoad:Q,onProgress:$,onError:Z});return}V8[J]=[],V8[J].push({onLoad:Q,onProgress:$,onError:Z});let H=new Request(J,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),Y=this.mimeType,X=this.responseType;fetch(H).then((K)=>{if(K.status===200||K.status===0){if(K.status===0)console.warn("THREE.FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||K.body===void 0||K.body.getReader===void 0)return K;let U=V8[J],G=K.body.getReader(),q=K.headers.get("X-File-Size")||K.headers.get("Content-Length"),E=q?parseInt(q):0,O=E!==0,k=0,M=new ReadableStream({start(N){F();function F(){G.read().then(({done:C,value:L})=>{if(C)N.close();else{k+=L.byteLength;let _=new ProgressEvent("progress",{lengthComputable:O,loaded:k,total:E});for(let v=0,w=U.length;v<w;v++){let T=U[v];if(T.onProgress)T.onProgress(_)}N.enqueue(L),F()}},(C)=>{N.error(C)})}}});return new Response(M)}else throw new ZH(`fetch for "${K.url}" responded with ${K.status}: ${K.statusText}`,K)}).then((K)=>{switch(X){case"arraybuffer":return K.arrayBuffer();case"blob":return K.blob();case"document":return K.text().then((U)=>{return new DOMParser().parseFromString(U,Y)});case"json":return K.json();default:if(Y==="")return K.text();else{let G=/charset="?([^;"\s]*)"?/i.exec(Y),q=G&&G[1]?G[1].toLowerCase():void 0,E=new TextDecoder(q);return K.arrayBuffer().then((O)=>E.decode(O))}}}).then((K)=>{K8.add(`file:${J}`,K);let U=V8[J];delete V8[J];for(let G=0,q=U.length;G<q;G++){let E=U[G];if(E.onLoad)E.onLoad(K)}}).catch((K)=>{let U=V8[J];if(U===void 0)throw this.manager.itemError(J),K;delete V8[J];for(let G=0,q=U.length;G<q;G++){let E=U[G];if(E.onError)E.onError(K)}this.manager.itemError(J)}).finally(()=>{this.manager.itemEnd(J)}),this.manager.itemStart(J)}setResponseType(J){return this.responseType=J,this}setMimeType(J){return this.mimeType=J,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var j9=new WeakMap;class g$ extends S8{constructor(J){super(J)}load(J,Q,$,Z){if(this.path!==void 0)J=this.path+J;J=this.manager.resolveURL(J);let W=this,H=K8.get(`image:${J}`);if(H!==void 0){if(H.complete===!0)W.manager.itemStart(J),setTimeout(function(){if(Q)Q(H);W.manager.itemEnd(J)},0);else{let G=j9.get(H);if(G===void 0)G=[],j9.set(H,G);G.push({onLoad:Q,onError:Z})}return H}let Y=v9("img");function X(){if(U(),Q)Q(this);let G=j9.get(this)||[];for(let q=0;q<G.length;q++){let E=G[q];if(E.onLoad)E.onLoad(this)}j9.delete(this),W.manager.itemEnd(J)}function K(G){if(U(),Z)Z(G);K8.remove(`image:${J}`);let q=j9.get(this)||[];for(let E=0;E<q.length;E++){let O=q[E];if(O.onError)O.onError(G)}j9.delete(this),W.manager.itemError(J),W.manager.itemEnd(J)}function U(){Y.removeEventListener("load",X,!1),Y.removeEventListener("error",K,!1)}if(Y.addEventListener("load",X,!1),Y.addEventListener("error",K,!1),J.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)Y.crossOrigin=this.crossOrigin}return K8.add(`image:${J}`,Y),W.manager.itemStart(J),Y.src=J,Y}}class u7 extends S8{constructor(J){super(J)}load(J,Q,$,Z){let W=new E0,H=new g$(this.manager);return H.setCrossOrigin(this.crossOrigin),H.setPath(this.path),H.load(J,function(Y){if(W.image=Y,W.needsUpdate=!0,Q!==void 0)Q(W)},$,Z),W}}class n9 extends Z0{constructor(J,Q=1){super();this.isLight=!0,this.type="Light",this.color=new jJ(J),this.intensity=Q}dispose(){}copy(J,Q){return super.copy(J,Q),this.color.copy(J.color),this.intensity=J.intensity,this}toJSON(J){let Q=super.toJSON(J);if(Q.object.color=this.color.getHex(),Q.object.intensity=this.intensity,this.groundColor!==void 0)Q.object.groundColor=this.groundColor.getHex();if(this.distance!==void 0)Q.object.distance=this.distance;if(this.angle!==void 0)Q.object.angle=this.angle;if(this.decay!==void 0)Q.object.decay=this.decay;if(this.penumbra!==void 0)Q.object.penumbra=this.penumbra;if(this.shadow!==void 0)Q.object.shadow=this.shadow.toJSON();if(this.target!==void 0)Q.object.target=this.target.uuid;return Q}}class c7 extends n9{constructor(J,Q,$){super(J,$);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Z0.DEFAULT_UP),this.updateMatrix(),this.groundColor=new jJ(Q)}copy(J,Q){return super.copy(J,Q),this.groundColor.copy(J.groundColor),this}}var SQ=new vJ,rZ=new A,tZ=new A;class n7{constructor(J){this.camera=J,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new PJ(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new vJ,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _6,this._frameExtents=new PJ(1,1),this._viewportCount=1,this._viewports=[new sJ(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(J){let Q=this.camera,$=this.matrix;if(rZ.setFromMatrixPosition(J.matrixWorld),Q.position.copy(rZ),tZ.setFromMatrixPosition(J.target.matrixWorld),Q.lookAt(tZ),Q.updateMatrixWorld(),SQ.multiplyMatrices(Q.projectionMatrix,Q.matrixWorldInverse),this._frustum.setFromProjectionMatrix(SQ,Q.coordinateSystem,Q.reversedDepth),Q.reversedDepth)$.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,1,0,0,0,0,1);else $.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);$.multiply(SQ)}getViewport(J){return this._viewports[J]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(J){return this.camera=J.camera.clone(),this.intensity=J.intensity,this.bias=J.bias,this.radius=J.radius,this.autoUpdate=J.autoUpdate,this.needsUpdate=J.needsUpdate,this.normalBias=J.normalBias,this.blurSamples=J.blurSamples,this.mapSize.copy(J.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let J={};if(this.intensity!==1)J.intensity=this.intensity;if(this.bias!==0)J.bias=this.bias;if(this.normalBias!==0)J.normalBias=this.normalBias;if(this.radius!==1)J.radius=this.radius;if(this.mapSize.x!==512||this.mapSize.y!==512)J.mapSize=this.mapSize.toArray();return J.camera=this.camera.toJSON(!1).object,delete J.camera.matrix,J}}class WH extends n7{constructor(){super(new O0(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(J){let Q=this.camera,$=W9*2*J.angle*this.focus,Z=this.mapSize.width/this.mapSize.height*this.aspect,W=J.distance||Q.far;if($!==Q.fov||Z!==Q.aspect||W!==Q.far)Q.fov=$,Q.aspect=Z,Q.far=W,Q.updateProjectionMatrix();super.updateMatrices(J)}copy(J){return super.copy(J),this.focus=J.focus,this}}class s7 extends n9{constructor(J,Q,$=0,Z=Math.PI/3,W=0,H=2){super(J,Q);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Z0.DEFAULT_UP),this.updateMatrix(),this.target=new Z0,this.distance=$,this.angle=Z,this.penumbra=W,this.decay=H,this.map=null,this.shadow=new WH}get power(){return this.intensity*Math.PI}set power(J){this.intensity=J/Math.PI}dispose(){this.shadow.dispose()}copy(J,Q){return super.copy(J,Q),this.distance=J.distance,this.angle=J.angle,this.penumbra=J.penumbra,this.decay=J.decay,this.target=J.target.clone(),this.shadow=J.shadow.clone(),this}}var eZ=new vJ,U6=new A,jQ=new A;class HH extends n7{constructor(){super(new O0(90,1,0.5,500));this.isPointLightShadow=!0,this._frameExtents=new PJ(4,2),this._viewportCount=6,this._viewports=[new sJ(2,1,1,1),new sJ(0,1,1,1),new sJ(3,1,1,1),new sJ(1,1,1,1),new sJ(3,0,1,1),new sJ(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(J,Q=0){let $=this.camera,Z=this.matrix,W=J.distance||$.far;if(W!==$.far)$.far=W,$.updateProjectionMatrix();U6.setFromMatrixPosition(J.matrixWorld),$.position.copy(U6),jQ.copy($.position),jQ.add(this._cubeDirections[Q]),$.up.copy(this._cubeUps[Q]),$.lookAt(jQ),$.updateMatrixWorld(),Z.makeTranslation(-U6.x,-U6.y,-U6.z),eZ.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),this._frustum.setFromProjectionMatrix(eZ,$.coordinateSystem,$.reversedDepth)}}class o7 extends n9{constructor(J,Q,$=0,Z=2){super(J,Q);this.isPointLight=!0,this.type="PointLight",this.distance=$,this.decay=Z,this.shadow=new HH}get power(){return this.intensity*4*Math.PI}set power(J){this.intensity=J/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(J,Q){return super.copy(J,Q),this.distance=J.distance,this.decay=J.decay,this.shadow=J.shadow.clone(),this}}class s9 extends j7{constructor(J=-1,Q=1,$=1,Z=-1,W=0.1,H=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=J,this.right=Q,this.top=$,this.bottom=Z,this.near=W,this.far=H,this.updateProjectionMatrix()}copy(J,Q){return super.copy(J,Q),this.left=J.left,this.right=J.right,this.top=J.top,this.bottom=J.bottom,this.near=J.near,this.far=J.far,this.zoom=J.zoom,this.view=J.view===null?null:Object.assign({},J.view),this}setViewOffset(J,Q,$,Z,W,H){if(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=J,this.view.fullHeight=Q,this.view.offsetX=$,this.view.offsetY=Z,this.view.width=W,this.view.height=H,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let J=(this.right-this.left)/(2*this.zoom),Q=(this.top-this.bottom)/(2*this.zoom),$=(this.right+this.left)/2,Z=(this.top+this.bottom)/2,W=$-J,H=$+J,Y=Z+Q,X=Z-Q;if(this.view!==null&&this.view.enabled){let K=(this.right-this.left)/this.view.fullWidth/this.zoom,U=(this.top-this.bottom)/this.view.fullHeight/this.zoom;W+=K*this.view.offsetX,H=W+K*this.view.width,Y-=U*this.view.offsetY,X=Y-U*this.view.height}this.projectionMatrix.makeOrthographic(W,H,Y,X,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(J){let Q=super.toJSON(J);if(Q.object.zoom=this.zoom,Q.object.left=this.left,Q.object.right=this.right,Q.object.top=this.top,Q.object.bottom=this.bottom,Q.object.near=this.near,Q.object.far=this.far,this.view!==null)Q.object.view=Object.assign({},this.view);return Q}}class YH extends n7{constructor(){super(new s9(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class o9 extends n9{constructor(J,Q){super(J,Q);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Z0.DEFAULT_UP),this.updateMatrix(),this.target=new Z0,this.shadow=new YH}dispose(){this.shadow.dispose()}copy(J){return super.copy(J),this.target=J.target.clone(),this.shadow=J.shadow.clone(),this}}class a8{static extractUrlBase(J){let Q=J.lastIndexOf("/");if(Q===-1)return"./";return J.slice(0,Q+1)}static resolveURL(J,Q){if(typeof J!=="string"||J==="")return"";if(/^https?:\/\//i.test(Q)&&/^\//.test(J))Q=Q.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(J))return J;if(/^data:.*,.*$/i.test(J))return J;if(/^blob:.*$/i.test(J))return J;return Q+J}}var yQ=new WeakMap;class i7 extends S8{constructor(J){super(J);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")console.warn("THREE.ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(J){return this.options=J,this}load(J,Q,$,Z){if(J===void 0)J="";if(this.path!==void 0)J=this.path+J;J=this.manager.resolveURL(J);let W=this,H=K8.get(`image-bitmap:${J}`);if(H!==void 0){if(W.manager.itemStart(J),H.then){H.then((K)=>{if(yQ.has(H)===!0){if(Z)Z(yQ.get(H));W.manager.itemError(J),W.manager.itemEnd(J)}else{if(Q)Q(K);return W.manager.itemEnd(J),K}});return}return setTimeout(function(){if(Q)Q(H);W.manager.itemEnd(J)},0),H}let Y={};Y.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",Y.headers=this.requestHeader,Y.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let X=fetch(J,Y).then(function(K){return K.blob()}).then(function(K){return createImageBitmap(K,Object.assign(W.options,{colorSpaceConversion:"none"}))}).then(function(K){if(K8.add(`image-bitmap:${J}`,K),Q)Q(K);return W.manager.itemEnd(J),K}).catch(function(K){if(Z)Z(K);yQ.set(X,K),K8.remove(`image-bitmap:${J}`),W.manager.itemError(J),W.manager.itemEnd(J)});K8.add(`image-bitmap:${J}`,X),W.manager.itemStart(J)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class p$ extends O0{constructor(J=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=J}}var l$="\\[\\]\\.:\\/",MX=new RegExp("["+l$+"]","g"),d$="[^"+l$+"]",DX="[^"+l$.replace("\\.","")+"]",LX=/((?:WC+[\/:])*)/.source.replace("WC",d$),VX=/(WCOD+)?/.source.replace("WCOD",DX),zX=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",d$),BX=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",d$),CX=new RegExp("^"+LX+VX+zX+BX+"$"),_X=["material","materials","bones","map"];class XH{constructor(J,Q,$){let Z=$||oJ.parseTrackName(Q);this._targetGroup=J,this._bindings=J.subscribe_(Q,Z)}getValue(J,Q){this.bind();let $=this._targetGroup.nCachedObjects_,Z=this._bindings[$];if(Z!==void 0)Z.getValue(J,Q)}setValue(J,Q){let $=this._bindings;for(let Z=this._targetGroup.nCachedObjects_,W=$.length;Z!==W;++Z)$[Z].setValue(J,Q)}bind(){let J=this._bindings;for(let Q=this._targetGroup.nCachedObjects_,$=J.length;Q!==$;++Q)J[Q].bind()}unbind(){let J=this._bindings;for(let Q=this._targetGroup.nCachedObjects_,$=J.length;Q!==$;++Q)J[Q].unbind()}}class oJ{constructor(J,Q,$){this.path=Q,this.parsedPath=$||oJ.parseTrackName(Q),this.node=oJ.findNode(J,this.parsedPath.nodeName),this.rootNode=J,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(J,Q,$){if(!(J&&J.isAnimationObjectGroup))return new oJ(J,Q,$);else return new oJ.Composite(J,Q,$)}static sanitizeNodeName(J){return J.replace(/\s/g,"_").replace(MX,"")}static parseTrackName(J){let Q=CX.exec(J);if(Q===null)throw Error("PropertyBinding: Cannot parse trackName: "+J);let $={nodeName:Q[2],objectName:Q[3],objectIndex:Q[4],propertyName:Q[5],propertyIndex:Q[6]},Z=$.nodeName&&$.nodeName.lastIndexOf(".");if(Z!==void 0&&Z!==-1){let W=$.nodeName.substring(Z+1);if(_X.indexOf(W)!==-1)$.nodeName=$.nodeName.substring(0,Z),$.objectName=W}if($.propertyName===null||$.propertyName.length===0)throw Error("PropertyBinding: can not parse propertyName from trackName: "+J);return $}static findNode(J,Q){if(Q===void 0||Q===""||Q==="."||Q===-1||Q===J.name||Q===J.uuid)return J;if(J.skeleton){let $=J.skeleton.getBoneByName(Q);if($!==void 0)return $}if(J.children){let $=function(W){for(let H=0;H<W.length;H++){let Y=W[H];if(Y.name===Q||Y.uuid===Q)return Y;let X=$(Y.children);if(X)return X}return null},Z=$(J.children);if(Z)return Z}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(J,Q){J[Q]=this.targetObject[this.propertyName]}_getValue_array(J,Q){let $=this.resolvedProperty;for(let Z=0,W=$.length;Z!==W;++Z)J[Q++]=$[Z]}_getValue_arrayElement(J,Q){J[Q]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(J,Q){this.resolvedProperty.toArray(J,Q)}_setValue_direct(J,Q){this.targetObject[this.propertyName]=J[Q]}_setValue_direct_setNeedsUpdate(J,Q){this.targetObject[this.propertyName]=J[Q],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(J,Q){this.targetObject[this.propertyName]=J[Q],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(J,Q){let $=this.resolvedProperty;for(let Z=0,W=$.length;Z!==W;++Z)$[Z]=J[Q++]}_setValue_array_setNeedsUpdate(J,Q){let $=this.resolvedProperty;for(let Z=0,W=$.length;Z!==W;++Z)$[Z]=J[Q++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(J,Q){let $=this.resolvedProperty;for(let Z=0,W=$.length;Z!==W;++Z)$[Z]=J[Q++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(J,Q){this.resolvedProperty[this.propertyIndex]=J[Q]}_setValue_arrayElement_setNeedsUpdate(J,Q){this.resolvedProperty[this.propertyIndex]=J[Q],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(J,Q){this.resolvedProperty[this.propertyIndex]=J[Q],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(J,Q){this.resolvedProperty.fromArray(J,Q)}_setValue_fromArray_setNeedsUpdate(J,Q){this.resolvedProperty.fromArray(J,Q),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(J,Q){this.resolvedProperty.fromArray(J,Q),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(J,Q){this.bind(),this.getValue(J,Q)}_setValue_unbound(J,Q){this.bind(),this.setValue(J,Q)}bind(){let J=this.node,Q=this.parsedPath,$=Q.objectName,Z=Q.propertyName,W=Q.propertyIndex;if(!J)J=oJ.findNode(this.rootNode,Q.nodeName),this.node=J;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!J){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if($){let K=Q.objectIndex;switch($){case"materials":if(!J.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!J.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}J=J.material.materials;break;case"bones":if(!J.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}J=J.skeleton.bones;for(let U=0;U<J.length;U++)if(J[U].name===K){K=U;break}break;case"map":if("map"in J){J=J.map;break}if(!J.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!J.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}J=J.material.map;break;default:if(J[$]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}J=J[$]}if(K!==void 0){if(J[K]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,J);return}J=J[K]}}let H=J[Z];if(H===void 0){let K=Q.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+K+"."+Z+" but it wasn't found.",J);return}let Y=this.Versioning.None;if(this.targetObject=J,J.isMaterial===!0)Y=this.Versioning.NeedsUpdate;else if(J.isObject3D===!0)Y=this.Versioning.MatrixWorldNeedsUpdate;let X=this.BindingType.Direct;if(W!==void 0){if(Z==="morphTargetInfluences"){if(!J.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!J.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(J.morphTargetDictionary[W]!==void 0)W=J.morphTargetDictionary[W]}X=this.BindingType.ArrayElement,this.resolvedProperty=H,this.propertyIndex=W}else if(H.fromArray!==void 0&&H.toArray!==void 0)X=this.BindingType.HasFromToArray,this.resolvedProperty=H;else if(Array.isArray(H))X=this.BindingType.EntireArray,this.resolvedProperty=H;else this.propertyName=Z;this.getValue=this.GetterByBindingType[X],this.setValue=this.SetterByBindingTypeAndVersioning[X][Y]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}oJ.Composite=XH;oJ.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};oJ.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};oJ.prototype.GetterByBindingType=[oJ.prototype._getValue_direct,oJ.prototype._getValue_array,oJ.prototype._getValue_arrayElement,oJ.prototype._getValue_toArray];oJ.prototype.SetterByBindingTypeAndVersioning=[[oJ.prototype._setValue_direct,oJ.prototype._setValue_direct_setNeedsUpdate,oJ.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[oJ.prototype._setValue_array,oJ.prototype._setValue_array_setNeedsUpdate,oJ.prototype._setValue_array_setMatrixWorldNeedsUpdate],[oJ.prototype._setValue_arrayElement,oJ.prototype._setValue_arrayElement_setNeedsUpdate,oJ.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[oJ.prototype._setValue_fromArray,oJ.prototype._setValue_fromArray_setNeedsUpdate,oJ.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var w1=new Float32Array(1);class A6{constructor(J=1,Q=0,$=0){this.radius=J,this.phi=Q,this.theta=$}set(J,Q,$){return this.radius=J,this.phi=Q,this.theta=$,this}copy(J){return this.radius=J.radius,this.phi=J.phi,this.theta=J.theta,this}makeSafe(){return this.phi=xJ(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(J){return this.setFromCartesianCoords(J.x,J.y,J.z)}setFromCartesianCoords(J,Q,$){if(this.radius=Math.sqrt(J*J+Q*Q+$*$),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(J,$),this.phi=Math.acos(xJ(Q/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class a7 extends P8{constructor(J,Q=null){super();this.object=J,this.domElement=Q,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(J){if(J===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}if(this.domElement!==null)this.disconnect();this.domElement=J}disconnect(){}dispose(){}update(){}}function m$(J,Q,$,Z){let W=wX(Z);switch($){case 1021:return J*Q;case 1028:return J*Q/W.components*W.byteLength;case 1029:return J*Q/W.components*W.byteLength;case 1030:return J*Q*2/W.components*W.byteLength;case 1031:return J*Q*2/W.components*W.byteLength;case 1022:return J*Q*3/W.components*W.byteLength;case 1023:return J*Q*4/W.components*W.byteLength;case 1033:return J*Q*4/W.components*W.byteLength;case 33776:case 33777:return Math.floor((J+3)/4)*Math.floor((Q+3)/4)*8;case 33778:case 33779:return Math.floor((J+3)/4)*Math.floor((Q+3)/4)*16;case 35841:case 35843:return Math.max(J,16)*Math.max(Q,8)/4;case 35840:case 35842:return Math.max(J,8)*Math.max(Q,8)/2;case 36196:case 37492:return Math.floor((J+3)/4)*Math.floor((Q+3)/4)*8;case 37496:return Math.floor((J+3)/4)*Math.floor((Q+3)/4)*16;case 37808:return Math.floor((J+3)/4)*Math.floor((Q+3)/4)*16;case 37809:return Math.floor((J+4)/5)*Math.floor((Q+3)/4)*16;case 37810:return Math.floor((J+4)/5)*Math.floor((Q+4)/5)*16;case 37811:return Math.floor((J+5)/6)*Math.floor((Q+4)/5)*16;case 37812:return Math.floor((J+5)/6)*Math.floor((Q+5)/6)*16;case 37813:return Math.floor((J+7)/8)*Math.floor((Q+4)/5)*16;case 37814:return Math.floor((J+7)/8)*Math.floor((Q+5)/6)*16;case 37815:return Math.floor((J+7)/8)*Math.floor((Q+7)/8)*16;case 37816:return Math.floor((J+9)/10)*Math.floor((Q+4)/5)*16;case 37817:return Math.floor((J+9)/10)*Math.floor((Q+5)/6)*16;case 37818:return Math.floor((J+9)/10)*Math.floor((Q+7)/8)*16;case 37819:return Math.floor((J+9)/10)*Math.floor((Q+9)/10)*16;case 37820:return Math.floor((J+11)/12)*Math.floor((Q+9)/10)*16;case 37821:return Math.floor((J+11)/12)*Math.floor((Q+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(J/4)*Math.ceil(Q/4)*16;case 36283:case 36284:return Math.ceil(J/4)*Math.ceil(Q/4)*8;case 36285:case 36286:return Math.ceil(J/4)*Math.ceil(Q/4)*16}throw Error(`Unable to determine texture byte length for ${$} format.`)}function wX(J){switch(J){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${J}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"179"}}));if(typeof window<"u")if(window.__THREE__)console.warn("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="179";function SH(){let J=null,Q=!1,$=null,Z=null;function W(H,Y){$(H,Y),Z=J.requestAnimationFrame(W)}return{start:function(){if(Q===!0)return;if($===null)return;Z=J.requestAnimationFrame(W),Q=!0},stop:function(){J.cancelAnimationFrame(Z),Q=!1},setAnimationLoop:function(H){$=H},setContext:function(H){J=H}}}function IX(J){let Q=new WeakMap;function $(X,K){let{array:U,usage:G}=X,q=U.byteLength,E=J.createBuffer();J.bindBuffer(K,E),J.bufferData(K,U,G),X.onUploadCallback();let O;if(U instanceof Float32Array)O=J.FLOAT;else if(typeof Float16Array<"u"&&U instanceof Float16Array)O=J.HALF_FLOAT;else if(U instanceof Uint16Array)if(X.isFloat16BufferAttribute)O=J.HALF_FLOAT;else O=J.UNSIGNED_SHORT;else if(U instanceof Int16Array)O=J.SHORT;else if(U instanceof Uint32Array)O=J.UNSIGNED_INT;else if(U instanceof Int32Array)O=J.INT;else if(U instanceof Int8Array)O=J.BYTE;else if(U instanceof Uint8Array)O=J.UNSIGNED_BYTE;else if(U instanceof Uint8ClampedArray)O=J.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+U);return{buffer:E,type:O,bytesPerElement:U.BYTES_PER_ELEMENT,version:X.version,size:q}}function Z(X,K,U){let{array:G,updateRanges:q}=K;if(J.bindBuffer(U,X),q.length===0)J.bufferSubData(U,0,G);else{q.sort((O,k)=>O.start-k.start);let E=0;for(let O=1;O<q.length;O++){let k=q[E],M=q[O];if(M.start<=k.start+k.count+1)k.count=Math.max(k.count,M.start+M.count-k.start);else++E,q[E]=M}q.length=E+1;for(let O=0,k=q.length;O<k;O++){let M=q[O];J.bufferSubData(U,M.start*G.BYTES_PER_ELEMENT,G,M.start,M.count)}K.clearUpdateRanges()}K.onUploadCallback()}function W(X){if(X.isInterleavedBufferAttribute)X=X.data;return Q.get(X)}function H(X){if(X.isInterleavedBufferAttribute)X=X.data;let K=Q.get(X);if(K)J.deleteBuffer(K.buffer),Q.delete(X)}function Y(X,K){if(X.isInterleavedBufferAttribute)X=X.data;if(X.isGLBufferAttribute){let G=Q.get(X);if(!G||G.version<X.version)Q.set(X,{buffer:X.buffer,type:X.type,bytesPerElement:X.elementSize,version:X.version});return}let U=Q.get(X);if(U===void 0)Q.set(X,$(X,K));else if(U.version<X.version){if(U.size!==X.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");Z(U.buffer,X,K),U.version=X.version}}return{get:W,remove:H,update:Y}}var PX=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,TX=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,AX=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,SX=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,jX=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,yX=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,vX=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,fX=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,hX=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,bX=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,xX=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,gX=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,pX=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,lX=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,dX=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,mX=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,uX=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,cX=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,nX=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,sX=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,oX=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,iX=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,aX=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,rX=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,tX=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,eX=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,JK=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,QK=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,$K=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,ZK=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,WK="gl_FragColor = linearToOutputTexel( gl_FragColor );",HK=`vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,YK=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,XK=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,KK=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,UK=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,GK=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,qK=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,EK=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,NK=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,OK=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,FK=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,RK=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,kK=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,MK=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,DK=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,LK=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,VK=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,zK=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,BK=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,CK=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,_K=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,wK=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,IK=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,PK=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,TK=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,AK=`#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,SK=`#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,jK=`#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,yK=`#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,vK=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,fK=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,hK=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,bK=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,xK=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,gK=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,pK=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,lK=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,dK=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,mK=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,uK=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,cK=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,nK=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,sK=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,oK=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,iK=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,aK=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,rK=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,tK=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,eK=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,JU=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,QU=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$U=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,ZU=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,WU=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,HU=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,YU=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,XU=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,KU=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,UU=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
		#ifdef USE_REVERSEDEPTHBUF
			return step( depth, compare );
		#else
			return step( compare, depth );
		#endif
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		#ifdef USE_REVERSEDEPTHBUF
			float hard_shadow = step( distribution.x, compare );
		#else
			float hard_shadow = step( compare , distribution.x );
		#endif
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,GU=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,qU=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,EU=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,NU=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,OU=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,FU=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,RU=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,kU=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,MU=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,DU=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,LU=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,VU=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,zU=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		#else
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,BU=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,CU=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,_U=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,wU=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,IU=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,PU=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,TU=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,AU=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,SU=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,jU=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,yU=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,vU=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	#ifdef USE_REVERSEDEPTHBUF
		float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
	#else
		float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
	#endif
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,fU=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,hU=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,bU=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,xU=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,gU=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,pU=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,lU=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,dU=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,mU=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,uU=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,cU=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,nU=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,sU=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,oU=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,iU=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,aU=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,rU=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,tU=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,eU=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,JG=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,QG=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,$G=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,ZG=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,WG=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,HG=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,YG=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,hJ={alphahash_fragment:PX,alphahash_pars_fragment:TX,alphamap_fragment:AX,alphamap_pars_fragment:SX,alphatest_fragment:jX,alphatest_pars_fragment:yX,aomap_fragment:vX,aomap_pars_fragment:fX,batching_pars_vertex:hX,batching_vertex:bX,begin_vertex:xX,beginnormal_vertex:gX,bsdfs:pX,iridescence_fragment:lX,bumpmap_pars_fragment:dX,clipping_planes_fragment:mX,clipping_planes_pars_fragment:uX,clipping_planes_pars_vertex:cX,clipping_planes_vertex:nX,color_fragment:sX,color_pars_fragment:oX,color_pars_vertex:iX,color_vertex:aX,common:rX,cube_uv_reflection_fragment:tX,defaultnormal_vertex:eX,displacementmap_pars_vertex:JK,displacementmap_vertex:QK,emissivemap_fragment:$K,emissivemap_pars_fragment:ZK,colorspace_fragment:WK,colorspace_pars_fragment:HK,envmap_fragment:YK,envmap_common_pars_fragment:XK,envmap_pars_fragment:KK,envmap_pars_vertex:UK,envmap_physical_pars_fragment:LK,envmap_vertex:GK,fog_vertex:qK,fog_pars_vertex:EK,fog_fragment:NK,fog_pars_fragment:OK,gradientmap_pars_fragment:FK,lightmap_pars_fragment:RK,lights_lambert_fragment:kK,lights_lambert_pars_fragment:MK,lights_pars_begin:DK,lights_toon_fragment:VK,lights_toon_pars_fragment:zK,lights_phong_fragment:BK,lights_phong_pars_fragment:CK,lights_physical_fragment:_K,lights_physical_pars_fragment:wK,lights_fragment_begin:IK,lights_fragment_maps:PK,lights_fragment_end:TK,logdepthbuf_fragment:AK,logdepthbuf_pars_fragment:SK,logdepthbuf_pars_vertex:jK,logdepthbuf_vertex:yK,map_fragment:vK,map_pars_fragment:fK,map_particle_fragment:hK,map_particle_pars_fragment:bK,metalnessmap_fragment:xK,metalnessmap_pars_fragment:gK,morphinstance_vertex:pK,morphcolor_vertex:lK,morphnormal_vertex:dK,morphtarget_pars_vertex:mK,morphtarget_vertex:uK,normal_fragment_begin:cK,normal_fragment_maps:nK,normal_pars_fragment:sK,normal_pars_vertex:oK,normal_vertex:iK,normalmap_pars_fragment:aK,clearcoat_normal_fragment_begin:rK,clearcoat_normal_fragment_maps:tK,clearcoat_pars_fragment:eK,iridescence_pars_fragment:JU,opaque_fragment:QU,packing:$U,premultiplied_alpha_fragment:ZU,project_vertex:WU,dithering_fragment:HU,dithering_pars_fragment:YU,roughnessmap_fragment:XU,roughnessmap_pars_fragment:KU,shadowmap_pars_fragment:UU,shadowmap_pars_vertex:GU,shadowmap_vertex:qU,shadowmask_pars_fragment:EU,skinbase_vertex:NU,skinning_pars_vertex:OU,skinning_vertex:FU,skinnormal_vertex:RU,specularmap_fragment:kU,specularmap_pars_fragment:MU,tonemapping_fragment:DU,tonemapping_pars_fragment:LU,transmission_fragment:VU,transmission_pars_fragment:zU,uv_pars_fragment:BU,uv_pars_vertex:CU,uv_vertex:_U,worldpos_vertex:wU,background_vert:IU,background_frag:PU,backgroundCube_vert:TU,backgroundCube_frag:AU,cube_vert:SU,cube_frag:jU,depth_vert:yU,depth_frag:vU,distanceRGBA_vert:fU,distanceRGBA_frag:hU,equirect_vert:bU,equirect_frag:xU,linedashed_vert:gU,linedashed_frag:pU,meshbasic_vert:lU,meshbasic_frag:dU,meshlambert_vert:mU,meshlambert_frag:uU,meshmatcap_vert:cU,meshmatcap_frag:nU,meshnormal_vert:sU,meshnormal_frag:oU,meshphong_vert:iU,meshphong_frag:aU,meshphysical_vert:rU,meshphysical_frag:tU,meshtoon_vert:eU,meshtoon_frag:JG,points_vert:QG,points_frag:$G,shadow_vert:ZG,shadow_frag:WG,sprite_vert:HG,sprite_frag:YG},$J={common:{diffuse:{value:new jJ(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fJ},alphaMap:{value:null},alphaMapTransform:{value:new fJ},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fJ}},envmap:{envMap:{value:null},envMapRotation:{value:new fJ},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fJ}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fJ}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fJ},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fJ},normalScale:{value:new PJ(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fJ},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fJ}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fJ}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fJ}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new jJ(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 jJ(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fJ},alphaTest:{value:0},uvTransform:{value:new fJ}},sprite:{diffuse:{value:new jJ(16777215)},opacity:{value:1},center:{value:new PJ(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fJ},alphaMap:{value:null},alphaMapTransform:{value:new fJ},alphaTest:{value:0}}},O8={basic:{uniforms:w0([$J.common,$J.specularmap,$J.envmap,$J.aomap,$J.lightmap,$J.fog]),vertexShader:hJ.meshbasic_vert,fragmentShader:hJ.meshbasic_frag},lambert:{uniforms:w0([$J.common,$J.specularmap,$J.envmap,$J.aomap,$J.lightmap,$J.emissivemap,$J.bumpmap,$J.normalmap,$J.displacementmap,$J.fog,$J.lights,{emissive:{value:new jJ(0)}}]),vertexShader:hJ.meshlambert_vert,fragmentShader:hJ.meshlambert_frag},phong:{uniforms:w0([$J.common,$J.specularmap,$J.envmap,$J.aomap,$J.lightmap,$J.emissivemap,$J.bumpmap,$J.normalmap,$J.displacementmap,$J.fog,$J.lights,{emissive:{value:new jJ(0)},specular:{value:new jJ(1118481)},shininess:{value:30}}]),vertexShader:hJ.meshphong_vert,fragmentShader:hJ.meshphong_frag},standard:{uniforms:w0([$J.common,$J.envmap,$J.aomap,$J.lightmap,$J.emissivemap,$J.bumpmap,$J.normalmap,$J.displacementmap,$J.roughnessmap,$J.metalnessmap,$J.fog,$J.lights,{emissive:{value:new jJ(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:hJ.meshphysical_vert,fragmentShader:hJ.meshphysical_frag},toon:{uniforms:w0([$J.common,$J.aomap,$J.lightmap,$J.emissivemap,$J.bumpmap,$J.normalmap,$J.displacementmap,$J.gradientmap,$J.fog,$J.lights,{emissive:{value:new jJ(0)}}]),vertexShader:hJ.meshtoon_vert,fragmentShader:hJ.meshtoon_frag},matcap:{uniforms:w0([$J.common,$J.bumpmap,$J.normalmap,$J.displacementmap,$J.fog,{matcap:{value:null}}]),vertexShader:hJ.meshmatcap_vert,fragmentShader:hJ.meshmatcap_frag},points:{uniforms:w0([$J.points,$J.fog]),vertexShader:hJ.points_vert,fragmentShader:hJ.points_frag},dashed:{uniforms:w0([$J.common,$J.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:hJ.linedashed_vert,fragmentShader:hJ.linedashed_frag},depth:{uniforms:w0([$J.common,$J.displacementmap]),vertexShader:hJ.depth_vert,fragmentShader:hJ.depth_frag},normal:{uniforms:w0([$J.common,$J.bumpmap,$J.normalmap,$J.displacementmap,{opacity:{value:1}}]),vertexShader:hJ.meshnormal_vert,fragmentShader:hJ.meshnormal_frag},sprite:{uniforms:w0([$J.sprite,$J.fog]),vertexShader:hJ.sprite_vert,fragmentShader:hJ.sprite_frag},background:{uniforms:{uvTransform:{value:new fJ},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:hJ.background_vert,fragmentShader:hJ.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new fJ}},vertexShader:hJ.backgroundCube_vert,fragmentShader:hJ.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:hJ.cube_vert,fragmentShader:hJ.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:hJ.equirect_vert,fragmentShader:hJ.equirect_frag},distanceRGBA:{uniforms:w0([$J.common,$J.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:hJ.distanceRGBA_vert,fragmentShader:hJ.distanceRGBA_frag},shadow:{uniforms:w0([$J.lights,$J.fog,{color:{value:new jJ(0)},opacity:{value:1}}]),vertexShader:hJ.shadow_vert,fragmentShader:hJ.shadow_frag}};O8.physical={uniforms:w0([O8.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fJ},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fJ},clearcoatNormalScale:{value:new PJ(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fJ},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fJ},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fJ},sheen:{value:0},sheenColor:{value:new jJ(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fJ},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fJ},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fJ},transmissionSamplerSize:{value:new PJ},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fJ},attenuationDistance:{value:0},attenuationColor:{value:new jJ(0)},specularColor:{value:new jJ(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fJ},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fJ},anisotropyVector:{value:new PJ},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fJ}}]),vertexShader:hJ.meshphysical_vert,fragmentShader:hJ.meshphysical_frag};var r7={r:0,b:0,g:0},q9=new Z8,XG=new vJ;function KG(J,Q,$,Z,W,H,Y){let X=new jJ(0),K=H===!0?0:1,U,G,q=null,E=0,O=null;function k(L){let _=L.isScene===!0?L.background:null;if(_&&_.isTexture)_=(L.backgroundBlurriness>0?$:Q).get(_);return _}function M(L){let _=!1,v=k(L);if(v===null)F(X,K);else if(v&&v.isColor)F(v,1),_=!0;let w=J.xr.getEnvironmentBlendMode();if(w==="additive")Z.buffers.color.setClear(0,0,0,1,Y);else if(w==="alpha-blend")Z.buffers.color.setClear(0,0,0,0,Y);if(J.autoClear||_)Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),J.clear(J.autoClearColor,J.autoClearDepth,J.autoClearStencil)}function N(L,_){let v=k(_);if(v&&(v.isCubeTexture||v.mapping===O6)){if(G===void 0)G=new _0(new d9(1,1,1),new N8({name:"BackgroundCubeMaterial",uniforms:G9(O8.backgroundCube.uniforms),vertexShader:O8.backgroundCube.vertexShader,fragmentShader:O8.backgroundCube.fragmentShader,side:g0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),G.geometry.deleteAttribute("normal"),G.geometry.deleteAttribute("uv"),G.onBeforeRender=function(w,T,x){this.matrixWorld.copyPosition(x.matrixWorld)},Object.defineProperty(G.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),W.update(G);if(q9.copy(_.backgroundRotation),q9.x*=-1,q9.y*=-1,q9.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1)q9.y*=-1,q9.z*=-1;if(G.material.uniforms.envMap.value=v,G.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,G.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,G.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,G.material.uniforms.backgroundRotation.value.setFromMatrix4(XG.makeRotationFromEuler(q9)),G.material.toneMapped=lJ.getTransfer(v.colorSpace)!==W0,q!==v||E!==v.version||O!==J.toneMapping)G.material.needsUpdate=!0,q=v,E=v.version,O=J.toneMapping;G.layers.enableAll(),L.unshift(G,G.geometry,G.material,0,0,null)}else if(v&&v.isTexture){if(U===void 0)U=new _0(new P6(2,2),new N8({name:"BackgroundMaterial",uniforms:G9(O8.background.uniforms),vertexShader:O8.background.vertexShader,fragmentShader:O8.background.fragmentShader,side:d8,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),U.geometry.deleteAttribute("normal"),Object.defineProperty(U.material,"map",{get:function(){return this.uniforms.t2D.value}}),W.update(U);if(U.material.uniforms.t2D.value=v,U.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,U.material.toneMapped=lJ.getTransfer(v.colorSpace)!==W0,v.matrixAutoUpdate===!0)v.updateMatrix();if(U.material.uniforms.uvTransform.value.copy(v.matrix),q!==v||E!==v.version||O!==J.toneMapping)U.material.needsUpdate=!0,q=v,E=v.version,O=J.toneMapping;U.layers.enableAll(),L.unshift(U,U.geometry,U.material,0,0,null)}}function F(L,_){L.getRGB(r7,T$(J)),Z.buffers.color.setClear(r7.r,r7.g,r7.b,_,Y)}function C(){if(G!==void 0)G.geometry.dispose(),G.material.dispose(),G=void 0;if(U!==void 0)U.geometry.dispose(),U.material.dispose(),U=void 0}return{getClearColor:function(){return X},setClearColor:function(L,_=1){X.set(L),K=_,F(X,K)},getClearAlpha:function(){return K},setClearAlpha:function(L){K=L,F(X,K)},render:M,addToRenderList:N,dispose:C}}function UG(J,Q){let $=J.getParameter(J.MAX_VERTEX_ATTRIBS),Z={},W=E(null),H=W,Y=!1;function X(V,j,m,l,c){let i=!1,u=q(l,m,j);if(H!==u)H=u,U(H.object);if(i=O(V,l,m,c),i)k(V,l,m,c);if(c!==null)Q.update(c,J.ELEMENT_ARRAY_BUFFER);if(i||Y){if(Y=!1,_(V,j,m,l),c!==null)J.bindBuffer(J.ELEMENT_ARRAY_BUFFER,Q.get(c).buffer)}}function K(){return J.createVertexArray()}function U(V){return J.bindVertexArray(V)}function G(V){return J.deleteVertexArray(V)}function q(V,j,m){let l=m.wireframe===!0,c=Z[V.id];if(c===void 0)c={},Z[V.id]=c;let i=c[j.id];if(i===void 0)i={},c[j.id]=i;let u=i[l];if(u===void 0)u=E(K()),i[l]=u;return u}function E(V){let j=[],m=[],l=[];for(let c=0;c<$;c++)j[c]=0,m[c]=0,l[c]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:j,enabledAttributes:m,attributeDivisors:l,object:V,attributes:{},index:null}}function O(V,j,m,l){let c=H.attributes,i=j.attributes,u=0,r=m.getAttributes();for(let g in r)if(r[g].location>=0){let UJ=c[g],TJ=i[g];if(TJ===void 0){if(g==="instanceMatrix"&&V.instanceMatrix)TJ=V.instanceMatrix;if(g==="instanceColor"&&V.instanceColor)TJ=V.instanceColor}if(UJ===void 0)return!0;if(UJ.attribute!==TJ)return!0;if(TJ&&UJ.data!==TJ.data)return!0;u++}if(H.attributesNum!==u)return!0;if(H.index!==l)return!0;return!1}function k(V,j,m,l){let c={},i=j.attributes,u=0,r=m.getAttributes();for(let g in r)if(r[g].location>=0){let UJ=i[g];if(UJ===void 0){if(g==="instanceMatrix"&&V.instanceMatrix)UJ=V.instanceMatrix;if(g==="instanceColor"&&V.instanceColor)UJ=V.instanceColor}let TJ={};if(TJ.attribute=UJ,UJ&&UJ.data)TJ.data=UJ.data;c[g]=TJ,u++}H.attributes=c,H.attributesNum=u,H.index=l}function M(){let V=H.newAttributes;for(let j=0,m=V.length;j<m;j++)V[j]=0}function N(V){F(V,0)}function F(V,j){let{newAttributes:m,enabledAttributes:l,attributeDivisors:c}=H;if(m[V]=1,l[V]===0)J.enableVertexAttribArray(V),l[V]=1;if(c[V]!==j)J.vertexAttribDivisor(V,j),c[V]=j}function C(){let{newAttributes:V,enabledAttributes:j}=H;for(let m=0,l=j.length;m<l;m++)if(j[m]!==V[m])J.disableVertexAttribArray(m),j[m]=0}function L(V,j,m,l,c,i,u){if(u===!0)J.vertexAttribIPointer(V,j,m,c,i);else J.vertexAttribPointer(V,j,m,l,c,i)}function _(V,j,m,l){M();let c=l.attributes,i=m.getAttributes(),u=j.defaultAttributeValues;for(let r in i){let g=i[r];if(g.location>=0){let ZJ=c[r];if(ZJ===void 0){if(r==="instanceMatrix"&&V.instanceMatrix)ZJ=V.instanceMatrix;if(r==="instanceColor"&&V.instanceColor)ZJ=V.instanceColor}if(ZJ!==void 0){let{normalized:UJ,itemSize:TJ}=ZJ,mJ=Q.get(ZJ);if(mJ===void 0)continue;let{buffer:Y0,type:d,bytesPerElement:WJ}=mJ,MJ=d===J.INT||d===J.UNSIGNED_INT||ZJ.gpuType===pQ;if(ZJ.isInterleavedBufferAttribute){let GJ=ZJ.data,RJ=GJ.stride,uJ=ZJ.offset;if(GJ.isInstancedInterleavedBuffer){for(let cJ=0;cJ<g.locationSize;cJ++)F(g.location+cJ,GJ.meshPerAttribute);if(V.isInstancedMesh!==!0&&l._maxInstanceCount===void 0)l._maxInstanceCount=GJ.meshPerAttribute*GJ.count}else for(let cJ=0;cJ<g.locationSize;cJ++)N(g.location+cJ);J.bindBuffer(J.ARRAY_BUFFER,Y0);for(let cJ=0;cJ<g.locationSize;cJ++)L(g.location+cJ,TJ/g.locationSize,d,UJ,RJ*WJ,(uJ+TJ/g.locationSize*cJ)*WJ,MJ)}else{if(ZJ.isInstancedBufferAttribute){for(let GJ=0;GJ<g.locationSize;GJ++)F(g.location+GJ,ZJ.meshPerAttribute);if(V.isInstancedMesh!==!0&&l._maxInstanceCount===void 0)l._maxInstanceCount=ZJ.meshPerAttribute*ZJ.count}else for(let GJ=0;GJ<g.locationSize;GJ++)N(g.location+GJ);J.bindBuffer(J.ARRAY_BUFFER,Y0);for(let GJ=0;GJ<g.locationSize;GJ++)L(g.location+GJ,TJ/g.locationSize,d,UJ,TJ*WJ,TJ/g.locationSize*GJ*WJ,MJ)}}else if(u!==void 0){let UJ=u[r];if(UJ!==void 0)switch(UJ.length){case 2:J.vertexAttrib2fv(g.location,UJ);break;case 3:J.vertexAttrib3fv(g.location,UJ);break;case 4:J.vertexAttrib4fv(g.location,UJ);break;default:J.vertexAttrib1fv(g.location,UJ)}}}}C()}function v(){x();for(let V in Z){let j=Z[V];for(let m in j){let l=j[m];for(let c in l)G(l[c].object),delete l[c];delete j[m]}delete Z[V]}}function w(V){if(Z[V.id]===void 0)return;let j=Z[V.id];for(let m in j){let l=j[m];for(let c in l)G(l[c].object),delete l[c];delete j[m]}delete Z[V.id]}function T(V){for(let j in Z){let m=Z[j];if(m[V.id]===void 0)continue;let l=m[V.id];for(let c in l)G(l[c].object),delete l[c];delete m[V.id]}}function x(){if(z(),Y=!0,H===W)return;H=W,U(H.object)}function z(){W.geometry=null,W.program=null,W.wireframe=!1}return{setup:X,reset:x,resetDefaultState:z,dispose:v,releaseStatesOfGeometry:w,releaseStatesOfProgram:T,initAttributes:M,enableAttribute:N,disableUnusedAttributes:C}}function GG(J,Q,$){let Z;function W(U){Z=U}function H(U,G){J.drawArrays(Z,U,G),$.update(G,Z,1)}function Y(U,G,q){if(q===0)return;J.drawArraysInstanced(Z,U,G,q),$.update(G,Z,q)}function X(U,G,q){if(q===0)return;Q.get("WEBGL_multi_draw").multiDrawArraysWEBGL(Z,U,0,G,0,q);let O=0;for(let k=0;k<q;k++)O+=G[k];$.update(O,Z,1)}function K(U,G,q,E){if(q===0)return;let O=Q.get("WEBGL_multi_draw");if(O===null)for(let k=0;k<U.length;k++)Y(U[k],G[k],E[k]);else{O.multiDrawArraysInstancedWEBGL(Z,U,0,G,0,E,0,q);let k=0;for(let M=0;M<q;M++)k+=G[M]*E[M];$.update(k,Z,1)}}this.setMode=W,this.render=H,this.renderInstances=Y,this.renderMultiDraw=X,this.renderMultiDrawInstances=K}function qG(J,Q,$,Z){let W;function H(){if(W!==void 0)return W;if(Q.has("EXT_texture_filter_anisotropic")===!0){let T=Q.get("EXT_texture_filter_anisotropic");W=J.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else W=0;return W}function Y(T){if(T!==G8&&Z.convert(T)!==J.getParameter(J.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function X(T){let x=T===R6&&(Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float"));if(T!==u8&&Z.convert(T)!==J.getParameter(J.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==c8&&!x)return!1;return!0}function K(T){if(T==="highp"){if(J.getShaderPrecisionFormat(J.VERTEX_SHADER,J.HIGH_FLOAT).precision>0&&J.getShaderPrecisionFormat(J.FRAGMENT_SHADER,J.HIGH_FLOAT).precision>0)return"highp";T="mediump"}if(T==="mediump"){if(J.getShaderPrecisionFormat(J.VERTEX_SHADER,J.MEDIUM_FLOAT).precision>0&&J.getShaderPrecisionFormat(J.FRAGMENT_SHADER,J.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let U=$.precision!==void 0?$.precision:"highp",G=K(U);if(G!==U)console.warn("THREE.WebGLRenderer:",U,"not supported, using",G,"instead."),U=G;let q=$.logarithmicDepthBuffer===!0,E=$.reversedDepthBuffer===!0&&Q.has("EXT_clip_control"),O=J.getParameter(J.MAX_TEXTURE_IMAGE_UNITS),k=J.getParameter(J.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=J.getParameter(J.MAX_TEXTURE_SIZE),N=J.getParameter(J.MAX_CUBE_MAP_TEXTURE_SIZE),F=J.getParameter(J.MAX_VERTEX_ATTRIBS),C=J.getParameter(J.MAX_VERTEX_UNIFORM_VECTORS),L=J.getParameter(J.MAX_VARYING_VECTORS),_=J.getParameter(J.MAX_FRAGMENT_UNIFORM_VECTORS),v=k>0,w=J.getParameter(J.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:H,getMaxPrecision:K,textureFormatReadable:Y,textureTypeReadable:X,precision:U,logarithmicDepthBuffer:q,reversedDepthBuffer:E,maxTextures:O,maxVertexTextures:k,maxTextureSize:M,maxCubemapSize:N,maxAttributes:F,maxVertexUniforms:C,maxVaryings:L,maxFragmentUniforms:_,vertexTextures:v,maxSamples:w}}function EG(J){let Q=this,$=null,Z=0,W=!1,H=!1,Y=new J8,X=new fJ,K={value:null,needsUpdate:!1};this.uniform=K,this.numPlanes=0,this.numIntersection=0,this.init=function(q,E){let O=q.length!==0||E||Z!==0||W;return W=E,Z=q.length,O},this.beginShadows=function(){H=!0,G(null)},this.endShadows=function(){H=!1},this.setGlobalState=function(q,E){$=G(q,E,0)},this.setState=function(q,E,O){let{clippingPlanes:k,clipIntersection:M,clipShadows:N}=q,F=J.get(q);if(!W||k===null||k.length===0||H&&!N)if(H)G(null);else U();else{let C=H?0:Z,L=C*4,_=F.clippingState||null;K.value=_,_=G(k,E,L,O);for(let v=0;v!==L;++v)_[v]=$[v];F.clippingState=_,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=C}};function U(){if(K.value!==$)K.value=$,K.needsUpdate=Z>0;Q.numPlanes=Z,Q.numIntersection=0}function G(q,E,O,k){let M=q!==null?q.length:0,N=null;if(M!==0){if(N=K.value,k!==!0||N===null){let F=O+M*4,C=E.matrixWorldInverse;if(X.getNormalMatrix(C),N===null||N.length<F)N=new Float32Array(F);for(let L=0,_=O;L!==M;++L,_+=4)Y.copy(q[L]).applyMatrix4(C,X),Y.normal.toArray(N,_),N[_+3]=Y.constant}K.value=N,K.needsUpdate=!0}return Q.numPlanes=M,Q.numIntersection=0,N}}function NG(J){let Q=new WeakMap;function $(Y,X){if(X===R7)Y.mapping=h9;else if(X===k7)Y.mapping=X9;return Y}function Z(Y){if(Y&&Y.isTexture){let X=Y.mapping;if(X===R7||X===k7)if(Q.has(Y)){let K=Q.get(Y).texture;return $(K,Y.mapping)}else{let K=Y.image;if(K&&K.height>0){let U=new S$(K.height);return U.fromEquirectangularTexture(J,Y),Q.set(Y,U),Y.addEventListener("dispose",W),$(U.texture,Y.mapping)}else return null}}return Y}function W(Y){let X=Y.target;X.removeEventListener("dispose",W);let K=Q.get(X);if(K!==void 0)Q.delete(X),K.dispose()}function H(){Q=new WeakMap}return{get:Z,dispose:H}}var a9=4,KH=[0.125,0.215,0.35,0.446,0.526,0.582],O9=20,u$=new s9,UH=new jJ,c$=null,n$=0,s$=0,o$=!1,N9=(1+Math.sqrt(5))/2,i9=1/N9,GH=[new A(-N9,i9,0),new A(N9,i9,0),new A(-i9,0,N9),new A(i9,0,N9),new A(0,N9,-i9),new A(0,N9,i9),new A(-1,1,-1),new A(1,1,-1),new A(-1,1,1),new A(1,1,1)],OG=new A;class a${constructor(J){this._renderer=J,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(J,Q=0,$=0.1,Z=100,W={}){let{size:H=256,position:Y=OG}=W;c$=this._renderer.getRenderTarget(),n$=this._renderer.getActiveCubeFace(),s$=this._renderer.getActiveMipmapLevel(),o$=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(H);let X=this._allocateTargets();if(X.depthBuffer=!0,this._sceneToCubeUV(J,$,Z,X,Y),Q>0)this._blur(X,0,0,Q);return this._applyPMREM(X),this._cleanup(X),X}fromEquirectangular(J,Q=null){return this._fromTexture(J,Q)}fromCubemap(J,Q=null){return this._fromTexture(J,Q)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=NH(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=EH(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose()}_setSize(J){this._lodMax=Math.floor(Math.log2(J)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let J=0;J<this._lodPlanes.length;J++)this._lodPlanes[J].dispose()}_cleanup(J){this._renderer.setRenderTarget(c$,n$,s$),this._renderer.xr.enabled=o$,J.scissorTest=!1,t7(J,0,0,J.width,J.height)}_fromTexture(J,Q){if(J.mapping===h9||J.mapping===X9)this._setSize(J.image.length===0?16:J.image[0].width||J.image[0].image.width);else this._setSize(J.image.width/4);c$=this._renderer.getRenderTarget(),n$=this._renderer.getActiveCubeFace(),s$=this._renderer.getActiveMipmapLevel(),o$=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let $=Q||this._allocateTargets();return this._textureToCubeUV(J,$),this._applyPMREM($),this._cleanup($),$}_allocateTargets(){let J=3*Math.max(this._cubeSize,112),Q=4*this._cubeSize,$={magFilter:W8,minFilter:W8,generateMipmaps:!1,type:R6,format:G8,colorSpace:T0,depthBuffer:!1},Z=qH(J,Q,$);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==J||this._pingPongRenderTarget.height!==Q){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=qH(J,Q,$);let{_lodMax:W}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=FG(W)),this._blurMaterial=RG(W,J,Q)}return Z}_compileMaterial(J){let Q=new _0(this._lodPlanes[0],J);this._renderer.compile(Q,u$)}_sceneToCubeUV(J,Q,$,Z,W){let X=new O0(90,1,Q,$),K=[1,-1,1,1,1,1],U=[1,1,1,-1,-1,-1],G=this._renderer,q=G.autoClear,E=G.toneMapping;if(G.getClearColor(UH),G.toneMapping=_8,G.autoClear=!1,G.state.buffers.depth.getReversed())G.setRenderTarget(Z),G.clearDepth(),G.setRenderTarget(null);let k=new E8({name:"PMREM.Background",side:g0,depthWrite:!1,depthTest:!1}),M=new _0(new d9,k),N=!1,F=J.background;if(F){if(F.isColor)k.color.copy(F),J.background=null,N=!0}else k.color.copy(UH),N=!0;for(let C=0;C<6;C++){let L=C%3;if(L===0)X.up.set(0,K[C],0),X.position.set(W.x,W.y,W.z),X.lookAt(W.x+U[C],W.y,W.z);else if(L===1)X.up.set(0,0,K[C]),X.position.set(W.x,W.y,W.z),X.lookAt(W.x,W.y+U[C],W.z);else X.up.set(0,K[C],0),X.position.set(W.x,W.y,W.z),X.lookAt(W.x,W.y,W.z+U[C]);let _=this._cubeSize;if(t7(Z,L*_,C>2?_:0,_,_),G.setRenderTarget(Z),N)G.render(M,X);G.render(J,X)}M.geometry.dispose(),M.material.dispose(),G.toneMapping=E,G.autoClear=q,J.background=F}_textureToCubeUV(J,Q){let $=this._renderer,Z=J.mapping===h9||J.mapping===X9;if(Z){if(this._cubemapMaterial===null)this._cubemapMaterial=NH();this._cubemapMaterial.uniforms.flipEnvMap.value=J.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=EH();let W=Z?this._cubemapMaterial:this._equirectMaterial,H=new _0(this._lodPlanes[0],W),Y=W.uniforms;Y.envMap.value=J;let X=this._cubeSize;t7(Q,0,0,3*X,2*X),$.setRenderTarget(Q),$.render(H,u$)}_applyPMREM(J){let Q=this._renderer,$=Q.autoClear;Q.autoClear=!1;let Z=this._lodPlanes.length;for(let W=1;W<Z;W++){let H=Math.sqrt(this._sigmas[W]*this._sigmas[W]-this._sigmas[W-1]*this._sigmas[W-1]),Y=GH[(Z-W-1)%GH.length];this._blur(J,W-1,W,H,Y)}Q.autoClear=$}_blur(J,Q,$,Z,W){let H=this._pingPongRenderTarget;this._halfBlur(J,H,Q,$,Z,"latitudinal",W),this._halfBlur(H,J,$,$,Z,"longitudinal",W)}_halfBlur(J,Q,$,Z,W,H,Y){let X=this._renderer,K=this._blurMaterial;if(H!=="latitudinal"&&H!=="longitudinal")console.error("blur direction must be either latitudinal or longitudinal!");let U=3,G=new _0(this._lodPlanes[Z],K),q=K.uniforms,E=this._sizeLods[$]-1,O=isFinite(W)?Math.PI/(2*E):2*Math.PI/(2*O9-1),k=W/O,M=isFinite(W)?1+Math.floor(U*k):O9;if(M>O9)console.warn(`sigmaRadians, ${W}, is too large and will clip, as it requested ${M} samples when the maximum is set to ${O9}`);let N=[],F=0;for(let w=0;w<O9;++w){let T=w/k,x=Math.exp(-T*T/2);if(N.push(x),w===0)F+=x;else if(w<M)F+=2*x}for(let w=0;w<N.length;w++)N[w]=N[w]/F;if(q.envMap.value=J.texture,q.samples.value=M,q.weights.value=N,q.latitudinal.value=H==="latitudinal",Y)q.poleAxis.value=Y;let{_lodMax:C}=this;q.dTheta.value=O,q.mipInt.value=C-$;let L=this._sizeLods[Z],_=3*L*(Z>C-a9?Z-C+a9:0),v=4*(this._cubeSize-L);t7(Q,_,v,3*L,2*L),X.setRenderTarget(Q),X.render(G,u$)}}function FG(J){let Q=[],$=[],Z=[],W=J,H=J-a9+1+KH.length;for(let Y=0;Y<H;Y++){let X=Math.pow(2,W);$.push(X);let K=1/X;if(Y>J-a9)K=KH[Y-J+a9-1];else if(Y===0)K=0;Z.push(K);let U=1/(X-2),G=-U,q=1+U,E=[G,G,q,G,q,q,G,G,q,q,G,q],O=6,k=6,M=3,N=2,F=1,C=new Float32Array(M*k*O),L=new Float32Array(N*k*O),_=new Float32Array(F*k*O);for(let w=0;w<O;w++){let T=w%3*2/3-1,x=w>2?0:-1,z=[T,x,0,T+0.6666666666666666,x,0,T+0.6666666666666666,x+1,0,T,x,0,T+0.6666666666666666,x+1,0,T,x+1,0];C.set(z,M*k*w),L.set(E,N*k*w);let V=[w,w,w,w,w,w];_.set(V,F*k*w)}let v=new d0;if(v.setAttribute("position",new F0(C,M)),v.setAttribute("uv",new F0(L,N)),v.setAttribute("faceIndex",new F0(_,F)),Q.push(v),W>a9)W--}return{lodPlanes:Q,sizeLods:$,sigmas:Z}}function qH(J,Q,$){let Z=new T8(J,Q,$);return Z.texture.mapping=O6,Z.texture.name="PMREM.cubeUv",Z.scissorTest=!0,Z}function t7(J,Q,$,Z,W){J.viewport.set(Q,$,Z,W),J.scissor.set(Q,$,Z,W)}function RG(J,Q,$){let Z=new Float32Array(O9),W=new A(0,1,0);return new N8({name:"SphericalGaussianBlur",defines:{n:O9,CUBEUV_TEXEL_WIDTH:1/Q,CUBEUV_TEXEL_HEIGHT:1/$,CUBEUV_MAX_MIP:`${J}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:Z},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:W}},vertexShader:t$(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:m8,depthTest:!1,depthWrite:!1})}function EH(){return new N8({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:t$(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:m8,depthTest:!1,depthWrite:!1})}function NH(){return new N8({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:t$(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:m8,depthTest:!1,depthWrite:!1})}function t$(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function kG(J){let Q=new WeakMap,$=null;function Z(X){if(X&&X.isTexture){let K=X.mapping,U=K===R7||K===k7,G=K===h9||K===X9;if(U||G){let q=Q.get(X),E=q!==void 0?q.texture.pmremVersion:0;if(X.isRenderTargetTexture&&X.pmremVersion!==E){if($===null)$=new a$(J);return q=U?$.fromEquirectangular(X,q):$.fromCubemap(X,q),q.texture.pmremVersion=X.pmremVersion,Q.set(X,q),q.texture}else if(q!==void 0)return q.texture;else{let O=X.image;if(U&&O&&O.height>0||G&&O&&W(O)){if($===null)$=new a$(J);return q=U?$.fromEquirectangular(X):$.fromCubemap(X),q.texture.pmremVersion=X.pmremVersion,Q.set(X,q),X.addEventListener("dispose",H),q.texture}else return null}}}return X}function W(X){let K=0,U=6;for(let G=0;G<U;G++)if(X[G]!==void 0)K++;return K===U}function H(X){let K=X.target;K.removeEventListener("dispose",H);let U=Q.get(K);if(U!==void 0)Q.delete(K),U.dispose()}function Y(){if(Q=new WeakMap,$!==null)$.dispose(),$=null}return{get:Z,dispose:Y}}function MG(J){let Q={};function $(Z){if(Q[Z]!==void 0)return Q[Z];let W;switch(Z){case"WEBGL_depth_texture":W=J.getExtension("WEBGL_depth_texture")||J.getExtension("MOZ_WEBGL_depth_texture")||J.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":W=J.getExtension("EXT_texture_filter_anisotropic")||J.getExtension("MOZ_EXT_texture_filter_anisotropic")||J.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":W=J.getExtension("WEBGL_compressed_texture_s3tc")||J.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||J.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":W=J.getExtension("WEBGL_compressed_texture_pvrtc")||J.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:W=J.getExtension(Z)}return Q[Z]=W,W}return{has:function(Z){return $(Z)!==null},init:function(){$("EXT_color_buffer_float"),$("WEBGL_clip_cull_distance"),$("OES_texture_float_linear"),$("EXT_color_buffer_half_float"),$("WEBGL_multisampled_render_to_texture"),$("WEBGL_render_shared_exponent")},get:function(Z){let W=$(Z);if(W===null)H9("THREE.WebGLRenderer: "+Z+" extension not supported.");return W}}}function DG(J,Q,$,Z){let W={},H=new WeakMap;function Y(q){let E=q.target;if(E.index!==null)Q.remove(E.index);for(let k in E.attributes)Q.remove(E.attributes[k]);E.removeEventListener("dispose",Y),delete W[E.id];let O=H.get(E);if(O)Q.remove(O),H.delete(E);if(Z.releaseStatesOfGeometry(E),E.isInstancedBufferGeometry===!0)delete E._maxInstanceCount;$.memory.geometries--}function X(q,E){if(W[E.id]===!0)return E;return E.addEventListener("dispose",Y),W[E.id]=!0,$.memory.geometries++,E}function K(q){let E=q.attributes;for(let O in E)Q.update(E[O],J.ARRAY_BUFFER)}function U(q){let E=[],O=q.index,k=q.attributes.position,M=0;if(O!==null){let C=O.array;M=O.version;for(let L=0,_=C.length;L<_;L+=3){let v=C[L+0],w=C[L+1],T=C[L+2];E.push(v,w,w,T,T,v)}}else if(k!==void 0){let C=k.array;M=k.version;for(let L=0,_=C.length/3-1;L<_;L+=3){let v=L+0,w=L+1,T=L+2;E.push(v,w,w,T,T,v)}}else return;let N=new((_$(E))?S7:A7)(E,1);N.version=M;let F=H.get(q);if(F)Q.remove(F);H.set(q,N)}function G(q){let E=H.get(q);if(E){let O=q.index;if(O!==null){if(E.version<O.version)U(q)}}else U(q);return H.get(q)}return{get:X,update:K,getWireframeAttribute:G}}function LG(J,Q,$){let Z;function W(E){Z=E}let H,Y;function X(E){H=E.type,Y=E.bytesPerElement}function K(E,O){J.drawElements(Z,O,H,E*Y),$.update(O,Z,1)}function U(E,O,k){if(k===0)return;J.drawElementsInstanced(Z,O,H,E*Y,k),$.update(O,Z,k)}function G(E,O,k){if(k===0)return;Q.get("WEBGL_multi_draw").multiDrawElementsWEBGL(Z,O,0,H,E,0,k);let N=0;for(let F=0;F<k;F++)N+=O[F];$.update(N,Z,1)}function q(E,O,k,M){if(k===0)return;let N=Q.get("WEBGL_multi_draw");if(N===null)for(let F=0;F<E.length;F++)U(E[F]/Y,O[F],M[F]);else{N.multiDrawElementsInstancedWEBGL(Z,O,0,H,E,0,M,0,k);let F=0;for(let C=0;C<k;C++)F+=O[C]*M[C];$.update(F,Z,1)}}this.setMode=W,this.setIndex=X,this.render=K,this.renderInstances=U,this.renderMultiDraw=G,this.renderMultiDrawInstances=q}function VG(J){let Q={geometries:0,textures:0},$={frame:0,calls:0,triangles:0,points:0,lines:0};function Z(H,Y,X){switch($.calls++,Y){case J.TRIANGLES:$.triangles+=X*(H/3);break;case J.LINES:$.lines+=X*(H/2);break;case J.LINE_STRIP:$.lines+=X*(H-1);break;case J.LINE_LOOP:$.lines+=X*H;break;case J.POINTS:$.points+=X*H;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",Y);break}}function W(){$.calls=0,$.triangles=0,$.points=0,$.lines=0}return{memory:Q,render:$,programs:null,autoReset:!0,reset:W,update:Z}}function zG(J,Q,$){let Z=new WeakMap,W=new sJ;function H(Y,X,K){let U=Y.morphTargetInfluences,G=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,q=G!==void 0?G.length:0,E=Z.get(X);if(E===void 0||E.count!==q){let z=function(){T.dispose(),Z.delete(X),X.removeEventListener("dispose",z)};if(E!==void 0)E.texture.dispose();let O=X.morphAttributes.position!==void 0,k=X.morphAttributes.normal!==void 0,M=X.morphAttributes.color!==void 0,N=X.morphAttributes.position||[],F=X.morphAttributes.normal||[],C=X.morphAttributes.color||[],L=0;if(O===!0)L=1;if(k===!0)L=2;if(M===!0)L=3;let _=X.attributes.position.count*L,v=1;if(_>Q.maxTextureSize)v=Math.ceil(_/Q.maxTextureSize),_=Q.maxTextureSize;let w=new Float32Array(_*v*4*q),T=new P7(w,_,v,q);T.type=c8,T.needsUpdate=!0;let x=L*4;for(let V=0;V<q;V++){let j=N[V],m=F[V],l=C[V],c=_*v*4*V;for(let i=0;i<j.count;i++){let u=i*x;if(O===!0)W.fromBufferAttribute(j,i),w[c+u+0]=W.x,w[c+u+1]=W.y,w[c+u+2]=W.z,w[c+u+3]=0;if(k===!0)W.fromBufferAttribute(m,i),w[c+u+4]=W.x,w[c+u+5]=W.y,w[c+u+6]=W.z,w[c+u+7]=0;if(M===!0)W.fromBufferAttribute(l,i),w[c+u+8]=W.x,w[c+u+9]=W.y,w[c+u+10]=W.z,w[c+u+11]=l.itemSize===4?W.w:1}}E={count:q,texture:T,size:new PJ(_,v)},Z.set(X,E),X.addEventListener("dispose",z)}if(Y.isInstancedMesh===!0&&Y.morphTexture!==null)K.getUniforms().setValue(J,"morphTexture",Y.morphTexture,$);else{let O=0;for(let M=0;M<U.length;M++)O+=U[M];let k=X.morphTargetsRelative?1:1-O;K.getUniforms().setValue(J,"morphTargetBaseInfluence",k),K.getUniforms().setValue(J,"morphTargetInfluences",U)}K.getUniforms().setValue(J,"morphTargetsTexture",E.texture,$),K.getUniforms().setValue(J,"morphTargetsTextureSize",E.size)}return{update:H}}function BG(J,Q,$,Z){let W=new WeakMap;function H(K){let U=Z.render.frame,G=K.geometry,q=Q.get(K,G);if(W.get(q)!==U)Q.update(q),W.set(q,U);if(K.isInstancedMesh){if(K.hasEventListener("dispose",X)===!1)K.addEventListener("dispose",X);if(W.get(K)!==U){if($.update(K.instanceMatrix,J.ARRAY_BUFFER),K.instanceColor!==null)$.update(K.instanceColor,J.ARRAY_BUFFER);W.set(K,U)}}if(K.isSkinnedMesh){let E=K.skeleton;if(W.get(E)!==U)E.update(),W.set(E,U)}return q}function Y(){W=new WeakMap}function X(K){let U=K.target;if(U.removeEventListener("dispose",X),$.remove(U.instanceMatrix),U.instanceColor!==null)$.remove(U.instanceColor)}return{update:H,dispose:Y}}var jH=new E0,OH=new l7(1,1),yH=new P7,vH=new P$,fH=new y7,FH=[],RH=[],kH=new Float32Array(16),MH=new Float32Array(9),DH=new Float32Array(4);function r9(J,Q,$){let Z=J[0];if(Z<=0||Z>0)return J;let W=Q*$,H=FH[W];if(H===void 0)H=new Float32Array(W),FH[W]=H;if(Q!==0){Z.toArray(H,0);for(let Y=1,X=0;Y!==Q;++Y)X+=$,J[Y].toArray(H,X)}return H}function R0(J,Q){if(J.length!==Q.length)return!1;for(let $=0,Z=J.length;$<Z;$++)if(J[$]!==Q[$])return!1;return!0}function k0(J,Q){for(let $=0,Z=Q.length;$<Z;$++)J[$]=Q[$]}function JQ(J,Q){let $=RH[Q];if($===void 0)$=new Int32Array(Q),RH[Q]=$;for(let Z=0;Z!==Q;++Z)$[Z]=J.allocateTextureUnit();return $}function CG(J,Q){let $=this.cache;if($[0]===Q)return;J.uniform1f(this.addr,Q),$[0]=Q}function _G(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y)J.uniform2f(this.addr,Q.x,Q.y),$[0]=Q.x,$[1]=Q.y}else{if(R0($,Q))return;J.uniform2fv(this.addr,Q),k0($,Q)}}function wG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z)J.uniform3f(this.addr,Q.x,Q.y,Q.z),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z}else if(Q.r!==void 0){if($[0]!==Q.r||$[1]!==Q.g||$[2]!==Q.b)J.uniform3f(this.addr,Q.r,Q.g,Q.b),$[0]=Q.r,$[1]=Q.g,$[2]=Q.b}else{if(R0($,Q))return;J.uniform3fv(this.addr,Q),k0($,Q)}}function IG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z||$[3]!==Q.w)J.uniform4f(this.addr,Q.x,Q.y,Q.z,Q.w),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z,$[3]=Q.w}else{if(R0($,Q))return;J.uniform4fv(this.addr,Q),k0($,Q)}}function PG(J,Q){let $=this.cache,Z=Q.elements;if(Z===void 0){if(R0($,Q))return;J.uniformMatrix2fv(this.addr,!1,Q),k0($,Q)}else{if(R0($,Z))return;DH.set(Z),J.uniformMatrix2fv(this.addr,!1,DH),k0($,Z)}}function TG(J,Q){let $=this.cache,Z=Q.elements;if(Z===void 0){if(R0($,Q))return;J.uniformMatrix3fv(this.addr,!1,Q),k0($,Q)}else{if(R0($,Z))return;MH.set(Z),J.uniformMatrix3fv(this.addr,!1,MH),k0($,Z)}}function AG(J,Q){let $=this.cache,Z=Q.elements;if(Z===void 0){if(R0($,Q))return;J.uniformMatrix4fv(this.addr,!1,Q),k0($,Q)}else{if(R0($,Z))return;kH.set(Z),J.uniformMatrix4fv(this.addr,!1,kH),k0($,Z)}}function SG(J,Q){let $=this.cache;if($[0]===Q)return;J.uniform1i(this.addr,Q),$[0]=Q}function jG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y)J.uniform2i(this.addr,Q.x,Q.y),$[0]=Q.x,$[1]=Q.y}else{if(R0($,Q))return;J.uniform2iv(this.addr,Q),k0($,Q)}}function yG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z)J.uniform3i(this.addr,Q.x,Q.y,Q.z),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z}else{if(R0($,Q))return;J.uniform3iv(this.addr,Q),k0($,Q)}}function vG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z||$[3]!==Q.w)J.uniform4i(this.addr,Q.x,Q.y,Q.z,Q.w),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z,$[3]=Q.w}else{if(R0($,Q))return;J.uniform4iv(this.addr,Q),k0($,Q)}}function fG(J,Q){let $=this.cache;if($[0]===Q)return;J.uniform1ui(this.addr,Q),$[0]=Q}function hG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y)J.uniform2ui(this.addr,Q.x,Q.y),$[0]=Q.x,$[1]=Q.y}else{if(R0($,Q))return;J.uniform2uiv(this.addr,Q),k0($,Q)}}function bG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z)J.uniform3ui(this.addr,Q.x,Q.y,Q.z),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z}else{if(R0($,Q))return;J.uniform3uiv(this.addr,Q),k0($,Q)}}function xG(J,Q){let $=this.cache;if(Q.x!==void 0){if($[0]!==Q.x||$[1]!==Q.y||$[2]!==Q.z||$[3]!==Q.w)J.uniform4ui(this.addr,Q.x,Q.y,Q.z,Q.w),$[0]=Q.x,$[1]=Q.y,$[2]=Q.z,$[3]=Q.w}else{if(R0($,Q))return;J.uniform4uiv(this.addr,Q),k0($,Q)}}function gG(J,Q,$){let Z=this.cache,W=$.allocateTextureUnit();if(Z[0]!==W)J.uniform1i(this.addr,W),Z[0]=W;let H;if(this.type===J.SAMPLER_2D_SHADOW)OH.compareFunction=V$,H=OH;else H=jH;$.setTexture2D(Q||H,W)}function pG(J,Q,$){let Z=this.cache,W=$.allocateTextureUnit();if(Z[0]!==W)J.uniform1i(this.addr,W),Z[0]=W;$.setTexture3D(Q||vH,W)}function lG(J,Q,$){let Z=this.cache,W=$.allocateTextureUnit();if(Z[0]!==W)J.uniform1i(this.addr,W),Z[0]=W;$.setTextureCube(Q||fH,W)}function dG(J,Q,$){let Z=this.cache,W=$.allocateTextureUnit();if(Z[0]!==W)J.uniform1i(this.addr,W),Z[0]=W;$.setTexture2DArray(Q||yH,W)}function mG(J){switch(J){case 5126:return CG;case 35664:return _G;case 35665:return wG;case 35666:return IG;case 35674:return PG;case 35675:return TG;case 35676:return AG;case 5124:case 35670:return SG;case 35667:case 35671:return jG;case 35668:case 35672:return yG;case 35669:case 35673:return vG;case 5125:return fG;case 36294:return hG;case 36295:return bG;case 36296:return xG;case 35678:case 36198:case 36298:case 36306:case 35682:return gG;case 35679:case 36299:case 36307:return pG;case 35680:case 36300:case 36308:case 36293:return lG;case 36289:case 36303:case 36311:case 36292:return dG}}function uG(J,Q){J.uniform1fv(this.addr,Q)}function cG(J,Q){let $=r9(Q,this.size,2);J.uniform2fv(this.addr,$)}function nG(J,Q){let $=r9(Q,this.size,3);J.uniform3fv(this.addr,$)}function sG(J,Q){let $=r9(Q,this.size,4);J.uniform4fv(this.addr,$)}function oG(J,Q){let $=r9(Q,this.size,4);J.uniformMatrix2fv(this.addr,!1,$)}function iG(J,Q){let $=r9(Q,this.size,9);J.uniformMatrix3fv(this.addr,!1,$)}function aG(J,Q){let $=r9(Q,this.size,16);J.uniformMatrix4fv(this.addr,!1,$)}function rG(J,Q){J.uniform1iv(this.addr,Q)}function tG(J,Q){J.uniform2iv(this.addr,Q)}function eG(J,Q){J.uniform3iv(this.addr,Q)}function Jq(J,Q){J.uniform4iv(this.addr,Q)}function Qq(J,Q){J.uniform1uiv(this.addr,Q)}function $q(J,Q){J.uniform2uiv(this.addr,Q)}function Zq(J,Q){J.uniform3uiv(this.addr,Q)}function Wq(J,Q){J.uniform4uiv(this.addr,Q)}function Hq(J,Q,$){let Z=this.cache,W=Q.length,H=JQ($,W);if(!R0(Z,H))J.uniform1iv(this.addr,H),k0(Z,H);for(let Y=0;Y!==W;++Y)$.setTexture2D(Q[Y]||jH,H[Y])}function Yq(J,Q,$){let Z=this.cache,W=Q.length,H=JQ($,W);if(!R0(Z,H))J.uniform1iv(this.addr,H),k0(Z,H);for(let Y=0;Y!==W;++Y)$.setTexture3D(Q[Y]||vH,H[Y])}function Xq(J,Q,$){let Z=this.cache,W=Q.length,H=JQ($,W);if(!R0(Z,H))J.uniform1iv(this.addr,H),k0(Z,H);for(let Y=0;Y!==W;++Y)$.setTextureCube(Q[Y]||fH,H[Y])}function Kq(J,Q,$){let Z=this.cache,W=Q.length,H=JQ($,W);if(!R0(Z,H))J.uniform1iv(this.addr,H),k0(Z,H);for(let Y=0;Y!==W;++Y)$.setTexture2DArray(Q[Y]||yH,H[Y])}function Uq(J){switch(J){case 5126:return uG;case 35664:return cG;case 35665:return nG;case 35666:return sG;case 35674:return oG;case 35675:return iG;case 35676:return aG;case 5124:case 35670:return rG;case 35667:case 35671:return tG;case 35668:case 35672:return eG;case 35669:case 35673:return Jq;case 5125:return Qq;case 36294:return $q;case 36295:return Zq;case 36296:return Wq;case 35678:case 36198:case 36298:case 36306:case 35682:return Hq;case 35679:case 36299:case 36307:return Yq;case 35680:case 36300:case 36308:case 36293:return Xq;case 36289:case 36303:case 36311:case 36292:return Kq}}class hH{constructor(J,Q,$){this.id=J,this.addr=$,this.cache=[],this.type=Q.type,this.setValue=mG(Q.type)}}class bH{constructor(J,Q,$){this.id=J,this.addr=$,this.cache=[],this.type=Q.type,this.size=Q.size,this.setValue=Uq(Q.type)}}class xH{constructor(J){this.id=J,this.seq=[],this.map={}}setValue(J,Q,$){let Z=this.seq;for(let W=0,H=Z.length;W!==H;++W){let Y=Z[W];Y.setValue(J,Q[Y.id],$)}}}var i$=/(\w+)(\])?(\[|\.)?/g;function LH(J,Q){J.seq.push(Q),J.map[Q.id]=Q}function Gq(J,Q,$){let Z=J.name,W=Z.length;i$.lastIndex=0;while(!0){let H=i$.exec(Z),Y=i$.lastIndex,X=H[1],K=H[2]==="]",U=H[3];if(K)X=X|0;if(U===void 0||U==="["&&Y+2===W){LH($,U===void 0?new hH(X,J,Q):new bH(X,J,Q));break}else{let q=$.map[X];if(q===void 0)q=new xH(X),LH($,q);$=q}}}class j6{constructor(J,Q){this.seq=[],this.map={};let $=J.getProgramParameter(Q,J.ACTIVE_UNIFORMS);for(let Z=0;Z<$;++Z){let W=J.getActiveUniform(Q,Z),H=J.getUniformLocation(Q,W.name);Gq(W,H,this)}}setValue(J,Q,$,Z){let W=this.map[Q];if(W!==void 0)W.setValue(J,$,Z)}setOptional(J,Q,$){let Z=Q[$];if(Z!==void 0)this.setValue(J,$,Z)}static upload(J,Q,$,Z){for(let W=0,H=Q.length;W!==H;++W){let Y=Q[W],X=$[Y.id];if(X.needsUpdate!==!1)Y.setValue(J,X.value,Z)}}static seqWithValue(J,Q){let $=[];for(let Z=0,W=J.length;Z!==W;++Z){let H=J[Z];if(H.id in Q)$.push(H)}return $}}function VH(J,Q,$){let Z=J.createShader(Q);return J.shaderSource(Z,$),J.compileShader(Z),Z}var qq=37297,Eq=0;function Nq(J,Q){let $=J.split(`
`),Z=[],W=Math.max(Q-6,0),H=Math.min(Q+6,$.length);for(let Y=W;Y<H;Y++){let X=Y+1;Z.push(`${X===Q?">":" "} ${X}: ${$[Y]}`)}return Z.join(`
`)}var zH=new fJ;function Oq(J){lJ._getMatrix(zH,lJ.workingColorSpace,J);let Q=`mat3( ${zH.elements.map(($)=>$.toFixed(4))} )`;switch(lJ.getTransfer(J)){case L$:return[Q,"LinearTransferOETF"];case W0:return[Q,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",J),[Q,"LinearTransferOETF"]}}function BH(J,Q,$){let Z=J.getShaderParameter(Q,J.COMPILE_STATUS),H=(J.getShaderInfoLog(Q)||"").trim();if(Z&&H==="")return"";let Y=/ERROR: 0:(\d+)/.exec(H);if(Y){let X=parseInt(Y[1]);return $.toUpperCase()+`

`+H+`

`+Nq(J.getShaderSource(Q),X)}else return H}function Fq(J,Q){let $=Oq(Q);return[`vec4 ${J}( vec4 value ) {`,`	return ${$[1]}( vec4( value.rgb * ${$[0]}, value.a ) );`,"}"].join(`
`)}function Rq(J,Q){let $;switch(Q){case IW:$="Linear";break;case PW:$="Reinhard";break;case TW:$="Cineon";break;case F7:$="ACESFilmic";break;case SW:$="AgX";break;case jW:$="Neutral";break;case AW:$="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",Q),$="Linear"}return"vec3 "+J+"( vec3 color ) { return "+$+"ToneMapping( color ); }"}var e7=new A;function kq(){lJ.getLuminanceCoefficients(e7);let J=e7.x.toFixed(4),Q=e7.y.toFixed(4),$=e7.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${J}, ${Q}, ${$} );`,"\treturn dot( weights, rgb );","}"].join(`
`)}function Mq(J){return[J.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",J.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(S6).join(`
`)}function Dq(J){let Q=[];for(let $ in J){let Z=J[$];if(Z===!1)continue;Q.push("#define "+$+" "+Z)}return Q.join(`
`)}function Lq(J,Q){let $={},Z=J.getProgramParameter(Q,J.ACTIVE_ATTRIBUTES);for(let W=0;W<Z;W++){let H=J.getActiveAttrib(Q,W),Y=H.name,X=1;if(H.type===J.FLOAT_MAT2)X=2;if(H.type===J.FLOAT_MAT3)X=3;if(H.type===J.FLOAT_MAT4)X=4;$[Y]={type:H.type,location:J.getAttribLocation(Q,Y),locationSize:X}}return $}function S6(J){return J!==""}function CH(J,Q){let $=Q.numSpotLightShadows+Q.numSpotLightMaps-Q.numSpotLightShadowsWithMaps;return J.replace(/NUM_DIR_LIGHTS/g,Q.numDirLights).replace(/NUM_SPOT_LIGHTS/g,Q.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,Q.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,$).replace(/NUM_RECT_AREA_LIGHTS/g,Q.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,Q.numPointLights).replace(/NUM_HEMI_LIGHTS/g,Q.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,Q.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,Q.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,Q.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,Q.numPointLightShadows)}function _H(J,Q){return J.replace(/NUM_CLIPPING_PLANES/g,Q.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,Q.numClippingPlanes-Q.numClipIntersection)}var Vq=/^[ \t]*#include +<([\w\d./]+)>/gm;function r$(J){return J.replace(Vq,Bq)}var zq=new Map;function Bq(J,Q){let $=hJ[Q];if($===void 0){let Z=zq.get(Q);if(Z!==void 0)$=hJ[Z],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',Q,Z);else throw Error("Can not resolve #include <"+Q+">")}return r$($)}var Cq=/#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 wH(J){return J.replace(Cq,_q)}function _q(J,Q,$,Z){let W="";for(let H=parseInt(Q);H<parseInt($);H++)W+=Z.replace(/\[\s*i\s*\]/g,"[ "+H+" ]").replace(/UNROLLED_LOOP_INDEX/g,H);return W}function IH(J){let Q=`precision ${J.precision} float;
	precision ${J.precision} int;
	precision ${J.precision} sampler2D;
	precision ${J.precision} samplerCube;
	precision ${J.precision} sampler3D;
	precision ${J.precision} sampler2DArray;
	precision ${J.precision} sampler2DShadow;
	precision ${J.precision} samplerCubeShadow;
	precision ${J.precision} sampler2DArrayShadow;
	precision ${J.precision} isampler2D;
	precision ${J.precision} isampler3D;
	precision ${J.precision} isamplerCube;
	precision ${J.precision} isampler2DArray;
	precision ${J.precision} usampler2D;
	precision ${J.precision} usampler3D;
	precision ${J.precision} usamplerCube;
	precision ${J.precision} usampler2DArray;
	`;if(J.precision==="highp")Q+=`
#define HIGH_PRECISION`;else if(J.precision==="mediump")Q+=`
#define MEDIUM_PRECISION`;else if(J.precision==="lowp")Q+=`
#define LOW_PRECISION`;return Q}function wq(J){let Q="SHADOWMAP_TYPE_BASIC";if(J.shadowMapType===hQ)Q="SHADOWMAP_TYPE_PCF";else if(J.shadowMapType===ZW)Q="SHADOWMAP_TYPE_PCF_SOFT";else if(J.shadowMapType===U8)Q="SHADOWMAP_TYPE_VSM";return Q}function Iq(J){let Q="ENVMAP_TYPE_CUBE";if(J.envMap)switch(J.envMapMode){case h9:case X9:Q="ENVMAP_TYPE_CUBE";break;case O6:Q="ENVMAP_TYPE_CUBE_UV";break}return Q}function Pq(J){let Q="ENVMAP_MODE_REFLECTION";if(J.envMap)switch(J.envMapMode){case X9:Q="ENVMAP_MODE_REFRACTION";break}return Q}function Tq(J){let Q="ENVMAP_BLENDING_NONE";if(J.envMap)switch(J.combine){case CW:Q="ENVMAP_BLENDING_MULTIPLY";break;case _W:Q="ENVMAP_BLENDING_MIX";break;case wW:Q="ENVMAP_BLENDING_ADD";break}return Q}function Aq(J){let Q=J.envMapCubeUVHeight;if(Q===null)return null;let $=Math.log2(Q)-2,Z=1/Q;return{texelWidth:1/(3*Math.max(Math.pow(2,$),112)),texelHeight:Z,maxMip:$}}function Sq(J,Q,$,Z){let W=J.getContext(),H=$.defines,Y=$.vertexShader,X=$.fragmentShader,K=wq($),U=Iq($),G=Pq($),q=Tq($),E=Aq($),O=Mq($),k=Dq(H),M=W.createProgram(),N,F,C=$.glslVersion?"#version "+$.glslVersion+`
`:"";if($.isRawShaderMaterial){if(N=["#define SHADER_TYPE "+$.shaderType,"#define SHADER_NAME "+$.shaderName,k].filter(S6).join(`
`),N.length>0)N+=`
`;if(F=["#define SHADER_TYPE "+$.shaderType,"#define SHADER_NAME "+$.shaderName,k].filter(S6).join(`
`),F.length>0)F+=`
`}else N=[IH($),"#define SHADER_TYPE "+$.shaderType,"#define SHADER_NAME "+$.shaderName,k,$.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",$.batching?"#define USE_BATCHING":"",$.batchingColor?"#define USE_BATCHING_COLOR":"",$.instancing?"#define USE_INSTANCING":"",$.instancingColor?"#define USE_INSTANCING_COLOR":"",$.instancingMorph?"#define USE_INSTANCING_MORPH":"",$.useFog&&$.fog?"#define USE_FOG":"",$.useFog&&$.fogExp2?"#define FOG_EXP2":"",$.map?"#define USE_MAP":"",$.envMap?"#define USE_ENVMAP":"",$.envMap?"#define "+G:"",$.lightMap?"#define USE_LIGHTMAP":"",$.aoMap?"#define USE_AOMAP":"",$.bumpMap?"#define USE_BUMPMAP":"",$.normalMap?"#define USE_NORMALMAP":"",$.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",$.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",$.displacementMap?"#define USE_DISPLACEMENTMAP":"",$.emissiveMap?"#define USE_EMISSIVEMAP":"",$.anisotropy?"#define USE_ANISOTROPY":"",$.anisotropyMap?"#define USE_ANISOTROPYMAP":"",$.clearcoatMap?"#define USE_CLEARCOATMAP":"",$.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",$.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",$.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",$.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",$.specularMap?"#define USE_SPECULARMAP":"",$.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",$.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",$.roughnessMap?"#define USE_ROUGHNESSMAP":"",$.metalnessMap?"#define USE_METALNESSMAP":"",$.alphaMap?"#define USE_ALPHAMAP":"",$.alphaHash?"#define USE_ALPHAHASH":"",$.transmission?"#define USE_TRANSMISSION":"",$.transmissionMap?"#define USE_TRANSMISSIONMAP":"",$.thicknessMap?"#define USE_THICKNESSMAP":"",$.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",$.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",$.mapUv?"#define MAP_UV "+$.mapUv:"",$.alphaMapUv?"#define ALPHAMAP_UV "+$.alphaMapUv:"",$.lightMapUv?"#define LIGHTMAP_UV "+$.lightMapUv:"",$.aoMapUv?"#define AOMAP_UV "+$.aoMapUv:"",$.emissiveMapUv?"#define EMISSIVEMAP_UV "+$.emissiveMapUv:"",$.bumpMapUv?"#define BUMPMAP_UV "+$.bumpMapUv:"",$.normalMapUv?"#define NORMALMAP_UV "+$.normalMapUv:"",$.displacementMapUv?"#define DISPLACEMENTMAP_UV "+$.displacementMapUv:"",$.metalnessMapUv?"#define METALNESSMAP_UV "+$.metalnessMapUv:"",$.roughnessMapUv?"#define ROUGHNESSMAP_UV "+$.roughnessMapUv:"",$.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+$.anisotropyMapUv:"",$.clearcoatMapUv?"#define CLEARCOATMAP_UV "+$.clearcoatMapUv:"",$.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+$.clearcoatNormalMapUv:"",$.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+$.clearcoatRoughnessMapUv:"",$.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+$.iridescenceMapUv:"",$.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+$.iridescenceThicknessMapUv:"",$.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+$.sheenColorMapUv:"",$.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+$.sheenRoughnessMapUv:"",$.specularMapUv?"#define SPECULARMAP_UV "+$.specularMapUv:"",$.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+$.specularColorMapUv:"",$.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+$.specularIntensityMapUv:"",$.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+$.transmissionMapUv:"",$.thicknessMapUv?"#define THICKNESSMAP_UV "+$.thicknessMapUv:"",$.vertexTangents&&$.flatShading===!1?"#define USE_TANGENT":"",$.vertexColors?"#define USE_COLOR":"",$.vertexAlphas?"#define USE_COLOR_ALPHA":"",$.vertexUv1s?"#define USE_UV1":"",$.vertexUv2s?"#define USE_UV2":"",$.vertexUv3s?"#define USE_UV3":"",$.pointsUvs?"#define USE_POINTS_UV":"",$.flatShading?"#define FLAT_SHADED":"",$.skinning?"#define USE_SKINNING":"",$.morphTargets?"#define USE_MORPHTARGETS":"",$.morphNormals&&$.flatShading===!1?"#define USE_MORPHNORMALS":"",$.morphColors?"#define USE_MORPHCOLORS":"",$.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+$.morphTextureStride:"",$.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+$.morphTargetsCount:"",$.doubleSided?"#define DOUBLE_SIDED":"",$.flipSided?"#define FLIP_SIDED":"",$.shadowMapEnabled?"#define USE_SHADOWMAP":"",$.shadowMapEnabled?"#define "+K:"",$.sizeAttenuation?"#define USE_SIZEATTENUATION":"",$.numLightProbes>0?"#define USE_LIGHT_PROBES":"",$.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",$.reversedDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
`].filter(S6).join(`
`),F=[IH($),"#define SHADER_TYPE "+$.shaderType,"#define SHADER_NAME "+$.shaderName,k,$.useFog&&$.fog?"#define USE_FOG":"",$.useFog&&$.fogExp2?"#define FOG_EXP2":"",$.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",$.map?"#define USE_MAP":"",$.matcap?"#define USE_MATCAP":"",$.envMap?"#define USE_ENVMAP":"",$.envMap?"#define "+U:"",$.envMap?"#define "+G:"",$.envMap?"#define "+q:"",E?"#define CUBEUV_TEXEL_WIDTH "+E.texelWidth:"",E?"#define CUBEUV_TEXEL_HEIGHT "+E.texelHeight:"",E?"#define CUBEUV_MAX_MIP "+E.maxMip+".0":"",$.lightMap?"#define USE_LIGHTMAP":"",$.aoMap?"#define USE_AOMAP":"",$.bumpMap?"#define USE_BUMPMAP":"",$.normalMap?"#define USE_NORMALMAP":"",$.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",$.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",$.emissiveMap?"#define USE_EMISSIVEMAP":"",$.anisotropy?"#define USE_ANISOTROPY":"",$.anisotropyMap?"#define USE_ANISOTROPYMAP":"",$.clearcoat?"#define USE_CLEARCOAT":"",$.clearcoatMap?"#define USE_CLEARCOATMAP":"",$.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",$.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",$.dispersion?"#define USE_DISPERSION":"",$.iridescence?"#define USE_IRIDESCENCE":"",$.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",$.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",$.specularMap?"#define USE_SPECULARMAP":"",$.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",$.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",$.roughnessMap?"#define USE_ROUGHNESSMAP":"",$.metalnessMap?"#define USE_METALNESSMAP":"",$.alphaMap?"#define USE_ALPHAMAP":"",$.alphaTest?"#define USE_ALPHATEST":"",$.alphaHash?"#define USE_ALPHAHASH":"",$.sheen?"#define USE_SHEEN":"",$.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",$.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",$.transmission?"#define USE_TRANSMISSION":"",$.transmissionMap?"#define USE_TRANSMISSIONMAP":"",$.thicknessMap?"#define USE_THICKNESSMAP":"",$.vertexTangents&&$.flatShading===!1?"#define USE_TANGENT":"",$.vertexColors||$.instancingColor||$.batchingColor?"#define USE_COLOR":"",$.vertexAlphas?"#define USE_COLOR_ALPHA":"",$.vertexUv1s?"#define USE_UV1":"",$.vertexUv2s?"#define USE_UV2":"",$.vertexUv3s?"#define USE_UV3":"",$.pointsUvs?"#define USE_POINTS_UV":"",$.gradientMap?"#define USE_GRADIENTMAP":"",$.flatShading?"#define FLAT_SHADED":"",$.doubleSided?"#define DOUBLE_SIDED":"",$.flipSided?"#define FLIP_SIDED":"",$.shadowMapEnabled?"#define USE_SHADOWMAP":"",$.shadowMapEnabled?"#define "+K:"",$.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",$.numLightProbes>0?"#define USE_LIGHT_PROBES":"",$.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",$.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",$.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",$.reversedDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",$.toneMapping!==_8?"#define TONE_MAPPING":"",$.toneMapping!==_8?hJ.tonemapping_pars_fragment:"",$.toneMapping!==_8?Rq("toneMapping",$.toneMapping):"",$.dithering?"#define DITHERING":"",$.opaque?"#define OPAQUE":"",hJ.colorspace_pars_fragment,Fq("linearToOutputTexel",$.outputColorSpace),kq(),$.useDepthPacking?"#define DEPTH_PACKING "+$.depthPacking:"",`
`].filter(S6).join(`
`);if(Y=r$(Y),Y=CH(Y,$),Y=_H(Y,$),X=r$(X),X=CH(X,$),X=_H(X,$),Y=wH(Y),X=wH(X),$.isRawShaderMaterial!==!0)C=`#version 300 es
`,N=[O,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+N,F=["#define varying in",$.glslVersion===z$?"":"layout(location = 0) out highp vec4 pc_fragColor;",$.glslVersion===z$?"":"#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(`
`)+`
`+F;let L=C+N+Y,_=C+F+X,v=VH(W,W.VERTEX_SHADER,L),w=VH(W,W.FRAGMENT_SHADER,_);if(W.attachShader(M,v),W.attachShader(M,w),$.index0AttributeName!==void 0)W.bindAttribLocation(M,0,$.index0AttributeName);else if($.morphTargets===!0)W.bindAttribLocation(M,0,"position");W.linkProgram(M);function T(j){if(J.debug.checkShaderErrors){let m=W.getProgramInfoLog(M)||"",l=W.getShaderInfoLog(v)||"",c=W.getShaderInfoLog(w)||"",i=m.trim(),u=l.trim(),r=c.trim(),g=!0,ZJ=!0;if(W.getProgramParameter(M,W.LINK_STATUS)===!1)if(g=!1,typeof J.debug.onShaderError==="function")J.debug.onShaderError(W,M,v,w);else{let UJ=BH(W,v,"vertex"),TJ=BH(W,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+W.getError()+" - VALIDATE_STATUS "+W.getProgramParameter(M,W.VALIDATE_STATUS)+`

Material Name: `+j.name+`
Material Type: `+j.type+`

Program Info Log: `+i+`
`+UJ+`
`+TJ)}else if(i!=="")console.warn("THREE.WebGLProgram: Program Info Log:",i);else if(u===""||r==="")ZJ=!1;if(ZJ)j.diagnostics={runnable:g,programLog:i,vertexShader:{log:u,prefix:N},fragmentShader:{log:r,prefix:F}}}W.deleteShader(v),W.deleteShader(w),x=new j6(W,M),z=Lq(W,M)}let x;this.getUniforms=function(){if(x===void 0)T(this);return x};let z;this.getAttributes=function(){if(z===void 0)T(this);return z};let V=$.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(V===!1)V=W.getProgramParameter(M,qq);return V},this.destroy=function(){Z.releaseStatesOfProgram(this),W.deleteProgram(M),this.program=void 0},this.type=$.shaderType,this.name=$.shaderName,this.id=Eq++,this.cacheKey=Q,this.usedTimes=1,this.program=M,this.vertexShader=v,this.fragmentShader=w,this}var jq=0;class gH{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(J){let{vertexShader:Q,fragmentShader:$}=J,Z=this._getShaderStage(Q),W=this._getShaderStage($),H=this._getShaderCacheForMaterial(J);if(H.has(Z)===!1)H.add(Z),Z.usedTimes++;if(H.has(W)===!1)H.add(W),W.usedTimes++;return this}remove(J){let Q=this.materialCache.get(J);for(let $ of Q)if($.usedTimes--,$.usedTimes===0)this.shaderCache.delete($.code);return this.materialCache.delete(J),this}getVertexShaderID(J){return this._getShaderStage(J.vertexShader).id}getFragmentShaderID(J){return this._getShaderStage(J.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(J){let Q=this.materialCache,$=Q.get(J);if($===void 0)$=new Set,Q.set(J,$);return $}_getShaderStage(J){let Q=this.shaderCache,$=Q.get(J);if($===void 0)$=new pH(J),Q.set(J,$);return $}}class pH{constructor(J){this.id=jq++,this.code=J,this.usedTimes=0}}function yq(J,Q,$,Z,W,H,Y){let X=new T7,K=new gH,U=new Set,G=[],q=W.logarithmicDepthBuffer,E=W.vertexTextures,O=W.precision,k={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 M(z){if(U.add(z),z===0)return"uv";return`uv${z}`}function N(z,V,j,m,l){let c=m.fog,i=l.geometry,u=z.isMeshStandardMaterial?m.environment:null,r=(z.isMeshStandardMaterial?$:Q).get(z.envMap||u),g=!!r&&r.mapping===O6?r.image.height:null,ZJ=k[z.type];if(z.precision!==null){if(O=W.getMaxPrecision(z.precision),O!==z.precision)console.warn("THREE.WebGLProgram.getParameters:",z.precision,"not supported, using",O,"instead.")}let UJ=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,TJ=UJ!==void 0?UJ.length:0,mJ=0;if(i.morphAttributes.position!==void 0)mJ=1;if(i.morphAttributes.normal!==void 0)mJ=2;if(i.morphAttributes.color!==void 0)mJ=3;let Y0,d,WJ,MJ;if(ZJ){let rJ=O8[ZJ];Y0=rJ.vertexShader,d=rJ.fragmentShader}else Y0=z.vertexShader,d=z.fragmentShader,K.update(z),WJ=K.getVertexShaderID(z),MJ=K.getFragmentShaderID(z);let GJ=J.getRenderTarget(),RJ=J.state.buffers.depth.getReversed(),uJ=l.isInstancedMesh===!0,cJ=l.isBatchedMesh===!0,dJ=!!z.map,I=!!z.matcap,$0=!!r,CJ=!!z.aoMap,iJ=!!z.lightMap,zJ=!!z.bumpMap,X0=!!z.normalMap,DJ=!!z.displacementMap,wJ=!!z.emissiveMap,V0=!!z.metalnessMap,D0=!!z.roughnessMap,N0=z.anisotropy>0,B=z.clearcoat>0,R=z.dispersion>0,f=z.iridescence>0,n=z.sheen>0,o=z.transmission>0,p=N0&&!!z.anisotropyMap,EJ=B&&!!z.clearcoatMap,JJ=B&&!!z.clearcoatNormalMap,kJ=B&&!!z.clearcoatRoughnessMap,AJ=f&&!!z.iridescenceMap,e=f&&!!z.iridescenceThicknessMap,XJ=n&&!!z.sheenColorMap,LJ=n&&!!z.sheenRoughnessMap,VJ=!!z.specularMap,KJ=!!z.specularColorMap,bJ=!!z.specularIntensityMap,P=o&&!!z.transmissionMap,HJ=o&&!!z.thicknessMap,QJ=!!z.gradientMap,NJ=!!z.alphaMap,a=z.alphaTest>0,s=!!z.alphaHash,FJ=!!z.extensions,yJ=_8;if(z.toneMapped){if(GJ===null||GJ.isXRRenderTarget===!0)yJ=J.toneMapping}let J0={shaderID:ZJ,shaderType:z.type,shaderName:z.name,vertexShader:Y0,fragmentShader:d,defines:z.defines,customVertexShaderID:WJ,customFragmentShaderID:MJ,isRawShaderMaterial:z.isRawShaderMaterial===!0,glslVersion:z.glslVersion,precision:O,batching:cJ,batchingColor:cJ&&l._colorsTexture!==null,instancing:uJ,instancingColor:uJ&&l.instanceColor!==null,instancingMorph:uJ&&l.morphTexture!==null,supportsVertexTextures:E,outputColorSpace:GJ===null?J.outputColorSpace:GJ.isXRRenderTarget===!0?GJ.texture.colorSpace:T0,alphaToCoverage:!!z.alphaToCoverage,map:dJ,matcap:I,envMap:$0,envMapMode:$0&&r.mapping,envMapCubeUVHeight:g,aoMap:CJ,lightMap:iJ,bumpMap:zJ,normalMap:X0,displacementMap:E&&DJ,emissiveMap:wJ,normalMapObjectSpace:X0&&z.normalMapType===mW,normalMapTangentSpace:X0&&z.normalMapType===dW,metalnessMap:V0,roughnessMap:D0,anisotropy:N0,anisotropyMap:p,clearcoat:B,clearcoatMap:EJ,clearcoatNormalMap:JJ,clearcoatRoughnessMap:kJ,dispersion:R,iridescence:f,iridescenceMap:AJ,iridescenceThicknessMap:e,sheen:n,sheenColorMap:XJ,sheenRoughnessMap:LJ,specularMap:VJ,specularColorMap:KJ,specularIntensityMap:bJ,transmission:o,transmissionMap:P,thicknessMap:HJ,gradientMap:QJ,opaque:z.transparent===!1&&z.blending===E6&&z.alphaToCoverage===!1,alphaMap:NJ,alphaTest:a,alphaHash:s,combine:z.combine,mapUv:dJ&&M(z.map.channel),aoMapUv:CJ&&M(z.aoMap.channel),lightMapUv:iJ&&M(z.lightMap.channel),bumpMapUv:zJ&&M(z.bumpMap.channel),normalMapUv:X0&&M(z.normalMap.channel),displacementMapUv:DJ&&M(z.displacementMap.channel),emissiveMapUv:wJ&&M(z.emissiveMap.channel),metalnessMapUv:V0&&M(z.metalnessMap.channel),roughnessMapUv:D0&&M(z.roughnessMap.channel),anisotropyMapUv:p&&M(z.anisotropyMap.channel),clearcoatMapUv:EJ&&M(z.clearcoatMap.channel),clearcoatNormalMapUv:JJ&&M(z.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:kJ&&M(z.clearcoatRoughnessMap.channel),iridescenceMapUv:AJ&&M(z.iridescenceMap.channel),iridescenceThicknessMapUv:e&&M(z.iridescenceThicknessMap.channel),sheenColorMapUv:XJ&&M(z.sheenColorMap.channel),sheenRoughnessMapUv:LJ&&M(z.sheenRoughnessMap.channel),specularMapUv:VJ&&M(z.specularMap.channel),specularColorMapUv:KJ&&M(z.specularColorMap.channel),specularIntensityMapUv:bJ&&M(z.specularIntensityMap.channel),transmissionMapUv:P&&M(z.transmissionMap.channel),thicknessMapUv:HJ&&M(z.thicknessMap.channel),alphaMapUv:NJ&&M(z.alphaMap.channel),vertexTangents:!!i.attributes.tangent&&(X0||N0),vertexColors:z.vertexColors,vertexAlphas:z.vertexColors===!0&&!!i.attributes.color&&i.attributes.color.itemSize===4,pointsUvs:l.isPoints===!0&&!!i.attributes.uv&&(dJ||NJ),fog:!!c,useFog:z.fog===!0,fogExp2:!!c&&c.isFogExp2,flatShading:z.flatShading===!0&&z.wireframe===!1,sizeAttenuation:z.sizeAttenuation===!0,logarithmicDepthBuffer:q,reversedDepthBuffer:RJ,skinning:l.isSkinnedMesh===!0,morphTargets:i.morphAttributes.position!==void 0,morphNormals:i.morphAttributes.normal!==void 0,morphColors:i.morphAttributes.color!==void 0,morphTargetsCount:TJ,morphTextureStride:mJ,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:Y.numPlanes,numClipIntersection:Y.numIntersection,dithering:z.dithering,shadowMapEnabled:J.shadowMap.enabled&&j.length>0,shadowMapType:J.shadowMap.type,toneMapping:yJ,decodeVideoTexture:dJ&&z.map.isVideoTexture===!0&&lJ.getTransfer(z.map.colorSpace)===W0,decodeVideoTextureEmissive:wJ&&z.emissiveMap.isVideoTexture===!0&&lJ.getTransfer(z.emissiveMap.colorSpace)===W0,premultipliedAlpha:z.premultipliedAlpha,doubleSided:z.side===j0,flipSided:z.side===g0,useDepthPacking:z.depthPacking>=0,depthPacking:z.depthPacking||0,index0AttributeName:z.index0AttributeName,extensionClipCullDistance:FJ&&z.extensions.clipCullDistance===!0&&Z.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(FJ&&z.extensions.multiDraw===!0||cJ)&&Z.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:Z.has("KHR_parallel_shader_compile"),customProgramCacheKey:z.customProgramCacheKey()};return J0.vertexUv1s=U.has(1),J0.vertexUv2s=U.has(2),J0.vertexUv3s=U.has(3),U.clear(),J0}function F(z){let V=[];if(z.shaderID)V.push(z.shaderID);else V.push(z.customVertexShaderID),V.push(z.customFragmentShaderID);if(z.defines!==void 0)for(let j in z.defines)V.push(j),V.push(z.defines[j]);if(z.isRawShaderMaterial===!1)C(V,z),L(V,z),V.push(J.outputColorSpace);return V.push(z.customProgramCacheKey),V.join()}function C(z,V){z.push(V.precision),z.push(V.outputColorSpace),z.push(V.envMapMode),z.push(V.envMapCubeUVHeight),z.push(V.mapUv),z.push(V.alphaMapUv),z.push(V.lightMapUv),z.push(V.aoMapUv),z.push(V.bumpMapUv),z.push(V.normalMapUv),z.push(V.displacementMapUv),z.push(V.emissiveMapUv),z.push(V.metalnessMapUv),z.push(V.roughnessMapUv),z.push(V.anisotropyMapUv),z.push(V.clearcoatMapUv),z.push(V.clearcoatNormalMapUv),z.push(V.clearcoatRoughnessMapUv),z.push(V.iridescenceMapUv),z.push(V.iridescenceThicknessMapUv),z.push(V.sheenColorMapUv),z.push(V.sheenRoughnessMapUv),z.push(V.specularMapUv),z.push(V.specularColorMapUv),z.push(V.specularIntensityMapUv),z.push(V.transmissionMapUv),z.push(V.thicknessMapUv),z.push(V.combine),z.push(V.fogExp2),z.push(V.sizeAttenuation),z.push(V.morphTargetsCount),z.push(V.morphAttributeCount),z.push(V.numDirLights),z.push(V.numPointLights),z.push(V.numSpotLights),z.push(V.numSpotLightMaps),z.push(V.numHemiLights),z.push(V.numRectAreaLights),z.push(V.numDirLightShadows),z.push(V.numPointLightShadows),z.push(V.numSpotLightShadows),z.push(V.numSpotLightShadowsWithMaps),z.push(V.numLightProbes),z.push(V.shadowMapType),z.push(V.toneMapping),z.push(V.numClippingPlanes),z.push(V.numClipIntersection),z.push(V.depthPacking)}function L(z,V){if(X.disableAll(),V.supportsVertexTextures)X.enable(0);if(V.instancing)X.enable(1);if(V.instancingColor)X.enable(2);if(V.instancingMorph)X.enable(3);if(V.matcap)X.enable(4);if(V.envMap)X.enable(5);if(V.normalMapObjectSpace)X.enable(6);if(V.normalMapTangentSpace)X.enable(7);if(V.clearcoat)X.enable(8);if(V.iridescence)X.enable(9);if(V.alphaTest)X.enable(10);if(V.vertexColors)X.enable(11);if(V.vertexAlphas)X.enable(12);if(V.vertexUv1s)X.enable(13);if(V.vertexUv2s)X.enable(14);if(V.vertexUv3s)X.enable(15);if(V.vertexTangents)X.enable(16);if(V.anisotropy)X.enable(17);if(V.alphaHash)X.enable(18);if(V.batching)X.enable(19);if(V.dispersion)X.enable(20);if(V.batchingColor)X.enable(21);if(V.gradientMap)X.enable(22);if(z.push(X.mask),X.disableAll(),V.fog)X.enable(0);if(V.useFog)X.enable(1);if(V.flatShading)X.enable(2);if(V.logarithmicDepthBuffer)X.enable(3);if(V.reversedDepthBuffer)X.enable(4);if(V.skinning)X.enable(5);if(V.morphTargets)X.enable(6);if(V.morphNormals)X.enable(7);if(V.morphColors)X.enable(8);if(V.premultipliedAlpha)X.enable(9);if(V.shadowMapEnabled)X.enable(10);if(V.doubleSided)X.enable(11);if(V.flipSided)X.enable(12);if(V.useDepthPacking)X.enable(13);if(V.dithering)X.enable(14);if(V.transmission)X.enable(15);if(V.sheen)X.enable(16);if(V.opaque)X.enable(17);if(V.pointsUvs)X.enable(18);if(V.decodeVideoTexture)X.enable(19);if(V.decodeVideoTextureEmissive)X.enable(20);if(V.alphaToCoverage)X.enable(21);z.push(X.mask)}function _(z){let V=k[z.type],j;if(V){let m=O8[V];j=JH.clone(m.uniforms)}else j=z.uniforms;return j}function v(z,V){let j;for(let m=0,l=G.length;m<l;m++){let c=G[m];if(c.cacheKey===V){j=c,++j.usedTimes;break}}if(j===void 0)j=new Sq(J,V,z,H),G.push(j);return j}function w(z){if(--z.usedTimes===0){let V=G.indexOf(z);G[V]=G[G.length-1],G.pop(),z.destroy()}}function T(z){K.remove(z)}function x(){K.dispose()}return{getParameters:N,getProgramCacheKey:F,getUniforms:_,acquireProgram:v,releaseProgram:w,releaseShaderCache:T,programs:G,dispose:x}}function vq(){let J=new WeakMap;function Q(Y){return J.has(Y)}function $(Y){let X=J.get(Y);if(X===void 0)X={},J.set(Y,X);return X}function Z(Y){J.delete(Y)}function W(Y,X,K){J.get(Y)[X]=K}function H(){J=new WeakMap}return{has:Q,get:$,remove:Z,update:W,dispose:H}}function fq(J,Q){if(J.groupOrder!==Q.groupOrder)return J.groupOrder-Q.groupOrder;else if(J.renderOrder!==Q.renderOrder)return J.renderOrder-Q.renderOrder;else if(J.material.id!==Q.material.id)return J.material.id-Q.material.id;else if(J.z!==Q.z)return J.z-Q.z;else return J.id-Q.id}function PH(J,Q){if(J.groupOrder!==Q.groupOrder)return J.groupOrder-Q.groupOrder;else if(J.renderOrder!==Q.renderOrder)return J.renderOrder-Q.renderOrder;else if(J.z!==Q.z)return Q.z-J.z;else return J.id-Q.id}function TH(){let J=[],Q=0,$=[],Z=[],W=[];function H(){Q=0,$.length=0,Z.length=0,W.length=0}function Y(q,E,O,k,M,N){let F=J[Q];if(F===void 0)F={id:q.id,object:q,geometry:E,material:O,groupOrder:k,renderOrder:q.renderOrder,z:M,group:N},J[Q]=F;else F.id=q.id,F.object=q,F.geometry=E,F.material=O,F.groupOrder=k,F.renderOrder=q.renderOrder,F.z=M,F.group=N;return Q++,F}function X(q,E,O,k,M,N){let F=Y(q,E,O,k,M,N);if(O.transmission>0)Z.push(F);else if(O.transparent===!0)W.push(F);else $.push(F)}function K(q,E,O,k,M,N){let F=Y(q,E,O,k,M,N);if(O.transmission>0)Z.unshift(F);else if(O.transparent===!0)W.unshift(F);else $.unshift(F)}function U(q,E){if($.length>1)$.sort(q||fq);if(Z.length>1)Z.sort(E||PH);if(W.length>1)W.sort(E||PH)}function G(){for(let q=Q,E=J.length;q<E;q++){let O=J[q];if(O.id===null)break;O.id=null,O.object=null,O.geometry=null,O.material=null,O.group=null}}return{opaque:$,transmissive:Z,transparent:W,init:H,push:X,unshift:K,finish:G,sort:U}}function hq(){let J=new WeakMap;function Q(Z,W){let H=J.get(Z),Y;if(H===void 0)Y=new TH,J.set(Z,[Y]);else if(W>=H.length)Y=new TH,H.push(Y);else Y=H[W];return Y}function $(){J=new WeakMap}return{get:Q,dispose:$}}function bq(){let J={};return{get:function(Q){if(J[Q.id]!==void 0)return J[Q.id];let $;switch(Q.type){case"DirectionalLight":$={direction:new A,color:new jJ};break;case"SpotLight":$={position:new A,direction:new A,color:new jJ,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":$={position:new A,color:new jJ,distance:0,decay:0};break;case"HemisphereLight":$={direction:new A,skyColor:new jJ,groundColor:new jJ};break;case"RectAreaLight":$={color:new jJ,position:new A,halfWidth:new A,halfHeight:new A};break}return J[Q.id]=$,$}}}function xq(){let J={};return{get:function(Q){if(J[Q.id]!==void 0)return J[Q.id];let $;switch(Q.type){case"DirectionalLight":$={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new PJ};break;case"SpotLight":$={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new PJ};break;case"PointLight":$={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new PJ,shadowCameraNear:1,shadowCameraFar:1000};break}return J[Q.id]=$,$}}}var gq=0;function pq(J,Q){return(Q.castShadow?2:0)-(J.castShadow?2:0)+(Q.map?1:0)-(J.map?1:0)}function lq(J){let Q=new bq,$=xq(),Z={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 U=0;U<9;U++)Z.probe.push(new A);let W=new A,H=new vJ,Y=new vJ;function X(U){let G=0,q=0,E=0;for(let z=0;z<9;z++)Z.probe[z].set(0,0,0);let O=0,k=0,M=0,N=0,F=0,C=0,L=0,_=0,v=0,w=0,T=0;U.sort(pq);for(let z=0,V=U.length;z<V;z++){let j=U[z],m=j.color,l=j.intensity,c=j.distance,i=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)G+=m.r*l,q+=m.g*l,E+=m.b*l;else if(j.isLightProbe){for(let u=0;u<9;u++)Z.probe[u].addScaledVector(j.sh.coefficients[u],l);T++}else if(j.isDirectionalLight){let u=Q.get(j);if(u.color.copy(j.color).multiplyScalar(j.intensity),j.castShadow){let r=j.shadow,g=$.get(j);g.shadowIntensity=r.intensity,g.shadowBias=r.bias,g.shadowNormalBias=r.normalBias,g.shadowRadius=r.radius,g.shadowMapSize=r.mapSize,Z.directionalShadow[O]=g,Z.directionalShadowMap[O]=i,Z.directionalShadowMatrix[O]=j.shadow.matrix,C++}Z.directional[O]=u,O++}else if(j.isSpotLight){let u=Q.get(j);u.position.setFromMatrixPosition(j.matrixWorld),u.color.copy(m).multiplyScalar(l),u.distance=c,u.coneCos=Math.cos(j.angle),u.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),u.decay=j.decay,Z.spot[M]=u;let r=j.shadow;if(j.map){if(Z.spotLightMap[v]=j.map,v++,r.updateMatrices(j),j.castShadow)w++}if(Z.spotLightMatrix[M]=r.matrix,j.castShadow){let g=$.get(j);g.shadowIntensity=r.intensity,g.shadowBias=r.bias,g.shadowNormalBias=r.normalBias,g.shadowRadius=r.radius,g.shadowMapSize=r.mapSize,Z.spotShadow[M]=g,Z.spotShadowMap[M]=i,_++}M++}else if(j.isRectAreaLight){let u=Q.get(j);u.color.copy(m).multiplyScalar(l),u.halfWidth.set(j.width*0.5,0,0),u.halfHeight.set(0,j.height*0.5,0),Z.rectArea[N]=u,N++}else if(j.isPointLight){let u=Q.get(j);if(u.color.copy(j.color).multiplyScalar(j.intensity),u.distance=j.distance,u.decay=j.decay,j.castShadow){let r=j.shadow,g=$.get(j);g.shadowIntensity=r.intensity,g.shadowBias=r.bias,g.shadowNormalBias=r.normalBias,g.shadowRadius=r.radius,g.shadowMapSize=r.mapSize,g.shadowCameraNear=r.camera.near,g.shadowCameraFar=r.camera.far,Z.pointShadow[k]=g,Z.pointShadowMap[k]=i,Z.pointShadowMatrix[k]=j.shadow.matrix,L++}Z.point[k]=u,k++}else if(j.isHemisphereLight){let u=Q.get(j);u.skyColor.copy(j.color).multiplyScalar(l),u.groundColor.copy(j.groundColor).multiplyScalar(l),Z.hemi[F]=u,F++}}if(N>0)if(J.has("OES_texture_float_linear")===!0)Z.rectAreaLTC1=$J.LTC_FLOAT_1,Z.rectAreaLTC2=$J.LTC_FLOAT_2;else Z.rectAreaLTC1=$J.LTC_HALF_1,Z.rectAreaLTC2=$J.LTC_HALF_2;Z.ambient[0]=G,Z.ambient[1]=q,Z.ambient[2]=E;let x=Z.hash;if(x.directionalLength!==O||x.pointLength!==k||x.spotLength!==M||x.rectAreaLength!==N||x.hemiLength!==F||x.numDirectionalShadows!==C||x.numPointShadows!==L||x.numSpotShadows!==_||x.numSpotMaps!==v||x.numLightProbes!==T)Z.directional.length=O,Z.spot.length=M,Z.rectArea.length=N,Z.point.length=k,Z.hemi.length=F,Z.directionalShadow.length=C,Z.directionalShadowMap.length=C,Z.pointShadow.length=L,Z.pointShadowMap.length=L,Z.spotShadow.length=_,Z.spotShadowMap.length=_,Z.directionalShadowMatrix.length=C,Z.pointShadowMatrix.length=L,Z.spotLightMatrix.length=_+v-w,Z.spotLightMap.length=v,Z.numSpotLightShadowsWithMaps=w,Z.numLightProbes=T,x.directionalLength=O,x.pointLength=k,x.spotLength=M,x.rectAreaLength=N,x.hemiLength=F,x.numDirectionalShadows=C,x.numPointShadows=L,x.numSpotShadows=_,x.numSpotMaps=v,x.numLightProbes=T,Z.version=gq++}function K(U,G){let q=0,E=0,O=0,k=0,M=0,N=G.matrixWorldInverse;for(let F=0,C=U.length;F<C;F++){let L=U[F];if(L.isDirectionalLight){let _=Z.directional[q];_.direction.setFromMatrixPosition(L.matrixWorld),W.setFromMatrixPosition(L.target.matrixWorld),_.direction.sub(W),_.direction.transformDirection(N),q++}else if(L.isSpotLight){let _=Z.spot[O];_.position.setFromMatrixPosition(L.matrixWorld),_.position.applyMatrix4(N),_.direction.setFromMatrixPosition(L.matrixWorld),W.setFromMatrixPosition(L.target.matrixWorld),_.direction.sub(W),_.direction.transformDirection(N),O++}else if(L.isRectAreaLight){let _=Z.rectArea[k];_.position.setFromMatrixPosition(L.matrixWorld),_.position.applyMatrix4(N),Y.identity(),H.copy(L.matrixWorld),H.premultiply(N),Y.extractRotation(H),_.halfWidth.set(L.width*0.5,0,0),_.halfHeight.set(0,L.height*0.5,0),_.halfWidth.applyMatrix4(Y),_.halfHeight.applyMatrix4(Y),k++}else if(L.isPointLight){let _=Z.point[E];_.position.setFromMatrixPosition(L.matrixWorld),_.position.applyMatrix4(N),E++}else if(L.isHemisphereLight){let _=Z.hemi[M];_.direction.setFromMatrixPosition(L.matrixWorld),_.direction.transformDirection(N),M++}}}return{setup:X,setupView:K,state:Z}}function AH(J){let Q=new lq(J),$=[],Z=[];function W(G){U.camera=G,$.length=0,Z.length=0}function H(G){$.push(G)}function Y(G){Z.push(G)}function X(){Q.setup($)}function K(G){Q.setupView($,G)}let U={lightsArray:$,shadowsArray:Z,camera:null,lights:Q,transmissionRenderTarget:{}};return{init:W,state:U,setupLights:X,setupLightsView:K,pushLight:H,pushShadow:Y}}function dq(J){let Q=new WeakMap;function $(W,H=0){let Y=Q.get(W),X;if(Y===void 0)X=new AH(J),Q.set(W,[X]);else if(H>=Y.length)X=new AH(J),Y.push(X);else X=Y[H];return X}function Z(){Q=new WeakMap}return{get:$,dispose:Z}}var mq=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,uq=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function cq(J,Q,$){let Z=new _6,W=new PJ,H=new PJ,Y=new sJ,X=new j$({depthPacking:lW}),K=new y$,U={},G=$.maxTextureSize,q={[d8]:g0,[g0]:d8,[j0]:j0},E=new N8({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new PJ},radius:{value:4}},vertexShader:mq,fragmentShader:uq}),O=E.clone();O.defines.HORIZONTAL_PASS=1;let k=new d0;k.setAttribute("position",new F0(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let M=new _0(k,E),N=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=hQ;let F=this.type;this.render=function(w,T,x){if(N.enabled===!1)return;if(N.autoUpdate===!1&&N.needsUpdate===!1)return;if(w.length===0)return;let z=J.getRenderTarget(),V=J.getActiveCubeFace(),j=J.getActiveMipmapLevel(),m=J.state;if(m.setBlending(m8),m.buffers.depth.getReversed())m.buffers.color.setClear(0,0,0,0);else m.buffers.color.setClear(1,1,1,1);m.buffers.depth.setTest(!0),m.setScissorTest(!1);let l=F!==U8&&this.type===U8,c=F===U8&&this.type!==U8;for(let i=0,u=w.length;i<u;i++){let r=w[i],g=r.shadow;if(g===void 0){console.warn("THREE.WebGLShadowMap:",r,"has no shadow.");continue}if(g.autoUpdate===!1&&g.needsUpdate===!1)continue;W.copy(g.mapSize);let ZJ=g.getFrameExtents();if(W.multiply(ZJ),H.copy(g.mapSize),W.x>G||W.y>G){if(W.x>G)H.x=Math.floor(G/ZJ.x),W.x=H.x*ZJ.x,g.mapSize.x=H.x;if(W.y>G)H.y=Math.floor(G/ZJ.y),W.y=H.y*ZJ.y,g.mapSize.y=H.y}if(g.map===null||l===!0||c===!0){let TJ=this.type!==U8?{minFilter:w8,magFilter:w8}:{};if(g.map!==null)g.map.dispose();g.map=new T8(W.x,W.y,TJ),g.map.texture.name=r.name+".shadowMap",g.camera.updateProjectionMatrix()}J.setRenderTarget(g.map),J.clear();let UJ=g.getViewportCount();for(let TJ=0;TJ<UJ;TJ++){let mJ=g.getViewport(TJ);Y.set(H.x*mJ.x,H.y*mJ.y,H.x*mJ.z,H.y*mJ.w),m.viewport(Y),g.updateMatrices(r,TJ),Z=g.getFrustum(),_(T,x,g.camera,r,this.type)}if(g.isPointLightShadow!==!0&&this.type===U8)C(g,x);g.needsUpdate=!1}F=this.type,N.needsUpdate=!1,J.setRenderTarget(z,V,j)};function C(w,T){let x=Q.update(M);if(E.defines.VSM_SAMPLES!==w.blurSamples)E.defines.VSM_SAMPLES=w.blurSamples,O.defines.VSM_SAMPLES=w.blurSamples,E.needsUpdate=!0,O.needsUpdate=!0;if(w.mapPass===null)w.mapPass=new T8(W.x,W.y);E.uniforms.shadow_pass.value=w.map.texture,E.uniforms.resolution.value=w.mapSize,E.uniforms.radius.value=w.radius,J.setRenderTarget(w.mapPass),J.clear(),J.renderBufferDirect(T,null,x,E,M,null),O.uniforms.shadow_pass.value=w.mapPass.texture,O.uniforms.resolution.value=w.mapSize,O.uniforms.radius.value=w.radius,J.setRenderTarget(w.map),J.clear(),J.renderBufferDirect(T,null,x,O,M,null)}function L(w,T,x,z){let V=null,j=x.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(j!==void 0)V=j;else if(V=x.isPointLight===!0?K:X,J.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){let m=V.uuid,l=T.uuid,c=U[m];if(c===void 0)c={},U[m]=c;let i=c[l];if(i===void 0)i=V.clone(),c[l]=i,T.addEventListener("dispose",v);V=i}if(V.visible=T.visible,V.wireframe=T.wireframe,z===U8)V.side=T.shadowSide!==null?T.shadowSide:T.side;else V.side=T.shadowSide!==null?T.shadowSide:q[T.side];if(V.alphaMap=T.alphaMap,V.alphaTest=T.alphaToCoverage===!0?0.5:T.alphaTest,V.map=T.map,V.clipShadows=T.clipShadows,V.clippingPlanes=T.clippingPlanes,V.clipIntersection=T.clipIntersection,V.displacementMap=T.displacementMap,V.displacementScale=T.displacementScale,V.displacementBias=T.displacementBias,V.wireframeLinewidth=T.wireframeLinewidth,V.linewidth=T.linewidth,x.isPointLight===!0&&V.isMeshDistanceMaterial===!0){let m=J.properties.get(V);m.light=x}return V}function _(w,T,x,z,V){if(w.visible===!1)return;if(w.layers.test(T.layers)&&(w.isMesh||w.isLine||w.isPoints)){if((w.castShadow||w.receiveShadow&&V===U8)&&(!w.frustumCulled||Z.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,w.matrixWorld);let l=Q.update(w),c=w.material;if(Array.isArray(c)){let i=l.groups;for(let u=0,r=i.length;u<r;u++){let g=i[u],ZJ=c[g.materialIndex];if(ZJ&&ZJ.visible){let UJ=L(w,ZJ,z,V);w.onBeforeShadow(J,w,T,x,l,UJ,g),J.renderBufferDirect(x,null,l,UJ,w,g),w.onAfterShadow(J,w,T,x,l,UJ,g)}}}else if(c.visible){let i=L(w,c,z,V);w.onBeforeShadow(J,w,T,x,l,i,null),J.renderBufferDirect(x,null,l,i,w,null),w.onAfterShadow(J,w,T,x,l,i,null)}}}let m=w.children;for(let l=0,c=m.length;l<c;l++)_(m[l],T,x,z,V)}function v(w){w.target.removeEventListener("dispose",v);for(let x in U){let z=U[x],V=w.target.uuid;if(V in z)z[V].dispose(),delete z[V]}}}var nq={[K7]:U7,[G7]:N7,[q7]:O7,[N6]:E7,[U7]:K7,[N7]:G7,[O7]:q7,[E7]:N6};function sq(J,Q){function $(){let P=!1,HJ=new sJ,QJ=null,NJ=new sJ(0,0,0,0);return{setMask:function(a){if(QJ!==a&&!P)J.colorMask(a,a,a,a),QJ=a},setLocked:function(a){P=a},setClear:function(a,s,FJ,yJ,J0){if(J0===!0)a*=yJ,s*=yJ,FJ*=yJ;if(HJ.set(a,s,FJ,yJ),NJ.equals(HJ)===!1)J.clearColor(a,s,FJ,yJ),NJ.copy(HJ)},reset:function(){P=!1,QJ=null,NJ.set(-1,0,0,0)}}}function Z(){let P=!1,HJ=!1,QJ=null,NJ=null,a=null;return{setReversed:function(s){if(HJ!==s){let FJ=Q.get("EXT_clip_control");if(s)FJ.clipControlEXT(FJ.LOWER_LEFT_EXT,FJ.ZERO_TO_ONE_EXT);else FJ.clipControlEXT(FJ.LOWER_LEFT_EXT,FJ.NEGATIVE_ONE_TO_ONE_EXT);HJ=s;let yJ=a;a=null,this.setClear(yJ)}},getReversed:function(){return HJ},setTest:function(s){if(s)GJ(J.DEPTH_TEST);else RJ(J.DEPTH_TEST)},setMask:function(s){if(QJ!==s&&!P)J.depthMask(s),QJ=s},setFunc:function(s){if(HJ)s=nq[s];if(NJ!==s){switch(s){case K7:J.depthFunc(J.NEVER);break;case U7:J.depthFunc(J.ALWAYS);break;case G7:J.depthFunc(J.LESS);break;case N6:J.depthFunc(J.LEQUAL);break;case q7:J.depthFunc(J.EQUAL);break;case E7:J.depthFunc(J.GEQUAL);break;case N7:J.depthFunc(J.GREATER);break;case O7:J.depthFunc(J.NOTEQUAL);break;default:J.depthFunc(J.LEQUAL)}NJ=s}},setLocked:function(s){P=s},setClear:function(s){if(a!==s){if(HJ)s=1-s;J.clearDepth(s),a=s}},reset:function(){P=!1,QJ=null,NJ=null,a=null,HJ=!1}}}function W(){let P=!1,HJ=null,QJ=null,NJ=null,a=null,s=null,FJ=null,yJ=null,J0=null;return{setTest:function(rJ){if(!P)if(rJ)GJ(J.STENCIL_TEST);else RJ(J.STENCIL_TEST)},setMask:function(rJ){if(HJ!==rJ&&!P)J.stencilMask(rJ),HJ=rJ},setFunc:function(rJ,H8,Y8){if(QJ!==rJ||NJ!==H8||a!==Y8)J.stencilFunc(rJ,H8,Y8),QJ=rJ,NJ=H8,a=Y8},setOp:function(rJ,H8,Y8){if(s!==rJ||FJ!==H8||yJ!==Y8)J.stencilOp(rJ,H8,Y8),s=rJ,FJ=H8,yJ=Y8},setLocked:function(rJ){P=rJ},setClear:function(rJ){if(J0!==rJ)J.clearStencil(rJ),J0=rJ},reset:function(){P=!1,HJ=null,QJ=null,NJ=null,a=null,s=null,FJ=null,yJ=null,J0=null}}}let H=new $,Y=new Z,X=new W,K=new WeakMap,U=new WeakMap,G={},q={},E=new WeakMap,O=[],k=null,M=!1,N=null,F=null,C=null,L=null,_=null,v=null,w=null,T=new jJ(0,0,0),x=0,z=!1,V=null,j=null,m=null,l=null,c=null,i=J.getParameter(J.MAX_COMBINED_TEXTURE_IMAGE_UNITS),u=!1,r=0,g=J.getParameter(J.VERSION);if(g.indexOf("WebGL")!==-1)r=parseFloat(/^WebGL (\d)/.exec(g)[1]),u=r>=1;else if(g.indexOf("OpenGL ES")!==-1)r=parseFloat(/^OpenGL ES (\d)/.exec(g)[1]),u=r>=2;let ZJ=null,UJ={},TJ=J.getParameter(J.SCISSOR_BOX),mJ=J.getParameter(J.VIEWPORT),Y0=new sJ().fromArray(TJ),d=new sJ().fromArray(mJ);function WJ(P,HJ,QJ,NJ){let a=new Uint8Array(4),s=J.createTexture();J.bindTexture(P,s),J.texParameteri(P,J.TEXTURE_MIN_FILTER,J.NEAREST),J.texParameteri(P,J.TEXTURE_MAG_FILTER,J.NEAREST);for(let FJ=0;FJ<QJ;FJ++)if(P===J.TEXTURE_3D||P===J.TEXTURE_2D_ARRAY)J.texImage3D(HJ,0,J.RGBA,1,1,NJ,0,J.RGBA,J.UNSIGNED_BYTE,a);else J.texImage2D(HJ+FJ,0,J.RGBA,1,1,0,J.RGBA,J.UNSIGNED_BYTE,a);return s}let MJ={};MJ[J.TEXTURE_2D]=WJ(J.TEXTURE_2D,J.TEXTURE_2D,1),MJ[J.TEXTURE_CUBE_MAP]=WJ(J.TEXTURE_CUBE_MAP,J.TEXTURE_CUBE_MAP_POSITIVE_X,6),MJ[J.TEXTURE_2D_ARRAY]=WJ(J.TEXTURE_2D_ARRAY,J.TEXTURE_2D_ARRAY,1,1),MJ[J.TEXTURE_3D]=WJ(J.TEXTURE_3D,J.TEXTURE_3D,1,1),H.setClear(0,0,0,1),Y.setClear(1),X.setClear(0),GJ(J.DEPTH_TEST),Y.setFunc(N6),zJ(!1),X0(fQ),GJ(J.CULL_FACE),CJ(m8);function GJ(P){if(G[P]!==!0)J.enable(P),G[P]=!0}function RJ(P){if(G[P]!==!1)J.disable(P),G[P]=!1}function uJ(P,HJ){if(q[P]!==HJ){if(J.bindFramebuffer(P,HJ),q[P]=HJ,P===J.DRAW_FRAMEBUFFER)q[J.FRAMEBUFFER]=HJ;if(P===J.FRAMEBUFFER)q[J.DRAW_FRAMEBUFFER]=HJ;return!0}return!1}function cJ(P,HJ){let QJ=O,NJ=!1;if(P){if(QJ=E.get(HJ),QJ===void 0)QJ=[],E.set(HJ,QJ);let a=P.textures;if(QJ.length!==a.length||QJ[0]!==J.COLOR_ATTACHMENT0){for(let s=0,FJ=a.length;s<FJ;s++)QJ[s]=J.COLOR_ATTACHMENT0+s;QJ.length=a.length,NJ=!0}}else if(QJ[0]!==J.BACK)QJ[0]=J.BACK,NJ=!0;if(NJ)J.drawBuffers(QJ)}function dJ(P){if(k!==P)return J.useProgram(P),k=P,!0;return!1}let I={[f9]:J.FUNC_ADD,[HW]:J.FUNC_SUBTRACT,[YW]:J.FUNC_REVERSE_SUBTRACT};I[XW]=J.MIN,I[KW]=J.MAX;let $0={[UW]:J.ZERO,[GW]:J.ONE,[qW]:J.SRC_COLOR,[NW]:J.SRC_ALPHA,[DW]:J.SRC_ALPHA_SATURATE,[kW]:J.DST_COLOR,[FW]:J.DST_ALPHA,[EW]:J.ONE_MINUS_SRC_COLOR,[OW]:J.ONE_MINUS_SRC_ALPHA,[MW]:J.ONE_MINUS_DST_COLOR,[RW]:J.ONE_MINUS_DST_ALPHA,[LW]:J.CONSTANT_COLOR,[VW]:J.ONE_MINUS_CONSTANT_COLOR,[zW]:J.CONSTANT_ALPHA,[BW]:J.ONE_MINUS_CONSTANT_ALPHA};function CJ(P,HJ,QJ,NJ,a,s,FJ,yJ,J0,rJ){if(P===m8){if(M===!0)RJ(J.BLEND),M=!1;return}if(M===!1)GJ(J.BLEND),M=!0;if(P!==WW){if(P!==N||rJ!==z){if(F!==f9||_!==f9)J.blendEquation(J.FUNC_ADD),F=f9,_=f9;if(rJ)switch(P){case E6:J.blendFuncSeparate(J.ONE,J.ONE_MINUS_SRC_ALPHA,J.ONE,J.ONE_MINUS_SRC_ALPHA);break;case bQ:J.blendFunc(J.ONE,J.ONE);break;case xQ:J.blendFuncSeparate(J.ZERO,J.ONE_MINUS_SRC_COLOR,J.ZERO,J.ONE);break;case gQ:J.blendFuncSeparate(J.DST_COLOR,J.ONE_MINUS_SRC_ALPHA,J.ZERO,J.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",P);break}else switch(P){case E6:J.blendFuncSeparate(J.SRC_ALPHA,J.ONE_MINUS_SRC_ALPHA,J.ONE,J.ONE_MINUS_SRC_ALPHA);break;case bQ:J.blendFuncSeparate(J.SRC_ALPHA,J.ONE,J.ONE,J.ONE);break;case xQ:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gQ:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",P);break}C=null,L=null,v=null,w=null,T.set(0,0,0),x=0,N=P,z=rJ}return}if(a=a||HJ,s=s||QJ,FJ=FJ||NJ,HJ!==F||a!==_)J.blendEquationSeparate(I[HJ],I[a]),F=HJ,_=a;if(QJ!==C||NJ!==L||s!==v||FJ!==w)J.blendFuncSeparate($0[QJ],$0[NJ],$0[s],$0[FJ]),C=QJ,L=NJ,v=s,w=FJ;if(yJ.equals(T)===!1||J0!==x)J.blendColor(yJ.r,yJ.g,yJ.b,J0),T.copy(yJ),x=J0;N=P,z=!1}function iJ(P,HJ){P.side===j0?RJ(J.CULL_FACE):GJ(J.CULL_FACE);let QJ=P.side===g0;if(HJ)QJ=!QJ;zJ(QJ),P.blending===E6&&P.transparent===!1?CJ(m8):CJ(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),Y.setFunc(P.depthFunc),Y.setTest(P.depthTest),Y.setMask(P.depthWrite),H.setMask(P.colorWrite);let NJ=P.stencilWrite;if(X.setTest(NJ),NJ)X.setMask(P.stencilWriteMask),X.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),X.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass);wJ(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?GJ(J.SAMPLE_ALPHA_TO_COVERAGE):RJ(J.SAMPLE_ALPHA_TO_COVERAGE)}function zJ(P){if(V!==P){if(P)J.frontFace(J.CW);else J.frontFace(J.CCW);V=P}}function X0(P){if(P!==QW){if(GJ(J.CULL_FACE),P!==j)if(P===fQ)J.cullFace(J.BACK);else if(P===$W)J.cullFace(J.FRONT);else J.cullFace(J.FRONT_AND_BACK)}else RJ(J.CULL_FACE);j=P}function DJ(P){if(P!==m){if(u)J.lineWidth(P);m=P}}function wJ(P,HJ,QJ){if(P){if(GJ(J.POLYGON_OFFSET_FILL),l!==HJ||c!==QJ)J.polygonOffset(HJ,QJ),l=HJ,c=QJ}else RJ(J.POLYGON_OFFSET_FILL)}function V0(P){if(P)GJ(J.SCISSOR_TEST);else RJ(J.SCISSOR_TEST)}function D0(P){if(P===void 0)P=J.TEXTURE0+i-1;if(ZJ!==P)J.activeTexture(P),ZJ=P}function N0(P,HJ,QJ){if(QJ===void 0)if(ZJ===null)QJ=J.TEXTURE0+i-1;else QJ=ZJ;let NJ=UJ[QJ];if(NJ===void 0)NJ={type:void 0,texture:void 0},UJ[QJ]=NJ;if(NJ.type!==P||NJ.texture!==HJ){if(ZJ!==QJ)J.activeTexture(QJ),ZJ=QJ;J.bindTexture(P,HJ||MJ[P]),NJ.type=P,NJ.texture=HJ}}function B(){let P=UJ[ZJ];if(P!==void 0&&P.type!==void 0)J.bindTexture(P.type,null),P.type=void 0,P.texture=void 0}function R(){try{J.compressedTexImage2D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function f(){try{J.compressedTexImage3D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function n(){try{J.texSubImage2D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function o(){try{J.texSubImage3D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function p(){try{J.compressedTexSubImage2D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function EJ(){try{J.compressedTexSubImage3D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function JJ(){try{J.texStorage2D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function kJ(){try{J.texStorage3D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function AJ(){try{J.texImage2D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function e(){try{J.texImage3D(...arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function XJ(P){if(Y0.equals(P)===!1)J.scissor(P.x,P.y,P.z,P.w),Y0.copy(P)}function LJ(P){if(d.equals(P)===!1)J.viewport(P.x,P.y,P.z,P.w),d.copy(P)}function VJ(P,HJ){let QJ=U.get(HJ);if(QJ===void 0)QJ=new WeakMap,U.set(HJ,QJ);let NJ=QJ.get(P);if(NJ===void 0)NJ=J.getUniformBlockIndex(HJ,P.name),QJ.set(P,NJ)}function KJ(P,HJ){let NJ=U.get(HJ).get(P);if(K.get(HJ)!==NJ)J.uniformBlockBinding(HJ,NJ,P.__bindingPointIndex),K.set(HJ,NJ)}function bJ(){J.disable(J.BLEND),J.disable(J.CULL_FACE),J.disable(J.DEPTH_TEST),J.disable(J.POLYGON_OFFSET_FILL),J.disable(J.SCISSOR_TEST),J.disable(J.STENCIL_TEST),J.disable(J.SAMPLE_ALPHA_TO_COVERAGE),J.blendEquation(J.FUNC_ADD),J.blendFunc(J.ONE,J.ZERO),J.blendFuncSeparate(J.ONE,J.ZERO,J.ONE,J.ZERO),J.blendColor(0,0,0,0),J.colorMask(!0,!0,!0,!0),J.clearColor(0,0,0,0),J.depthMask(!0),J.depthFunc(J.LESS),Y.setReversed(!1),J.clearDepth(1),J.stencilMask(4294967295),J.stencilFunc(J.ALWAYS,0,4294967295),J.stencilOp(J.KEEP,J.KEEP,J.KEEP),J.clearStencil(0),J.cullFace(J.BACK),J.frontFace(J.CCW),J.polygonOffset(0,0),J.activeTexture(J.TEXTURE0),J.bindFramebuffer(J.FRAMEBUFFER,null),J.bindFramebuffer(J.DRAW_FRAMEBUFFER,null),J.bindFramebuffer(J.READ_FRAMEBUFFER,null),J.useProgram(null),J.lineWidth(1),J.scissor(0,0,J.canvas.width,J.canvas.height),J.viewport(0,0,J.canvas.width,J.canvas.height),G={},ZJ=null,UJ={},q={},E=new WeakMap,O=[],k=null,M=!1,N=null,F=null,C=null,L=null,_=null,v=null,w=null,T=new jJ(0,0,0),x=0,z=!1,V=null,j=null,m=null,l=null,c=null,Y0.set(0,0,J.canvas.width,J.canvas.height),d.set(0,0,J.canvas.width,J.canvas.height),H.reset(),Y.reset(),X.reset()}return{buffers:{color:H,depth:Y,stencil:X},enable:GJ,disable:RJ,bindFramebuffer:uJ,drawBuffers:cJ,useProgram:dJ,setBlending:CJ,setMaterial:iJ,setFlipSided:zJ,setCullFace:X0,setLineWidth:DJ,setPolygonOffset:wJ,setScissorTest:V0,activeTexture:D0,bindTexture:N0,unbindTexture:B,compressedTexImage2D:R,compressedTexImage3D:f,texImage2D:AJ,texImage3D:e,updateUBOMapping:VJ,uniformBlockBinding:KJ,texStorage2D:JJ,texStorage3D:kJ,texSubImage2D:n,texSubImage3D:o,compressedTexSubImage2D:p,compressedTexSubImage3D:EJ,scissor:XJ,viewport:LJ,reset:bJ}}function oq(J,Q,$,Z,W,H,Y){let X=Q.has("WEBGL_multisampled_render_to_texture")?Q.get("WEBGL_multisampled_render_to_texture"):null,K=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),U=new PJ,G=new WeakMap,q,E=new WeakMap,O=!1;try{O=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(B){}function k(B,R){return O?new OffscreenCanvas(B,R):v9("canvas")}function M(B,R,f){let n=1,o=N0(B);if(o.width>f||o.height>f)n=f/Math.max(o.width,o.height);if(n<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){let p=Math.floor(n*o.width),EJ=Math.floor(n*o.height);if(q===void 0)q=k(p,EJ);let JJ=R?k(p,EJ):q;return JJ.width=p,JJ.height=EJ,JJ.getContext("2d").drawImage(B,0,0,p,EJ),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+o.width+"x"+o.height+") to ("+p+"x"+EJ+")."),JJ}else{if("data"in B)console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+o.width+"x"+o.height+").");return B}return B}function N(B){return B.generateMipmaps}function F(B){J.generateMipmap(B)}function C(B){if(B.isWebGLCubeRenderTarget)return J.TEXTURE_CUBE_MAP;if(B.isWebGL3DRenderTarget)return J.TEXTURE_3D;if(B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture)return J.TEXTURE_2D_ARRAY;return J.TEXTURE_2D}function L(B,R,f,n,o=!1){if(B!==null){if(J[B]!==void 0)return J[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let p=R;if(R===J.RED){if(f===J.FLOAT)p=J.R32F;if(f===J.HALF_FLOAT)p=J.R16F;if(f===J.UNSIGNED_BYTE)p=J.R8}if(R===J.RED_INTEGER){if(f===J.UNSIGNED_BYTE)p=J.R8UI;if(f===J.UNSIGNED_SHORT)p=J.R16UI;if(f===J.UNSIGNED_INT)p=J.R32UI;if(f===J.BYTE)p=J.R8I;if(f===J.SHORT)p=J.R16I;if(f===J.INT)p=J.R32I}if(R===J.RG){if(f===J.FLOAT)p=J.RG32F;if(f===J.HALF_FLOAT)p=J.RG16F;if(f===J.UNSIGNED_BYTE)p=J.RG8}if(R===J.RG_INTEGER){if(f===J.UNSIGNED_BYTE)p=J.RG8UI;if(f===J.UNSIGNED_SHORT)p=J.RG16UI;if(f===J.UNSIGNED_INT)p=J.RG32UI;if(f===J.BYTE)p=J.RG8I;if(f===J.SHORT)p=J.RG16I;if(f===J.INT)p=J.RG32I}if(R===J.RGB_INTEGER){if(f===J.UNSIGNED_BYTE)p=J.RGB8UI;if(f===J.UNSIGNED_SHORT)p=J.RGB16UI;if(f===J.UNSIGNED_INT)p=J.RGB32UI;if(f===J.BYTE)p=J.RGB8I;if(f===J.SHORT)p=J.RGB16I;if(f===J.INT)p=J.RGB32I}if(R===J.RGBA_INTEGER){if(f===J.UNSIGNED_BYTE)p=J.RGBA8UI;if(f===J.UNSIGNED_SHORT)p=J.RGBA16UI;if(f===J.UNSIGNED_INT)p=J.RGBA32UI;if(f===J.BYTE)p=J.RGBA8I;if(f===J.SHORT)p=J.RGBA16I;if(f===J.INT)p=J.RGBA32I}if(R===J.RGB){if(f===J.UNSIGNED_INT_5_9_9_9_REV)p=J.RGB9_E5}if(R===J.RGBA){let EJ=o?L$:lJ.getTransfer(n);if(f===J.FLOAT)p=J.RGBA32F;if(f===J.HALF_FLOAT)p=J.RGBA16F;if(f===J.UNSIGNED_BYTE)p=EJ===W0?J.SRGB8_ALPHA8:J.RGBA8;if(f===J.UNSIGNED_SHORT_4_4_4_4)p=J.RGBA4;if(f===J.UNSIGNED_SHORT_5_5_5_1)p=J.RGB5_A1}if(p===J.R16F||p===J.R32F||p===J.RG16F||p===J.RG32F||p===J.RGBA16F||p===J.RGBA32F)Q.get("EXT_color_buffer_float");return p}function _(B,R){let f;if(B){if(R===null||R===g9||R===p9)f=J.DEPTH24_STENCIL8;else if(R===c8)f=J.DEPTH32F_STENCIL8;else if(R===F6)f=J.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(R===null||R===g9||R===p9)f=J.DEPTH_COMPONENT24;else if(R===c8)f=J.DEPTH_COMPONENT32F;else if(R===F6)f=J.DEPTH_COMPONENT16;return f}function v(B,R){if(N(B)===!0||B.isFramebufferTexture&&B.minFilter!==w8&&B.minFilter!==W8)return Math.log2(Math.max(R.width,R.height))+1;else if(B.mipmaps!==void 0&&B.mipmaps.length>0)return B.mipmaps.length;else if(B.isCompressedTexture&&Array.isArray(B.image))return R.mipmaps.length;else return 1}function w(B){let R=B.target;if(R.removeEventListener("dispose",w),x(R),R.isVideoTexture)G.delete(R)}function T(B){let R=B.target;R.removeEventListener("dispose",T),V(R)}function x(B){let R=Z.get(B);if(R.__webglInit===void 0)return;let f=B.source,n=E.get(f);if(n){let o=n[R.__cacheKey];if(o.usedTimes--,o.usedTimes===0)z(B);if(Object.keys(n).length===0)E.delete(f)}Z.remove(B)}function z(B){let R=Z.get(B);J.deleteTexture(R.__webglTexture);let f=B.source,n=E.get(f);delete n[R.__cacheKey],Y.memory.textures--}function V(B){let R=Z.get(B);if(B.depthTexture)B.depthTexture.dispose(),Z.remove(B.depthTexture);if(B.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(R.__webglFramebuffer[n]))for(let o=0;o<R.__webglFramebuffer[n].length;o++)J.deleteFramebuffer(R.__webglFramebuffer[n][o]);else J.deleteFramebuffer(R.__webglFramebuffer[n]);if(R.__webglDepthbuffer)J.deleteRenderbuffer(R.__webglDepthbuffer[n])}else{if(Array.isArray(R.__webglFramebuffer))for(let n=0;n<R.__webglFramebuffer.length;n++)J.deleteFramebuffer(R.__webglFramebuffer[n]);else J.deleteFramebuffer(R.__webglFramebuffer);if(R.__webglDepthbuffer)J.deleteRenderbuffer(R.__webglDepthbuffer);if(R.__webglMultisampledFramebuffer)J.deleteFramebuffer(R.__webglMultisampledFramebuffer);if(R.__webglColorRenderbuffer){for(let n=0;n<R.__webglColorRenderbuffer.length;n++)if(R.__webglColorRenderbuffer[n])J.deleteRenderbuffer(R.__webglColorRenderbuffer[n])}if(R.__webglDepthRenderbuffer)J.deleteRenderbuffer(R.__webglDepthRenderbuffer)}let f=B.textures;for(let n=0,o=f.length;n<o;n++){let p=Z.get(f[n]);if(p.__webglTexture)J.deleteTexture(p.__webglTexture),Y.memory.textures--;Z.remove(f[n])}Z.remove(B)}let j=0;function m(){j=0}function l(){let B=j;if(B>=W.maxTextures)console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+W.maxTextures);return j+=1,B}function c(B){let R=[];return R.push(B.wrapS),R.push(B.wrapT),R.push(B.wrapR||0),R.push(B.magFilter),R.push(B.minFilter),R.push(B.anisotropy),R.push(B.internalFormat),R.push(B.format),R.push(B.type),R.push(B.generateMipmaps),R.push(B.premultiplyAlpha),R.push(B.flipY),R.push(B.unpackAlignment),R.push(B.colorSpace),R.join()}function i(B,R){let f=Z.get(B);if(B.isVideoTexture)V0(B);if(B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&f.__version!==B.version){let n=B.image;if(n===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(n.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{MJ(f,B,R);return}}else if(B.isExternalTexture)f.__webglTexture=B.sourceTexture?B.sourceTexture:null;$.bindTexture(J.TEXTURE_2D,f.__webglTexture,J.TEXTURE0+R)}function u(B,R){let f=Z.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&f.__version!==B.version){MJ(f,B,R);return}$.bindTexture(J.TEXTURE_2D_ARRAY,f.__webglTexture,J.TEXTURE0+R)}function r(B,R){let f=Z.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&f.__version!==B.version){MJ(f,B,R);return}$.bindTexture(J.TEXTURE_3D,f.__webglTexture,J.TEXTURE0+R)}function g(B,R){let f=Z.get(B);if(B.version>0&&f.__version!==B.version){GJ(f,B,R);return}$.bindTexture(J.TEXTURE_CUBE_MAP,f.__webglTexture,J.TEXTURE0+R)}let ZJ={[b9]:J.REPEAT,[M7]:J.CLAMP_TO_EDGE,[D7]:J.MIRRORED_REPEAT},UJ={[w8]:J.NEAREST,[L7]:J.NEAREST_MIPMAP_NEAREST,[K9]:J.NEAREST_MIPMAP_LINEAR,[W8]:J.LINEAR,[x9]:J.LINEAR_MIPMAP_NEAREST,[I8]:J.LINEAR_MIPMAP_LINEAR},TJ={[uW]:J.NEVER,[aW]:J.ALWAYS,[cW]:J.LESS,[V$]:J.LEQUAL,[nW]:J.EQUAL,[iW]:J.GEQUAL,[sW]:J.GREATER,[oW]:J.NOTEQUAL};function mJ(B,R){if(R.type===c8&&Q.has("OES_texture_float_linear")===!1&&(R.magFilter===W8||R.magFilter===x9||R.magFilter===K9||R.magFilter===I8||R.minFilter===W8||R.minFilter===x9||R.minFilter===K9||R.minFilter===I8))console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(J.texParameteri(B,J.TEXTURE_WRAP_S,ZJ[R.wrapS]),J.texParameteri(B,J.TEXTURE_WRAP_T,ZJ[R.wrapT]),B===J.TEXTURE_3D||B===J.TEXTURE_2D_ARRAY)J.texParameteri(B,J.TEXTURE_WRAP_R,ZJ[R.wrapR]);if(J.texParameteri(B,J.TEXTURE_MAG_FILTER,UJ[R.magFilter]),J.texParameteri(B,J.TEXTURE_MIN_FILTER,UJ[R.minFilter]),R.compareFunction)J.texParameteri(B,J.TEXTURE_COMPARE_MODE,J.COMPARE_REF_TO_TEXTURE),J.texParameteri(B,J.TEXTURE_COMPARE_FUNC,TJ[R.compareFunction]);if(Q.has("EXT_texture_filter_anisotropic")===!0){if(R.magFilter===w8)return;if(R.minFilter!==K9&&R.minFilter!==I8)return;if(R.type===c8&&Q.has("OES_texture_float_linear")===!1)return;if(R.anisotropy>1||Z.get(R).__currentAnisotropy){let f=Q.get("EXT_texture_filter_anisotropic");J.texParameterf(B,f.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(R.anisotropy,W.getMaxAnisotropy())),Z.get(R).__currentAnisotropy=R.anisotropy}}}function Y0(B,R){let f=!1;if(B.__webglInit===void 0)B.__webglInit=!0,R.addEventListener("dispose",w);let n=R.source,o=E.get(n);if(o===void 0)o={},E.set(n,o);let p=c(R);if(p!==B.__cacheKey){if(o[p]===void 0)o[p]={texture:J.createTexture(),usedTimes:0},Y.memory.textures++,f=!0;o[p].usedTimes++;let EJ=o[B.__cacheKey];if(EJ!==void 0){if(o[B.__cacheKey].usedTimes--,EJ.usedTimes===0)z(R)}B.__cacheKey=p,B.__webglTexture=o[p].texture}return f}function d(B,R,f){return Math.floor(Math.floor(B/f)/R)}function WJ(B,R,f,n){let p=B.updateRanges;if(p.length===0)$.texSubImage2D(J.TEXTURE_2D,0,0,0,R.width,R.height,f,n,R.data);else{p.sort((e,XJ)=>e.start-XJ.start);let EJ=0;for(let e=1;e<p.length;e++){let XJ=p[EJ],LJ=p[e],VJ=XJ.start+XJ.count,KJ=d(LJ.start,R.width,4),bJ=d(XJ.start,R.width,4);if(LJ.start<=VJ+1&&KJ===bJ&&d(LJ.start+LJ.count-1,R.width,4)===KJ)XJ.count=Math.max(XJ.count,LJ.start+LJ.count-XJ.start);else++EJ,p[EJ]=LJ}p.length=EJ+1;let JJ=J.getParameter(J.UNPACK_ROW_LENGTH),kJ=J.getParameter(J.UNPACK_SKIP_PIXELS),AJ=J.getParameter(J.UNPACK_SKIP_ROWS);J.pixelStorei(J.UNPACK_ROW_LENGTH,R.width);for(let e=0,XJ=p.length;e<XJ;e++){let LJ=p[e],VJ=Math.floor(LJ.start/4),KJ=Math.ceil(LJ.count/4),bJ=VJ%R.width,P=Math.floor(VJ/R.width),HJ=KJ,QJ=1;J.pixelStorei(J.UNPACK_SKIP_PIXELS,bJ),J.pixelStorei(J.UNPACK_SKIP_ROWS,P),$.texSubImage2D(J.TEXTURE_2D,0,bJ,P,HJ,1,f,n,R.data)}B.clearUpdateRanges(),J.pixelStorei(J.UNPACK_ROW_LENGTH,JJ),J.pixelStorei(J.UNPACK_SKIP_PIXELS,kJ),J.pixelStorei(J.UNPACK_SKIP_ROWS,AJ)}}function MJ(B,R,f){let n=J.TEXTURE_2D;if(R.isDataArrayTexture||R.isCompressedArrayTexture)n=J.TEXTURE_2D_ARRAY;if(R.isData3DTexture)n=J.TEXTURE_3D;let o=Y0(B,R),p=R.source;$.bindTexture(n,B.__webglTexture,J.TEXTURE0+f);let EJ=Z.get(p);if(p.version!==EJ.__version||o===!0){$.activeTexture(J.TEXTURE0+f);let JJ=lJ.getPrimaries(lJ.workingColorSpace),kJ=R.colorSpace===U9?null:lJ.getPrimaries(R.colorSpace),AJ=R.colorSpace===U9||JJ===kJ?J.NONE:J.BROWSER_DEFAULT_WEBGL;J.pixelStorei(J.UNPACK_FLIP_Y_WEBGL,R.flipY),J.pixelStorei(J.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),J.pixelStorei(J.UNPACK_ALIGNMENT,R.unpackAlignment),J.pixelStorei(J.UNPACK_COLORSPACE_CONVERSION_WEBGL,AJ);let e=M(R.image,!1,W.maxTextureSize);e=D0(R,e);let XJ=H.convert(R.format,R.colorSpace),LJ=H.convert(R.type),VJ=L(R.internalFormat,XJ,LJ,R.colorSpace,R.isVideoTexture);mJ(n,R);let KJ,bJ=R.mipmaps,P=R.isVideoTexture!==!0,HJ=EJ.__version===void 0||o===!0,QJ=p.dataReady,NJ=v(R,e);if(R.isDepthTexture){if(VJ=_(R.format===k6,R.type),HJ)if(P)$.texStorage2D(J.TEXTURE_2D,1,VJ,e.width,e.height);else $.texImage2D(J.TEXTURE_2D,0,VJ,e.width,e.height,0,XJ,LJ,null)}else if(R.isDataTexture)if(bJ.length>0){if(P&&HJ)$.texStorage2D(J.TEXTURE_2D,NJ,VJ,bJ[0].width,bJ[0].height);for(let a=0,s=bJ.length;a<s;a++)if(KJ=bJ[a],P){if(QJ)$.texSubImage2D(J.TEXTURE_2D,a,0,0,KJ.width,KJ.height,XJ,LJ,KJ.data)}else $.texImage2D(J.TEXTURE_2D,a,VJ,KJ.width,KJ.height,0,XJ,LJ,KJ.data);R.generateMipmaps=!1}else if(P){if(HJ)$.texStorage2D(J.TEXTURE_2D,NJ,VJ,e.width,e.height);if(QJ)WJ(R,e,XJ,LJ)}else $.texImage2D(J.TEXTURE_2D,0,VJ,e.width,e.height,0,XJ,LJ,e.data);else if(R.isCompressedTexture)if(R.isCompressedArrayTexture){if(P&&HJ)$.texStorage3D(J.TEXTURE_2D_ARRAY,NJ,VJ,bJ[0].width,bJ[0].height,e.depth);for(let a=0,s=bJ.length;a<s;a++)if(KJ=bJ[a],R.format!==G8)if(XJ!==null)if(P){if(QJ)if(R.layerUpdates.size>0){let FJ=m$(KJ.width,KJ.height,R.format,R.type);for(let yJ of R.layerUpdates){let J0=KJ.data.subarray(yJ*FJ/KJ.data.BYTES_PER_ELEMENT,(yJ+1)*FJ/KJ.data.BYTES_PER_ELEMENT);$.compressedTexSubImage3D(J.TEXTURE_2D_ARRAY,a,0,0,yJ,KJ.width,KJ.height,1,XJ,J0)}R.clearLayerUpdates()}else $.compressedTexSubImage3D(J.TEXTURE_2D_ARRAY,a,0,0,0,KJ.width,KJ.height,e.depth,XJ,KJ.data)}else $.compressedTexImage3D(J.TEXTURE_2D_ARRAY,a,VJ,KJ.width,KJ.height,e.depth,0,KJ.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(P){if(QJ)$.texSubImage3D(J.TEXTURE_2D_ARRAY,a,0,0,0,KJ.width,KJ.height,e.depth,XJ,LJ,KJ.data)}else $.texImage3D(J.TEXTURE_2D_ARRAY,a,VJ,KJ.width,KJ.height,e.depth,0,XJ,LJ,KJ.data)}else{if(P&&HJ)$.texStorage2D(J.TEXTURE_2D,NJ,VJ,bJ[0].width,bJ[0].height);for(let a=0,s=bJ.length;a<s;a++)if(KJ=bJ[a],R.format!==G8)if(XJ!==null)if(P){if(QJ)$.compressedTexSubImage2D(J.TEXTURE_2D,a,0,0,KJ.width,KJ.height,XJ,KJ.data)}else $.compressedTexImage2D(J.TEXTURE_2D,a,VJ,KJ.width,KJ.height,0,KJ.data);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(P){if(QJ)$.texSubImage2D(J.TEXTURE_2D,a,0,0,KJ.width,KJ.height,XJ,LJ,KJ.data)}else $.texImage2D(J.TEXTURE_2D,a,VJ,KJ.width,KJ.height,0,XJ,LJ,KJ.data)}else if(R.isDataArrayTexture)if(P){if(HJ)$.texStorage3D(J.TEXTURE_2D_ARRAY,NJ,VJ,e.width,e.height,e.depth);if(QJ)if(R.layerUpdates.size>0){let a=m$(e.width,e.height,R.format,R.type);for(let s of R.layerUpdates){let FJ=e.data.subarray(s*a/e.data.BYTES_PER_ELEMENT,(s+1)*a/e.data.BYTES_PER_ELEMENT);$.texSubImage3D(J.TEXTURE_2D_ARRAY,0,0,0,s,e.width,e.height,1,XJ,LJ,FJ)}R.clearLayerUpdates()}else $.texSubImage3D(J.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,XJ,LJ,e.data)}else $.texImage3D(J.TEXTURE_2D_ARRAY,0,VJ,e.width,e.height,e.depth,0,XJ,LJ,e.data);else if(R.isData3DTexture)if(P){if(HJ)$.texStorage3D(J.TEXTURE_3D,NJ,VJ,e.width,e.height,e.depth);if(QJ)$.texSubImage3D(J.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,XJ,LJ,e.data)}else $.texImage3D(J.TEXTURE_3D,0,VJ,e.width,e.height,e.depth,0,XJ,LJ,e.data);else if(R.isFramebufferTexture){if(HJ)if(P)$.texStorage2D(J.TEXTURE_2D,NJ,VJ,e.width,e.height);else{let{width:a,height:s}=e;for(let FJ=0;FJ<NJ;FJ++)$.texImage2D(J.TEXTURE_2D,FJ,VJ,a,s,0,XJ,LJ,null),a>>=1,s>>=1}}else if(bJ.length>0){if(P&&HJ){let a=N0(bJ[0]);$.texStorage2D(J.TEXTURE_2D,NJ,VJ,a.width,a.height)}for(let a=0,s=bJ.length;a<s;a++)if(KJ=bJ[a],P){if(QJ)$.texSubImage2D(J.TEXTURE_2D,a,0,0,XJ,LJ,KJ)}else $.texImage2D(J.TEXTURE_2D,a,VJ,XJ,LJ,KJ);R.generateMipmaps=!1}else if(P){if(HJ){let a=N0(e);$.texStorage2D(J.TEXTURE_2D,NJ,VJ,a.width,a.height)}if(QJ)$.texSubImage2D(J.TEXTURE_2D,0,0,0,XJ,LJ,e)}else $.texImage2D(J.TEXTURE_2D,0,VJ,XJ,LJ,e);if(N(R))F(n);if(EJ.__version=p.version,R.onUpdate)R.onUpdate(R)}B.__version=R.version}function GJ(B,R,f){if(R.image.length!==6)return;let n=Y0(B,R),o=R.source;$.bindTexture(J.TEXTURE_CUBE_MAP,B.__webglTexture,J.TEXTURE0+f);let p=Z.get(o);if(o.version!==p.__version||n===!0){$.activeTexture(J.TEXTURE0+f);let EJ=lJ.getPrimaries(lJ.workingColorSpace),JJ=R.colorSpace===U9?null:lJ.getPrimaries(R.colorSpace),kJ=R.colorSpace===U9||EJ===JJ?J.NONE:J.BROWSER_DEFAULT_WEBGL;J.pixelStorei(J.UNPACK_FLIP_Y_WEBGL,R.flipY),J.pixelStorei(J.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),J.pixelStorei(J.UNPACK_ALIGNMENT,R.unpackAlignment),J.pixelStorei(J.UNPACK_COLORSPACE_CONVERSION_WEBGL,kJ);let AJ=R.isCompressedTexture||R.image[0].isCompressedTexture,e=R.image[0]&&R.image[0].isDataTexture,XJ=[];for(let s=0;s<6;s++){if(!AJ&&!e)XJ[s]=M(R.image[s],!0,W.maxCubemapSize);else XJ[s]=e?R.image[s].image:R.image[s];XJ[s]=D0(R,XJ[s])}let LJ=XJ[0],VJ=H.convert(R.format,R.colorSpace),KJ=H.convert(R.type),bJ=L(R.internalFormat,VJ,KJ,R.colorSpace),P=R.isVideoTexture!==!0,HJ=p.__version===void 0||n===!0,QJ=o.dataReady,NJ=v(R,LJ);mJ(J.TEXTURE_CUBE_MAP,R);let a;if(AJ){if(P&&HJ)$.texStorage2D(J.TEXTURE_CUBE_MAP,NJ,bJ,LJ.width,LJ.height);for(let s=0;s<6;s++){a=XJ[s].mipmaps;for(let FJ=0;FJ<a.length;FJ++){let yJ=a[FJ];if(R.format!==G8)if(VJ!==null)if(P){if(QJ)$.compressedTexSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ,0,0,yJ.width,yJ.height,VJ,yJ.data)}else $.compressedTexImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ,bJ,yJ.width,yJ.height,0,yJ.data);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(P){if(QJ)$.texSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ,0,0,yJ.width,yJ.height,VJ,KJ,yJ.data)}else $.texImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ,bJ,yJ.width,yJ.height,0,VJ,KJ,yJ.data)}}}else{if(a=R.mipmaps,P&&HJ){if(a.length>0)NJ++;let s=N0(XJ[0]);$.texStorage2D(J.TEXTURE_CUBE_MAP,NJ,bJ,s.width,s.height)}for(let s=0;s<6;s++)if(e){if(P){if(QJ)$.texSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,0,0,XJ[s].width,XJ[s].height,VJ,KJ,XJ[s].data)}else $.texImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,bJ,XJ[s].width,XJ[s].height,0,VJ,KJ,XJ[s].data);for(let FJ=0;FJ<a.length;FJ++){let J0=a[FJ].image[s].image;if(P){if(QJ)$.texSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ+1,0,0,J0.width,J0.height,VJ,KJ,J0.data)}else $.texImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ+1,bJ,J0.width,J0.height,0,VJ,KJ,J0.data)}}else{if(P){if(QJ)$.texSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,0,0,VJ,KJ,XJ[s])}else $.texImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,bJ,VJ,KJ,XJ[s]);for(let FJ=0;FJ<a.length;FJ++){let yJ=a[FJ];if(P){if(QJ)$.texSubImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ+1,0,0,VJ,KJ,yJ.image[s])}else $.texImage2D(J.TEXTURE_CUBE_MAP_POSITIVE_X+s,FJ+1,bJ,VJ,KJ,yJ.image[s])}}}if(N(R))F(J.TEXTURE_CUBE_MAP);if(p.__version=o.version,R.onUpdate)R.onUpdate(R)}B.__version=R.version}function RJ(B,R,f,n,o,p){let EJ=H.convert(f.format,f.colorSpace),JJ=H.convert(f.type),kJ=L(f.internalFormat,EJ,JJ,f.colorSpace),AJ=Z.get(R),e=Z.get(f);if(e.__renderTarget=R,!AJ.__hasExternalTextures){let XJ=Math.max(1,R.width>>p),LJ=Math.max(1,R.height>>p);if(o===J.TEXTURE_3D||o===J.TEXTURE_2D_ARRAY)$.texImage3D(o,p,kJ,XJ,LJ,R.depth,0,EJ,JJ,null);else $.texImage2D(o,p,kJ,XJ,LJ,0,EJ,JJ,null)}if($.bindFramebuffer(J.FRAMEBUFFER,B),wJ(R))X.framebufferTexture2DMultisampleEXT(J.FRAMEBUFFER,n,o,e.__webglTexture,0,DJ(R));else if(o===J.TEXTURE_2D||o>=J.TEXTURE_CUBE_MAP_POSITIVE_X&&o<=J.TEXTURE_CUBE_MAP_NEGATIVE_Z)J.framebufferTexture2D(J.FRAMEBUFFER,n,o,e.__webglTexture,p);$.bindFramebuffer(J.FRAMEBUFFER,null)}function uJ(B,R,f){if(J.bindRenderbuffer(J.RENDERBUFFER,B),R.depthBuffer){let n=R.depthTexture,o=n&&n.isDepthTexture?n.type:null,p=_(R.stencilBuffer,o),EJ=R.stencilBuffer?J.DEPTH_STENCIL_ATTACHMENT:J.DEPTH_ATTACHMENT,JJ=DJ(R);if(wJ(R))X.renderbufferStorageMultisampleEXT(J.RENDERBUFFER,JJ,p,R.width,R.height);else if(f)J.renderbufferStorageMultisample(J.RENDERBUFFER,JJ,p,R.width,R.height);else J.renderbufferStorage(J.RENDERBUFFER,p,R.width,R.height);J.framebufferRenderbuffer(J.FRAMEBUFFER,EJ,J.RENDERBUFFER,B)}else{let n=R.textures;for(let o=0;o<n.length;o++){let p=n[o],EJ=H.convert(p.format,p.colorSpace),JJ=H.convert(p.type),kJ=L(p.internalFormat,EJ,JJ,p.colorSpace),AJ=DJ(R);if(f&&wJ(R)===!1)J.renderbufferStorageMultisample(J.RENDERBUFFER,AJ,kJ,R.width,R.height);else if(wJ(R))X.renderbufferStorageMultisampleEXT(J.RENDERBUFFER,AJ,kJ,R.width,R.height);else J.renderbufferStorage(J.RENDERBUFFER,kJ,R.width,R.height)}}J.bindRenderbuffer(J.RENDERBUFFER,null)}function cJ(B,R){if(R&&R.isWebGLCubeRenderTarget)throw Error("Depth Texture with cube render targets is not supported");if($.bindFramebuffer(J.FRAMEBUFFER,B),!(R.depthTexture&&R.depthTexture.isDepthTexture))throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let n=Z.get(R.depthTexture);if(n.__renderTarget=R,!n.__webglTexture||R.depthTexture.image.width!==R.width||R.depthTexture.image.height!==R.height)R.depthTexture.image.width=R.width,R.depthTexture.image.height=R.height,R.depthTexture.needsUpdate=!0;i(R.depthTexture,0);let o=n.__webglTexture,p=DJ(R);if(R.depthTexture.format===V7)if(wJ(R))X.framebufferTexture2DMultisampleEXT(J.FRAMEBUFFER,J.DEPTH_ATTACHMENT,J.TEXTURE_2D,o,0,p);else J.framebufferTexture2D(J.FRAMEBUFFER,J.DEPTH_ATTACHMENT,J.TEXTURE_2D,o,0);else if(R.depthTexture.format===k6)if(wJ(R))X.framebufferTexture2DMultisampleEXT(J.FRAMEBUFFER,J.DEPTH_STENCIL_ATTACHMENT,J.TEXTURE_2D,o,0,p);else J.framebufferTexture2D(J.FRAMEBUFFER,J.DEPTH_STENCIL_ATTACHMENT,J.TEXTURE_2D,o,0);else throw Error("Unknown depthTexture format")}function dJ(B){let R=Z.get(B),f=B.isWebGLCubeRenderTarget===!0;if(R.__boundDepthTexture!==B.depthTexture){let n=B.depthTexture;if(R.__depthDisposeCallback)R.__depthDisposeCallback();if(n){let o=()=>{delete R.__boundDepthTexture,delete R.__depthDisposeCallback,n.removeEventListener("dispose",o)};n.addEventListener("dispose",o),R.__depthDisposeCallback=o}R.__boundDepthTexture=n}if(B.depthTexture&&!R.__autoAllocateDepthBuffer){if(f)throw Error("target.depthTexture not supported in Cube render targets");let n=B.texture.mipmaps;if(n&&n.length>0)cJ(R.__webglFramebuffer[0],B);else cJ(R.__webglFramebuffer,B)}else if(f){R.__webglDepthbuffer=[];for(let n=0;n<6;n++)if($.bindFramebuffer(J.FRAMEBUFFER,R.__webglFramebuffer[n]),R.__webglDepthbuffer[n]===void 0)R.__webglDepthbuffer[n]=J.createRenderbuffer(),uJ(R.__webglDepthbuffer[n],B,!1);else{let o=B.stencilBuffer?J.DEPTH_STENCIL_ATTACHMENT:J.DEPTH_ATTACHMENT,p=R.__webglDepthbuffer[n];J.bindRenderbuffer(J.RENDERBUFFER,p),J.framebufferRenderbuffer(J.FRAMEBUFFER,o,J.RENDERBUFFER,p)}}else{let n=B.texture.mipmaps;if(n&&n.length>0)$.bindFramebuffer(J.FRAMEBUFFER,R.__webglFramebuffer[0]);else $.bindFramebuffer(J.FRAMEBUFFER,R.__webglFramebuffer);if(R.__webglDepthbuffer===void 0)R.__webglDepthbuffer=J.createRenderbuffer(),uJ(R.__webglDepthbuffer,B,!1);else{let o=B.stencilBuffer?J.DEPTH_STENCIL_ATTACHMENT:J.DEPTH_ATTACHMENT,p=R.__webglDepthbuffer;J.bindRenderbuffer(J.RENDERBUFFER,p),J.framebufferRenderbuffer(J.FRAMEBUFFER,o,J.RENDERBUFFER,p)}}$.bindFramebuffer(J.FRAMEBUFFER,null)}function I(B,R,f){let n=Z.get(B);if(R!==void 0)RJ(n.__webglFramebuffer,B,B.texture,J.COLOR_ATTACHMENT0,J.TEXTURE_2D,0);if(f!==void 0)dJ(B)}function $0(B){let R=B.texture,f=Z.get(B),n=Z.get(R);B.addEventListener("dispose",T);let o=B.textures,p=B.isWebGLCubeRenderTarget===!0,EJ=o.length>1;if(!EJ){if(n.__webglTexture===void 0)n.__webglTexture=J.createTexture();n.__version=R.version,Y.memory.textures++}if(p){f.__webglFramebuffer=[];for(let JJ=0;JJ<6;JJ++)if(R.mipmaps&&R.mipmaps.length>0){f.__webglFramebuffer[JJ]=[];for(let kJ=0;kJ<R.mipmaps.length;kJ++)f.__webglFramebuffer[JJ][kJ]=J.createFramebuffer()}else f.__webglFramebuffer[JJ]=J.createFramebuffer()}else{if(R.mipmaps&&R.mipmaps.length>0){f.__webglFramebuffer=[];for(let JJ=0;JJ<R.mipmaps.length;JJ++)f.__webglFramebuffer[JJ]=J.createFramebuffer()}else f.__webglFramebuffer=J.createFramebuffer();if(EJ)for(let JJ=0,kJ=o.length;JJ<kJ;JJ++){let AJ=Z.get(o[JJ]);if(AJ.__webglTexture===void 0)AJ.__webglTexture=J.createTexture(),Y.memory.textures++}if(B.samples>0&&wJ(B)===!1){f.__webglMultisampledFramebuffer=J.createFramebuffer(),f.__webglColorRenderbuffer=[],$.bindFramebuffer(J.FRAMEBUFFER,f.__webglMultisampledFramebuffer);for(let JJ=0;JJ<o.length;JJ++){let kJ=o[JJ];f.__webglColorRenderbuffer[JJ]=J.createRenderbuffer(),J.bindRenderbuffer(J.RENDERBUFFER,f.__webglColorRenderbuffer[JJ]);let AJ=H.convert(kJ.format,kJ.colorSpace),e=H.convert(kJ.type),XJ=L(kJ.internalFormat,AJ,e,kJ.colorSpace,B.isXRRenderTarget===!0),LJ=DJ(B);J.renderbufferStorageMultisample(J.RENDERBUFFER,LJ,XJ,B.width,B.height),J.framebufferRenderbuffer(J.FRAMEBUFFER,J.COLOR_ATTACHMENT0+JJ,J.RENDERBUFFER,f.__webglColorRenderbuffer[JJ])}if(J.bindRenderbuffer(J.RENDERBUFFER,null),B.depthBuffer)f.__webglDepthRenderbuffer=J.createRenderbuffer(),uJ(f.__webglDepthRenderbuffer,B,!0);$.bindFramebuffer(J.FRAMEBUFFER,null)}}if(p){$.bindTexture(J.TEXTURE_CUBE_MAP,n.__webglTexture),mJ(J.TEXTURE_CUBE_MAP,R);for(let JJ=0;JJ<6;JJ++)if(R.mipmaps&&R.mipmaps.length>0)for(let kJ=0;kJ<R.mipmaps.length;kJ++)RJ(f.__webglFramebuffer[JJ][kJ],B,R,J.COLOR_ATTACHMENT0,J.TEXTURE_CUBE_MAP_POSITIVE_X+JJ,kJ);else RJ(f.__webglFramebuffer[JJ],B,R,J.COLOR_ATTACHMENT0,J.TEXTURE_CUBE_MAP_POSITIVE_X+JJ,0);if(N(R))F(J.TEXTURE_CUBE_MAP);$.unbindTexture()}else if(EJ){for(let JJ=0,kJ=o.length;JJ<kJ;JJ++){let AJ=o[JJ],e=Z.get(AJ),XJ=J.TEXTURE_2D;if(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)XJ=B.isWebGL3DRenderTarget?J.TEXTURE_3D:J.TEXTURE_2D_ARRAY;if($.bindTexture(XJ,e.__webglTexture),mJ(XJ,AJ),RJ(f.__webglFramebuffer,B,AJ,J.COLOR_ATTACHMENT0+JJ,XJ,0),N(AJ))F(XJ)}$.unbindTexture()}else{let JJ=J.TEXTURE_2D;if(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)JJ=B.isWebGL3DRenderTarget?J.TEXTURE_3D:J.TEXTURE_2D_ARRAY;if($.bindTexture(JJ,n.__webglTexture),mJ(JJ,R),R.mipmaps&&R.mipmaps.length>0)for(let kJ=0;kJ<R.mipmaps.length;kJ++)RJ(f.__webglFramebuffer[kJ],B,R,J.COLOR_ATTACHMENT0,JJ,kJ);else RJ(f.__webglFramebuffer,B,R,J.COLOR_ATTACHMENT0,JJ,0);if(N(R))F(JJ);$.unbindTexture()}if(B.depthBuffer)dJ(B)}function CJ(B){let R=B.textures;for(let f=0,n=R.length;f<n;f++){let o=R[f];if(N(o)){let p=C(B),EJ=Z.get(o).__webglTexture;$.bindTexture(p,EJ),F(p),$.unbindTexture()}}}let iJ=[],zJ=[];function X0(B){if(B.samples>0){if(wJ(B)===!1){let{textures:R,width:f,height:n}=B,o=J.COLOR_BUFFER_BIT,p=B.stencilBuffer?J.DEPTH_STENCIL_ATTACHMENT:J.DEPTH_ATTACHMENT,EJ=Z.get(B),JJ=R.length>1;if(JJ)for(let AJ=0;AJ<R.length;AJ++)$.bindFramebuffer(J.FRAMEBUFFER,EJ.__webglMultisampledFramebuffer),J.framebufferRenderbuffer(J.FRAMEBUFFER,J.COLOR_ATTACHMENT0+AJ,J.RENDERBUFFER,null),$.bindFramebuffer(J.FRAMEBUFFER,EJ.__webglFramebuffer),J.framebufferTexture2D(J.DRAW_FRAMEBUFFER,J.COLOR_ATTACHMENT0+AJ,J.TEXTURE_2D,null,0);$.bindFramebuffer(J.READ_FRAMEBUFFER,EJ.__webglMultisampledFramebuffer);let kJ=B.texture.mipmaps;if(kJ&&kJ.length>0)$.bindFramebuffer(J.DRAW_FRAMEBUFFER,EJ.__webglFramebuffer[0]);else $.bindFramebuffer(J.DRAW_FRAMEBUFFER,EJ.__webglFramebuffer);for(let AJ=0;AJ<R.length;AJ++){if(B.resolveDepthBuffer){if(B.depthBuffer)o|=J.DEPTH_BUFFER_BIT;if(B.stencilBuffer&&B.resolveStencilBuffer)o|=J.STENCIL_BUFFER_BIT}if(JJ){J.framebufferRenderbuffer(J.READ_FRAMEBUFFER,J.COLOR_ATTACHMENT0,J.RENDERBUFFER,EJ.__webglColorRenderbuffer[AJ]);let e=Z.get(R[AJ]).__webglTexture;J.framebufferTexture2D(J.DRAW_FRAMEBUFFER,J.COLOR_ATTACHMENT0,J.TEXTURE_2D,e,0)}if(J.blitFramebuffer(0,0,f,n,0,0,f,n,o,J.NEAREST),K===!0){if(iJ.length=0,zJ.length=0,iJ.push(J.COLOR_ATTACHMENT0+AJ),B.depthBuffer&&B.resolveDepthBuffer===!1)iJ.push(p),zJ.push(p),J.invalidateFramebuffer(J.DRAW_FRAMEBUFFER,zJ);J.invalidateFramebuffer(J.READ_FRAMEBUFFER,iJ)}}if($.bindFramebuffer(J.READ_FRAMEBUFFER,null),$.bindFramebuffer(J.DRAW_FRAMEBUFFER,null),JJ)for(let AJ=0;AJ<R.length;AJ++){$.bindFramebuffer(J.FRAMEBUFFER,EJ.__webglMultisampledFramebuffer),J.framebufferRenderbuffer(J.FRAMEBUFFER,J.COLOR_ATTACHMENT0+AJ,J.RENDERBUFFER,EJ.__webglColorRenderbuffer[AJ]);let e=Z.get(R[AJ]).__webglTexture;$.bindFramebuffer(J.FRAMEBUFFER,EJ.__webglFramebuffer),J.framebufferTexture2D(J.DRAW_FRAMEBUFFER,J.COLOR_ATTACHMENT0+AJ,J.TEXTURE_2D,e,0)}$.bindFramebuffer(J.DRAW_FRAMEBUFFER,EJ.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&K){let R=B.stencilBuffer?J.DEPTH_STENCIL_ATTACHMENT:J.DEPTH_ATTACHMENT;J.invalidateFramebuffer(J.DRAW_FRAMEBUFFER,[R])}}}function DJ(B){return Math.min(W.maxSamples,B.samples)}function wJ(B){let R=Z.get(B);return B.samples>0&&Q.has("WEBGL_multisampled_render_to_texture")===!0&&R.__useRenderToTexture!==!1}function V0(B){let R=Y.render.frame;if(G.get(B)!==R)G.set(B,R),B.update()}function D0(B,R){let{colorSpace:f,format:n,type:o}=B;if(B.isCompressedTexture===!0||B.isVideoTexture===!0)return R;if(f!==T0&&f!==U9)if(lJ.getTransfer(f)===W0){if(n!==G8||o!==u8)console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else console.error("THREE.WebGLTextures: Unsupported texture color space:",f);return R}function N0(B){if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement)U.width=B.naturalWidth||B.width,U.height=B.naturalHeight||B.height;else if(typeof VideoFrame<"u"&&B instanceof VideoFrame)U.width=B.displayWidth,U.height=B.displayHeight;else U.width=B.width,U.height=B.height;return U}this.allocateTextureUnit=l,this.resetTextureUnits=m,this.setTexture2D=i,this.setTexture2DArray=u,this.setTexture3D=r,this.setTextureCube=g,this.rebindTextures=I,this.setupRenderTarget=$0,this.updateRenderTargetMipmap=CJ,this.updateMultisampleRenderTarget=X0,this.setupDepthRenderbuffer=dJ,this.setupFrameBufferTexture=RJ,this.useMultisampledRTT=wJ}function iq(J,Q){function $(Z,W=U9){let H,Y=lJ.getTransfer(W);if(Z===u8)return J.UNSIGNED_BYTE;if(Z===lQ)return J.UNSIGNED_SHORT_4_4_4_4;if(Z===dQ)return J.UNSIGNED_SHORT_5_5_5_1;if(Z===fW)return J.UNSIGNED_INT_5_9_9_9_REV;if(Z===yW)return J.BYTE;if(Z===vW)return J.SHORT;if(Z===F6)return J.UNSIGNED_SHORT;if(Z===pQ)return J.INT;if(Z===g9)return J.UNSIGNED_INT;if(Z===c8)return J.FLOAT;if(Z===R6)return J.HALF_FLOAT;if(Z===hW)return J.ALPHA;if(Z===bW)return J.RGB;if(Z===G8)return J.RGBA;if(Z===V7)return J.DEPTH_COMPONENT;if(Z===k6)return J.DEPTH_STENCIL;if(Z===xW)return J.RED;if(Z===mQ)return J.RED_INTEGER;if(Z===gW)return J.RG;if(Z===uQ)return J.RG_INTEGER;if(Z===cQ)return J.RGBA_INTEGER;if(Z===z7||Z===B7||Z===C7||Z===_7)if(Y===W0)if(H=Q.get("WEBGL_compressed_texture_s3tc_srgb"),H!==null){if(Z===z7)return H.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(Z===B7)return H.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(Z===C7)return H.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(Z===_7)return H.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(H=Q.get("WEBGL_compressed_texture_s3tc"),H!==null){if(Z===z7)return H.COMPRESSED_RGB_S3TC_DXT1_EXT;if(Z===B7)return H.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(Z===C7)return H.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(Z===_7)return H.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(Z===nQ||Z===sQ||Z===oQ||Z===iQ)if(H=Q.get("WEBGL_compressed_texture_pvrtc"),H!==null){if(Z===nQ)return H.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(Z===sQ)return H.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(Z===oQ)return H.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(Z===iQ)return H.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(Z===aQ||Z===rQ||Z===tQ)if(H=Q.get("WEBGL_compressed_texture_etc"),H!==null){if(Z===aQ||Z===rQ)return Y===W0?H.COMPRESSED_SRGB8_ETC2:H.COMPRESSED_RGB8_ETC2;if(Z===tQ)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:H.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(Z===eQ||Z===J$||Z===Q$||Z===$$||Z===Z$||Z===W$||Z===H$||Z===Y$||Z===X$||Z===K$||Z===U$||Z===G$||Z===q$||Z===E$)if(H=Q.get("WEBGL_compressed_texture_astc"),H!==null){if(Z===eQ)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:H.COMPRESSED_RGBA_ASTC_4x4_KHR;if(Z===J$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:H.COMPRESSED_RGBA_ASTC_5x4_KHR;if(Z===Q$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:H.COMPRESSED_RGBA_ASTC_5x5_KHR;if(Z===$$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:H.COMPRESSED_RGBA_ASTC_6x5_KHR;if(Z===Z$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:H.COMPRESSED_RGBA_ASTC_6x6_KHR;if(Z===W$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:H.COMPRESSED_RGBA_ASTC_8x5_KHR;if(Z===H$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:H.COMPRESSED_RGBA_ASTC_8x6_KHR;if(Z===Y$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:H.COMPRESSED_RGBA_ASTC_8x8_KHR;if(Z===X$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:H.COMPRESSED_RGBA_ASTC_10x5_KHR;if(Z===K$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:H.COMPRESSED_RGBA_ASTC_10x6_KHR;if(Z===U$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:H.COMPRESSED_RGBA_ASTC_10x8_KHR;if(Z===G$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:H.COMPRESSED_RGBA_ASTC_10x10_KHR;if(Z===q$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:H.COMPRESSED_RGBA_ASTC_12x10_KHR;if(Z===E$)return Y===W0?H.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:H.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(Z===w7||Z===N$||Z===O$)if(H=Q.get("EXT_texture_compression_bptc"),H!==null){if(Z===w7)return Y===W0?H.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:H.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(Z===N$)return H.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(Z===O$)return H.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(Z===pW||Z===F$||Z===R$||Z===k$)if(H=Q.get("EXT_texture_compression_rgtc"),H!==null){if(Z===w7)return H.COMPRESSED_RED_RGTC1_EXT;if(Z===F$)return H.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(Z===R$)return H.COMPRESSED_RED_GREEN_RGTC2_EXT;if(Z===k$)return H.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(Z===p9)return J.UNSIGNED_INT_24_8;return J[Z]!==void 0?J[Z]:null}return{convert:$}}class e$ extends E0{constructor(J=null){super();this.sourceTexture=J,this.isExternalTexture=!0}}var aq=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,rq=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`;class lH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(J,Q){if(this.texture===null){let $=new e$(J.texture);if(J.depthNear!==Q.depthNear||J.depthFar!==Q.depthFar)this.depthNear=J.depthNear,this.depthFar=J.depthFar;this.texture=$}}getMesh(J){if(this.texture!==null){if(this.mesh===null){let Q=J.cameras[0].viewport,$=new N8({vertexShader:aq,fragmentShader:rq,uniforms:{depthColor:{value:this.texture},depthWidth:{value:Q.z},depthHeight:{value:Q.w}}});this.mesh=new _0(new P6(20,20),$)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dH extends P8{constructor(J,Q){super();let $=this,Z=null,W=1,H=null,Y="local-floor",X=1,K=null,U=null,G=null,q=null,E=null,O=null,k=new lH,M={},N=Q.getContextAttributes(),F=null,C=null,L=[],_=[],v=new PJ,w=null,T=new O0;T.viewport=new sJ;let x=new O0;x.viewport=new sJ;let z=[T,x],V=new p$,j=null,m=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(d){let WJ=L[d];if(WJ===void 0)WJ=new V6,L[d]=WJ;return WJ.getTargetRaySpace()},this.getControllerGrip=function(d){let WJ=L[d];if(WJ===void 0)WJ=new V6,L[d]=WJ;return WJ.getGripSpace()},this.getHand=function(d){let WJ=L[d];if(WJ===void 0)WJ=new V6,L[d]=WJ;return WJ.getHandSpace()};function l(d){let WJ=_.indexOf(d.inputSource);if(WJ===-1)return;let MJ=L[WJ];if(MJ!==void 0)MJ.update(d.inputSource,d.frame,K||H),MJ.dispatchEvent({type:d.type,data:d.inputSource})}function c(){Z.removeEventListener("select",l),Z.removeEventListener("selectstart",l),Z.removeEventListener("selectend",l),Z.removeEventListener("squeeze",l),Z.removeEventListener("squeezestart",l),Z.removeEventListener("squeezeend",l),Z.removeEventListener("end",c),Z.removeEventListener("inputsourceschange",i);for(let d=0;d<L.length;d++){let WJ=_[d];if(WJ===null)continue;_[d]=null,L[d].disconnect(WJ)}j=null,m=null,k.reset();for(let d in M)delete M[d];J.setRenderTarget(F),E=null,q=null,G=null,Z=null,C=null,Y0.stop(),$.isPresenting=!1,J.setPixelRatio(w),J.setSize(v.width,v.height,!1),$.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(d){if(W=d,$.isPresenting===!0)console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(d){if(Y=d,$.isPresenting===!0)console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return K||H},this.setReferenceSpace=function(d){K=d},this.getBaseLayer=function(){return q!==null?q:E},this.getBinding=function(){return G},this.getFrame=function(){return O},this.getSession=function(){return Z},this.setSession=async function(d){if(Z=d,Z!==null){if(F=J.getRenderTarget(),Z.addEventListener("select",l),Z.addEventListener("selectstart",l),Z.addEventListener("selectend",l),Z.addEventListener("squeeze",l),Z.addEventListener("squeezestart",l),Z.addEventListener("squeezeend",l),Z.addEventListener("end",c),Z.addEventListener("inputsourceschange",i),N.xrCompatible!==!0)await Q.makeXRCompatible();if(w=J.getPixelRatio(),J.getSize(v),typeof XRWebGLBinding<"u")G=new XRWebGLBinding(Z,Q);if(!(G!==null&&("createProjectionLayer"in XRWebGLBinding.prototype))){let MJ={antialias:N.antialias,alpha:!0,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:W};E=new XRWebGLLayer(Z,Q,MJ),Z.updateRenderState({baseLayer:E}),J.setPixelRatio(1),J.setSize(E.framebufferWidth,E.framebufferHeight,!1),C=new T8(E.framebufferWidth,E.framebufferHeight,{format:G8,type:u8,colorSpace:J.outputColorSpace,stencilBuffer:N.stencil,resolveDepthBuffer:E.ignoreDepthValues===!1,resolveStencilBuffer:E.ignoreDepthValues===!1})}else{let MJ=null,GJ=null,RJ=null;if(N.depth)RJ=N.stencil?Q.DEPTH24_STENCIL8:Q.DEPTH_COMPONENT24,MJ=N.stencil?k6:V7,GJ=N.stencil?p9:g9;let uJ={colorFormat:Q.RGBA8,depthFormat:RJ,scaleFactor:W};q=G.createProjectionLayer(uJ),Z.updateRenderState({layers:[q]}),J.setPixelRatio(1),J.setSize(q.textureWidth,q.textureHeight,!1),C=new T8(q.textureWidth,q.textureHeight,{format:G8,type:u8,depthTexture:new l7(q.textureWidth,q.textureHeight,GJ,void 0,void 0,void 0,void 0,void 0,void 0,MJ),stencilBuffer:N.stencil,colorSpace:J.outputColorSpace,samples:N.antialias?4:0,resolveDepthBuffer:q.ignoreDepthValues===!1,resolveStencilBuffer:q.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(X),K=null,H=await Z.requestReferenceSpace(Y),Y0.setContext(Z),Y0.start(),$.isPresenting=!0,$.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(Z!==null)return Z.environmentBlendMode},this.getDepthTexture=function(){return k.getDepthTexture()};function i(d){for(let WJ=0;WJ<d.removed.length;WJ++){let MJ=d.removed[WJ],GJ=_.indexOf(MJ);if(GJ>=0)_[GJ]=null,L[GJ].disconnect(MJ)}for(let WJ=0;WJ<d.added.length;WJ++){let MJ=d.added[WJ],GJ=_.indexOf(MJ);if(GJ===-1){for(let uJ=0;uJ<L.length;uJ++)if(uJ>=_.length){_.push(MJ),GJ=uJ;break}else if(_[uJ]===null){_[uJ]=MJ,GJ=uJ;break}if(GJ===-1)break}let RJ=L[GJ];if(RJ)RJ.connect(MJ)}}let u=new A,r=new A;function g(d,WJ,MJ){u.setFromMatrixPosition(WJ.matrixWorld),r.setFromMatrixPosition(MJ.matrixWorld);let GJ=u.distanceTo(r),RJ=WJ.projectionMatrix.elements,uJ=MJ.projectionMatrix.elements,cJ=RJ[14]/(RJ[10]-1),dJ=RJ[14]/(RJ[10]+1),I=(RJ[9]+1)/RJ[5],$0=(RJ[9]-1)/RJ[5],CJ=(RJ[8]-1)/RJ[0],iJ=(uJ[8]+1)/uJ[0],zJ=cJ*CJ,X0=cJ*iJ,DJ=GJ/(-CJ+iJ),wJ=DJ*-CJ;if(WJ.matrixWorld.decompose(d.position,d.quaternion,d.scale),d.translateX(wJ),d.translateZ(DJ),d.matrixWorld.compose(d.position,d.quaternion,d.scale),d.matrixWorldInverse.copy(d.matrixWorld).invert(),RJ[10]===-1)d.projectionMatrix.copy(WJ.projectionMatrix),d.projectionMatrixInverse.copy(WJ.projectionMatrixInverse);else{let V0=cJ+DJ,D0=dJ+DJ,N0=zJ-wJ,B=X0+(GJ-wJ),R=I*dJ/D0*V0,f=$0*dJ/D0*V0;d.projectionMatrix.makePerspective(N0,B,R,f,V0,D0),d.projectionMatrixInverse.copy(d.projectionMatrix).invert()}}function ZJ(d,WJ){if(WJ===null)d.matrixWorld.copy(d.matrix);else d.matrixWorld.multiplyMatrices(WJ.matrixWorld,d.matrix);d.matrixWorldInverse.copy(d.matrixWorld).invert()}this.updateCamera=function(d){if(Z===null)return;let{near:WJ,far:MJ}=d;if(k.texture!==null){if(k.depthNear>0)WJ=k.depthNear;if(k.depthFar>0)MJ=k.depthFar}if(V.near=x.near=T.near=WJ,V.far=x.far=T.far=MJ,j!==V.near||m!==V.far)Z.updateRenderState({depthNear:V.near,depthFar:V.far}),j=V.near,m=V.far;V.layers.mask=d.layers.mask|6,T.layers.mask=V.layers.mask&3,x.layers.mask=V.layers.mask&5;let GJ=d.parent,RJ=V.cameras;ZJ(V,GJ);for(let uJ=0;uJ<RJ.length;uJ++)ZJ(RJ[uJ],GJ);if(RJ.length===2)g(V,T,x);else V.projectionMatrix.copy(T.projectionMatrix);UJ(d,V,GJ)};function UJ(d,WJ,MJ){if(MJ===null)d.matrix.copy(WJ.matrixWorld);else d.matrix.copy(MJ.matrixWorld),d.matrix.invert(),d.matrix.multiply(WJ.matrixWorld);if(d.matrix.decompose(d.position,d.quaternion,d.scale),d.updateMatrixWorld(!0),d.projectionMatrix.copy(WJ.projectionMatrix),d.projectionMatrixInverse.copy(WJ.projectionMatrixInverse),d.isPerspectiveCamera)d.fov=W9*2*Math.atan(1/d.projectionMatrix.elements[5]),d.zoom=1}this.getCamera=function(){return V},this.getFoveation=function(){if(q===null&&E===null)return;return X},this.setFoveation=function(d){if(X=d,q!==null)q.fixedFoveation=d;if(E!==null&&E.fixedFoveation!==void 0)E.fixedFoveation=d},this.hasDepthSensing=function(){return k.texture!==null},this.getDepthSensingMesh=function(){return k.getMesh(V)},this.getCameraTexture=function(d){return M[d]};let TJ=null;function mJ(d,WJ){if(U=WJ.getViewerPose(K||H),O=WJ,U!==null){let MJ=U.views;if(E!==null)J.setRenderTargetFramebuffer(C,E.framebuffer),J.setRenderTarget(C);let GJ=!1;if(MJ.length!==V.cameras.length)V.cameras.length=0,GJ=!0;for(let dJ=0;dJ<MJ.length;dJ++){let I=MJ[dJ],$0=null;if(E!==null)$0=E.getViewport(I);else{let iJ=G.getViewSubImage(q,I);if($0=iJ.viewport,dJ===0)J.setRenderTargetTextures(C,iJ.colorTexture,iJ.depthStencilTexture),J.setRenderTarget(C)}let CJ=z[dJ];if(CJ===void 0)CJ=new O0,CJ.layers.enable(dJ),CJ.viewport=new sJ,z[dJ]=CJ;if(CJ.matrix.fromArray(I.transform.matrix),CJ.matrix.decompose(CJ.position,CJ.quaternion,CJ.scale),CJ.projectionMatrix.fromArray(I.projectionMatrix),CJ.projectionMatrixInverse.copy(CJ.projectionMatrix).invert(),CJ.viewport.set($0.x,$0.y,$0.width,$0.height),dJ===0)V.matrix.copy(CJ.matrix),V.matrix.decompose(V.position,V.quaternion,V.scale);if(GJ===!0)V.cameras.push(CJ)}let RJ=Z.enabledFeatures;if(RJ&&RJ.includes("depth-sensing")&&Z.depthUsage=="gpu-optimized"&&G){let dJ=G.getDepthInformation(MJ[0]);if(dJ&&dJ.isValid&&dJ.texture)k.init(dJ,Z.renderState)}if(RJ&&RJ.includes("camera-access")){if(J.state.unbindTexture(),G)for(let dJ=0;dJ<MJ.length;dJ++){let I=MJ[dJ].camera;if(I){let $0=M[I];if(!$0)$0=new e$,M[I]=$0;let CJ=G.getCameraImage(I);$0.sourceTexture=CJ}}}}for(let MJ=0;MJ<L.length;MJ++){let GJ=_[MJ],RJ=L[MJ];if(GJ!==null&&RJ!==void 0)RJ.update(GJ,WJ,K||H)}if(TJ)TJ(d,WJ);if(WJ.detectedPlanes)$.dispatchEvent({type:"planesdetected",data:WJ});O=null}let Y0=new SH;Y0.setAnimationLoop(mJ),this.setAnimationLoop=function(d){TJ=d},this.dispose=function(){}}}var E9=new Z8,tq=new vJ;function eq(J,Q){function $(N,F){if(N.matrixAutoUpdate===!0)N.updateMatrix();F.value.copy(N.matrix)}function Z(N,F){if(F.color.getRGB(N.fogColor.value,T$(J)),F.isFog)N.fogNear.value=F.near,N.fogFar.value=F.far;else if(F.isFogExp2)N.fogDensity.value=F.density}function W(N,F,C,L,_){if(F.isMeshBasicMaterial)H(N,F);else if(F.isMeshLambertMaterial)H(N,F);else if(F.isMeshToonMaterial)H(N,F),q(N,F);else if(F.isMeshPhongMaterial)H(N,F),G(N,F);else if(F.isMeshStandardMaterial){if(H(N,F),E(N,F),F.isMeshPhysicalMaterial)O(N,F,_)}else if(F.isMeshMatcapMaterial)H(N,F),k(N,F);else if(F.isMeshDepthMaterial)H(N,F);else if(F.isMeshDistanceMaterial)H(N,F),M(N,F);else if(F.isMeshNormalMaterial)H(N,F);else if(F.isLineBasicMaterial){if(Y(N,F),F.isLineDashedMaterial)X(N,F)}else if(F.isPointsMaterial)K(N,F,C,L);else if(F.isSpriteMaterial)U(N,F);else if(F.isShadowMaterial)N.color.value.copy(F.color),N.opacity.value=F.opacity;else if(F.isShaderMaterial)F.uniformsNeedUpdate=!1}function H(N,F){if(N.opacity.value=F.opacity,F.color)N.diffuse.value.copy(F.color);if(F.emissive)N.emissive.value.copy(F.emissive).multiplyScalar(F.emissiveIntensity);if(F.map)N.map.value=F.map,$(F.map,N.mapTransform);if(F.alphaMap)N.alphaMap.value=F.alphaMap,$(F.alphaMap,N.alphaMapTransform);if(F.bumpMap){if(N.bumpMap.value=F.bumpMap,$(F.bumpMap,N.bumpMapTransform),N.bumpScale.value=F.bumpScale,F.side===g0)N.bumpScale.value*=-1}if(F.normalMap){if(N.normalMap.value=F.normalMap,$(F.normalMap,N.normalMapTransform),N.normalScale.value.copy(F.normalScale),F.side===g0)N.normalScale.value.negate()}if(F.displacementMap)N.displacementMap.value=F.displacementMap,$(F.displacementMap,N.displacementMapTransform),N.displacementScale.value=F.displacementScale,N.displacementBias.value=F.displacementBias;if(F.emissiveMap)N.emissiveMap.value=F.emissiveMap,$(F.emissiveMap,N.emissiveMapTransform);if(F.specularMap)N.specularMap.value=F.specularMap,$(F.specularMap,N.specularMapTransform);if(F.alphaTest>0)N.alphaTest.value=F.alphaTest;let C=Q.get(F),L=C.envMap,_=C.envMapRotation;if(L){if(N.envMap.value=L,E9.copy(_),E9.x*=-1,E9.y*=-1,E9.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1)E9.y*=-1,E9.z*=-1;N.envMapRotation.value.setFromMatrix4(tq.makeRotationFromEuler(E9)),N.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,N.reflectivity.value=F.reflectivity,N.ior.value=F.ior,N.refractionRatio.value=F.refractionRatio}if(F.lightMap)N.lightMap.value=F.lightMap,N.lightMapIntensity.value=F.lightMapIntensity,$(F.lightMap,N.lightMapTransform);if(F.aoMap)N.aoMap.value=F.aoMap,N.aoMapIntensity.value=F.aoMapIntensity,$(F.aoMap,N.aoMapTransform)}function Y(N,F){if(N.diffuse.value.copy(F.color),N.opacity.value=F.opacity,F.map)N.map.value=F.map,$(F.map,N.mapTransform)}function X(N,F){N.dashSize.value=F.dashSize,N.totalSize.value=F.dashSize+F.gapSize,N.scale.value=F.scale}function K(N,F,C,L){if(N.diffuse.value.copy(F.color),N.opacity.value=F.opacity,N.size.value=F.size*C,N.scale.value=L*0.5,F.map)N.map.value=F.map,$(F.map,N.uvTransform);if(F.alphaMap)N.alphaMap.value=F.alphaMap,$(F.alphaMap,N.alphaMapTransform);if(F.alphaTest>0)N.alphaTest.value=F.alphaTest}function U(N,F){if(N.diffuse.value.copy(F.color),N.opacity.value=F.opacity,N.rotation.value=F.rotation,F.map)N.map.value=F.map,$(F.map,N.mapTransform);if(F.alphaMap)N.alphaMap.value=F.alphaMap,$(F.alphaMap,N.alphaMapTransform);if(F.alphaTest>0)N.alphaTest.value=F.alphaTest}function G(N,F){N.specular.value.copy(F.specular),N.shininess.value=Math.max(F.shininess,0.0001)}function q(N,F){if(F.gradientMap)N.gradientMap.value=F.gradientMap}function E(N,F){if(N.metalness.value=F.metalness,F.metalnessMap)N.metalnessMap.value=F.metalnessMap,$(F.metalnessMap,N.metalnessMapTransform);if(N.roughness.value=F.roughness,F.roughnessMap)N.roughnessMap.value=F.roughnessMap,$(F.roughnessMap,N.roughnessMapTransform);if(F.envMap)N.envMapIntensity.value=F.envMapIntensity}function O(N,F,C){if(N.ior.value=F.ior,F.sheen>0){if(N.sheenColor.value.copy(F.sheenColor).multiplyScalar(F.sheen),N.sheenRoughness.value=F.sheenRoughness,F.sheenColorMap)N.sheenColorMap.value=F.sheenColorMap,$(F.sheenColorMap,N.sheenColorMapTransform);if(F.sheenRoughnessMap)N.sheenRoughnessMap.value=F.sheenRoughnessMap,$(F.sheenRoughnessMap,N.sheenRoughnessMapTransform)}if(F.clearcoat>0){if(N.clearcoat.value=F.clearcoat,N.clearcoatRoughness.value=F.clearcoatRoughness,F.clearcoatMap)N.clearcoatMap.value=F.clearcoatMap,$(F.clearcoatMap,N.clearcoatMapTransform);if(F.clearcoatRoughnessMap)N.clearcoatRoughnessMap.value=F.clearcoatRoughnessMap,$(F.clearcoatRoughnessMap,N.clearcoatRoughnessMapTransform);if(F.clearcoatNormalMap){if(N.clearcoatNormalMap.value=F.clearcoatNormalMap,$(F.clearcoatNormalMap,N.clearcoatNormalMapTransform),N.clearcoatNormalScale.value.copy(F.clearcoatNormalScale),F.side===g0)N.clearcoatNormalScale.value.negate()}}if(F.dispersion>0)N.dispersion.value=F.dispersion;if(F.iridescence>0){if(N.iridescence.value=F.iridescence,N.iridescenceIOR.value=F.iridescenceIOR,N.iridescenceThicknessMinimum.value=F.iridescenceThicknessRange[0],N.iridescenceThicknessMaximum.value=F.iridescenceThicknessRange[1],F.iridescenceMap)N.iridescenceMap.value=F.iridescenceMap,$(F.iridescenceMap,N.iridescenceMapTransform);if(F.iridescenceThicknessMap)N.iridescenceThicknessMap.value=F.iridescenceThicknessMap,$(F.iridescenceThicknessMap,N.iridescenceThicknessMapTransform)}if(F.transmission>0){if(N.transmission.value=F.transmission,N.transmissionSamplerMap.value=C.texture,N.transmissionSamplerSize.value.set(C.width,C.height),F.transmissionMap)N.transmissionMap.value=F.transmissionMap,$(F.transmissionMap,N.transmissionMapTransform);if(N.thickness.value=F.thickness,F.thicknessMap)N.thicknessMap.value=F.thicknessMap,$(F.thicknessMap,N.thicknessMapTransform);N.attenuationDistance.value=F.attenuationDistance,N.attenuationColor.value.copy(F.attenuationColor)}if(F.anisotropy>0){if(N.anisotropyVector.value.set(F.anisotropy*Math.cos(F.anisotropyRotation),F.anisotropy*Math.sin(F.anisotropyRotation)),F.anisotropyMap)N.anisotropyMap.value=F.anisotropyMap,$(F.anisotropyMap,N.anisotropyMapTransform)}if(N.specularIntensity.value=F.specularIntensity,N.specularColor.value.copy(F.specularColor),F.specularColorMap)N.specularColorMap.value=F.specularColorMap,$(F.specularColorMap,N.specularColorMapTransform);if(F.specularIntensityMap)N.specularIntensityMap.value=F.specularIntensityMap,$(F.specularIntensityMap,N.specularIntensityMapTransform)}function k(N,F){if(F.matcap)N.matcap.value=F.matcap}function M(N,F){let C=Q.get(F).light;N.referencePosition.value.setFromMatrixPosition(C.matrixWorld),N.nearDistance.value=C.shadow.camera.near,N.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:Z,refreshMaterialUniforms:W}}function J1(J,Q,$,Z){let W={},H={},Y=[],X=J.getParameter(J.MAX_UNIFORM_BUFFER_BINDINGS);function K(C,L){let _=L.program;Z.uniformBlockBinding(C,_)}function U(C,L){let _=W[C.id];if(_===void 0)k(C),_=G(C),W[C.id]=_,C.addEventListener("dispose",N);let v=L.program;Z.updateUBOMapping(C,v);let w=Q.render.frame;if(H[C.id]!==w)E(C),H[C.id]=w}function G(C){let L=q();C.__bindingPointIndex=L;let _=J.createBuffer(),v=C.__size,w=C.usage;return J.bindBuffer(J.UNIFORM_BUFFER,_),J.bufferData(J.UNIFORM_BUFFER,v,w),J.bindBuffer(J.UNIFORM_BUFFER,null),J.bindBufferBase(J.UNIFORM_BUFFER,L,_),_}function q(){for(let C=0;C<X;C++)if(Y.indexOf(C)===-1)return Y.push(C),C;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function E(C){let L=W[C.id],_=C.uniforms,v=C.__cache;J.bindBuffer(J.UNIFORM_BUFFER,L);for(let w=0,T=_.length;w<T;w++){let x=Array.isArray(_[w])?_[w]:[_[w]];for(let z=0,V=x.length;z<V;z++){let j=x[z];if(O(j,w,z,v)===!0){let m=j.__offset,l=Array.isArray(j.value)?j.value:[j.value],c=0;for(let i=0;i<l.length;i++){let u=l[i],r=M(u);if(typeof u==="number"||typeof u==="boolean")j.__data[0]=u,J.bufferSubData(J.UNIFORM_BUFFER,m+c,j.__data);else if(u.isMatrix3)j.__data[0]=u.elements[0],j.__data[1]=u.elements[1],j.__data[2]=u.elements[2],j.__data[3]=0,j.__data[4]=u.elements[3],j.__data[5]=u.elements[4],j.__data[6]=u.elements[5],j.__data[7]=0,j.__data[8]=u.elements[6],j.__data[9]=u.elements[7],j.__data[10]=u.elements[8],j.__data[11]=0;else u.toArray(j.__data,c),c+=r.storage/Float32Array.BYTES_PER_ELEMENT}J.bufferSubData(J.UNIFORM_BUFFER,m,j.__data)}}}J.bindBuffer(J.UNIFORM_BUFFER,null)}function O(C,L,_,v){let w=C.value,T=L+"_"+_;if(v[T]===void 0){if(typeof w==="number"||typeof w==="boolean")v[T]=w;else v[T]=w.clone();return!0}else{let x=v[T];if(typeof w==="number"||typeof w==="boolean"){if(x!==w)return v[T]=w,!0}else if(x.equals(w)===!1)return x.copy(w),!0}return!1}function k(C){let L=C.uniforms,_=0,v=16;for(let T=0,x=L.length;T<x;T++){let z=Array.isArray(L[T])?L[T]:[L[T]];for(let V=0,j=z.length;V<j;V++){let m=z[V],l=Array.isArray(m.value)?m.value:[m.value];for(let c=0,i=l.length;c<i;c++){let u=l[c],r=M(u),g=_%v,ZJ=g%r.boundary,UJ=g+ZJ;if(_+=ZJ,UJ!==0&&v-UJ<r.storage)_+=v-UJ;m.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),m.__offset=_,_+=r.storage}}}let w=_%v;if(w>0)_+=v-w;return C.__size=_,C.__cache={},this}function M(C){let L={boundary:0,storage:0};if(typeof C==="number"||typeof C==="boolean")L.boundary=4,L.storage=4;else if(C.isVector2)L.boundary=8,L.storage=8;else if(C.isVector3||C.isColor)L.boundary=16,L.storage=12;else if(C.isVector4)L.boundary=16,L.storage=16;else if(C.isMatrix3)L.boundary=48,L.storage=48;else if(C.isMatrix4)L.boundary=64,L.storage=64;else if(C.isTexture)console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.");else console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",C);return L}function N(C){let L=C.target;L.removeEventListener("dispose",N);let _=Y.indexOf(L.__bindingPointIndex);Y.splice(_,1),J.deleteBuffer(W[L.id]),delete W[L.id],delete H[L.id]}function F(){for(let C in W)J.deleteBuffer(W[C]);Y=[],W={},H={}}return{bind:K,update:U,dispose:F}}class JZ{constructor(J={}){let{canvas:Q=rW(),context:$=null,depth:Z=!0,stencil:W=!1,alpha:H=!1,antialias:Y=!1,premultipliedAlpha:X=!0,preserveDrawingBuffer:K=!1,powerPreference:U="default",failIfMajorPerformanceCaveat:G=!1,reversedDepthBuffer:q=!1}=J;this.isWebGLRenderer=!0;let E;if($!==null){if(typeof WebGLRenderingContext<"u"&&$ instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");E=$.getContextAttributes().alpha}else E=H;let O=new Uint32Array(4),k=new Int32Array(4),M=null,N=null,F=[],C=[];this.domElement=Q,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=_8,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let L=this,_=!1;this._outputColorSpace=q8;let v=0,w=0,T=null,x=-1,z=null,V=new sJ,j=new sJ,m=null,l=new jJ(0),c=0,i=Q.width,u=Q.height,r=1,g=null,ZJ=null,UJ=new sJ(0,0,i,u),TJ=new sJ(0,0,i,u),mJ=!1,Y0=new _6,d=!1,WJ=!1,MJ=new vJ,GJ=new A,RJ=new sJ,uJ={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},cJ=!1;function dJ(){return T===null?r:1}let I=$;function $0(D,S){return Q.getContext(D,S)}try{let D={alpha:!0,depth:Z,stencil:W,antialias:Y,premultipliedAlpha:X,preserveDrawingBuffer:K,powerPreference:U,failIfMajorPerformanceCaveat:G};if("setAttribute"in Q)Q.setAttribute("data-engine",`three.js r${JW}`);if(Q.addEventListener("webglcontextlost",HJ,!1),Q.addEventListener("webglcontextrestored",QJ,!1),Q.addEventListener("webglcontextcreationerror",NJ,!1),I===null){if(I=$0("webgl2",D),I===null)if($0("webgl2"))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(D){throw console.error("THREE.WebGLRenderer: "+D.message),D}let CJ,iJ,zJ,X0,DJ,wJ,V0,D0,N0,B,R,f,n,o,p,EJ,JJ,kJ,AJ,e,XJ,LJ,VJ,KJ;function bJ(){if(CJ=new MG(I),CJ.init(),LJ=new iq(I,CJ),iJ=new qG(I,CJ,J,LJ),zJ=new sq(I,CJ),iJ.reversedDepthBuffer&&q)zJ.buffers.depth.setReversed(!0);X0=new VG(I),DJ=new vq,wJ=new oq(I,CJ,zJ,DJ,iJ,LJ,X0),V0=new NG(L),D0=new kG(L),N0=new IX(I),VJ=new UG(I,N0),B=new DG(I,N0,X0,VJ),R=new BG(I,B,N0,X0),AJ=new zG(I,iJ,wJ),EJ=new EG(DJ),f=new yq(L,V0,D0,CJ,iJ,VJ,EJ),n=new eq(L,DJ),o=new hq,p=new dq(CJ),kJ=new KG(L,V0,D0,zJ,R,E,X),JJ=new cq(L,R,iJ),KJ=new J1(I,X0,iJ,zJ),e=new GG(I,CJ,X0),XJ=new LG(I,CJ,X0),X0.programs=f.programs,L.capabilities=iJ,L.extensions=CJ,L.properties=DJ,L.renderLists=o,L.shadowMap=JJ,L.state=zJ,L.info=X0}bJ();let P=new dH(L,I);this.xr=P,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let D=CJ.get("WEBGL_lose_context");if(D)D.loseContext()},this.forceContextRestore=function(){let D=CJ.get("WEBGL_lose_context");if(D)D.restoreContext()},this.getPixelRatio=function(){return r},this.setPixelRatio=function(D){if(D===void 0)return;r=D,this.setSize(i,u,!1)},this.getSize=function(D){return D.set(i,u)},this.setSize=function(D,S,h=!0){if(P.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}if(i=D,u=S,Q.width=Math.floor(D*r),Q.height=Math.floor(S*r),h===!0)Q.style.width=D+"px",Q.style.height=S+"px";this.setViewport(0,0,D,S)},this.getDrawingBufferSize=function(D){return D.set(i*r,u*r).floor()},this.setDrawingBufferSize=function(D,S,h){i=D,u=S,r=h,Q.width=Math.floor(D*h),Q.height=Math.floor(S*h),this.setViewport(0,0,D,S)},this.getCurrentViewport=function(D){return D.copy(V)},this.getViewport=function(D){return D.copy(UJ)},this.setViewport=function(D,S,h,b){if(D.isVector4)UJ.set(D.x,D.y,D.z,D.w);else UJ.set(D,S,h,b);zJ.viewport(V.copy(UJ).multiplyScalar(r).round())},this.getScissor=function(D){return D.copy(TJ)},this.setScissor=function(D,S,h,b){if(D.isVector4)TJ.set(D.x,D.y,D.z,D.w);else TJ.set(D,S,h,b);zJ.scissor(j.copy(TJ).multiplyScalar(r).round())},this.getScissorTest=function(){return mJ},this.setScissorTest=function(D){zJ.setScissorTest(mJ=D)},this.setOpaqueSort=function(D){g=D},this.setTransparentSort=function(D){ZJ=D},this.getClearColor=function(D){return D.copy(kJ.getClearColor())},this.setClearColor=function(){kJ.setClearColor(...arguments)},this.getClearAlpha=function(){return kJ.getClearAlpha()},this.setClearAlpha=function(){kJ.setClearAlpha(...arguments)},this.clear=function(D=!0,S=!0,h=!0){let b=0;if(D){let y=!1;if(T!==null){let t=T.texture.format;y=t===cQ||t===uQ||t===mQ}if(y){let t=T.texture.type,YJ=t===u8||t===g9||t===F6||t===p9||t===lQ||t===dQ,OJ=kJ.getClearColor(),qJ=kJ.getClearAlpha(),IJ=OJ.r,SJ=OJ.g,BJ=OJ.b;if(YJ)O[0]=IJ,O[1]=SJ,O[2]=BJ,O[3]=qJ,I.clearBufferuiv(I.COLOR,0,O);else k[0]=IJ,k[1]=SJ,k[2]=BJ,k[3]=qJ,I.clearBufferiv(I.COLOR,0,k)}else b|=I.COLOR_BUFFER_BIT}if(S)b|=I.DEPTH_BUFFER_BIT;if(h)b|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);I.clear(b)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){Q.removeEventListener("webglcontextlost",HJ,!1),Q.removeEventListener("webglcontextrestored",QJ,!1),Q.removeEventListener("webglcontextcreationerror",NJ,!1),kJ.dispose(),o.dispose(),p.dispose(),DJ.dispose(),V0.dispose(),D0.dispose(),R.dispose(),VJ.dispose(),KJ.dispose(),f.dispose(),P.dispose(),P.removeEventListener("sessionstart",H8),P.removeEventListener("sessionend",Y8),t8.stop()};function HJ(D){D.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function QJ(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;let D=X0.autoReset,S=JJ.enabled,h=JJ.autoUpdate,b=JJ.needsUpdate,y=JJ.type;bJ(),X0.autoReset=D,JJ.enabled=S,JJ.autoUpdate=h,JJ.needsUpdate=b,JJ.type=y}function NJ(D){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function a(D){let S=D.target;S.removeEventListener("dispose",a),s(S)}function s(D){FJ(D),DJ.remove(D)}function FJ(D){let S=DJ.get(D).programs;if(S!==void 0){if(S.forEach(function(h){f.releaseProgram(h)}),D.isShaderMaterial)f.releaseShaderCache(D)}}this.renderBufferDirect=function(D,S,h,b,y,t){if(S===null)S=uJ;let YJ=y.isMesh&&y.matrixWorld.determinant()<0,OJ=zY(D,S,h,b,y);zJ.setMaterial(b,YJ);let qJ=h.index,IJ=1;if(b.wireframe===!0){if(qJ=B.getWireframeAttribute(h),qJ===void 0)return;IJ=2}let SJ=h.drawRange,BJ=h.attributes.position,pJ=SJ.start*IJ,tJ=(SJ.start+SJ.count)*IJ;if(t!==null)pJ=Math.max(pJ,t.start*IJ),tJ=Math.min(tJ,(t.start+t.count)*IJ);if(qJ!==null)pJ=Math.max(pJ,0),tJ=Math.min(tJ,qJ.count);else if(BJ!==void 0&&BJ!==null)pJ=Math.max(pJ,0),tJ=Math.min(tJ,BJ.count);let G0=tJ-pJ;if(G0<0||G0===1/0)return;VJ.setup(y,b,OJ,h,qJ);let H0,Q0=e;if(qJ!==null)H0=N0.get(qJ),Q0=XJ,Q0.setIndex(H0);if(y.isMesh)if(b.wireframe===!0)zJ.setLineWidth(b.wireframeLinewidth*dJ()),Q0.setMode(I.LINES);else Q0.setMode(I.TRIANGLES);else if(y.isLine){let _J=b.linewidth;if(_J===void 0)_J=1;if(zJ.setLineWidth(_J*dJ()),y.isLineSegments)Q0.setMode(I.LINES);else if(y.isLineLoop)Q0.setMode(I.LINE_LOOP);else Q0.setMode(I.LINE_STRIP)}else if(y.isPoints)Q0.setMode(I.POINTS);else if(y.isSprite)Q0.setMode(I.TRIANGLES);if(y.isBatchedMesh)if(y._multiDrawInstances!==null)H9("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Q0.renderMultiDrawInstances(y._multiDrawStarts,y._multiDrawCounts,y._multiDrawCount,y._multiDrawInstances);else if(!CJ.get("WEBGL_multi_draw")){let{_multiDrawStarts:_J,_multiDrawCounts:K0,_multiDrawCount:nJ}=y,f0=qJ?N0.get(qJ).bytesPerElement:1,M9=DJ.get(b).currentProgram.getUniforms();for(let h0=0;h0<nJ;h0++)M9.setValue(I,"_gl_DrawID",h0),Q0.render(_J[h0]/f0,K0[h0])}else Q0.renderMultiDraw(y._multiDrawStarts,y._multiDrawCounts,y._multiDrawCount);else if(y.isInstancedMesh)Q0.renderInstances(pJ,G0,y.count);else if(h.isInstancedBufferGeometry){let _J=h._maxInstanceCount!==void 0?h._maxInstanceCount:1/0,K0=Math.min(h.instanceCount,_J);Q0.renderInstances(pJ,G0,K0)}else Q0.render(pJ,G0)};function yJ(D,S,h){if(D.transparent===!0&&D.side===j0&&D.forceSinglePass===!1)D.side=g0,D.needsUpdate=!0,f6(D,S,h),D.side=d8,D.needsUpdate=!0,f6(D,S,h),D.side=j0;else f6(D,S,h)}this.compile=function(D,S,h=null){if(h===null)h=D;if(N=p.get(h),N.init(S),C.push(N),h.traverseVisible(function(y){if(y.isLight&&y.layers.test(S.layers)){if(N.pushLight(y),y.castShadow)N.pushShadow(y)}}),D!==h)D.traverseVisible(function(y){if(y.isLight&&y.layers.test(S.layers)){if(N.pushLight(y),y.castShadow)N.pushShadow(y)}});N.setupLights();let b=new Set;return D.traverse(function(y){if(!(y.isMesh||y.isPoints||y.isLine||y.isSprite))return;let t=y.material;if(t)if(Array.isArray(t))for(let YJ=0;YJ<t.length;YJ++){let OJ=t[YJ];yJ(OJ,h,y),b.add(OJ)}else yJ(t,h,y),b.add(t)}),N=C.pop(),b},this.compileAsync=function(D,S,h=null){let b=this.compile(D,S,h);return new Promise((y)=>{function t(){if(b.forEach(function(YJ){if(DJ.get(YJ).currentProgram.isReady())b.delete(YJ)}),b.size===0){y(D);return}setTimeout(t,10)}if(CJ.get("KHR_parallel_shader_compile")!==null)t();else setTimeout(t,10)})};let J0=null;function rJ(D){if(J0)J0(D)}function H8(){t8.stop()}function Y8(){t8.start()}let t8=new SH;if(t8.setAnimationLoop(rJ),typeof self<"u")t8.setContext(self);this.setAnimationLoop=function(D){J0=D,P.setAnimationLoop(D),D===null?t8.stop():t8.start()},P.addEventListener("sessionstart",H8),P.addEventListener("sessionend",Y8),this.render=function(D,S){if(S!==void 0&&S.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(S.parent===null&&S.matrixWorldAutoUpdate===!0)S.updateMatrixWorld();if(P.enabled===!0&&P.isPresenting===!0){if(P.cameraAutoUpdate===!0)P.updateCamera(S);S=P.getCamera()}if(D.isScene===!0)D.onBeforeRender(L,D,S,T);if(N=p.get(D,C.length),N.init(S),C.push(N),MJ.multiplyMatrices(S.projectionMatrix,S.matrixWorldInverse),Y0.setFromProjectionMatrix(MJ,B$,S.reversedDepth),WJ=this.localClippingEnabled,d=EJ.init(this.clippingPlanes,WJ),M=o.get(D,F.length),M.init(),F.push(M),P.enabled===!0&&P.isPresenting===!0){let t=L.xr.getDepthSensingMesh();if(t!==null)HQ(t,S,-1/0,L.sortObjects)}if(HQ(D,S,0,L.sortObjects),M.finish(),L.sortObjects===!0)M.sort(g,ZJ);if(cJ=P.enabled===!1||P.isPresenting===!1||P.hasDepthSensing()===!1,cJ)kJ.addToRenderList(M,D);if(this.info.render.frame++,d===!0)EJ.beginShadows();let h=N.state.shadowsArray;if(JJ.render(h,D,S),d===!0)EJ.endShadows();if(this.info.autoReset===!0)this.info.reset();let{opaque:b,transmissive:y}=M;if(N.setupLights(),S.isArrayCamera){let t=S.cameras;if(y.length>0)for(let YJ=0,OJ=t.length;YJ<OJ;YJ++){let qJ=t[YJ];OZ(b,y,D,qJ)}if(cJ)kJ.render(D);for(let YJ=0,OJ=t.length;YJ<OJ;YJ++){let qJ=t[YJ];NZ(M,D,qJ,qJ.viewport)}}else{if(y.length>0)OZ(b,y,D,S);if(cJ)kJ.render(D);NZ(M,D,S)}if(T!==null&&w===0)wJ.updateMultisampleRenderTarget(T),wJ.updateRenderTargetMipmap(T);if(D.isScene===!0)D.onAfterRender(L,D,S);if(VJ.resetDefaultState(),x=-1,z=null,C.pop(),C.length>0){if(N=C[C.length-1],d===!0)EJ.setGlobalState(L.clippingPlanes,N.state.camera)}else N=null;if(F.pop(),F.length>0)M=F[F.length-1];else M=null};function HQ(D,S,h,b){if(D.visible===!1)return;if(D.layers.test(S.layers)){if(D.isGroup)h=D.renderOrder;else if(D.isLOD){if(D.autoUpdate===!0)D.update(S)}else if(D.isLight){if(N.pushLight(D),D.castShadow)N.pushShadow(D)}else if(D.isSprite){if(!D.frustumCulled||Y0.intersectsSprite(D)){if(b)RJ.setFromMatrixPosition(D.matrixWorld).applyMatrix4(MJ);let YJ=R.update(D),OJ=D.material;if(OJ.visible)M.push(D,YJ,OJ,h,RJ.z,null)}}else if(D.isMesh||D.isLine||D.isPoints){if(!D.frustumCulled||Y0.intersectsObject(D)){let YJ=R.update(D),OJ=D.material;if(b){if(D.boundingSphere!==void 0){if(D.boundingSphere===null)D.computeBoundingSphere();RJ.copy(D.boundingSphere.center)}else{if(YJ.boundingSphere===null)YJ.computeBoundingSphere();RJ.copy(YJ.boundingSphere.center)}RJ.applyMatrix4(D.matrixWorld).applyMatrix4(MJ)}if(Array.isArray(OJ)){let qJ=YJ.groups;for(let IJ=0,SJ=qJ.length;IJ<SJ;IJ++){let BJ=qJ[IJ],pJ=OJ[BJ.materialIndex];if(pJ&&pJ.visible)M.push(D,YJ,pJ,h,RJ.z,BJ)}}else if(OJ.visible)M.push(D,YJ,OJ,h,RJ.z,null)}}}let t=D.children;for(let YJ=0,OJ=t.length;YJ<OJ;YJ++)HQ(t[YJ],S,h,b)}function NZ(D,S,h,b){let{opaque:y,transmissive:t,transparent:YJ}=D;if(N.setupLightsView(h),d===!0)EJ.setGlobalState(L.clippingPlanes,h);if(b)zJ.viewport(V.copy(b));if(y.length>0)v6(y,S,h);if(t.length>0)v6(t,S,h);if(YJ.length>0)v6(YJ,S,h);zJ.buffers.depth.setTest(!0),zJ.buffers.depth.setMask(!0),zJ.buffers.color.setMask(!0),zJ.setPolygonOffset(!1)}function OZ(D,S,h,b){if((h.isScene===!0?h.overrideMaterial:null)!==null)return;if(N.state.transmissionRenderTarget[b.id]===void 0)N.state.transmissionRenderTarget[b.id]=new T8(1,1,{generateMipmaps:!0,type:CJ.has("EXT_color_buffer_half_float")||CJ.has("EXT_color_buffer_float")?R6:u8,minFilter:I8,samples:4,stencilBuffer:W,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:lJ.workingColorSpace});let t=N.state.transmissionRenderTarget[b.id],YJ=b.viewport||V;t.setSize(YJ.z*L.transmissionResolutionScale,YJ.w*L.transmissionResolutionScale);let OJ=L.getRenderTarget(),qJ=L.getActiveCubeFace(),IJ=L.getActiveMipmapLevel();if(L.setRenderTarget(t),L.getClearColor(l),c=L.getClearAlpha(),c<1)L.setClearColor(16777215,0.5);if(L.clear(),cJ)kJ.render(h);let SJ=L.toneMapping;L.toneMapping=_8;let BJ=b.viewport;if(b.viewport!==void 0)b.viewport=void 0;if(N.setupLightsView(b),d===!0)EJ.setGlobalState(L.clippingPlanes,b);if(v6(D,h,b),wJ.updateMultisampleRenderTarget(t),wJ.updateRenderTargetMipmap(t),CJ.has("WEBGL_multisampled_render_to_texture")===!1){let pJ=!1;for(let tJ=0,G0=S.length;tJ<G0;tJ++){let H0=S[tJ],Q0=H0.object,_J=H0.geometry,K0=H0.material,nJ=H0.group;if(K0.side===j0&&Q0.layers.test(b.layers)){let f0=K0.side;K0.side=g0,K0.needsUpdate=!0,FZ(Q0,h,b,_J,K0,nJ),K0.side=f0,K0.needsUpdate=!0,pJ=!0}}if(pJ===!0)wJ.updateMultisampleRenderTarget(t),wJ.updateRenderTargetMipmap(t)}if(L.setRenderTarget(OJ,qJ,IJ),L.setClearColor(l,c),BJ!==void 0)b.viewport=BJ;L.toneMapping=SJ}function v6(D,S,h){let b=S.isScene===!0?S.overrideMaterial:null;for(let y=0,t=D.length;y<t;y++){let YJ=D[y],OJ=YJ.object,qJ=YJ.geometry,IJ=YJ.group,SJ=YJ.material;if(SJ.allowOverride===!0&&b!==null)SJ=b;if(OJ.layers.test(h.layers))FZ(OJ,S,h,qJ,SJ,IJ)}}function FZ(D,S,h,b,y,t){if(D.onBeforeRender(L,S,h,b,y,t),D.modelViewMatrix.multiplyMatrices(h.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),y.onBeforeRender(L,S,h,b,D,t),y.transparent===!0&&y.side===j0&&y.forceSinglePass===!1)y.side=g0,y.needsUpdate=!0,L.renderBufferDirect(h,S,b,y,D,t),y.side=d8,y.needsUpdate=!0,L.renderBufferDirect(h,S,b,y,D,t),y.side=j0;else L.renderBufferDirect(h,S,b,y,D,t);D.onAfterRender(L,S,h,b,y,t)}function f6(D,S,h){if(S.isScene!==!0)S=uJ;let b=DJ.get(D),y=N.state.lights,t=N.state.shadowsArray,YJ=y.state.version,OJ=f.getParameters(D,y.state,t,S,h),qJ=f.getProgramCacheKey(OJ),IJ=b.programs;if(b.environment=D.isMeshStandardMaterial?S.environment:null,b.fog=S.fog,b.envMap=(D.isMeshStandardMaterial?D0:V0).get(D.envMap||b.environment),b.envMapRotation=b.environment!==null&&D.envMap===null?S.environmentRotation:D.envMapRotation,IJ===void 0)D.addEventListener("dispose",a),IJ=new Map,b.programs=IJ;let SJ=IJ.get(qJ);if(SJ!==void 0){if(b.currentProgram===SJ&&b.lightsStateVersion===YJ)return kZ(D,OJ),SJ}else OJ.uniforms=f.getUniforms(D),D.onBeforeCompile(OJ,L),SJ=f.acquireProgram(OJ,qJ),IJ.set(qJ,SJ),b.uniforms=OJ.uniforms;let BJ=b.uniforms;if(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)BJ.clippingPlanes=EJ.uniform;if(kZ(D,OJ),b.needsLights=CY(D),b.lightsStateVersion=YJ,b.needsLights)BJ.ambientLightColor.value=y.state.ambient,BJ.lightProbe.value=y.state.probe,BJ.directionalLights.value=y.state.directional,BJ.directionalLightShadows.value=y.state.directionalShadow,BJ.spotLights.value=y.state.spot,BJ.spotLightShadows.value=y.state.spotShadow,BJ.rectAreaLights.value=y.state.rectArea,BJ.ltc_1.value=y.state.rectAreaLTC1,BJ.ltc_2.value=y.state.rectAreaLTC2,BJ.pointLights.value=y.state.point,BJ.pointLightShadows.value=y.state.pointShadow,BJ.hemisphereLights.value=y.state.hemi,BJ.directionalShadowMap.value=y.state.directionalShadowMap,BJ.directionalShadowMatrix.value=y.state.directionalShadowMatrix,BJ.spotShadowMap.value=y.state.spotShadowMap,BJ.spotLightMatrix.value=y.state.spotLightMatrix,BJ.spotLightMap.value=y.state.spotLightMap,BJ.pointShadowMap.value=y.state.pointShadowMap,BJ.pointShadowMatrix.value=y.state.pointShadowMatrix;return b.currentProgram=SJ,b.uniformsList=null,SJ}function RZ(D){if(D.uniformsList===null){let S=D.currentProgram.getUniforms();D.uniformsList=j6.seqWithValue(S.seq,D.uniforms)}return D.uniformsList}function kZ(D,S){let h=DJ.get(D);h.outputColorSpace=S.outputColorSpace,h.batching=S.batching,h.batchingColor=S.batchingColor,h.instancing=S.instancing,h.instancingColor=S.instancingColor,h.instancingMorph=S.instancingMorph,h.skinning=S.skinning,h.morphTargets=S.morphTargets,h.morphNormals=S.morphNormals,h.morphColors=S.morphColors,h.morphTargetsCount=S.morphTargetsCount,h.numClippingPlanes=S.numClippingPlanes,h.numIntersection=S.numClipIntersection,h.vertexAlphas=S.vertexAlphas,h.vertexTangents=S.vertexTangents,h.toneMapping=S.toneMapping}function zY(D,S,h,b,y){if(S.isScene!==!0)S=uJ;wJ.resetTextureUnits();let t=S.fog,YJ=b.isMeshStandardMaterial?S.environment:null,OJ=T===null?L.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:T0,qJ=(b.isMeshStandardMaterial?D0:V0).get(b.envMap||YJ),IJ=b.vertexColors===!0&&!!h.attributes.color&&h.attributes.color.itemSize===4,SJ=!!h.attributes.tangent&&(!!b.normalMap||b.anisotropy>0),BJ=!!h.morphAttributes.position,pJ=!!h.morphAttributes.normal,tJ=!!h.morphAttributes.color,G0=_8;if(b.toneMapped){if(T===null||T.isXRRenderTarget===!0)G0=L.toneMapping}let H0=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,Q0=H0!==void 0?H0.length:0,_J=DJ.get(b),K0=N.state.lights;if(d===!0){if(WJ===!0||D!==z){let I0=D===z&&b.id===x;EJ.setState(b,D,I0)}}let nJ=!1;if(b.version===_J.__version){if(_J.needsLights&&_J.lightsStateVersion!==K0.state.version)nJ=!0;else if(_J.outputColorSpace!==OJ)nJ=!0;else if(y.isBatchedMesh&&_J.batching===!1)nJ=!0;else if(!y.isBatchedMesh&&_J.batching===!0)nJ=!0;else if(y.isBatchedMesh&&_J.batchingColor===!0&&y.colorTexture===null)nJ=!0;else if(y.isBatchedMesh&&_J.batchingColor===!1&&y.colorTexture!==null)nJ=!0;else if(y.isInstancedMesh&&_J.instancing===!1)nJ=!0;else if(!y.isInstancedMesh&&_J.instancing===!0)nJ=!0;else if(y.isSkinnedMesh&&_J.skinning===!1)nJ=!0;else if(!y.isSkinnedMesh&&_J.skinning===!0)nJ=!0;else if(y.isInstancedMesh&&_J.instancingColor===!0&&y.instanceColor===null)nJ=!0;else if(y.isInstancedMesh&&_J.instancingColor===!1&&y.instanceColor!==null)nJ=!0;else if(y.isInstancedMesh&&_J.instancingMorph===!0&&y.morphTexture===null)nJ=!0;else if(y.isInstancedMesh&&_J.instancingMorph===!1&&y.morphTexture!==null)nJ=!0;else if(_J.envMap!==qJ)nJ=!0;else if(b.fog===!0&&_J.fog!==t)nJ=!0;else if(_J.numClippingPlanes!==void 0&&(_J.numClippingPlanes!==EJ.numPlanes||_J.numIntersection!==EJ.numIntersection))nJ=!0;else if(_J.vertexAlphas!==IJ)nJ=!0;else if(_J.vertexTangents!==SJ)nJ=!0;else if(_J.morphTargets!==BJ)nJ=!0;else if(_J.morphNormals!==pJ)nJ=!0;else if(_J.morphColors!==tJ)nJ=!0;else if(_J.toneMapping!==G0)nJ=!0;else if(_J.morphTargetsCount!==Q0)nJ=!0}else nJ=!0,_J.__version=b.version;let f0=_J.currentProgram;if(nJ===!0)f0=f6(b,S,y);let M9=!1,h0=!1,Q6=!1,U0=f0.getUniforms(),c0=_J.uniforms;if(zJ.useProgram(f0.program))M9=!0,h0=!0,Q6=!0;if(b.id!==x)x=b.id,h0=!0;if(M9||z!==D){if(zJ.buffers.depth.getReversed()&&D.reversedDepth!==!0)D._reversedDepth=!0,D.updateProjectionMatrix();U0.setValue(I,"projectionMatrix",D.projectionMatrix),U0.setValue(I,"viewMatrix",D.matrixWorldInverse);let S0=U0.map.cameraPosition;if(S0!==void 0)S0.setValue(I,GJ.setFromMatrixPosition(D.matrixWorld));if(iJ.logarithmicDepthBuffer)U0.setValue(I,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2));if(b.isMeshPhongMaterial||b.isMeshToonMaterial||b.isMeshLambertMaterial||b.isMeshBasicMaterial||b.isMeshStandardMaterial||b.isShaderMaterial)U0.setValue(I,"isOrthographic",D.isOrthographicCamera===!0);if(z!==D)z=D,h0=!0,Q6=!0}if(y.isSkinnedMesh){U0.setOptional(I,y,"bindMatrix"),U0.setOptional(I,y,"bindMatrixInverse");let I0=y.skeleton;if(I0){if(I0.boneTexture===null)I0.computeBoneTexture();U0.setValue(I,"boneTexture",I0.boneTexture,wJ)}}if(y.isBatchedMesh){if(U0.setOptional(I,y,"batchingTexture"),U0.setValue(I,"batchingTexture",y._matricesTexture,wJ),U0.setOptional(I,y,"batchingIdTexture"),U0.setValue(I,"batchingIdTexture",y._indirectTexture,wJ),U0.setOptional(I,y,"batchingColorTexture"),y._colorsTexture!==null)U0.setValue(I,"batchingColorTexture",y._colorsTexture,wJ)}let n0=h.morphAttributes;if(n0.position!==void 0||n0.normal!==void 0||n0.color!==void 0)AJ.update(y,h,f0);if(h0||_J.receiveShadow!==y.receiveShadow)_J.receiveShadow=y.receiveShadow,U0.setValue(I,"receiveShadow",y.receiveShadow);if(b.isMeshGouraudMaterial&&b.envMap!==null)c0.envMap.value=qJ,c0.flipEnvMap.value=qJ.isCubeTexture&&qJ.isRenderTargetTexture===!1?-1:1;if(b.isMeshStandardMaterial&&b.envMap===null&&S.environment!==null)c0.envMapIntensity.value=S.environmentIntensity;if(h0){if(U0.setValue(I,"toneMappingExposure",L.toneMappingExposure),_J.needsLights)BY(c0,Q6);if(t&&b.fog===!0)n.refreshFogUniforms(c0,t);n.refreshMaterialUniforms(c0,b,r,u,N.state.transmissionRenderTarget[D.id]),j6.upload(I,RZ(_J),c0,wJ)}if(b.isShaderMaterial&&b.uniformsNeedUpdate===!0)j6.upload(I,RZ(_J),c0,wJ),b.uniformsNeedUpdate=!1;if(b.isSpriteMaterial)U0.setValue(I,"center",y.center);if(U0.setValue(I,"modelViewMatrix",y.modelViewMatrix),U0.setValue(I,"normalMatrix",y.normalMatrix),U0.setValue(I,"modelMatrix",y.matrixWorld),b.isShaderMaterial||b.isRawShaderMaterial){let I0=b.uniformsGroups;for(let S0=0,YQ=I0.length;S0<YQ;S0++){let e8=I0[S0];KJ.update(e8,f0),KJ.bind(e8,f0)}}return f0}function BY(D,S){D.ambientLightColor.needsUpdate=S,D.lightProbe.needsUpdate=S,D.directionalLights.needsUpdate=S,D.directionalLightShadows.needsUpdate=S,D.pointLights.needsUpdate=S,D.pointLightShadows.needsUpdate=S,D.spotLights.needsUpdate=S,D.spotLightShadows.needsUpdate=S,D.rectAreaLights.needsUpdate=S,D.hemisphereLights.needsUpdate=S}function CY(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(D,S,h){let b=DJ.get(D);if(b.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,b.__autoAllocateDepthBuffer===!1)b.__useRenderToTexture=!1;DJ.get(D.texture).__webglTexture=S,DJ.get(D.depthTexture).__webglTexture=b.__autoAllocateDepthBuffer?void 0:h,b.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,S){let h=DJ.get(D);h.__webglFramebuffer=S,h.__useDefaultFramebuffer=S===void 0};let _Y=I.createFramebuffer();this.setRenderTarget=function(D,S=0,h=0){T=D,v=S,w=h;let b=!0,y=null,t=!1,YJ=!1;if(D){let qJ=DJ.get(D);if(qJ.__useDefaultFramebuffer!==void 0)zJ.bindFramebuffer(I.FRAMEBUFFER,null),b=!1;else if(qJ.__webglFramebuffer===void 0)wJ.setupRenderTarget(D);else if(qJ.__hasExternalTextures)wJ.rebindTextures(D,DJ.get(D.texture).__webglTexture,DJ.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){let BJ=D.depthTexture;if(qJ.__boundDepthTexture!==BJ){if(BJ!==null&&DJ.has(BJ)&&(D.width!==BJ.image.width||D.height!==BJ.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");wJ.setupDepthRenderbuffer(D)}}let IJ=D.texture;if(IJ.isData3DTexture||IJ.isDataArrayTexture||IJ.isCompressedArrayTexture)YJ=!0;let SJ=DJ.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget){if(Array.isArray(SJ[S]))y=SJ[S][h];else y=SJ[S];t=!0}else if(D.samples>0&&wJ.useMultisampledRTT(D)===!1)y=DJ.get(D).__webglMultisampledFramebuffer;else if(Array.isArray(SJ))y=SJ[h];else y=SJ;V.copy(D.viewport),j.copy(D.scissor),m=D.scissorTest}else V.copy(UJ).multiplyScalar(r).floor(),j.copy(TJ).multiplyScalar(r).floor(),m=mJ;if(h!==0)y=_Y;if(zJ.bindFramebuffer(I.FRAMEBUFFER,y)&&b)zJ.drawBuffers(D,y);if(zJ.viewport(V),zJ.scissor(j),zJ.setScissorTest(m),t){let qJ=DJ.get(D.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+S,qJ.__webglTexture,h)}else if(YJ){let qJ=S;for(let IJ=0;IJ<D.textures.length;IJ++){let SJ=DJ.get(D.textures[IJ]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+IJ,SJ.__webglTexture,h,qJ)}}else if(D!==null&&h!==0){let qJ=DJ.get(D.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,qJ.__webglTexture,h)}x=-1},this.readRenderTargetPixels=function(D,S,h,b,y,t,YJ,OJ=0){if(!(D&&D.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let qJ=DJ.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&YJ!==void 0)qJ=qJ[YJ];if(qJ){zJ.bindFramebuffer(I.FRAMEBUFFER,qJ);try{let IJ=D.textures[OJ],SJ=IJ.format,BJ=IJ.type;if(!iJ.textureFormatReadable(SJ)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!iJ.textureTypeReadable(BJ)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(S>=0&&S<=D.width-b&&(h>=0&&h<=D.height-y)){if(D.textures.length>1)I.readBuffer(I.COLOR_ATTACHMENT0+OJ);I.readPixels(S,h,b,y,LJ.convert(SJ),LJ.convert(BJ),t)}}finally{let IJ=T!==null?DJ.get(T).__webglFramebuffer:null;zJ.bindFramebuffer(I.FRAMEBUFFER,IJ)}}},this.readRenderTargetPixelsAsync=async function(D,S,h,b,y,t,YJ,OJ=0){if(!(D&&D.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let qJ=DJ.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&YJ!==void 0)qJ=qJ[YJ];if(qJ)if(S>=0&&S<=D.width-b&&(h>=0&&h<=D.height-y)){zJ.bindFramebuffer(I.FRAMEBUFFER,qJ);let IJ=D.textures[OJ],SJ=IJ.format,BJ=IJ.type;if(!iJ.textureFormatReadable(SJ))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!iJ.textureTypeReadable(BJ))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let pJ=I.createBuffer();if(I.bindBuffer(I.PIXEL_PACK_BUFFER,pJ),I.bufferData(I.PIXEL_PACK_BUFFER,t.byteLength,I.STREAM_READ),D.textures.length>1)I.readBuffer(I.COLOR_ATTACHMENT0+OJ);I.readPixels(S,h,b,y,LJ.convert(SJ),LJ.convert(BJ),0);let tJ=T!==null?DJ.get(T).__webglFramebuffer:null;zJ.bindFramebuffer(I.FRAMEBUFFER,tJ);let G0=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await tW(I,G0,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,pJ),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,t),I.deleteBuffer(pJ),I.deleteSync(G0),t}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,S=null,h=0){let b=Math.pow(2,-h),y=Math.floor(D.image.width*b),t=Math.floor(D.image.height*b),YJ=S!==null?S.x:0,OJ=S!==null?S.y:0;wJ.setTexture2D(D,0),I.copyTexSubImage2D(I.TEXTURE_2D,h,0,0,YJ,OJ,y,t),zJ.unbindTexture()};let wY=I.createFramebuffer(),IY=I.createFramebuffer();if(this.copyTextureToTexture=function(D,S,h=null,b=null,y=0,t=null){if(t===null)if(y!==0)H9("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),t=y,y=0;else t=0;let YJ,OJ,qJ,IJ,SJ,BJ,pJ,tJ,G0,H0=D.isCompressedTexture?D.mipmaps[t]:D.image;if(h!==null)YJ=h.max.x-h.min.x,OJ=h.max.y-h.min.y,qJ=h.isBox3?h.max.z-h.min.z:1,IJ=h.min.x,SJ=h.min.y,BJ=h.isBox3?h.min.z:0;else{let n0=Math.pow(2,-y);if(YJ=Math.floor(H0.width*n0),OJ=Math.floor(H0.height*n0),D.isDataArrayTexture)qJ=H0.depth;else if(D.isData3DTexture)qJ=Math.floor(H0.depth*n0);else qJ=1;IJ=0,SJ=0,BJ=0}if(b!==null)pJ=b.x,tJ=b.y,G0=b.z;else pJ=0,tJ=0,G0=0;let Q0=LJ.convert(S.format),_J=LJ.convert(S.type),K0;if(S.isData3DTexture)wJ.setTexture3D(S,0),K0=I.TEXTURE_3D;else if(S.isDataArrayTexture||S.isCompressedArrayTexture)wJ.setTexture2DArray(S,0),K0=I.TEXTURE_2D_ARRAY;else wJ.setTexture2D(S,0),K0=I.TEXTURE_2D;I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,S.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,S.unpackAlignment);let nJ=I.getParameter(I.UNPACK_ROW_LENGTH),f0=I.getParameter(I.UNPACK_IMAGE_HEIGHT),M9=I.getParameter(I.UNPACK_SKIP_PIXELS),h0=I.getParameter(I.UNPACK_SKIP_ROWS),Q6=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,H0.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,H0.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,IJ),I.pixelStorei(I.UNPACK_SKIP_ROWS,SJ),I.pixelStorei(I.UNPACK_SKIP_IMAGES,BJ);let U0=D.isDataArrayTexture||D.isData3DTexture,c0=S.isDataArrayTexture||S.isData3DTexture;if(D.isDepthTexture){let n0=DJ.get(D),I0=DJ.get(S),S0=DJ.get(n0.__renderTarget),YQ=DJ.get(I0.__renderTarget);zJ.bindFramebuffer(I.READ_FRAMEBUFFER,S0.__webglFramebuffer),zJ.bindFramebuffer(I.DRAW_FRAMEBUFFER,YQ.__webglFramebuffer);for(let e8=0;e8<qJ;e8++){if(U0)I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,DJ.get(D).__webglTexture,y,BJ+e8),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,DJ.get(S).__webglTexture,t,G0+e8);I.blitFramebuffer(IJ,SJ,YJ,OJ,pJ,tJ,YJ,OJ,I.DEPTH_BUFFER_BIT,I.NEAREST)}zJ.bindFramebuffer(I.READ_FRAMEBUFFER,null),zJ.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(y!==0||D.isRenderTargetTexture||DJ.has(D)){let n0=DJ.get(D),I0=DJ.get(S);zJ.bindFramebuffer(I.READ_FRAMEBUFFER,wY),zJ.bindFramebuffer(I.DRAW_FRAMEBUFFER,IY);for(let S0=0;S0<qJ;S0++){if(U0)I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,n0.__webglTexture,y,BJ+S0);else I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,n0.__webglTexture,y);if(c0)I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I0.__webglTexture,t,G0+S0);else I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,I0.__webglTexture,t);if(y!==0)I.blitFramebuffer(IJ,SJ,YJ,OJ,pJ,tJ,YJ,OJ,I.COLOR_BUFFER_BIT,I.NEAREST);else if(c0)I.copyTexSubImage3D(K0,t,pJ,tJ,G0+S0,IJ,SJ,YJ,OJ);else I.copyTexSubImage2D(K0,t,pJ,tJ,IJ,SJ,YJ,OJ)}zJ.bindFramebuffer(I.READ_FRAMEBUFFER,null),zJ.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(c0)if(D.isDataTexture||D.isData3DTexture)I.texSubImage3D(K0,t,pJ,tJ,G0,YJ,OJ,qJ,Q0,_J,H0.data);else if(S.isCompressedArrayTexture)I.compressedTexSubImage3D(K0,t,pJ,tJ,G0,YJ,OJ,qJ,Q0,H0.data);else I.texSubImage3D(K0,t,pJ,tJ,G0,YJ,OJ,qJ,Q0,_J,H0);else if(D.isDataTexture)I.texSubImage2D(I.TEXTURE_2D,t,pJ,tJ,YJ,OJ,Q0,_J,H0.data);else if(D.isCompressedTexture)I.compressedTexSubImage2D(I.TEXTURE_2D,t,pJ,tJ,H0.width,H0.height,Q0,H0.data);else I.texSubImage2D(I.TEXTURE_2D,t,pJ,tJ,YJ,OJ,Q0,_J,H0);if(I.pixelStorei(I.UNPACK_ROW_LENGTH,nJ),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,f0),I.pixelStorei(I.UNPACK_SKIP_PIXELS,M9),I.pixelStorei(I.UNPACK_SKIP_ROWS,h0),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Q6),t===0&&S.generateMipmaps)I.generateMipmap(K0);zJ.unbindTexture()},this.copyTextureToTexture3D=function(D,S,h=null,b=null,y=0){return H9('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(D,S,h,b,y)},this.initRenderTarget=function(D){if(DJ.get(D).__webglFramebuffer===void 0)wJ.setupRenderTarget(D)},this.initTexture=function(D){if(D.isCubeTexture)wJ.setTextureCube(D,0);else if(D.isData3DTexture)wJ.setTexture3D(D,0);else if(D.isDataArrayTexture||D.isCompressedArrayTexture)wJ.setTexture2DArray(D,0);else wJ.setTexture2D(D,0);zJ.unbindTexture()},this.resetState=function(){v=0,w=0,T=null,zJ.reset(),VJ.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return B$}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(J){this._outputColorSpace=J;let Q=this.getContext();Q.drawingBufferColorSpace=lJ._getDrawingBufferColorSpace(J),Q.unpackColorSpace=lJ._getUnpackColorSpace()}}var mH={type:"change"},$Z={type:"start"},cH={type:"end"},QQ=new n8,uH=new J8,$1=Math.cos(70*D6.DEG2RAD),M0=new A,v0=2*Math.PI,eJ={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},QZ=0.000001;class ZZ extends a7{constructor(J,Q=null){super(J,Q);if(this.state=eJ.NONE,this.target=new A,this.cursor=new A,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=0.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:p8.ROTATE,MIDDLE:p8.DOLLY,RIGHT:p8.PAN},this.touches={ONE:l8.ROTATE,TWO:l8.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new A,this._lastQuaternion=new y0,this._lastTargetPosition=new A,this._quat=new y0().setFromUnitVectors(J.up,new A(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new A6,this._sphericalDelta=new A6,this._scale=1,this._panOffset=new A,this._rotateStart=new PJ,this._rotateEnd=new PJ,this._rotateDelta=new PJ,this._panStart=new PJ,this._panEnd=new PJ,this._panDelta=new PJ,this._dollyStart=new PJ,this._dollyEnd=new PJ,this._dollyDelta=new PJ,this._dollyDirection=new A,this._mouse=new PJ,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=W1.bind(this),this._onPointerDown=Z1.bind(this),this._onPointerUp=H1.bind(this),this._onContextMenu=E1.bind(this),this._onMouseWheel=K1.bind(this),this._onKeyDown=U1.bind(this),this._onTouchStart=G1.bind(this),this._onTouchMove=q1.bind(this),this._onMouseDown=Y1.bind(this),this._onMouseMove=X1.bind(this),this._interceptControlDown=N1.bind(this),this._interceptControlUp=O1.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}connect(J){super.connect(J),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(J){J.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=J}stopListenToKeyEvents(){if(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(mH),this.update(),this.state=eJ.NONE}update(J=null){let Q=this.object.position;if(M0.copy(Q).sub(this.target),M0.applyQuaternion(this._quat),this._spherical.setFromVector3(M0),this.autoRotate&&this.state===eJ.NONE)this._rotateLeft(this._getAutoRotationAngle(J));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let $=this.minAzimuthAngle,Z=this.maxAzimuthAngle;if(isFinite($)&&isFinite(Z)){if($<-Math.PI)$+=v0;else if($>Math.PI)$-=v0;if(Z<-Math.PI)Z+=v0;else if(Z>Math.PI)Z-=v0;if($<=Z)this._spherical.theta=Math.max($,Math.min(Z,this._spherical.theta));else this._spherical.theta=this._spherical.theta>($+Z)/2?Math.max($,this._spherical.theta):Math.min(Z,this._spherical.theta)}if(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);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let W=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let H=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),W=H!=this._spherical.radius}if(M0.setFromSpherical(this._spherical),M0.applyQuaternion(this._quatInverse),Q.copy(this.target).add(M0),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);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let H=null;if(this.object.isPerspectiveCamera){let Y=M0.length();H=this._clampDistance(Y*this._scale);let X=Y-H;this.object.position.addScaledVector(this._dollyDirection,X),this.object.updateMatrixWorld(),W=!!X}else if(this.object.isOrthographicCamera){let Y=new A(this._mouse.x,this._mouse.y,0);Y.unproject(this.object);let X=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),W=X!==this.object.zoom;let K=new A(this._mouse.x,this._mouse.y,0);K.unproject(this.object),this.object.position.sub(K).add(Y),this.object.updateMatrixWorld(),H=M0.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(H!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(H).add(this.object.position);else if(QQ.origin.copy(this.object.position),QQ.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(QQ.direction))<$1)this.object.lookAt(this.target);else uH.setFromNormalAndCoplanarPoint(this.object.up,this.target),QQ.intersectPlane(uH,this.target)}else if(this.object.isOrthographicCamera){let H=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),H!==this.object.zoom)this.object.updateProjectionMatrix(),W=!0}if(this._scale=1,this._performCursorZoom=!1,W||this._lastPosition.distanceToSquared(this.object.position)>QZ||8*(1-this._lastQuaternion.dot(this.object.quaternion))>QZ||this._lastTargetPosition.distanceToSquared(this.target)>QZ)return this.dispatchEvent(mH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(J){if(J!==null)return v0/60*this.autoRotateSpeed*J;else return v0/60/60*this.autoRotateSpeed}_getZoomScale(J){let Q=Math.abs(J*0.01);return Math.pow(0.95,this.zoomSpeed*Q)}_rotateLeft(J){this._sphericalDelta.theta-=J}_rotateUp(J){this._sphericalDelta.phi-=J}_panLeft(J,Q){M0.setFromMatrixColumn(Q,0),M0.multiplyScalar(-J),this._panOffset.add(M0)}_panUp(J,Q){if(this.screenSpacePanning===!0)M0.setFromMatrixColumn(Q,1);else M0.setFromMatrixColumn(Q,0),M0.crossVectors(this.object.up,M0);M0.multiplyScalar(J),this._panOffset.add(M0)}_pan(J,Q){let $=this.domElement;if(this.object.isPerspectiveCamera){let Z=this.object.position;M0.copy(Z).sub(this.target);let W=M0.length();W*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*J*W/$.clientHeight,this.object.matrix),this._panUp(2*Q*W/$.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(J*(this.object.right-this.object.left)/this.object.zoom/$.clientWidth,this.object.matrix),this._panUp(Q*(this.object.top-this.object.bottom)/this.object.zoom/$.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(J){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=J;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(J){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=J;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(J,Q){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let $=this.domElement.getBoundingClientRect(),Z=J-$.left,W=Q-$.top,H=$.width,Y=$.height;this._mouse.x=Z/H*2-1,this._mouse.y=-(W/Y)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(J){return Math.max(this.minDistance,Math.min(this.maxDistance,J))}_handleMouseDownRotate(J){this._rotateStart.set(J.clientX,J.clientY)}_handleMouseDownDolly(J){this._updateZoomParameters(J.clientX,J.clientX),this._dollyStart.set(J.clientX,J.clientY)}_handleMouseDownPan(J){this._panStart.set(J.clientX,J.clientY)}_handleMouseMoveRotate(J){this._rotateEnd.set(J.clientX,J.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let Q=this.domElement;this._rotateLeft(v0*this._rotateDelta.x/Q.clientHeight),this._rotateUp(v0*this._rotateDelta.y/Q.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(J){if(this._dollyEnd.set(J.clientX,J.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(J){this._panEnd.set(J.clientX,J.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(J){if(this._updateZoomParameters(J.clientX,J.clientY),J.deltaY<0)this._dollyIn(this._getZoomScale(J.deltaY));else if(J.deltaY>0)this._dollyOut(this._getZoomScale(J.deltaY));this.update()}_handleKeyDown(J){let Q=!1;switch(J.code){case this.keys.UP:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enableRotate)this._rotateUp(v0*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);Q=!0;break;case this.keys.BOTTOM:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enableRotate)this._rotateUp(-v0*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);Q=!0;break;case this.keys.LEFT:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enableRotate)this._rotateLeft(v0*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);Q=!0;break;case this.keys.RIGHT:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enableRotate)this._rotateLeft(-v0*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);Q=!0;break}if(Q)J.preventDefault(),this.update()}_handleTouchStartRotate(J){if(this._pointers.length===1)this._rotateStart.set(J.pageX,J.pageY);else{let Q=this._getSecondPointerPosition(J),$=0.5*(J.pageX+Q.x),Z=0.5*(J.pageY+Q.y);this._rotateStart.set($,Z)}}_handleTouchStartPan(J){if(this._pointers.length===1)this._panStart.set(J.pageX,J.pageY);else{let Q=this._getSecondPointerPosition(J),$=0.5*(J.pageX+Q.x),Z=0.5*(J.pageY+Q.y);this._panStart.set($,Z)}}_handleTouchStartDolly(J){let Q=this._getSecondPointerPosition(J),$=J.pageX-Q.x,Z=J.pageY-Q.y,W=Math.sqrt($*$+Z*Z);this._dollyStart.set(0,W)}_handleTouchStartDollyPan(J){if(this.enableZoom)this._handleTouchStartDolly(J);if(this.enablePan)this._handleTouchStartPan(J)}_handleTouchStartDollyRotate(J){if(this.enableZoom)this._handleTouchStartDolly(J);if(this.enableRotate)this._handleTouchStartRotate(J)}_handleTouchMoveRotate(J){if(this._pointers.length==1)this._rotateEnd.set(J.pageX,J.pageY);else{let $=this._getSecondPointerPosition(J),Z=0.5*(J.pageX+$.x),W=0.5*(J.pageY+$.y);this._rotateEnd.set(Z,W)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let Q=this.domElement;this._rotateLeft(v0*this._rotateDelta.x/Q.clientHeight),this._rotateUp(v0*this._rotateDelta.y/Q.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(J){if(this._pointers.length===1)this._panEnd.set(J.pageX,J.pageY);else{let Q=this._getSecondPointerPosition(J),$=0.5*(J.pageX+Q.x),Z=0.5*(J.pageY+Q.y);this._panEnd.set($,Z)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(J){let Q=this._getSecondPointerPosition(J),$=J.pageX-Q.x,Z=J.pageY-Q.y,W=Math.sqrt($*$+Z*Z);this._dollyEnd.set(0,W),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 H=(J.pageX+Q.x)*0.5,Y=(J.pageY+Q.y)*0.5;this._updateZoomParameters(H,Y)}_handleTouchMoveDollyPan(J){if(this.enableZoom)this._handleTouchMoveDolly(J);if(this.enablePan)this._handleTouchMovePan(J)}_handleTouchMoveDollyRotate(J){if(this.enableZoom)this._handleTouchMoveDolly(J);if(this.enableRotate)this._handleTouchMoveRotate(J)}_addPointer(J){this._pointers.push(J.pointerId)}_removePointer(J){delete this._pointerPositions[J.pointerId];for(let Q=0;Q<this._pointers.length;Q++)if(this._pointers[Q]==J.pointerId){this._pointers.splice(Q,1);return}}_isTrackingPointer(J){for(let Q=0;Q<this._pointers.length;Q++)if(this._pointers[Q]==J.pointerId)return!0;return!1}_trackPointer(J){let Q=this._pointerPositions[J.pointerId];if(Q===void 0)Q=new PJ,this._pointerPositions[J.pointerId]=Q;Q.set(J.pageX,J.pageY)}_getSecondPointerPosition(J){let Q=J.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[Q]}_customWheelEvent(J){let Q=J.deltaMode,$={clientX:J.clientX,clientY:J.clientY,deltaY:J.deltaY};switch(Q){case 1:$.deltaY*=16;break;case 2:$.deltaY*=100;break}if(J.ctrlKey&&!this._controlActive)$.deltaY*=10;return $}}function Z1(J){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(J.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(J))return;if(this._addPointer(J),J.pointerType==="touch")this._onTouchStart(J);else this._onMouseDown(J)}function W1(J){if(this.enabled===!1)return;if(J.pointerType==="touch")this._onTouchMove(J);else this._onMouseMove(J)}function H1(J){switch(this._removePointer(J),this._pointers.length){case 0:this.domElement.releasePointerCapture(J.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(cH),this.state=eJ.NONE;break;case 1:let Q=this._pointers[0],$=this._pointerPositions[Q];this._onTouchStart({pointerId:Q,pageX:$.x,pageY:$.y});break}}function Y1(J){let Q;switch(J.button){case 0:Q=this.mouseButtons.LEFT;break;case 1:Q=this.mouseButtons.MIDDLE;break;case 2:Q=this.mouseButtons.RIGHT;break;default:Q=-1}switch(Q){case p8.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(J),this.state=eJ.DOLLY;break;case p8.ROTATE:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(J),this.state=eJ.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(J),this.state=eJ.ROTATE}break;case p8.PAN:if(J.ctrlKey||J.metaKey||J.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(J),this.state=eJ.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(J),this.state=eJ.PAN}break;default:this.state=eJ.NONE}if(this.state!==eJ.NONE)this.dispatchEvent($Z)}function X1(J){switch(this.state){case eJ.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(J);break;case eJ.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(J);break;case eJ.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(J);break}}function K1(J){if(this.enabled===!1||this.enableZoom===!1||this.state!==eJ.NONE)return;J.preventDefault(),this.dispatchEvent($Z),this._handleMouseWheel(this._customWheelEvent(J)),this.dispatchEvent(cH)}function U1(J){if(this.enabled===!1)return;this._handleKeyDown(J)}function G1(J){switch(this._trackPointer(J),this._pointers.length){case 1:switch(this.touches.ONE){case l8.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(J),this.state=eJ.TOUCH_ROTATE;break;case l8.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(J),this.state=eJ.TOUCH_PAN;break;default:this.state=eJ.NONE}break;case 2:switch(this.touches.TWO){case l8.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(J),this.state=eJ.TOUCH_DOLLY_PAN;break;case l8.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(J),this.state=eJ.TOUCH_DOLLY_ROTATE;break;default:this.state=eJ.NONE}break;default:this.state=eJ.NONE}if(this.state!==eJ.NONE)this.dispatchEvent($Z)}function q1(J){switch(this._trackPointer(J),this.state){case eJ.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(J),this.update();break;case eJ.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(J),this.update();break;case eJ.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(J),this.update();break;case eJ.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(J),this.update();break;default:this.state=eJ.NONE}}function E1(J){if(this.enabled===!1)return;J.preventDefault()}function N1(J){if(J.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function O1(J){if(J.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function WZ(J,Q){if(Q===D$)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),J;if(Q===l9||Q===M6){let $=J.getIndex();if($===null){let Y=[],X=J.getAttribute("position");if(X!==void 0){for(let K=0;K<X.count;K++)Y.push(K);J.setIndex(Y),$=J.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),J}let Z=$.count-2,W=[];if(Q===l9)for(let Y=1;Y<=Z;Y++)W.push($.getX(0)),W.push($.getX(Y)),W.push($.getX(Y+1));else for(let Y=0;Y<Z;Y++)if(Y%2===0)W.push($.getX(Y)),W.push($.getX(Y+1)),W.push($.getX(Y+2));else W.push($.getX(Y+2)),W.push($.getX(Y+1)),W.push($.getX(Y));if(W.length/3!==Z)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let H=J.clone();return H.setIndex(W),H.clearGroups(),H}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",Q),J}class GZ extends S8{constructor(J){super(J);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(Q){return new eH(Q)}),this.register(function(Q){return new JY(Q)}),this.register(function(Q){return new UY(Q)}),this.register(function(Q){return new GY(Q)}),this.register(function(Q){return new qY(Q)}),this.register(function(Q){return new $Y(Q)}),this.register(function(Q){return new ZY(Q)}),this.register(function(Q){return new WY(Q)}),this.register(function(Q){return new HY(Q)}),this.register(function(Q){return new tH(Q)}),this.register(function(Q){return new YY(Q)}),this.register(function(Q){return new QY(Q)}),this.register(function(Q){return new KY(Q)}),this.register(function(Q){return new XY(Q)}),this.register(function(Q){return new aH(Q)}),this.register(function(Q){return new EY(Q)}),this.register(function(Q){return new NY(Q)})}load(J,Q,$,Z){let W=this,H;if(this.resourcePath!=="")H=this.resourcePath;else if(this.path!==""){let K=a8.extractUrlBase(J);H=a8.resolveURL(K,this.path)}else H=a8.extractUrlBase(J);this.manager.itemStart(J);let Y=function(K){if(Z)Z(K);else console.error(K);W.manager.itemError(J),W.manager.itemEnd(J)},X=new T6(this.manager);X.setPath(this.path),X.setResponseType("arraybuffer"),X.setRequestHeader(this.requestHeader),X.setWithCredentials(this.withCredentials),X.load(J,function(K){try{W.parse(K,H,function(U){Q(U),W.manager.itemEnd(J)},Y)}catch(U){Y(U)}},$,Y)}setDRACOLoader(J){return this.dracoLoader=J,this}setKTX2Loader(J){return this.ktx2Loader=J,this}setMeshoptDecoder(J){return this.meshoptDecoder=J,this}register(J){if(this.pluginCallbacks.indexOf(J)===-1)this.pluginCallbacks.push(J);return this}unregister(J){if(this.pluginCallbacks.indexOf(J)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(J),1);return this}parse(J,Q,$,Z){let W,H={},Y={},X=new TextDecoder;if(typeof J==="string")W=JSON.parse(J);else if(J instanceof ArrayBuffer)if(X.decode(new Uint8Array(J,0,4))===OY){try{H[gJ.KHR_BINARY_GLTF]=new FY(J)}catch(G){if(Z)Z(G);return}W=JSON.parse(H[gJ.KHR_BINARY_GLTF].content)}else W=JSON.parse(X.decode(J));else W=J;if(W.asset===void 0||W.asset.version[0]<2){if(Z)Z(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let K=new LY(W,{path:Q||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});K.fileLoader.setRequestHeader(this.requestHeader);for(let U=0;U<this.pluginCallbacks.length;U++){let G=this.pluginCallbacks[U](K);if(!G.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");Y[G.name]=G,H[G.name]=!0}if(W.extensionsUsed)for(let U=0;U<W.extensionsUsed.length;++U){let G=W.extensionsUsed[U],q=W.extensionsRequired||[];switch(G){case gJ.KHR_MATERIALS_UNLIT:H[G]=new rH;break;case gJ.KHR_DRACO_MESH_COMPRESSION:H[G]=new RY(W,this.dracoLoader);break;case gJ.KHR_TEXTURE_TRANSFORM:H[G]=new kY;break;case gJ.KHR_MESH_QUANTIZATION:H[G]=new MY;break;default:if(q.indexOf(G)>=0&&Y[G]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+G+'".')}}K.setExtensions(H),K.setPlugins(Y),K.parse($,Z)}parseAsync(J,Q){let $=this;return new Promise(function(Z,W){$.parse(J,Q,Z,W)})}}function F1(){let J={};return{get:function(Q){return J[Q]},add:function(Q,$){J[Q]=$},remove:function(Q){delete J[Q]},removeAll:function(){J={}}}}var gJ={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class aH{constructor(J){this.parser=J,this.name=gJ.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let J=this.parser,Q=this.parser.json.nodes||[];for(let $=0,Z=Q.length;$<Z;$++){let W=Q[$];if(W.extensions&&W.extensions[this.name]&&W.extensions[this.name].light!==void 0)J._addNodeRef(this.cache,W.extensions[this.name].light)}}_loadLight(J){let Q=this.parser,$="light:"+J,Z=Q.cache.get($);if(Z)return Z;let W=Q.json,X=((W.extensions&&W.extensions[this.name]||{}).lights||[])[J],K,U=new jJ(16777215);if(X.color!==void 0)U.setRGB(X.color[0],X.color[1],X.color[2],T0);let G=X.range!==void 0?X.range:0;switch(X.type){case"directional":K=new o9(U),K.target.position.set(0,0,-1),K.add(K.target);break;case"point":K=new o7(U),K.distance=G;break;case"spot":K=new s7(U),K.distance=G,X.spot=X.spot||{},X.spot.innerConeAngle=X.spot.innerConeAngle!==void 0?X.spot.innerConeAngle:0,X.spot.outerConeAngle=X.spot.outerConeAngle!==void 0?X.spot.outerConeAngle:Math.PI/4,K.angle=X.spot.outerConeAngle,K.penumbra=1-X.spot.innerConeAngle/X.spot.outerConeAngle,K.target.position.set(0,0,-1),K.add(K.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+X.type)}if(K.position.set(0,0,0),j8(K,X),X.intensity!==void 0)K.intensity=X.intensity;return K.name=Q.createUniqueName(X.name||"light_"+J),Z=Promise.resolve(K),Q.cache.add($,Z),Z}getDependency(J,Q){if(J!=="light")return;return this._loadLight(Q)}createNodeAttachment(J){let Q=this,$=this.parser,W=$.json.nodes[J],Y=(W.extensions&&W.extensions[this.name]||{}).light;if(Y===void 0)return null;return this._loadLight(Y).then(function(X){return $._getNodeRef(Q.cache,Y,X)})}}class rH{constructor(){this.name=gJ.KHR_MATERIALS_UNLIT}getMaterialType(){return E8}extendParams(J,Q,$){let Z=[];J.color=new jJ(1,1,1),J.opacity=1;let W=Q.pbrMetallicRoughness;if(W){if(Array.isArray(W.baseColorFactor)){let H=W.baseColorFactor;J.color.setRGB(H[0],H[1],H[2],T0),J.opacity=H[3]}if(W.baseColorTexture!==void 0)Z.push($.assignTexture(J,"map",W.baseColorTexture,q8))}return Promise.all(Z)}}class tH{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(J,Q){let Z=this.parser.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=Z.extensions[this.name].emissiveStrength;if(W!==void 0)Q.emissiveIntensity=W;return Promise.resolve()}}class eH{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_CLEARCOAT}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(H.clearcoatFactor!==void 0)Q.clearcoat=H.clearcoatFactor;if(H.clearcoatTexture!==void 0)W.push($.assignTexture(Q,"clearcoatMap",H.clearcoatTexture));if(H.clearcoatRoughnessFactor!==void 0)Q.clearcoatRoughness=H.clearcoatRoughnessFactor;if(H.clearcoatRoughnessTexture!==void 0)W.push($.assignTexture(Q,"clearcoatRoughnessMap",H.clearcoatRoughnessTexture));if(H.clearcoatNormalTexture!==void 0){if(W.push($.assignTexture(Q,"clearcoatNormalMap",H.clearcoatNormalTexture)),H.clearcoatNormalTexture.scale!==void 0){let Y=H.clearcoatNormalTexture.scale;Q.clearcoatNormalScale=new PJ(Y,Y)}}return Promise.all(W)}}class JY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_DISPERSION}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let Z=this.parser.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=Z.extensions[this.name];return Q.dispersion=W.dispersion!==void 0?W.dispersion:0,Promise.resolve()}}class QY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_IRIDESCENCE}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(H.iridescenceFactor!==void 0)Q.iridescence=H.iridescenceFactor;if(H.iridescenceTexture!==void 0)W.push($.assignTexture(Q,"iridescenceMap",H.iridescenceTexture));if(H.iridescenceIor!==void 0)Q.iridescenceIOR=H.iridescenceIor;if(Q.iridescenceThicknessRange===void 0)Q.iridescenceThicknessRange=[100,400];if(H.iridescenceThicknessMinimum!==void 0)Q.iridescenceThicknessRange[0]=H.iridescenceThicknessMinimum;if(H.iridescenceThicknessMaximum!==void 0)Q.iridescenceThicknessRange[1]=H.iridescenceThicknessMaximum;if(H.iridescenceThicknessTexture!==void 0)W.push($.assignTexture(Q,"iridescenceThicknessMap",H.iridescenceThicknessTexture));return Promise.all(W)}}class $Y{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_SHEEN}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[];Q.sheenColor=new jJ(0,0,0),Q.sheenRoughness=0,Q.sheen=1;let H=Z.extensions[this.name];if(H.sheenColorFactor!==void 0){let Y=H.sheenColorFactor;Q.sheenColor.setRGB(Y[0],Y[1],Y[2],T0)}if(H.sheenRoughnessFactor!==void 0)Q.sheenRoughness=H.sheenRoughnessFactor;if(H.sheenColorTexture!==void 0)W.push($.assignTexture(Q,"sheenColorMap",H.sheenColorTexture,q8));if(H.sheenRoughnessTexture!==void 0)W.push($.assignTexture(Q,"sheenRoughnessMap",H.sheenRoughnessTexture));return Promise.all(W)}}class ZY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_TRANSMISSION}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(H.transmissionFactor!==void 0)Q.transmission=H.transmissionFactor;if(H.transmissionTexture!==void 0)W.push($.assignTexture(Q,"transmissionMap",H.transmissionTexture));return Promise.all(W)}}class WY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_VOLUME}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(Q.thickness=H.thicknessFactor!==void 0?H.thicknessFactor:0,H.thicknessTexture!==void 0)W.push($.assignTexture(Q,"thicknessMap",H.thicknessTexture));Q.attenuationDistance=H.attenuationDistance||1/0;let Y=H.attenuationColor||[1,1,1];return Q.attenuationColor=new jJ().setRGB(Y[0],Y[1],Y[2],T0),Promise.all(W)}}class HY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_IOR}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let Z=this.parser.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=Z.extensions[this.name];return Q.ior=W.ior!==void 0?W.ior:1.5,Promise.resolve()}}class YY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_SPECULAR}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(Q.specularIntensity=H.specularFactor!==void 0?H.specularFactor:1,H.specularTexture!==void 0)W.push($.assignTexture(Q,"specularIntensityMap",H.specularTexture));let Y=H.specularColorFactor||[1,1,1];if(Q.specularColor=new jJ().setRGB(Y[0],Y[1],Y[2],T0),H.specularColorTexture!==void 0)W.push($.assignTexture(Q,"specularColorMap",H.specularColorTexture,q8));return Promise.all(W)}}class XY{constructor(J){this.parser=J,this.name=gJ.EXT_MATERIALS_BUMP}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(Q.bumpScale=H.bumpFactor!==void 0?H.bumpFactor:1,H.bumpTexture!==void 0)W.push($.assignTexture(Q,"bumpMap",H.bumpTexture));return Promise.all(W)}}class KY{constructor(J){this.parser=J,this.name=gJ.KHR_MATERIALS_ANISOTROPY}getMaterialType(J){let $=this.parser.json.materials[J];if(!$.extensions||!$.extensions[this.name])return null;return m0}extendMaterialParams(J,Q){let $=this.parser,Z=$.json.materials[J];if(!Z.extensions||!Z.extensions[this.name])return Promise.resolve();let W=[],H=Z.extensions[this.name];if(H.anisotropyStrength!==void 0)Q.anisotropy=H.anisotropyStrength;if(H.anisotropyRotation!==void 0)Q.anisotropyRotation=H.anisotropyRotation;if(H.anisotropyTexture!==void 0)W.push($.assignTexture(Q,"anisotropyMap",H.anisotropyTexture));return Promise.all(W)}}class UY{constructor(J){this.parser=J,this.name=gJ.KHR_TEXTURE_BASISU}loadTexture(J){let Q=this.parser,$=Q.json,Z=$.textures[J];if(!Z.extensions||!Z.extensions[this.name])return null;let W=Z.extensions[this.name],H=Q.options.ktx2Loader;if(!H)if($.extensionsRequired&&$.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return Q.loadTextureImage(J,W.source,H)}}class GY{constructor(J){this.parser=J,this.name=gJ.EXT_TEXTURE_WEBP}loadTexture(J){let Q=this.name,$=this.parser,Z=$.json,W=Z.textures[J];if(!W.extensions||!W.extensions[Q])return null;let H=W.extensions[Q],Y=Z.images[H.source],X=$.textureLoader;if(Y.uri){let K=$.options.manager.getHandler(Y.uri);if(K!==null)X=K}return $.loadTextureImage(J,H.source,X)}}class qY{constructor(J){this.parser=J,this.name=gJ.EXT_TEXTURE_AVIF}loadTexture(J){let Q=this.name,$=this.parser,Z=$.json,W=Z.textures[J];if(!W.extensions||!W.extensions[Q])return null;let H=W.extensions[Q],Y=Z.images[H.source],X=$.textureLoader;if(Y.uri){let K=$.options.manager.getHandler(Y.uri);if(K!==null)X=K}return $.loadTextureImage(J,H.source,X)}}class EY{constructor(J){this.name=gJ.EXT_MESHOPT_COMPRESSION,this.parser=J}loadBufferView(J){let Q=this.parser.json,$=Q.bufferViews[J];if($.extensions&&$.extensions[this.name]){let Z=$.extensions[this.name],W=this.parser.getDependency("buffer",Z.buffer),H=this.parser.options.meshoptDecoder;if(!H||!H.supported)if(Q.extensionsRequired&&Q.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return W.then(function(Y){let X=Z.byteOffset||0,K=Z.byteLength||0,U=Z.count,G=Z.byteStride,q=new Uint8Array(Y,X,K);if(H.decodeGltfBufferAsync)return H.decodeGltfBufferAsync(U,G,q,Z.mode,Z.filter).then(function(E){return E.buffer});else return H.ready.then(function(){let E=new ArrayBuffer(U*G);return H.decodeGltfBuffer(new Uint8Array(E),U,G,q,Z.mode,Z.filter),E})})}else return null}}class NY{constructor(J){this.name=gJ.EXT_MESH_GPU_INSTANCING,this.parser=J}createNodeMesh(J){let Q=this.parser.json,$=Q.nodes[J];if(!$.extensions||!$.extensions[this.name]||$.mesh===void 0)return null;let Z=Q.meshes[$.mesh];for(let K of Z.primitives)if(K.mode!==a0.TRIANGLES&&K.mode!==a0.TRIANGLE_STRIP&&K.mode!==a0.TRIANGLE_FAN&&K.mode!==void 0)return null;let H=$.extensions[this.name].attributes,Y=[],X={};for(let K in H)Y.push(this.parser.getDependency("accessor",H[K]).then((U)=>{return X[K]=U,X[K]}));if(Y.length<1)return null;return Y.push(this.parser.createNodeMesh(J)),Promise.all(Y).then((K)=>{let U=K.pop(),G=U.isGroup?U.children:[U],q=K[0].count,E=[];for(let O of G){let k=new vJ,M=new A,N=new y0,F=new A(1,1,1),C=new b7(O.geometry,O.material,q);for(let L=0;L<q;L++){if(X.TRANSLATION)M.fromBufferAttribute(X.TRANSLATION,L);if(X.ROTATION)N.fromBufferAttribute(X.ROTATION,L);if(X.SCALE)F.fromBufferAttribute(X.SCALE,L);C.setMatrixAt(L,k.compose(M,N,F))}for(let L in X)if(L==="_COLOR_0"){let _=X[L];C.instanceColor=new Y9(_.array,_.itemSize,_.normalized)}else if(L!=="TRANSLATION"&&L!=="ROTATION"&&L!=="SCALE")O.geometry.setAttribute(L,X[L]);Z0.prototype.copy.call(C,O),this.parser.assignFinalMaterial(C),E.push(C)}if(U.isGroup)return U.clear(),U.add(...E),U;return E[0]})}}var OY="glTF",y6=12,nH={JSON:1313821514,BIN:5130562};class FY{constructor(J){this.name=gJ.KHR_BINARY_GLTF,this.content=null,this.body=null;let Q=new DataView(J,0,y6),$=new TextDecoder;if(this.header={magic:$.decode(new Uint8Array(J.slice(0,4))),version:Q.getUint32(4,!0),length:Q.getUint32(8,!0)},this.header.magic!==OY)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let Z=this.header.length-y6,W=new DataView(J,y6),H=0;while(H<Z){let Y=W.getUint32(H,!0);H+=4;let X=W.getUint32(H,!0);if(H+=4,X===nH.JSON){let K=new Uint8Array(J,y6+H,Y);this.content=$.decode(K)}else if(X===nH.BIN){let K=y6+H;this.body=J.slice(K,K+Y)}H+=Y}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class RY{constructor(J,Q){if(!Q)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=gJ.KHR_DRACO_MESH_COMPRESSION,this.json=J,this.dracoLoader=Q,this.dracoLoader.preload()}decodePrimitive(J,Q){let $=this.json,Z=this.dracoLoader,W=J.extensions[this.name].bufferView,H=J.extensions[this.name].attributes,Y={},X={},K={};for(let U in H){let G=KZ[U]||U.toLowerCase();Y[G]=H[U]}for(let U in J.attributes){let G=KZ[U]||U.toLowerCase();if(H[U]!==void 0){let q=$.accessors[J.attributes[U]],E=t9[q.componentType];K[G]=E.name,X[G]=q.normalized===!0}}return Q.getDependency("bufferView",W).then(function(U){return new Promise(function(G,q){Z.decodeDracoFile(U,function(E){for(let O in E.attributes){let k=E.attributes[O],M=X[O];if(M!==void 0)k.normalized=M}G(E)},Y,K,T0,q)})})}}class kY{constructor(){this.name=gJ.KHR_TEXTURE_TRANSFORM}extendTexture(J,Q){if((Q.texCoord===void 0||Q.texCoord===J.channel)&&Q.offset===void 0&&Q.rotation===void 0&&Q.scale===void 0)return J;if(J=J.clone(),Q.texCoord!==void 0)J.channel=Q.texCoord;if(Q.offset!==void 0)J.offset.fromArray(Q.offset);if(Q.rotation!==void 0)J.rotation=Q.rotation;if(Q.scale!==void 0)J.repeat.fromArray(Q.scale);return J.needsUpdate=!0,J}}class MY{constructor(){this.name=gJ.KHR_MESH_QUANTIZATION}}class qZ extends s8{constructor(J,Q,$,Z){super(J,Q,$,Z)}copySampleValue_(J){let Q=this.resultBuffer,$=this.sampleValues,Z=this.valueSize,W=J*Z*3+Z;for(let H=0;H!==Z;H++)Q[H]=$[W+H];return Q}interpolate_(J,Q,$,Z){let W=this.resultBuffer,H=this.sampleValues,Y=this.valueSize,X=Y*2,K=Y*3,U=Z-Q,G=($-Q)/U,q=G*G,E=q*G,O=J*K,k=O-K,M=-2*E+3*q,N=E-q,F=1-M,C=N-q+G;for(let L=0;L!==Y;L++){let _=H[k+L+Y],v=H[k+L+X]*U,w=H[O+L+Y],T=H[O+L]*U;W[L]=F*_+C*v+M*w+N*T}return W}}var R1=new y0;class DY extends qZ{interpolate_(J,Q,$,Z){let W=super.interpolate_(J,Q,$,Z);return R1.fromArray(W).normalize().toArray(W),W}}var a0={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},t9={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},sH={9728:w8,9729:W8,9984:L7,9985:x9,9986:K9,9987:I8},oH={33071:M7,33648:D7,10497:b9},HZ={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},KZ={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},r8={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},k1={CUBICSPLINE:void 0,LINEAR:I7,STEP:M$},YZ={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function M1(J){if(J.DefaultMaterial===void 0)J.DefaultMaterial=new c9({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d8});return J.DefaultMaterial}function F9(J,Q,$){for(let Z in $.extensions)if(J[Z]===void 0)Q.userData.gltfExtensions=Q.userData.gltfExtensions||{},Q.userData.gltfExtensions[Z]=$.extensions[Z]}function j8(J,Q){if(Q.extras!==void 0)if(typeof Q.extras==="object")Object.assign(J.userData,Q.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+Q.extras)}function D1(J,Q,$){let Z=!1,W=!1,H=!1;for(let U=0,G=Q.length;U<G;U++){let q=Q[U];if(q.POSITION!==void 0)Z=!0;if(q.NORMAL!==void 0)W=!0;if(q.COLOR_0!==void 0)H=!0;if(Z&&W&&H)break}if(!Z&&!W&&!H)return Promise.resolve(J);let Y=[],X=[],K=[];for(let U=0,G=Q.length;U<G;U++){let q=Q[U];if(Z){let E=q.POSITION!==void 0?$.getDependency("accessor",q.POSITION):J.attributes.position;Y.push(E)}if(W){let E=q.NORMAL!==void 0?$.getDependency("accessor",q.NORMAL):J.attributes.normal;X.push(E)}if(H){let E=q.COLOR_0!==void 0?$.getDependency("accessor",q.COLOR_0):J.attributes.color;K.push(E)}}return Promise.all([Promise.all(Y),Promise.all(X),Promise.all(K)]).then(function(U){let G=U[0],q=U[1],E=U[2];if(Z)J.morphAttributes.position=G;if(W)J.morphAttributes.normal=q;if(H)J.morphAttributes.color=E;return J.morphTargetsRelative=!0,J})}function L1(J,Q){if(J.updateMorphTargets(),Q.weights!==void 0)for(let $=0,Z=Q.weights.length;$<Z;$++)J.morphTargetInfluences[$]=Q.weights[$];if(Q.extras&&Array.isArray(Q.extras.targetNames)){let $=Q.extras.targetNames;if(J.morphTargetInfluences.length===$.length){J.morphTargetDictionary={};for(let Z=0,W=$.length;Z<W;Z++)J.morphTargetDictionary[$[Z]]=Z}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function V1(J){let Q,$=J.extensions&&J.extensions[gJ.KHR_DRACO_MESH_COMPRESSION];if($)Q="draco:"+$.bufferView+":"+$.indices+":"+XZ($.attributes);else Q=J.indices+":"+XZ(J.attributes)+":"+J.mode;if(J.targets!==void 0)for(let Z=0,W=J.targets.length;Z<W;Z++)Q+=":"+XZ(J.targets[Z]);return Q}function XZ(J){let Q="",$=Object.keys(J).sort();for(let Z=0,W=$.length;Z<W;Z++)Q+=$[Z]+":"+J[$[Z]]+";";return Q}function UZ(J){switch(J){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function z1(J){if(J.search(/\.jpe?g($|\?)/i)>0||J.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(J.search(/\.webp($|\?)/i)>0||J.search(/^data\:image\/webp/)===0)return"image/webp";if(J.search(/\.ktx2($|\?)/i)>0||J.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var B1=new vJ;class LY{constructor(J={},Q={}){this.json=J,this.extensions={},this.plugins={},this.options=Q,this.cache=new F1,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let $=!1,Z=-1,W=!1,H=-1;if(typeof navigator<"u"){let Y=navigator.userAgent;$=/^((?!chrome|android).)*safari/i.test(Y)===!0;let X=Y.match(/Version\/(\d+)/);Z=$&&X?parseInt(X[1],10):-1,W=Y.indexOf("Firefox")>-1,H=W?Y.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||$&&Z<17||W&&H<98)this.textureLoader=new u7(this.options.manager);else this.textureLoader=new i7(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new T6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(J){this.extensions=J}setPlugins(J){this.plugins=J}parse(J,Q){let $=this,Z=this.json,W=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(H){return H._markDefs&&H._markDefs()}),Promise.all(this._invokeAll(function(H){return H.beforeRoot&&H.beforeRoot()})).then(function(){return Promise.all([$.getDependencies("scene"),$.getDependencies("animation"),$.getDependencies("camera")])}).then(function(H){let Y={scene:H[0][Z.scene||0],scenes:H[0],animations:H[1],cameras:H[2],asset:Z.asset,parser:$,userData:{}};return F9(W,Y,Z),j8(Y,Z),Promise.all($._invokeAll(function(X){return X.afterRoot&&X.afterRoot(Y)})).then(function(){for(let X of Y.scenes)X.updateMatrixWorld();J(Y)})}).catch(Q)}_markDefs(){let J=this.json.nodes||[],Q=this.json.skins||[],$=this.json.meshes||[];for(let Z=0,W=Q.length;Z<W;Z++){let H=Q[Z].joints;for(let Y=0,X=H.length;Y<X;Y++)J[H[Y]].isBone=!0}for(let Z=0,W=J.length;Z<W;Z++){let H=J[Z];if(H.mesh!==void 0){if(this._addNodeRef(this.meshCache,H.mesh),H.skin!==void 0)$[H.mesh].isSkinnedMesh=!0}if(H.camera!==void 0)this._addNodeRef(this.cameraCache,H.camera)}}_addNodeRef(J,Q){if(Q===void 0)return;if(J.refs[Q]===void 0)J.refs[Q]=J.uses[Q]=0;J.refs[Q]++}_getNodeRef(J,Q,$){if(J.refs[Q]<=1)return $;let Z=$.clone(),W=(H,Y)=>{let X=this.associations.get(H);if(X!=null)this.associations.set(Y,X);for(let[K,U]of H.children.entries())W(U,Y.children[K])};return W($,Z),Z.name+="_instance_"+J.uses[Q]++,Z}_invokeOne(J){let Q=Object.values(this.plugins);Q.push(this);for(let $=0;$<Q.length;$++){let Z=J(Q[$]);if(Z)return Z}return null}_invokeAll(J){let Q=Object.values(this.plugins);Q.unshift(this);let $=[];for(let Z=0;Z<Q.length;Z++){let W=J(Q[Z]);if(W)$.push(W)}return $}getDependency(J,Q){let $=J+":"+Q,Z=this.cache.get($);if(!Z){switch(J){case"scene":Z=this.loadScene(Q);break;case"node":Z=this._invokeOne(function(W){return W.loadNode&&W.loadNode(Q)});break;case"mesh":Z=this._invokeOne(function(W){return W.loadMesh&&W.loadMesh(Q)});break;case"accessor":Z=this.loadAccessor(Q);break;case"bufferView":Z=this._invokeOne(function(W){return W.loadBufferView&&W.loadBufferView(Q)});break;case"buffer":Z=this.loadBuffer(Q);break;case"material":Z=this._invokeOne(function(W){return W.loadMaterial&&W.loadMaterial(Q)});break;case"texture":Z=this._invokeOne(function(W){return W.loadTexture&&W.loadTexture(Q)});break;case"skin":Z=this.loadSkin(Q);break;case"animation":Z=this._invokeOne(function(W){return W.loadAnimation&&W.loadAnimation(Q)});break;case"camera":Z=this.loadCamera(Q);break;default:if(Z=this._invokeOne(function(W){return W!=this&&W.getDependency&&W.getDependency(J,Q)}),!Z)throw Error("Unknown type: "+J);break}this.cache.add($,Z)}return Z}getDependencies(J){let Q=this.cache.get(J);if(!Q){let $=this,Z=this.json[J+(J==="mesh"?"es":"s")]||[];Q=Promise.all(Z.map(function(W,H){return $.getDependency(J,H)})),this.cache.add(J,Q)}return Q}loadBuffer(J){let Q=this.json.buffers[J],$=this.fileLoader;if(Q.type&&Q.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+Q.type+" buffer type is not supported.");if(Q.uri===void 0&&J===0)return Promise.resolve(this.extensions[gJ.KHR_BINARY_GLTF].body);let Z=this.options;return new Promise(function(W,H){$.load(a8.resolveURL(Q.uri,Z.path),W,void 0,function(){H(Error('THREE.GLTFLoader: Failed to load buffer "'+Q.uri+'".'))})})}loadBufferView(J){let Q=this.json.bufferViews[J];return this.getDependency("buffer",Q.buffer).then(function($){let Z=Q.byteLength||0,W=Q.byteOffset||0;return $.slice(W,W+Z)})}loadAccessor(J){let Q=this,$=this.json,Z=this.json.accessors[J];if(Z.bufferView===void 0&&Z.sparse===void 0){let H=HZ[Z.type],Y=t9[Z.componentType],X=Z.normalized===!0,K=new Y(Z.count*H);return Promise.resolve(new F0(K,H,X))}let W=[];if(Z.bufferView!==void 0)W.push(this.getDependency("bufferView",Z.bufferView));else W.push(null);if(Z.sparse!==void 0)W.push(this.getDependency("bufferView",Z.sparse.indices.bufferView)),W.push(this.getDependency("bufferView",Z.sparse.values.bufferView));return Promise.all(W).then(function(H){let Y=H[0],X=HZ[Z.type],K=t9[Z.componentType],U=K.BYTES_PER_ELEMENT,G=U*X,q=Z.byteOffset||0,E=Z.bufferView!==void 0?$.bufferViews[Z.bufferView].byteStride:void 0,O=Z.normalized===!0,k,M;if(E&&E!==G){let N=Math.floor(q/E),F="InterleavedBuffer:"+Z.bufferView+":"+Z.componentType+":"+N+":"+Z.count,C=Q.cache.get(F);if(!C)k=new K(Y,N*E,Z.count*E/U),C=new z6(k,E/U),Q.cache.add(F,C);M=new m9(C,X,q%E/U,O)}else{if(Y===null)k=new K(Z.count*X);else k=new K(Y,q,Z.count*X);M=new F0(k,X,O)}if(Z.sparse!==void 0){let N=HZ.SCALAR,F=t9[Z.sparse.indices.componentType],C=Z.sparse.indices.byteOffset||0,L=Z.sparse.values.byteOffset||0,_=new F(H[1],C,Z.sparse.count*N),v=new K(H[2],L,Z.sparse.count*X);if(Y!==null)M=new F0(M.array.slice(),M.itemSize,M.normalized);M.normalized=!1;for(let w=0,T=_.length;w<T;w++){let x=_[w];if(M.setX(x,v[w*X]),X>=2)M.setY(x,v[w*X+1]);if(X>=3)M.setZ(x,v[w*X+2]);if(X>=4)M.setW(x,v[w*X+3]);if(X>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}M.normalized=O}return M})}loadTexture(J){let Q=this.json,$=this.options,W=Q.textures[J].source,H=Q.images[W],Y=this.textureLoader;if(H.uri){let X=$.manager.getHandler(H.uri);if(X!==null)Y=X}return this.loadTextureImage(J,W,Y)}loadTextureImage(J,Q,$){let Z=this,W=this.json,H=W.textures[J],Y=W.images[Q],X=(Y.uri||Y.bufferView)+":"+H.sampler;if(this.textureCache[X])return this.textureCache[X];let K=this.loadImageSource(Q,$).then(function(U){if(U.flipY=!1,U.name=H.name||Y.name||"",U.name===""&&typeof Y.uri==="string"&&Y.uri.startsWith("data:image/")===!1)U.name=Y.uri;let q=(W.samplers||{})[H.sampler]||{};return U.magFilter=sH[q.magFilter]||W8,U.minFilter=sH[q.minFilter]||I8,U.wrapS=oH[q.wrapS]||b9,U.wrapT=oH[q.wrapT]||b9,U.generateMipmaps=!U.isCompressedTexture&&U.minFilter!==w8&&U.minFilter!==W8,Z.associations.set(U,{textures:J}),U}).catch(function(){return null});return this.textureCache[X]=K,K}loadImageSource(J,Q){let $=this,Z=this.json,W=this.options;if(this.sourceCache[J]!==void 0)return this.sourceCache[J].then((G)=>G.clone());let H=Z.images[J],Y=self.URL||self.webkitURL,X=H.uri||"",K=!1;if(H.bufferView!==void 0)X=$.getDependency("bufferView",H.bufferView).then(function(G){K=!0;let q=new Blob([G],{type:H.mimeType});return X=Y.createObjectURL(q),X});else if(H.uri===void 0)throw Error("THREE.GLTFLoader: Image "+J+" is missing URI and bufferView");let U=Promise.resolve(X).then(function(G){return new Promise(function(q,E){let O=q;if(Q.isImageBitmapLoader===!0)O=function(k){let M=new E0(k);M.needsUpdate=!0,q(M)};Q.load(a8.resolveURL(G,W.path),O,void 0,E)})}).then(function(G){if(K===!0)Y.revokeObjectURL(X);return j8(G,H),G.userData.mimeType=H.mimeType||z1(H.uri),G}).catch(function(G){throw console.error("THREE.GLTFLoader: Couldn't load texture",X),G});return this.sourceCache[J]=U,U}assignTexture(J,Q,$,Z){let W=this;return this.getDependency("texture",$.index).then(function(H){if(!H)return null;if($.texCoord!==void 0&&$.texCoord>0)H=H.clone(),H.channel=$.texCoord;if(W.extensions[gJ.KHR_TEXTURE_TRANSFORM]){let Y=$.extensions!==void 0?$.extensions[gJ.KHR_TEXTURE_TRANSFORM]:void 0;if(Y){let X=W.associations.get(H);H=W.extensions[gJ.KHR_TEXTURE_TRANSFORM].extendTexture(H,Y),W.associations.set(H,X)}}if(Z!==void 0)H.colorSpace=Z;return J[Q]=H,H})}assignFinalMaterial(J){let{geometry:Q,material:$}=J,Z=Q.attributes.tangent===void 0,W=Q.attributes.color!==void 0,H=Q.attributes.normal===void 0;if(J.isPoints){let Y="PointsMaterial:"+$.uuid,X=this.cache.get(Y);if(!X)X=new I6,l0.prototype.copy.call(X,$),X.color.copy($.color),X.map=$.map,X.sizeAttenuation=!1,this.cache.add(Y,X);$=X}else if(J.isLine){let Y="LineBasicMaterial:"+$.uuid,X=this.cache.get(Y);if(!X)X=new w6,l0.prototype.copy.call(X,$),X.color.copy($.color),X.map=$.map,this.cache.add(Y,X);$=X}if(Z||W||H){let Y="ClonedMaterial:"+$.uuid+":";if(Z)Y+="derivative-tangents:";if(W)Y+="vertex-colors:";if(H)Y+="flat-shading:";let X=this.cache.get(Y);if(!X){if(X=$.clone(),W)X.vertexColors=!0;if(H)X.flatShading=!0;if(Z){if(X.normalScale)X.normalScale.y*=-1;if(X.clearcoatNormalScale)X.clearcoatNormalScale.y*=-1}this.cache.add(Y,X),this.associations.set(X,this.associations.get($))}$=X}J.material=$}getMaterialType(){return c9}loadMaterial(J){let Q=this,$=this.json,Z=this.extensions,W=$.materials[J],H,Y={},X=W.extensions||{},K=[];if(X[gJ.KHR_MATERIALS_UNLIT]){let G=Z[gJ.KHR_MATERIALS_UNLIT];H=G.getMaterialType(),K.push(G.extendParams(Y,W,Q))}else{let G=W.pbrMetallicRoughness||{};if(Y.color=new jJ(1,1,1),Y.opacity=1,Array.isArray(G.baseColorFactor)){let q=G.baseColorFactor;Y.color.setRGB(q[0],q[1],q[2],T0),Y.opacity=q[3]}if(G.baseColorTexture!==void 0)K.push(Q.assignTexture(Y,"map",G.baseColorTexture,q8));if(Y.metalness=G.metallicFactor!==void 0?G.metallicFactor:1,Y.roughness=G.roughnessFactor!==void 0?G.roughnessFactor:1,G.metallicRoughnessTexture!==void 0)K.push(Q.assignTexture(Y,"metalnessMap",G.metallicRoughnessTexture)),K.push(Q.assignTexture(Y,"roughnessMap",G.metallicRoughnessTexture));H=this._invokeOne(function(q){return q.getMaterialType&&q.getMaterialType(J)}),K.push(Promise.all(this._invokeAll(function(q){return q.extendMaterialParams&&q.extendMaterialParams(J,Y)})))}if(W.doubleSided===!0)Y.side=j0;let U=W.alphaMode||YZ.OPAQUE;if(U===YZ.BLEND)Y.transparent=!0,Y.depthWrite=!1;else if(Y.transparent=!1,U===YZ.MASK)Y.alphaTest=W.alphaCutoff!==void 0?W.alphaCutoff:0.5;if(W.normalTexture!==void 0&&H!==E8){if(K.push(Q.assignTexture(Y,"normalMap",W.normalTexture)),Y.normalScale=new PJ(1,1),W.normalTexture.scale!==void 0){let G=W.normalTexture.scale;Y.normalScale.set(G,G)}}if(W.occlusionTexture!==void 0&&H!==E8){if(K.push(Q.assignTexture(Y,"aoMap",W.occlusionTexture)),W.occlusionTexture.strength!==void 0)Y.aoMapIntensity=W.occlusionTexture.strength}if(W.emissiveFactor!==void 0&&H!==E8){let G=W.emissiveFactor;Y.emissive=new jJ().setRGB(G[0],G[1],G[2],T0)}if(W.emissiveTexture!==void 0&&H!==E8)K.push(Q.assignTexture(Y,"emissiveMap",W.emissiveTexture,q8));return Promise.all(K).then(function(){let G=new H(Y);if(W.name)G.name=W.name;if(j8(G,W),Q.associations.set(G,{materials:J}),W.extensions)F9(Z,G,W);return G})}createUniqueName(J){let Q=oJ.sanitizeNodeName(J||"");if(Q in this.nodeNamesUsed)return Q+"_"+ ++this.nodeNamesUsed[Q];else return this.nodeNamesUsed[Q]=0,Q}loadGeometries(J){let Q=this,$=this.extensions,Z=this.primitiveCache;function W(Y){return $[gJ.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(Y,Q).then(function(X){return iH(X,Y,Q)})}let H=[];for(let Y=0,X=J.length;Y<X;Y++){let K=J[Y],U=V1(K),G=Z[U];if(G)H.push(G.promise);else{let q;if(K.extensions&&K.extensions[gJ.KHR_DRACO_MESH_COMPRESSION])q=W(K);else q=iH(new d0,K,Q);Z[U]={primitive:K,promise:q},H.push(q)}}return Promise.all(H)}loadMesh(J){let Q=this,$=this.json,Z=this.extensions,W=$.meshes[J],H=W.primitives,Y=[];for(let X=0,K=H.length;X<K;X++){let U=H[X].material===void 0?M1(this.cache):this.getDependency("material",H[X].material);Y.push(U)}return Y.push(Q.loadGeometries(H)),Promise.all(Y).then(function(X){let K=X.slice(0,X.length-1),U=X[X.length-1],G=[];for(let E=0,O=U.length;E<O;E++){let k=U[E],M=H[E],N,F=K[E];if(M.mode===a0.TRIANGLES||M.mode===a0.TRIANGLE_STRIP||M.mode===a0.TRIANGLE_FAN||M.mode===void 0){if(N=W.isSkinnedMesh===!0?new f7(k,F):new _0(k,F),N.isSkinnedMesh===!0)N.normalizeSkinWeights();if(M.mode===a0.TRIANGLE_STRIP)N.geometry=WZ(N.geometry,M6);else if(M.mode===a0.TRIANGLE_FAN)N.geometry=WZ(N.geometry,l9)}else if(M.mode===a0.LINES)N=new x7(k,F);else if(M.mode===a0.LINE_STRIP)N=new u9(k,F);else if(M.mode===a0.LINE_LOOP)N=new g7(k,F);else if(M.mode===a0.POINTS)N=new p7(k,F);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+M.mode);if(Object.keys(N.geometry.morphAttributes).length>0)L1(N,W);if(N.name=Q.createUniqueName(W.name||"mesh_"+J),j8(N,W),M.extensions)F9(Z,N,M);Q.assignFinalMaterial(N),G.push(N)}for(let E=0,O=G.length;E<O;E++)Q.associations.set(G[E],{meshes:J,primitives:E});if(G.length===1){if(W.extensions)F9(Z,G[0],W);return G[0]}let q=new X8;if(W.extensions)F9(Z,q,W);Q.associations.set(q,{meshes:J});for(let E=0,O=G.length;E<O;E++)q.add(G[E]);return q})}loadCamera(J){let Q,$=this.json.cameras[J],Z=$[$.type];if(!Z){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if($.type==="perspective")Q=new O0(D6.radToDeg(Z.yfov),Z.aspectRatio||1,Z.znear||1,Z.zfar||2000000);else if($.type==="orthographic")Q=new s9(-Z.xmag,Z.xmag,Z.ymag,-Z.ymag,Z.znear,Z.zfar);if($.name)Q.name=this.createUniqueName($.name);return j8(Q,$),Promise.resolve(Q)}loadSkin(J){let Q=this.json.skins[J],$=[];for(let Z=0,W=Q.joints.length;Z<W;Z++)$.push(this._loadNodeShallow(Q.joints[Z]));if(Q.inverseBindMatrices!==void 0)$.push(this.getDependency("accessor",Q.inverseBindMatrices));else $.push(null);return Promise.all($).then(function(Z){let W=Z.pop(),H=Z,Y=[],X=[];for(let K=0,U=H.length;K<U;K++){let G=H[K];if(G){Y.push(G);let q=new vJ;if(W!==null)q.fromArray(W.array,K*16);X.push(q)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',Q.joints[K])}return new C6(Y,X)})}loadAnimation(J){let Q=this.json,$=this,Z=Q.animations[J],W=Z.name?Z.name:"animation_"+J,H=[],Y=[],X=[],K=[],U=[];for(let G=0,q=Z.channels.length;G<q;G++){let E=Z.channels[G],O=Z.samplers[E.sampler],k=E.target,M=k.node,N=Z.parameters!==void 0?Z.parameters[O.input]:O.input,F=Z.parameters!==void 0?Z.parameters[O.output]:O.output;if(k.node===void 0)continue;H.push(this.getDependency("node",M)),Y.push(this.getDependency("accessor",N)),X.push(this.getDependency("accessor",F)),K.push(O),U.push(k)}return Promise.all([Promise.all(H),Promise.all(Y),Promise.all(X),Promise.all(K),Promise.all(U)]).then(function(G){let q=G[0],E=G[1],O=G[2],k=G[3],M=G[4],N=[];for(let F=0,C=q.length;F<C;F++){let L=q[F],_=E[F],v=O[F],w=k[F],T=M[F];if(L===void 0)continue;if(L.updateMatrix)L.updateMatrix();let x=$._createAnimationTracks(L,_,v,w,T);if(x)for(let z=0;z<x.length;z++)N.push(x[z])}return new m7(W,void 0,N)})}createNodeMesh(J){let Q=this.json,$=this,Z=Q.nodes[J];if(Z.mesh===void 0)return null;return $.getDependency("mesh",Z.mesh).then(function(W){let H=$._getNodeRef($.meshCache,Z.mesh,W);if(Z.weights!==void 0)H.traverse(function(Y){if(!Y.isMesh)return;for(let X=0,K=Z.weights.length;X<K;X++)Y.morphTargetInfluences[X]=Z.weights[X]});return H})}loadNode(J){let Q=this.json,$=this,Z=Q.nodes[J],W=$._loadNodeShallow(J),H=[],Y=Z.children||[];for(let K=0,U=Y.length;K<U;K++)H.push($.getDependency("node",Y[K]));let X=Z.skin===void 0?Promise.resolve(null):$.getDependency("skin",Z.skin);return Promise.all([W,Promise.all(H),X]).then(function(K){let U=K[0],G=K[1],q=K[2];if(q!==null)U.traverse(function(E){if(!E.isSkinnedMesh)return;E.bind(q,B1)});for(let E=0,O=G.length;E<O;E++)U.add(G[E]);return U})}_loadNodeShallow(J){let Q=this.json,$=this.extensions,Z=this;if(this.nodeCache[J]!==void 0)return this.nodeCache[J];let W=Q.nodes[J],H=W.name?Z.createUniqueName(W.name):"",Y=[],X=Z._invokeOne(function(K){return K.createNodeMesh&&K.createNodeMesh(J)});if(X)Y.push(X);if(W.camera!==void 0)Y.push(Z.getDependency("camera",W.camera).then(function(K){return Z._getNodeRef(Z.cameraCache,W.camera,K)}));return Z._invokeAll(function(K){return K.createNodeAttachment&&K.createNodeAttachment(J)}).forEach(function(K){Y.push(K)}),this.nodeCache[J]=Promise.all(Y).then(function(K){let U;if(W.isBone===!0)U=new B6;else if(K.length>1)U=new X8;else if(K.length===1)U=K[0];else U=new Z0;if(U!==K[0])for(let G=0,q=K.length;G<q;G++)U.add(K[G]);if(W.name)U.userData.name=W.name,U.name=H;if(j8(U,W),W.extensions)F9($,U,W);if(W.matrix!==void 0){let G=new vJ;G.fromArray(W.matrix),U.applyMatrix4(G)}else{if(W.translation!==void 0)U.position.fromArray(W.translation);if(W.rotation!==void 0)U.quaternion.fromArray(W.rotation);if(W.scale!==void 0)U.scale.fromArray(W.scale)}if(!Z.associations.has(U))Z.associations.set(U,{});else if(W.mesh!==void 0&&Z.meshCache.refs[W.mesh]>1){let G=Z.associations.get(U);Z.associations.set(U,{...G})}return Z.associations.get(U).nodes=J,U}),this.nodeCache[J]}loadScene(J){let Q=this.extensions,$=this.json.scenes[J],Z=this,W=new X8;if($.name)W.name=Z.createUniqueName($.name);if(j8(W,$),$.extensions)F9(Q,W,$);let H=$.nodes||[],Y=[];for(let X=0,K=H.length;X<K;X++)Y.push(Z.getDependency("node",H[X]));return Promise.all(Y).then(function(X){for(let U=0,G=X.length;U<G;U++)W.add(X[U]);let K=(U)=>{let G=new Map;for(let[q,E]of Z.associations)if(q instanceof l0||q instanceof E0)G.set(q,E);return U.traverse((q)=>{let E=Z.associations.get(q);if(E!=null)G.set(q,E)}),G};return Z.associations=K(W),W})}_createAnimationTracks(J,Q,$,Z,W){let H=[],Y=J.name?J.name:J.uuid,X=[];if(r8[W.path]===r8.weights)J.traverse(function(q){if(q.morphTargetInfluences)X.push(q.name?q.name:q.uuid)});else X.push(Y);let K;switch(r8[W.path]){case r8.weights:K=B8;break;case r8.rotation:K=A8;break;case r8.translation:case r8.scale:K=C8;break;default:switch($.itemSize){case 1:K=B8;break;case 2:case 3:default:K=C8;break}break}let U=Z.interpolation!==void 0?k1[Z.interpolation]:I7,G=this._getArrayFromAccessor($);for(let q=0,E=X.length;q<E;q++){let O=new K(X[q]+"."+r8[W.path],Q.array,G,U);if(Z.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(O);H.push(O)}return H}_getArrayFromAccessor(J){let Q=J.array;if(J.normalized){let $=UZ(Q.constructor),Z=new Float32Array(Q.length);for(let W=0,H=Q.length;W<H;W++)Z[W]=Q[W]*$;Q=Z}return Q}_createCubicSplineTrackInterpolant(J){J.createInterpolant=function($){return new(this instanceof A8?DY:qZ)(this.times,this.values,this.getValueSize()/3,$)},J.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function C1(J,Q,$){let Z=Q.attributes,W=new A0;if(Z.POSITION!==void 0){let X=$.json.accessors[Z.POSITION],K=X.min,U=X.max;if(K!==void 0&&U!==void 0){if(W.set(new A(K[0],K[1],K[2]),new A(U[0],U[1],U[2])),X.normalized){let G=UZ(t9[X.componentType]);W.min.multiplyScalar(G),W.max.multiplyScalar(G)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let H=Q.targets;if(H!==void 0){let X=new A,K=new A;for(let U=0,G=H.length;U<G;U++){let q=H[U];if(q.POSITION!==void 0){let E=$.json.accessors[q.POSITION],O=E.min,k=E.max;if(O!==void 0&&k!==void 0){if(K.setX(Math.max(Math.abs(O[0]),Math.abs(k[0]))),K.setY(Math.max(Math.abs(O[1]),Math.abs(k[1]))),K.setZ(Math.max(Math.abs(O[2]),Math.abs(k[2]))),E.normalized){let M=UZ(t9[E.componentType]);K.multiplyScalar(M)}X.max(K)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}W.expandByVector(X)}J.boundingBox=W;let Y=new p0;W.getCenter(Y.center),Y.radius=W.min.distanceTo(W.max)/2,J.boundingSphere=Y}function iH(J,Q,$){let Z=Q.attributes,W=[];function H(Y,X){return $.getDependency("accessor",Y).then(function(K){J.setAttribute(X,K)})}for(let Y in Z){let X=KZ[Y]||Y.toLowerCase();if(X in J.attributes)continue;W.push(H(Z[Y],X))}if(Q.indices!==void 0&&!J.index){let Y=$.getDependency("accessor",Q.indices).then(function(X){J.setIndex(X)});W.push(Y)}if(lJ.workingColorSpace!==T0&&"COLOR_0"in Z)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${lJ.workingColorSpace}" not supported.`);return j8(J,Q),C1(J,Q,$),Promise.all(W).then(function(){return Q.targets!==void 0?D1(J,Q.targets,$):J})}var EZ=document.getElementById("viewport"),e9=new v7,y8=new O0(34,1,0.1,2000);y8.up.set(0,0,1);var z0=new JZ({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});z0.setPixelRatio(Math.min(devicePixelRatio,2));z0.setClearColor(0,0);z0.outputColorSpace=q8;z0.toneMapping=F7;z0.toneMappingExposure=1.25;EZ.appendChild(z0.domElement);var k9=new ZZ(y8,z0.domElement);k9.enableDamping=!0;k9.minDistance=65;k9.maxDistance=1500;k9.target.set(0,-90,-88);e9.add(new c7(16777215,7834488,2.5));for(let[J,Q,$,Z]of[[-90,100,-110,3],[100,60,90,2],[-30,-100,40,1]]){let W=new o9(16777215,Z);W.position.set(J,Q,$),e9.add(W)}var VY=new GZ,F8="assembled",J6="front",R9=0,$Q=[],_1={front:[280,310,155],rear:[-270,-320,210],side:[-430,5,80]},ZQ=()=>{let J=(1+R9*0.35)*Math.max(1,1.05/y8.aspect),Q=[0,-90,-88];y8.position.set(..._1[J6].map(($,Z)=>Q[Z]+$*J)),k9.target.set(...Q),k9.update(),document.querySelectorAll("[data-view]").forEach(($)=>$.classList.toggle("active",$.dataset.view===J6))};function WQ(){for(let{object:J,part:Q}of $Q){let $=Q?.explode??[0,0,0];J.position.set(...$.map((Z)=>Z*R9)),J.traverse((Z)=>{if(!Z.isMesh)return;for(let W of Array.isArray(Z.material)?Z.material:[Z.material]){let H=["rear","front","base","neck"].includes(Q?.group);W.transparent=F8==="inside"&&H,W.opacity=F8==="inside"&&H?0.13:1,W.depthWrite=!(F8==="inside"&&H),W.side=j0,W.needsUpdate=!0}Z.renderOrder=["rear","front","base","neck"].includes(Q?.group)&&F8==="inside"?2:0})}document.getElementById("explode").value=R9*100,document.getElementById("explodeValue").textContent=`${Math.round(R9*100)}%`,document.querySelectorAll("[data-mode]").forEach((J)=>J.classList.toggle("active",J.dataset.mode===F8)),document.getElementById("viewLabel").textContent=`${J6==="front"?"COMPLETE LAMP":J6==="rear"?"REAR VIEW":"SIDE"} / ${F8.toUpperCase()}`}document.querySelectorAll("[data-mode]").forEach((J)=>J.onclick=()=>{F8=J.dataset.mode,R9=F8==="exploded"?1:0,ZQ(),WQ()});document.querySelectorAll("[data-view]").forEach((J)=>J.onclick=()=>{J6=J.dataset.view,ZQ(),WQ()});document.getElementById("explode").oninput=(J)=>{R9=Number(J.target.value)/100,F8=R9?"exploded":"assembled",WQ()};document.getElementById("save-view").onclick=async()=>{z0.render(e9,y8);let J=new A0;for(let{object:G}of $Q)J.union(new A0().setFromObject(G));let Q=[];for(let G of[J.min.x,J.max.x])for(let q of[J.min.y,J.max.y])for(let E of[J.min.z,J.max.z]){let O=new A(G,q,E).project(y8);Q.push([(O.x+1)*z0.domElement.width/2,(1-O.y)*z0.domElement.height/2])}let $=32*z0.getPixelRatio(),Z=Math.max(0,Math.floor(Math.min(...Q.map((G)=>G[0]))-$)),W=Math.max(0,Math.floor(Math.min(...Q.map((G)=>G[1]))-$)),H=Math.min(z0.domElement.width,Math.ceil(Math.max(...Q.map((G)=>G[0]))+$)),Y=Math.min(z0.domElement.height,Math.ceil(Math.max(...Q.map((G)=>G[1]))+$)),X=document.createElement("canvas");X.width=H-Z,X.height=Y-W;let K=X.getContext("2d");K.fillStyle="#eef3eb",K.fillRect(0,0,X.width,X.height),K.drawImage(z0.domElement,Z,W,X.width,X.height,0,0,X.width,X.height);let U=await fetch("/save-preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:X.toDataURL("image/png"),view:J6,mode:F8})});document.getElementById("save-view").textContent=U.ok?"View saved to project ✓":"Save failed — try again"};new ResizeObserver(()=>{let{width:J,height:Q}=EZ.getBoundingClientRect();z0.setSize(J,Q),y8.aspect=J/Q,y8.updateProjectionMatrix(),ZQ()}).observe(EZ);try{let J=await(await fetch("./mechanical/parts.json")).json();document.getElementById("part-count").textContent=`${J.length} mechanical models + routed PCB`,await Promise.all([...J.map(async(Q)=>{let $=await VY.loadAsync(`./mechanical/${Q.glb}`);$.scene.name=Q.id,$.scene.traverse((Z)=>{if(Z.isMesh)Z.material.roughness=0.48,Z.material.metalness=0.05}),e9.add($.scene),$Q.push({object:$.scene,part:Q})}),(async()=>{let Q=await VY.loadAsync("./mechanical/pcb.gltf");Q.scene.applyMatrix4(new vJ().set(-1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1)),e9.add(Q.scene),$Q.push({object:Q.scene})})()]),document.getElementById("loading").classList.add("hidden"),ZQ(),WQ()}catch(J){document.getElementById("loading").textContent=`Preview could not load: ${J.message}`,console.error(J)}z0.setAnimationLoop(()=>{k9.update(),z0.render(e9,y8)});