/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT */ const t="184",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n=1,r=3,s=0,a=1,o=2,l=100,h=101,c=102,u=200,d=201,p=202,m=203,f=204,g=205,y=206,_=207,v=208,x=209,b=210,M=211,S=212,T=213,w=214,E=0,A=1,C=2,R=3,N=4,I=5,P=6,L=7,D=0,O=1,U=2,F=1,z=2,k=3,B=4,V=5,G=6,H=7,W="attached",j="detached",X=300,q=301,Y=302,Z=303,K=304,J=306,$=1e3,Q=1001,tt=1002,et=1003,it=1004,nt=1005,rt=1006,st=1007,at=1008,ot=1009,lt=1010,ht=1011,ct=1012,ut=1013,dt=1014,pt=1015,mt=1016,ft=1017,gt=1018,yt=1020,_t=35902,vt=35899,xt=1021,bt=1022,Mt=1023,St=1026,Tt=1027,wt=1028,Et=1029,At=1030,Ct=1031,Rt=1033,Nt=33776,It=33777,Pt=33778,Lt=33779,Dt=35840,Ot=35841,Ut=35842,Ft=35843,zt=36196,kt=37492,Bt=37496,Vt=37488,Gt=37489,Ht=37490,Wt=37491,jt=37808,Xt=37809,qt=37810,Yt=37811,Zt=37812,Kt=37813,Jt=37814,$t=37815,Qt=37816,te=37817,ee=37818,ie=37819,ne=37820,re=37821,se=36492,ae=36494,oe=36495,le=36283,he=36284,ce=36285,ue=36286,de=2300,pe=2301,me=2302,fe=2303,ge=2400,ye=2401,_e=2402,ve=2500,xe=2501,be="",Me="srgb",Se="srgb-linear",Te="linear",we="srgb",Ee=7680,Ae=512,Ce=513,Re=514,Ne=515,Ie=516,Pe=517,Le=518,De=519,Oe=35044,Ue="300 es",Fe=2e3,ze=2001;const ke={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Be(t,e){return new ke[t](e)}function Ve(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ge(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function He(){const t=Ge("canvas");return t.style.display="block",t}const We={};let je=null;function Xe(...t){const e="THREE."+t.shift();je?je("log",e,...t):console.log(e,...t)}function qe(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Ye(...t){const e="THREE."+(t=qe(t)).shift();if(je)je("warn",e,...t);else{const i=t[0];i&&i.isStackTrace?console.warn(i.getError(e)):console.warn(e,...t)}}function Ze(...t){const e="THREE."+(t=qe(t)).shift();if(je)je("error",e,...t);else{const i=t[0];i&&i.isStackTrace?console.error(i.getError(e)):console.error(e,...t)}}function Ke(...t){const e=t.join(" ");e in We||(We[e]=!0,Ye(...t))}const Je={[E]:1,[C]:6,[N]:7,[R]:5,[A]:0,[P]:2,[L]:4,[I]:3};let $e=class{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const n=i[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,n=e.length;i>8&255]+Qe[t>>16&255]+Qe[t>>24&255]+"-"+Qe[255&e]+Qe[e>>8&255]+"-"+Qe[e>>16&15|64]+Qe[e>>24&255]+"-"+Qe[63&i|128]+Qe[i>>8&255]+"-"+Qe[i>>16&255]+Qe[i>>24&255]+Qe[255&n]+Qe[n>>8&255]+Qe[n>>16&255]+Qe[n>>24&255]).toLowerCase()}function ri(t,e,i){return Math.max(e,Math.min(i,t))}function si(t,e){return(t%e+e)%e}function ai(t,e,i){return(1-i)*t+i*e}function oi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function li(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const hi={DEG2RAD:ei,RAD2DEG:ii,generateUUID:ni,clamp:ri,euclideanModulo:si,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:ai,damp:function(t,e,i,n){return ai(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(si(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(ti=t);let e=ti+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*ei},radToDeg:function(t){return t*ii},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),h=s((e+n)/2),c=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),m=a((n-e)/2);switch(r){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*c,o*h);break;default:Ye("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:li,denormalize:oi};let ci=class t{static{t.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=ri(this.x,t.x,e.x),this.y=ri(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ri(this.x,t,e),this.y=ri(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ri(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(ri(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ui=class{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,s,a){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3],u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(c!==m||o!==u||l!==d||h!==p){let t=o*u+l*d+h*p+c*m;t<0&&(u=-u,d=-d,p=-p,m=-m,t=-t);let e=1-a;if(t<.9995){const i=Math.acos(t),n=Math.sin(i);e=Math.sin(e*i)/n,o=o*e+u*(a=Math.sin(a*i)/n),l=l*e+d*a,h=h*e+p*a,c=c*e+m*a}else{o=o*e+u*a,l=l*e+d*a,h=h*e+p*a,c=c*e+m*a;const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+h*c+o*d-l*u,t[e+1]=o*p+h*u+l*c-a*d,t[e+2]=l*p+h*d+a*u-o*c,t[e+3]=h*p-a*c-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(n/2),c=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ri(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+s*a+n*l-r*o,this._y=n*h+s*o+r*a-i*l,this._z=r*h+s*l+i*o-n*a,this._w=s*h-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,r=t._z,s=t._w,a=this.dot(t);a<0&&(i=-i,n=-n,r=-r,s=-s,a=-a);let o=1-e;if(a<.9995){const t=Math.acos(a),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this._onChangeCallback()}else this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},di=class t{static{t.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(mi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(mi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*n-a*i),h=2*(a*e-r*n),c=2*(r*i-s*e);return this.x=e+o*l+s*c-a*h,this.y=i+o*h+a*l-r*c,this.z=n+o*c+r*h-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=ri(this.x,t.x,e.x),this.y=ri(this.y,t.y,e.y),this.z=ri(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ri(this.x,t,e),this.y=ri(this.y,t,e),this.z=ri(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ri(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return pi.copy(this).projectOnVector(t),this.sub(pi)}reflect(t){return this.sub(pi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(ri(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const pi=new di,mi=new ui;let fi=class t{static{t.prototype.isMatrix3=!0}constructor(t,e,i,n,r,s,a,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l)}set(t,e,i,n,r,s,a,o,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=r,h[5]=o,h[6]=i,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],y=n[1],_=n[4],v=n[7],x=n[2],b=n[5],M=n[8];return r[0]=s*m+a*y+o*x,r[3]=s*f+a*_+o*b,r[6]=s*g+a*v+o*M,r[1]=l*m+h*y+c*x,r[4]=l*f+h*_+c*b,r[7]=l*g+h*v+c*M,r[2]=u*m+d*y+p*x,r[5]=u*f+d*_+p*b,r[8]=u*g+d*v+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*s*h-e*a*l-i*r*h+i*a*o+n*r*l-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*s-a*l,u=a*o-h*r,d=l*r-s*o,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(n*l-h*i)*m,t[2]=(a*i-n*s)*m,t[3]=u*m,t[4]=(h*e-n*o)*m,t[5]=(n*r-a*e)*m,t[6]=d*m,t[7]=(i*o-l*e)*m,t[8]=(s*e-i*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*s+l*a)+s+t,-n*l,n*o,-n*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(gi.makeScale(t,e)),this}rotate(t){return this.premultiply(gi.makeRotation(-t)),this}translate(t,e){return this.premultiply(gi.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}};const gi=new fi,yi=(new fi).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_i=(new fi).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vi(){const t={enabled:!0,workingColorSpace:Se,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===we&&(t.r=bi(t.r),t.g=bi(t.g),t.b=bi(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===we&&(t.r=Mi(t.r),t.g=Mi(t.g),t.b=Mi(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===be?Te:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return Ke("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return Ke("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],n=[.3127,.329];return t.define({[Se]:{primaries:e,whitePoint:n,transfer:Te,toXYZ:yi,fromXYZ:_i,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:Me},outputColorSpaceConfig:{drawingBufferColorSpace:Me}},[Me]:{primaries:e,whitePoint:n,transfer:we,toXYZ:yi,fromXYZ:_i,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:Me}}}),t}const xi=vi();function bi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Mi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Si,Ti=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===Si&&(Si=Ge("canvas")),Si.width=t.width,Si.height=t.height;const e=Si.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=Si}return i.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=Ge("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ri).x}get height(){return this.source.getSize(Ri).y}get depth(){return this.source.getSize(Ri).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(void 0===i){Ye(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i:Ye(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==X)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case $:t.x=t.x-Math.floor(t.x);break;case Q:t.x=t.x<0?0:1;break;case tt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case $:t.y=t.y-Math.floor(t.y);break;case Q:t.y=t.y<0?0:1;break;case tt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}};Ni.DEFAULT_IMAGE=null,Ni.DEFAULT_MAPPING=X,Ni.DEFAULT_ANISOTROPY=1;let Ii=class t{static{t.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(h-u)o&&t>y?ty?o1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),null!==this.pivot&&(n.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(t=>({...t})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(n.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(n.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(n.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e0){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;eo+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:t,target:this})));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(dn)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new un;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const mn={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},fn={h:0,s:0,l:0},gn={h:0,s:0,l:0};function yn(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}let _n=class{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Me){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,xi.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=xi.workingColorSpace){return this.r=t,this.g=e,this.b=i,xi.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=xi.workingColorSpace){if(t=si(t,1),e=ri(e,0,1),i=ri(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=yn(r,n,t+1/3),this.g=yn(r,n,t),this.b=yn(r,n,t-1/3)}return xi.colorSpaceToWorking(this,n),this}setStyle(t,e=Me){function i(e){void 0!==e&&parseFloat(e)<1&&Ye("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=n[1],a=n[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ye("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,16),e);Ye("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Me){const i=mn[t.toLowerCase()];return void 0!==i?this.setHex(i,e):Ye("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=bi(t.r),this.g=bi(t.g),this.b=bi(t.b),this}copyLinearToSRGB(t){return this.r=Mi(t.r),this.g=Mi(t.g),this.b=Mi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Me){return xi.workingToColorSpace(vn.copy(this),t),65536*Math.round(ri(255*vn.r,0,255))+256*Math.round(ri(255*vn.g,0,255))+Math.round(ri(255*vn.b,0,255))}getHexString(t=Me){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=xi.workingColorSpace){xi.workingToColorSpace(vn.copy(this),e);const i=vn.r,n=vn.g,r=vn.b,s=Math.max(i,n,r),a=Math.min(i,n,r);let o,l;const h=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=h<=.5?t/(s+a):t/(2-s-a),s){case i:o=(n-r)/t+(n0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Sn=new di,Tn=new di,wn=new di,En=new di,An=new di,Cn=new di,Rn=new di,Nn=new di,In=new di,Pn=new di,Ln=new Ii,Dn=new Ii,On=new Ii;class Un{constructor(t=new di,e=new di,i=new di){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),Sn.subVectors(t,e),n.cross(Sn);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){Sn.subVectors(n,e),Tn.subVectors(i,e),wn.subVectors(t,e);const s=Sn.dot(Sn),a=Sn.dot(Tn),o=Sn.dot(wn),l=Tn.dot(Tn),h=Tn.dot(wn),c=s*l-a*a;if(0===c)return r.set(0,0,0),null;const u=1/c,d=(l*o-a*h)*u,p=(s*h-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return null!==this.getBarycoord(t,e,i,n,En)&&(En.x>=0&&En.y>=0&&En.x+En.y<=1)}static getInterpolation(t,e,i,n,r,s,a,o){return null===this.getBarycoord(t,e,i,n,En)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,En.x),o.addScaledVector(s,En.y),o.addScaledVector(a,En.z),o)}static getInterpolatedAttribute(t,e,i,n,r,s){return Ln.setScalar(0),Dn.setScalar(0),On.setScalar(0),Ln.fromBufferAttribute(t,e),Dn.fromBufferAttribute(t,i),On.fromBufferAttribute(t,n),s.setScalar(0),s.addScaledVector(Ln,r.x),s.addScaledVector(Dn,r.y),s.addScaledVector(On,r.z),s}static isFrontFacing(t,e,i,n){return Sn.subVectors(i,e),Tn.subVectors(t,e),Sn.cross(Tn).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Sn.subVectors(this.c,this.b),Tn.subVectors(this.a,this.b),.5*Sn.cross(Tn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Un.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Un.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,r){return Un.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Un.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Un.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let s,a;An.subVectors(n,i),Cn.subVectors(r,i),Nn.subVectors(t,i);const o=An.dot(Nn),l=Cn.dot(Nn);if(o<=0&&l<=0)return e.copy(i);In.subVectors(t,n);const h=An.dot(In),c=Cn.dot(In);if(h>=0&&c<=h)return e.copy(n);const u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return s=o/(o-h),e.copy(i).addScaledVector(An,s);Pn.subVectors(t,r);const d=An.dot(Pn),p=Cn.dot(Pn);if(p>=0&&d<=p)return e.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector(Cn,a);const f=h*p-d*c;if(f<=0&&c-h>=0&&d-p>=0)return Rn.subVectors(r,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(Rn,a);const g=1/(f+m+u);return s=m*g,a=u*g,e.copy(i).addScaledVector(An,s).addScaledVector(Cn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Fn=class{constructor(t=new di(1/0,1/0,1/0),e=new di(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,kn),kn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(qn),Yn.subVectors(this.max,qn),Vn.subVectors(t.a,qn),Gn.subVectors(t.b,qn),Hn.subVectors(t.c,qn),Wn.subVectors(Gn,Vn),jn.subVectors(Hn,Gn),Xn.subVectors(Vn,Hn);let e=[0,-Wn.z,Wn.y,0,-jn.z,jn.y,0,-Xn.z,Xn.y,Wn.z,0,-Wn.x,jn.z,0,-jn.x,Xn.z,0,-Xn.x,-Wn.y,Wn.x,0,-jn.y,jn.x,0,-Xn.y,Xn.x,0];return!!Jn(e,Vn,Gn,Hn,Yn)&&(e=[1,0,0,0,1,0,0,0,1],!!Jn(e,Vn,Gn,Hn,Yn)&&(Zn.crossVectors(Wn,jn),e=[Zn.x,Zn.y,Zn.z],Jn(e,Vn,Gn,Hn,Yn)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,kn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(kn).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zn)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}};const zn=[new di,new di,new di,new di,new di,new di,new di,new di],kn=new di,Bn=new Fn,Vn=new di,Gn=new di,Hn=new di,Wn=new di,jn=new di,Xn=new di,qn=new di,Yn=new di,Zn=new di,Kn=new di;function Jn(t,e,i,n,r){for(let s=0,a=t.length-3;s<=a;s+=3){Kn.fromArray(t,s);const a=r.x*Math.abs(Kn.x)+r.y*Math.abs(Kn.y)+r.z*Math.abs(Kn.z),o=e.dot(Kn),l=i.dot(Kn),h=n.dot(Kn);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const $n=Qn();function Qn(){const t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),n=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(n[t]=0,n[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(n[t]=1024>>-e-14,n[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(n[t]=e+15<<10,n[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(n[t]=31744,n[256|t]=64512,r[t]=24,r[256|t]=24):(n[t]=31744,n[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;!(8388608&e);)e<<=1,i-=8388608;e&=-8388609,i+=947912704,s[t]=e|i}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function tr(t){Math.abs(t)>65504&&Ye("DataUtils.toHalfFloat(): Value out of range."),t=ri(t,-65504,65504),$n.floatView[0]=t;const e=$n.uint32View[0],i=e>>23&511;return $n.baseTable[i]+((8388607&e)>>$n.shiftTable[i])}function er(t){const e=t>>10;return $n.uint32View[0]=$n.mantissaTable[$n.offsetTable[e]+(1023&t)]+$n.exponentTable[e],$n.floatView[0]}class ir{static toHalfFloat(t){return tr(t)}static fromHalfFloat(t){return er(t)}}const nr=new di,rr=new ci;let sr=0,ar=class extends $e{constructor(t,e,i=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:sr++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=Oe,this.updateRanges=[],this.gpuType=pt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;nthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;dr.subVectors(t,this.center);const e=dr.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(dr,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(pr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(dr.copy(t.center).add(pr)),this.expandByPoint(dr.copy(t.center).sub(pr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},fr=0;const gr=new Ui,yr=new cn,_r=new di,vr=new Fn,xr=new Fn,br=new di;class Mr extends $e{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:fr++}),this.uuid=ni(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?hr:or)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new fi).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return gr.makeRotationFromQuaternion(t),this.applyMatrix4(gr),this}rotateX(t){return gr.makeRotationX(t),this.applyMatrix4(gr),this}rotateY(t){return gr.makeRotationY(t),this.applyMatrix4(gr),this}rotateZ(t){return gr.makeRotationZ(t),this.applyMatrix4(gr),this}translate(t,e,i){return gr.makeTranslation(t,e,i),this.applyMatrix4(gr),this}scale(t,e,i){return gr.makeScale(t,e,i),this.applyMatrix4(gr),this}lookAt(t){return yr.lookAt(t),yr.updateMatrix(),this.applyMatrix4(yr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_r).negate(),this.translate(_r.x,_r.y,_r.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let i=0,n=t.length;ie.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Fn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new di(-1/0,-1/0,-1/0),new di(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.toJSON()),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone());const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){Ye(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:Ye(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),this.blendSrc!==f&&(i.blendSrc=this.blendSrc),this.blendDst!==g&&(i.blendDst=this.blendDst),this.blendEquation!==l&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ee&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ee&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ee&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class Rr extends Cr{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new _n(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Nr=new di,Ir=new di,Pr=new di,Lr=new ci,Dr=new ci,Or=new Ui,Ur=new di,Fr=new di,zr=new di,kr=new ci,Br=new ci,Vr=new ci;class Gr extends cn{constructor(t=new Rr){if(super(),this.isSprite=!0,this.type="Sprite",void 0===wr){wr=new Mr;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Sr(t,5);wr.setIndex([0,1,2,0,2,3]),wr.setAttribute("position",new Er(e,3,0,!1)),wr.setAttribute("uv",new Er(e,2,3,!1))}this.geometry=wr,this.material=t,this.center=new ci(.5,.5),this.count=1}raycast(t,e){null===t.camera&&Ze('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ir.setFromMatrixScale(this.matrixWorld),Or.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Pr.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Ir.multiplyScalar(-Pr.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;Hr(Ur.set(-.5,-.5,0),Pr,s,Ir,n,r),Hr(Fr.set(.5,-.5,0),Pr,s,Ir,n,r),Hr(zr.set(.5,.5,0),Pr,s,Ir,n,r),kr.set(0,0),Br.set(1,0),Vr.set(1,1);let a=t.ray.intersectTriangle(Ur,Fr,zr,!1,Nr);if(null===a&&(Hr(Fr.set(-.5,.5,0),Pr,s,Ir,n,r),Br.set(0,1),a=t.ray.intersectTriangle(Ur,zr,Fr,!1,Nr),null===a))return;const o=t.ray.origin.distanceTo(Nr);ot.far||e.push({distance:o,point:Nr.clone(),uv:Un.getInterpolation(Nr,Ur,Fr,zr,kr,Br,Vr,new ci),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Hr(t,e,i,n,r,s){Lr.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(Dr.x=s*Lr.x-r*Lr.y,Dr.y=r*Lr.x+s*Lr.y):Dr.copy(Lr),t.copy(e),t.x+=Dr.x,t.y+=Dr.y,t.applyMatrix4(Or)}const Wr=new di,jr=new di;class Xr extends cn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,i=e.length;t0){let i,n;for(i=1,n=e.length;i0){Wr.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(Wr);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Wr.setFromMatrixPosition(t.matrixWorld),jr.setFromMatrixPosition(this.matrixWorld);const i=Wr.distanceTo(jr)/t.zoom;let n,r;for(e[0].object.visible=!0,n=1,r=e.length;n=t))break;e[n-1].object.visible=!1,e[n].object.visible=!0}for(this._currentLevel=n-1;n0)if(c=s*o-a,u=s*a-o,p=r*h,c>=0)if(u>=-p)if(u<=p){const t=1/h;c*=t,u*=t,d=c*(c+s*u+2*a)+u*(s*c+u+2*o)+l}else u=r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;else u=-r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;else u<=-p?(c=Math.max(0,-(-s*r+a)),u=c>0?-r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+l):u<=p?(c=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(c=Math.max(0,-(s*r+a)),u=c>0?r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+l);else u=s>0?-r:r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Yr).addScaledVector(Zr,u),d}intersectSphere(t,e){qr.subVectors(t.center,this.origin);const i=qr.dot(this.direction),n=qr.dot(qr)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),i>s||r>n?null:((r>i||isNaN(i))&&(i=r),(s=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,qr)}intersectTriangle(t,e,i,n,r){Jr.subVectors(e,t),$r.subVectors(i,t),Qr.crossVectors(Jr,$r);let s,a=this.direction.dot(Qr);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Kr.subVectors(this.origin,t);const o=s*this.direction.dot($r.crossVectors(Kr,$r));if(o<0)return null;const l=s*this.direction.dot(Jr.cross(Kr));if(l<0)return null;if(o+l>a)return null;const h=-s*Kr.dot(Qr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class es extends Cr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _n(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 Xi,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const is=new Ui,ns=new ts,rs=new mr,ss=new di,as=new di,os=new di,ls=new di,hs=new di,cs=new di,us=new di,ds=new di;class ps extends cn{constructor(t=new Mr,e=new es){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)return}is.copy(r).invert(),ns.copy(t.ray).applyMatrix4(is),null!==i.boundingBox&&!1===ns.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,ns)}}_computeIntersections(t,e,i){let n;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;ri.far?null:{distance:h,point:ds.clone(),object:t}}(t,e,i,n,as,os,ls,us);if(c){const t=new di;Un.getBarycoord(us,as,os,ls,t),r&&(c.uv=Un.getInterpolatedAttribute(r,o,l,h,t,new ci)),s&&(c.uv1=Un.getInterpolatedAttribute(s,o,l,h,t,new ci)),a&&(c.normal=Un.getInterpolatedAttribute(a,o,l,h,t,new di),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:l,c:h,normal:new di,materialIndex:0};Un.getNormal(as,os,ls,e.normal),c.face=e,c.barycoord=t}return c}const fs=new Ii,gs=new Ii,ys=new Ii,_s=new Ii,vs=new Ui,xs=new di,bs=new mr,Ms=new Ui,Ss=new ts;class Ts extends ps{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=W,this.bindMatrix=new Ui,this.bindMatrixInverse=new Ui,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Fn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t1)?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||Vs.getNormalMatrix(t),n=this.coplanarPoint(ks).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Hs=new mr,Ws=new ci(.5,.5),js=new di;class Xs{constructor(t=new Gs,e=new Gs,i=new Gs,n=new Gs,r=new Gs,s=new Gs){this.planes=[t,e,i,n,r,s]}set(t,e,i,n,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3,i=!1){const n=this.planes,r=t.elements,s=r[0],a=r[1],o=r[2],l=r[3],h=r[4],c=r[5],u=r[6],d=r[7],p=r[8],m=r[9],f=r[10],g=r[11],y=r[12],_=r[13],v=r[14],x=r[15];if(n[0].setComponents(l-s,d-h,g-p,x-y).normalize(),n[1].setComponents(l+s,d+h,g+p,x+y).normalize(),n[2].setComponents(l+a,d+c,g+m,x+_).normalize(),n[3].setComponents(l-a,d-c,g-m,x-_).normalize(),i)n[4].setComponents(o,u,f,v).normalize(),n[5].setComponents(l-o,d-u,g-f,x-v).normalize();else if(n[4].setComponents(l-o,d-u,g-f,x-v).normalize(),e===Fe)n[5].setComponents(l+o,d+u,g+f,x+v).normalize();else{if(e!==ze)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(o,u,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Hs.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Hs.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Hs)}intersectsSprite(t){Hs.center.set(0,0,0);const e=Ws.distanceTo(t.center);return Hs.radius=.7071067811865476+e,Hs.applyMatrix4(t.matrixWorld),this.intersectsSphere(Hs)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,js.y=n.normal.y>0?t.max.y:t.min.y,js.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(js)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const qs=new Ui,Ys=new Xs;class Zs{constructor(){this.coordinateSystem=Fe}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=n}reset(){this.list.length=0,this.index=0}}const ta=new Ui,ea=new _n(1,1,1),ia=new Xs,na=new Zs,ra=new Fn,sa=new mr,aa=new di,oa=new di,la=new di,ha=new Qs,ca=new ps,ua=[];function da(t,e,i=0){const n=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s65535?new Uint32Array(n):new Uint16Array(n);e.setIndex(new ar(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(!t.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=t.getAttribute(i),r=e.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Fn);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,n=e.length;i=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Ks),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=e):(i=this._instanceInfo.length,this._instanceInfo.push(e));const n=this._matricesTexture;ta.identity().toArray(n.image.data,16*i),n.needsUpdate=!0;const r=this._colorsTexture;return r&&(ea.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,i=-1){this._initializeGeometry(t),this._validateGeometry(t);const n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=-1===i?s.count:i),-1!==n.indexStart&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Ks),a=this._availableGeometryIds.shift(),r[a]=n):(a=this._geometryCount,this._geometryCount++,r.push(n)),this.setGeometryAt(a,t),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,n=null!==i.getIndex(),r=i.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(n&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in i.attributes){const n=e.getAttribute(t),r=i.getAttribute(t);da(n,r,o);const s=n.itemSize;for(let t=n.count,e=l;t=e.length||!1===e[t].active)return this;const i=this._instanceInfo;for(let e=0,n=i.length;ee).sort((t,e)=>i[t].vertexStart-i[e].vertexStart),r=this.geometry;for(let s=0,a=i.length;s=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[t];if(null===n.boundingBox){const t=new Fn,e=i.index,r=i.attributes.position;for(let i=n.start,s=n.start+n.count;i=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[t];if(null===n.boundingSphere){const e=new mr;this.getBoundingBoxAt(t,ra),ra.getCenter(e.center);const r=i.index,s=i.attributes.position;let a=0;for(let t=n.start,i=n.start+n.count;tt.active);if(Math.max(...i.map(t=>t.vertexStart+t.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...i.map(t=>t.indexStart+t.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const n=this.geometry;n.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Mr,this._initializeGeometry(n));const r=this.geometry;n.index&&pa(n.index.array,r.index.array);for(const t in n.attributes)pa(n.attributes[t].array,r.attributes[t].array)}raycast(t,e){const i=this._instanceInfo,n=this._geometryInfo,r=this.matrixWorld,s=this.geometry;ca.material=this.material,ca.geometry.index=s.index,ca.geometry.attributes=s.attributes,null===ca.geometry.boundingBox&&(ca.geometry.boundingBox=new Fn),null===ca.geometry.boundingSphere&&(ca.geometry.boundingSphere=new mr);for(let s=0,a=i.length;s({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(t=>({...t})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=n.getIndex();let a=null===s?1:s.array.BYTES_PER_ELEMENT,o=1;r.wireframe&&(o=2,a=n.attributes.position.count>65535?4:2);const l=this._instanceInfo,h=this._multiDrawStarts,c=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,f=i.isArrayCamera?na:ia;d&&!i.isArrayCamera&&(ta.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),ia.setFromProjectionMatrix(ta,i.coordinateSystem,i.reversedDepth));let g=0;if(this.sortObjects){ta.copy(this.matrixWorld).invert(),aa.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ta),oa.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(ta);for(let t=0,e=l.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tn)return;ba.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(ba);return le.far?void 0:{distance:l,point:Ma.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const wa=new di,Ea=new di;class Aa extends Sa{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Ua extends Ni{constructor(t,e,i,n,r=1006,s=1006,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const h=this;"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(function e(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class Fa extends Ni{constructor(t,e,i,n,r,s,a,o,l,h,c,u){super(null,s,a,o,l,h,n,r,c,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}let za=class extends Ni{constructor(t=[],e=301,i,n,r,s,a,o,l,h){super(t,e,i,n,r,s,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};let ka=class extends Ni{constructor(t,e,i=1014,n,r,s,a=1003,o=1003,l,h=1026,c=1){if(h!==St&&h!==Tt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},n,r,s,a,o,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ei(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}};class Ba extends ka{constructor(t,e=1014,i=301,n,r,s=1003,a=1003,o,l=1026){const h={width:t,height:t,depth:1},c=[h,h,h,h,h,h];super(t,t,e,i,n,r,s,a,o,l),this.image=c,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Va extends Ni{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Ga extends Mr{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],h=[],c=[];let u=0,d=0;function p(t,e,i,n,r,s,p,m,f,g,y){const _=s/f,v=p/g,x=s/2,b=p/2,M=m/2,S=f+1,T=g+1;let w=0,E=0;const A=new di;for(let s=0;s0?1:-1,h.push(A.x,A.y,A.z),c.push(o/f),c.push(1-s/g),w+=1}}for(let t=0;t0){const t=(y-1)*m;for(let e=0;e0||0!==n)&&(h.push(s,a,l),_+=3),(e>0||n!==r-1)&&(h.push(a,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===s&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new cr(c,3)),this.setAttribute("normal",new cr(u,3)),this.setAttribute("uv",new cr(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ja(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Xa extends ja{constructor(t=1,e=1,i=32,n=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,i,n,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new Xa(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class qa extends Mr{constructor(t=[],e=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const r=[],s=[];function a(t,e,i,n){const r=n+1,s=[];for(let n=0;n<=r;n++){s[n]=[];const a=t.clone().lerp(i,n/r),o=e.clone().lerp(i,n/r),l=r-n;for(let t=0;t<=l;t++)s[n][t]=0===t&&n===r?a:a.clone().lerp(o,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(s[t+0]+=1),i<.2&&(s[t+2]+=1),n<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new cr(r,3)),this.setAttribute("normal",new cr(r.slice(),3)),this.setAttribute("uv",new cr(s,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qa(t.vertices,t.indices,t.radius,t.detail)}}class Ya extends qa{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ya(t.radius,t.detail)}}const Za=new di,Ka=new di,Ja=new di,$a=new Un;class Qa extends Mr{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,n=Math.pow(10,i),r=Math.cos(ei*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],h=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t0)){l=n;break}l=n-1}if(n=l,i[n]===s)return n/(r-1);const h=i[n];return(n+(s-h)/(i[n+1]-h))/(r-1)}getTangent(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),a=this.getPoint(r),o=e||(s.isVector2?new ci:new di);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){const i=new di,n=[],r=[],s=[],a=new di,o=new Ui;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new di)}r[0]=new di,s[0]=new di;let l=Number.MAX_VALUE;const h=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),s[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(n[e-1],n[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ri(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(ri(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(n[i],e*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class eo extends to{constructor(t=0,e=0,i=1,n=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new ci){const i=e,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===h&&l===r-1&&(l=r-2,h=1),this.closed||l>0?a=n[(l-1)%r]:(so.subVectors(n[0],n[1]).add(n[0]),a=so);const c=n[l%r],u=n[(l+1)%r];if(this.closed||l+2n.length-2?n.length-1:s+1],c=n[s>n.length-3?n.length-1:s+2];return i.set(co(a,o.x,l.x,h.x,c.x),co(a,o.y,l.y,h.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){const t=n[r]-i,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,n=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class To extends So{constructor(t){super(t),this.uuid=ni(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i80*i){o=t[0],l=t[1];let e=o,n=l;for(let s=i;se&&(e=i),r>n&&(n=r)}h=Math.max(e-o,n-l),h=0!==h?32767/h:0}return Co(s,a,i,o,l,h,0),a}function Eo(t,e,i,n,r){let s;if(r===function(t,e,i,n){let r=0;for(let s=e,a=i-n;s0)for(let r=e;r=e;r-=n)s=Yo(r/n|0,t[r],t[r+1],s);return s&&Go(s,s.next)&&(Zo(s),s=s.next),s}function Ao(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Go(n,n.next)&&0!==Vo(n.prev,n,n.next))n=n.next;else{if(Zo(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Co(t,e,i,n,r,s,a){if(!t)return;!a&&s&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Uo(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let s=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||r.z<=a.z)?(n=r,r=r.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=a}s.nextZ=null,i*=2}while(e>1)}(r)}(t,n,r,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(s?No(t,n,r,s):Ro(t))e.push(l.i,t.i,h.i),Zo(t),t=h.next,o=h.next;else if((t=h)===o){a?1===a?Co(t=Io(Ao(t),e),e,i,n,r,s,2):2===a&&Po(t,e,i,n,r,s):Co(Ao(t),e,i,n,r,s,1);break}}}function Ro(t){const e=t.prev,i=t,n=t.next;if(Vo(e,i,n)>=0)return!1;const r=e.x,s=i.x,a=n.x,o=e.y,l=i.y,h=n.y,c=Math.min(r,s,a),u=Math.min(o,l,h),d=Math.max(r,s,a),p=Math.max(o,l,h);let m=n.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&ko(r,o,s,l,a,h,m.x,m.y)&&Vo(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function No(t,e,i,n){const r=t.prev,s=t,a=t.next;if(Vo(r,s,a)>=0)return!1;const o=r.x,l=s.x,h=a.x,c=r.y,u=s.y,d=a.y,p=Math.min(o,l,h),m=Math.min(c,u,d),f=Math.max(o,l,h),g=Math.max(c,u,d),y=Uo(p,m,e,i,n),_=Uo(f,g,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=y&&x&&x.z<=_;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&ko(o,c,l,u,h,d,v.x,v.y)&&Vo(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&ko(o,c,l,u,h,d,x.x,x.y)&&Vo(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=y;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&ko(o,c,l,u,h,d,v.x,v.y)&&Vo(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&ko(o,c,l,u,h,d,x.x,x.y)&&Vo(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Io(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Go(n,r)&&Ho(n,i,i.next,r)&&Xo(n,r)&&Xo(r,n)&&(e.push(n.i,i.i,r.i),Zo(i),Zo(i.next),i=t=r),i=i.next}while(i!==t);return Ao(i)}function Po(t,e,i,n,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Bo(a,t)){let o=qo(a,t);return a=Ao(a,a.next),o=Ao(o,o.next),Co(a,e,i,n,r,s,0),void Co(o,e,i,n,r,s,0)}t=t.next}a=a.next}while(a!==t)}function Lo(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function Do(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let s,a=-1/0;if(Go(t,i))return i;do{if(Go(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>a&&(a=t,s=i.x=i.x&&i.x>=l&&n!==i.x&&zo(rs.x||i.x===s.x&&Oo(s,i)))&&(s=i,c=e)}i=i.next}while(i!==o);return s}(t,e);if(!i)return e;const n=qo(i,t);return Ao(n,n.next),Ao(i,i.next)}function Oo(t,e){return Vo(t.prev,t,e.prev)<0&&Vo(e.next,t,t.next)<0}function Uo(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Fo(t){let e=t,i=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(i-a)*(e-o)&&(i-a)*(s-o)>=(r-a)*(n-o)}function ko(t,e,i,n,r,s,a,o){return!(t===a&&e===o)&&zo(t,e,i,n,r,s,a,o)}function Bo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Ho(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Xo(t,e)&&Xo(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Vo(t.prev,t,e.prev)||Vo(t,e.prev,e))||Go(t,e)&&Vo(t.prev,t,t.next)>0&&Vo(e.prev,e,e.next)>0)}function Vo(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Go(t,e){return t.x===e.x&&t.y===e.y}function Ho(t,e,i,n){const r=jo(Vo(t,e,i)),s=jo(Vo(t,e,n)),a=jo(Vo(i,n,t)),o=jo(Vo(i,n,e));return r!==s&&a!==o||(!(0!==r||!Wo(t,i,e))||(!(0!==s||!Wo(t,n,e))||(!(0!==a||!Wo(i,t,n))||!(0!==o||!Wo(i,e,n)))))}function Wo(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function jo(t){return t>0?1:t<0?-1:0}function Xo(t,e){return Vo(t.prev,t,t.next)<0?Vo(t,e,t.next)>=0&&Vo(t,t.prev,e)>=0:Vo(t,e,t.prev)<0||Vo(t,t.next,e)<0}function qo(t,e){const i=Ko(t.i,t.x,t.y),n=Ko(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Yo(t,e,i,n){const r=Ko(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Zo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ko(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Jo{static triangulate(t,e,i=2){return wo(t,e,i)}}class $o{static area(t){const e=t.length;let i=0;for(let n=e-1,r=0;r2&&t[e-1].equals(t[0])&&t.pop()}function tl(t,e){for(let i=0;iNumber.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=e.x-o/u,m=e.y+a/u,f=((i.x-h/d-p)*h-(i.y+l/d-m)*l)/(a*h-o*l);n=p+a*f-t.x,r=m+o*f-t.y;const g=n*n+r*r;if(g<=2)return new ci(n,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(h)&&(t=!0),t?(n=-o,r=a,s=Math.sqrt(c)):(n=a,r=o,s=Math.sqrt(c/2))}return new ci(n/s,r/s)}const I=[];for(let t=0,e=A.length,i=e-1,n=t+1;t=0;t--){const e=t/p,i=c*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=A.length;t=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=o+2*p;t0)&&d.push(e,r,l),(t!==i-1||o0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class Tl extends Sl{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wl extends Cr{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new _n(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 _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(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 Xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class El extends wl{constructor(t){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 ci(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ri(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new _n(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 _n(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new _n(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Al extends Cr{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _n(16777215),this.specular=new _n(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Cl extends Cr{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new _n(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Rl extends Cr{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Nl extends Cr{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new _n(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Il extends Cr{constructor(t){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(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Pl extends Cr{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Ll extends Cr{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new _n(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Dl extends fa{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Ol(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Ul(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort(function(e,i){return t[e]-t[i]}),i}function Fl(t,e,i){const n=t.length,r=new t.constructor(n);for(let s=0,a=0;a!==n;++s){const n=i[s]*e;for(let i=0;i!==e;++i)r[a++]=t[n+i]}return r}function zl(t,e,i,n){let r=1,s=t[0];for(;void 0!==s&&void 0===s[n];)s=t[r++];if(void 0===s)return;let a=s[n];if(void 0!==a)if(Array.isArray(a))do{a=s[n],void 0!==a&&(e.push(s.time),i.push(...a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[n],void 0!==a&&(e.push(s.time),a.toArray(i,i.length)),s=t[r++]}while(void 0!==s);else do{a=s[n],void 0!==a&&(e.push(s.time),i.push(a)),s=t[r++]}while(void 0!==s)}class kl{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let s;i:{n:if(!(t=r)){const a=e[1];t=r)break e}s=i,i=0;break i}break t}for(;i>>1;te;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=i.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Ze("KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(Ze("KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){Ze("KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==s&&s>n){Ze("KeyframeTrack: Out of order keys.",this,e,n,s),t=!1;break}s=n}if(void 0!==n&&Ve(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){Ze("KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===me,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*i,n=s*i,a=0;a!==i;++a)e[n+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}Wl.prototype.ValueTypeName="",Wl.prototype.TimeBufferType=Float32Array,Wl.prototype.ValueBufferType=Float32Array,Wl.prototype.DefaultInterpolation=pe;class jl extends Wl{constructor(t,e,i){super(t,e,i)}}jl.prototype.ValueTypeName="bool",jl.prototype.ValueBufferType=Array,jl.prototype.DefaultInterpolation=de,jl.prototype.InterpolantFactoryMethodLinear=void 0,jl.prototype.InterpolantFactoryMethodSmooth=void 0;class Xl extends Wl{constructor(t,e,i,n){super(t,e,i,n)}}Xl.prototype.ValueTypeName="color";class ql extends Wl{constructor(t,e,i,n){super(t,e,i,n)}}ql.prototype.ValueTypeName="number";class Yl extends kl{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(i-e)/(n-e);let l=t*a;for(let t=l+a;l!==t;l+=4)ui.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Zl extends Wl{constructor(t,e,i,n){super(t,e,i,n)}InterpolantFactoryMethodLinear(t){return new Yl(this.times,this.values,this.getValueSize(),t)}}Zl.prototype.ValueTypeName="quaternion",Zl.prototype.InterpolantFactoryMethodSmooth=void 0;class Kl extends Wl{constructor(t,e,i){super(t,e,i)}}Kl.prototype.ValueTypeName="string",Kl.prototype.ValueBufferType=Array,Kl.prototype.DefaultInterpolation=de,Kl.prototype.InterpolantFactoryMethodLinear=void 0,Kl.prototype.InterpolantFactoryMethodSmooth=void 0;class Jl extends Wl{constructor(t,e,i,n){super(t,e,i,n)}}Jl.prototype.ValueTypeName="vector";class $l{constructor(t="",e=-1,i=[],n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=ni(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(Ql(i[t]).scale(n));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,n=i.length;t!==n;++t)e.push(Wl.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const s=[];for(const t in n)s.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return s}static parseAnimation(t,e){if(Ye("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return Ze("AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const s=[],a=[];zl(i,s,a,n),0!==s.length&&r.push(new t(e,s,a))}},n=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)},0);if(void 0!==sh[t])return void sh[t].push({onLoad:e,onProgress:i,onError:n});sh[t]=[],sh[t].push({onLoad:e,onProgress:i,onError:n});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&Ye("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=sh[t],n=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){n.read().then(({done:n,value:r})=>{if(n)t.close();else{o+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=i.length;t{t.error(e)})}()}});return new Response(l)}throw new ah(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(""===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then(t=>n.decode(t))}}}).then(e=>{th.add(`file:${t}`,e);const i=sh[t];delete sh[t];for(let t=0,n=i.length;t{const i=sh[t];if(void 0===i)throw this.manager.itemError(t),e;delete sh[t];for(let t=0,n=i.length;t{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class lh extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=[],a=new Fa,o=new oh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function h(h){o.load(t[h],function(t){const i=r.parse(t,!0);s[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(a.minFilter=rt),a.image=s,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(n.uniforms[e]={},r.type){case"t":n.uniforms[e].value=i(r.value);break;case"c":n.uniforms[e].value=(new _n).setHex(r.value);break;case"v2":n.uniforms[e].value=(new ci).fromArray(r.value);break;case"v3":n.uniforms[e].value=(new di).fromArray(r.value);break;case"v4":n.uniforms[e].value=(new Ii).fromArray(r.value);break;case"m3":n.uniforms[e].value=(new fi).fromArray(r.value);break;case"m4":n.uniforms[e].value=(new Ui).fromArray(r.value);break;default:n.uniforms[e].value=r.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(n.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(n.lights=t.lights),void 0!==t.clipping&&(n.clipping=t.clipping),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new ci).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapRotation&&n.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ci).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(n.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(n.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=i(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return zh.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:yl,SpriteMaterial:Rr,RawShaderMaterial:Tl,ShaderMaterial:Sl,PointsMaterial:Ra,MeshPhysicalMaterial:El,MeshStandardMaterial:wl,MeshPhongMaterial:Al,MeshToonMaterial:Cl,MeshNormalMaterial:Rl,MeshLambertMaterial:Nl,MeshDepthMaterial:Il,MeshDistanceMaterial:Pl,MeshBasicMaterial:es,MeshMatcapMaterial:Ll,LineDashedMaterial:Dl,LineBasicMaterial:fa,Material:Cr}[t]}}class kh{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Bh extends Mr{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Vh extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new oh(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):Ze(e),r.manager.itemError(t)}},i,n)}parse(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const r=t.interleavedBuffers[n],s=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers,r=n[e],s=new Uint32Array(r).buffer;return i[e]=s,s}(t,r.buffer),a=Be(r.type,s),o=new Sr(a,r.stride);return o.uuid=r.uuid,e[n]=o,o}const r=t.isInstancedBufferGeometry?new Bh:new Mr,s=t.data.index;if(void 0!==s){const t=Be(s.type,s.array);r.setIndex(new ar(t,1))}const a=t.data.attributes;for(const e in a){const i=a[e];let s;if(i.isInterleavedBufferAttribute){const e=n(t.data,i.data);s=new Er(e,i.itemSize,i.offset,i.normalized)}else{const t=Be(i.type,i.array);s=new(i.isInstancedBufferAttribute?Ns:ar)(t,i.itemSize,i.normalized)}void 0!==i.name&&(s.name=i.name),void 0!==i.usage&&s.setUsage(i.usage),r.setAttribute(e,s)}const o=t.data.morphAttributes;if(o)for(const e in o){const i=o[e],s=[];for(let e=0,r=i.length;e{!0===Xh.has(s)?(n&&n(Xh.get(s)),r.manager.itemError(t),r.manager.itemEnd(t)):(e&&e(i),r.manager.itemEnd(t))}):void setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){th.add(`image-bitmap:${t}`,i),e&&e(i),r.manager.itemEnd(t)}).catch(function(e){n&&n(e),Xh.set(o,e),th.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});th.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Yh;class Zh{static getContext(){return void 0===Yh&&(Yh=new(window.AudioContext||window.webkitAudioContext)),Yh}static setContext(t){Yh=t}}const Kh=new Ui,Jh=new Ui,$h=new Ui;const Qh=-90;class tc extends cn{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Eh(Qh,1,t,e);n.layers=this.layers,this.add(n);const r=new Eh(Qh,1,t,e);r.layers=this.layers,this.add(r);const s=new Eh(Qh,1,t,e);s.layers=this.layers,this.add(s);const a=new Eh(Qh,1,t,e);a.layers=this.layers,this.add(a);const o=new Eh(Qh,1,t,e);o.layers=this.layers,this.add(o);const l=new Eh(Qh,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Fe)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==ze)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,h]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let f=!1;f=!0===t.isWebGLRenderer?t.state.buffers.depth.getReversed():t.reversedDepthBuffer,t.setRenderTarget(i,0,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,r),t.setRenderTarget(i,1,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,2,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,a),t.setRenderTarget(i,3,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,4,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,n),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,h),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class ec extends Eh{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class ic{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=nc.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function nc(){!1===this._document.hidden&&this.reset()}const rc=new di,sc=new ui,ac=new di,oc=new di,lc=new di;class hc extends cn{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void Ye("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void Ye("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;Ye("Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;Ye("Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]}_slerp(t,e,i,n){ui.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,r){const s=this._workIndex*r;ui.multiplyQuaternionsFlat(t,s,t,e,t,i),ui.slerpFlat(t,e,t,e,t,s,n)}_lerp(t,e,i,n,r){const s=1-n;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[i+a]*n}}_lerpAdditive(t,e,i,n,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[i+s]*n}}}const fc="\\[\\]\\.:\\/",gc=new RegExp("["+fc+"]","g"),yc="[^"+fc+"]",_c="[^"+fc.replace("\\.","")+"]",vc=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",yc)+/(WCOD+)?/.source.replace("WCOD",_c)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yc)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yc)+"$"),xc=["material","materials","bones","map"];class bc{constructor(t,e,i){this.path=e,this.parsedPath=i||bc.parseTrackName(e),this.node=bc.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new bc.Composite(t,e,i):new bc(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(gc,"")}static parseTrackName(t){const e=vc.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==xc.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===xe)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(s),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(s),e[i].accumulate(n,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const s=2202===i;if(0===t)return-1===r||!s||1&~r?n:e-n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this._loopCount=r,this.time=n;if(s&&!(1&~r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=ye,n.endingEnd=ye):(n.endingStart=t?this.zeroSlopeAtStart?ye:ge:_e,n.endingEnd=e?this.zeroSlopeAtEnd?ye:ge:_e)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}const Sc=new Float32Array(1);class Tc{constructor(t){this.value=t}clone(){return new Tc(void 0===this.value.clone?this.value:this.value.clone())}}let wc=0;const Ec=new Ui;class Ac{constructor(t,e,i=0,n=1/0){this.ray=new ts(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new qi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Ze("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Ec.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ec),this}intersectObject(t,e=!0,i=[]){return Rc(t,this,i,e),i.sort(Cc),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;nNumber.EPSILON){if(l<0&&(i=e[s],o=-o,a=e[r],l=-l),t.ya.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=l*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=$o.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,a;const o=[];if(1===n.length)return s=n[0],a=new To,a.curves=s.curves,o.push(a),o;let l=!i(n[0].getPoints());l=t?!l:l;const h=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e1){let t=!1,i=0;for(let t=0,e=c.length;t0&&!1===t&&(p=h)}for(let t=0,e=c.length;tt.start-e.start);let e=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include ",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},cu={common:{diffuse:{value:new _n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fi},alphaMap:{value:null},alphaMapTransform:{value:new fi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fi}},envmap:{envMap:{value:null},envMapRotation:{value:new fi},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fi},normalScale:{value:new ci(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _n(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new di},probesMax:{value:new di},probesResolution:{value:new di}},points:{diffuse:{value:new _n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fi},alphaTest:{value:0},uvTransform:{value:new fi}},sprite:{diffuse:{value:new _n(16777215)},opacity:{value:1},center:{value:new ci(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fi},alphaMap:{value:null},alphaMapTransform:{value:new fi},alphaTest:{value:0}}},uu={basic:{uniforms:vl([cu.common,cu.specularmap,cu.envmap,cu.aomap,cu.lightmap,cu.fog]),vertexShader:hu.meshbasic_vert,fragmentShader:hu.meshbasic_frag},lambert:{uniforms:vl([cu.common,cu.specularmap,cu.envmap,cu.aomap,cu.lightmap,cu.emissivemap,cu.bumpmap,cu.normalmap,cu.displacementmap,cu.fog,cu.lights,{emissive:{value:new _n(0)},envMapIntensity:{value:1}}]),vertexShader:hu.meshlambert_vert,fragmentShader:hu.meshlambert_frag},phong:{uniforms:vl([cu.common,cu.specularmap,cu.envmap,cu.aomap,cu.lightmap,cu.emissivemap,cu.bumpmap,cu.normalmap,cu.displacementmap,cu.fog,cu.lights,{emissive:{value:new _n(0)},specular:{value:new _n(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:hu.meshphong_vert,fragmentShader:hu.meshphong_frag},standard:{uniforms:vl([cu.common,cu.envmap,cu.aomap,cu.lightmap,cu.emissivemap,cu.bumpmap,cu.normalmap,cu.displacementmap,cu.roughnessmap,cu.metalnessmap,cu.fog,cu.lights,{emissive:{value:new _n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:hu.meshphysical_vert,fragmentShader:hu.meshphysical_frag},toon:{uniforms:vl([cu.common,cu.aomap,cu.lightmap,cu.emissivemap,cu.bumpmap,cu.normalmap,cu.displacementmap,cu.gradientmap,cu.fog,cu.lights,{emissive:{value:new _n(0)}}]),vertexShader:hu.meshtoon_vert,fragmentShader:hu.meshtoon_frag},matcap:{uniforms:vl([cu.common,cu.bumpmap,cu.normalmap,cu.displacementmap,cu.fog,{matcap:{value:null}}]),vertexShader:hu.meshmatcap_vert,fragmentShader:hu.meshmatcap_frag},points:{uniforms:vl([cu.points,cu.fog]),vertexShader:hu.points_vert,fragmentShader:hu.points_frag},dashed:{uniforms:vl([cu.common,cu.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:hu.linedashed_vert,fragmentShader:hu.linedashed_frag},depth:{uniforms:vl([cu.common,cu.displacementmap]),vertexShader:hu.depth_vert,fragmentShader:hu.depth_frag},normal:{uniforms:vl([cu.common,cu.bumpmap,cu.normalmap,cu.displacementmap,{opacity:{value:1}}]),vertexShader:hu.meshnormal_vert,fragmentShader:hu.meshnormal_frag},sprite:{uniforms:vl([cu.sprite,cu.fog]),vertexShader:hu.sprite_vert,fragmentShader:hu.sprite_frag},background:{uniforms:{uvTransform:{value:new fi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:hu.background_vert,fragmentShader:hu.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new fi}},vertexShader:hu.backgroundCube_vert,fragmentShader:hu.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:hu.cube_vert,fragmentShader:hu.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:hu.equirect_vert,fragmentShader:hu.equirect_frag},distance:{uniforms:vl([cu.common,cu.displacementmap,{referencePosition:{value:new di},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:hu.distance_vert,fragmentShader:hu.distance_frag},shadow:{uniforms:vl([cu.lights,cu.fog,{color:{value:new _n(0)},opacity:{value:1}}]),vertexShader:hu.shadow_vert,fragmentShader:hu.shadow_frag}};uu.physical={uniforms:vl([uu.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fi},clearcoatNormalScale:{value:new ci(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fi},sheen:{value:0},sheenColor:{value:new _n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fi},transmissionSamplerSize:{value:new ci},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fi},attenuationDistance:{value:0},attenuationColor:{value:new _n(0)},specularColor:{value:new _n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fi},anisotropyVector:{value:new ci},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fi}}]),vertexShader:hu.meshphysical_vert,fragmentShader:hu.meshphysical_frag};const du={r:0,b:0,g:0},pu=new Ui,mu=new fi;function fu(t,e,i,n,r,s){const a=new _n(0);let o,l,h=!0===r?0:1,c=null,u=0,d=null;function p(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){const n=t.backgroundBlurriness>0;i=e.get(i,n)}return i}function m(e,n){e.getRGB(du,bl(t)),i.buffers.color.setClear(du.r,du.g,du.b,n,s)}return{getClearColor:function(){return a},setClearColor:function(t,e=1){a.set(t),h=e,m(a,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(a,h)},render:function(e){let n=!1;const r=p(e);null===r?m(a,h):r&&r.isColor&&(m(r,1),n=!0);const o=t.xr.getEnvironmentBlendMode();"additive"===o?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===o&&i.buffers.color.setClear(0,0,0,0,s),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const r=p(i);r&&(r.isCubeTexture||r.mapping===J)?(void 0===l&&(l=new ps(new Ga(1,1,1),new Sl({name:"BackgroundCubeMaterial",uniforms:_l(uu.backgroundCube.uniforms),vertexShader:uu.backgroundCube.vertexShader,fragmentShader:uu.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=r,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(pu.makeRotationFromEuler(i.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&l.material.uniforms.backgroundRotation.value.premultiply(mu),l.material.toneMapped=xi.getTransfer(r.colorSpace)!==we,c===r&&u===r.version&&d===t.toneMapping||(l.material.needsUpdate=!0,c=r,u=r.version,d=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===o&&(o=new ps(new al(2,2),new Sl({name:"BackgroundMaterial",uniforms:_l(uu.background.uniforms),vertexShader:uu.background.vertexShader,fragmentShader:uu.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,o.material.toneMapped=xi.getTransfer(r.colorSpace)!==we,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),c===r&&u===r.version&&d===t.toneMapping||(o.material.needsUpdate=!0,c=r,u=r.version,d=t.toneMapping),o.layers.enableAll(),e.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function gu(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=h(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function h(t){const e=[],n=[],r=[];for(let t=0;t=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,f,l,g),y&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const l=i.getAttributes();for(const e in l){if(l[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,f,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(y||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),l=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const h=l.buffer,c=l.type,p=l.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===ut;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(Ye("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===i.logarithmicDepthBuffer,h=!0===i.reversedDepthBuffer&&e.has("EXT_clip_control");!0===i.reversedDepthBuffer&&!1===h&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===Mt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===mt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==ot&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==pt&&!r)},precision:a,logarithmicDepthBuffer:l,reversedDepthBuffer:h,maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function vu(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Gs,o=new fi,l={value:null,needsUpdate:!1};function h(t,i,n,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=l.value,!0!==r||null===h){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;l.value=r,r=h(u,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}mu.set(-1,0,0,0,1,0,0,0,1);const xu=[.125,.215,.35,.446,.526,.582],bu=20,Mu=new Ih,Su=new _n;let Tu=null,wu=0,Eu=0,Au=!1;const Cu=new di;class Ru{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,r={}){const{size:s=256,position:a=Cu}=r;Tu=this._renderer.getRenderTarget(),wu=this._renderer.getActiveCubeFace(),Eu=this._renderer.getActiveMipmapLevel(),Au=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Lu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Pu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=xu[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,m=3,f=2,g=1,y=new Float32Array(m*p*d),_=new Float32Array(f*p*d),v=new Float32Array(g*p*d);for(let t=0;t2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];y.set(n,m*p*t),_.set(u,f*p*t);const r=[t,t,t,t,t,t];v.set(r,g*p*t)}const x=new Mr;x.setAttribute("position",new ar(y,m)),x.setAttribute("uv",new ar(_,f)),x.setAttribute("faceIndex",new ar(v,g)),n.push(new ps(x,null)),r>4&&r--}return{lodMeshes:n,sizeLods:e,sigmas:i}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(bu),r=new di(0,1,0),s=new Sl({name:"SphericalGaussianBlur",defines:{n:bu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Du(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(n,t,e),this._ggxMaterial=function(t,e,i){const n=new Sl({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Du(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return n}(n,t,e)}return n}_compileMaterial(t){const e=new ps(new Mr,t);this._renderer.compile(e,Mu)}_sceneToCubeUV(t,e,i,n,r){const s=new Eh(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,h=l.autoClear,c=l.toneMapping;l.getClearColor(Su),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(n),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new ps(new Ga,new es({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,d=u.material;let p=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,p=!0):(d.color.copy(Su),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[e],r.y,r.z)):1===i?(s.up.set(0,0,a[e]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[e],r.z)):(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[e]));const h=this._cubeSize;Iu(n,i*h,e>2?h:0,h,h),l.setRenderTarget(n),p&&l.render(u,s),l.render(t,s)}l.toneMapping=c,l.autoClear=h,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===q||t.mapping===Y;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Lu()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Pu());const r=n?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;r.uniforms.envMap.value=t;const a=this._cubeSize;Iu(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,Mu)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let e=1;eu-4?i-u+4:0),m=4*(this._cubeSize-d);o.envMap.value=t.texture,o.roughness.value=c,o.mipInt.value=u-e,Iu(r,p,m,3*d,2*d),n.setRenderTarget(r),n.render(a,Mu),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=u-i,Iu(t,p,m,3*d,2*d),n.setRenderTarget(t),n.render(a,Mu)}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&Ze("blur direction must be either latitudinal or longitudinal!");const h=this._lodMeshes[n];h.material=l;const c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):bu;m>bu&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;ty-4?n-y+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(h,Mu)}}function Nu(t,e,i){const n=new Li(t,e,i);return n.texture.mapping=J,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Iu(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function Pu(){return new Sl({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Du(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Lu(){return new Sl({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Du(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Du(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}class Ou extends Li{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];this.texture=new za(n),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new Ga(5,5,5),r=new Sl({name:"CubemapFromEquirect",uniforms:_l(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new ps(n,r),a=e.minFilter;e.minFilter===at&&(e.minFilter=rt);return new tc(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e=!0,i=!0,n=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}function Uu(t){let e=new WeakMap,i=new WeakMap,n=null;function r(t,e){return e===Z?t.mapping=q:e===K&&(t.mapping=Y),t}function s(t){const i=t.target;i.removeEventListener("dispose",s);const n=e.get(i);void 0!==n&&(e.delete(i),n.dispose())}function a(t){const e=t.target;e.removeEventListener("dispose",a);const n=i.get(e);void 0!==n&&(i.delete(e),n.dispose())}return{get:function(o,l=!1){return null==o?null:l?function(e){if(e&&e.isTexture){const r=e.mapping,s=r===Z||r===K,o=r===q||r===Y;if(s||o){let r=i.get(e);const l=void 0!==r?r.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==l)return null===n&&(n=new Ru(t)),r=s?n.fromEquirectangular(e,r):n.fromCubemap(e,r),r.texture.pmremVersion=e.pmremVersion,i.set(e,r),r.texture;if(void 0!==r)return r.texture;{const l=e.image;return s&&l&&l.height>0||o&&l&&function(t){let e=0;const i=6;for(let n=0;n0){const a=new Ou(n.height);return a.fromEquirectangularTexture(t,i),e.set(i,a),i.addEventListener("dispose",s),r(a.texture,i.mapping)}return null}}}return i}(o)},dispose:function(){e=new WeakMap,i=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Fu(t){const e={};function i(i){if(void 0!==e[i])return e[i];const n=t.getExtension(i);return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&Ke("WebGLRenderer: "+t+" extension not supported."),e}}}function zu(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(void 0===r)return;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e=65535?hr:or)(i,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.versione.maxTextureSize&&(x=Math.ceil(v/e.maxTextureSize),v=e.maxTextureSize);const b=new Float32Array(v*x*4*c),M=new Di(b,v,x,c);M.type=pt,M.needsUpdate=!0;const S=4*_;for(let w=0;w\n\t\t\t#include \n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),h=new ps(o,l),c=new Ih(-1,1,1,-1,0,1);let u,d=null,p=null,m=!1,f=null,g=[],y=!1;this.setSize=function(t,e){s.setSize(t,e),a.setSize(t,e);for(let i=0;i0&&!0===g[0].isRenderPass;const e=s.width,i=s.height;for(let t=0;t0)return t;const r=e*i;let s=Ku[r];if(void 0===s&&(s=new Float32Array(r),Ku[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function id(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i0&&(this.seq=n.concat(r))}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Kd(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Jd=0;const $d=new fi;function Qd(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function tp(t,e){const i=function(t){xi._getMatrix($d,xi.workingColorSpace,t);const e=`mat3( ${$d.elements.map(t=>t.toFixed(4))} )`;switch(xi.getTransfer(t)){case Te:return[e,"LinearTransferOETF"];case we:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}const ep={[F]:"Linear",[z]:"Reinhard",[k]:"Cineon",[B]:"ACESFilmic",[G]:"AgX",[H]:"Neutral",[V]:"Custom"};function ip(t,e){const i=ep[e];return void 0===i?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const np=new di;function rp(){xi.getLuminanceCoefficients(np);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${np.x.toFixed(4)}, ${np.y.toFixed(4)}, ${np.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function sp(t){return""!==t}function ap(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function op(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const lp=/^[ \t]*#include +<([\w\d./]+)>/gm;function hp(t){return t.replace(lp,up)}const cp=new Map;function up(t,e){let i=hu[e];if(void 0===i){const t=cp.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=hu[t],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return hp(i)}const dp=/#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 pp(t){return t.replace(dp,mp)}function mp(t,e,i,n){let r="";for(let t=parseInt(e);t0&&(g+="\n"),y=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(sp).join("\n"),y.length>0&&(y+="\n")):(g=[fp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexNormals?"#define HAS_NORMAL":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\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","\n"].filter(sp).join("\n"),y=[fp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas||i.batchingColor?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?hu.tonemapping_pars_fragment:"",0!==i.toneMapping?ip("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",hu.colorspace_pars_fragment,tp("linearToOutputTexel",i.outputColorSpace),rp(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(sp).join("\n")),a=hp(a),a=ap(a,i),a=op(a,i),o=hp(o),o=ap(o,i),o=op(o,i),a=pp(a),o=pp(o),!0!==i.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,y=["#define varying in",i.glslVersion===Ue?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ue?"":"#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("\n")+"\n"+y);const v=_+g+a,x=_+y+o,b=Kd(r,r.VERTEX_SHADER,v),M=Kd(r,r.FRAGMENT_SHADER,x);function S(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(f)||"",n=r.getShaderInfoLog(b)||"",s=r.getShaderInfoLog(M)||"",a=i.trim(),o=n.trim(),l=s.trim();let h=!0,c=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(h=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,b,M);else{const t=Qd(r,b,"vertex"),i=Qd(r,M,"fragment");Ze("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?Ye("WebGLProgram: Program Info Log:",a):""!==o&&""!==l||(c=!1);c&&(e.diagnostics={runnable:h,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:y}})}r.deleteShader(b),r.deleteShader(M),T=new Zd(r,f),w=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,q=r.clearcoat>0,Y=r.dispersion>0,Z=r.iridescence>0,K=r.sheen>0,$=r.transmission>0,Q=X&&!!r.anisotropyMap,tt=q&&!!r.clearcoatMap,et=q&&!!r.clearcoatNormalMap,it=q&&!!r.clearcoatRoughnessMap,nt=Z&&!!r.iridescenceMap,rt=Z&&!!r.iridescenceThicknessMap,st=K&&!!r.sheenColorMap,at=K&&!!r.sheenRoughnessMap,ot=!!r.specularMap,lt=!!r.specularColorMap,ht=!!r.specularIntensityMap,ct=$&&!!r.transmissionMap,ut=$&&!!r.thicknessMap,dt=!!r.gradientMap,pt=!!r.alphaMap,mt=r.alphaTest>0,ft=!!r.alphaHash,gt=!!r.extensions;let yt=0;r.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(yt=t.toneMapping));const _t={shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:E,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,batching:D,batchingColor:D&&null!==f._colorsTexture,instancing:L,instancingColor:L&&null!==f.instanceColor,instancingMorph:L&&null!==f.morphTexture,outputColorSpace:null===I?t.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:xi.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:O,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:M,aoMap:z,lightMap:k,bumpMap:B,normalMap:V,displacementMap:G,emissiveMap:H,normalMapObjectSpace:V&&1===r.normalMapType,normalMapTangentSpace:V&&0===r.normalMapType,packedNormalMap:V&&0===r.normalMapType&&(vt=r.normalMap.format,vt===At||vt===Ht||vt===ce),metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:Q,clearcoat:q,clearcoatMap:tt,clearcoatNormalMap:et,clearcoatRoughnessMap:it,dispersion:Y,iridescence:Z,iridescenceMap:nt,iridescenceThicknessMap:rt,sheen:K,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:lt,specularIntensityMap:ht,transmission:$,transmissionMap:ct,thicknessMap:ut,gradientMap:dt,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:r.combine,mapUv:O&&m(r.map.channel),aoMapUv:z&&m(r.aoMap.channel),lightMapUv:k&&m(r.lightMap.channel),bumpMapUv:B&&m(r.bumpMap.channel),normalMapUv:V&&m(r.normalMap.channel),displacementMapUv:G&&m(r.displacementMap.channel),emissiveMapUv:H&&m(r.emissiveMap.channel),metalnessMapUv:W&&m(r.metalnessMap.channel),roughnessMapUv:j&&m(r.roughnessMap.channel),anisotropyMapUv:Q&&m(r.anisotropyMap.channel),clearcoatMapUv:tt&&m(r.clearcoatMap.channel),clearcoatNormalMapUv:et&&m(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&m(r.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(r.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&m(r.iridescenceThicknessMap.channel),sheenColorMapUv:st&&m(r.sheenColorMap.channel),sheenRoughnessMapUv:at&&m(r.sheenRoughnessMap.channel),specularMapUv:ot&&m(r.specularMap.channel),specularColorMapUv:lt&&m(r.specularColorMap.channel),specularIntensityMapUv:ht&&m(r.specularIntensityMap.channel),transmissionMapUv:ct&&m(r.transmissionMap.channel),thicknessMapUv:ut&&m(r.thicknessMap.channel),alphaMapUv:pt&&m(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(V||X),vertexNormals:!!_.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===f.isPoints&&!!_.attributes.uv&&(O||pt),fog:!!y,useFog:!0===r.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===_.attributes.normal&&!1===V&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:P,skinning:!0===f.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:w,morphTextureStride:N,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numLightProbes:a.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,decodeVideoTexture:O&&!0===r.map.isVideoTexture&&xi.getTransfer(r.map.colorSpace)===we,decodeVideoTextureEmissive:H&&!0===r.emissiveMap.isVideoTexture&&xi.getTransfer(r.emissiveMap.colorSpace)===we,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:gt&&!0===r.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===r.extensions.multiDraw||D)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};var vt;return _t.vertexUv1s=l.has(1),_t.vertexUv2s=l.has(2),_t.vertexUv3s=l.has(3),l.clear(),_t},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){a.disableAll(),e.instancing&&a.enable(0);e.instancingColor&&a.enable(1);e.instancingMorph&&a.enable(2);e.matcap&&a.enable(3);e.envMap&&a.enable(4);e.normalMapObjectSpace&&a.enable(5);e.normalMapTangentSpace&&a.enable(6);e.clearcoat&&a.enable(7);e.iridescence&&a.enable(8);e.alphaTest&&a.enable(9);e.vertexColors&&a.enable(10);e.vertexAlphas&&a.enable(11);e.vertexUv1s&&a.enable(12);e.vertexUv2s&&a.enable(13);e.vertexUv3s&&a.enable(14);e.vertexTangents&&a.enable(15);e.anisotropy&&a.enable(16);e.alphaHash&&a.enable(17);e.batching&&a.enable(18);e.dispersion&&a.enable(19);e.batchingColor&&a.enable(20);e.gradientMap&&a.enable(21);e.packedNormalMap&&a.enable(22);e.vertexNormals&&a.enable(23);t.push(a.mask),a.disableAll(),e.fog&&a.enable(0);e.useFog&&a.enable(1);e.flatShading&&a.enable(2);e.logarithmicDepthBuffer&&a.enable(3);e.reversedDepthBuffer&&a.enable(4);e.skinning&&a.enable(5);e.morphTargets&&a.enable(6);e.morphNormals&&a.enable(7);e.morphColors&&a.enable(8);e.premultipliedAlpha&&a.enable(9);e.shadowMapEnabled&&a.enable(10);e.doubleSided&&a.enable(11);e.flipSided&&a.enable(12);e.useDepthPacking&&a.enable(13);e.dithering&&a.enable(14);e.transmission&&a.enable(15);e.sheen&&a.enable(16);e.opaque&&a.enable(17);e.pointsUvs&&a.enable(18);e.decodeVideoTexture&&a.enable(19);e.decodeVideoTextureEmissive&&a.enable(20);e.alphaToCoverage&&a.enable(21);e.numLightProbeGrids>0&&a.enable(22);t.push(a.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=p[t.type];let i;if(e){const t=uu[e];i=Ml.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n=c.get(i);return void 0!==n?++n.usedTimes:(n=new xp(t,i,e,r),h.push(n),c.set(i,n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),c.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){o.remove(t)},programs:h,dispose:function(){o.dispose()}}}function wp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Ep(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.materialVariant!==e.materialVariant?t.materialVariant-e.materialVariant:t.z!==e.z?t.z-e.z:t.id-e.id}function Ap(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Cp(){const t=[];let e=0;const i=[],n=[],r=[];function s(t){let e=0;return t.isInstancedMesh&&(e+=2),t.isSkinnedMesh&&(e+=1),e}function a(i,n,r,a,o,l){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,materialVariant:s(i),groupOrder:a,renderOrder:i.renderOrder,z:o,group:l},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.materialVariant=s(i),h.groupOrder=a,h.renderOrder=i.renderOrder,h.z=o,h.group=l),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,s,o,l,h){const c=a(t,e,s,o,l,h);s.transmission>0?n.push(c):!0===s.transparent?r.push(c):i.push(c)},unshift:function(t,e,s,o,l,h){const c=a(t,e,s,o,l,h);s.transmission>0?n.unshift(c):!0===s.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i1&&i.sort(t||Ep),n.length>1&&n.sort(e||Ap),r.length>1&&r.sort(e||Ap)}}}function Rp(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new Cp,t.set(e,[r])):i>=n.length?(r=new Cp,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function Np(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new di,color:new _n};break;case"SpotLight":i={position:new di,direction:new di,color:new _n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new di,color:new _n,distance:0,decay:0};break;case"HemisphereLight":i={direction:new di,skyColor:new _n,groundColor:new _n};break;case"RectAreaLight":i={color:new _n,position:new di,halfWidth:new di,halfHeight:new di}}return t[e.id]=i,i}}}let Ip=0;function Pp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Lp(t){const e=new Np,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)n.probe.push(new di);const r=new di,s=new Ui,a=new Ui;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let l=0,h=0,c=0,u=0,d=0,p=0,m=0,f=0,g=0,y=0,_=0;r.sort(Pp);for(let t=0,v=r.length;t0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=cu.LTC_FLOAT_1,n.rectAreaLTC2=cu.LTC_FLOAT_2):(n.rectAreaLTC1=cu.LTC_HALF_1,n.rectAreaLTC2=cu.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const v=n.hash;v.directionalLength===l&&v.pointLength===h&&v.spotLength===c&&v.rectAreaLength===u&&v.hemiLength===d&&v.numDirectionalShadows===p&&v.numPointShadows===m&&v.numSpotShadows===f&&v.numSpotMaps===g&&v.numLightProbes===_||(n.directional.length=l,n.spot.length=c,n.rectArea.length=u,n.point.length=h,n.hemi.length=d,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-y,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=_,v.directionalLength=l,v.pointLength=h,v.spotLength=c,v.rectAreaLength=u,v.hemiLength=d,v.numDirectionalShadows=p,v.numPointShadows=m,v.numSpotShadows=f,v.numSpotMaps=g,v.numLightProbes=_,n.version=Ip++)},setupView:function(t,e){let i=0,o=0,l=0,h=0,c=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(s=new Dp(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}const Up=[new di(1,0,0),new di(-1,0,0),new di(0,1,0),new di(0,-1,0),new di(0,0,1),new di(0,0,-1)],Fp=[new di(0,-1,0),new di(0,-1,0),new di(0,0,1),new di(0,0,-1),new di(0,-1,0),new di(0,-1,0)],zp=new Ui,kp=new di,Bp=new di;function Vp(t,e,i){let n=new Xs;const r=new ci,l=new ci,h=new Ii,c=new Il,u=new Pl,d={},p=i.maxTextureSize,m={[s]:1,[a]:0,[o]:2},f=new Sl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ci},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),g=f.clone();g.defines.HORIZONTAL_PASS=1;const y=new Mr;y.setAttribute("position",new ar(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new ps(y,f),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let x=this.type;function b(i,n){const s=e.update(_);f.defines.VSM_SAMPLES!==i.blurSamples&&(f.defines.VSM_SAMPLES=i.blurSamples,g.defines.VSM_SAMPLES=i.blurSamples,f.needsUpdate=!0,g.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Li(r.x,r.y,{format:At,type:mt})),f.uniforms.shadow_pass.value=i.map.depthTexture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,f,_,null),g.uniforms.shadow_pass.value=i.mapPass.texture,g.uniforms.resolution.value=i.mapSize,g.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,g,_,null)}function M(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?u:c,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=s.uuid,e=i.uuid;let n=d[t];void 0===n&&(n={},d[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",T)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:m[i.side],s.alphaMap=i.alphaMap,s.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function S(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),l=i.material;if(Array.isArray(l)){const e=n.groups;for(let h=0,c=e.length;ht.needsUpdate=!0):t.material.needsUpdate=!0)});for(let a=0,o=e.length;ap||r.y>p)&&(r.x>p&&(l.x=Math.floor(p/m.x),r.x=l.x*m.x,c.mapSize.x=l.x),r.y>p&&(l.y=Math.floor(p/m.y),r.y=l.y*m.y,c.mapSize.y=l.y));const f=t.state.buffers.depth.getReversed();if(c.camera._reversedDepth=f,null===c.map||!0===d){if(null!==c.map&&(null!==c.map.depthTexture&&(c.map.depthTexture.dispose(),c.map.depthTexture=null),c.map.dispose()),3===this.type){if(o.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}c.map=new Li(r.x,r.y,{format:At,type:mt,minFilter:rt,magFilter:rt,generateMipmaps:!1}),c.map.texture.name=o.name+".shadowMap",c.map.depthTexture=new ka(r.x,r.y,pt),c.map.depthTexture.name=o.name+".shadowMapDepth",c.map.depthTexture.format=St,c.map.depthTexture.compareFunction=null,c.map.depthTexture.minFilter=et,c.map.depthTexture.magFilter=et}else o.isPointLight?(c.map=new Ou(r.x),c.map.depthTexture=new Ba(r.x,dt)):(c.map=new Li(r.x,r.y),c.map.depthTexture=new ka(r.x,r.y,dt)),c.map.depthTexture.name=o.name+".shadowMap",c.map.depthTexture.format=St,1===this.type?(c.map.depthTexture.compareFunction=f?Le:Ne,c.map.depthTexture.minFilter=rt,c.map.depthTexture.magFilter=rt):(c.map.depthTexture.compareFunction=null,c.map.depthTexture.minFilter=et,c.map.depthTexture.magFilter=et);c.camera.updateProjectionMatrix()}const g=c.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e=1):-1!==K.indexOf("OpenGL ES")&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=Z>=2);let J=null,$={};const Q=t.getParameter(t.SCISSOR_BOX),tt=t.getParameter(t.VIEWPORT),et=(new Ii).fromArray(Q),it=(new Ii).fromArray(tt);function nt(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;ai||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=f(i,s));const a=e?f(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),Ye("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&Ye("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function y(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function v(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function x(i,n,r,s,a,o=!1){if(null!==i){if(void 0!==t[i])return t[i];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l;s&&(l=e.get("EXT_texture_norm16"),l||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let h=n;if(n===t.RED&&(r===t.FLOAT&&(h=t.R32F),r===t.HALF_FLOAT&&(h=t.R16F),r===t.UNSIGNED_BYTE&&(h=t.R8),r===t.UNSIGNED_SHORT&&l&&(h=l.R16_EXT),r===t.SHORT&&l&&(h=l.R16_SNORM_EXT)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.R8UI),r===t.UNSIGNED_SHORT&&(h=t.R16UI),r===t.UNSIGNED_INT&&(h=t.R32UI),r===t.BYTE&&(h=t.R8I),r===t.SHORT&&(h=t.R16I),r===t.INT&&(h=t.R32I)),n===t.RG&&(r===t.FLOAT&&(h=t.RG32F),r===t.HALF_FLOAT&&(h=t.RG16F),r===t.UNSIGNED_BYTE&&(h=t.RG8),r===t.UNSIGNED_SHORT&&l&&(h=l.RG16_EXT),r===t.SHORT&&l&&(h=l.RG16_SNORM_EXT)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RG8UI),r===t.UNSIGNED_SHORT&&(h=t.RG16UI),r===t.UNSIGNED_INT&&(h=t.RG32UI),r===t.BYTE&&(h=t.RG8I),r===t.SHORT&&(h=t.RG16I),r===t.INT&&(h=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RGB8UI),r===t.UNSIGNED_SHORT&&(h=t.RGB16UI),r===t.UNSIGNED_INT&&(h=t.RGB32UI),r===t.BYTE&&(h=t.RGB8I),r===t.SHORT&&(h=t.RGB16I),r===t.INT&&(h=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(h=t.RGBA16UI),r===t.UNSIGNED_INT&&(h=t.RGBA32UI),r===t.BYTE&&(h=t.RGBA8I),r===t.SHORT&&(h=t.RGBA16I),r===t.INT&&(h=t.RGBA32I)),n===t.RGB&&(r===t.UNSIGNED_SHORT&&l&&(h=l.RGB16_EXT),r===t.SHORT&&l&&(h=l.RGB16_SNORM_EXT),r===t.UNSIGNED_INT_5_9_9_9_REV&&(h=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(h=t.R11F_G11F_B10F)),n===t.RGBA){const e=o?Te:xi.getTransfer(a);r===t.FLOAT&&(h=t.RGBA32F),r===t.HALF_FLOAT&&(h=t.RGBA16F),r===t.UNSIGNED_BYTE&&(h=e===we?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT&&l&&(h=l.RGBA16_EXT),r===t.SHORT&&l&&(h=l.RGBA16_SNORM_EXT),r===t.UNSIGNED_SHORT_4_4_4_4&&(h=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(h=t.RGB5_A1)}return h!==t.R16F&&h!==t.R32F&&h!==t.RG16F&&h!==t.RG32F&&h!==t.RGBA16F&&h!==t.RGBA32F||e.get("EXT_color_buffer_float"),h}function b(e,i){let n;return e?null===i||i===dt||i===yt?n=t.DEPTH24_STENCIL8:i===pt?n=t.DEPTH32F_STENCIL8:i===ct&&(n=t.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===dt||i===yt?n=t.DEPTH_COMPONENT24:i===pt?n=t.DEPTH_COMPONENT32F:i===ct&&(n=t.DEPTH_COMPONENT16),n}function M(t,e){return!0===y(t)||t.isFramebufferTexture&&t.minFilter!==et&&t.minFilter!==rt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function S(t){const e=t.target;e.removeEventListener("dispose",S),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=p.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&w(t),0===Object.keys(r).length&&p.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e),e.isHTMLTexture&&u.delete(e)}function T(e){const i=e.target;i.removeEventListener("dispose",T),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n0&&s.__version!==e.version){const t=e.image;if(null===t)Ye("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);Ye("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const C={[$]:t.REPEAT,[Q]:t.CLAMP_TO_EDGE,[tt]:t.MIRRORED_REPEAT},R={[et]:t.NEAREST,[it]:t.NEAREST_MIPMAP_NEAREST,[nt]:t.NEAREST_MIPMAP_LINEAR,[rt]:t.LINEAR,[st]:t.LINEAR_MIPMAP_NEAREST,[at]:t.LINEAR_MIPMAP_LINEAR},N={[Ae]:t.NEVER,[De]:t.ALWAYS,[Ce]:t.LESS,[Ne]:t.LEQUAL,[Re]:t.EQUAL,[Le]:t.GEQUAL,[Ie]:t.GREATER,[Pe]:t.NOTEQUAL};function I(i,s){if(s.type!==pt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==rt&&s.magFilter!==st&&s.magFilter!==nt&&s.magFilter!==at&&s.minFilter!==rt&&s.minFilter!==st&&s.minFilter!==nt&&s.minFilter!==at||Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,C[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,C[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,C[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,R[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,R[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,N[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===et)return;if(s.minFilter!==nt&&s.minFilter!==at)return;if(s.type===pt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function P(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",S));const r=i.source;let s=p.get(r);void 0===s&&(s={},p.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&w(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function L(t,e,i){return Math.floor(Math.floor(t/i)/e)}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const h=P(e,a),c=a.source;i.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===h){i.activeTexture(t.TEXTURE0+o);if(!1===("undefined"!=typeof ImageBitmap&&a.image instanceof ImageBitmap)){const e=xi.getPrimaries(xi.workingColorSpace),n=a.colorSpace===be?null:xi.getPrimaries(a.colorSpace),r=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;i.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),i.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),i.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,r)}i.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment);let e=g(a.image,!1,r.maxTextureSize);e=H(a,e);const n=s.convert(a.format,a.colorSpace),p=s.convert(a.type);let m,f=x(a.internalFormat,n,p,a.normalized,a.colorSpace,a.isVideoTexture);I(l,a);const v=a.mipmaps,S=!0!==a.isVideoTexture,T=void 0===d.__version||!0===h,w=c.dataReady,E=M(a,e);if(a.isDepthTexture)f=b(a.format===Tt,a.type),T&&(S?i.texStorage2D(t.TEXTURE_2D,1,f,e.width,e.height):i.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,n,p,null));else if(a.isDataTexture)if(v.length>0){S&&T&&i.texStorage2D(t.TEXTURE_2D,E,f,v[0].width,v[0].height);for(let e=0,r=v.length;et.start-e.start);let o=0;for(let t=1;t0){const e=au(m.width,m.height,a.format,a.type);for(const s of a.layerUpdates){const a=m.data.subarray(s*e/m.data.BYTES_PER_ELEMENT,(s+1)*e/m.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,s,m.width,m.height,1,n,a)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,n,m.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,m.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else S?w&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,n,p,m.data):i.texImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,n,p,m.data)}else{S&&T&&i.texStorage2D(t.TEXTURE_2D,E,f,v[0].width,v[0].height);for(let e=0,r=v.length;e0){const r=au(e.width,e.height,a.format,a.type);for(const s of a.layerUpdates){const a=e.data.subarray(s*r/e.data.BYTES_PER_ELEMENT,(s+1)*r/e.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,s,e.width,e.height,1,n,p,a)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,n,p,e.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,f,e.width,e.height,e.depth,0,n,p,e.data);else if(a.isData3DTexture)S?(T&&i.texStorage3D(t.TEXTURE_3D,E,f,e.width,e.height,e.depth),w&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,n,p,e.data)):i.texImage3D(t.TEXTURE_3D,0,f,e.width,e.height,e.depth,0,n,p,e.data);else if(a.isFramebufferTexture){if(T)if(S)i.texStorage2D(t.TEXTURE_2D,E,f,e.width,e.height);else{let r=e.width,s=e.height;for(let e=0;e>=1,s>>=1}}else if(a.isHTMLTexture){if("texElementImage2D"in t){const i=t.canvas;if(i.hasAttribute("layoutsubtree")||i.setAttribute("layoutsubtree","true"),e.parentNode!==i)return i.appendChild(e),u.add(a),i.onpaint=t=>{const e=t.changedElements;for(const t of u)e.includes(t.image)&&(t.needsUpdate=!0)},void i.requestPaint();const n=0,r=t.RGBA,s=t.RGBA,o=t.UNSIGNED_BYTE;t.texElementImage2D(t.TEXTURE_2D,n,r,s,o,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(v.length>0){if(S&&T){const e=W(v[0]);i.texStorage2D(t.TEXTURE_2D,E,f,e.width,e.height)}for(let e=0,r=v.length;e>c),n=Math.max(1,r.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?i.texImage3D(h,c,p,e,n,r.depth,0,u,d,null):i.texImage2D(h,c,p,e,n,0,u,d,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,h,f.__webglTexture,0,V(r)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,h,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function U(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=b(i.stencilBuffer,s),l=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,V(i),a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,V(i),a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer)if(s)for(let t=0;t<6;t++)F(r.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?F(r.__webglFramebuffer[0],e,0):F(r.__webglFramebuffer,e,0)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),U(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),U(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const k=[],B=[];function V(t){return Math.min(r.maxSamples,t.samples)}function G(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Se&&i!==be&&(xi.getTransfer(i)===we?n===Mt&&r===ot||Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ze("WebGLTextures: Unsupported texture color space:",i)),e}function W(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(h.width=t.naturalWidth||t.width,h.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(h.width=t.displayWidth,h.height=t.displayHeight):(h.width=t.width,h.height=t.height),h}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&Ye("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.getTextureUnits=function(){return E},this.setTextureUnits=function(t){E=t},this.setTexture2D=A,this.setTexture2DArray=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):(e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null),i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r))},this.setTexture3D=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=P(e,a),h=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(h);if(h.version!==c.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=xi.getPrimaries(xi.workingColorSpace),n=a.colorSpace===be?null:xi.getPrimaries(a.colorSpace),u=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;i.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),i.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),i.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),i.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=d||p?p?a.image[t].image:a.image[t]:g(a.image[t],!0,r.maxCubemapSize),m[t]=H(a,m[t]);const f=m[0],v=s.convert(a.format,a.colorSpace),b=s.convert(a.type),S=x(a.internalFormat,v,b,a.normalized,a.colorSpace),T=!0!==a.isVideoTexture,w=void 0===c.__version||!0===l,E=h.dataReady;let A,C=M(a,f);if(I(t.TEXTURE_CUBE_MAP,a),d){T&&w&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,f.width,f.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n0&&C++;const e=W(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){T?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,v,b,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,m[e].width,m[e].height,0,v,b,m[e].data);for(let n=0;n1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i0){o.__webglFramebuffer=[];for(let e=0;e0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i0)for(let n=0;n0)for(let i=0;i0)if(!1===G(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const h=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),u=r.length>1;if(u)for(let e=0;e0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ps(new al(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xp extends $e{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new jp,g={},y=e.getContextAttributes();let _=null,v=null;const x=[],b=[],M=new ci;let S=null;const T=new Eh;T.viewport=new Ii;const w=new Eh;w.viewport=new Ii;const E=[T,w],A=new ec;let C=null,R=null;function N(t){const e=b.indexOf(t.inputSource);if(-1===e)return;const i=x[e];void 0!==i&&(i.update(t.inputSource,t.frame,l||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function I(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",I),n.removeEventListener("inputsourceschange",P);for(let t=0;t=0&&(b[n]=null,x[n].disconnect(i))}for(let e=0;e=b.length){b.push(i),n=t;break}if(null===b[t]){b[t]=i,n=t;break}}if(-1===n)break}const r=x[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new pn,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new pn,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new pn,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&Ye("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&Ye("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(h){if(n=h,null!==n){_=t.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",I),n.addEventListener("inputsourceschange",P),!0!==y.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(M);if(m&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;y.depth&&(a=y.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=y.stencil?Tt:St,s=y.stencil?yt:dt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=this.getBinding(),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),v=new Li(u.textureWidth,u.textureHeight,{format:Mt,type:ot,depthTexture:new ka(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:y.stencil,colorSpace:t.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}else{const i={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new Li(d.framebufferWidth,d.framebufferHeight,{format:Mt,type:ot,colorSpace:t.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const L=new di,D=new di;function O(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(i=f.depthFar)),A.near=w.near=T.near=e,A.far=w.far=T.far=i,C===A.near&&R===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,T.layers.mask=-5&A.layers.mask,w.layers.mask=-3&A.layers.mask;const r=t.parent,s=A.cameras;O(A,r);for(let t=0;t0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,t.envMapRotation.value.setFromMatrix4(qp.makeRotationFromEuler(a)).transpose(),s.isCubeTexture&&!1===s.isRenderTargetTexture&&t.envMapRotation.value.premultiply(Yp),t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,bl(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?n(t,r):r.isMeshLambertMaterial?(n(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Kp(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return"number"==typeof r||"boolean"==typeof r?n[s]=r:ArrayBuffer.isView(r)?n[s]=r.slice():n[s]=r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else{if(ArrayBuffer.isView(r))return!0;if(!1===t.equals(r))return t.copy(r),!0}}return!1}function h(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(t)?(e.boundary=16,e.storage=t.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,u){let d=r[i.id];void 0===d&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t0&&(i+=n-r);t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t=r){const s=r++,h=t[s];e[h.uuid]=l,t[l]=h,e[o]=s,t[s]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[l];e[l]=n,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);n=r.length,i[t]=n,s.push(t),a.push(e),r.push(c);for(let i=h,n=o.length;i!==n;++i){const n=o[i];c[i]=new bc(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=i,s[i]=o,s.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:class{static convertArray(t,e){return Ol(t,e)}static isTypedArray(t){return Ve(t)}static getKeyframeOrder(t){return Ul(t)}static sortedArray(t,e,i){return Fl(t,e,i)}static flattenJSON(t,e,i,n){zl(t,e,i,n)}static subclip(t,e,i,n,r=30){return function(t,e,i,n,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t=n)){l.push(e.times[t]);for(let i=0;is.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t=n.times[u]){const t=u*l+o,e=t+l-o;d=n.values.slice(t,e)}else{const t=n.createInterpolant(),e=o,i=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,i)}"quaternion"===r&&(new ui).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{eu.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(eu,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:W,Audio:hc,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Pc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Fn,Box3Helper:class extends Aa{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Mr;n.setIndex(new ar(i,1)),n.setAttribute("position",new cr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new fa({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Ga,BoxHelper:class extends Aa{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new Mr;r.setIndex(new ar(i,1)),r.setAttribute("position",new ar(n,3)),super(r,new fa({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&tu.setFromObject(this.object),tu.isEmpty())return;const t=tu.min,e=tu.max,i=this.geometry.attributes.position,n=i.array;n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=t.x,n[4]=e.y,n[5]=e.z,n[6]=t.x,n[7]=t.y,n[8]=e.z,n[9]=e.x,n[10]=t.y,n[11]=e.z,n[12]=e.x,n[13]=e.y,n[14]=t.z,n[15]=t.x,n[16]=e.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=e.x,n[22]=t.y,n[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:ar,BufferGeometry:Mr,BufferGeometryLoader:Vh,ByteType:lt,Cache:th,Camera:Mh,CameraHelper:class extends Aa{constructor(t){const e=new Mr,i=new fa({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new cr(n,3)),e.setAttribute("color",new cr(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new _n(16755200),h=new _n(16711680),c=new _n(43775),u=new _n(16777215),d=new _n(3355443);this.setColors(l,h,c,u,d)}setColors(t,e,i,n,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let i,n;if($c.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===Fe)i=-1,n=1;else{if(this.camera.coordinateSystem!==ze)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}Qc("c",e,t,$c,0,0,i),Qc("t",e,t,$c,0,0,n),Qc("n1",e,t,$c,-1,-1,i),Qc("n2",e,t,$c,1,-1,i),Qc("n3",e,t,$c,-1,1,i),Qc("n4",e,t,$c,1,1,i),Qc("f1",e,t,$c,-1,-1,n),Qc("f2",e,t,$c,1,-1,n),Qc("f3",e,t,$c,-1,1,n),Qc("f4",e,t,$c,1,1,n),Qc("u1",e,t,$c,.7,1.1,i),Qc("u2",e,t,$c,-.7,1.1,i),Qc("u3",e,t,$c,0,2,i),Qc("cf1",e,t,$c,-1,0,n),Qc("cf2",e,t,$c,1,0,n),Qc("cf3",e,t,$c,0,-1,n),Qc("cf4",e,t,$c,0,1,n),Qc("cn1",e,t,$c,-1,0,i),Qc("cn2",e,t,$c,1,0,i),Qc("cn3",e,t,$c,0,-1,i),Qc("cn4",e,t,$c,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Ni{constructor(t,e,i,n,r,s,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:Ha,CatmullRomCurve3:ho,CineonToneMapping:3,CircleGeometry:Wa,ClampToEdgeWrapping:Q,Clock:class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Ye("Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}},Color:_n,ColorKeyframeTrack:Xl,ColorManagement:xi,Compatibility:{TEXTURE_COMPARE:"depthTextureCompare"},CompressedArrayTexture:class extends Fa{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=Q,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Fa{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,q),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Fa,CompressedTextureLoader:lh,ConeGeometry:Xa,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:su,CubeCamera:tc,CubeDepthTexture:Ba,CubeReflectionMapping:q,CubeRefractionMapping:Y,CubeTexture:za,CubeTextureLoader:class extends rh{constructor(t){super(t)}load(t,e,i,n){const r=new za;r.colorSpace=Me;const s=new ch(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,n)}for(let e=0;e{this.needsUpdate=!0},h.requestPaint())}dispose(){const t=this.image?this.image.parentNode:null;null!==t&&"onpaint"in t&&(t.onpaint=null),super.dispose()}},HalfFloatType:mt,HemisphereLight:mh,HemisphereLightHelper:class extends cn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new sl(e);n.rotateY(.5*Math.PI),this.material=new es({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new ar(s,3)),this.add(new ps(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Xc.copy(this.light.color),qc.copy(this.light.groundColor);for(let t=0,i=e.count;t1&&(s=1,r=ri((e-t)/c,0,1))}}return e.copy(a).addScaledVector(Oc,r),i.copy(o).addScaledVector(Uc,s),e.distanceToSquared(i)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:fa,LineCurve:go,LineCurve3:yo,LineDashedMaterial:Dl,LineLoop:Ca,LineSegments:Aa,LinearFilter:rt,LinearInterpolant:Vl,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:at,LinearMipmapNearestFilter:st,LinearSRGBColorSpace:Se,LinearToneMapping:1,LinearTransfer:Te,Loader:rh,LoaderUtils:kh,LoadingManager:ih,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:e,Material:Cr,MaterialBlending:6,MaterialLoader:zh,MathUtils:hi,Matrix2:Ic,Matrix3:fi,Matrix4:Ui,MaxEquation:104,Mesh:ps,MeshBasicMaterial:es,MeshDepthMaterial:Il,MeshDistanceMaterial:Pl,MeshLambertMaterial:Nl,MeshMatcapMaterial:Ll,MeshNormalMaterial:Rl,MeshPhongMaterial:Al,MeshPhysicalMaterial:El,MeshStandardMaterial:wl,MeshToonMaterial:Cl,MinEquation:103,MirroredRepeatWrapping:tt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:et,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:nt,NearestMipmapNearestFilter:it,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:be,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:ve,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:ql,Object3D:cn,ObjectLoader:class extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?kh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new oh(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void Ze("ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void Ze("ObjectLoader: Can't load "+t);r.parse(s,e)},i,n)}async loadAsync(t,e){const i=""===this.path?kh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new oh(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e);let s;try{s=JSON.parse(r)}catch(e){throw new Error("ObjectLoader: Can't parse "+t+". "+e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),s=this.parseImages(t.images,function(){void 0!==e&&e(l)}),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,r,o,a,i),h=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,h),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,n,a,s,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}static registerGeometry(t,e){Gh[t]=e}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i0){const i=new ih(e);r=new ch(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){n=new ch(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Fn).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new mr).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),s._instanceInfo=t.instanceInfo,s._availableInstanceIds=t._availableInstanceIds,s._availableGeometryIds=t._availableGeometryIds,s._nextIndexStart=t.nextIndexStart,s._nextVertexStart=t.nextVertexStart,s._geometryCount=t.geometryCount,s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._matricesTexture=c(t.matricesTexture.uuid),s._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(s.boundingSphere=(new mr).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(s.boundingBox=(new Fn).fromJSON(t.boundingBox));break;case"LOD":s=new Xr;break;case"Line":s=new Sa(l(t.geometry),h(t.material));break;case"LineLoop":s=new Ca(l(t.geometry),h(t.material));break;case"LineSegments":s=new Aa(l(t.geometry),h(t.material));break;case"PointCloud":case"Points":s=new Da(l(t.geometry),h(t.material));break;case"Sprite":s=new Gr(h(t.material));break;case"Group":s=new un;break;case"Bone":s=new ws;break;default:s=new cn}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.pivot&&(s.pivot=(new di).fromArray(t.pivot)),void 0!==t.morphTargetDictionary&&(s.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),void 0!==t.morphTargetInfluences&&(s.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.static&&(s.static=t.static),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t1)for(let i=0;ie?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,n){return au(t,e,i,n)}},Timer:ic,TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:ul,TorusKnotGeometry:dl,Triangle:Un,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:pl,UVMapping:X,Uint16BufferAttribute:or,Uint32BufferAttribute:hr,Uint8BufferAttribute:class extends ar{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends ar{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Tc,UniformsGroup:class extends $e{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:wc++}),this.name="",this.usage=Oe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t0),d=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,m=!!i.morphAttributes.color;let f=0;n.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(f=E.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,y=void 0!==g?g.length:0,_=ut.get(n),v=M.state.lights;if(!0===Y&&(!0===Z||t!==L)){const e=t===L&&n.id===P;Nt.setState(n,t,e)}let b=!1;n.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?b=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?b=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?b=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==h||!0===n.fog&&_.fog!==s?b=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===Nt.numPlanes&&_.numIntersection===Nt.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==u||_.morphTargets!==d||_.morphNormals!==p||_.morphColors!==m||_.toneMapping!==f||_.morphTargetsCount!==y||!!_.lightProbeGrid!=M.state.lightProbeGridArray.length>0)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,_.__version=n.version);let S=_.currentProgram;!0===b&&(S=ne(n,e,r),C&&n.isNodeMaterial&&C.onUpdateProgram(n,S,_));let T=!1,w=!1,A=!1;const R=S.getUniforms(),N=_.uniforms;lt.useProgram(S.program)&&(T=!0,w=!0,A=!0);n.id!==P&&(P=n.id,w=!0);if(_.needsLights){const t=function(t,e){if(0===t.length)return null;if(1===t.length)return null!==t[0].texture?t[0]:null;x.setFromMatrixPosition(e.matrixWorld);for(let e=0,i=t.length;e0&&R.setValue(kt,"directionalShadowMap",v.state.directionalShadowMap,pt),v.state.spotShadowMap.length>0&&R.setValue(kt,"spotShadowMap",v.state.spotShadowMap,pt),v.state.pointShadowMap.length>0&&R.setValue(kt,"pointShadowMap",v.state.pointShadowMap,pt));if(r.isSkinnedMesh){R.setOptional(kt,r,"bindMatrix"),R.setOptional(kt,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(kt,"boneTexture",t.boneTexture,pt))}r.isBatchedMesh&&(R.setOptional(kt,r,"batchingTexture"),R.setValue(kt,"batchingTexture",r._matricesTexture,pt),R.setOptional(kt,r,"batchingIdTexture"),R.setValue(kt,"batchingIdTexture",r._indirectTexture,pt),R.setOptional(kt,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(kt,"batchingColorTexture",r._colorsTexture,pt));const D=i.morphAttributes;void 0===D.position&&void 0===D.normal&&void 0===D.color||Lt.update(r,i,S);(w||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(kt,"receiveShadow",r.receiveShadow));(n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial)&&null===n.envMap&&null!==e.environment&&(N.envMapIntensity.value=e.environmentIntensity);void 0!==N.dfgLUT&&(N.dfgLUT.value=(null===$p&&($p=new Es(Jp,16,16,At,mt),$p.name="DFG_LUT",$p.minFilter=rt,$p.magFilter=rt,$p.wrapS=Q,$p.wrapT=Q,$p.generateMipmaps=!1,$p.needsUpdate=!0),$p));if(w){if(R.setValue(kt,"toneMappingExposure",E.toneMappingExposure),_.needsLights&&(U=A,(O=N).ambientLightColor.needsUpdate=U,O.lightProbe.needsUpdate=U,O.directionalLights.needsUpdate=U,O.directionalLightShadows.needsUpdate=U,O.pointLights.needsUpdate=U,O.pointLightShadows.needsUpdate=U,O.spotLights.needsUpdate=U,O.spotLightShadows.needsUpdate=U,O.rectAreaLights.needsUpdate=U,O.hemisphereLights.needsUpdate=U),s&&!0===n.fog&&St.refreshFogUniforms(N,s),St.refreshMaterialUniforms(N,n,V,B,M.state.transmissionRenderTarget[t.id]),_.needsLights&&_.lightProbeGrid){const t=_.lightProbeGrid;N.probesSH.value=t.texture,N.probesMin.value.copy(t.boundingBox.min),N.probesMax.value.copy(t.boundingBox.max),N.probesResolution.value.copy(t.resolution)}Zd.upload(kt,re(_),N,pt)}var O,U;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Zd.upload(kt,re(_),N,pt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&R.setValue(kt,"center",r.center);if(R.setValue(kt,"modelViewMatrix",r.modelViewMatrix),R.setValue(kt,"normalMatrix",r.normalMatrix),R.setValue(kt,"modelMatrix",r.matrixWorld),void 0!==n.uniformsGroups){const t=n.uniformsGroups;for(let e=0,i=t.length;e{function i(){n.forEach(function(t){ut.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==nt.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let Yt=null;function Zt(){Jt.stop()}function Kt(){Jt.start()}const Jt=new ou;function $t(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLightProbeGrid)M.pushLightProbeGrid(t);else if(t.isLight)M.pushLight(t),t.castShadow&&M.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||q.intersectsSprite(t)){n&&$.setFromMatrixPosition(t.matrixWorld).applyMatrix4(K);const e=bt.update(t),r=t.material;r.visible&&b.push(t,e,r,i,$.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||q.intersectsObject(t))){const e=bt.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),$.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),$.copy(e.boundingSphere.center)),$.applyMatrix4(t.matrixWorld).applyMatrix4(K)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s0&&ee(r,e,i),s.length>0&&ee(s,e,i),a.length>0&&ee(a,e,i),lt.buffers.depth.setTest(!0),lt.buffers.depth.setMask(!0),lt.buffers.color.setMask(!0),lt.setPolygonOffset(!1)}function te(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;if(void 0===M.state.transmissionRenderTarget[n.id]){const t=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[n.id]=new Li(1,1,{generateMipmaps:!0,type:t?mt:ot,minFilter:at,samples:Math.max(4,st.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xi.workingColorSpace})}const r=M.state.transmissionRenderTarget[n.id],a=n.viewport||D;r.setSize(a.z*E.transmissionResolutionScale,a.w*E.transmissionResolutionScale);const o=E.getRenderTarget(),l=E.getActiveCubeFace(),h=E.getActiveMipmapLevel();E.setRenderTarget(r),E.getClearColor(F),z=E.getClearAlpha(),z<1&&E.setClearColor(16777215,.5),E.clear(),et&&Pt.render(i);const c=E.toneMapping;E.toneMapping=0;const u=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),M.setupLightsView(n),!0===Y&&Nt.setGlobalState(E.clippingPlanes,n),ee(t,i,n),pt.updateMultisampleRenderTarget(r),pt.updateRenderTargetMipmap(r),!1===nt.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r0,n.currentProgram=u,n.uniformsList=null,u}function re(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Zd.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function se(t,e){const i=ut.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Jt.setAnimationLoop(function(t){Yt&&Yt(t)}),"undefined"!=typeof self&&Jt.setContext(self),this.setAnimationLoop=function(t){Yt=t,Gt.setAnimationLoop(t),null===t?Jt.stop():Jt.start()},Gt.addEventListener("sessionstart",Zt),Gt.addEventListener("sessionend",Kt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void Ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===A)return;null!==C&&C.renderStart(t,e);const i=!0===Gt.enabled&&!0===Gt.isPresenting,n=null!==w&&(null===I||i)&&w.begin(E,I);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Gt.enabled||!0!==Gt.isPresenting||null!==w&&!1!==w.isCompositing()||(!0===Gt.cameraAutoUpdate&&Gt.updateCamera(e),e=Gt.getCamera()),!0===t.isScene&&t.onBeforeRender(E,t,e,I),M=wt.get(t,T.length),M.init(e),M.state.textureUnits=pt.getTextureUnits(),T.push(M),K.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),q.setFromProjectionMatrix(K,Fe,e.reversedDepth),Z=this.localClippingEnabled,Y=Nt.init(this.clippingPlanes,Z),b=Tt.get(t,S.length),b.init(),S.push(b),!0===Gt.enabled&&!0===Gt.isPresenting){const t=E.xr.getDepthSensingMesh();null!==t&&$t(t,e,-1/0,E.sortObjects)}$t(t,e,0,E.sortObjects),b.finish(),!0===E.sortObjects&&b.sort(G,H),et=!1===Gt.enabled||!1===Gt.isPresenting||!1===Gt.hasDepthSensing(),et&&Pt.addToRenderList(b,t),this.info.render.frame++,!0===Y&&Nt.beginShadows();const r=M.state.shadowsArray;It.render(r,t,e),!0===Y&&Nt.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(n&&w.hasRenderPass())){const i=b.opaque,n=b.transmissive;if(M.setupLights(),e.isArrayCamera){const r=e.cameras;if(n.length>0)for(let e=0,s=r.length;e0&&te(i,n,t,e),et&&Pt.render(t),Qt(b,t,e)}null!==I&&0===N&&(pt.updateMultisampleRenderTarget(I),pt.updateRenderTargetMipmap(I)),n&&w.end(E),!0===t.isScene&&t.onAfterRender(E,t,e),Ft.resetDefaultState(),P=-1,L=null,T.pop(),T.length>0?(M=T[T.length-1],pt.setTextureUnits(M.state.textureUnits),!0===Y&&Nt.setGlobalState(E.clippingPlanes,M.state.camera)):M=null,S.pop(),b=S.length>0?S[S.length-1]:null,null!==C&&C.renderEnd()},this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(t,e,i){const n=ut.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),ut.get(t.texture).__webglTexture=e,ut.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=ut.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const ae=kt.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){I=t,R=e,N=i;let n=null,r=!1,s=!1;if(t){const a=ut.get(t);if(void 0!==a.__useDefaultFramebuffer)return lt.bindFramebuffer(kt.FRAMEBUFFER,a.__webglFramebuffer),D.copy(t.viewport),O.copy(t.scissor),U=t.scissorTest,lt.viewport(D),lt.scissor(O),lt.setScissorTest(U),void(P=-1);if(void 0===a.__webglFramebuffer)pt.setupRenderTarget(t);else if(a.__hasExternalTextures)pt.rebindTextures(t,ut.get(t.texture).__webglTexture,ut.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&&ut.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");pt.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);const l=ut.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=Array.isArray(l[e])?l[e][i]:l[e],r=!0):n=t.samples>0&&!1===pt.useMultisampledRTT(t)?ut.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,D.copy(t.viewport),O.copy(t.scissor),U=t.scissorTest}else D.copy(W).multiplyScalar(V).floor(),O.copy(j).multiplyScalar(V).floor(),U=X;0!==i&&(n=ae);if(lt.bindFramebuffer(kt.FRAMEBUFFER,n)&<.drawBuffers(t,n),lt.viewport(D),lt.scissor(O),lt.setScissorTest(U),r){const n=ut.get(t.texture);kt.framebufferTexture2D(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(s){const n=e;for(let e=0;e1&&kt.readBuffer(kt.COLOR_ATTACHMENT0+o),!st.textureFormatReadable(l))return void Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!st.textureTypeReadable(h))return void Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&kt.readPixels(e,i,n,r,Ut.convert(l),Ut.convert(h),s)}finally{const t=null!==I?ut.get(I).__webglFramebuffer:null;lt.bindFramebuffer(kt.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ut.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){lt.bindFramebuffer(kt.FRAMEBUFFER,l);const a=t.textures[o],h=a.format,c=a.type;if(t.textures.length>1&&kt.readBuffer(kt.COLOR_ATTACHMENT0+o),!st.textureFormatReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!st.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=kt.createBuffer();kt.bindBuffer(kt.PIXEL_PACK_BUFFER,u),kt.bufferData(kt.PIXEL_PACK_BUFFER,s.byteLength,kt.STREAM_READ),kt.readPixels(e,i,n,r,Ut.convert(h),Ut.convert(c),0);const d=null!==I?ut.get(I).__webglFramebuffer:null;lt.bindFramebuffer(kt.FRAMEBUFFER,d);const p=kt.fenceSync(kt.SYNC_GPU_COMMANDS_COMPLETE,0);return kt.flush(),await function(t,e,i){return new Promise(function(n,r){setTimeout(function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}},i)})}(kt,p,4),kt.bindBuffer(kt.PIXEL_PACK_BUFFER,u),kt.getBufferSubData(kt.PIXEL_PACK_BUFFER,0,s),kt.deleteBuffer(u),kt.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;pt.setTexture2D(t,0),kt.copyTexSubImage2D(kt.TEXTURE_2D,i,0,0,a,o,r,s),lt.unbindTexture()};const oe=kt.createFramebuffer(),le=kt.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=0){let a,o,l,h,c,u,d,p,m;const f=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,l=i.isBox3?i.max.z-i.min.z:1,h=i.min.x,c=i.min.y,u=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(f.width*e),o=Math.floor(f.height*e),l=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,h=0,c=0,u=0}null!==n?(d=n.x,p=n.y,m=n.z):(d=0,p=0,m=0);const g=Ut.convert(e.format),y=Ut.convert(e.type);let _;e.isData3DTexture?(pt.setTexture3D(e,0),_=kt.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(pt.setTexture2DArray(e,0),_=kt.TEXTURE_2D_ARRAY):(pt.setTexture2D(e,0),_=kt.TEXTURE_2D),lt.activeTexture(kt.TEXTURE0),lt.pixelStorei(kt.UNPACK_FLIP_Y_WEBGL,e.flipY),lt.pixelStorei(kt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),lt.pixelStorei(kt.UNPACK_ALIGNMENT,e.unpackAlignment);const v=lt.getParameter(kt.UNPACK_ROW_LENGTH),x=lt.getParameter(kt.UNPACK_IMAGE_HEIGHT),b=lt.getParameter(kt.UNPACK_SKIP_PIXELS),M=lt.getParameter(kt.UNPACK_SKIP_ROWS),S=lt.getParameter(kt.UNPACK_SKIP_IMAGES);lt.pixelStorei(kt.UNPACK_ROW_LENGTH,f.width),lt.pixelStorei(kt.UNPACK_IMAGE_HEIGHT,f.height),lt.pixelStorei(kt.UNPACK_SKIP_PIXELS,h),lt.pixelStorei(kt.UNPACK_SKIP_ROWS,c),lt.pixelStorei(kt.UNPACK_SKIP_IMAGES,u);const T=t.isDataArrayTexture||t.isData3DTexture,w=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=ut.get(t),n=ut.get(e),f=ut.get(i.__renderTarget),g=ut.get(n.__renderTarget);lt.bindFramebuffer(kt.READ_FRAMEBUFFER,f.__webglFramebuffer),lt.bindFramebuffer(kt.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i1e4?1e4:t,{In:function(e){return Math.pow(e,t)},Out:function(e){return 1-Math.pow(1-e,t)},InOut:function(e){return e<.5?Math.pow(2*e,t)/2:(1-Math.pow(2-2*e,t))/2+.5}}}}),em=function(){return performance.now()},im=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=em()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n1?s(t[i],t[i-1],i-n):s(t[r],t[r+1>i?i:r+1],n-r)},Utils:{Linear:function(t,e,i){return(e-t)*i+t}}},rm=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),sm=new im,am=function(){function t(t,e){void 0===e&&(e=sm),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=tm.Linear.None,this._interpolationFunction=nm.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=rm.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(t,e){if(void 0===e&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},t.prototype.duration=function(t){return void 0===t&&(t=1e3),this._duration=t<0?0:t,this},t.prototype.dynamic=function(t){return void 0===t&&(t=!1),this._isDynamic=t,this},t.prototype.start=function(t,e){if(void 0===t&&(t=em()),void 0===e&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var i in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var n={};for(var r in this._valuesEnd)n[r]=this._valuesEnd[r];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},t.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},t.prototype._setupProperties=function(t,e,i,n,r){for(var s in i){var a=t[s],o=Array.isArray(a),l=o?"array":typeof a,h=!o&&Array.isArray(i[s]);if("undefined"!==l&&"function"!==l){if(h){if(0===(g=i[s]).length)continue;for(var c=[a],u=0,d=g.length;us)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,tl)return 1;var t=Math.trunc(a/o),e=a-t*o,i=Math.min(e/r._duration,1);return 0===i&&a===r._duration?1:i}(),c=this._easingFunction(h);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),0===this._duration||a>=this._duration){if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(n in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,p=this._chainedTweens.length;d>8&255]+Lm[t>>16&255]+Lm[t>>24&255]+"-"+Lm[255&e]+Lm[e>>8&255]+"-"+Lm[e>>16&15|64]+Lm[e>>24&255]+"-"+Lm[63&i|128]+Lm[i>>8&255]+"-"+Lm[i>>16&255]+Lm[i>>24&255]+Lm[255&n]+Lm[n>>8&255]+Lm[n>>16&255]+Lm[n>>24&255]).toLowerCase()}function zm(t,e,i){return Math.max(e,Math.min(i,t))}function km(t,e){return(t%e+e)%e}function Bm(t,e,i){return(1-i)*t+i*e}function Vm(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Gm(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Hm={DEG2RAD:Om,RAD2DEG:Um,generateUUID:Fm,clamp:zm,euclideanModulo:km,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:Bm,damp:function(t,e,i,n){return Bm(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(km(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Dm=t);let e=Dm+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Om},radToDeg:function(t){return t*Um},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),h=s((e+n)/2),c=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),m=a((n-e)/2);switch(r){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*c,o*h);break;default:Nm("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Gm,denormalize:Vm};class Wm{static{Wm.prototype.isMatrix3=!0}constructor(t,e,i,n,r,s,a,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l)}set(t,e,i,n,r,s,a,o,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=r,h[5]=o,h[6]=i,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],y=n[1],_=n[4],v=n[7],x=n[2],b=n[5],M=n[8];return r[0]=s*m+a*y+o*x,r[3]=s*f+a*_+o*b,r[6]=s*g+a*v+o*M,r[1]=l*m+h*y+c*x,r[4]=l*f+h*_+c*b,r[7]=l*g+h*v+c*M,r[2]=u*m+d*y+p*x,r[5]=u*f+d*_+p*b,r[8]=u*g+d*v+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*s*h-e*a*l-i*r*h+i*a*o+n*r*l-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*s-a*l,u=a*o-h*r,d=l*r-s*o,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(n*l-h*i)*m,t[2]=(a*i-n*s)*m,t[3]=u*m,t[4]=(h*e-n*o)*m,t[5]=(n*r-a*e)*m,t[6]=d*m,t[7]=(i*o-l*e)*m,t[8]=(s*e-i*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*s+l*a)+s+t,-n*l,n*o,-n*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(jm.makeScale(t,e)),this}rotate(t){return this.premultiply(jm.makeRotation(-t)),this}translate(t,e){return this.premultiply(jm.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const jm=new Wm,Xm=(new Wm).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qm=(new Wm).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ym(){const t={enabled:!0,workingColorSpace:vm,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===bm&&(t.r=Km(t.r),t.g=Km(t.g),t.b=Km(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===bm&&(t.r=Jm(t.r),t.g=Jm(t.g),t.b=Jm(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?xm:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return Pm("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return Pm("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],n=[.3127,.329];return t.define({[vm]:{primaries:e,whitePoint:n,transfer:xm,toXYZ:Xm,fromXYZ:qm,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:_m},outputColorSpaceConfig:{drawingBufferColorSpace:_m}},[_m]:{primaries:e,whitePoint:n,transfer:bm,toXYZ:Xm,fromXYZ:qm,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:_m}}}),t}const Zm=Ym();function Km(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Jm(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const $m={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},Qm={h:0,s:0,l:0},tf={h:0,s:0,l:0};function ef(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class nf{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=_m){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Zm.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=Zm.workingColorSpace){return this.r=t,this.g=e,this.b=i,Zm.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=Zm.workingColorSpace){if(t=km(t,1),e=zm(e,0,1),i=zm(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=ef(r,n,t+1/3),this.g=ef(r,n,t),this.b=ef(r,n,t-1/3)}return Zm.colorSpaceToWorking(this,n),this}setStyle(t,e=_m){function i(e){void 0!==e&&parseFloat(e)<1&&Nm("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=n[1],a=n[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Nm("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,16),e);Nm("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=_m){const i=$m[t.toLowerCase()];return void 0!==i?this.setHex(i,e):Nm("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Km(t.r),this.g=Km(t.g),this.b=Km(t.b),this}copyLinearToSRGB(t){return this.r=Jm(t.r),this.g=Jm(t.g),this.b=Jm(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=_m){return Zm.workingToColorSpace(rf.copy(this),t),65536*Math.round(zm(255*rf.r,0,255))+256*Math.round(zm(255*rf.g,0,255))+Math.round(zm(255*rf.b,0,255))}getHexString(t=_m){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Zm.workingColorSpace){Zm.workingToColorSpace(rf.copy(this),e);const i=rf.r,n=rf.g,r=rf.b,s=Math.max(i,n,r),a=Math.min(i,n,r);let o,l;const h=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=h<=.5?t/(s+a):t/(2-s-a),s){case i:o=(n-r)/t+(n0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(zm(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+s*a+n*l-r*o,this._y=n*h+s*o+r*a-i*l,this._z=r*h+s*l+i*o-n*a,this._w=s*h-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,r=t._z,s=t._w,a=this.dot(t);a<0&&(i=-i,n=-n,r=-r,s=-s,a=-a);let o=1-e;if(a<.9995){const t=Math.acos(a),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this._onChangeCallback()}else this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},of=class t{static{t.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(hf.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(hf.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*n-a*i),h=2*(a*e-r*n),c=2*(r*i-s*e);return this.x=e+o*l+s*c-a*h,this.y=i+o*h+a*l-r*c,this.z=n+o*c+r*h-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=zm(this.x,t.x,e.x),this.y=zm(this.y,t.y,e.y),this.z=zm(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=zm(this.x,t,e),this.y=zm(this.y,t,e),this.z=zm(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(zm(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return lf.copy(this).projectOnVector(t),this.sub(lf)}reflect(t){return this.sub(lf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(zm(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const lf=new of,hf=new af;let cf=class t{static{t.prototype.isMatrix4=!0}constructor(t,e,i,n,r,s,a,o,l,h,c,u,d,p,m,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l,h,c,u,d,p,m,f)}set(t,e,i,n,r,s,a,o,l,h,c,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new t).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,i=t.elements,n=1/uf.setFromMatrixColumn(t,0).length(),r=1/uf.setFromMatrixColumn(t,1).length(),s=1/uf.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=n+i*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t+r*a,e[4]=n*a-i,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-a,e[2]=i*a-n,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t-r*a,e[4]=-s*c,e[8]=n+i*a,e[1]=i+n*a,e[5]=s*h,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=n*l-i,e[8]=t*l+r,e[1]=o*c,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=r-t*c,e[8]=n*c+i,e[1]=c,e[5]=s*h,e[9]=-a*h,e[2]=-l*h,e[6]=i*c+n,e[10]=t-r*c}else if("XZY"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=i*c-n,e[2]=n*c-i,e[6]=a*h,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(pf,t,mf)}lookAt(t,e,i){const n=this.elements;return yf.subVectors(t,e),0===yf.lengthSq()&&(yf.z=1),yf.normalize(),ff.crossVectors(i,yf),0===ff.lengthSq()&&(1===Math.abs(i.z)?yf.x+=1e-4:yf.z+=1e-4,yf.normalize(),ff.crossVectors(i,yf)),ff.normalize(),gf.crossVectors(yf,ff),n[0]=ff.x,n[4]=gf.x,n[8]=yf.x,n[1]=ff.y,n[5]=gf.y,n[9]=yf.y,n[2]=ff.z,n[6]=gf.z,n[10]=yf.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],y=i[3],_=i[7],v=i[11],x=i[15],b=n[0],M=n[4],S=n[8],T=n[12],w=n[1],E=n[5],A=n[9],C=n[13],R=n[2],N=n[6],I=n[10],P=n[14],L=n[3],D=n[7],O=n[11],U=n[15];return r[0]=s*b+a*w+o*R+l*L,r[4]=s*M+a*E+o*N+l*D,r[8]=s*S+a*A+o*I+l*O,r[12]=s*T+a*C+o*P+l*U,r[1]=h*b+c*w+u*R+d*L,r[5]=h*M+c*E+u*N+d*D,r[9]=h*S+c*A+u*I+d*O,r[13]=h*T+c*C+u*P+d*U,r[2]=p*b+m*w+f*R+g*L,r[6]=p*M+m*E+f*N+g*D,r[10]=p*S+m*A+f*I+g*O,r[14]=p*T+m*C+f*P+g*U,r[3]=y*b+_*w+v*R+x*L,r[7]=y*M+_*E+v*N+x*D,r[11]=y*S+_*A+v*I+x*O,r[15]=y*T+_*C+v*P+x*U,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],f=t[11],g=t[15],y=o*d-l*u,_=a*d-l*c,v=a*u-o*c,x=s*d-l*h,b=s*u-o*h,M=s*c-a*h;return e*(m*y-f*_+g*v)-i*(p*y-f*x+g*b)+n*(p*_-m*x+g*M)-r*(p*v-m*b+f*M)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],y=e*a-i*s,_=e*o-n*s,v=e*l-r*s,x=i*o-n*a,b=i*l-r*a,M=n*l-r*o,S=h*m-c*p,T=h*f-u*p,w=h*g-d*p,E=c*f-u*m,A=c*g-d*m,C=u*g-d*f,R=y*C-_*A+v*E+x*w-b*T+M*S;if(0===R)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/R;return t[0]=(a*C-o*A+l*E)*N,t[1]=(n*A-i*C-r*E)*N,t[2]=(m*M-f*b+g*x)*N,t[3]=(u*b-c*M-d*x)*N,t[4]=(o*w-s*C-l*T)*N,t[5]=(e*C-n*w+r*T)*N,t[6]=(f*v-p*M-g*_)*N,t[7]=(h*M-u*v+d*_)*N,t[8]=(s*A-a*w+l*S)*N,t[9]=(i*w-e*A-r*S)*N,t[10]=(p*b-m*v+g*y)*N,t[11]=(c*v-h*b-d*y)*N,t[12]=(a*T-s*E-o*S)*N,t[13]=(e*E-i*T+n*S)*N,t[14]=(m*_-p*x-f*y)*N,t[15]=(h*x-c*_+u*y)*N,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,a=t.y,o=t.z,l=r*s,h=r*a;return this.set(l*s+i,l*a-n*o,l*o+n*a,0,l*a+n*o,h*a+i,h*o-n*s,0,l*o-n*a,h*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,s){return this.set(1,i,r,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,h=s+s,c=a+a,u=r*l,d=r*h,p=r*c,m=s*h,f=s*c,g=a*c,y=o*l,_=o*h,v=o*c,x=i.x,b=i.y,M=i.z;return n[0]=(1-(m+g))*x,n[1]=(d+v)*x,n[2]=(p-_)*x,n[3]=0,n[4]=(d-v)*b,n[5]=(1-(u+g))*b,n[6]=(f+y)*b,n[7]=0,n[8]=(p+_)*M,n[9]=(f-y)*M,n[10]=(1-(u+m))*M,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const r=this.determinant();if(0===r)return i.set(1,1,1),e.identity(),this;let s=uf.set(n[0],n[1],n[2]).length();const a=uf.set(n[4],n[5],n[6]).length(),o=uf.set(n[8],n[9],n[10]).length();r<0&&(s=-s),df.copy(this);const l=1/s,h=1/a,c=1/o;return df.elements[0]*=l,df.elements[1]*=l,df.elements[2]*=l,df.elements[4]*=h,df.elements[5]*=h,df.elements[6]*=h,df.elements[8]*=c,df.elements[9]*=c,df.elements[10]*=c,e.setFromRotationMatrix(df),i.x=s,i.y=a,i.z=o,this}makePerspective(t,e,i,n,r,s,a=2e3,o=!1){const l=this.elements,h=2*r/(e-t),c=2*r/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,m;if(o)p=r/(s-r),m=s*r/(s-r);else if(a===Sm)p=-(s+r)/(s-r),m=-2*s*r/(s-r);else{if(a!==Tm)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-r),m=-s*r/(s-r)}return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,r,s,a=2e3,o=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,m;if(o)p=1/(s-r),m=s/(s-r);else if(a===Sm)p=-2/(s-r),m=-(s+r)/(s-r);else{if(a!==Tm)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=-1/(s-r),m=-r/(s-r)}return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}};const uf=new of,df=new cf,pf=new of(0,0,0),mf=new of(1,1,1),ff=new of,gf=new of,yf=new of;class _f{static{_f.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=zm(this.x,t.x,e.x),this.y=zm(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=zm(this.x,t,e),this.y=zm(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(zm(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(zm(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vf{static{vf.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(h-u)o&&t>y?ty?o{const i=t.match(e);if(!i)return null;const n=i[1]||i[2]||"",r=i[3].split("?")[0],s=parseInt(i[4],10),a=parseInt(i[5],10);return{fn:n,file:r.split("/").pop(),line:s,column:a}}).filter(t=>t&&!xf.some(e=>e.test(t.file)))}(t||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const t=this.stack[0],e=t.fn;return`${e?`"${e}()" at `:""}"${t.file}:${t.line}"`}getError(t){if(0===this.stack.length)return t;return`${t}\n${this.stack.map(t=>{const e=`${t.file}:${t.line}:${t.column}`;return t.fn?` at ${t.fn} (${e})`:` at ${e}`}).join("\n")}`}}function Mf(t,e=0){let i=3735928559^e,n=1103547991^e;if(Array.isArray(t))for(let e,r=0;r>>16,2246822507),i^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}const Sf=t=>Mf(t),Tf=(...t)=>Mf(t);function wf(t){if(null==t)return null;const e=typeof t;return!0===t.isNode?"node":"number"===e?"float":"boolean"===e?"bool":"string"===e?"string":"function"===e?"shader":!0===t.isVector2?"vec2":!0===t.isVector3?"vec3":!0===t.isVector4?"vec4":!0===t.isMatrix2?"mat2":!0===t.isMatrix3?"mat3":!0===t.isMatrix4?"mat4":!0===t.isColor?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function Ef(t,...e){const i=t?t.slice(-4):void 0;return 1===e.length&&("vec2"===i?e=[e[0],e[0]]:"vec3"===i?e=[e[0],e[0],e[0]]:"vec4"===i&&(e=[e[0],e[0],e[0],e[0]])),"color"===t?new nf(...e):"vec2"===i?new _f(...e):"vec3"===i?new of(...e):"vec4"===i?new vf(...e):"mat2"===i?new sf(...e):"mat3"===i?new Wm(...e):"mat4"===i?new cf(...e):"bool"===t?e[0]||!1:"float"===t||"int"===t||"uint"===t?e[0]||0:"string"===t?e[0]||"":"ArrayBuffer"===t?(n=e[0],Uint8Array.from(atob(n),t=>t.charCodeAt(0)).buffer):null;var n}class Af{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const n=i[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,n=e.length;iMf(t))(i),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t,e=null){const i=t.getDataFromNode(this);let n;return null!==e?(i.typeFromOutput=i.typeFromOutput||{},n=i.typeFromOutput[e],void 0===n&&(n=this.generateNodeType(t,e),i.typeFromOutput[e]=n)):(n=i.type,void 0===n&&(n=this.generateNodeType(t),i.type=n)),n}generateNodeType(t,e=null){const i=t.getNodeProperties(this);return i.outputNode?i.outputNode.getNodeType(t,e):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}getArrayCount(){return null}setup(t){const e=t.getNodeProperties(this);let i=0;for(const t of this.getChildren())e["node"+i++]=t;return e.outputNode||null}analyze(t,e=null){const i=t.increaseUsage(this);if(!0===this.parents){const i=t.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[t.shaderStage]=i.stages[t.shaderStage]||[],i.stages[t.shaderStage].push(e)}if(1===i){const e=t.getNodeProperties(this);for(const i of Object.values(e))i&&!0===i.isNode&&i.build(t,this)}}generate(t,e){const{outputNode:i}=t.getNodeProperties(this);if(i&&!0===i.isNode)return i.build(t,e)}updateBefore(){Nm("Abstract function.")}updateAfter(){Nm("Abstract function.")}update(){Nm("Abstract function.")}before(t){return null===this._beforeNodes&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){const i=this.getShared(t);if(this!==i)return i.build(t,e);if(null!==this._beforeNodes){const i=this._beforeNodes;this._beforeNodes=null;for(const n of i)n.build(t,e);this._beforeNodes=i}const n=t.getDataFromNode(this);n.buildStages=n.buildStages||{},n.buildStages[t.buildStage]=!0;const r=Cf[t.buildStage];if(r&&!0!==n.buildStages[r]){const e=t.getBuildStage();t.setBuildStage(r),this.build(t),t.setBuildStage(e)}t.addChain(this);let s=null;const a=t.getBuildStage();if("setup"===a){t.addNode(this),this.updateReference(t);const e=t.getNodeProperties(this);if(!0!==e.initialized){e.initialized=!0,e.outputNode=this.setup(t)||e.outputNode||null;for(const i of Object.values(e))if(i&&!0===i.isNode){if(!0===i.parents){const e=t.getNodeProperties(i);e.parents=e.parents||[],e.parents.push(this)}i.build(t)}t.addSequentialNode(this)}s=e.outputNode}else if("analyze"===a)this.analyze(t,e);else if("generate"===a){if(this.generate.length<2){const i=this.getNodeType(t),n=t.getDataFromNode(this);s=n.snippet,void 0===s?void 0===n.generated?(n.generated=!0,s=this.generate(t)||"",n.snippet=s):(Nm("Node: Recursion detected.",this),s="/* Recursion detected. */"):void 0!==n.flowCodes&&void 0!==t.context.nodeBlock&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),s=t.format(s,i,e)}else s=this.generate(t,e)||"";""===s&&null!==e&&"void"!==e&&"OutputType"!==e&&(Im(`TSL: Invalid generated code, expected a "${e}".`),s=t.generateConst(e))}return t.removeChain(this),s}getSerializeChildren(){return this._getChildren()}serialize(t){const e=this.getSerializeChildren(),i={};for(const{property:n,index:r,childNode:s}of e)void 0!==r?(void 0===i[n]&&(i[n]=Number.isInteger(r)?[]:{}),i[n][r]=s.toJSON(t.meta).uuid):i[n]=s.toJSON(t.meta).uuid;Object.keys(i).length>0&&(t.inputNodes=i)}deserialize(t){if(void 0!==t.inputNodes){const e=t.meta.nodes;for(const i in t.inputNodes)if(Array.isArray(t.inputNodes[i])){const n=[];for(const r of t.inputNodes[i])n.push(e[r]);this[i]=n}else if("object"==typeof t.inputNodes[i]){const n={};for(const r in t.inputNodes[i]){const s=t.inputNodes[i][r];n[r]=e[s]}this[i]=n}else{const n=t.inputNodes[i];this[i]=e[n]}}}toJSON(t){const{uuid:e,type:i}=this,n=void 0===t||"string"==typeof t;n&&(t={textures:{},images:{},nodes:{}});let r=t.nodes[e];function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(void 0===r&&(r={uuid:e,type:i,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==n&&(t.nodes[r.uuid]=r),this.serialize(r),delete r.meta),n){const e=s(t.textures),i=s(t.images),n=s(t.nodes);e.length>0&&(r.textures=e),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}};Nf.captureStackTrace=!1;class If extends Nf{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if("generate"===t.getBuildStage()){const i=t.getVectorType(this.getNodeType(t,e)),n=t.getDataFromNode(this);if(void 0!==n.propertyName)return t.format(n.propertyName,i,e);if("void"!==i&&"void"!==e&&this.hasDependencies(t)){const r=super.build(t,i),s=t.getVarFromNode(this,null,i),a=t.getPropertyName(s);return t.addLineFlowCode(`${a} = ${r}`,this),n.snippet=r,n.propertyName=a,t.format(n.propertyName,i,e)}}return super.build(t,e)}}class Pf extends Nf{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}generateNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){const e=this.indexNode.getNodeType(t);return`${this.node.build(t)}[ ${this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint")} ]`}}class Lf extends Nf{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}generateNodeType(t){const e=this.node.getNodeType(t);let i=null;for(const n of this.convertTo.split("|"))null!==i&&t.getTypeLength(e)!==t.getTypeLength(n)||(i=n);return i}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const i=this.node,n=this.getNodeType(t),r=i.build(t,n);return t.format(r,n,e)}}class Df extends If{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}generateNodeType(t){return null!==this.nodeType?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,i)=>e+t.getTypeLength(i.getNodeType(t)),0))}generate(t,e){const i=this.getNodeType(t),n=t.getTypeLength(i),r=this.nodes,s=t.getComponentType(i),a=[];let o=0;for(const e of r){if(o>=n){Im(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let r,l=e.getNodeType(t),h=t.getTypeLength(l);o+h>n&&(Im(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),h=n-o,l=t.getTypeFromLength(h)),o+=h,r=e.build(t,l);if(t.getComponentType(l)!==s){const e=t.getTypeFromLength(h,s);r=t.format(r,l,e)}a.push(r)}const l=`${t.getType(i)}( ${a.join(", ")} )`;return t.format(l,i,e)}}const Of=mm.join("");class Uf extends Nf{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(mm.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}generateNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){const i=this.node,n=t.getTypeLength(i.getNodeType(t));let r=null;if(n>1){let s=null;this.getVectorLength()>=n&&(s=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const a=i.build(t,s);r=this.components.length===n&&this.components===Of.slice(0,this.components.length)?t.format(a,s,e):t.format(`${a}.${this.components}`,this.getNodeType(t),e)}else r=i.build(t,e);return r}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class Ff extends If{static get type(){return"SetNode"}constructor(t,e,i){super(),this.sourceNode=t,this.components=e,this.targetNode=i}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:i,targetNode:n}=this,r=this.getNodeType(t),s=t.getComponentType(n.getNodeType(t)),a=t.getTypeFromLength(i.length,s),o=n.build(t,a),l=e.build(t,r),h=t.getTypeLength(r),c=[];for(let t=0;t(t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"))(t).split("").sort().join("");Nf.prototype.assign=function(...t){if(!0!==this.isStackNode)return Im("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new bf),this;{const e=Hf.get("assign");return this.addToStack(e(...t))}},Nf.prototype.toVarIntent=function(){return this},Nf.prototype.get=function(t){return new Gf(this,t)};const Xf={};function qf(t,e,i){Xf[t]=Xf[e]=Xf[i]={get(){this._cache=this._cache||{};let e=this._cache[t];return void 0===e&&(e=new Uf(this,t),this._cache[t]=e),e},set(e){this[t].assign(yg(e))}};const n=t.toUpperCase(),r=e.toUpperCase(),s=i.toUpperCase();Nf.prototype["set"+n]=Nf.prototype["set"+r]=Nf.prototype["set"+s]=function(e){const i=jf(t);return new Ff(this,i,yg(e))},Nf.prototype["flip"+n]=Nf.prototype["flip"+r]=Nf.prototype["flip"+s]=function(){const e=jf(t);return new zf(this,e)}}const Yf=["x","y","z","w"],Zf=["r","g","b","a"],Kf=["s","t","p","q"];for(let t=0;t<4;t++){let e=Yf[t],i=Zf[t],n=Kf[t];qf(e,i,n);for(let r=0;r<4;r++){e=Yf[t]+Yf[r],i=Zf[t]+Zf[r],n=Kf[t]+Kf[r],qf(e,i,n);for(let s=0;s<4;s++){e=Yf[t]+Yf[r]+Yf[s],i=Zf[t]+Zf[r]+Zf[s],n=Kf[t]+Kf[r]+Kf[s],qf(e,i,n);for(let a=0;a<4;a++)e=Yf[t]+Yf[r]+Yf[s]+Yf[a],i=Zf[t]+Zf[r]+Zf[s]+Zf[a],n=Kf[t]+Kf[r]+Kf[s]+Kf[a],qf(e,i,n)}}}for(let t=0;t<32;t++)Xf[t]={get(){this._cache=this._cache||{};let e=this._cache[t];return void 0===e&&(e=new Pf(this,new Vf(t,"uint")),this._cache[t]=e),e},set(e){this[t].assign(yg(e))}};Object.defineProperties(Nf.prototype,Xf);const Jf=new WeakMap,$f=function(t,e=null){for(const i in t)t[i]=yg(t[i],e);return t},Qf=function(t,e=null){const i=t.length;for(let n=0;no?(Im(`TSL: "${i}" parameter length exceeds limit.`,new bf),e.slice(0,o)):e}return null===e?s=(...e)=>r(new t(...xg(h(e)))):null!==i?(i=yg(i),s=(...n)=>r(new t(e,...xg(h(n)),i))):s=(...i)=>r(new t(e,...xg(h(i)))),s.setParameterLength=(...t)=>(1===t.length?a=o=t[0]:2===t.length&&([a,o]=t),s),s.setName=t=>(l=t,s),s},eg=function(t,...e){return new t(...xg(e))};class ig extends Nf{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}generateNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){const{shaderNode:e,rawInputs:i}=this,n=t.getNodeProperties(e),r=t.getClosestSubBuild(e.subBuilds)||"",s=r||"default";if(n[s])return n[s];const a=t.subBuildFn,o=t.fnCall;t.subBuildFn=r,t.fnCall=this;let l=null;if(e.layout){let n=Jf.get(t.constructor);void 0===n&&(n=new WeakMap,Jf.set(t.constructor,n));let r=n.get(e);void 0===r&&(r=yg(t.buildFunctionNode(e)),n.set(e,r)),t.addInclude(r);const s=i?function(t){let e;vg(t);e=t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)?[...t]:t[0];return e}(i):null;l=yg(r.call(s))}else{const n=new Proxy(t,{get:(t,e,i)=>{let n;return n=Symbol.iterator===e?function*(){yield}:Reflect.get(t,e,i),n}}),r=i?function(t){let e=0;return vg(t),new Proxy(t,{get:(i,n,r)=>{let s;if("length"===n)return s=t.length,s;if(Symbol.iterator===n)s=function*(){for(const e of t)yield yg(e)};else{if(t.length>0)if(Object.getPrototypeOf(t[0])===Object.prototype){const i=t[0];s=void 0===i[n]?i[e++]:Reflect.get(i,n,r)}else t[0]instanceof Nf&&(s=void 0===t[n]?t[e++]:Reflect.get(t,n,r));else s=Reflect.get(i,n,r);s=yg(s)}return s}})}(i):null,s=Array.isArray(i)?i.length>0:null!==i,a=e.jsFunc,o=s||a.length>1?a(r,n):a(n);l=yg(o)}return t.subBuildFn=a,t.fnCall=o,e.once&&(n[s]=l),l}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){const e=t.getNodeProperties(this),i=t.getSubBuildOutput(this);return e[i]=e[i]||this.setupOutput(t),e[i].subBuild=t.getClosestSubBuild(this),e[i]}build(t,e=null){let i=null;const n=t.getBuildStage(),r=t.getNodeProperties(this),s=t.getSubBuildOutput(this),a=this.getOutputNode(t),o=t.fnCall;if(t.fnCall=this,"setup"===n){const e=t.getSubBuildProperty("initialized",this);if(!0!==r[e]&&(r[e]=!0,r[s]=this.getOutputNode(t),r[s].build(t),this.shaderNode.subBuilds))for(const e of t.chaining){const i=t.getDataFromNode(e,"any");i.subBuilds=i.subBuilds||new Set;for(const t of this.shaderNode.subBuilds)i.subBuilds.add(t)}i=r[s]}else"analyze"===n?a.build(t,e):"generate"===n&&(i=a.build(t,e)||"");return t.fnCall=o,i}}class ng extends Nf{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new ig(this,t)}setup(){return this.call()}}const rg=[!1,!0],sg=[0,1,2,3],ag=[-1,-2],og=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],lg=new Map;for(const t of rg)lg.set(t,new Vf(t));const hg=new Map;for(const t of sg)hg.set(t,new Vf(t,"uint"));const cg=new Map([...hg].map(t=>new Vf(t.value,"int")));for(const t of ag)cg.set(t,new Vf(t,"int"));const ug=new Map([...cg].map(t=>new Vf(t.value)));for(const t of og)ug.set(t,new Vf(t));for(const t of og)ug.set(-t,new Vf(-t));const dg={bool:lg,uint:hg,ints:cg,float:ug},pg=new Map([...lg,...ug]),mg=(t,e)=>pg.has(t)?pg.get(t):!0===t.isNode?t:new Vf(t,e),fg=function(t,e=null){return(...i)=>{for(const e of i)if(void 0===e)return Im(`TSL: Invalid parameter for the type "${t}".`,new bf),new Vf(0,t);if((0===i.length||!["bool","float","int","uint"].includes(t)&&i.every(t=>{const e=typeof t;return"object"!==e&&"function"!==e}))&&(i=[Ef(t,...i)]),1===i.length&&null!==e&&e.has(i[0]))return _g(e.get(i[0]));if(1===i.length){const e=mg(i[0],t);return e.nodeType===t?_g(e):_g(new Lf(e,t))}const n=i.map(t=>mg(t));return _g(new Df(n,t))}};function gg(t,e){return new ng(t,e)}const yg=(t,e=null)=>function(t,e=null){const i=wf(t);return"node"===i?t:null===e&&("float"===i||"boolean"===i)||i&&"shader"!==i&&"string"!==i?yg(mg(t,e)):"shader"===i?t.isFn?t:Eg(t):t}(t,e),_g=(t,e=null)=>yg(t,e).toVarIntent(),vg=(t,e=null)=>new $f(t,e),xg=(t,e=null)=>new Qf(t,e),bg=(t,e=null,i=null,n=null)=>new tg(t,e,i,n),Mg=(t,...e)=>new eg(t,...e),Sg=(t,e=null,i=null,n={})=>new tg(t,e,i,{...n,intent:!0});let Tg=0;class wg extends Nf{constructor(t,e=null){super();let i=null;null!==e&&("object"==typeof e?i=e.return:("string"==typeof e?i=e:Im("TSL: Invalid layout type.",new bf),e=null)),this.shaderNode=new gg(t,i),null!==e&&this.setLayout(e),this.isFn=!0}setLayout(t){const e=this.shaderNode.nodeType;if("object"!=typeof t.inputs){const i={name:"fn"+Tg++,type:e,inputs:[]};for(const e in t)"return"!==e&&i.inputs.push({name:e,type:t[e]});t=i}return this.shaderNode.setLayout(t),this}generateNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){const e=this.shaderNode.call(t);return"void"===this.shaderNode.nodeType&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){const e=this.getNodeType(t);return Im('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}}function Eg(t,e=null){const i=new wg(t,e);return new Proxy(()=>{},{apply:(t,e,n)=>i.call(...n),get:(t,e,n)=>Reflect.get(i,e,n),set:(t,e,n,r)=>Reflect.set(i,e,n,r)})}const Ag=(...t)=>null.If(...t);function Cg(t){return t}Wf("toStack",Cg);const Rg=new fg("color"),Ng=new fg("float",dg.float),Ig=new fg("int",dg.ints),Pg=new fg("uint",dg.uint),Lg=new fg("bool",dg.bool),Dg=new fg("vec2"),Og=new fg("ivec2"),Ug=new fg("uvec2"),Fg=new fg("bvec2"),zg=new fg("vec3"),kg=new fg("ivec3"),Bg=new fg("uvec3"),Vg=new fg("bvec3"),Gg=new fg("vec4"),Hg=new fg("ivec4"),Wg=new fg("uvec4"),jg=new fg("bvec4"),Xg=new fg("mat2"),qg=new fg("mat3"),Yg=new fg("mat4");Wf("toColor",Rg),Wf("toFloat",Ng),Wf("toInt",Ig),Wf("toUint",Pg),Wf("toBool",Lg),Wf("toVec2",Dg),Wf("toIVec2",Og),Wf("toUVec2",Ug),Wf("toBVec2",Fg),Wf("toVec3",zg),Wf("toIVec3",kg),Wf("toUVec3",Bg),Wf("toBVec3",Vg),Wf("toVec4",Gg),Wf("toIVec4",Hg),Wf("toUVec4",Wg),Wf("toBVec4",jg),Wf("toMat2",Xg),Wf("toMat3",qg),Wf("toMat4",Yg);Wf("element",bg(Pf).setParameterLength(2)),Wf("convert",(t,e)=>new Lf(yg(t),e)),Wf("append",t=>(Nm("TSL: .append() has been renamed to .toStack().",new bf),t));class Zg extends If{static get type(){return"ArrayNode"}constructor(t,e,i=null){super(t),this.count=e,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(t){return null===this.nodeType?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return null===this.nodeType?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){const e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}}Wf("toArray",(t,e)=>((...t)=>{let e;if(1===t.length){const i=t[0];e=new Zg(null,i.length,i)}else{const i=t[0],n=t[1];e=new Zg(i,n)}return yg(e)})(Array(e).fill(t)));class Kg extends If{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(t,e){return"void"!==e?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(!1===t.isAvailable("swizzleAssign")&&e.isSplitNode&&e.components.length>1){const i=t.getTypeLength(e.node.getNodeType(t));return mm.join("").slice(0,i)!==e.components}return!1}setup(t){const{targetNode:e,sourceNode:i}=this,n=e.getScope();t.getDataFromNode(n).assign=!0;const r=t.getNodeProperties(this);r.sourceNode=i,r.targetNode=e.context({assign:!0})}generate(t,e){const{targetNode:i,sourceNode:n}=t.getNodeProperties(this),r=this.needsSplitAssign(t),s=i.build(t),a=i.getNodeType(t),o=n.build(t,a),l=n.getNodeType(t),h=t.getDataFromNode(this);let c;if(!0===h.initialized)"void"!==e&&(c=s);else if(r){const n=t.getVarFromNode(this,null,a),r=t.getPropertyName(n);t.addLineFlowCode(`${r} = ${o}`,this);const l=i.node,h=l.node.context({assign:!0}).build(t);for(let e=0;enew Jg(t,!1,e,i),Qg=(t,e=0,i=null)=>new Jg(t,!0,e,i),ty=Qg("render",0,dm),ey=$g("object",1,pm);class iy extends kf{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=ey}setName(t){return this.name=t,this}label(t){return Nm('TSL: "label()" has been deprecated. Use "setName()" instead.',new bf),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(e=>{const i=t(e,this);void 0!==i&&(this.value=i)},e)}getInputType(t){let e=super.getInputType(t);return"bool"===e&&(e="uint"),e}generate(t,e){const i=this.getNodeType(t),n=this.getUniformHash(t);let r=t.getNodeFromHash(n);void 0===r&&(t.setHashNode(this,n),r=this);const s=r.getInputType(t),a=t.getUniformFromNode(r,s,t.shaderStage,this.name||t.context.nodeName),o=t.getPropertyName(a);void 0!==t.context.nodeName&&delete t.context.nodeName;let l=o;if("bool"===i){const e=t.getDataFromNode(this);let n=e.propertyName;if(void 0===n){const r=t.getVarFromNode(this,null,"bool");n=t.getPropertyName(r),e.propertyName=n,l=t.format(o,s,i),t.addLineFlowCode(`${n} = ${l}`,this)}l=n}return t.format(l,i,e)}}const ny=(t,e)=>{const i=(t=>null!=t?t.nodeType||t.convertTo||("string"==typeof t?t:null):null)(e||t);if(i===t&&(t=Ef(i)),t&&!0===t.isNode){let e=t.value;t.traverse(t=>{!0===t.isConstNode&&(e=t.value)}),t=e}return new iy(t,i)};class ry extends Nf{static get type(){return"PropertyNode"}constructor(t,e=null,i=!1){super(t),this.name=e,this.varying=i,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return Sf(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return!0===this.varying?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const sy=Mg(ry,"vec4","DiffuseColor");class ay extends If{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}generateNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){const e=[],i=this.functionNode,n=i.getInputs(t),r=this.parameters,s=(e,i)=>{const n=i.type;let r;return r="pointer"===n?"&"+e.build(t):e.build(t,n),r};if(Array.isArray(r)){if(r.length>n.length)Im("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),r.length=n.length;else if(r.length(e=e.length>1||e[0]&&!0===e[0].isNode?xg(e):vg(e[0]),new ay(yg(t),e)));const oy={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ly extends If{static get type(){return"OperatorNode"}constructor(t,e,i,...n){if(super(),n.length>0){let r=new ly(t,e,i);for(let e=0;e>"===i||"<<"===i)return t.getIntegerType(s);if("!"===i||"&&"===i||"||"===i||"^^"===i)return"bool";if("=="===i||"!="===i||"<"===i||">"===i||"<="===i||">="===i){const e=Math.max(t.getTypeLength(s),t.getTypeLength(a));return e>1?`bvec${e}`:"bool"}if(t.isMatrix(s)){if("float"===a)return s;if(t.isVector(a))return t.getVectorFromMatrix(s);if(t.isMatrix(a))return s}else if(t.isMatrix(a)){if("float"===s)return a;if(t.isVector(s))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(s)?a:s}generate(t,e){const i=this.op,{aNode:n,bNode:r}=this,s=this.getNodeType(t,e);let a=null,o=null;"void"!==s?(a=n.getNodeType(t),o=r?r.getNodeType(t):null,"<"===i||">"===i||"<="===i||">="===i||"=="===i||"!="===i?t.isVector(a)?o=a:t.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===i||"<<"===i?(a=s,o=t.changeComponentType(o,"uint")):"%"===i?(a=s,o=t.isInteger(a)&&t.isInteger(o)?o:a):t.isMatrix(a)?"float"===o?o="float":t.isVector(o)?o=t.getVectorFromMatrix(a):t.isMatrix(o)||(a=o=s):a=t.isMatrix(o)?"float"===a?"float":t.isVector(a)?t.getVectorFromMatrix(o):o=s:o=s):a=o=s;const l=n.build(t,a),h=r?r.build(t,o):null,c=t.getFunctionOperator(i);if("void"!==e){const n=t.renderer.coordinateSystem===Sm;if("=="===i||"!="===i||"<"===i||">"===i||"<="===i||">="===i)return n&&t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${l}, ${h} )`,s,e):t.format(`( ${l} ${i} ${h} )`,s,e);if("%"===i)return t.isInteger(o)?t.format(`( ${l} % ${h} )`,s,e):t.format(`${this.getOperatorMethod(t,s)}( ${l}, ${h} )`,s,e);if("!"===i||"~"===i)return t.format(`(${i}${l})`,a,e);if(c)return t.format(`${c}( ${l}, ${h} )`,s,e);if(t.isMatrix(a)&&"float"===o)return t.format(`( ${h} ${i} ${l} )`,s,e);if("float"===a&&t.isMatrix(o))return t.format(`${l} ${i} ${h}`,s,e);{let r=`( ${l} ${i} ${h} )`;return!n&&"bool"===s&&t.isVector(a)&&t.isVector(o)&&(r=`all${r}`),t.format(r,s,e)}}if("void"!==a)return c?t.format(`${c}( ${l}, ${h} )`,s,e):t.isMatrix(a)&&"float"===o?t.format(`${h} ${i} ${l}`,s,e):t.format(`${l} ${i} ${h}`,s,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const hy=Sg(ly,"+").setParameterLength(2,1/0).setName("add"),cy=Sg(ly,"-").setParameterLength(2,1/0).setName("sub"),uy=Sg(ly,"*").setParameterLength(2,1/0).setName("mul"),dy=Sg(ly,"/").setParameterLength(2,1/0).setName("div"),py=Sg(ly,"%").setParameterLength(2).setName("mod"),my=Sg(ly,"==").setParameterLength(2).setName("equal"),fy=Sg(ly,"!=").setParameterLength(2).setName("notEqual"),gy=Sg(ly,"<").setParameterLength(2).setName("lessThan"),yy=Sg(ly,">").setParameterLength(2).setName("greaterThan"),_y=Sg(ly,"<=").setParameterLength(2).setName("lessThanEqual"),vy=Sg(ly,">=").setParameterLength(2).setName("greaterThanEqual"),xy=Sg(ly,"&&").setParameterLength(2,1/0).setName("and"),by=Sg(ly,"||").setParameterLength(2,1/0).setName("or"),My=Sg(ly,"!").setParameterLength(1).setName("not"),Sy=Sg(ly,"^^").setParameterLength(2).setName("xor"),Ty=Sg(ly,"&").setParameterLength(2).setName("bitAnd"),wy=Sg(ly,"~").setParameterLength(1).setName("bitNot"),Ey=Sg(ly,"|").setParameterLength(2).setName("bitOr"),Ay=Sg(ly,"^").setParameterLength(2).setName("bitXor"),Cy=Sg(ly,"<<").setParameterLength(2).setName("shiftLeft"),Ry=Sg(ly,">>").setParameterLength(2).setName("shiftRight"),Ny=Eg(([t])=>(t.addAssign(1),t)),Iy=Eg(([t])=>(t.subAssign(1),t)),Py=Eg(([t])=>{const e=Ig(t).toConst();return t.addAssign(1),e}),Ly=Eg(([t])=>{const e=Ig(t).toConst();return t.subAssign(1),e});Wf("add",hy),Wf("sub",cy),Wf("mul",uy),Wf("div",dy),Wf("mod",py),Wf("equal",my),Wf("notEqual",fy),Wf("lessThan",gy),Wf("greaterThan",yy),Wf("lessThanEqual",_y),Wf("greaterThanEqual",vy),Wf("and",xy),Wf("or",by),Wf("not",My),Wf("xor",Sy),Wf("bitAnd",Ty),Wf("bitNot",wy),Wf("bitOr",Ey),Wf("bitXor",Ay),Wf("shiftLeft",Cy),Wf("shiftRight",Ry),Wf("incrementBefore",Ny),Wf("decrementBefore",Iy),Wf("increment",Py),Wf("decrement",Ly);Wf("modInt",(t,e)=>(Nm('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new bf),py(Ig(t),Ig(e))));class Dy extends If{static get type(){return"MathNode"}constructor(t,e,i=null,n=null){if(super(),(t===Dy.MAX||t===Dy.MIN)&&arguments.length>3){let r=new Dy(t,e,i);for(let e=2;es&&r>a?e:s>a?i:a>r?n:e}generateNodeType(t){const e=this.method;return e===Dy.LENGTH||e===Dy.DISTANCE||e===Dy.DOT?"float":e===Dy.CROSS?"vec3":e===Dy.ALL||e===Dy.ANY?"bool":e===Dy.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){const{aNode:e,bNode:i,method:n}=this;let r=null;if(n===Dy.ONE_MINUS)r=cy(1,e);else if(n===Dy.RECIPROCAL)r=dy(1,e);else if(n===Dy.DIFFERENCE)r=l_(cy(e,i));else if(n===Dy.TRANSFORM_DIRECTION){let n=e,s=i;t.isMatrix(n.getNodeType(t))?s=Gg(zg(s),0):n=Gg(zg(n),0);const a=uy(n,s).xyz;r=Yy(a)}return null!==r?r:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method;const n=this.getNodeType(t),r=this.getInputType(t),s=this.aNode,a=this.bNode,o=this.cNode,l=t.renderer.coordinateSystem;if(i===Dy.NEGATE)return t.format("( - "+s.build(t,r)+" )",n,e);{const h=[];return i===Dy.CROSS?h.push(s.build(t,n),a.build(t,n)):l===Sm&&i===Dy.STEP?h.push(s.build(t,1===t.getTypeLength(s.getNodeType(t))?"float":r),a.build(t,r)):l!==Sm||i!==Dy.MIN&&i!==Dy.MAX?i===Dy.REFRACT?h.push(s.build(t,r),a.build(t,r),o.build(t,"float")):i===Dy.MIX?h.push(s.build(t,r),a.build(t,r),o.build(t,1===t.getTypeLength(o.getNodeType(t))?"float":r)):(l===Tm&&i===Dy.ATAN&&null!==a&&(i="atan2"),"fragment"===t.shaderStage||i!==Dy.DFDX&&i!==Dy.DFDY||(Nm(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),h.push(s.build(t,r)),null!==a&&h.push(a.build(t,r)),null!==o&&h.push(o.build(t,r))):h.push(s.build(t,r),a.build(t,1===t.getTypeLength(a.getNodeType(t))?"float":r)),t.format(`${t.getMethod(i,n)}( ${h.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}Dy.ALL="all",Dy.ANY="any",Dy.RADIANS="radians",Dy.DEGREES="degrees",Dy.EXP="exp",Dy.EXP2="exp2",Dy.LOG="log",Dy.LOG2="log2",Dy.SQRT="sqrt",Dy.INVERSE_SQRT="inversesqrt",Dy.FLOOR="floor",Dy.CEIL="ceil",Dy.NORMALIZE="normalize",Dy.FRACT="fract",Dy.SIN="sin",Dy.SINH="sinh",Dy.COS="cos",Dy.COSH="cosh",Dy.TAN="tan",Dy.TANH="tanh",Dy.ASIN="asin",Dy.ASINH="asinh",Dy.ACOS="acos",Dy.ACOSH="acosh",Dy.ATAN="atan",Dy.ATANH="atanh",Dy.ABS="abs",Dy.SIGN="sign",Dy.LENGTH="length",Dy.NEGATE="negate",Dy.ONE_MINUS="oneMinus",Dy.DFDX="dFdx",Dy.DFDY="dFdy",Dy.ROUND="round",Dy.RECIPROCAL="reciprocal",Dy.TRUNC="trunc",Dy.FWIDTH="fwidth",Dy.TRANSPOSE="transpose",Dy.DETERMINANT="determinant",Dy.INVERSE="inverse",Dy.EQUALS="equals",Dy.MIN="min",Dy.MAX="max",Dy.STEP="step",Dy.REFLECT="reflect",Dy.DISTANCE="distance",Dy.DIFFERENCE="difference",Dy.DOT="dot",Dy.CROSS="cross",Dy.POW="pow",Dy.TRANSFORM_DIRECTION="transformDirection",Dy.MIX="mix",Dy.CLAMP="clamp",Dy.REFRACT="refract",Dy.SMOOTHSTEP="smoothstep",Dy.FACEFORWARD="faceforward";const Oy=Ng(Math.PI),Uy=Sg(Dy,Dy.ALL).setParameterLength(1),Fy=Sg(Dy,Dy.ANY).setParameterLength(1),zy=Sg(Dy,Dy.RADIANS).setParameterLength(1),ky=Sg(Dy,Dy.DEGREES).setParameterLength(1),By=Sg(Dy,Dy.EXP).setParameterLength(1),Vy=Sg(Dy,Dy.EXP2).setParameterLength(1),Gy=Sg(Dy,Dy.LOG).setParameterLength(1),Hy=Sg(Dy,Dy.LOG2).setParameterLength(1),Wy=Sg(Dy,Dy.SQRT).setParameterLength(1),jy=Sg(Dy,Dy.INVERSE_SQRT).setParameterLength(1),Xy=Sg(Dy,Dy.FLOOR).setParameterLength(1),qy=Sg(Dy,Dy.CEIL).setParameterLength(1),Yy=Sg(Dy,Dy.NORMALIZE).setParameterLength(1),Zy=Sg(Dy,Dy.FRACT).setParameterLength(1),Ky=Sg(Dy,Dy.SIN).setParameterLength(1),Jy=Sg(Dy,Dy.SINH).setParameterLength(1),$y=Sg(Dy,Dy.COS).setParameterLength(1),Qy=Sg(Dy,Dy.COSH).setParameterLength(1),t_=Sg(Dy,Dy.TAN).setParameterLength(1),e_=Sg(Dy,Dy.TANH).setParameterLength(1),i_=Sg(Dy,Dy.ASIN).setParameterLength(1),n_=Sg(Dy,Dy.ASINH).setParameterLength(1),r_=Sg(Dy,Dy.ACOS).setParameterLength(1),s_=Sg(Dy,Dy.ACOSH).setParameterLength(1),a_=Sg(Dy,Dy.ATAN).setParameterLength(1,2),o_=Sg(Dy,Dy.ATANH).setParameterLength(1),l_=Sg(Dy,Dy.ABS).setParameterLength(1),h_=Sg(Dy,Dy.SIGN).setParameterLength(1),c_=Sg(Dy,Dy.LENGTH).setParameterLength(1),u_=Sg(Dy,Dy.NEGATE).setParameterLength(1),d_=Sg(Dy,Dy.ONE_MINUS).setParameterLength(1),p_=Sg(Dy,Dy.DFDX).setParameterLength(1),m_=Sg(Dy,Dy.DFDY).setParameterLength(1),f_=Sg(Dy,Dy.ROUND).setParameterLength(1),g_=Sg(Dy,Dy.RECIPROCAL).setParameterLength(1),y_=Sg(Dy,Dy.TRUNC).setParameterLength(1),__=Sg(Dy,Dy.FWIDTH).setParameterLength(1),v_=Sg(Dy,Dy.TRANSPOSE).setParameterLength(1),x_=Sg(Dy,Dy.DETERMINANT).setParameterLength(1),b_=Sg(Dy,Dy.INVERSE).setParameterLength(1),M_=Sg(Dy,Dy.MIN).setParameterLength(2,1/0),S_=Sg(Dy,Dy.MAX).setParameterLength(2,1/0),T_=Sg(Dy,Dy.STEP).setParameterLength(2),w_=Sg(Dy,Dy.REFLECT).setParameterLength(2),E_=Sg(Dy,Dy.DISTANCE).setParameterLength(2),A_=Sg(Dy,Dy.DIFFERENCE).setParameterLength(2),C_=Sg(Dy,Dy.DOT).setParameterLength(2),R_=Sg(Dy,Dy.CROSS).setParameterLength(2),N_=Sg(Dy,Dy.POW).setParameterLength(2),I_=Sg(Dy,Dy.TRANSFORM_DIRECTION).setParameterLength(2),P_=Sg(Dy,Dy.MIX).setParameterLength(3),L_=(t,e=0,i=1)=>new Dy(Dy.CLAMP,yg(t),yg(e),yg(i)),D_=t=>L_(t),O_=Sg(Dy,Dy.REFRACT).setParameterLength(3),U_=Sg(Dy,Dy.SMOOTHSTEP).setParameterLength(3),F_=Sg(Dy,Dy.FACEFORWARD).setParameterLength(3),z_=Eg(([t])=>{const e=C_(t.xy,Dg(12.9898,78.233)),i=py(e,Oy);return Zy(Ky(i).mul(43758.5453))});Wf("all",Uy),Wf("any",Fy),Wf("radians",zy),Wf("degrees",ky),Wf("exp",By),Wf("exp2",Vy),Wf("log",Gy),Wf("log2",Hy),Wf("sqrt",Wy),Wf("inverseSqrt",jy),Wf("floor",Xy),Wf("ceil",qy),Wf("normalize",Yy),Wf("fract",Zy),Wf("sin",Ky),Wf("sinh",Jy),Wf("cos",$y),Wf("cosh",Qy),Wf("tan",t_),Wf("tanh",e_),Wf("asin",i_),Wf("asinh",n_),Wf("acos",r_),Wf("acosh",s_),Wf("atan",a_),Wf("atanh",o_),Wf("abs",l_),Wf("sign",h_),Wf("length",c_),Wf("lengthSq",t=>C_(t,t)),Wf("negate",u_),Wf("oneMinus",d_),Wf("dFdx",p_),Wf("dFdy",m_),Wf("round",f_),Wf("reciprocal",g_),Wf("trunc",y_),Wf("fwidth",__),Wf("min",M_),Wf("max",S_),Wf("step",(t,e)=>T_(e,t)),Wf("reflect",w_),Wf("distance",E_),Wf("dot",C_),Wf("cross",R_),Wf("pow",N_),Wf("pow2",t=>uy(t,t)),Wf("pow3",t=>uy(t,t,t)),Wf("pow4",t=>uy(t,t,t,t)),Wf("transformDirection",I_),Wf("mix",(t,e,i)=>P_(e,i,t)),Wf("clamp",L_),Wf("refract",O_),Wf("smoothstep",(t,e,i)=>U_(e,i,t)),Wf("faceForward",F_),Wf("difference",A_),Wf("saturate",D_),Wf("cbrt",t=>uy(h_(t),N_(l_(t),1/3))),Wf("transpose",v_),Wf("determinant",x_),Wf("inverse",b_),Wf("rand",z_);class k_ extends Nf{static get type(){return"ConditionalNode"}constructor(t,e,i=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=i}generateNodeType(t){const{ifNode:e,elseNode:i}=t.getNodeProperties(this);if(void 0===e)return t.flowBuildStage(this,"setup"),this.getNodeType(t);const n=e.getNodeType(t);if(null!==i){const e=i.getNodeType(t);if(t.getTypeLength(e)>t.getTypeLength(n))return e}return n}setup(t){const e=this.condNode,i=this.ifNode.isolate(),n=this.elseNode?this.elseNode.isolate():null,r=t.context.nodeBlock;t.getDataFromNode(i).parentNodeBlock=r,null!==n&&(t.getDataFromNode(n).parentNodeBlock=r);const s=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=s?i:i.context({nodeBlock:i}),a.elseNode=n?s?n:n.context({nodeBlock:n}):null}generate(t,e){const i=this.getNodeType(t),n=t.getDataFromNode(this);if(void 0!==n.nodeProperty)return n.nodeProperty;const{condNode:r,ifNode:s,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l="void"!==e,h=l?((t,e)=>new ry(t,e))(i).build(t):"";n.nodeProperty=h;const c=r.build(t,"bool");if(t.context.uniformFlow&&null!==a){const n=s.build(t,i),r=a.build(t,i),o=t.getTernary(c,n,r);return t.format(o,i,e)}t.addFlowCode(`\n${t.tab}if ( ${c} ) {\n\n`).addFlowTab();let u=s.build(t,i);if(u&&(l?u=h+" = "+u+";":(u="return "+u+";",null===o&&(Nm("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),u="// "+u))),t.removeFlowTab().addFlowCode(t.tab+"\t"+u+"\n\n"+t.tab+"}"),null!==a){t.addFlowCode(" else {\n\n").addFlowTab();let e=a.build(t,i);e&&(l?e=h+" = "+e+";":(e="return "+e+";",null===o&&(Nm("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),e="// "+e))),t.removeFlowTab().addFlowCode(t.tab+"\t"+e+"\n\n"+t.tab+"}\n\n")}else t.addFlowCode("\n\n");return t.format(h,i,e)}}const B_=bg(k_).setParameterLength(2,3);Wf("select",B_);class V_ extends Nf{static get type(){return"ContextNode"}constructor(t=null,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}generateNodeType(t){return this.node.getNodeType(t)}getFlowContextData(){const t=[];return this.traverse(e=>{!0===e.isContextNode&&t.push(e.value)}),Object.assign({},...t)}getMemberType(t,e){return this.node.getMemberType(t,e)}analyze(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}setup(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}generate(t,e){const i=t.addContext(this.value),n=this.node.build(t,e);return t.setContext(i),n}}const G_=(t=null,e={})=>{let i=t;return null!==i&&!0===i.isNode||(e=i||e,i=null),new V_(i,e)},H_=(t,e)=>G_(t,{nodeName:e});Wf("context",G_),Wf("label",function(t,e){return Nm('TSL: "label()" has been deprecated. Use "setName()" instead.'),H_(t,e)}),Wf("uniformFlow",t=>G_(t,{uniformFlow:!0})),Wf("setName",H_),Wf("builtinShadowContext",(t,e,i)=>function(t,e,i=null){return G_(i,{getShadow:({light:i,shadowColorNode:n})=>e===i?n.mul(t):n})}(e,i,t)),Wf("builtinAOContext",(t,e)=>function(t,e=null){return G_(e,{getAO:(e,{material:i})=>!0===i.transparent?e:null!==e?e.mul(t):t})}(e,t));class W_ extends Nf{static get type(){return"VarNode"}constructor(t,e=null,i=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0,this.intent=!1}setIntent(t){return this.intent=t,this}isIntent(t){return!0!==t.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}generateNodeType(t){return this.node.getNodeType(t)}getArrayCount(t){return this.node.getArrayCount(t)}isAssign(t){return t.getDataFromNode(this).assign}build(...t){const e=t[0];if(!1===this._hasStack(e)&&"setup"===e.buildStage&&(e.context.nodeLoop||e.context.nodeBlock)){let t=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&e.fnCall&&e.fnCall.shaderNode){if(e.getDataFromNode(this.node.shaderNode).hasLoop){e.getDataFromNode(this).forceDeclaration=!0,t=!0}}const i=e.getBaseStack();t?i.addToStackBefore(this):i.addToStack(this)}return this.isIntent(e)&&!0!==this.isAssign(e)?this.node.build(...t):super.build(...t)}generate(t){const{node:e,name:i,readOnly:n}=this,{renderer:r}=t,s=!0===r.backend.isWebGPUBackend;let a=!1,o=!1;n&&(a=t.isDeterministic(e),o=s?n:a);const l=this.getNodeType(t);if("void"==l){!0!==this.isIntent(t)&&Im('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return e.build(t)}const h=t.getVectorType(l),c=e.build(t,h),u=t.getVarFromNode(this,i,h,void 0,o),d=t.getPropertyName(u);let p=d;if(o)if(s)p=a?`const ${d}`:`let ${d}`;else{const i=e.getArrayCount(t);p=`const ${t.getVar(u.type,d,i)}`}return t.addLineFlowCode(`${p} = ${c}`,this),d}_hasStack(t){return void 0!==t.getDataFromNode(this).stack}}const j_=bg(W_);Wf("toVar",(t,e=null)=>j_(t,e).toStack()),Wf("toConst",(t,e=null)=>j_(t,e,!0).toStack()),Wf("toVarIntent",t=>j_(t).setIntent(!0).toStack());class X_ extends Nf{static get type(){return"SubBuild"}constructor(t,e,i=null){super(i),this.node=t,this.name=e,this.isSubBuildNode=!0}generateNodeType(t){if(null!==this.nodeType)return this.nodeType;t.addSubBuild(this.name);const e=this.node.getNodeType(t);return t.removeSubBuild(),e}build(t,...e){t.addSubBuild(this.name);const i=this.node.build(t,...e);return t.removeSubBuild(),i}}const q_=(t,e,i=null)=>new X_(yg(t),e,i);class Y_ extends Nf{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=q_(t,"VERTEX"),this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}generateNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let i=e.varying;if(void 0===i){const n=this.name,r=this.getNodeType(t),s=this.interpolationType,a=this.interpolationSampling;e.varying=i=t.getVaryingFromNode(this,n,r,s,a),e.node=q_(this.node,"VERTEX")}return i.needsInterpolation||(i.needsInterpolation="fragment"===t.shaderStage),i}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(hm,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(hm,this.node)}generate(t){const e=t.getSubBuildProperty("property",t.currentStack),i=t.getNodeProperties(this),n=this.setupVarying(t);if(void 0===i[e]){const r=this.getNodeType(t),s=t.getPropertyName(n,hm);t.flowNodeFromShaderStage(hm,i.node,r,s),i[e]=s}return t.getPropertyName(n)}}const Z_=bg(Y_).setParameterLength(1,2);Wf("toVarying",Z_),Wf("toVertexStage",t=>Z_(t));const K_=Eg(([t])=>{const e=t.mul(.9478672986).add(.0521327014).pow(2.4),i=t.mul(.0773993808),n=t.lessThanEqual(.04045);return P_(e,i,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),J_=Eg(([t])=>{const e=t.pow(.41666).mul(1.055).sub(.055),i=t.mul(12.92),n=t.lessThanEqual(.0031308);return P_(e,i,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$_="WorkingColorSpace";class Q_ extends If{static get type(){return"ColorSpaceNode"}constructor(t,e,i){super("vec4"),this.colorNode=t,this.source=e,this.target=i}resolveColorSpace(t,e){return e===$_?Zm.workingColorSpace:"OutputColorSpace"===e?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{colorNode:e}=this,i=this.resolveColorSpace(t,this.source),n=this.resolveColorSpace(t,this.target);let r=e;return!1!==Zm.enabled&&i!==n&&i&&n?(Zm.getTransfer(i)===bm&&(r=Gg(K_(r.rgb),r.a)),Zm.getPrimaries(i)!==Zm.getPrimaries(n)&&(r=Gg(qg(Zm._getMatrix(new Wm,i,n)).mul(r.rgb),r.a)),Zm.getTransfer(n)===bm&&(r=Gg(J_(r.rgb),r.a)),r):r}}const tv=(t,e)=>new Q_(yg(t),e,$_);Wf("workingToColorSpace",(t,e)=>new Q_(yg(t),$_,e)),Wf("colorSpaceToWorking",tv);let ev=class extends Pf{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),i=this.referenceNode.getNodeType(),n=this.getNodeType();return t.format(e,i,n)}};class iv extends Nf{static get type(){return"ReferenceBaseNode"}constructor(t,e,i=null,n=null){super(),this.property=t,this.uniformType=e,this.object=i,this.count=n,this.properties=t.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=pm}setGroup(t){return this.group=t,this}element(t){return new ev(this,yg(t))}setNodeType(t){const e=ny(null,t);null!==this.group&&e.setGroup(this.group),this.node=e}generateNodeType(t){return null===this.node&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let i=t[e[0]];for(let t=1;tnew nv(t,e,i);class sv extends If{static get type(){return"ToneMappingNode"}constructor(t,e=av,i=null){super("vec3"),this._toneMapping=t,this.exposureNode=e,this.colorNode=i}customCacheKey(){return Tf(this._toneMapping)}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup(t){const e=this.colorNode||t.context.color,i=this._toneMapping;if(0===i)return e;let n=null;const r=t.renderer.library.getToneMappingFunction(i);return null!==r?n=Gg(r(e.rgb,this.exposureNode),e.a):(Im("ToneMappingNode: Unsupported Tone Mapping configuration.",i),n=e),n}}const av=rv("toneMappingExposure","float");Wf("toneMapping",(t,e,i)=>((t,e,i)=>new sv(t,yg(e),yg(i)))(e,i,t));const ov=new of,lv=new _f;let hv=0;class cv extends Af{constructor(t,e,i=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:hv++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=Mm,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;nfunction(t,e=null,i=0,n=0,r=35044,s=!1){return"mat3"===e||null===e&&9===t.itemSize?qg(new gv(t,"vec3",9,0).setUsage(r).setInstanced(s),new gv(t,"vec3",9,3).setUsage(r).setInstanced(s),new gv(t,"vec3",9,6).setUsage(r).setInstanced(s)):"mat4"===e||null===e&&16===t.itemSize?Yg(new gv(t,"vec4",16,0).setUsage(r).setInstanced(s),new gv(t,"vec4",16,4).setUsage(r).setInstanced(s),new gv(t,"vec4",16,8).setUsage(r).setInstanced(s),new gv(t,"vec4",16,12).setUsage(r).setInstanced(s)):new gv(t,e,i,n).setUsage(r)}(t,e,i,n);Wf("toAttribute",t=>yv(t.value));class _v extends Nf{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){const e=this.getNodeType(t),i=this.scope;let n,r;if(i===_v.VERTEX)n=t.getVertexIndex();else if(i===_v.INSTANCE)n=t.getInstanceIndex();else if(i===_v.DRAW)n=t.getDrawIndex();else if(i===_v.INVOCATION_LOCAL)n=t.getInvocationLocalIndex();else if(i===_v.INVOCATION_SUBGROUP)n=t.getInvocationSubgroupIndex();else{if(i!==_v.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+i);n=t.getSubgroupIndex()}if("vertex"===t.shaderStage||"compute"===t.shaderStage)r=n;else{r=Z_(this).build(t,e)}return r}}_v.VERTEX="vertex",_v.INSTANCE="instance",_v.SUBGROUP="subgroup",_v.INVOCATION_LOCAL="invocationLocal",_v.INVOCATION_SUBGROUP="invocationSubgroup",_v.DRAW="draw";const vv=Mg(_v,_v.INSTANCE);class xv extends Nf{static get type(){return"ComputeNode"}constructor(t,e){super("void"),this.isComputeNode=!0,this.computeNode=t,this.workgroupSize=e,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=pm,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(t){return this.name=t,this}label(t){return Nm('TSL: "label()" has been deprecated. Use "setName()" instead.',new bf),this.setName(t)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){null!==this.count&&null===this.countNode&&(this.countNode=ny(this.count,"uint").onObjectUpdate(()=>this.count));const e=this.computeNode.build(t);if(e){t.getNodeProperties(this).outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){const{shaderStage:i}=t;if("compute"===i){const e=this.computeNode.build(t,"void");if(""!==e&&t.addLineFlowCode(e,this),null!==this.count&&!0===t.allowEarlyReturns){const e=this.countNode.build(t,"uint"),i=vv.build(t,"uint");t.flow.code=`${t.tab}if ( ${i} >= ${e} ) { return; }\n\n${t.flow.code}`}}else{const i=t.getNodeProperties(this).outputComputeNode;if(i)return i.build(t,e)}}}const bv=(t,e=[64])=>{(0===e.length||e.length>3)&&Im("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new bf);for(let t=0;t{const n=bv(t,i);return"number"==typeof e?n.count=e:n.dispatchSize=e,n}),Wf("computeKernel",bv);class Mv extends Nf{static get type(){return"IsolateNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isIsolateNode=!0}generateNodeType(t){const e=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const n=this.node.getNodeType(t);return t.setCache(e),n}build(t,...e){const i=t.getCache(),n=t.getCacheFromNode(this,this.parent);t.setCache(n);const r=this.node.build(t,...e);return t.setCache(i),r}setParent(t){return this.parent=t,this}getParent(){return this.parent}}const Sv=t=>new Mv(yg(t));Wf("cache",function(t,e=!0){return Nm('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Sv(t).setParent(e)}),Wf("isolate",Sv);class Tv extends Nf{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}generateNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return""!==e&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}Wf("bypass",bg(Tv).setParameterLength(2));const wv=Eg(([t,e,i,n=Ng(0),r=Ng(1),s=Lg(!1)])=>{let a=t.sub(e).div(i.sub(e));var o;return(o=s)&&o.isNode&&o.traverse(t=>{t.isConstNode&&(o=t.value)}),Boolean(o)&&(a=a.clamp()),a.mul(r.sub(n)).add(n)});Wf("remap",wv),Wf("remapClamp",function(t,e,i,n=Ng(0),r=Ng(1)){return wv(t,e,i,n,r,!0)});class Ev extends Nf{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const i=this.getNodeType(t),n=this.snippet;if("void"!==i)return t.format(n,i,e);t.addLineFlowCode(n,this)}}const Av=bg(Ev).setParameterLength(1,2);Wf("discard",t=>(t?B_(t,Av("discard")):Av("discard")).toStack());class Cv extends If{static get type(){return"RenderOutputNode"}constructor(t,e,i){super("vec4"),this.colorNode=t,this._toneMapping=e,this.outputColorSpace=i,this.isRenderOutputNode=!0}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup({context:t}){let e=this.colorNode||t.color;const i=(null!==this._toneMapping?this._toneMapping:t.toneMapping)||0,n=(null!==this.outputColorSpace?this.outputColorSpace:t.outputColorSpace)||"";return 0!==i&&(e=e.toneMapping(i)),""!==n&&n!==Zm.workingColorSpace&&(e=e.workingToColorSpace(n)),e}}Wf("renderOutput",(t,e=null,i=null)=>new Cv(yg(t),e,i));class Rv extends If{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}generateNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){const e=this.callback,i=this.node.build(t);if(null!==e)e(t,i);else{const e="--- TSL debug - "+t.shaderStage+" shader ---",n="-".repeat(e.length);let r="";r+="// #"+e+"#\n",r+=t.flow.code.replace(/^\t/gm,"")+"\n",r+="/* ... */ "+i+" /* ... */\n",r+="// #"+n+"#\n",Cm(r)}return i}}Wf("debug",(t,e=null)=>new Rv(yg(t),e).toStack());class Nv extends Af{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(t){return this._renderer=t,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class Iv extends Nf{static get type(){return"InspectorNode"}constructor(t,e="",i=null){super(),this.node=t,this.name=e,this.callback=i,this.updateType=um,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(t){t.renderer.inspector.inspect(this)}generateNodeType(t){return this.node.getNodeType(t)}setup(t){let e=this.node;return!0===t.context.inspector&&null!==this.callback&&(e=this.callback(e)),!0!==t.renderer.backend.isWebGPUBackend&&t.renderer.inspector.constructor!==Nv&&Pm('TSL: ".toInspector()" is only available with WebGPU.'),e}}Wf("toInspector",function(t,e="",i=null){return(t=yg(t)).before(new Iv(t,e,i))});class Pv extends Nf{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}generateNodeType(t){let e=this.nodeType;if(null===e){const i=this.getAttributeName(t);if(t.hasGeometryAttribute(i)){const n=t.geometry.getAttribute(i);e=t.getTypeFromAttribute(n)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),i=this.getNodeType(t);if(!0===t.hasGeometryAttribute(e)){const n=t.geometry.getAttribute(e),r=t.getTypeFromAttribute(n),s=t.getAttribute(e,r);if("vertex"===t.shaderStage)return t.format(s.name,r,i);return Z_(this).build(t,i)}return Nm(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(i)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const Lv=(t,e=null)=>new Pv(t,e),Dv=(t=0)=>Lv("uv"+(t>0?t:""),"vec2");class Ov extends Nf{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const i=this.textureNode.build(t,"property"),n=null===this.levelNode?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${i}, ${n} )`,this.getNodeType(t),e)}}const Uv=bg(Ov).setParameterLength(1,2);class Fv extends iy{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=um}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,i=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(i&&void 0!==i.width){const{width:t,height:e}=i;this.value=Math.log2(Math.max(t,e))}}}const zv=bg(Fv).setParameterLength(1);let kv;class Bv{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===kv&&(kv=Em("canvas")),kv.width=t.width,kv.height=t.height;const e=kv.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=kv}return i.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=Em("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(jv).x}get height(){return this.source.getSize(jv).y}get depth(){return this.source.getSize(jv).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(void 0===i){Nm(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i:Nm(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case fm:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case fm:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Xv.DEFAULT_IMAGE=null,Xv.DEFAULT_MAPPING=300,Xv.DEFAULT_ANISOTROPY=1;class qv extends Error{constructor(t,e=null){super(t),this.name="NodeError",this.stackTrace=e}}const Yv=new Xv;class Zv extends iy{static get type(){return"TextureNode"}constructor(t=Yv,e=null,i=null,n=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=i,this.biasNode=n,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=cm,this.referenceNode=null,this._value=t,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===e)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?"float":1014===this.value.type?"uvec4":1013===this.value.type?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Dv(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return null===this._matrixUniform&&(this._matrixUniform=ny(this.value.matrix)),this._matrixUniform.mul(zg(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this}setupUV(t,e){return t.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=ny(!1)),e=e.toVar(),e=this.sampler?this._flipYUniform.select(e.flipY(),e):this._flipYUniform.select(e.setY(Ig(Uv(this,this.levelNode).y).sub(e.y).sub(1)),e)),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;const i=this.value;if(!i||!0!==i.isTexture)throw new qv("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const n=Eg(()=>{let e=this.uvNode;return null!==e&&!0!==t.context.forceUVContext||!t.context.getUV||(e=t.context.getUV(this,t)),e||(e=this.getDefaultUV()),!0===this.updateMatrix&&(e=this.getTransformedUV(e)),e=this.setupUV(t,e),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?pm:cm,e})();let r=this.levelNode;null===r&&t.context.getTextureLevel&&(r=t.context.getTextureLevel(this));let s=null,a=null;if(null!==this.compareNode)if(t.renderer.hasCompatibility(wm))s=this.compareNode;else{const t=i.compareFunction;null===t||513===t||515===t||516===t||518===t?a=this.compareNode:(s=this.compareNode,Pm('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}e.uvNode=n,e.levelNode=r,e.biasNode=this.biasNode,e.compareNode=s,e.compareStepNode=a,e.gradNode=this.gradNode,e.depthNode=this.depthNode,e.offsetNode=this.offsetNode}generateUV(t,e){return e.build(t,!0===this.sampler?"vec2":"ivec2")}generateOffset(t,e){return e.build(t,"ivec2")}generateSnippet(t,e,i,n,r,s,a,o,l){const h=this.value;let c;return c=r?t.generateTextureBias(h,e,i,r,s,l):o?t.generateTextureGrad(h,e,i,o,s,l):a?t.generateTextureCompare(h,e,i,a,s,l):!1===this.sampler?t.generateTextureLoad(h,e,i,n,s,l):n?t.generateTextureLevel(h,e,i,n,s,l):t.generateTexture(h,e,i,s,l),c}generate(t,e){const i=this.value,n=t.getNodeProperties(this),r=super.generate(t,"property");if(/^sampler/.test(e))return r+"_sampler";if(t.isReference(e))return r;{const s=t.getDataFromNode(this),a=this.getNodeType(t);let o=s.propertyName;if(void 0===o){const{uvNode:e,levelNode:l,biasNode:h,compareNode:c,compareStepNode:u,depthNode:d,gradNode:p,offsetNode:m}=n,f=this.generateUV(t,e),g=l?l.build(t,"float"):null,y=h?h.build(t,"float"):null,_=d?d.build(t,"int"):null,v=c?c.build(t,"float"):null,x=u?u.build(t,"float"):null,b=p?[p[0].build(t,"vec2"),p[1].build(t,"vec2")]:null,M=m?this.generateOffset(t,m):null;let S=_;null===S&&i.isArrayTexture&&!0!==this.isTexture3DNode&&(S="0");const T=t.getVarFromNode(this);o=t.getPropertyName(T);let w=this.generateSnippet(t,r,f,g,y,S,v,b,M);if(null!==x){const e=i.compareFunction;w=516===e||518===e?T_(Av(w,a),Av(x,"float")).build(t,a):T_(Av(x,"float"),Av(w,a)).build(t,a)}t.addLineFlowCode(`${o} = ${w}`,this),s.snippet=w,s.propertyName=o}let l=o;return t.needsToWorkingColorSpace(i)&&(l=tv(Av(l,a),i.colorSpace).setup(t).build(t,a)),t.format(l,a,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}sample(t){const e=this.clone();return e.uvNode=yg(t),e.referenceNode=this.getBase(),yg(e)}load(t){return this.sample(t).setSampler(!1)}blur(t){const e=this.clone();e.biasNode=yg(t).mul(zv(e)),e.referenceNode=this.getBase();const i=e.value;return!1===e.generateMipmaps&&(i&&!1===i.generateMipmaps||i.minFilter===gm||i.magFilter===gm)&&(Nm("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),e.biasNode=null),yg(e)}level(t){const e=this.clone();return e.levelNode=yg(t),e.referenceNode=this.getBase(),yg(e)}size(t){return Uv(this,t)}bias(t){const e=this.clone();return e.biasNode=yg(t),e.referenceNode=this.getBase(),yg(e)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(t){const e=this.clone();return e.compareNode=yg(t),e.referenceNode=this.getBase(),yg(e)}grad(t,e){const i=this.clone();return i.gradNode=[yg(t),yg(e)],i.referenceNode=this.getBase(),yg(i)}depth(t){const e=this.clone();return e.depthNode=yg(t),e.referenceNode=this.getBase(),yg(e)}offset(t){const e=this.clone();return e.offsetNode=yg(t),e.referenceNode=this.getBase(),yg(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;null!==e&&(e.value=t.matrix),!0===t.matrixAutoUpdate&&t.updateMatrix();const i=this._flipYUniform;null!==i&&(i.value=t.image instanceof ImageBitmap&&!0===t.flipY||!0===t.isRenderTargetTexture||!0===t.isFramebufferTexture||!0===t.isDepthTexture)}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}const Kv=bg(Zv).setParameterLength(1,4).setName("texture");class Jv extends iy{static get type(){return"BufferNode"}constructor(t,e,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=i,this.updateRanges=[]}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}class $v extends Pf{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),i=this.getNodeType(t),n=this.node.getPaddedType();return t.format(e,n,i)}}class Qv extends Jv{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null),this.array=t,this.elementType=null===e?wf(t[0]):e,this.paddedType=this.getPaddedType(),this.updateType=dm,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const t=this.elementType;let e="vec4";return"mat2"===t?e="mat2":!0===/mat/.test(t)?e="mat4":"i"===t.charAt(0)?e="ivec4":"u"===t.charAt(0)&&(e="uvec4"),e}update(){const{array:t,value:e}=this,i=this.elementType;if("float"===i||"int"===i||"uint"===i)for(let i=0;inew Qv(t,e);const ex=bg(class extends Nf{constructor(t){super("float"),this.name=t,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1);let ix,nx;class rx extends Nf{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===rx.DPR?"float":this.scope===rx.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=cm;return this.scope!==rx.SIZE&&this.scope!==rx.VIEWPORT&&this.scope!==rx.DPR||(t=dm),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===rx.VIEWPORT?null!==e?nx.copy(e.viewport):(t.getViewport(nx),nx.multiplyScalar(t.getPixelRatio())):this.scope===rx.DPR?this._output.value=t.getPixelRatio():null!==e?(ix.width=e.width,ix.height=e.height):t.getDrawingBufferSize(ix)}setup(){const t=this.scope;let e=null;return e=t===rx.SIZE?ny(ix||(ix=new _f)):t===rx.VIEWPORT?ny(nx||(nx=new vf)):t===rx.DPR?ny(1):Dg(ox.div(ax)),this._output=e,e}generate(t){if(this.scope===rx.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const i=t.getNodeProperties(ax).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${i}.y - ${e}.y )`}return e}return super.generate(t)}}rx.COORDINATE="coordinate",rx.VIEWPORT="viewport",rx.SIZE="size",rx.UV="uv",rx.DPR="dpr";const sx=Mg(rx,rx.UV),ax=Mg(rx,rx.SIZE),ox=Mg(rx,rx.COORDINATE);let lx=null,hx=null,cx=null,ux=null;const dx=ny(0,"uint").setName("u_cameraIndex").setGroup(Qg("cameraIndex")).toVarying("v_cameraIndex"),px=ny("float").setName("cameraNear").setGroup(ty).onRenderUpdate(({camera:t})=>t.near),mx=ny("float").setName("cameraFar").setGroup(ty).onRenderUpdate(({camera:t})=>t.far),fx=Eg(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const i=[];for(const e of t.cameras)i.push(e.projectionMatrixInverse);null===hx?hx=tx(i).setGroup(ty).setName("cameraProjectionMatricesInverse"):hx.array=i,e=hx.element(t.isMultiViewCamera?ex("gl_ViewID_OVR"):dx).toConst("cameraProjectionMatrixInverse")}else null===lx&&(lx=ny(t.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(ty).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=lx;return e}).once()(),gx=Eg(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const i=[];for(const e of t.cameras)i.push(e.matrixWorldInverse);null===ux?ux=tx(i).setGroup(ty).setName("cameraViewMatrices"):ux.array=i,e=ux.element(t.isMultiViewCamera?ex("gl_ViewID_OVR"):dx).toConst("cameraViewMatrix")}else null===cx&&(cx=ny(t.matrixWorldInverse).setName("cameraViewMatrix").setGroup(ty).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=cx;return e}).once()();class yx{constructor(t=new of(1/0,1/0,1/0),e=new of(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,vx),vx.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ax),Cx.subVectors(this.max,Ax),bx.subVectors(t.a,Ax),Mx.subVectors(t.b,Ax),Sx.subVectors(t.c,Ax),Tx.subVectors(Mx,bx),wx.subVectors(Sx,Mx),Ex.subVectors(bx,Sx);let e=[0,-Tx.z,Tx.y,0,-wx.z,wx.y,0,-Ex.z,Ex.y,Tx.z,0,-Tx.x,wx.z,0,-wx.x,Ex.z,0,-Ex.x,-Tx.y,Tx.x,0,-wx.y,wx.x,0,-Ex.y,Ex.x,0];return!!Ix(e,bx,Mx,Sx,Cx)&&(e=[1,0,0,0,1,0,0,0,1],!!Ix(e,bx,Mx,Sx,Cx)&&(Rx.crossVectors(Tx,wx),e=[Rx.x,Rx.y,Rx.z],Ix(e,bx,Mx,Sx,Cx)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,vx).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(vx).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(_x[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_x[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_x[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_x[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_x[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_x[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_x[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_x[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_x)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const _x=[new of,new of,new of,new of,new of,new of,new of,new of],vx=new of,xx=new yx,bx=new of,Mx=new of,Sx=new of,Tx=new of,wx=new of,Ex=new of,Ax=new of,Cx=new of,Rx=new of,Nx=new of;function Ix(t,e,i,n,r){for(let s=0,a=t.length-3;s<=a;s+=3){Nx.fromArray(t,s);const a=r.x*Math.abs(Nx.x)+r.y*Math.abs(Nx.y)+r.z*Math.abs(Nx.z),o=e.dot(Nx),l=i.dot(Nx),h=n.dot(Nx);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Px=new yx,Lx=new of,Dx=new of;class Ox{constructor(t=new of,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Px.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Lx.subVectors(t,this.center);const e=Lx.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Lx,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Dx.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Lx.copy(t.center).add(Dx)),this.expandByPoint(Lx.copy(t.center).sub(Dx))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Ux=new Ox;class Fx extends Nf{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=pm,this.uniformNode=new iy(null)}generateNodeType(){const t=this.scope;return t===Fx.WORLD_MATRIX?"mat4":t===Fx.POSITION||t===Fx.VIEW_POSITION||t===Fx.DIRECTION||t===Fx.SCALE?"vec3":t===Fx.RADIUS?"float":void 0}update(t){const e=this.object3d,i=this.uniformNode,n=this.scope;if(n===Fx.WORLD_MATRIX)i.value=e.matrixWorld;else if(n===Fx.POSITION)i.value=i.value||new of,i.value.setFromMatrixPosition(e.matrixWorld);else if(n===Fx.SCALE)i.value=i.value||new of,i.value.setFromMatrixScale(e.matrixWorld);else if(n===Fx.DIRECTION)i.value=i.value||new of,e.getWorldDirection(i.value);else if(n===Fx.VIEW_POSITION){const n=t.camera;i.value=i.value||new of,i.value.setFromMatrixPosition(e.matrixWorld),i.value.applyMatrix4(n.matrixWorldInverse)}else if(n===Fx.RADIUS){const n=t.object.geometry;null===n.boundingSphere&&n.computeBoundingSphere(),Ux.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),i.value=Ux.radius}}generate(t){const e=this.scope;return e===Fx.WORLD_MATRIX?this.uniformNode.nodeType="mat4":e===Fx.POSITION||e===Fx.VIEW_POSITION||e===Fx.DIRECTION||e===Fx.SCALE?this.uniformNode.nodeType="vec3":e===Fx.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}Fx.WORLD_MATRIX="worldMatrix",Fx.POSITION="position",Fx.SCALE="scale",Fx.VIEW_POSITION="viewPosition",Fx.DIRECTION="direction",Fx.RADIUS="radius";class zx extends Fx{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}const kx=Mg(zx,zx.WORLD_MATRIX),Bx=ny(new Wm).onObjectUpdate(({object:t},e)=>e.value.getNormalMatrix(t.matrixWorld)),Vx=Eg(t=>t.context.modelViewMatrix||Gx).once()().toVar("modelViewMatrix"),Gx=gx.mul(kx),Hx=Eg(t=>"fragment"!==t.shaderStage?(Pm("TSL: `clipSpace` is only available in fragment stage."),Gg()):t.context.clipSpace.toVarying("v_clipSpace")).once()(),Wx=Eg(t=>{if("fragment"===t.shaderStage&&t.material.vertexNode){const t=fx.mul(Hx);return t.xyz.div(t.w).toVar("positionView")}return t.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),jx=Eg(t=>{let e;return e=t.camera.isOrthographicCamera?zg(0,0,1):Wx.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class Xx extends Nf{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){if("fragment"!==t.shaderStage)return"true";const{material:e}=t;return 1===e.side?"false":t.getFrontFacing()}}const qx=Ng(Mg(Xx)).mul(2).sub(1),Yx=Eg(([t],{material:e})=>{const i=e.side;return 1===i?t=t.mul(-1):2===i&&(t=t.mul(qx)),t}),Zx=Lv("normal","vec3"),Kx=Eg(t=>!1===t.geometry.hasAttribute("normal")?(Nm('TSL: Vertex attribute "normal" not found on geometry.'),zg(0,1,0)):Zx,"vec3").once()().toVar("normalLocal"),Jx=Wx.dFdx().cross(Wx.dFdy()).normalize().toVar("normalFlat"),$x=Eg(t=>{let e;return e=t.isFlatShading()?Jx:ib(Kx).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),Qx=Eg(t=>{let e;return"NORMAL"===t.subBuildFn||"VERTEX"===t.subBuildFn?(e=$x,!0!==t.isFlatShading()&&(e=Yx(e))):e=t.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),tb=Qx.transformDirection(gx).toVar("normalWorld"),eb=Eg(({subBuildFn:t,context:e})=>{let i;return i="NORMAL"===t||"VERTEX"===t?Qx:e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),ib=Eg(([t],e)=>{const i=e.context.modelNormalViewMatrix;if(i)return i.transformDirection(t);const n=Bx.mul(t);return gx.transformDirection(n)});Eg(()=>(Nm('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Qx)).once(["NORMAL","VERTEX"])(),Eg(()=>(Nm('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),tb)).once(["NORMAL","VERTEX"])(),Eg(()=>(Nm('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),eb)).once(["NORMAL","VERTEX"])();const nb=new cf,rb=ny(0).onReference(({material:t})=>t).onObjectUpdate(({material:t})=>t.refractionRatio),sb=ny(new cf).onReference(function(t){return t.material}).onObjectUpdate(function({material:t,scene:e}){const i=null!==e.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation;return i?nb.makeRotationFromEuler(i).transpose():nb.identity(),nb}),ab=jx.negate().reflect(Qx),ob=jx.negate().refract(Qx,rb),lb=ab.transformDirection(gx).toVar("reflectVector"),hb=ob.transformDirection(gx).toVar("reflectVector");class cb extends Xv{constructor(t=[],e=301,i,n,r,s,a,o,l,h){super(t,e,i,n,r,s,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}const ub=new cb;class db extends Zv{static get type(){return"CubeTextureNode"}constructor(t,e=null,i=null,n=null){super(t,e,i,n),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const t=this.value;return 301===t.mapping?lb:302===t.mapping?hb:(Im('CubeTextureNode: Mapping "%s" not supported.',t.mapping),zg(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const i=this.value;return!0===i.isDepthTexture?t.renderer.coordinateSystem===Tm?zg(e.x,e.y.negate(),e.z):e:(e=sb.mul(e),t.renderer.coordinateSystem!==Tm&&i.isRenderTargetTexture||(e=zg(e.x.negate(),e.yz)),e)}generateUV(t,e){return e.build(t,!0===this.sampler?"vec3":"ivec3")}}const pb=bg(db).setParameterLength(1,4).setName("cubeTexture");class mb extends Pf{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),i=this.referenceNode.getNodeType(t),n=this.getNodeType(t);return t.format(e,i,n)}}class fb extends Nf{static get type(){return"ReferenceNode"}constructor(t,e,i=null,n=null){super(),this.property=t,this.uniformType=e,this.object=i,this.count=n,this.properties=t.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=pm}element(t){return new mb(this,yg(t))}setGroup(t){return this.group=t,this}setName(t){return this.name=t,this}label(t){return Nm('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(t)}setNodeType(t){let e=null;var i,n,r;null!==this.count?(i=null,n=t,r=this.count,e=new Jv(i,n,r)):e=Array.isArray(this.getValueFromReference())?tx(null,t):"texture"===t?((t=Yv,e=null,i=null,n=null)=>{let r;return t&&!0===t.isTextureNode?(r=yg(t.clone()),r.referenceNode=t.getBase(),null!==e&&(r.uvNode=yg(e)),null!==i&&(r.levelNode=yg(i)),null!==n&&(r.biasNode=yg(n))):r=Kv(t,e,i,n),r})(null):"cubeTexture"===t?((t=ub,e=null,i=null,n=null)=>{let r;return t&&!0===t.isCubeTextureNode?(r=yg(t.clone()),r.referenceNode=t,null!==e&&(r.uvNode=yg(e)),null!==i&&(r.levelNode=yg(i)),null!==n&&(r.biasNode=yg(n))):r=pb(t,e,i,n),r})(null):ny(null,t),null!==this.group&&e.setGroup(this.group),null!==this.name&&e.setName(this.name),this.node=e}generateNodeType(t){return null===this.node&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let i=t[e[0]];for(let t=1;tnew fb(t,e,i);class yb extends fb{static get type(){return"MaterialReferenceNode"}constructor(t,e,i=null){super(t,e,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=null!==this.material?this.material:t.material,this.reference}}const _b=Dv(),vb=Wx.dFdx(),xb=Wx.dFdy(),bb=_b.dFdx(),Mb=_b.dFdy(),Sb=Qx,Tb=xb.cross(Sb),wb=Sb.cross(vb),Eb=Tb.mul(bb.x).add(wb.mul(Mb.x)),Ab=Tb.mul(bb.y).add(wb.mul(Mb.y)),Cb=Eb.dot(Eb).max(Ab.dot(Ab)),Rb=Cb.equal(0).select(0,Cb.inverseSqrt()),Nb=Eb.mul(Rb).toVar("tangentViewFrame"),Ib=Ab.mul(Rb).toVar("bitangentViewFrame"),Pb=Lv("tangent","vec4"),Lb=Pb.xyz.toVar("tangentLocal"),Db=Eg(t=>{let e;return e="VERTEX"===t.subBuildFn||t.geometry.hasAttribute("tangent")?Vx.mul(Gg(Lb,0)).xyz.toVarying("v_tangentView").normalize():Nb,!0!==t.isFlatShading()&&(e=Yx(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),Ob=Eg(([t,e],i)=>{let n=t.mul(Pb.w).xyz;return"NORMAL"===i.subBuildFn&&!0!==i.isFlatShading()&&(n=n.toVarying(e)),n}).once(["NORMAL"]),Ub=qg(Db,Eg(t=>{let e;return e="VERTEX"===t.subBuildFn||t.geometry.hasAttribute("tangent")?Ob(Qx.cross(Db),"v_bitangentView").normalize():Ib,!0!==t.isFlatShading()&&(e=Yx(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Qx).toVar("TBNViewMatrix"),Fb=t=>zg(t,Wy(D_(Ng(1).sub(C_(t,t)))));class zb extends If{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=0,this.unpackNormalMode=""}setup(t){const{normalMapType:e,scaleNode:i,unpackNormalMode:n}=this;let r=this.node.mul(2).sub(1);if(0===e?"rg"===n?r=Fb(r.xy):"ga"===n?r=Fb(r.yw):""!==n&&Im(`THREE.NodeMaterial: Unexpected unpack normal mode: ${n}`):""!==n&&Im(`THREE.NodeMaterial: Normal map type '${e}' is not compatible with unpack normal mode '${n}'`),null!==i){let e=i;!0===t.isFlatShading()&&(e=Yx(e)),r=zg(r.xy.mul(e),r.z)}let s=null;return 1===e?s=ib(r):0===e?s=Ub.mul(r).normalize():(Im(`NodeMaterial: Unsupported normal map type: ${e}`),s=Qx),s}}const kb=bg(zb).setParameterLength(1,2),Bb=Eg(({textureNode:t,bumpScale:e})=>{const i=e=>t.isolate().context({getUV:t=>e(t.uvNode||Dv()),forceUVContext:!0}),n=Ng(i(t=>t));return Dg(Ng(i(t=>t.add(t.dFdx()))).sub(n),Ng(i(t=>t.add(t.dFdy()))).sub(n)).mul(e)}),Vb=Eg(t=>{const{surf_pos:e,surf_norm:i,dHdxy:n}=t,r=e.dFdx().normalize(),s=i,a=e.dFdy().normalize().cross(s),o=s.cross(r),l=r.dot(a).mul(qx),h=l.sign().mul(n.x.mul(a).add(n.y.mul(o)));return l.abs().mul(i).sub(h).normalize()});class Gb extends If{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=null!==this.scaleNode?this.scaleNode:1,e=Bb({textureNode:this.textureNode,bumpScale:t});return Vb({surf_pos:Wx,surf_norm:Qx,dHdxy:e})}}const Hb=bg(Gb).setParameterLength(1,2),Wb=new Map;class jb extends Nf{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let i=Wb.get(t);return void 0===i&&(i=((t,e,i=null)=>new yb(t,e,i))(t,e),Wb.set(t,i)),i}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache("map"===t?"map":t+"Map","texture")}setup(t){const e=t.context.material,i=this.scope;let n=null;if(i===jb.COLOR){const t=void 0!==e.color?this.getColor(i):zg();n=e.map&&!0===e.map.isTexture?t.mul(this.getTexture("map")):t}else if(i===jb.OPACITY){const t=this.getFloat(i);n=e.alphaMap&&!0===e.alphaMap.isTexture?t.mul(this.getTexture("alpha")):t}else if(i===jb.SPECULAR_STRENGTH)n=e.specularMap&&!0===e.specularMap.isTexture?this.getTexture("specular").r:Ng(1);else if(i===jb.SPECULAR_INTENSITY){const t=this.getFloat(i);n=e.specularIntensityMap&&!0===e.specularIntensityMap.isTexture?t.mul(this.getTexture(i).a):t}else if(i===jb.SPECULAR_COLOR){const t=this.getColor(i);n=e.specularColorMap&&!0===e.specularColorMap.isTexture?t.mul(this.getTexture(i).rgb):t}else if(i===jb.ROUGHNESS){const t=this.getFloat(i);n=e.roughnessMap&&!0===e.roughnessMap.isTexture?t.mul(this.getTexture(i).g):t}else if(i===jb.METALNESS){const t=this.getFloat(i);n=e.metalnessMap&&!0===e.metalnessMap.isTexture?t.mul(this.getTexture(i).b):t}else if(i===jb.EMISSIVE){const t=this.getFloat("emissiveIntensity"),r=this.getColor(i).mul(t);n=e.emissiveMap&&!0===e.emissiveMap.isTexture?r.mul(this.getTexture(i)):r}else if(i===jb.NORMAL)e.normalMap?(n=kb(this.getTexture("normal"),this.getCache("normalScale","vec2")),n.normalMapType=e.normalMapType,1030!=e.normalMap.format&&36285!=e.normalMap.format&&37490!=e.normalMap.format||(n.unpackNormalMode="rg")):n=e.bumpMap?Hb(this.getTexture("bump").r,this.getFloat("bumpScale")):Qx;else if(i===jb.CLEARCOAT){const t=this.getFloat(i);n=e.clearcoatMap&&!0===e.clearcoatMap.isTexture?t.mul(this.getTexture(i).r):t}else if(i===jb.CLEARCOAT_ROUGHNESS){const t=this.getFloat(i);n=e.clearcoatRoughnessMap&&!0===e.clearcoatRoughnessMap.isTexture?t.mul(this.getTexture(i).r):t}else if(i===jb.CLEARCOAT_NORMAL)n=e.clearcoatNormalMap?kb(this.getTexture(i),this.getCache(i+"Scale","vec2")):Qx;else if(i===jb.SHEEN){const t=this.getColor("sheenColor").mul(this.getFloat("sheen"));n=e.sheenColorMap&&!0===e.sheenColorMap.isTexture?t.mul(this.getTexture("sheenColor").rgb):t}else if(i===jb.SHEEN_ROUGHNESS){const t=this.getFloat(i);n=e.sheenRoughnessMap&&!0===e.sheenRoughnessMap.isTexture?t.mul(this.getTexture(i).a):t,n=n.clamp(1e-4,1)}else if(i===jb.ANISOTROPY)if(e.anisotropyMap&&!0===e.anisotropyMap.isTexture){const t=this.getTexture(i);n=Xg(Xb.x,Xb.y,Xb.y.negate(),Xb.x).mul(t.rg.mul(2).sub(Dg(1)).normalize().mul(t.b))}else n=Xb;else if(i===jb.IRIDESCENCE_THICKNESS){const t=gb("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const r=gb("0","float",e.iridescenceThicknessRange);n=t.sub(r).mul(this.getTexture(i).g).add(r)}else n=t}else if(i===jb.TRANSMISSION){const t=this.getFloat(i);n=e.transmissionMap?t.mul(this.getTexture(i).r):t}else if(i===jb.THICKNESS){const t=this.getFloat(i);n=e.thicknessMap?t.mul(this.getTexture(i).g):t}else if(i===jb.IOR)n=this.getFloat(i);else if(i===jb.LIGHT_MAP)n=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===jb.AO)n=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(i===jb.LINE_DASH_OFFSET)n=e.dashOffset?this.getFloat(i):Ng(0);else{const e=this.getNodeType(t);n=this.getCache(i,e)}return n}}jb.ALPHA_TEST="alphaTest",jb.COLOR="color",jb.OPACITY="opacity",jb.SHININESS="shininess",jb.SPECULAR="specular",jb.SPECULAR_STRENGTH="specularStrength",jb.SPECULAR_INTENSITY="specularIntensity",jb.SPECULAR_COLOR="specularColor",jb.REFLECTIVITY="reflectivity",jb.ROUGHNESS="roughness",jb.METALNESS="metalness",jb.NORMAL="normal",jb.CLEARCOAT="clearcoat",jb.CLEARCOAT_ROUGHNESS="clearcoatRoughness",jb.CLEARCOAT_NORMAL="clearcoatNormal",jb.EMISSIVE="emissive",jb.ROTATION="rotation",jb.SHEEN="sheen",jb.SHEEN_ROUGHNESS="sheenRoughness",jb.ANISOTROPY="anisotropy",jb.IRIDESCENCE="iridescence",jb.IRIDESCENCE_IOR="iridescenceIOR",jb.IRIDESCENCE_THICKNESS="iridescenceThickness",jb.IOR="ior",jb.TRANSMISSION="transmission",jb.THICKNESS="thickness",jb.ATTENUATION_DISTANCE="attenuationDistance",jb.ATTENUATION_COLOR="attenuationColor",jb.LINE_SCALE="scale",jb.LINE_DASH_SIZE="dashSize",jb.LINE_GAP_SIZE="gapSize",jb.LINE_WIDTH="linewidth",jb.LINE_DASH_OFFSET="dashOffset",jb.POINT_SIZE="size",jb.DISPERSION="dispersion",jb.LIGHT_MAP="light",jb.AO="ao";const Xb=ny(new _f).onReference(function(t){return t.material}).onRenderUpdate(function({material:t}){this.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation))});class qb extends Nf{static get type(){return"LoopNode"}constructor(t=[]){super("void"),this.params=t}getVarName(t){return String.fromCharCode("i".charCodeAt(0)+t)}getProperties(t){const e=t.getNodeProperties(this);if(void 0!==e.stackNode)return e;const i={};for(let t=0,e=this.params.length-1;tNumber(l)?">=":"<")),a)s=`while ( ${l} )`;else{const i={start:o,end:l},n=i.start,r=i.end;let a;const p=()=>u.includes("<")?"+=":"-=";if(null!=d)switch(typeof d){case"function":a=t.flowStagesNode(e.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=h+" "+p()+" "+t.generateConst(c,d);break;case"string":a=h+" "+d;break;default:d.isNode?a=h+" "+p()+" "+d.build(t):(Im("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),a="break /* invalid update */")}else d="int"===c||"uint"===c?u.includes("<")?"++":"--":p()+" 1.",a=h+" "+d;s=`for ( ${t.getVar(c,h)+" = "+n}; ${h+" "+u+" "+r}; ${a} )`}t.addFlowCode((0===n?"\n":"")+t.tab+s+" {\n\n").addFlowTab()}const r=n.build(t,"void");e.returnsNode.build(t,"void"),t.removeFlowTab().addFlowCode("\n"+t.tab+r);for(let e=0,i=this.params.length-1;enew qb(xg(t,"int")).toStack();class Zb extends Xv{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gm,this.minFilter=gm,this.generateMipmaps=!1,this.needsUpdate=!0}}const Kb=new _f;class Jb extends Zv{static get type(){return"ViewportTextureNode"}constructor(t=sx,e=null,i=null){let n=null;null===i?(n=new Zb,n.minFilter=1008,i=n):n=i,super(i,t,e),this.generateMipmaps=!1,this.defaultFramebuffer=n,this.isOutputTextureNode=!0,this.updateBeforeType=dm,this._cacheTextures=new WeakMap}getTextureForReference(t=null){let e,i;if(this.referenceNode?(e=this.referenceNode.defaultFramebuffer,i=this.referenceNode._cacheTextures):(e=this.defaultFramebuffer,i=this._cacheTextures),null===t)return e;if(!1===i.has(t)){const n=e.clone();i.set(t,n)}return i.get(t)}updateReference(t){const e=t.renderer,i=e.getRenderTarget(),n=e.getCanvasTarget(),r=i||n;return this.value=this.getTextureForReference(r),this.value}updateBefore(t){const e=t.renderer,i=e.getRenderTarget(),n=e.getCanvasTarget(),r=i||n;null===r?e.getDrawingBufferSize(Kb):r.getDrawingBufferSize?r.getDrawingBufferSize(Kb):Kb.set(r.width,r.height);const s=this.getTextureForReference(r);s.image.width===Kb.width&&s.image.height===Kb.height||(s.image.width=Kb.width,s.image.height=Kb.height,s.needsUpdate=!0);const a=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(s),s.generateMipmaps=a}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}class $b extends Xv{constructor(t,e,i=1014,n,r,s,a=1003,o=1003,l,h=1026,c=1){if(1026!==h&&1027!==h)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},n,r,s,a,o,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Gv(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}let Qb=null;class tM extends Jb{static get type(){return"ViewportDepthTextureNode"}constructor(t=sx,e=null,i=null){null===i&&(null===Qb&&(Qb=new $b),i=Qb),super(t,e,i)}}const eM=bg(tM).setParameterLength(0,3);class iM extends Nf{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===iM.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,i=this.valueNode;let n=null;if(e===iM.DEPTH_BASE)null!==i&&(n=aM().assign(i));else if(e===iM.DEPTH)n=t.isPerspectiveCamera?rM(Wx.z,px,mx):nM(Wx.z,px,mx);else if(e===iM.LINEAR_DEPTH)if(null!==i)if(t.isPerspectiveCamera){const t=sM(i,px,mx);n=nM(t,px,mx)}else n=i;else n=nM(Wx.z,px,mx);return n}}iM.DEPTH_BASE="depthBase",iM.DEPTH="depth",iM.LINEAR_DEPTH="linearDepth";const nM=(t,e,i)=>t.add(e).div(e.sub(i)),rM=(t,e,i)=>e.add(t).mul(i).div(i.sub(e).mul(t)),sM=Eg(([t,e,i],n)=>!0===n.renderer.reversedDepthBuffer?e.mul(i).div(e.sub(i).mul(t).sub(e)):e.mul(i).div(i.sub(e).mul(t).sub(i))),aM=bg(iM,iM.DEPTH_BASE),oM=Mg(iM,iM.DEPTH);eM(),oM.assign=t=>aM(t);class lM extends Nf{static get type(){return"ClippingNode"}constructor(t=lM.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{intersectionPlanes:i,unionPlanes:n}=e;return this.hardwareClipping=t.material.hardwareClipping,this.scope===lM.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,n):this.scope===lM.HARDWARE?this.setupHardwareClipping(n,t):this.setupDefault(i,n)}setupAlphaToCoverage(t,e){return Eg(()=>{const i=Ng().toVar("distanceToPlane"),n=Ng().toVar("distanceToGradient"),r=Ng(1).toVar("clipOpacity"),s=e.length;if(!1===this.hardwareClipping&&s>0){const t=tx(e).setGroup(ty);Yb(s,({i:e})=>{const s=t.element(e);i.assign(Wx.dot(s.xyz).negate().add(s.w)),n.assign(i.fwidth().div(2)),r.mulAssign(U_(n.negate(),n,i))})}const a=t.length;if(a>0){const e=tx(t).setGroup(ty),s=Ng(1).toVar("intersectionClipOpacity");Yb(a,({i:t})=>{const r=e.element(t);i.assign(Wx.dot(r.xyz).negate().add(r.w)),n.assign(i.fwidth().div(2)),s.mulAssign(U_(n.negate(),n,i).oneMinus())}),r.mulAssign(s.oneMinus())}sy.a.mulAssign(r),sy.a.equal(0).discard()})()}setupDefault(t,e){return Eg(()=>{const i=e.length;if(!1===this.hardwareClipping&&i>0){const t=tx(e).setGroup(ty);Yb(i,({i:e})=>{const i=t.element(e);Wx.dot(i.xyz).greaterThan(i.w).discard()})}const n=t.length;if(n>0){const e=tx(t).setGroup(ty),i=Lg(!0).toVar("clipped");Yb(n,({i:t})=>{const n=e.element(t);i.assign(Wx.dot(n.xyz).greaterThan(n.w).and(i))}),i.discard()}})()}setupHardwareClipping(t,e){const i=t.length;return e.enableHardwareClipping(i),Eg(()=>{const n=tx(t).setGroup(ty),r=ex(e.getClipDistance());Yb(i,({i:t})=>{const e=n.element(t),i=Wx.dot(e.xyz).sub(e.w).negate();r.element(t).assign(i)})})()}}lM.ALPHA_TO_COVERAGE="alphaToCoverage",lM.DEFAULT="default",lM.HARDWARE="hardware";class hM extends Af{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ym,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new vf(0,0,t,e),this.scissorTest=!1,this.viewport=new vf(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},r=new Xv(n),s=i.count;for(let t=0;t1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e{const i=1e-4,n=zg().toVar();return Ag(e.x.lessThan(i),()=>{n.assign(zg(1,0,0))}).ElseIf(e.y.lessThan(i),()=>{n.assign(zg(0,1,0))}).ElseIf(e.z.lessThan(i),()=>{n.assign(zg(0,0,1))}).ElseIf(e.x.greaterThan(.9999),()=>{n.assign(zg(-1,0,0))}).ElseIf(e.y.greaterThan(.9999),()=>{n.assign(zg(0,-1,0))}).ElseIf(e.z.greaterThan(.9999),()=>{n.assign(zg(0,0,-1))}).Else(()=>{const i=.01,r=t.sample(e.add(zg(-.01,0,0))).r.sub(t.sample(e.add(zg(i,0,0))).r),s=t.sample(e.add(zg(0,-.01,0))).r.sub(t.sample(e.add(zg(0,i,0))).r),a=t.sample(e.add(zg(0,0,-.01))).r.sub(t.sample(e.add(zg(0,0,i))).r);n.assign(zg(r,s,a))}),n.normalize()});const cM=new _f;class uM extends Zv{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(t){return t.getNodeProperties(this).passNode=this.passNode,super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class dM extends uM{static get type(){return"PassMultipleTextureNode"}constructor(t,e,i=!1){super(t,null),this.textureName=e,this.previousTexture=i,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){const t=new this.constructor(this.passNode,this.textureName,this.previousTexture);return t.uvNode=this.uvNode,t.levelNode=this.levelNode,t.biasNode=this.biasNode,t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}class pM extends If{static get type(){return"PassNode"}constructor(t,e,i,n={}){super("vec4"),this.scope=t,this.scene=e,this.camera=i,this.options=n,this._pixelRatio=1,this._width=1,this._height=1;const r=new $b;r.isRenderTargetTexture=!0,r.name="depth";const s=new hM(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:1016,...n});s.texture.name="output",s.depthTexture=r,this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=ny(0),this._cameraFar=ny(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=um,this.global=!0}setResolutionScale(t){return this._resolutionScale=t,this}getResolutionScale(){return this._resolutionScale}setResolution(t){return Nm("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(t)}getResolution(){return Nm("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let e=this._textures[t];if(void 0===e){e=this.renderTarget.texture.clone(),e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)}return e}getPreviousTexture(t){let e=this._previousTextures[t];return void 0===e&&(e=this.getTexture(t).clone(),this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(void 0!==e){const i=this._textures[t],n=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[n]=e,this._textures[t]=e,this._previousTextures[t]=i,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return void 0===e&&(e=new dM(this,t),e.updateTexture(),this._textureNodes[t]=e),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return void 0===e&&(void 0===this._textureNodes[t]&&this.getTextureNode(t),e=new dM(this,t,!0),e.updateTexture(),this._previousTextureNodes[t]=e),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(void 0===e){const i=this._cameraNear,n=this._cameraFar;this._viewZNodes[t]=e=sM(this.getTextureNode(t),i,n)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(void 0===e){const i=this._cameraNear,n=this._cameraFar,r=this.getViewZNode(t);this._linearDepthNodes[t]=e=nM(r,i,n)}return e}async compileAsync(t){const e=t.getRenderTarget(),i=t.getMRT();t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),await t.compileAsync(this.scene,this.camera),t.setRenderTarget(e),t.setMRT(i)}setup({renderer:t}){return this.renderTarget.samples=void 0===this.options.samples?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),!0===t.reversedDepthBuffer&&(this.renderTarget.depthTexture.type=1015),this.scope===pM.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:i}=this;let n,r;const s=e.getOutputRenderTarget();s&&!0===s.isXRRenderTarget?(r=1,n=e.xr.getCamera(),e.xr.updateCamera(n),cM.set(s.width,s.height)):(n=this.camera,r=e.getPixelRatio(),e.getSize(cM)),this._pixelRatio=r,this.setSize(cM.width,cM.height);const a=e.getRenderTarget(),o=e.getMRT(),l=e.autoClear,h=e.transparent,c=e.opaque,u=n.layers.mask,d=e.contextNode,p=i.overrideMaterial;this._cameraNear.value=n.near,this._cameraFar.value=n.far,null!==this._layers&&(n.layers.mask=this._layers.mask);for(const t in this._previousTextures)this.toggleTexture(t);null!==this.overrideMaterial&&(i.overrideMaterial=this.overrideMaterial),e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.autoClear=!0,e.transparent=this.transparent,e.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:G_({...e.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),e.contextNode=this._contextNodeCache.context);const m=i.name;i.name=this.name?this.name:i.name,e.render(i,n),i.name=m,i.overrideMaterial=p,e.setRenderTarget(a),e.setMRT(o),e.autoClear=l,e.transparent=h,e.opaque=c,e.contextNode=d,n.layers.mask=u}setSize(t,e){this._width=t,this._height=e;const i=Math.floor(this._width*this._pixelRatio*this._resolutionScale),n=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(i,n),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._pixelRatio*this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._pixelRatio*this._resolutionScale).floor()}setScissor(t,e,i,n){null===t?this._scissor=null:(null===this._scissor&&(this._scissor=new vf),t.isVector4?this._scissor.copy(t):this._scissor.set(t,e,i,n))}setViewport(t,e,i,n){null===t?this._viewport=null:(null===this._viewport&&(this._viewport=new vf),t.isVector4?this._viewport.copy(t):this._viewport.set(t,e,i,n))}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}pM.COLOR="color",pM.DEPTH="depth";class mM extends Nf{static get type(){return"AtomicFunctionNode"}constructor(t,e,i){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=i,this.parents=!0}getInputType(t){return this.pointerNode.getNodeType(t)}generateNodeType(t){return this.getInputType(t)}generate(t){const e=t.getNodeProperties(this),i=e.parents,n=this.method,r=this.getNodeType(t),s=this.getInputType(t),a=this.pointerNode,o=this.valueNode,l=[];l.push(`&${a.build(t,s)}`),null!==o&&l.push(o.build(t,s));const h=`${t.getMethod(n,r)}( ${l.join(", ")} )`;if(!(!!i&&(1===i.length&&!0===i[0].isStackNode)))return void 0===e.constNode&&(e.constNode=Av(h,r).toConst()),e.constNode.build(t);t.addLineFlowCode(h,this)}}mM.ATOMIC_LOAD="atomicLoad",mM.ATOMIC_STORE="atomicStore",mM.ATOMIC_ADD="atomicAdd",mM.ATOMIC_SUB="atomicSub",mM.ATOMIC_MAX="atomicMax",mM.ATOMIC_MIN="atomicMin",mM.ATOMIC_AND="atomicAnd",mM.ATOMIC_OR="atomicOr",mM.ATOMIC_XOR="atomicXor",bg(mM);bg(class extends Nf{constructor(t){super(),this.scope=t,this.isBarrierNode=!0}setup(t){t.allowEarlyReturns=!1,t.allowGlobalVariables=!1}generate(t){const{scope:e}=this,{renderer:i}=t;!0===i.backend.isWebGLBackend?t.addFlowCode(`\t// ${e}Barrier \n`):t.addLineFlowCode(`${e}Barrier()`,this)}});class fM extends If{static get type(){return"SubgroupFunctionNode"}constructor(t,e=null,i=null){super(),this.method=t,this.aNode=e,this.bNode=i}getInputType(t){const e=this.aNode?this.aNode.getNodeType(t):null,i=this.bNode?this.bNode.getNodeType(t):null;return(t.isMatrix(e)?0:t.getTypeLength(e))>(t.isMatrix(i)?0:t.getTypeLength(i))?e:i}generateNodeType(t){const e=this.method;return e===fM.SUBGROUP_ELECT?"bool":e===fM.SUBGROUP_BALLOT?"uvec4":this.getInputType(t)}generate(t,e){const i=this.method,n=this.getNodeType(t),r=this.getInputType(t),s=this.aNode,a=this.bNode,o=[];if(i===fM.SUBGROUP_BROADCAST||i===fM.SUBGROUP_SHUFFLE||i===fM.QUAD_BROADCAST){const e=a.getNodeType(t);o.push(s.build(t,n),a.build(t,"float"===e?"int":n))}else i===fM.SUBGROUP_SHUFFLE_XOR||i===fM.SUBGROUP_SHUFFLE_DOWN||i===fM.SUBGROUP_SHUFFLE_UP?o.push(s.build(t,n),a.build(t,"uint")):(null!==s&&o.push(s.build(t,r)),null!==a&&o.push(a.build(t,r)));const l=0===o.length?"()":`( ${o.join(", ")} )`;return t.format(`${t.getMethod(i,n)}${l}`,n,e)}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}fM.SUBGROUP_ELECT="subgroupElect",fM.SUBGROUP_BALLOT="subgroupBallot",fM.SUBGROUP_ADD="subgroupAdd",fM.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",fM.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",fM.SUBGROUP_MUL="subgroupMul",fM.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",fM.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",fM.SUBGROUP_AND="subgroupAnd",fM.SUBGROUP_OR="subgroupOr",fM.SUBGROUP_XOR="subgroupXor",fM.SUBGROUP_MIN="subgroupMin",fM.SUBGROUP_MAX="subgroupMax",fM.SUBGROUP_ALL="subgroupAll",fM.SUBGROUP_ANY="subgroupAny",fM.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",fM.QUAD_SWAP_X="quadSwapX",fM.QUAD_SWAP_Y="quadSwapY",fM.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",fM.SUBGROUP_BROADCAST="subgroupBroadcast",fM.SUBGROUP_SHUFFLE="subgroupShuffle",fM.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",fM.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",fM.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",fM.QUAD_BROADCAST="quadBroadcast",Eg(([t])=>Zy(Ng(52.9829189).mul(Zy(C_(t,Dg(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),Eg(([t,e,i])=>{const n=Ng(2.399963229728653),r=Wy(Ng(t).add(.5).div(Ng(e))),s=Ng(t).mul(n).add(i);return Dg($y(s),Ky(s)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class gM extends If{static get type(){return"BitcastNode"}constructor(t,e,i=null){super(),this.valueNode=t,this.conversionType=e,this.inputType=i,this.isBitcastNode=!0}generateNodeType(t){if(null!==this.inputType){const e=this.valueNode.getNodeType(t),i=t.getTypeLength(e);return t.getTypeFromLength(i,this.conversionType)}return this.conversionType}generate(t){const e=this.getNodeType(t);let i="";if(null!==this.inputType){const e=this.valueNode.getNodeType(t);i=1===t.getTypeLength(e)?this.inputType:t.changeComponentType(e,this.inputType)}else i=this.valueNode.getNodeType(t);return`${t.getBitcastMethod(e,i)}( ${this.valueNode.build(t,i)} )`}}const yM=Sg(gM).setParameterLength(2),_M={};class vM extends Dy{static get type(){return"BitcountNode"}constructor(t,e){super(t,e),this.isBitcountNode=!0}_resolveElementType(t,e,i){"int"===i?e.assign(yM(t,"uint")):e.assign(t)}_returnDataNode(t){switch(t){case"uint":return Pg;case"int":return Ig;case"uvec2":return Ug;case"uvec3":return Bg;case"uvec4":return Wg;case"ivec2":return Og;case"ivec3":return kg;case"ivec4":return Hg}}_createTrailingZerosBaseLayout(t,e){const i=this._returnDataNode(e);return Eg(([t])=>{const n=Pg(0);this._resolveElementType(t,n,e);const r=(t=>new gM(t,"uint","float"))(Ng(n.bitAnd(u_(n)))),s=r.shiftRight(23).sub(127);return i(s)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createLeadingZerosBaseLayout(t,e){const i=this._returnDataNode(e);return Eg(([t])=>{Ag(t.equal(Pg(0)),()=>Pg(32));const n=Pg(0),r=Pg(0);return this._resolveElementType(t,n,e),Ag(n.shiftRight(16).equal(0),()=>{r.addAssign(16),n.shiftLeftAssign(16)}),Ag(n.shiftRight(24).equal(0),()=>{r.addAssign(8),n.shiftLeftAssign(8)}),Ag(n.shiftRight(28).equal(0),()=>{r.addAssign(4),n.shiftLeftAssign(4)}),Ag(n.shiftRight(30).equal(0),()=>{r.addAssign(2),n.shiftLeftAssign(2)}),Ag(n.shiftRight(31).equal(0),()=>{r.addAssign(1)}),i(r)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createOneBitsBaseLayout(t,e){const i=this._returnDataNode(e);return Eg(([t])=>{const n=Pg(0);this._resolveElementType(t,n,e),n.assign(n.sub(n.shiftRight(Pg(1)).bitAnd(Pg(1431655765)))),n.assign(n.bitAnd(Pg(858993459)).add(n.shiftRight(Pg(2)).bitAnd(Pg(858993459))));const r=n.add(n.shiftRight(Pg(4))).bitAnd(Pg(252645135)).mul(Pg(16843009)).shiftRight(Pg(24));return i(r)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createMainLayout(t,e,i,n){const r=this._returnDataNode(e),s=Eg(([t])=>{if(1===i)return r(n(t));{const e=r(0),s=["x","y","z","w"];for(let r=0;rc(i))()}}vM.COUNT_TRAILING_ZEROS="countTrailingZeros",vM.COUNT_LEADING_ZEROS="countLeadingZeros",vM.COUNT_ONE_BITS="countOneBits";class xM extends Nf{static get type(){return"EventNode"}constructor(t,e){super("void"),this.eventType=t,this.callback=e,t===xM.OBJECT?this.updateType=pm:t===xM.MATERIAL?this.updateType=dm:t===xM.FRAME?this.updateType=um:t===xM.BEFORE_OBJECT?this.updateBeforeType=pm:t===xM.BEFORE_MATERIAL?this.updateBeforeType=dm:t===xM.BEFORE_FRAME&&(this.updateBeforeType=um)}update(t){this.callback(t)}updateBefore(t){this.callback(t)}}xM.OBJECT="object",xM.MATERIAL="material",xM.FRAME="frame",xM.BEFORE_OBJECT="beforeObject",xM.BEFORE_MATERIAL="beforeMaterial",xM.BEFORE_FRAME="beforeFrame",new cf;const bM=new hM;sx.flipX(),bM.depthTexture=new $b(1,1),zg(.04),Ng(1);const MM={type:"change"},SM={type:"start"},TM={type:"end"},wM=new ts,EM=new Gs,AM=Math.cos(70*hi.DEG2RAD),CM=new di,RM=2*Math.PI,NM=-1,IM=0,PM=1,LM=2,DM=3,OM=4,UM=5,FM=6,zM=1e-6;class kM extends su{constructor(t,n=null){super(t,n),this.state=NM,this.target=new di,this.cursor=new di,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:e.ROTATE,MIDDLE:e.DOLLY,RIGHT:e.PAN},this.touches={ONE:i.ROTATE,TWO:i.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new di,this._lastQuaternion=new ui,this._lastTargetPosition=new di,this._quat=(new ui).setFromUnitVectors(t.up,new di(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Nc,this._sphericalDelta=new Nc,this._scale=1,this._panOffset=new di,this._rotateStart=new ci,this._rotateEnd=new ci,this._rotateDelta=new ci,this._panStart=new ci,this._panEnd=new ci,this._panDelta=new ci,this._dollyStart=new ci,this._dollyEnd=new ci,this._dollyDelta=new ci,this._dollyDirection=new di,this._mouse=new ci,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=VM.bind(this),this._onPointerDown=BM.bind(this),this._onPointerUp=GM.bind(this),this._onContextMenu=ZM.bind(this),this._onMouseWheel=jM.bind(this),this._onKeyDown=XM.bind(this),this._onTouchStart=qM.bind(this),this._onTouchMove=YM.bind(this),this._onMouseDown=HM.bind(this),this._onMouseMove=WM.bind(this),this._interceptControlDown=KM.bind(this),this._interceptControlUp=JM.bind(this),null!==this.domElement&&this.connect(this.domElement),this.update()}set cursorStyle(t){this._cursorStyle=t,this.domElement.style.cursor="grab"===t?"grab":"auto"}get cursorStyle(){return this._cursorStyle}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1});this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.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=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){null!==this._domElementKeyEvents&&(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(MM),this.update(),this.state=NM}pan(t,e){this._pan(t,e),this.update()}dollyIn(t){this._dollyIn(t),this.update()}dollyOut(t){this._dollyOut(t),this.update()}rotateLeft(t){this._rotateLeft(t),this.update()}rotateUp(t){this._rotateUp(t),this.update()}update(t=null){const e=this.object.position;CM.copy(e).sub(this.target),CM.applyQuaternion(this._quat),this._spherical.setFromVector3(CM),this.autoRotate&&this.state===NM&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=RM:i>Math.PI&&(i-=RM),n<-Math.PI?n+=RM:n>Math.PI&&(n-=RM),this._spherical.theta=i<=n?Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(CM.setFromSpherical(this._spherical),CM.applyQuaternion(this._quatInverse),e.copy(this.target).add(CM),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=CM.length();t=this._clampDistance(e*this._scale);const i=e-t;this.object.position.addScaledVector(this._dollyDirection,i),this.object.updateMatrixWorld(),r=!!i}else if(this.object.isOrthographicCamera){const e=new di(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=i!==this.object.zoom;const n=new di(this._mouse.x,this._mouse.y,0);n.unproject(this.object),this.object.position.sub(n).add(e),this.object.updateMatrixWorld(),t=CM.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(wM.origin.copy(this.object.position),wM.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(wM.direction))zM||8*(1-this._lastQuaternion.dot(this.object.quaternion))>zM||this._lastTargetPosition.distanceToSquared(this.target)>zM)&&(this.dispatchEvent(MM),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?RM/60*this.autoRotateSpeed*t:RM/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){CM.setFromMatrixColumn(e,0),CM.multiplyScalar(-t),this._panOffset.add(CM)}_panUp(t,e){!0===this.screenSpacePanning?CM.setFromMatrixColumn(e,1):(CM.setFromMatrixColumn(e,0),CM.crossVectors(this.object.up,CM)),CM.multiplyScalar(t),this._panOffset.add(CM)}_pan(t,e){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;CM.copy(n).sub(this.target);let r=CM.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/i.clientHeight,this.object.matrix),this._panUp(2*e*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=t-i.left,r=e-i.top,s=i.width,a=i.height;this._mouse.x=n/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(RM*this._rotateDelta.x/e.clientHeight),this._rotateUp(RM*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(RM*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-RM*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(RM*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-RM*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panStart.set(i,n)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(i*i+n*n);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._rotateEnd.set(i,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(RM*this._rotateDelta.x/e.clientHeight),this._rotateUp(RM*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;et&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(fS.copy(SS).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(fS.copy(TS).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(fS.copy(TS).applyQuaternion(e).dot(this.eye)).9&&(n.visible=!1)),"Y"===this.axis&&(eS.setFromEuler(mS.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(eS),Math.abs(fS.copy(SS).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(eS.setFromEuler(mS.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(eS),Math.abs(fS.copy(TS).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(eS.setFromEuler(mS.set(0,Math.PI/2,0)),fS.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(yS.lookAt(gS,fS,SS)),n.quaternion.multiply(eS),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),QM.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),QM.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(QM),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class NS extends ps{constructor(){super(new al(1e5,1e5,2,2),new es({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),wS.copy(MS).applyQuaternion("local"===e?this.worldQuaternion:vS),ES.copy(SS).applyQuaternion("local"===e?this.worldQuaternion:vS),AS.copy(TS).applyQuaternion("local"===e?this.worldQuaternion:vS),fS.copy(ES),this.mode){case"translate":case"scale":switch(this.axis){case"X":fS.copy(this.eye).cross(wS),xS.copy(wS).cross(fS);break;case"Y":fS.copy(this.eye).cross(ES),xS.copy(ES).cross(fS);break;case"Z":fS.copy(this.eye).cross(AS),xS.copy(AS).cross(fS);break;case"XY":xS.copy(AS);break;case"YZ":xS.copy(wS);break;case"XZ":fS.copy(AS),xS.copy(ES);break;case"XYZ":case"E":xS.set(0,0,0)}break;default:xS.set(0,0,0)}0===xS.length()?this.quaternion.copy(this.cameraQuaternion):(bS.lookAt(QM.set(0,0,0),xS,fS),this.quaternion.setFromRotationMatrix(bS)),super.updateMatrixWorld(t)}}class IS extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new oh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(t){const i=r.parse(JSON.parse(t));e&&e(i)},i,n)}parse(t){return new PS(t)}}class PS{constructor(t){this.isFont=!0,this.type="Font",this.data=t}generateShapes(t,e=100,i="ltr"){const n=[],r=function(t,e,i,n){const r=Array.from(t),s=e/i.resolution,a=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*s,o=[];let l=0,h=0;"rtl"!=n&&"tb"!=n||r.reverse();for(let t=0;t>8&255]+DS[t>>16&255]+DS[t>>24&255]+"-"+DS[255&e]+DS[e>>8&255]+"-"+DS[e>>16&15|64]+DS[e>>24&255]+"-"+DS[63&i|128]+DS[i>>8&255]+"-"+DS[i>>16&255]+DS[i>>24&255]+DS[255&n]+DS[n>>8&255]+DS[n>>16&255]+DS[n>>24&255]).toLowerCase()},clamp:zS,euclideanModulo:kS,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:BS,damp:function(t,e,i,n){return BS(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(kS(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(OS=t);let e=OS+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*US},radToDeg:function(t){return t*FS},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),h=s((e+n)/2),c=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),m=a((n-e)/2);switch(r){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:function(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}},denormalize:function(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}});class GS{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,s,a){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||l!==d||h!==p){let t=1-a;const e=o*u+l*d+h*p+c*m,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*t+u*r,l=l*t+d*r,h=h*t+p*r,c=c*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+h*c+o*d-l*u,t[e+1]=o*p+h*u+l*c-a*d,t[e+2]=l*p+h*d+a*u-o*c,t[e+3]=h*p-a*c-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(n/2),c=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(zS(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+s*a+n*l-r*o,this._y=n*h+s*o+r*a-i*l,this._z=r*h+s*l+i*o-n*a,this._w=s*h-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*t._w+i*t._x+n*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=s*c+this._w*u,this._x=i*c+this._x*u,this._y=n*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(r),i*Math.cos(r),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class HS{constructor(t=0,e=0,i=0){HS.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(jS.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(jS.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=o*e+s*n-a*i,h=o*i+a*e-r*n,c=o*n+r*i-s*e,u=-r*e-s*i-a*n;return this.x=l*o+u*-r+h*-a-c*-s,this.y=h*o+u*-s+c*-r-l*-a,this.z=c*o+u*-a+l*-s-h*-r,this}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return WS.copy(this).projectOnVector(t),this.sub(WS)}reflect(t){return this.sub(WS.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(zS(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const WS=new HS,jS=new GS;class XS{constructor(){XS.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,i,n,r,s,a,o,l,h,c,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 XS).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/qS.setFromMatrixColumn(t,0).length(),r=1/qS.setFromMatrixColumn(t,1).length(),s=1/qS.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=n+i*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t+r*a,e[4]=n*a-i,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-a,e[2]=i*a-n,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t-r*a,e[4]=-s*c,e[8]=n+i*a,e[1]=i+n*a,e[5]=s*h,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=n*l-i,e[8]=t*l+r,e[1]=o*c,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=r-t*c,e[8]=n*c+i,e[1]=c,e[5]=s*h,e[9]=-a*h,e[2]=-l*h,e[6]=i*c+n,e[10]=t-r*c}else if("XZY"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=i*c-n,e[2]=n*c-i,e[6]=a*h,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ZS,t,KS)}lookAt(t,e,i){const n=this.elements;return QS.subVectors(t,e),0===QS.lengthSq()&&(QS.z=1),QS.normalize(),JS.crossVectors(i,QS),0===JS.lengthSq()&&(1===Math.abs(i.z)?QS.x+=1e-4:QS.z+=1e-4,QS.normalize(),JS.crossVectors(i,QS)),JS.normalize(),$S.crossVectors(QS,JS),n[0]=JS.x,n[4]=$S.x,n[8]=QS.x,n[1]=JS.y,n[5]=$S.y,n[9]=QS.y,n[2]=JS.z,n[6]=$S.z,n[10]=QS.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],y=i[3],_=i[7],v=i[11],x=i[15],b=n[0],M=n[4],S=n[8],T=n[12],w=n[1],E=n[5],A=n[9],C=n[13],R=n[2],N=n[6],I=n[10],P=n[14],L=n[3],D=n[7],O=n[11],U=n[15];return r[0]=s*b+a*w+o*R+l*L,r[4]=s*M+a*E+o*N+l*D,r[8]=s*S+a*A+o*I+l*O,r[12]=s*T+a*C+o*P+l*U,r[1]=h*b+c*w+u*R+d*L,r[5]=h*M+c*E+u*N+d*D,r[9]=h*S+c*A+u*I+d*O,r[13]=h*T+c*C+u*P+d*U,r[2]=p*b+m*w+f*R+g*L,r[6]=p*M+m*E+f*N+g*D,r[10]=p*S+m*A+f*I+g*O,r[14]=p*T+m*C+f*P+g*U,r[3]=y*b+_*w+v*R+x*L,r[7]=y*M+_*E+v*N+x*D,r[11]=y*S+_*A+v*I+x*O,r[15]=y*T+_*C+v*P+x*U,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*o*c-n*l*c-r*a*u+i*l*u+n*a*d-i*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-n*s*d+n*l*h-r*o*h)+t[11]*(+e*l*c-e*a*d-r*s*c+i*s*d+r*a*h-i*l*h)+t[15]*(-n*a*h-e*o*c+e*a*u+n*s*c-i*s*u+i*o*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],y=c*f*l-m*u*l+m*o*d-a*f*d-c*o*g+a*u*g,_=p*u*l-h*f*l-p*o*d+s*f*d+h*o*g-s*u*g,v=h*m*l-p*c*l+p*a*d-s*m*d-h*a*g+s*c*g,x=p*c*o-h*m*o-p*a*u+s*m*u+h*a*f-s*c*f,b=e*y+i*_+n*v+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/b;return t[0]=y*M,t[1]=(m*u*r-c*f*r-m*n*d+i*f*d+c*n*g-i*u*g)*M,t[2]=(a*f*r-m*o*r+m*n*l-i*f*l-a*n*g+i*o*g)*M,t[3]=(c*o*r-a*u*r-c*n*l+i*u*l+a*n*d-i*o*d)*M,t[4]=_*M,t[5]=(h*f*r-p*u*r+p*n*d-e*f*d-h*n*g+e*u*g)*M,t[6]=(p*o*r-s*f*r-p*n*l+e*f*l+s*n*g-e*o*g)*M,t[7]=(s*u*r-h*o*r+h*n*l-e*u*l-s*n*d+e*o*d)*M,t[8]=v*M,t[9]=(p*c*r-h*m*r-p*i*d+e*m*d+h*i*g-e*c*g)*M,t[10]=(s*m*r-p*a*r+p*i*l-e*m*l-s*i*g+e*a*g)*M,t[11]=(h*a*r-s*c*r-h*i*l+e*c*l+s*i*d-e*a*d)*M,t[12]=x*M,t[13]=(h*m*n-p*c*n+p*i*u-e*m*u-h*i*f+e*c*f)*M,t[14]=(p*a*n-s*m*n-p*i*o+e*m*o+s*i*f-e*a*f)*M,t[15]=(s*c*n-h*a*n+h*i*o-e*c*o-s*i*u+e*a*u)*M,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,a=t.y,o=t.z,l=r*s,h=r*a;return this.set(l*s+i,l*a-n*o,l*o+n*a,0,l*a+n*o,h*a+i,h*o-n*s,0,l*o-n*a,h*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,s){return this.set(1,i,r,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,h=s+s,c=a+a,u=r*l,d=r*h,p=r*c,m=s*h,f=s*c,g=a*c,y=o*l,_=o*h,v=o*c,x=i.x,b=i.y,M=i.z;return n[0]=(1-(m+g))*x,n[1]=(d+v)*x,n[2]=(p-_)*x,n[3]=0,n[4]=(d-v)*b,n[5]=(1-(u+g))*b,n[6]=(f+y)*b,n[7]=0,n[8]=(p+_)*M,n[9]=(f-y)*M,n[10]=(1-(u+m))*M,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=qS.set(n[0],n[1],n[2]).length();const s=qS.set(n[4],n[5],n[6]).length(),a=qS.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],YS.copy(this);const o=1/r,l=1/s,h=1/a;return YS.elements[0]*=o,YS.elements[1]*=o,YS.elements[2]*=o,YS.elements[4]*=l,YS.elements[5]*=l,YS.elements[6]*=l,YS.elements[8]*=h,YS.elements[9]*=h,YS.elements[10]*=h,e.setFromRotationMatrix(YS),i.x=r,i.y=s,i.z=a,this}makePerspective(t,e,i,n,r,s){const a=this.elements,o=2*r/(e-t),l=2*r/(i-n),h=(e+t)/(e-t),c=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return a[0]=o,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,n,r,s){const a=this.elements,o=1/(e-t),l=1/(i-n),h=1/(s-r),c=(e+t)*o,u=(i+n)*l,d=(s+r)*h;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const qS=new HS,YS=new XS,ZS=new HS(0,0,0),KS=new HS(1,1,1),JS=new HS,$S=new HS,QS=new HS,tT=new XS,eT=new GS;class iT{constructor(t=0,e=0,i=0,n=iT.DefaultOrder){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],s=n[4],a=n[8],o=n[1],l=n[5],h=n[9],c=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(zS(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-zS(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(zS(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-zS(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(zS(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-zS(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return tT.makeRotationFromQuaternion(t),this.setFromRotationMatrix(tT,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return eT.setFromEuler(this),this.setFromQuaternion(eT,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}iT.DefaultOrder="XYZ",iT.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class nT extends el{constructor(t,e={}){const i=e.font;if(void 0===i)super();else{const n=i.generateShapes(t,e.size,e.direction);void 0===e.depth&&(e.depth=50),void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),super(n,e)}this.type="TextGeometry"}toJSON(){return super.toJSON()}static fromJSON(t){const e=t.options;return e.font=new PS(e.font.data),new nT(e.text,e)}}var rT=Object.freeze({__proto__:null,DDSLoader:class extends lh{constructor(t){super(t)}parse(t,e){const i={mipmaps:[],width:0,height:0,format:null,mipmapCount:1,isCubemap:!1};function n(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}function r(t,e,i,n){const r=i*n*4,s=new Uint8Array(t,e,r),a=new Uint8Array(r);let o=0,l=0;for(let t=0;t>8&255,y>>16&255,y>>24&255))),i;f=!0,d=64,i.format=Mt}}var y;i.mipmapCount=1,131072&u[2]&&!1!==e&&(i.mipmapCount=Math.max(1,u[7]));const _=u[28];if(i.isCubemap=!!(512&_),i.isCubemap&&(!(1024&_)||!(2048&_)||!(4096&_)||!(8192&_)||!(16384&_)||!(32768&_)))return console.error("THREE.DDSLoader.parse: Incomplete cubemap faces"),i;i.width=u[4],i.height=u[3];const v=i.isCubemap?6:1;for(let e=0;e>1,1),n=Math.max(n>>1,1)}}return i}}});class sT{constructor(t="",e={}){this.baseUrl=t,this.options=e,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:0,this.wrap=void 0!==this.options.wrap?this.options.wrap:$}setCrossOrigin(t){return this.crossOrigin=t,this}setManager(t){this.manager=t}setMaterials(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(t){if(!this.options)return t;const e={};for(const i in t){const n=t[i],r={};e[i]=r;for(const t in n){let e=!0,i=n[t];const s=t.toLowerCase();switch(s){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(e=!1)}e&&(r[s]=i)}}return e}preload(){for(const t in this.materialsInfo)this.create(t)}getIndex(t){return this.nameLookup[t]}getAsArray(){let t=0;for(const e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray}create(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]}createMaterial_(t){const e=this,i=this.materialsInfo[t],n={name:t,side:this.side};function r(t,i){if(n[t])return;const r=e.getTextureParams(i,n),s=e.loadTexture((a=e.baseUrl,"string"!=typeof(o=r.url)||""===o?"":/^https?:\/\//i.test(o)?o:a+o));var a,o;s.repeat.copy(r.scale),s.offset.copy(r.offset),s.wrapS=e.wrap,s.wrapT=e.wrap,"map"!==t&&"emissiveMap"!==t||(s.colorSpace=Me),n[t]=s}for(const t in i){const e=i[t];let s;if(""!==e)switch(t.toLowerCase()){case"kd":n.color=xi.colorSpaceToWorking((new _n).fromArray(e),Me);break;case"ks":n.specular=xi.colorSpaceToWorking((new _n).fromArray(e),Me);break;case"ke":n.emissive=xi.colorSpaceToWorking((new _n).fromArray(e),Me);break;case"map_kd":r("map",e);break;case"map_ks":r("specularMap",e);break;case"map_ke":r("emissiveMap",e);break;case"norm":r("normalMap",e);break;case"map_bump":case"bump":r("bumpMap",e);break;case"disp":r("displacementMap",e);break;case"map_d":r("alphaMap",e),n.transparent=!0;break;case"ns":n.shininess=parseFloat(e);break;case"d":s=parseFloat(e),s<1&&(n.opacity=s,n.transparent=!0);break;case"tr":s=parseFloat(e),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(n.opacity=1-s,n.transparent=!0)}}return this.materials[t]=new Al(n),this.materials[t]}getTextureParams(t,e){const i={scale:new ci(1,1),offset:new ci(0,0)},n=t.split(/\s+/);let r;return r=n.indexOf("-bm"),r>=0&&(e.bumpScale=parseFloat(n[r+1]),n.splice(r,2)),r=n.indexOf("-mm"),r>=0&&(e.displacementBias=parseFloat(n[r+1]),e.displacementScale=parseFloat(n[r+2]),n.splice(r,3)),r=n.indexOf("-s"),r>=0&&(i.scale.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),r=n.indexOf("-o"),r>=0&&(i.offset.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),i.url=n.join(" ").trim(),i}loadTexture(t,e,i,n,r){const s=void 0!==this.manager?this.manager:nh;let a=s.getHandler(t);null===a&&(a=new dh(s)),a.setCrossOrigin&&a.setCrossOrigin(this.crossOrigin);const o=a.load(t,i,n,r);return void 0!==e&&(o.mapping=e),o}}var aT=Object.freeze({__proto__:null,MTLLoader:class extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===this.path?kh.extractUrlBase(t):this.path,a=new oh(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){try{e(r.parse(i,s))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}setMaterialOptions(t){return this.materialOptions=t,this}parse(t,e){const i=t.split("\n");let n={};const r=/\s+/,s={};for(let t=0;t=0?e.substring(0,a):e;o=o.toLowerCase();let l=a>=0?e.substring(a+1):"";if(l=l.trim(),"newmtl"===o)n={name:l},s[l]=n;else if("ka"===o||"kd"===o||"ks"===o||"ke"===o){const t=l.split(r,3);n[o]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else n[o]=l}const a=new sT(this.resourcePath||e,this.materialOptions);return a.setCrossOrigin(this.crossOrigin),a.setManager(this.manager),a.setMaterials(s),a}}});const oT=/^[og]\s*(.+)?/,lT=/^mtllib /,hT=/^usemtl /,cT=/^usemap /,uT=/\s+/,dT=new di,pT=new di,mT=new di,fT=new di,gT=new di,yT=new _n;function _T(){const t={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);const i=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:t||"",fromDeclaration:!1!==e,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(t,e){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const n={index:this.materials.length,name:t||"",mtllib:Array.isArray(e)&&e.length>0?e[e.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(t){const e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(n),n},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){const e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},i&&i.name&&"function"==typeof i.clone){const t=i.clone(0);t.inherited=!0,this.object.materials.push(t)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(t,e){const i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseNormalIndex:function(t,e){const i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseUVIndex:function(t,e){const i=parseInt(t,10);return 2*(i>=0?i-1:i+e/2)},addVertex:function(t,e,i){const n=this.vertices,r=this.object.geometry.vertices;r.push(n[t+0],n[t+1],n[t+2]),r.push(n[e+0],n[e+1],n[e+2]),r.push(n[i+0],n[i+1],n[i+2])},addVertexPoint:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,i){const n=this.normals,r=this.object.geometry.normals;r.push(n[t+0],n[t+1],n[t+2]),r.push(n[e+0],n[e+1],n[e+2]),r.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(t,e,i){const n=this.vertices,r=this.object.geometry.normals;dT.fromArray(n,t),pT.fromArray(n,e),mT.fromArray(n,i),gT.subVectors(mT,pT),fT.subVectors(dT,pT),gT.cross(fT),gT.normalize(),r.push(gT.x,gT.y,gT.z),r.push(gT.x,gT.y,gT.z),r.push(gT.x,gT.y,gT.z)},addColor:function(t,e,i){const n=this.colors,r=this.object.geometry.colors;void 0!==n[t]&&r.push(n[t+0],n[t+1],n[t+2]),void 0!==n[e]&&r.push(n[e+0],n[e+1],n[e+2]),void 0!==n[i]&&r.push(n[i+0],n[i+1],n[i+2])},addUV:function(t,e,i){const n=this.uvs,r=this.object.geometry.uvs;r.push(n[t+0],n[t+1]),r.push(n[e+0],n[e+1]),r.push(n[i+0],n[i+1])},addDefaultUV:function(){const t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){const e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,i,n,r,s,a,o,l){const h=this.vertices.length;let c=this.parseVertexIndex(t,h),u=this.parseVertexIndex(e,h),d=this.parseVertexIndex(i,h);if(this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==a&&""!==a){const t=this.normals.length;c=this.parseNormalIndex(a,t),u=this.parseNormalIndex(o,t),d=this.parseNormalIndex(l,t),this.addNormal(c,u,d)}else this.addFaceNormal(c,u,d);if(void 0!==n&&""!==n){const t=this.uvs.length;c=this.parseUVIndex(n,t),u=this.parseUVIndex(r,t),d=this.parseUVIndex(s,t),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";const e=this.vertices.length;for(let i=0,n=t.length;i=7?(yT.setRGB(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6]),Me),e.colors.push(yT.r,yT.g,yT.b)):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":e.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===s){const t=r.slice(1).trim().split(uT),i=[];for(let e=0,n=t.length;e0){const t=n.split("/");i.push(t)}}const n=i[0];for(let t=1,r=i.length-1;t1){const t=n[1].trim().toLowerCase();e.object.smooth="0"!==t&&"off"!==t}else e.object.smooth=!0;const t=e.object.currentMaterial();t&&(t.smooth=e.object.smooth)}else{if("\0"===r)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+r+'"')}}e.finalize();const r=new un;r.materialLibraries=[].concat(e.materialLibraries);if(!0===!(1===e.objects.length&&0===e.objects[0].geometry.vertices.length))for(let t=0,i=e.objects.length;t0&&h.setAttribute("normal",new cr(n.normals,3)),n.colors.length>0&&(l=!0,h.setAttribute("color",new cr(n.colors,3))),!0===n.hasUVIndices&&h.setAttribute("uv",new cr(n.uvs,2));const c=[];for(let t=0,i=s.length;t1){for(let t=0,e=s.length;t0){const t=new Ra({size:1,sizeAttenuation:!1}),i=new Mr;i.setAttribute("position",new cr(e.vertices,3)),e.colors.length>0&&void 0!==e.colors[0]&&(i.setAttribute("color",new cr(e.colors,3)),t.vertexColors=!0);const n=new Da(i,t);r.add(n)}return r}}}),xT=Uint8Array,bT=Uint16Array,MT=Int32Array,ST=new xT([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),TT=new xT([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wT=new xT([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ET=function(t,e){for(var i=new bT(31),n=0;n<31;++n)i[n]=e+=1< Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.8.2 */CT[28]=258,RT[258]=28;for(var NT=ET(TT,0).b,IT=new bT(32768),PT=0;PT<32768;++PT){var LT=(43690&PT)>>1|(21845&PT)<<1;LT=(61680&(LT=(52428<)>>2|(13107<)<<2))>>4|(3855<)<<4,IT[PT]=((65280<)>>8|(255<)<<8)>>1}var DT=function(t,e,i){for(var n=t.length,r=0,s=new bT(e);r>l]=h}else for(a=new bT(n),r=0;r>15-t[r]);return a},OT=new xT(288);for(PT=0;PT<144;++PT)OT[PT]=8;for(PT=144;PT<256;++PT)OT[PT]=9;for(PT=256;PT<280;++PT)OT[PT]=7;for(PT=280;PT<288;++PT)OT[PT]=8;var UT=new xT(32);for(PT=0;PT<32;++PT)UT[PT]=5;var FT=DT(OT,9,1),zT=DT(UT,5,1),kT=function(t){for(var e=t[0],i=1;ie&&(e=t[i]);return e},BT=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(7&e)&i},VT=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},GT=function(t){return(t+7)/8|0},HT=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],WT=function(t,e,i){var n=new Error(e||HT[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,WT),!i)throw n;return n},jT=function(t,e,i,n){var r=t.length;if(!r||e.f&&!e.l)return i||new xT(0);var s=!i,a=s||2!=e.i;s&&(i=new xT(3*r));var o=function(t){var e=i.length;if(t>e){var n=new xT(Math.max(2*e,t));n.set(i),i=n}},l=e.f||0,h=e.p||0,c=e.b||0,u=e.l,d=e.d,p=e.m,m=e.n,f=8*r;do{if(!u){l=BT(t,h,1);var g=BT(t,h+1,3);if(h+=3,!g){var y=t[(C=GT(h)+4)-4]|t[C-3]<<8,_=C+y;if(_>r){WT(0);break}a&&o(c+y),i.set(t.subarray(C,_),c),e.b=c+=y,e.p=h=8*_,e.f=l;continue}if(1==g)u=FT,d=zT,p=9,m=5;else if(2==g){var v=BT(t,h,31)+257,x=BT(t,h+10,15)+4,b=v+BT(t,h+5,31)+1;h+=14;for(var M=new xT(b),S=new xT(19),T=0;T>4)<16)M[T++]=C;else{var N=0,I=0;for(16==C?(I=3+BT(t,h,3),h+=2,N=M[T-1]):17==C?(I=3+BT(t,h,7),h+=3):18==C&&(I=11+BT(t,h,127),h+=7);I--;)M[T++]=N}}var P=M.subarray(0,v),L=M.subarray(v);p=kT(P),m=kT(L),u=DT(P,p,1),d=DT(L,m,1)}else WT(1);if(h>f){WT(0);break}}a&&o(c+131072);for(var D=(1<>4;if((h+=15&N)>f){WT(0);break}if(N||WT(2),F<256)i[c++]=F;else{if(256==F){U=h,u=null;break}var z=F-254;if(F>264){var k=ST[T=F-257];z=BT(t,h,(1<>4;B||WT(3),h+=15&B;L=NT[V];if(V>3){k=TT[V];L+=VT(t,h)&(1<f){WT(0);break}a&&o(c+131072);var G=c+z;if(ct.length)&&(i=t.length),new xT(t.subarray(e,i))}(i,0,c):i.subarray(0,c)},XT=new xT(0);function qT(t,e){return jT(t.subarray(((8!=(15&(i=t)[0])||i[0]>>4>7||(i[0]<<8|i[1])%31)&&WT(6,"invalid zlib data"),1==(i[1]>>5&1)&&WT(6,"invalid zlib data: "+(32&i[1]?"need":"unexpected")+" dictionary"),2+(i[1]>>3&4)),-4),{i:2},e,e);var i}var YT="undefined"!=typeof TextDecoder&&new TextDecoder;try{YT.decode(XT,{stream:!0})}catch(t){}function ZT(t,e,i){const n=i.length-t-1;if(e>=i[n])return n-1;if(e<=i[t])return t;let r=t,s=n,a=Math.floor((r+s)/2);for(;e=i[a+1];)e=s&&(l[r][0]=l[e][0]/o[c+1][h],n=l[r][0]*o[h][c]);const u=t-1<=c?s-1:i-t;for(let t=h>=-1?1:-h;t<=u;++t)l[r][t]=(l[e][t]-l[e][t-1])/o[c+1][h+t],n+=l[r][t]*o[h+t][c];t<=c&&(l[r][s]=-l[e][s-1]/o[c+1][t],n+=l[r][s]*o[t][c]),a[s][t]=n;const d=e;e=r,r=d}}let c=i;for(let t=1;t<=n;++t){for(let e=0;e<=i;++e)a[t][e]*=c;c*=i-t}return a}(o,n,t,s,e),h=[];for(let t=0;tt.toArray()),t.startKnot=this.startKnot,t.endKnot=this.endKnot,t}fromJSON(t){return super.fromJSON(t),this.degree=t.degree,this.knots=[...t.knots],this.controlPoints=t.controlPoints.map(t=>new Ii(t[0],t[1],t[2],t[3])),this.startKnot=t.startKnot,this.endKnot=t.endKnot,this}}let QT,tw,ew;class iw{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){tw=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),i=this.parseMaterials(e),n=this.parseDeformers(),r=(new nw).parse(n);return this.parseScene(n,r,i),ew}parseConnections(){const t=new Map;if("Connections"in QT){QT.Connections.connections.forEach(function(e){const i=e[0],n=e[1],r=e[2];t.has(i)||t.set(i,{parents:[],children:[]});const s={ID:n,relationship:r};t.get(i).parents.push(s),t.has(n)||t.set(n,{parents:[],children:[]});const a={ID:i,relationship:r};t.get(n).children.push(a)})}return t}parseImages(){const t={},e={};if("Video"in QT.Objects){const i=QT.Objects.Video;for(const n in i){const r=i[n];if(t[parseInt(n)]=r.RelativeFilename||r.Filename,"Content"in r){const t=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,s="string"==typeof r.Content&&""!==r.Content;if(t||s){const t=this.parseImage(i[n]);e[r.RelativeFilename||r.Filename]=t}}}}for(const i in t){const n=t[i];void 0!==e[n]?t[i]=e[n]:t[i]=t[i].split("\\").pop()}return t}parseImage(t){const e=t.Content,i=t.RelativeFilename||t.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();let r;switch(n){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),r="image/tga";break;case"webp":r="image/webp";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof e)return"data:"+r+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:r}))}}parseTextures(t){const e=new Map;if("Texture"in QT.Objects){const i=QT.Objects.Texture;for(const n in i){const r=this.parseTexture(i[n],t);e.set(parseInt(n),r)}}return e}parseTexture(t,e){const i=this.loadTexture(t,e);i.ID=t.id,i.name=t.attrName;const n=t.WrapModeU,r=t.WrapModeV,s=void 0!==n?n.value:0,a=void 0!==r?r.value:0;if(i.wrapS=0===s?$:Q,i.wrapT=0===a?$:Q,"Scaling"in t){const e=t.Scaling.value;i.repeat.x=e[0],i.repeat.y=e[1]}if("Translation"in t){const e=t.Translation.value;i.offset.x=e[0],i.offset.y=e[1]}return i}loadTexture(t,e){const i=t.FileName.split(".").pop().toLowerCase();let n=this.manager.getHandler(`.${i}`);null===n&&(n=this.textureLoader);const r=n.path;r||n.setPath(this.textureLoader.path);const s=tw.get(t.id).children;let a;if(void 0!==s&&s.length>0&&void 0!==e[s[0].ID]&&(a=e[s[0].ID],0!==a.indexOf("blob:")&&0!==a.indexOf("data:")||n.setPath(void 0)),void 0===a)return console.warn("FBXLoader: Undefined filename, creating placeholder texture."),new Ni;const o=n.load(a);return n.setPath(r),o}parseMaterials(t){const e=new Map;if("Material"in QT.Objects){const i=QT.Objects.Material;for(const n in i){const r=this.parseMaterial(i[n],t);null!==r&&e.set(parseInt(n),r)}}return e}parseMaterial(t,e){const i=t.id,n=t.attrName;let r=t.ShadingModel;if("object"==typeof r&&(r=r.value),!tw.has(i))return null;const s=this.parseParameters(t,e,i);let a;switch(r.toLowerCase()){case"phong":a=new Al;break;case"lambert":a=new Nl;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new Al}return a.setValues(s),a.name=n,a}parseParameters(t,e,i){const n={};t.BumpFactor&&(n.bumpScale=t.BumpFactor.value),t.Diffuse?n.color=xi.colorSpaceToWorking((new _n).fromArray(t.Diffuse.value),Me):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(n.color=xi.colorSpaceToWorking((new _n).fromArray(t.DiffuseColor.value),Me)),t.DisplacementFactor&&(n.displacementScale=t.DisplacementFactor.value),t.Emissive?n.emissive=xi.colorSpaceToWorking((new _n).fromArray(t.Emissive.value),Me):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(n.emissive=xi.colorSpaceToWorking((new _n).fromArray(t.EmissiveColor.value),Me)),t.EmissiveFactor&&(n.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),n.opacity=1-(t.TransparencyFactor?parseFloat(t.TransparencyFactor.value):0),1!==n.opacity&&0!==n.opacity||(n.opacity=t.Opacity?parseFloat(t.Opacity.value):null,null===n.opacity&&(n.opacity=1)),n.opacity<1&&(n.transparent=!0),t.ReflectionFactor&&(n.reflectivity=t.ReflectionFactor.value),t.Shininess&&(n.shininess=t.Shininess.value),t.Specular?n.specular=xi.colorSpaceToWorking((new _n).fromArray(t.Specular.value),Me):t.SpecularColor&&"Color"===t.SpecularColor.type&&(n.specular=xi.colorSpaceToWorking((new _n).fromArray(t.SpecularColor.value),Me));const r=this;return tw.get(i).children.forEach(function(t){const i=t.relationship;switch(i){case"Bump":n.bumpMap=r.getTexture(e,t.ID);break;case"Maya|TEX_ao_map":n.aoMap=r.getTexture(e,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=r.getTexture(e,t.ID),void 0!==n.map&&(n.map.colorSpace=Me);break;case"DisplacementColor":n.displacementMap=r.getTexture(e,t.ID);break;case"EmissiveColor":n.emissiveMap=r.getTexture(e,t.ID),void 0!==n.emissiveMap&&(n.emissiveMap.colorSpace=Me);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=r.getTexture(e,t.ID);break;case"ReflectionColor":n.envMap=r.getTexture(e,t.ID),void 0!==n.envMap&&(n.envMap.mapping=Z,n.envMap.colorSpace=Me);break;case"SpecularColor":n.specularMap=r.getTexture(e,t.ID),void 0!==n.specularMap&&(n.specularMap.colorSpace=Me);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=r.getTexture(e,t.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",i)}}),n}getTexture(t,e){return"LayeredTexture"in QT.Objects&&e in QT.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=tw.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in QT.Objects){const i=QT.Objects.Deformer;for(const n in i){const r=i[n],s=tw.get(parseInt(n));if("Skin"===r.attrType){const e=this.parseSkeleton(s,i);e.ID=n,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=s.parents[0].ID,t[n]=e}else if("BlendShape"===r.attrType){const t={id:n};t.rawTargets=this.parseMorphTargets(s,i),t.id=n,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[n]=t}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const i=[];return t.children.forEach(function(t){const n=e[t.ID];if("Cluster"!==n.attrType)return;const r={ID:t.ID,indices:[],weights:[],transformLink:(new Ui).fromArray(n.TransformLink.a)};"Indexes"in n&&(r.indices=n.Indexes.a,r.weights=n.Weights.a),i.push(r)}),{rawBones:i,bones:[]}}parseMorphTargets(t,e){const i=[];for(let n=0;n1?s=a:a.length>0?s=a[0]:(s=new Al({name:rh.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(s)),"color"in r.attributes&&a.forEach(function(t){t.vertexColors=!0}),r.groups.length>0){let t=!1;for(let e=0,i=r.groups.length;e=a.length)&&(i.materialIndex=a.length,t=!0)}if(t){const t=new Al;a.push(t)}}return r.FBX_Deformer?(n=new Ts(r,s),n.normalizeSkinWeights()):n=new ps(r,s),n}createCurve(t,e){const i=t.children.reduce(function(t,i){return e.has(i.ID)&&(t=e.get(i.ID)),t},null),n=new fa({name:rh.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Sa(i,n)}getTransformData(t,e){const i={};"InheritType"in e&&(i.inheritType=parseInt(e.InheritType.value)),i.eulerOrder=gw("RotationOrder"in e?e.RotationOrder.value:0),"Lcl_Translation"in e&&(i.translation=e.Lcl_Translation.value),"PreRotation"in e&&(i.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(i.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(i.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(i.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(i.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(i.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(i.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(i.rotationPivot=e.RotationPivot.value),t.userData.transformData=i}setLookAtProperties(t,e){if("LookAtProperty"in e){tw.get(t.ID).children.forEach(function(e){if("LookAtProperty"===e.relationship){const i=QT.Objects.Model[e.ID];if("Lcl_Translation"in i){const e=i.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),ew.add(t.target)):t.lookAt((new di).fromArray(e))}}})}}bindSkeleton(t,e,i){for(const n in t){const r=t[n],s=[];for(let t=0,e=r.bones.length;t0){const n=e[i].PoseNode;Array.isArray(n)?n.forEach(function(e){t[e.Node]=(new Ui).fromArray(e.Matrix.a)}):t[n.Node]=(new Ui).fromArray(n.Matrix.a)}}return t}addGlobalSceneSettings(){if("GlobalSettings"in QT){if("AmbientColor"in QT.GlobalSettings){const t=QT.GlobalSettings.AmbientColor.value,e=t[0],i=t[1],n=t[2];if(0!==e||0!==i||0!==n){const t=(new _n).setRGB(e,i,n,Me);ew.add(new Dh(t,1))}}"UnitScaleFactor"in QT.GlobalSettings&&(ew.userData.unitScaleFactor=QT.GlobalSettings.UnitScaleFactor.value)}}}class nw{constructor(){this.negativeMaterialIndices=!1}parse(t){const e=new Map;if("Geometry"in QT.Objects){const i=QT.Objects.Geometry;for(const n in i){const r=tw.get(parseInt(n)),s=this.parseGeometry(r,i[n],t);e.set(parseInt(n),s)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),e}parseGeometry(t,e,i){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,i);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,i){const n=i.skeletons,r=[],s=t.parents.map(function(t){return QT.Objects.Model[t.ID]});if(0===s.length)return;const a=t.children.reduce(function(t,e){return void 0!==n[e.ID]&&(t=n[e.ID]),t},null);t.children.forEach(function(t){void 0!==i.morphTargets[t.ID]&&r.push(i.morphTargets[t.ID])});const o=s[0],l={};"RotationOrder"in o&&(l.eulerOrder=gw(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const h=fw(l);return this.genGeometry(e,a,r,h)}genGeometry(t,e,i,n){const r=new Mr;t.attrName&&(r.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),o=new cr(a.vertex,3);if(o.applyMatrix4(n),r.setAttribute("position",o),a.colors.length>0&&r.setAttribute("color",new cr(a.colors,3)),e&&(r.setAttribute("skinIndex",new or(a.weightsIndices,4)),r.setAttribute("skinWeight",new cr(a.vertexWeights,4)),r.FBX_Deformer=e),a.normal.length>0){const t=(new fi).getNormalMatrix(n),e=new cr(a.normal,3);e.applyNormalMatrix(t),r.setAttribute("normal",e)}if(a.uvs.forEach(function(t,e){const i=0===e?"uv":`uv${e}`;r.setAttribute(i,new cr(a.uvs[e],2))}),s.material&&"AllSame"!==s.material.mappingType){let t=a.materialIndex[0],e=0;if(a.materialIndex.forEach(function(i,n){i!==t&&(r.addGroup(e,n-e,t),t=i,e=n)}),r.groups.length>0){const e=r.groups[r.groups.length-1],i=e.start+e.count;i!==a.materialIndex.length&&r.addGroup(i,a.materialIndex.length-i,t)}0===r.groups.length&&r.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(r,t,i,n),r}parseGeoNode(t,e){const i={};if(i.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],i.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&t.LayerElementColor[0].Colors&&(i.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(i.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(i.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){i.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&i.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return i.weightTable={},null!==e&&(i.skeleton=e,e.rawBones.forEach(function(t,e){t.indices.forEach(function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:e,weight:t.weights[r]})})})),i}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,n=0,r=!1,s=[],a=[],o=[],l=[],h=[],c=[];const u=this;return t.vertexIndices.forEach(function(d,p){let m,f=!1;d<0&&(d^=-1,f=!0);let g=[],y=[];if(s.push(3*d,3*d+1,3*d+2),t.color){const e=dw(p,i,d,t.color);o.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[d]&&t.weightTable[d].forEach(function(t){y.push(t.weight),g.push(t.id)}),y.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const t=[0,0,0,0],e=[0,0,0,0];y.forEach(function(i,n){let r=i,s=g[n];e.forEach(function(e,i,n){if(r>e){n[i]=r,r=e;const a=t[i];t[i]=s,s=a}})}),g=t,y=e}for(;y.length<4;)y.push(0),g.push(0);for(let t=0;t<4;++t)h.push(y[t]),c.push(g[t])}if(t.normal){const e=dw(p,i,d,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(m=dw(p,i,d,t.material)[0],m<0&&(u.negativeMaterialIndices=!0,m=0)),t.uv&&t.uv.forEach(function(t,e){const n=dw(p,i,d,t);void 0===l[e]&&(l[e]=[]),l[e].push(n[0]),l[e].push(n[1])}),n++,f&&(u.genFace(e,t,s,m,a,o,l,h,c,n),i++,n=0,s=[],a=[],o=[],l=[],h=[],c=[])}),e}getNormalNewell(t){const e=new di(0,0,0);for(let i=0;i.5?new di(0,1,0):new di(0,0,1)).cross(e).normalize(),n=e.clone().cross(i).normalize();return{normal:e,tangent:i,bitangent:n}}flattenVertex(t,e,i){return new ci(t.dot(e),t.dot(i))}genFace(t,e,i,n,r,s,a,o,l,h){let c;if(h>3){const t=[],n=e.baseVertexPositions||e.vertexPositions;for(let e=0;e1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=t.get(r[0].ID);i[n]={name:e[n].attrName,layer:s}}return i}addClip(t){let e=[];const i=this;return t.layer.forEach(function(t){e=e.concat(i.generateTracks(t))}),new $l(t.name,-1,e)}generateTracks(t){const e=[];let i=new di,n=new di;if(t.transform&&t.transform.decompose(i,new ui,n),i=i.toArray(),n=n.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.T.curves,i,"position");void 0!==n&&e.push(n)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const i=this.generateRotationTrack(t.modelName,t.R.curves,t.preRotation,t.postRotation,t.eulerOrder,t.initialRotation);void 0!==i&&e.push(i)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const i=this.generateVectorTrack(t.modelName,t.S.curves,n,"scale");void 0!==i&&e.push(i)}if(void 0!==t.DeformPercent){const i=this.generateMorphTrack(t);void 0!==i&&e.push(i)}return e}generateVectorTrack(t,e,i,n){const r=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(r,e,i);return new Jl(t+"."+n,r,s)}generateRotationTrack(t,e,i,n,r,s){let a,o;if(void 0!==e.x||void 0!==e.y||void 0!==e.z){const t=this.getTimesForAllAxes(e);if(t.length>0){const i=s||[0,0,0],n=this.synchronizeCurve(e.x,t,i[0]),l=this.synchronizeCurve(e.y,t,i[1]),h=this.synchronizeCurve(e.z,t,i[2]),c=this.interpolateRotations(n,l,h,r);a=c[0],o=c[1]}}const l=gw(0);void 0!==i&&((i=i.map(hi.degToRad)).push(l),i=(new Xi).fromArray(i),i=(new ui).setFromEuler(i)),void 0!==n&&((n=n.map(hi.degToRad)).push(l),n=(new Xi).fromArray(n),n=(new ui).setFromEuler(n).invert());const h=new ui,c=new Xi,u=[];if(o&&a){for(let t=0;t2){(new ui).fromArray(u,(t-3)/3*4).dot(h)<0&&h.set(-h.x,-h.y,-h.z,-h.w)}h.toArray(u,t/3*4)}return new Zl(t+".quaternion",a,u)}}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,i=e.values.map(function(t){return t/100}),n=ew.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new ql(t.modelName+".morphTargetInfluences["+n+"]",e.times,i)}getTimesForAllAxes(t){let e=[];if(void 0!==t.x&&(e=e.concat(t.x.times)),void 0!==t.y&&(e=e.concat(t.y.times)),void 0!==t.z&&(e=e.concat(t.z.times)),e=e.sort(function(t,e){return t-e}),e.length>1){let t=1,i=e[0];for(let n=1;ni)};if(t.times.length===e.length)return t;const n=[];for(let r=0;r=n[n.length-1])return r[r.length-1];for(let t=0;t=n[t]&&e<=n[t+1]){if(n[t]===e)return r[t];const i=(e-n[t])/(n[t+1]-n[t]);return r[t]*(1-i)+r[t+1]*i}return i}interpolateRotations(t,e,i,n){const r=[],s=[];r.push(t.times[0]),s.push(hi.degToRad(t.values[0])),s.push(hi.degToRad(e.values[0])),s.push(hi.degToRad(i.values[0]));for(let a=1;a=180||d[1]>=180||d[2]>=180){const e=Math.max(...d)/180,i=new Xi(...l,n),o=new Xi(...c,n),h=(new ui).setFromEuler(i),u=(new ui).setFromEuler(o);h.dot(u)<0&&u.set(-u.x,-u.y,-u.z,-u.w);const p=t.times[a-1],m=t.times[a]-p,f=new ui,g=new Xi;for(let t=0;t<1;t+=1/e)f.copy(h.clone().slerp(u.clone(),t)),r.push(p+t*m),g.setFromQuaternion(f,n),s.push(g.x),s.push(g.y),s.push(g.z)}else r.push(t.times[a]),s.push(hi.degToRad(t.values[a])),s.push(hi.degToRad(e.values[a])),s.push(hi.degToRad(i.values[a]))}return[r,s]}}class sw{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new lw,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,i=t.split(/[\r\n]+/);return i.forEach(function(t,n){const r=t.match(/^[\s\t]*;/),s=t.match(/^[\s\t]*$/);if(r||s)return;const a=t.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),o=t.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=t.match("^\\t{"+(e.currentIndent-1)+"}}");a?e.parseNodeBegin(t,a):o?e.parseNodeProperty(t,o,i[++n]):l?e.popStack():t.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(t)}),this.allNodes}parseNodeBegin(t,e){const i=e[1].trim().replace(/^"/,"").replace(/"$/,""),n=e[2].split(",").map(function(t){return t.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:i},s=this.parseNodeAttr(n),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(i,r):i in a?("PoseNode"===i?a.PoseNode.push(r):void 0!==a[i].id&&(a[i]={},a[i][a[i].id]=a[i]),""!==s.id&&(a[i][s.id]=r)):"number"==typeof s.id?(a[i]={},a[i][s.id]=r):"Properties70"!==i&&(a[i]="PoseNode"===i?[r]:r),"number"==typeof s.id&&(r.id=s.id),""!==s.name&&(r.attrName=s.name),""!==s.type&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(t){let e=t[0];""!==t[0]&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let i="",n="";return t.length>1&&(i=t[1].replace(/^(\w+)::/,""),n=t[2]),{id:e,name:i,type:n}}parseNodeProperty(t,e,i){let n=e[1].replace(/^"/,"").replace(/"$/,"").trim(),r=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===n){const t=r.split(",").slice(1),e=parseInt(t[0]),i=parseInt(t[1]);let a=r.split(",").slice(3);a=a.map(function(t){return t.trim().replace(/^"/,"")}),n="connections",r=[e,i],function(t,e){for(let i=0,n=t.length,r=e.length;i=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const i={},n=e>=7500?t.getUint64():t.getUint32(),r=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const s=t.getUint8(),a=t.getString(s);if(0===n)return null;const o=[];for(let e=0;e0?o[0]:"",h=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(i.singleProperty=1===r&&t.getOffset()===n;n>t.getOffset();){const n=this.parseNode(t,e);null!==n&&this.parseSubNode(a,i,n)}return i.propertyList=o,"number"==typeof l&&(i.id=l),""!==h&&(i.attrName=h),""!==c&&(i.attrType=c),""!==a&&(i.name=a),i}parseSubNode(t,e,i){if(!0===i.singleProperty){const t=i.propertyList[0];Array.isArray(t)?(e[i.name]=i,i.a=t):e[i.name]=t}else if("Connections"===t&&"C"===i.name){const t=[];i.propertyList.forEach(function(e,i){0!==i&&t.push(e)}),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===i.name){Object.keys(i).forEach(function(t){e[t]=i[t]})}else if("Properties70"===t&&"P"===i.name){let t=i.propertyList[0],n=i.propertyList[1];const r=i.propertyList[2],s=i.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),a="Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],e[t]={type:n,type2:r,flag:s,value:a}}else void 0===e[i.name]?"number"==typeof i.id?(e[i.name]={},e[i.name][i.id]=i):e[i.name]=i:"PoseNode"===i.name?(Array.isArray(e[i.name])||(e[i.name]=[e[i.name]]),e[i.name].push(i)):void 0===e[i.name][i.id]&&(e[i.name][i.id]=i)}parseProperty(t){const e=t.getString(1);let i;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return i=t.getUint32(),t.getArrayBuffer(i);case"S":return i=t.getUint32(),t.getString(i);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=t.getUint32(),r=t.getUint32(),s=t.getUint32();if(0===r)switch(e){case"b":case"c":return t.getBooleanArray(n);case"d":return t.getFloat64Array(n);case"f":return t.getFloat32Array(n);case"i":return t.getInt32Array(n);case"l":return t.getInt64Array(n)}const a=qT(new Uint8Array(t.getArrayBuffer(s))),o=new ow(a.buffer);switch(e){case"b":case"c":return o.getBooleanArray(n);case"d":return o.getFloat64Array(n);case"f":return o.getFloat32Array(n);case"i":return o.getInt32Array(n);case"l":return o.getInt64Array(n)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class ow{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return!(1&~this.getUint8())}getBooleanArray(t){const e=[];for(let i=0;i=0&&(i=new Uint8Array(this.dv.buffer,e,n)),this._textDecoder.decode(i)}}class lw{add(t,e){this[t]=e}}function hw(t){const e=t.match(/FBXVersion: (\d+)/);if(e){return parseInt(e[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function cw(t){return t/46186158e3}const uw=[];function dw(t,e,i,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=t;break;case"ByPolygon":r=e;break;case"ByVertice":r=i;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(r=n.indices[r]);const s=r*n.dataSize,a=s+n.dataSize;return function(t,e,i,n){for(let r=i,s=0;r=e.length&&e===_w(t,0,e.length)}(t))QT=(new aw).parse(t);else{const e=_w(t);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let i=0;function n(e){const n=t[e-1];return t=t.slice(i+e),i++,n}for(let t=0;t=this.arr.length}next(){return this.arr[this.i++]}}var Mw=Object.freeze({__proto__:null,PLYLoader:class extends rh{constructor(t){super(t),this.propertyNameMapping={},this.customPropertyMapping={}}load(t,e,i,n){const r=this,s=new oh(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(i){try{e(r.parse(i))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}setPropertyNameMapping(t){this.propertyNameMapping=t}setCustomPropertyNameMapping(t){this.customPropertyMapping=t}parse(t){function e(t,e=0){let i="";const n=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(t);null!==n&&(i=n[1]);const r={comments:[],elements:[],headerLength:e,objInfo:""},s=i.split(/\r\n|\r|\n/);let a;function o(t,e){const i={type:t[0]};return"list"===i.type?(i.name=t[3],i.countType=t[1],i.itemType=t[2]):i.name=t[1],i.name in e&&(i.name=e[i.name]),i}for(let t=0;tt.name);function i(t){for(let i=0,n=t.length;i0&&e.setIndex(t.indices),e.setAttribute("position",new cr(t.vertices,3)),t.normals.length>0&&e.setAttribute("normal",new cr(t.normals,3)),t.uvs.length>0&&e.setAttribute("uv",new cr(t.uvs,2)),t.colors.length>0&&e.setAttribute("color",new cr(t.colors,3)),(t.faceVertexUvs.length>0||t.faceVertexColors.length>0)&&(e=e.toNonIndexed(),t.faceVertexUvs.length>0&&e.setAttribute("uv",new cr(t.faceVertexUvs,2)),t.faceVertexColors.length>0&&e.setAttribute("color",new cr(t.faceVertexColors,3)));for(const i of Object.keys(d.customPropertyMapping))t[i].length>0&&e.setAttribute(i,new cr(t[i],d.customPropertyMapping[i].length));return e.computeBoundingSphere(),e}function l(t,e,i,n){if("vertex"===e){t.vertices.push(i[n.attrX],i[n.attrY],i[n.attrZ]),null!==n.attrNX&&null!==n.attrNY&&null!==n.attrNZ&&t.normals.push(i[n.attrNX],i[n.attrNY],i[n.attrNZ]),null!==n.attrS&&null!==n.attrT&&t.uvs.push(i[n.attrS],i[n.attrT]),null!==n.attrR&&null!==n.attrG&&null!==n.attrB&&(xw.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255,Me),t.colors.push(xw.r,xw.g,xw.b));for(const e of Object.keys(d.customPropertyMapping))for(const n of d.customPropertyMapping[e])t[e].push(i[n])}else if("face"===e){const e=i.vertex_indices||i.vertex_index,r=i.texcoord;3===e.length?(t.indices.push(e[0],e[1],e[2]),r&&6===r.length&&(t.faceVertexUvs.push(r[0],r[1]),t.faceVertexUvs.push(r[2],r[3]),t.faceVertexUvs.push(r[4],r[5]))):4===e.length&&(t.indices.push(e[0],e[1],e[3]),t.indices.push(e[1],e[2],e[3])),null!==n.attrR&&null!==n.attrG&&null!==n.attrB&&(xw.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255,Me),t.faceVertexColors.push(xw.r,xw.g,xw.b),t.faceVertexColors.push(xw.r,xw.g,xw.b),t.faceVertexColors.push(xw.r,xw.g,xw.b))}}function h(t,e){const i={};let n=0;for(let r=0;rt.getInt8(e),size:1};case"uint8":case"uchar":return{read:e=>t.getUint8(e),size:1};case"int16":case"short":return{read:e=>t.getInt16(e,i),size:2};case"uint16":case"ushort":return{read:e=>t.getUint16(e,i),size:2};case"int32":case"int":return{read:e=>t.getInt32(e,i),size:4};case"uint32":case"uint":return{read:e=>t.getUint32(e,i),size:4};case"float32":case"float":return{read:e=>t.getFloat32(e,i),size:4};case"float64":case"double":return{read:e=>t.getFloat64(e,i),size:8}}}for(let r=0,s=t.length;r256||24!==t.colormap_size||1!==t.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case n:case r:case a:case o:if(t.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case e:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+t.image_type)}if(t.width<=0||t.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==t.pixel_size&&16!==t.pixel_size&&24!==t.pixel_size&&32!==t.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+t.pixel_size)}(g),g.id_length+m>t.length)throw new Error("THREE.TGALoader: No data.");m+=g.id_length;let y=!1,_=!1,v=!1;switch(g.image_type){case s:y=!0,_=!0;break;case i:_=!0;break;case a:y=!0;break;case n:break;case o:y=!0,v=!0;break;case r:v=!0}const x=new Uint8Array(g.width*g.height*4),b=function(t,e,i,n,r){let s,a;const o=i.pixel_size>>3,l=i.width*i.height*o;if(e&&(a=r.subarray(n,n+=i.colormap_length*(i.colormap_size>>3))),t){let t,e,i;s=new Uint8Array(l);let a=0;const h=new Uint8Array(o);for(;a>h){default:case d:s=0,o=1,f=e,a=0,m=1,y=i;break;case c:s=0,o=1,f=e,a=i-1,m=-1,y=-1;break;case p:s=e-1,o=-1,f=-1,a=0,m=1,y=i;break;case u:s=e-1,o=-1,f=-1,a=i-1,m=-1,y=-1}if(v)switch(g.pixel_size){case 8:!function(t,e,i,n,r,s,a,o){let l,h,c,u=0;const d=g.width;for(c=e;c!==n;c+=i)for(h=r;h!==a;h+=s,u++)l=o[u],t[4*(h+d*c)+0]=l,t[4*(h+d*c)+1]=l,t[4*(h+d*c)+2]=l,t[4*(h+d*c)+3]=255}(t,a,m,y,s,o,f,n);break;case 16:!function(t,e,i,n,r,s,a,o){let l,h,c=0;const u=g.width;for(h=e;h!==n;h+=i)for(l=r;l!==a;l+=s,c+=2)t[4*(l+u*h)+0]=o[c+0],t[4*(l+u*h)+1]=o[c+0],t[4*(l+u*h)+2]=o[c+0],t[4*(l+u*h)+3]=o[c+1]}(t,a,m,y,s,o,f,n);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(t,e,i,n,r,s,a,o,l){const h=l;let c,u,d,p=0;const m=g.width;for(d=e;d!==n;d+=i)for(u=r;u!==a;u+=s,p++)c=o[p],t[4*(u+m*d)+3]=255,t[4*(u+m*d)+2]=h[3*c+0],t[4*(u+m*d)+1]=h[3*c+1],t[4*(u+m*d)+0]=h[3*c+2]}(t,a,m,y,s,o,f,n,r);break;case 16:!function(t,e,i,n,r,s,a,o){let l,h,c,u=0;const d=g.width;for(c=e;c!==n;c+=i)for(h=r;h!==a;h+=s,u+=2)l=o[u+0]+(o[u+1]<<8),t[4*(h+d*c)+0]=(31744&l)>>7,t[4*(h+d*c)+1]=(992&l)>>2,t[4*(h+d*c)+2]=(31&l)<<3,t[4*(h+d*c)+3]=32768&l?0:255}(t,a,m,y,s,o,f,n);break;case 24:!function(t,e,i,n,r,s,a,o){let l,h,c=0;const u=g.width;for(h=e;h!==n;h+=i)for(l=r;l!==a;l+=s,c+=3)t[4*(l+u*h)+3]=255,t[4*(l+u*h)+2]=o[c+0],t[4*(l+u*h)+1]=o[c+1],t[4*(l+u*h)+0]=o[c+2]}(t,a,m,y,s,o,f,n);break;case 32:!function(t,e,i,n,r,s,a,o){let l,h,c=0;const u=g.width;for(h=e;h!==n;h+=i)for(l=r;l!==a;l+=s,c+=4)t[4*(l+u*h)+2]=o[c+0],t[4*(l+u*h)+1]=o[c+1],t[4*(l+u*h)+0]=o[c+2],t[4*(l+u*h)+3]=o[c+3]}(t,a,m,y,s,o,f,n);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(x,g.width,g.height,b.pixel_data,b.palettes),{data:x,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:at}}}function Tw(t,e){const i=[],n=t.childNodes;for(let t=0,r=n.length;tparseInt(t))}function Cw(t){return t.substring(1)}class Rw{constructor(){this.count=0}generateId(){return"three_default_"+this.count++}parse(t){if(0===t.length)return null;const e=(new DOMParser).parseFromString(t,"application/xml"),i=Tw(e,"COLLADA")[0],n=e.getElementsByTagName("parsererror")[0];if(void 0!==n){const t=Tw(n,"div")[0];let e;return e=t?t.textContent:this.parserErrorToText(n),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",e),null}const r=i.getAttribute("version");console.debug("THREE.ColladaLoader: File version",r);const s=this.parseAsset(Tw(i,"asset")[0]),a={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{},joints:{}};return this.library=a,this.collada=i,this.parseLibrary(i,"library_animations","animation",this.parseAnimation.bind(this)),this.parseLibrary(i,"library_animation_clips","animation_clip",this.parseAnimationClip.bind(this)),this.parseLibrary(i,"library_controllers","controller",this.parseController.bind(this)),this.parseLibrary(i,"library_images","image",this.parseImage.bind(this)),this.parseLibrary(i,"library_effects","effect",this.parseEffect.bind(this)),this.parseLibrary(i,"library_materials","material",this.parseMaterial.bind(this)),this.parseLibrary(i,"library_cameras","camera",this.parseCamera.bind(this)),this.parseLibrary(i,"library_lights","light",this.parseLight.bind(this)),this.parseLibrary(i,"library_geometries","geometry",this.parseGeometry.bind(this)),this.parseLibrary(i,"library_nodes","node",this.parseNode.bind(this)),this.parseLibrary(i,"library_visual_scenes","visual_scene",this.parseVisualScene.bind(this)),this.parseLibrary(i,"library_joints","joint",this.parseLibraryJoint.bind(this)),this.parseLibrary(i,"library_kinematics_models","kinematics_model",this.parseKinematicsModel.bind(this)),this.parseLibrary(i,"library_physics_models","physics_model",this.parsePhysicsModel.bind(this)),this.parseLibrary(i,"scene","instance_kinematics_scene",this.parseKinematicsScene.bind(this)),{library:a,asset:s,collada:i}}parserErrorToText(t){const e=[],i=[t];for(;i.length;){const t=i.shift();t.nodeType===Node.TEXT_NODE?e.push(t.textContent):(e.push("\n"),i.push(...t.childNodes))}return e.join("").trim()}parseAsset(t){return{unit:this.parseAssetUnit(Tw(t,"unit")[0]),upAxis:this.parseAssetUpAxis(Tw(t,"up_axis")[0])}}parseAssetUnit(t){return void 0!==t&&!0===t.hasAttribute("meter")?parseFloat(t.getAttribute("meter")):1}parseAssetUpAxis(t){return void 0!==t?t.textContent:"Y_UP"}parseLibrary(t,e,i,n){const r=Tw(t,e)[0];if(void 0!==r){const t=Tw(r,i);for(let e=0;e0?i+s:i;e.inputs[a]={id:t,offset:r},e.stride=Math.max(e.stride,r+1),"TEXCOORD"===i&&(e.hasUV=!0);break;case"vcount":e.vcount=Aw(n.textContent);break;case"p":e.p=Aw(n.textContent)}}return"polygons"===e.type&&(e.vcount=[e.p.length/e.stride]),e}parseLibraryJoint(t){this.library.joints[t.getAttribute("id")]=this.parseKinematicsJoint(t)}parseKinematicsModel(t){const e={name:t.getAttribute("name")||"",joints:{},links:[]};for(let i=0;i=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}parseKinematicsLink(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]};for(let i=0;i0&&c.dot(h)<0&&(h.x=-h.x,h.y=-h.y,h.z=-h.z,h.w=-h.w),c.copy(h),d.push(h.x,h.y,h.z,h.w)}const m=new Zl(t.uuid+".quaternion",o,d);this.applyInterpolation(m,p),s.push(m)}buildScaleTrack(t,e,i,n){if(e.default&&3===e.default.stride){const i=e.default,r=Array.from(i.times),s=Array.from(i.values),a=new Jl(t.uuid+".scale",r,s),o=this.getInterpolationInfo(e);return this.applyInterpolation(a,o,e),void n.push(a)}const r=this.getTimesForAllAxes(e);if(0===r.length)return;const s=[],a=this.getInterpolationInfo(e);for(let t=0;tt-e),e}getValueAtTime(t,e,i){if(!t)return i;const n=t.times,r=t.values,s=t.interpolation;for(let i=0;ie){if(0===i)return r[0];const a=i-1,o=i,l=n[a],h=n[o],c=r[a],u=r[o],d=s?s[a]:"LINEAR";if("STEP"===d)return c;if("BEZIER"===d&&t.inTangent&&t.outTangent)return this.evaluateBezierComponent(t,a,o,l,h,e);return c+(e-l)/(h-l)*(u-c)}}return r[r.length-1]}evaluateBezierComponent(t,e,i,n,r,s){const a=t.values,o=t.inTangent,l=t.outTangent,h=t.inTangentStride||1,c=a[e],u=a[i];let d,p,m,f;2===h?(d=l[2*e],p=l[2*e+1],m=o[2*i],f=o[2*i+1]):(d=n+(r-n)/3,p=l[e],m=r-(r-n)/3,f=o[i]);let g=(s-n)/(r-n);for(let t=0;t<8;t++){const t=g*g,e=1-g,i=e*e,a=i*e*n+3*i*g*d+3*e*t*m+t*g*r,o=3*i*(d-n)+6*e*g*(m-d)+3*t*(r-m);if(Math.abs(o)<1e-10)break;const l=a-s;if(Math.abs(l)<1e-10)break;g-=l/o,g=Math.max(0,Math.min(1,g))}const y=g*g,_=1-g,v=_*_;return v*_*c+3*v*g*p+3*_*y*f+y*g*u}getInterpolationInfo(t){const e=["X","Y","Z","ANGLE","default"];let i=null,n=!0;for(const r of e){const e=t[r];if(!e||!e.interpolation)continue;const s=e.interpolation;for(let t=0;tt.time-e.time);for(let t=0;t<16;t++)this.transformAnimationData(i,t,e.elements[t]);return i}createKeyframeTracks(t,e){const i=t.keyframes,n=t.name,r=[],s=[],a=[],o=[],l=this.position,h=this.quaternion,c=this.scale,u=this.matrix;for(let t=0,e=i.length;t0&&e.push(new Jl(n+".position",r,s)),a.length>0&&e.push(new Zl(n+".quaternion",r,a)),o.length>0&&e.push(new Jl(n+".scale",r,o)),e}transformAnimationData(t,e,i){let n,r,s,a=!0;for(r=0,s=t.length;r=0;){const n=t[e];if(null!==n.value[i])return n;e--}return null}getNext(t,e,i){for(;e>>0)+2);if(i=i.toLowerCase(),"tga"===i)e=this.tgaLoader;else e=this.textureLoader;return e}buildMaterial(t){const e=this.getEffect(t.url),i=e.profile.technique;let n;switch(i.type){case"phong":case"blinn":n=new Al;break;case"lambert":n=new Nl;break;default:n=new es}n.name=t.name||"";const r=this;function s(t,i=null){const n=e.profile.samplers[t.id];let s=null;if(void 0!==n){const t=e.profile.surfaces[n.source];s=r.getImage(t.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),s=r.getImage(t.id);if(null!==s){const e=r.getTextureLoader(s);if(void 0!==e){const n=e.load(s),a=t.extra;if(void 0!==a&&void 0!==a.technique&&!1===r.isEmpty(a.technique)){const t=a.technique;n.wrapS=t.wrapU?$:Q,n.wrapT=t.wrapV?$:Q,n.offset.set(t.offsetU||0,t.offsetV||0),n.repeat.set(t.repeatU||1,t.repeatV||1)}else n.wrapS=$,n.wrapT=$;return null!==i&&(n.colorSpace=i),n}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",s),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}const a=i.parameters;for(const t in a){const e=a[t];switch(t){case"diffuse":e.color&&n.color.fromArray(e.color),e.texture&&(n.map=s(e.texture,Me));break;case"specular":e.color&&n.specular&&n.specular.fromArray(e.color),e.texture&&(n.specularMap=s(e.texture));break;case"bump":e.texture&&(n.normalMap=s(e.texture));break;case"ambient":e.texture&&(n.lightMap=s(e.texture,Me));break;case"shininess":e.float&&n.shininess&&(n.shininess=e.float);break;case"emission":e.color&&n.emissive&&n.emissive.fromArray(e.color),e.texture&&(n.emissiveMap=s(e.texture,Me))}}xi.colorSpaceToWorking(n.color,Me),n.specular&&xi.colorSpaceToWorking(n.specular,Me),n.emissive&&xi.colorSpaceToWorking(n.emissive,Me);let o=a.transparent,l=a.transparency;if(void 0===l&&o&&(l={float:1}),void 0===o&&l&&(o={opaque:"A_ONE",data:{color:[1,1,1,1]}}),o&&l)if(o.data.texture)n.transparent=!0;else{const t=o.data.color;switch(o.opaque){case"A_ONE":n.opacity=t[3]*l.float;break;case"RGB_ZERO":n.opacity=1-t[0]*l.float;break;case"A_ZERO":n.opacity=1-t[3]*l.float;break;case"RGB_ONE":n.opacity=t[0]*l.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',o.opaque)}n.opacity<1&&(n.transparent=!0)}if(void 0!==i.extra&&void 0!==i.extra.technique){const t=i.extra.technique;for(const e in t){const i=t[e];switch(e){case"double_sided":n.side=1===i?2:0;break;case"bump":n.normalMap=s(i.texture),n.normalScale=new ci(1,1)}}}return n}getMaterial(t){return this.getBuild(this.library.materials[t],this.buildMaterial.bind(this))}buildCamera(t){let e;switch(t.optics.technique){case"perspective":e=new Eh(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let i=t.optics.parameters.ymag,n=t.optics.parameters.xmag;const r=t.optics.parameters.aspect_ratio;n=void 0===n?i*r:n,i=void 0===i?n/r:i,n*=.5,i*=.5,e=new Ih(-n,n,i,-i,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:e=new Eh}return e.name=t.name||"",e}getCamera(t){const e=this.library.cameras[t];return void 0!==e?this.getBuild(e,this.buildCamera.bind(this)):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",t),null)}buildLight(t){let e;switch(t.technique){case"directional":e=new Lh;break;case"point":e=new Nh;break;case"spot":e=new Ch;break;case"ambient":e=new Dh}return t.parameters.color&&e.color.copy(t.parameters.color),t.parameters.distance&&(e.distance=t.parameters.distance),t.parameters.falloffAngle&&(e.angle=hi.degToRad(t.parameters.falloffAngle)),e}getLight(t){const e=this.library.lights[t];return void 0!==e?this.getBuild(e,this.buildLight.bind(this)):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",t),null)}groupPrimitives(t){const e={};for(let i=0;i0&&e0&&p.setAttribute("position",new cr(r.array,r.stride)),s.array.length>0&&p.setAttribute("normal",new cr(s.array,s.stride)),l.array.length>0&&p.setAttribute("color",new cr(l.array,l.stride)),a.array.length>0&&p.setAttribute("uv",new cr(a.array,a.stride)),o.array.length>0&&p.setAttribute("uv1",new cr(o.array,o.stride)),h.length>0&&p.setAttribute("skinIndex",new cr(h,c)),u.length>0&&p.setAttribute("skinWeight",new cr(u,d)),n.data=p,n.type=t[0].type,n.materialKeys=m,n}buildGeometryData(t,e,i,n,r=!1){const s=t.p,a=t.stride,o=t.vcount,l=this.tempColor;function h(t){let e=s[t+i]*u;const a=e+u;for(;e4){const e=[];for(let n=0;nMath.abs(n.y)&&Math.abs(n.x)>Math.abs(n.z))for(let t=0;tMath.abs(n.z))for(let t=0;tn.limits.max||e0&&l.dot(o)<0&&(o.x=-o.x,o.y=-o.y,o.z=-o.z,o.w=-o.w),l.copy(o),h.push(o.x,o.y,o.z,o.w)}const u=new Zl(t.uuid+".quaternion",s,h);this.applyInterpolation(u,c),n.push(u)}buildHierarchyScaleTrack(t,e,i,n){if(e.default&&3===e.default.stride){const i=e.default,r=new Jl(t.uuid+".scale",Array.from(i.times),Array.from(i.values)),s=this.getInterpolationInfo(e);return this.applyInterpolation(r,s,e),void n.push(r)}const r=this.getTimesForAllAxes(e);if(0===r.length)return;const s=[],a=this.getInterpolationInfo(e);for(let t=0;t>5&31)/31,s=(t>>10&31)/31)}for(let o=1;o<=3;o++){const l=i+12*o,h=3*t*3+3*(o-1);p[h]=e.getFloat32(l,!0),p[h+1]=e.getFloat32(l+4,!0),p[h+2]=e.getFloat32(l+8,!0),m[h]=c,m[h+1]=d,m[h+2]=g,u&&(f.setRGB(n,r,s,Me),a[h]=f.r,a[h+1]=f.g,a[h+2]=f.b)}}return d.setAttribute("position",new ar(p,3)),d.setAttribute("normal",new ar(m,3)),u&&(d.setAttribute("color",new ar(a,3)),d.hasColors=!0,d.alpha=c),d}(i):function(t){const e=new Mr,i=/solid([\s\S]*?)endsolid/g,n=/facet([\s\S]*?)endfacet/g,r=/solid\s(.+)/;let s=0;const a=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+a+a+a,"g"),l=new RegExp("normal"+a+a+a,"g"),h=[],c=[],u=[],d=new di;let p,m=0,f=0,g=0;for(;null!==(p=i.exec(t));){f=g;const t=p[0],i=null!==(p=r.exec(t))?p[1]:"";for(u.push(i);null!==(p=n.exec(t));){let t=0,e=0;const i=p[0];for(;null!==(p=l.exec(i));)d.x=parseFloat(p[1]),d.y=parseFloat(p[2]),d.z=parseFloat(p[3]),e++;for(;null!==(p=o.exec(i));)h.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),c.push(d.x,d.y,d.z),t++,g++;1!==e&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+s),3!==t&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+s),s++}const a=f,y=g-f;e.userData.groupNames=u,e.addGroup(a,y,m),m++}return e.setAttribute("position",new cr(h,3)),e.setAttribute("normal",new cr(c,3)),e}(function(t){return"string"!=typeof t?(new TextDecoder).decode(t):t}(t))}}});var Lw=Object.freeze({__proto__:null,XYZLoader:class extends rh{load(t,e,i,n){const r=this,s=new oh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(i){try{e(r.parse(i))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}parse(t){const e=t.split("\n"),i=[],n=[],r=new _n;for(let t of e){if(t=t.trim(),"#"===t.charAt(0))continue;const e=t.split(/\s+/);if(3===e.length&&(i.push(parseFloat(e[0])),i.push(parseFloat(e[1])),i.push(parseFloat(e[2]))),6===e.length){i.push(parseFloat(e[0])),i.push(parseFloat(e[1])),i.push(parseFloat(e[2]));const t=parseFloat(e[3])/255,s=parseFloat(e[4])/255,a=parseFloat(e[5])/255;r.setRGB(t,s,a,Me),n.push(r.r,r.g,r.b)}}const s=new Mr;return s.setAttribute("position",new cr(i,3)),n.length>0&&s.setAttribute("color",new cr(n,3)),s}}});class Dw{constructor(t,e,i){this.data=t,this.offset=e,this.position=e,this.debugMessage=i,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>t.byteLength&&this.debugMessage("Bad chunk size for chunk at "+e)}readChunk(){if(this.endOfChunk)return null;try{const t=new Dw(this.data,this.position,this.debugMessage);return this.position+=t.size,t}catch(t){return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const t=this.data.getUint8(this.position,!0);return this.position+=1,t}readFloat(){try{const t=this.data.getFloat32(this.position,!0);return this.position+=4,t}catch(t){return this.debugMessage(t+" "+this.position+" "+this.data.byteLength),0}}readInt(){const t=this.data.getInt32(this.position,!0);return this.position+=4,t}readShort(){const t=this.data.getInt16(this.position,!0);return this.position+=2,t}readDWord(){const t=this.data.getUint32(this.position,!0);return this.position+=4,t}readWord(){const t=this.data.getUint16(this.position,!0);return this.position+=2,t}readString(){let t="",e=this.readByte();for(;e;)t+=String.fromCharCode(e),e=this.readByte();return t}}const Ow=19789,Uw=15786,Fw=49725,zw=2,kw=16,Bw=17,Vw=18,Gw=19,Hw=48,Ww=49,jw=15677,Xw=15678,qw=256,Yw=45055,Zw=40960,Kw=40976,Jw=40992,$w=41008,Qw=41024,tE=41040,eE=41089,iE=41091,nE=41093,rE=41095,sE=41472,aE=41488,oE=41520,lE=41476,hE=41728,cE=41812,uE=41814,dE=41816,pE=41818,mE=16384,fE=16640,gE=16656,yE=16672,_E=16688,vE=16704,xE=16736;var bE=Object.freeze({__proto__:null,TDSLoader:class extends rh{constructor(t){super(t),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(t,e,i,n){const r=this,s=""===this.path?kh.extractUrlBase(t):this.path,a=new oh(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){try{e(r.parse(i,s))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}},i,n)}parse(t,e){this.group=new un,this.materials=[],this.meshes=[],this.readFile(t,e);for(let t=0;t"rgb"===t),i=e.type[t],n=parseFloat(c[l.rgb]);let s=n;if("F"===i){const t=new Float32Array(1);t[0]=n,s=new Int32Array(t.buffer)[0]}const a=(s>>16&255)/255,h=(s>>8&255)/255,u=(255&s)/255;o.setRGB(a,h,u,Me),r.push(o.r,o.g,o.b)}void 0!==l.normal_x&&(n.push(parseFloat(c[l.normal_x])),n.push(parseFloat(c[l.normal_y])),n.push(parseFloat(c[l.normal_z]))),void 0!==l.intensity&&s.push(parseFloat(c[l.intensity])),void 0!==l.label&&a.push(parseInt(c[l.label]))}}if("binary_compressed"===e.data){const l=new Uint32Array(t.slice(e.headerLen,e.headerLen+8)),h=l[0],c=l[1],u=function(t,e){const i=t.length,n=new Uint8Array(e);let r,s,a,o=0,l=0;do{if(r=t[o++],r<32){if(r++,l+r>e)throw new Error("Output buffer is not large enough");if(o+r>i)throw new Error("Invalid compressed data");do{n[l++]=t[o++]}while(--r)}else{if(s=r>>5,a=l-((31&r)<<8)-1,o>=i)throw new Error("Invalid compressed data");if(7===s&&(s+=t[o++],o>=i))throw new Error("Invalid compressed data");if(a-=t[o++],l+s+2>e)throw new Error("Output buffer is not large enough");if(a<0)throw new Error("Invalid compressed data");if(a>=l)throw new Error("Invalid compressed data");do{n[l++]=n[a++]}while(2+--s)}}while(o0&&l.setAttribute("position",new cr(i,3)),n.length>0&&l.setAttribute("normal",new cr(n,3)),r.length>0&&l.setAttribute("color",new cr(r,3)),s.length>0&&l.setAttribute("intensity",new cr(s,1)),a.length>0&&l.setAttribute("label",new lr(a,1)),l.computeBoundingSphere();const h=new Ra({size:.005});return r.length>0&&(h.vertexColors=!0),new Da(l,h)}}});function SE(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new Mr;let h=0;for(let c=0;c=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class jE{constructor(t){this.parser=t,this.name=NE.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return i.loadTextureImage(t,s.source,o)}}class XE{constructor(t){this.parser=t,this.name=NE.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return i.loadTextureImage(t,s.source,o)}}class qE{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(e){const i=t.byteOffset||0,n=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then(function(t){return t.buffer}):r.ready.then(function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e})})}return null}}class YE{constructor(t){this.name=NE.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=e.meshes[i.mesh];for(const t of n.primitives)if(t.mode!==sA.TRIANGLES&&t.mode!==sA.TRIANGLE_STRIP&&t.mode!==sA.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=i.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then(e=>(a[t]=e,a[t])));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then(t=>{const e=t.pop(),i=e.isGroup?e.children:[e],n=t[0].count,r=[];for(const t of i){const e=new Ui,i=new di,s=new ui,o=new di(1,1,1),l=new zs(t.geometry,t.material,n);for(let t=0;t-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&n<17||r&&s<98?this.textureLoader=new dh(this.options.manager):this.textureLoader=new qh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(t){return t._markDefs&&t._markDefs()}),Promise.all(this._invokeAll(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(e){const s={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};return yA(r,s,n),_A(s,n),Promise.all(i._invokeAll(function(t){return t.afterRoot&&t.afterRoot(s)})).then(function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=e.length;i{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,n]of t.children.entries())r(n,e.children[i])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p})}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t].source,r=e.images[n];let s=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,n,s)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,i).then(function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const i=(r.samplers||{})[s.sampler]||{};return e.magFilter=oA[i.magFilter]||rt,e.minFilter=oA[i.minFilter]||at,e.wrapS=lA[i.wrapS]||$,e.wrapT=lA[i.wrapT]||$,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==et&&e.minFilter!==rt,n.associations.set(e,{textures:t}),e}).catch(function(){return null});return this.textureCache[o]=l,l}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(t=>t.clone());const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=i.getDependency("bufferView",s.bufferView).then(function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o});else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then(function(t){return new Promise(function(i,n){let s=i;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Ni(t);e.needsUpdate=!0,i(e)}),e.load(kh.resolveURL(t,r.path),s,void 0,n)})}).then(function(t){var e;return!0===l&&a.revokeObjectURL(o),_A(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t}).catch(function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t});return this.sourceCache[t]=h,h}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),r.extensions[NE.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[NE.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[NE.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==n&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new Ra,Cr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new fa,Cr.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,this.cache.add(t,e)),i=e}if(n||r||s){let t="ClonedMaterial:"+i.uuid+":";n&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}t.material=i}getMaterialType(){return wl}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=[];if((r.extensions||{})[NE.KHR_MATERIALS_UNLIT]){const t=n[NE.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const i=r.pbrMetallicRoughness||{};if(a.color=new _n(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],Se),a.opacity=t[3]}void 0!==i.baseColorTexture&&o.push(e.assignTexture(a,"map",i.baseColorTexture,Me)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne(function(e){return e.getMaterialType&&e.getMaterialType(t)}),o.push(Promise.all(this._invokeAll(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)})))}!0===r.doubleSided&&(a.side=2);const l=r.alphaMode||pA;if(l===fA?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===mA&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==es&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new ci(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==es&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==es){const t=r.emissiveFactor;a.emissive=(new _n).setRGB(t[0],t[1],t[2],Se)}return void 0!==r.emissiveTexture&&s!==es&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Me)),Promise.all(o).then(function(){const i=new s(a);return r.name&&(i.name=r.name),_A(i,r),e.associations.set(i,{materials:t}),r.extensions&&yA(n,i,r),i})}createUniqueName(t){const e=bc.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[NE.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then(function(i){return wA(i,t,e)})}const s=[];for(let i=0,a=t.length;i0&&vA(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),_A(u,r),c.extensions&&yA(n,u,c),e.assignFinalMaterial(u),l.push(u)}for(let i=0,n=l.length;i0){const t=e.userData.pivot,n=i[0];e.pivot=(new di).fromArray(t),e.position.x-=t[0],e.position.y-=t[1],e.position.z-=t[2],n.position.set(0,0,0),delete e.userData.pivot}return e})}_loadNodeShallow(t){const e=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?n.createUniqueName(r.name):"",a=[],o=n._invokeOne(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return o&&a.push(o),void 0!==r.camera&&a.push(n.getDependency("camera",r.camera).then(function(t){return n._getNodeRef(n.cameraCache,r.camera,t)})),n._invokeAll(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(t){a.push(t)}),this.nodeCache[t]=Promise.all(a).then(function(e){let a;if(a=!0===r.isBone?new ws:e.length>1?new un:1===e.length?e[0]:new cn,a!==e[0])for(let t=0,i=e.length;t1){const t=n.associations.get(a);n.associations.set(a,{...t})}}else n.associations.set(a,{});return n.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const e=this.extensions,i=this.json.scenes[t],n=this,r=new un;i.name&&(r.name=n.createUniqueName(i.name)),_A(r,i),i.extensions&&yA(e,r,i);const s=i.nodes||[],a=[];for(let t=0,e=s.length;t{const e=new Map;for(const[t,i]of n.associations)(t instanceof Cr||t instanceof Ni)&&e.set(t,i);return t.traverse(t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)}),e})(r),r})}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];function l(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)}let h;switch(uA[r.path]===uA.weights?(l(t),t.isGroup&&t.children.forEach(l)):o.push(a),uA[r.path]){case uA.weights:h=ql;break;case uA.rotation:h=Zl;break;case uA.translation:case uA.scale:h=Jl;break;default:if(1===i.itemSize)h=ql;else h=Jl}const c=void 0!==n.interpolation?dA[n.interpolation]:pe,u=this._getArrayFromAccessor(i);for(let t=0,i=o.length;t=2.0 are supported.")));const l=new TA(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(i,n)}parseAsync(t,e){const i=this;return new Promise(function(n,r){i.parse(t,e,n,r)})}}});const AA=new WeakMap;function CA(){let t,e;function i(t,e,i,n,r,s){const a=i.num_points(),o=s.num_components(),l=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}(t,r),h=o*r.BYTES_PER_ELEMENT,c=4*Math.ceil(h/4),u=c/r.BYTES_PER_ELEMENT,d=a*h,p=a*c,m=t._malloc(d);e.GetAttributeDataArrayForAllPoints(i,s,l,d,m);const f=new r(t.HEAPF32.buffer,m,d/r.BYTES_PER_ELEMENT);let g;if(h===c)g=f.slice();else{g=new r(p/r.BYTES_PER_ELEMENT);let t=0;for(let e=0,i=f.length;e{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,n,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const h=e.GetEncodedGeometryType(n);if(h===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(n,n.byteLength,o);else{if(h!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(n,n.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const c={index:null,attributes:[]};for(const n in s){const l=self[a[n]];let h,u;if(r.useUniqueIDs)u=s[n],h=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[n]]),-1===u)continue;h=e.GetAttribute(o,u)}const d=i(t,e,o,n,l,h);"color"===n&&(d.vertexColorSpace=r.vertexColorSpace),c.attributes.push(d)}h===t.TRIANGULAR_MESH&&(c.index=function(t,e,i){const n=i.num_faces(),r=3*n,s=4*r,a=t._malloc(s);e.GetTrianglesUInt32Array(i,s,a);const o=new Uint32Array(t.HEAPF32.buffer,a,r).slice();return t._free(a),{array:o,itemSize:1}}(t,e,o));return t.destroy(o),c}(e,a,new Int8Array(n),s),o=t.attributes.map(t=>t.array.buffer);t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}})}}}var RA=Object.freeze({__proto__:null,DRACOLoader:class extends rh{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,n){const r=new oh(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,t=>{this.parse(t,e,n)},i,n)}parse(t,e,i=()=>{}){this.decodeDracoFile(t,e,null,null,Me,i).catch(i)}decodeDracoFile(t,e,i,n,r=Se,s=()=>{}){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(t,a).then(e).catch(s)}decodeGeometry(t,e){const i=JSON.stringify(e);if(AA.has(t)){const e=AA.get(t);if(e.key===i)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then(i=>(n=i,new Promise((i,s)=>{n._callbacks[r]={resolve:i,reject:s},n.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))).then(t=>this._createGeometry(t.geometry));return a.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),AA.set(t,{key:i,promise:a}),a}_createGeometry(t){const e=new Mr;t.index&&e.setIndex(new ar(t.index.array,1));for(let i=0;i{i.load(t,e,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(e=>{const i=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const n=CA.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.lengthe._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t{e.isMesh&&(t.add(e.geometry),t.add(e.material))});for(const e of t)e.dispose()}}});var PA=Object.freeze({__proto__:null,HDRLoader:class extends uh{constructor(t){super(t),this.type=mt}parse(t){const e=function(t,e){switch(t){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(e||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(e||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(e||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(e||""))}},i=function(t,e,i){e=e||1024;let n=t.pos,r=-1,s=0,a="",o=String.fromCharCode.apply(null,new Uint16Array(t.subarray(n,n+128)));for(;0>(r=o.indexOf("\n"))&&s=t.byteLength||!(l=i(t)))&&e(1,"no header found"),(h=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=h[1],o.string+=l+"\n";l=i(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(n))&&(o.gamma=parseFloat(h[1])),(h=l.match(r))&&(o.exposure=parseFloat(h[1])),(h=l.match(s))&&(o.valid|=2,o.format=h[1]),(h=l.match(a))&&(o.valid|=4,o.height=parseInt(h[1],10),o.width=parseInt(h[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,h=function(t,i,n){const r=i;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*i*n);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,h=new Uint8Array(4),c=new Uint8Array(l);let u=n;for(;u>0&&ot.byteLength&&e(1),h[0]=t[o++],h[1]=t[o++],h[2]=t[o++],h[3]=t[o++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==r||e(3,"bad rgbe scanline format");let i,n=0;for(;n128;if(r&&(i-=128),(0===i||n+i>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t