dfg_3dviewer_js_library/dist/library/assets/three.js
2026-06-25 09:19:26 +02:00

19 lines
1.2 MiB

/**
* @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<n;i++)e[i].call(this,t);t.target=null}}};const Qe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ti=1234567;const ei=Math.PI/180,ii=180/Math.PI;function ni(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Qe[255&t]+Qe[t>>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;t<r.length;t++)r[t]=255*bi(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*bi(e[t]/255)):e[t]=bi(e[t]);return{data:e,width:t.width,height:t.height}}return Ye("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},wi=0,Ei=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wi++}),this.uuid=ni(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(Ai(n[e].image)):t.push(Ai(n[e]))}else t=Ai(n);i.url=t}return e||(t.images[this.uuid]=i),i}};function Ai(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Ti.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Ye("Texture: Unable to serialize Texture."),{})}let Ci=0;const Ri=new di;let Ni=class t extends $e{constructor(e=t.DEFAULT_IMAGE,i=t.DEFAULT_MAPPING,n=1001,r=1001,s=1006,a=1008,o=1023,l=ot,h=t.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ci++}),this.uuid=ni(),this.name="",this.source=new Ei(e),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ci(0,0),this.repeat=new ci(1,1),this.center=new ci(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),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)<s&&Math.abs(c-m)<s&&Math.abs(p-f)<s){if(Math.abs(h+u)<a&&Math.abs(c+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,y=(g+1)/2,_=(h+u)/4,v=(c+m)/4,x=(p+f)/4;return t>o&&t>y?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=_/i,r=v/i):o>y?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=_/n,r=x/n):y<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(y),i=v/r,n=x/r),this.set(i,n,r,e),this}let y=Math.sqrt((f-p)*(f-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(f-p)/y,this.y=(c-m)/y,this.z=(u-h)/y,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=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.w=ri(this.w,t.w,e.w),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.w=ri(this.w,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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,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.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Pi=class extends $e{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rt,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 Ii(0,0,t,e),this.scissorTest=!1,this.viewport=new Ii(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},r=new Ni(n),s=i.count;for(let t=0;t<s;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(t={}){const e={minFilter:rt,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let t=0;t<this.textures.length;t++){this.textures[t].setValues(e)}}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,!0!==this.textures[n].isData3DTexture&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Ei(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}};class Li extends Pi{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Di extends Ni{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=et,this.minFilter=et,this.wrapR=Q,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Oi extends Ni{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=et,this.minFilter=et,this.wrapR=Q,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}let Ui=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/Fi.setFromMatrixColumn(t,0).length(),r=1/Fi.setFromMatrixColumn(t,1).length(),s=1/Fi.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(ki,t,Bi)}lookAt(t,e,i){const n=this.elements;return Hi.subVectors(t,e),0===Hi.lengthSq()&&(Hi.z=1),Hi.normalize(),Vi.crossVectors(i,Hi),0===Vi.lengthSq()&&(1===Math.abs(i.z)?Hi.x+=1e-4:Hi.z+=1e-4,Hi.normalize(),Vi.crossVectors(i,Hi)),Vi.normalize(),Gi.crossVectors(Hi,Vi),n[0]=Vi.x,n[4]=Gi.x,n[8]=Hi.x,n[1]=Vi.y,n[5]=Gi.y,n[9]=Hi.y,n[2]=Vi.z,n[6]=Gi.z,n[10]=Hi.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=Fi.set(n[0],n[1],n[2]).length();const a=Fi.set(n[4],n[5],n[6]).length(),o=Fi.set(n[8],n[9],n[10]).length();r<0&&(s=-s),zi.copy(this);const l=1/s,h=1/a,c=1/o;return zi.elements[0]*=l,zi.elements[1]*=l,zi.elements[2]*=l,zi.elements[4]*=h,zi.elements[5]*=h,zi.elements[6]*=h,zi.elements[8]*=c,zi.elements[9]*=c,zi.elements[10]*=c,e.setFromRotationMatrix(zi),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===Fe)p=-(s+r)/(s-r),m=-2*s*r/(s-r);else{if(a!==ze)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===Fe)p=-2/(s-r),m=-(s+r)/(s-r);else{if(a!==ze)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 Fi=new di,zi=new Ui,ki=new di(0,0,0),Bi=new di(1,1,1),Vi=new di,Gi=new di,Hi=new di,Wi=new Ui,ji=new ui;let Xi=class t{constructor(e=0,i=0,n=0,r=t.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=i,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,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(ri(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(-ri(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(ri(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(-ri(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(ri(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(-ri(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:Ye("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Wi.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Wi,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ji.setFromEuler(this),this.setFromQuaternion(ji,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}};Xi.DEFAULT_ORDER="XYZ";class qi{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let Yi=0;const Zi=new di,Ki=new ui,Ji=new Ui,$i=new di,Qi=new di,tn=new di,en=new ui,nn=new di(1,0,0),rn=new di(0,1,0),sn=new di(0,0,1),an={type:"added"},on={type:"removed"},ln={type:"childadded",child:null},hn={type:"childremoved",child:null};class cn extends $e{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Yi++}),this.uuid=ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=cn.DEFAULT_UP.clone();const t=new di,e=new Xi,i=new ui,n=new di(1,1,1);e._onChange(function(){i.setFromEuler(e,!1)}),i._onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ui},normalMatrix:{value:new fi}}),this.matrix=new Ui,this.matrixWorld=new Ui,this.matrixAutoUpdate=cn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ki.setFromAxisAngle(t,e),this.quaternion.multiply(Ki),this}rotateOnWorldAxis(t,e){return Ki.setFromAxisAngle(t,e),this.quaternion.premultiply(Ki),this}rotateX(t){return this.rotateOnAxis(nn,t)}rotateY(t){return this.rotateOnAxis(rn,t)}rotateZ(t){return this.rotateOnAxis(sn,t)}translateOnAxis(t,e){return Zi.copy(t).applyQuaternion(this.quaternion),this.position.add(Zi.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(nn,t)}translateY(t){return this.translateOnAxis(rn,t)}translateZ(t){return this.translateOnAxis(sn,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ji.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?$i.copy(t):$i.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Qi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ji.lookAt(Qi,$i,this.up):Ji.lookAt($i,Qi,this.up),this.quaternion.setFromRotationMatrix(Ji),n&&(Ji.extractRotation(n.matrixWorld),Ki.setFromRotationMatrix(Ji),this.quaternion.premultiply(Ki.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(Ze("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(an),ln.child=t,this.dispatchEvent(ln),ln.child=null):Ze("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(on),hn.child=t,this.dispatchEvent(hn),hn.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ji.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Ji.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ji),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(an),ln.child=t,this.dispatchEvent(ln),ln.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let r=0,s=n.length;r<s;r++)n[r].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,t,tn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,en,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,i=t.y,n=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*i-r[8]*n,r[13]+=i-r[1]*e-r[5]*i-r[9]*n,r[14]+=n-r[2]*e-r[6]*i-r[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){e[i].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),!1!==this.static&&(n.static=this.static),Object.keys(this.userData).length>0&&(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;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=s(t.geometries),n=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),h=s(t.animations),c=s(t.nodes);e.length>0&&(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;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}}cn.DEFAULT_UP=new di(0,1,0),cn.DEFAULT_MATRIX_AUTO_UPDATE=!0,cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;let un=class extends cn{constructor(){super(),this.isGroup=!0,this.type="Group"}};const dn={type:"move"};class pn{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new un,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new un,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new di,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new di),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new un,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new di,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new di,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i),r=this._getHandJoint(l,n);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const n=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=n.position.distanceTo(r.position),o=.02,h=.005;l.inputState.pinching&&a>o+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+(n<r?6:0);break;case n:o=(r-i)/t+2;break;case r:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=xi.workingColorSpace){return xi.workingToColorSpace(vn.copy(this),e),t.r=vn.r,t.g=vn.g,t.b=vn.b,t}getStyle(t=Me){xi.workingToColorSpace(vn.copy(this),t);const e=vn.r,i=vn.g,n=vn.b;return t!==Me?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(fn),this.setHSL(fn.h+t,fn.s+e,fn.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(fn),t.getHSL(gn);const i=ai(fn.h,gn.h,e),n=ai(fn.s,gn.s,e),r=ai(fn.l,gn.l,e);return this.setHSL(i,n,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,r=t.elements;return this.r=r[0]*e+r[3]*i+r[6]*n,this.g=r[1]*e+r[4]*i+r[7]*n,this.b=r[2]*e+r[5]*i+r[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const vn=new _n;_n.NAMES=mn;class xn{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new _n(t),this.density=e}clone(){return new xn(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class bn{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new _n(t),this.near=e,this.far=i}clone(){return new bn(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Mn extends cn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Xi,this.environmentIntensity=1,this.environmentRotation=new Xi,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(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<i;e+=3)this.expandByPoint(kn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(kn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=kn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,i=n.count;e<i;e++)!0===t.isMesh?t.getVertexPosition(e,kn):kn.fromBufferAttribute(n,e),kn.applyMatrix4(t.matrixWorld),this.expandByPoint(kn);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Bn.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Bn.copy(i.boundingBox)),Bn.applyMatrix4(t.matrixWorld),this.union(Bn)}const n=t.children;for(let t=0,i=n.length;t<i;t++)this.expandByObject(n[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,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;n<r;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)rr.fromBufferAttribute(this,e),rr.applyMatrix3(t),this.setXY(e,rr.x,rr.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.applyMatrix3(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.applyMatrix4(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.applyNormalMatrix(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.transformDirection(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=oi(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=li(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=oi(e,this.array)),e}setX(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=oi(e,this.array)),e}setY(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=oi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=oi(e,this.array)),e}setW(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array),r=li(r,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Oe&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}};class or extends ar{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class lr extends ar{constructor(t,e,i){super(new Int32Array(t),e,i)}}class hr extends ar{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class cr extends ar{constructor(t,e,i){super(new Float32Array(t),e,i)}}const ur=new Fn,dr=new di,pr=new di;let mr=class{constructor(t=new di,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):ur.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;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;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}this.setAttribute("position",new cr(e,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const i=t[n];e.setXYZ(n,i.x,i.y,i.z||0)}t.length>e.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;t<i;t++){const i=e[t];vr.setFromBufferAttribute(i),this.morphTargetsRelative?(br.addVectors(this.boundingBox.min,vr.min),this.boundingBox.expandByPoint(br),br.addVectors(this.boundingBox.max,vr.max),this.boundingBox.expandByPoint(br)):(this.boundingBox.expandByPoint(vr.min),this.boundingBox.expandByPoint(vr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ze('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new mr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new di,1/0);if(t){const i=this.boundingSphere.center;if(vr.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];xr.setFromBufferAttribute(i),this.morphTargetsRelative?(br.addVectors(vr.min,xr.min),vr.expandByPoint(br),br.addVectors(vr.max,xr.max),vr.expandByPoint(br)):(vr.expandByPoint(xr.min),vr.expandByPoint(xr.max))}vr.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)br.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(br));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)br.fromBufferAttribute(s,e),a&&(_r.fromBufferAttribute(t,e),br.add(_r)),n=Math.max(n,i.distanceToSquared(br))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void Ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.position,n=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ar(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let t=0;t<i.count;t++)a[t]=new di,o[t]=new di;const l=new di,h=new di,c=new di,u=new ci,d=new ci,p=new ci,m=new di,f=new di;function g(t,e,n){l.fromBufferAttribute(i,t),h.fromBufferAttribute(i,e),c.fromBufferAttribute(i,n),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,n),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(s),f.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(s),a[t].add(m),a[e].add(m),a[n].add(m),o[t].add(f),o[e].add(f),o[n].add(f))}let y=this.groups;0===y.length&&(y=[{start:0,count:t.count}]);for(let e=0,i=y.length;e<i;++e){const i=y[e],n=i.start;for(let e=n,r=n+i.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const _=new di,v=new di,x=new di,b=new di;function M(t){x.fromBufferAttribute(n,t),b.copy(x);const e=a[t];_.copy(e),_.sub(x.multiplyScalar(x.dot(e))).normalize(),v.crossVectors(b,e);const i=v.dot(o[t])<0?-1:1;s.setXYZW(t,_.x,_.y,_.z,i)}for(let e=0,i=y.length;e<i;++e){const i=y[e],n=i.start;for(let e=n,r=n+i.count;e<r;e+=3)M(t.getX(e+0)),M(t.getX(e+1)),M(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new ar(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new di,r=new di,s=new di,a=new di,o=new di,l=new di,h=new di,c=new di;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),m=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),h.subVectors(s,r),c.subVectors(n,r),h.cross(c),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),a.add(h),o.add(h),l.add(h),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),c.subVectors(n,r),h.cross(c),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)br.fromBufferAttribute(t,e),br.normalize(),t.setXYZ(e,br.x,br.y,br.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,s=new i.constructor(e.length*n);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*n;for(let t=0;t<n;t++)s[o++]=i[a++]}return new ar(s,n,r)}if(null===this.index)return Ye("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Mr,i=this.index.array,n=this.attributes;for(const r in n){const s=t(n[r],i);e.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],a=r[n];for(let e=0,n=a.length;e<n;e++){const n=t(a[e],i);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.addGroup(i.start,i.count,i.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),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;e<n;e++){const n=i[e];s.push(n.toJSON(t.data))}s.length>0&&(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;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Sr=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Oe,this.updateRanges=[],this.version=0,this.uuid=ni()}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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=ni()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=ni()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const Tr=new di;let wr,Er=class t{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Tr.fromBufferAttribute(this,e),Tr.applyMatrix4(t),this.setXYZ(e,Tr.x,Tr.y,Tr.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Tr.fromBufferAttribute(this,e),Tr.applyNormalMatrix(t),this.setXYZ(e,Tr.x,Tr.y,Tr.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Tr.fromBufferAttribute(this,e),Tr.transformDirection(t),this.setXYZ(e,Tr.x,Tr.y,Tr.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=oi(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=li(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=li(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=li(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=li(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=li(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=oi(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=oi(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=oi(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=oi(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=li(e,this.array),i=li(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array),r=li(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this}clone(e){if(void 0===e){Xe("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new ar(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new t(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){Xe("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Ar=0;class Cr extends $e{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ar++}),this.uuid=ni(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=f,this.blendDst=g,this.blendEquation=l,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _n(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ee,this.stencilZFail=Ee,this.stencilZPass=Ee,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(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);o<t.near||o>t.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;t<i;t++){const i=e[t];this.addLevel(i.object.clone(),i.distance,i.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,i=0){e=Math.abs(e);const n=this.levels;let r;for(r=0;r<n.length&&!(e<n[r].distance);r++);return n.splice(r,0,{distance:e,hysteresis:i,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let i=0;i<e.length;i++)if(e[i].distance===t){const t=e.splice(i,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n;i++){let n=e[i].distance;if(e[i].object.visible&&(n-=n*e[i].hysteresis),t<n)break}return e[i-1].object}return null}raycast(t,e){if(this.levels.length>0){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<r;n++){let t=e[n].distance;if(e[n].object.visible&&(t-=t*e[n].hysteresis),!(i>=t))break;e[n-1].object.visible=!1,e[n].object.visible=!0}for(this._currentLevel=n-1;n<r;n++)e[n].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let t=0,n=i.length;t<n;t++){const n=i[t];e.object.levels.push({object:n.object.uuid,distance:n.distance,hysteresis:n.hysteresis})}return e}}const qr=new di,Yr=new di,Zr=new di,Kr=new di,Jr=new di,$r=new di,Qr=new di;class ts{constructor(t=new di,e=new di(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,qr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=qr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(qr.copy(this.origin).addScaledVector(this.direction,e),qr.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Yr.copy(t).add(e).multiplyScalar(.5),Zr.copy(e).sub(t).normalize(),Kr.copy(this.origin).sub(Yr);const r=.5*t.distanceTo(e),s=-this.direction.dot(Zr),a=Kr.dot(this.direction),o=-Kr.dot(Zr),l=Kr.lengthSq(),h=Math.abs(1-s*s);let c,u,d,p;if(h>0)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<n||isNaN(n))&&(n=s),c>=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<n||n!=n)&&(n=o),n<0?null:this.at(i>=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<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,s=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(r&&a){cs.set(0,0,0);for(let i=0,n=r.length;i<n;i++){const n=a[i],o=r[i];0!==n&&(hs.fromBufferAttribute(o,t),s?cs.addScaledVector(hs,n):cs.addScaledVector(hs.sub(e),n))}e.add(cs)}return e}raycast(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),rs.copy(i.boundingSphere),rs.applyMatrix4(r),ns.copy(t.ray).recast(t.near),!1===rs.containsPoint(ns.origin)){if(null===ns.intersectSphere(rs,ss))return;if(ns.origin.distanceToSquared(ss)>(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;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){n=ms(this,p,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=o.materialIndex,e.push(n))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){n=ms(this,s,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){n=ms(this,p,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=a.materialIndex,e.push(n))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){n=ms(this,s,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}}}function ms(t,e,i,n,r,s,a,o,l,h){t.getVertexPosition(o,as),t.getVertexPosition(l,os),t.getVertexPosition(h,ls);const c=function(t,e,i,n,r,s,a,o){let l;if(l=1===e.side?n.intersectTriangle(a,s,r,!0,o):n.intersectTriangle(r,s,a,0===e.side,o),null===l)return null;ds.copy(o),ds.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(ds);return h<i.near||h>i.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;t<e.count;t++)this.getVertexPosition(t,xs),this.boundingBox.expandByPoint(xs)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new mr),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,xs),this.boundingSphere.expandByPoint(xs)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),bs.copy(this.boundingSphere),bs.applyMatrix4(n),!1!==t.ray.intersectsSphere(bs)&&(Ms.copy(n).invert(),Ss.copy(t.ray).applyMatrix4(Ms),null!==this.boundingBox&&!1===Ss.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Ss)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Ii,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===W?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===j?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ye("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;gs.fromBufferAttribute(n.attributes.skinIndex,t),ys.fromBufferAttribute(n.attributes.skinWeight,t),e.isVector4?(fs.copy(e),e.set(0,0,0,0)):(fs.set(...e,1),e.set(0,0,0)),fs.applyMatrix4(this.bindMatrix);for(let t=0;t<4;t++){const n=ys.getComponent(t);if(0!==n){const r=gs.getComponent(t);vs.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(_s.copy(fs).applyMatrix4(vs),n)}}return e.isVector4&&(e.w=fs.w),e.applyMatrix4(this.bindMatrixInverse)}}class ws extends cn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Es extends Ni{constructor(t=null,e=1,i=1,n,r,s,a,o,l=1003,h=1003,c,u){super(null,s,a,o,l,h,n,r,c,u),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const As=new Ui,Cs=new Ui;class Rs{constructor(t=[],e=[]){this.uuid=ni(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){Ye("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Ui)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Ui;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const r=t[n]?t[n].matrixWorld:Cs;As.multiplyMatrices(r,e[n]),As.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new Rs(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new Es(e,t,t,Mt,pt);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const n=t.bones[i];let r=e[n];void 0===r&&(Ye("Skeleton: No bone found with UUID:",n),r=new ws),this.bones.push(r),this.boneInverses.push((new Ui).fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,r=e.length;n<r;n++){const r=e[n];t.bones.push(r.uuid);const s=i[n];t.boneInverses.push(s.toArray())}return t}}class Ns extends ar{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Is=new Ui,Ps=new Ui,Ls=[],Ds=new Fn,Os=new Ui,Us=new ps,Fs=new mr;class zs extends ps{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ns(new Float32Array(16*i),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<i;t++)this.setMatrixAt(t,Os)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Fn),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Is),Ds.copy(t.boundingBox).applyMatrix4(Is),this.boundingBox.union(Ds)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new mr),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Is),Fs.copy(t.boundingSphere).applyMatrix4(Is),this.boundingSphere.union(Fs)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.previousInstanceMatrix&&(this.previousInstanceMatrix=t.previousInstanceMatrix.clone()),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return null===this.instanceColor?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const i=e.morphTargetInfluences,n=this.morphTexture.source.data.data,r=t*(i.length+1)+1;for(let t=0;t<i.length;t++)i[t]=n[r+t]}raycast(t,e){const i=this.matrixWorld,n=this.count;if(Us.geometry=this.geometry,Us.material=this.material,void 0!==Us.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Fs.copy(this.boundingSphere),Fs.applyMatrix4(i),!1!==t.ray.intersectsSphere(Fs)))for(let r=0;r<n;r++){this.getMatrixAt(r,Is),Ps.multiplyMatrices(i,Is),Us.matrixWorld=Ps,Us.raycast(t,Ls);for(let t=0,i=Ls.length;t<i;t++){const i=Ls[t];i.instanceId=r,i.object=this,e.push(i)}Ls.length=0}}setColorAt(t,e){return null===this.instanceColor&&(this.instanceColor=new Ns(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,16*t),this}setMorphAt(t,e){const i=e.morphTargetInfluences,n=i.length+1;null===this.morphTexture&&(this.morphTexture=new Es(new Float32Array(n*this.count),n,this.count,wt,pt));const r=this.morphTexture.source.data.data;let s=0;for(let t=0;t<i.length;t++)s+=i[t];const a=this.geometry.morphTargetsRelative?1:1-s,o=n*t;return r[o]=a,r.set(i,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const ks=new di,Bs=new di,Vs=new fi;class Gs{constructor(t=new di(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=ks.subVectors(i,e).cross(Bs.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,i=!0){const n=t.delta(ks),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return!0===i&&(s<0||s>1)?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)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(js.x=n.normal.x>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<e.cameras.length;i++){const n=e.cameras[i];if(qs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ys.setFromProjectionMatrix(qs,n.coordinateSystem,n.reversedDepth),Ys.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let i=0;i<e.cameras.length;i++){const n=e.cameras[i];if(qs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ys.setFromProjectionMatrix(qs,n.coordinateSystem,n.reversedDepth),Ys.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let i=0;i<e.cameras.length;i++){const n=e.cameras[i];if(qs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ys.setFromProjectionMatrix(qs,n.coordinateSystem,n.reversedDepth),Ys.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let i=0;i<e.cameras.length;i++){const n=e.cameras[i];if(qs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ys.setFromProjectionMatrix(qs,n.coordinateSystem,n.reversedDepth),Ys.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let i=0;i<e.cameras.length;i++){const n=e.cameras[i];if(qs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ys.setFromProjectionMatrix(qs,n.coordinateSystem,n.reversedDepth),Ys.containsPoint(t))return!0}return!1}clone(){return new Zs}}function Ks(t,e){return t-e}function Js(t,e){return t.z-e.z}function $s(t,e){return e.z-t.z}class Qs{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,i,n){const r=this.pool,s=this.list;this.index>=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;s<r;s++)for(let r=0;r<n;r++)e.setComponent(s+i,r,t.getComponent(s,r))}else e.array.set(t.array,i*n);e.needsUpdate=!0}function pa(t,e){if(t.constructor!==e.constructor){const i=Math.min(t.length,e.length);for(let n=0;n<i;n++)e[n]=t[n]}else{const i=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,i))}}class ma extends ps{constructor(t,e,i=2*e,n){super(new Mr,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),i=new Es(e,t,t,Mt,pt);this._matricesTexture=i}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),i=new Es(e,t,t,Et,dt);this._indirectTexture=i}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),i=new Es(e,t,t,Mt,pt);i.colorSpace=xi.workingColorSpace,this._colorsTexture=i}_initializeGeometry(t){const e=this.geometry,i=this._maxVertexCount,n=this._maxIndexCount;if(!1===this._geometryInitialized){for(const n in t.attributes){const r=t.getAttribute(n),{array:s,itemSize:a,normalized:o}=r,l=new s.constructor(i*a),h=new ar(l,a,o);e.setAttribute(n,h)}if(null!==t.getIndex()){const t=i>65535?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<n;i++){if(!1===e[i].active)continue;const n=e[i].geometryIndex;this.getMatrixAt(i,ta),this.getBoundingBoxAt(n,ra).applyMatrix4(ta),t.union(ra)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new mr);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let i=0,n=e.length;i<n;i++){if(!1===e[i].active)continue;const n=e[i].geometryIndex;this.getMatrixAt(i,ta),this.getBoundingSphereAt(n,sa).applyMatrix4(ta),t.union(sa)}}addInstance(t){if(this._instanceInfo.length>=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;t++){const e=o+t;for(let t=0;t<s;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(o*s,l*s)}if(n){const t=a.indexStart,i=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let e=0;e<s.count;e++)r.setX(t+e,o+s.getX(e));for(let e=s.count,n=i;e<n;e++)r.setX(t+e,o);r.needsUpdate=!0,r.addUpdateRange(t,a.reservedIndexCount)}return a.start=n?a.indexStart:a.vertexStart,a.count=n?a.indexCount:a.vertexCount,a.boundingBox=null,null!==e.boundingBox&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,null!==e.boundingSphere&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const i=this._instanceInfo;for(let e=0,n=i.length;e<n;e++)i[e].active&&i[e].geometryIndex===t&&this.deleteInstance(e);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const i=this._geometryInfo,n=i.map((t,e)=>e).sort((t,e)=>i[t].vertexStart-i[e].vertexStart),r=this.geometry;for(let s=0,a=i.length;s<a;s++){const a=n[s],o=i[a];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==e){const{indexStart:i,vertexStart:n,reservedIndexCount:s}=o,a=r.index,l=a.array,h=t-n;for(let t=i;t<i+s;t++)l[t]=l[t]+h;a.array.copyWithin(e,i,i+s),a.addUpdateRange(e,s),a.needsUpdate=!0,o.indexStart=e}e+=o.reservedIndexCount}if(o.vertexStart!==t){const{vertexStart:e,reservedVertexCount:i}=o,n=r.attributes;for(const r in n){const s=n[r],{array:a,itemSize:o}=s;a.copyWithin(t*o,e*o,(e+i)*o),s.addUpdateRange(t*o,i*o),s.needsUpdate=!0}o.vertexStart=t}t+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=e,this._nextVertexStart=t,this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=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<s;i++){let n=i;e&&(n=e.getX(n)),t.expandByPoint(aa.fromBufferAttribute(r,n))}n.boundingBox=t}return e.copy(n.boundingBox),e}getBoundingSphereAt(t,e){if(t>=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;t<i;t++){let i=t;r&&(i=r.getX(i)),aa.fromBufferAttribute(s,i),a=Math.max(a,e.center.distanceToSquared(aa))}e.radius=Math.sqrt(a),n.boundingSphere=e}return e.copy(n.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const i=this._matricesTexture,n=this._matricesTexture.image.data;return e.toArray(n,16*t),i.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture?e.isVector4?e.set(1,1,1,1):e.setRGB(1,1,1):e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const i=this._geometryInfo[t];return e.vertexStart=i.vertexStart,e.vertexCount=i.vertexCount,e.reservedVertexCount=i.reservedVertexCount,e.indexStart=i.indexStart,e.indexCount=i.indexCount,e.reservedIndexCount=i.reservedIndexCount,e.start=i.start,e.count=i.count,e}setInstanceCount(t){const e=this._availableInstanceIds,i=this._instanceInfo;for(e.sort(Ks);e[e.length-1]===i.length-1;)i.pop(),e.pop();if(t<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const n=new Int32Array(t),r=new Int32Array(t);pa(this._multiDrawCounts,n),pa(this._multiDrawStarts,r),this._multiDrawCounts=n,this._multiDrawStarts=r,this._maxInstanceCount=t;const s=this._indirectTexture,a=this._matricesTexture,o=this._colorsTexture;s.dispose(),this._initIndirectTexture(),pa(s.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),pa(a.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),pa(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const i=[...this._geometryInfo].filter(t=>t.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<a;s++){if(!i[s].visible||!i[s].active)continue;const a=i[s].geometryIndex,o=n[a];ca.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(s,ca.matrixWorld).premultiply(r),this.getBoundingBoxAt(a,ca.geometry.boundingBox),this.getBoundingSphereAt(a,ca.geometry.boundingSphere),ca.raycast(t,ua);for(let t=0,i=ua.length;t<i;t++){const i=ua[t];i.object=this,i.batchId=s,e.push(i)}ua.length=0}ca.material=null,ca.geometry.index=null,ca.geometry.attributes={},ca.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(t=>({...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;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;this.getMatrixAt(t,ta),this.getBoundingSphereAt(e,sa).applyMatrix4(ta);let n=!1;if(d&&(n=!f.intersectsSphere(sa,i)),!n){const i=u[e],n=la.subVectors(sa.center,aa).dot(oa);ha.push(i.start,i.count,n,t)}}const t=ha.list,e=this.customSort;null===e?t.sort(r.transparent?$s:Js):e.call(this,t,i);for(let e=0,i=t.length;e<i;e++){const i=t[e];h[g]=i.start*a*o,c[g]=i.count*o,m[g]=i.index,g++}ha.reset()}else for(let t=0,e=l.length;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;let n=!1;if(d&&(this.getMatrixAt(t,ta),this.getBoundingSphereAt(e,sa).applyMatrix4(ta),n=!f.intersectsSphere(sa,i)),!n){const i=u[e];h[g]=i.start*a*o,c[g]=i.count*o,m[g]=t,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(t,e,i,n,r,s){this.onBeforeRender(t,null,n,r,s)}}class fa extends Cr{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _n(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const ga=new di,ya=new di,_a=new Ui,va=new ts,xa=new mr,ba=new di,Ma=new di;class Sa extends cn{constructor(t=new Mr,e=new fa){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)ga.fromBufferAttribute(e,t-1),ya.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=ga.distanceTo(ya);t.setAttribute("lineDistance",new cr(i,1))}else Ye("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),xa.copy(i.boundingSphere),xa.applyMatrix4(n),xa.radius+=r,!1===t.ray.intersectsSphere(xa))return;_a.copy(n).invert(),va.copy(t.ray).applyMatrix4(_a);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,h=i.index,c=i.attributes.position;if(null!==h){const i=Math.max(0,s.start),n=Math.min(h.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=h.getX(r),n=h.getX(r+1),s=Ta(this,t,va,o,i,n,r);s&&e.push(s)}if(this.isLineLoop){const r=h.getX(n-1),s=h.getX(i),a=Ta(this,t,va,o,r,s,n-1);a&&e.push(a)}}else{const i=Math.max(0,s.start),n=Math.min(c.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=Ta(this,t,va,o,r,r+1,r);i&&e.push(i)}if(this.isLineLoop){const r=Ta(this,t,va,o,n-1,i,n-1);r&&e.push(r)}}}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<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Ta(t,e,i,n,r,s,a){const o=t.geometry.attributes.position;ga.fromBufferAttribute(o,r),ya.fromBufferAttribute(o,s);if(i.distanceSqToSegment(ga,ya,ba,Ma)>n)return;ba.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(ba);return l<e.near||l>e.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;t<n;t+=2)wa.fromBufferAttribute(e,t),Ea.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+wa.distanceTo(Ea);t.setAttribute("lineDistance",new cr(i,1))}else Ye("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ca extends Sa{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Ra extends Cr{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new _n(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Na=new Ui,Ia=new ts,Pa=new mr,La=new di;class Da extends cn{constructor(t=new Mr,e=new Ra){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Pa.copy(i.boundingSphere),Pa.applyMatrix4(n),Pa.radius+=r,!1===t.ray.intersectsSphere(Pa))return;Na.copy(n).invert(),Ia.copy(t.ray).applyMatrix4(Na);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=i.index,h=i.attributes.position;if(null!==l){for(let i=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);i<r;i++){const r=l.getX(i);La.fromBufferAttribute(h,r),Oa(La,r,o,n,t,e,this)}}else{for(let i=Math.max(0,s.start),r=Math.min(h.count,s.start+s.count);i<r;i++)La.fromBufferAttribute(h,i),Oa(La,i,o,n,t,e,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<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Oa(t,e,i,n,r,s,a){const o=Ia.distanceSqToPoint(t);if(o<i){const i=new di;Ia.closestPointToPoint(t,i),i.applyMatrix4(n);const l=r.ray.origin.distanceTo(i);if(l<r.near||l>r.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;s<T;s++){const a=s*v-b;for(let o=0;o<S;o++){const u=o*_-x;A[t]=u*n,A[e]=a*r,A[i]=M,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[i]=m>0?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;t<g;t++)for(let e=0;e<f;e++){const i=u+e+S*t,n=u+e+S*(t+1),r=u+(e+1)+S*(t+1),s=u+(e+1)+S*t;o.push(i,n,s),o.push(n,r,s),E+=6}a.addGroup(d,E,y),d+=E,u+=w}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new cr(l,3)),this.setAttribute("normal",new cr(h,3)),this.setAttribute("uv",new cr(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ga(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Ha extends Mr{constructor(t=1,e=1,i=4,n=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:i,radialSegments:n,heightSegments:r},e=Math.max(0,e),i=Math.max(1,Math.floor(i)),n=Math.max(3,Math.floor(n)),r=Math.max(1,Math.floor(r));const s=[],a=[],o=[],l=[],h=e/2,c=Math.PI/2*t,u=e,d=2*c+u,p=2*i+r,m=n+1,f=new di,g=new di;for(let y=0;y<=p;y++){let _=0,v=0,x=0,b=0;if(y<=i){const e=y/i,n=e*Math.PI/2;v=-h-t*Math.cos(n),x=t*Math.sin(n),b=-t*Math.cos(n),_=e*c}else if(y<=i+r){const n=(y-i)/r;v=n*e-h,x=t,b=0,_=c+n*u}else{const e=(y-i-r)/i,n=e*Math.PI/2;v=h+t*Math.sin(n),x=t*Math.cos(n),b=t*Math.sin(n),_=c+u+e*c}const M=Math.max(0,Math.min(1,_/d));let S=0;0===y?S=.5/n:y===p&&(S=-.5/n);for(let t=0;t<=n;t++){const e=t/n,i=e*Math.PI*2,r=Math.sin(i),s=Math.cos(i);g.x=-x*s,g.y=v,g.z=x*r,a.push(g.x,g.y,g.z),f.set(-x*s,b,x*r),f.normalize(),o.push(f.x,f.y,f.z),l.push(e+S,M)}if(y>0){const t=(y-1)*m;for(let e=0;e<n;e++){const i=t+e,n=t+e+1,r=y*m+e,a=y*m+e+1;s.push(i,n,r),s.push(n,a,r)}}}this.setIndex(s),this.setAttribute("position",new cr(a,3)),this.setAttribute("normal",new cr(o,3)),this.setAttribute("uv",new cr(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ha(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class Wa extends Mr{constructor(t=1,e=32,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const r=[],s=[],a=[],o=[],l=new di,h=new ci;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,c=3;r<=e;r++,c+=3){const u=i+r/e*n;l.x=t*Math.cos(u),l.y=t*Math.sin(u),s.push(l.x,l.y,l.z),a.push(0,0,1),h.x=(s[c]/t+1)/2,h.y=(s[c+1]/t+1)/2,o.push(h.x,h.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new cr(s,3)),this.setAttribute("normal",new cr(a,3)),this.setAttribute("uv",new cr(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wa(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class ja extends Mr{constructor(t=1,e=1,i=1,n=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;n=Math.floor(n),r=Math.floor(r);const h=[],c=[],u=[],d=[];let p=0;const m=[],f=i/2;let g=0;function y(i){const r=p,s=new ci,m=new di;let y=0;const _=!0===i?t:e,v=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,f*v,0),u.push(0,v,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=n;t++){const e=t/n*o+a,i=Math.cos(e),r=Math.sin(e);m.x=_*r,m.y=f*v,m.z=_*i,c.push(m.x,m.y,m.z),u.push(0,v,0),s.x=.5*i+.5,s.y=.5*r*v+.5,d.push(s.x,s.y),p++}for(let t=0;t<n;t++){const e=r+t,n=x+t;!0===i?h.push(n,n+1,e):h.push(n+1,n,e),y+=3}l.addGroup(g,y,!0===i?1:2),g+=y}!function(){const s=new di,y=new di;let _=0;const v=(e-t)/i;for(let l=0;l<=r;l++){const h=[],g=l/r,_=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,r=e*o+a,l=Math.sin(r),m=Math.cos(r);y.x=_*l,y.y=-g*i+f,y.z=_*m,c.push(y.x,y.y,y.z),s.set(l,v,m).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-g),h.push(p++)}m.push(h)}for(let i=0;i<n;i++)for(let n=0;n<r;n++){const s=m[n][i],a=m[n+1][i],o=m[n+1][i+1],l=m[n][i+1];(t>0||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<r;t++)for(let e=0;e<2*(r-t)-1;e++){const i=Math.floor(e/2);e%2==0?(o(s[t][i+1]),o(s[t+1][i]),o(s[t][i])):(o(s[t][i+1]),o(s[t+1][i+1]),o(s[t+1][i]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,i){const n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function h(t,e,i,n){n<0&&1===t.x&&(s[e]=t.x-1),0===i.x&&0===i.z&&(s[e]=n/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const i=new di,n=new di,r=new di;for(let s=0;s<e.length;s+=3)l(e[s+0],i),l(e[s+1],n),l(e[s+2],r),a(i,n,r,t)}(n),function(t){const e=new di;for(let i=0;i<r.length;i+=3)e.x=r[i+0],e.y=r[i+1],e.z=r[i+2],e.normalize().multiplyScalar(t),r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z}(i),function(){const t=new di;for(let e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];const i=c(t)/2/Math.PI+.5,n=u(t)/Math.PI+.5;s.push(i,1-n)}(function(){const t=new di,e=new di,i=new di,n=new di,a=new ci,o=new ci,l=new ci;for(let u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),i.set(r[u+6],r[u+7],r[u+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),n.copy(t).add(e).add(i).divideScalar(3);const p=c(n);h(a,d+0,t,p),h(o,d+2,e,p),h(l,d+4,i,p)}})(),function(){for(let t=0;t<s.length;t+=6){const e=s[t+0],i=s[t+2],n=s[t+4],r=Math.max(e,i,n),a=Math.min(e,i,n);r>.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;t<o;t+=3){s?(l[0]=s.getX(t),l[1]=s.getX(t+1),l[2]=s.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:i,c:o}=$a;if(e.fromBufferAttribute(a,l[0]),i.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),$a.getNormal(Ja),c[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,c[1]=`${Math.round(i.x*n)},${Math.round(i.y*n)},${Math.round(i.z*n)}`,c[2]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let t=0;t<3;t++){const e=(t+1)%3,i=c[t],n=c[e],s=$a[h[t]],a=$a[h[e]],o=`${i}_${n}`,p=`${n}_${i}`;p in u&&u[p]?(Ja.dot(u[p].normal)<=r&&(d.push(s.x,s.y,s.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:l[t],index1:l[e],normal:Ja.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:i}=u[t];Za.fromBufferAttribute(a,e),Ka.fromBufferAttribute(a,i),d.push(Za.x,Za.y,Za.z),d.push(Ka.x,Ka.y,Ka.z)}this.setAttribute("position",new cr(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class to{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ye("Curve: .getPoint() not implemented.")}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,n=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)i=this.getPoint(s/t),r+=i.distanceTo(n),e.push(r),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const i=this.getLengths();let n=0;const r=i.length;let s;s=e||t*i[r-1];let a,o=0,l=r-1;for(;o<=l;)if(n=Math.floor(o+(l-o)/2),a=i[n]-s,a<0)o=n+1;else{if(!(a>0)){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)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const a=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=o-this.aX,n=l-this.aY;o=i*t-n*e+this.aX,l=i*e+n*t+this.aY}return i.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class io extends eo{constructor(t,e,i,n,r,s){super(t,e,i,i,n,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function no(){let t=0,e=0,i=0,n=0;function r(r,s,a,o){t=r,e=a,i=-3*r+3*s-2*a-o,n=2*r-2*s+a+o}return{initCatmullRom:function(t,e,i,n,s){r(e,i,s*(i-t),s*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,s,a,o){let l=(e-t)/s-(i-t)/(s+a)+(i-e)/a,h=(i-e)/a-(n-e)/(a+o)+(n-i)/o;l*=a,h*=a,r(e,i,l,h)},calc:function(r){const s=r*r;return t+e*r+i*s+n*(s*r)}}}const ro=new di,so=new di,ao=new no,oo=new no,lo=new no;class ho extends to{constructor(t=[],e=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}getPoint(t,e=new di){const i=e,n=this.points,r=n.length,s=(r-(this.closed?0:1))*t;let a,o,l=Math.floor(s),h=s-l;this.closed?l+=l>0?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+2<r?o=n[(l+2)%r]:(ro.subVectors(n[r-1],n[r-2]).add(n[r-1]),o=ro),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),i=Math.pow(c.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(o),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),ao.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),oo.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),lo.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(ao.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),oo.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),lo.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(ao.calc(h),oo.calc(h),lo.calc(h)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new di).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function co(t,e,i,n,r){const s=.5*(n-e),a=.5*(r-i),o=t*t;return(2*i-2*n+s+a)*(t*o)+(-3*i+3*n-2*s-a)*o+s*t+i}function uo(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function po(t,e,i,n,r){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}class mo extends to{constructor(t=new ci,e=new ci,i=new ci,n=new ci){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new ci){const i=e,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(po(t,n.x,r.x,s.x,a.x),po(t,n.y,r.y,s.y,a.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class fo extends to{constructor(t=new di,e=new di,i=new di,n=new di){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new di){const i=e,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(po(t,n.x,r.x,s.x,a.x),po(t,n.y,r.y,s.y,a.y),po(t,n.z,r.z,s.z,a.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class go extends to{constructor(t=new ci,e=new ci){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ci){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new ci){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class yo extends to{constructor(t=new di,e=new di){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new di){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new di){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class _o extends to{constructor(t=new ci,e=new ci,i=new ci){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new ci){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(uo(t,n.x,r.x,s.x),uo(t,n.y,r.y,s.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class vo extends to{constructor(t=new di,e=new di,i=new di){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new di){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(uo(t,n.x,r.x,s.x),uo(t,n.y,r.y,s.y),uo(t,n.z,r.z,s.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class xo extends to{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ci){const i=e,n=this.points,r=(n.length-1)*t,s=Math.floor(r),a=r-s,o=n[0===s?s:s-1],l=n[s],h=n[s>n.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;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new ci).fromArray(i))}return this}}var bo=Object.freeze({__proto__:null,ArcCurve:io,CatmullRomCurve3:ho,CubicBezierCurve:mo,CubicBezierCurve3:fo,EllipseCurve:eo,LineCurve:go,LineCurve3:yo,QuadraticBezierCurve:_o,QuadraticBezierCurve3:vo,SplineCurve:xo});class Mo extends to{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const i=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new bo[i](e,t))}return this}getPoint(t,e){const i=t*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=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;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],a=s.isEllipseCurve?2*t:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?t*s.points.length:t,o=s.getPoints(a);for(let t=0;t<o.length;t++){const n=o[t];i&&i.equals(n)||(e.push(n),i=n)}}return this.autoClose&&e.length>1&&!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;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new bo[i.type]).fromJSON(i))}return this}}class So extends Mo{constructor(t){super(),this.type="Path",this.currentPoint=new ci,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const i=new go(this.currentPoint.clone(),new ci(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const r=new _o(this.currentPoint.clone(),new ci(t,e),new ci(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,r,s){const a=new mo(this.currentPoint.clone(),new ci(t,e),new ci(i,n),new ci(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new xo(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,n,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,i,n,r,s),this}absarc(t,e,i,n,r,s){return this.absellipse(t,e,i,i,n,r,s),this}ellipse(t,e,i,n,r,s,a,o){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,i,n,r,s,a,o),this}absellipse(t,e,i,n,r,s,a,o){const l=new eo(t,e,i,n,r,s,a,o);if(this.curves.length>0){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;i<n;i++)e[i]=this.holes[i].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new So).fromJSON(i))}return this}}function wo(t,e,i=2){const n=e&&e.length,r=n?e[0]*i:t.length;let s=Eo(t,0,r,i,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,h;if(n&&(s=function(t,e,i,n){const r=[];for(let i=0,s=e.length;i<s;i++){const a=Eo(t,e[i]*n,i<s-1?e[i+1]*n:t.length,n,!1);a===a.next&&(a.steiner=!0),r.push(Fo(a))}r.sort(Lo);for(let t=0;t<r.length;t++)i=Do(r[t],i);return i}(t,e,s,i)),t.length>80*i){o=t[0],l=t[1];let e=o,n=l;for(let s=i;s<r;s+=i){const i=t[s],r=t[s+1];i<o&&(o=i),r<l&&(l=r),i>e&&(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;s<i;s+=n)r+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return r}(t,e,i,n)>0)for(let r=e;r<i;r+=n)s=Yo(r/n|0,t[r],t[r+1],s);else for(let r=i-n;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;t<i&&(o++,a=a.nextZ,a);t++);let l=i;for(;o>0||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.next.x?i:i.next,t===n))return s}i=i.next}while(i!==e);if(!s)return null;const o=s,l=s.x,h=s.y;let c=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&zo(r<h?n:a,r,l,h,r<h?a:n,r,i.x,i.y)){const e=Math.abs(r-i.y)/(n-i.x);Xo(i,t)&&(e<c||e===c&&(i.x>s.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<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function zo(t,e,i,n,r,s,a,o){return(r-a)*(e-o)>=(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;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i}static isClockWise(t){return $o.area(t)<0}static triangulateShape(t,e){const i=[],n=[],r=[];Qo(t),tl(i,t);let s=t.length;e.forEach(Qo);for(let t=0;t<e.length;t++)n.push(s),s+=e[t].length,tl(i,e[t]);const a=Jo.triangulate(i,n);for(let t=0;t<a.length;t+=3)r.push(a.slice(t,t+3));return r}}function Qo(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function tl(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class el extends Mr{constructor(t=new To([new ci(.5,.5),new ci(-.5,.5),new ci(-.5,-.5),new ci(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],r=[];for(let e=0,i=t.length;e<i;e++){s(t[e])}function s(t){const s=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let h=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:c-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:il;let g,y,_,v,x,b=!1;if(m){g=m.getSpacedPoints(o),b=!0,h=!1;const t=!!m.isCatmullRomCurve3&&m.closed;y=m.computeFrenetFrames(o,t),_=new di,v=new di,x=new di}h||(p=0,c=0,u=0,d=0);const M=t.extractPoints(a);let S=M.shape;const T=M.holes;if(!$o.isClockWise(S)){S=S.reverse();for(let t=0,e=T.length;t<e;t++){const e=T[t];$o.isClockWise(e)&&(T[t]=e.reverse())}}function w(t){const e=1e-10*1e-10;let i=t[0];for(let n=1;n<=t.length;n++){const r=n%t.length,s=t[r],a=s.x-i.x,o=s.y-i.y,l=a*a+o*o,h=Math.max(Math.abs(s.x),Math.abs(s.y),Math.abs(i.x),Math.abs(i.y));l<=e*h*h?(t.splice(r,1),n--):i=s}}w(S),T.forEach(w);const E=T.length,A=S;for(let t=0;t<E;t++){const e=T[t];S=S.concat(e)}function C(t,e,i){return e||Ze("ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,i)}const R=S.length;function N(t,e,i){let n,r,s;const a=t.x-e.x,o=t.y-e.y,l=i.x-t.x,h=i.y-t.y,c=a*a+o*o,u=a*h-o*l;if(Math.abs(u)>Number.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<e;t++,i++,n++)i===e&&(i=0),n===e&&(n=0),I[t]=N(A[t],A[i],A[n]);const P=[];let L,D,O=I.concat();for(let t=0,e=E;t<e;t++){const e=T[t];L=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),L[t]=N(e[t],e[n],e[r]);P.push(L),O=O.concat(L)}if(0===p)D=$o.triangulateShape(A,T);else{const t=[],e=[];for(let i=0;i<p;i++){const n=i/p,r=c*Math.cos(n*Math.PI/2),s=u*Math.sin(n*Math.PI/2)+d;for(let e=0,i=A.length;e<i;e++){const i=C(A[e],I[e],s);k(i.x,i.y,-r),0===n&&t.push(i)}for(let t=0,i=E;t<i;t++){const i=T[t];L=P[t];const a=[];for(let t=0,e=i.length;t<e;t++){const e=C(i[t],L[t],s);k(e.x,e.y,-r),0===n&&a.push(e)}0===n&&e.push(a)}}D=$o.triangulateShape(t,e)}const U=D.length,F=u+d;for(let t=0;t<R;t++){const e=h?C(S[t],O[t],F):S[t];b?(v.copy(y.normals[0]).multiplyScalar(e.x),_.copy(y.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(v).add(_),k(x.x,x.y,x.z)):k(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<R;e++){const i=h?C(S[e],O[e],F):S[e];b?(v.copy(y.normals[t]).multiplyScalar(i.x),_.copy(y.binormals[t]).multiplyScalar(i.y),x.copy(g[t]).add(v).add(_),k(x.x,x.y,x.z)):k(i.x,i.y,l/o*t)}for(let t=p-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<e;t++){const e=C(A[t],I[t],n);k(e.x,e.y,l+i)}for(let t=0,e=T.length;t<e;t++){const e=T[t];L=P[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],L[t],n);b?k(r.x,r.y+g[o-1].y,g[o-1].x+i):k(r.x,r.y,l+i)}}}function z(t,e){let i=t.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=o+2*p;t<i;t++){const i=R*t,s=R*(t+1);V(e+n+i,e+r+i,e+r+s,e+n+s)}}}function k(t,e,i){s.push(t),s.push(e),s.push(i)}function B(t,e,r){G(t),G(e),G(r);const s=n.length/3,a=f.generateTopUV(i,n,s-3,s-2,s-1);H(a[0]),H(a[1]),H(a[2])}function V(t,e,r,s){G(t),G(e),G(s),G(e),G(r),G(s);const a=n.length/3,o=f.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function G(t){n.push(s[3*t+0]),n.push(s[3*t+1]),n.push(s[3*t+2])}function H(t){r.push(t.x),r.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=R*t;for(let t=0;t<U;t++){const i=D[t];B(i[2]+e,i[1]+e,i[0]+e)}t=o+2*p,e=R*t;for(let t=0;t<U;t++){const i=D[t];B(i[0]+e,i[1]+e,i[2]+e)}}else{for(let t=0;t<U;t++){const e=D[t];B(e[2],e[1],e[0])}for(let t=0;t<U;t++){const e=D[t];B(e[0]+R*o,e[1]+R*o,e[2]+R*o)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;z(A,e),e+=A.length;for(let t=0,i=T.length;t<i;t++){const i=T[t];z(i,e),e+=i.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new cr(n,3)),this.setAttribute("uv",new cr(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){const n=t[e];i.shapes.push(n.uuid)}else i.shapes.push(t.uuid);i.options=Object.assign({},e),void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const i=[];for(let n=0,r=t.shapes.length;n<r;n++){const r=e[t.shapes[n]];i.push(r)}const n=t.options.extrudePath;return void 0!==n&&(t.options.extrudePath=(new bo[n.type]).fromJSON(n)),new el(i,t.options)}}const il={generateTopUV:function(t,e,i,n,r){const s=e[3*i],a=e[3*i+1],o=e[3*n],l=e[3*n+1],h=e[3*r],c=e[3*r+1];return[new ci(s,a),new ci(o,l),new ci(h,c)]},generateSideWallUV:function(t,e,i,n,r,s){const a=e[3*i],o=e[3*i+1],l=e[3*i+2],h=e[3*n],c=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],m=e[3*r+2],f=e[3*s],g=e[3*s+1],y=e[3*s+2];return Math.abs(o-c)<Math.abs(a-h)?[new ci(a,1-l),new ci(h,1-u),new ci(d,1-m),new ci(f,1-y)]:[new ci(o,1-l),new ci(c,1-u),new ci(p,1-m),new ci(g,1-y)]}};class nl extends qa{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new nl(t.radius,t.detail)}}class rl extends Mr{constructor(t=[new ci(0,-.5),new ci(.5,0),new ci(0,.5)],e=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=ri(n,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],h=1/e,c=new di,u=new ci,d=new di,p=new di,m=new di;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=e;r++){const d=i+r*h*n,p=Math.sin(d),m=Math.cos(d);for(let i=0;i<=t.length-1;i++){c.x=t[i].x*p,c.y=t[i].y,c.z=t[i].x*m,s.push(c.x,c.y,c.z),u.x=r/e,u.y=i/(t.length-1),a.push(u.x,u.y);const n=o[3*i+0]*p,h=o[3*i+1],d=o[3*i+0]*m;l.push(n,h,d)}}for(let i=0;i<e;i++)for(let e=0;e<t.length-1;e++){const n=e+i*t.length,s=n,a=n+t.length,o=n+t.length+1,l=n+1;r.push(s,a,l),r.push(o,l,a)}this.setIndex(r),this.setAttribute("position",new cr(s,3)),this.setAttribute("uv",new cr(a,2)),this.setAttribute("normal",new cr(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rl(t.points,t.segments,t.phiStart,t.phiLength)}}class sl extends qa{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new sl(t.radius,t.detail)}}class al extends Mr{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,s=e/2,a=Math.floor(i),o=Math.floor(n),l=a+1,h=o+1,c=t/a,u=e/o,d=[],p=[],m=[],f=[];for(let t=0;t<h;t++){const e=t*u-s;for(let i=0;i<l;i++){const n=i*c-r;p.push(n,-e,0),m.push(0,0,1),f.push(i/a),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=e+l*t,n=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new cr(p,3)),this.setAttribute("normal",new cr(m,3)),this.setAttribute("uv",new cr(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new al(t.width,t.height,t.widthSegments,t.heightSegments)}}class ol extends Mr{constructor(t=.5,e=1,i=32,n=1,r=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:s},i=Math.max(3,i);const a=[],o=[],l=[],h=[];let c=t;const u=(e-t)/(n=Math.max(1,n)),d=new di,p=new ci;for(let t=0;t<=n;t++){for(let t=0;t<=i;t++){const n=r+t/i*s;d.x=c*Math.cos(n),d.y=c*Math.sin(n),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,h.push(p.x,p.y)}c+=u}for(let t=0;t<n;t++){const e=t*(i+1);for(let t=0;t<i;t++){const n=t+e,r=n,s=n+i+1,o=n+i+2,l=n+1;a.push(r,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new cr(o,3)),this.setAttribute("normal",new cr(l,3)),this.setAttribute("uv",new cr(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ol(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class ll extends Mr{constructor(t=new To([new ci(0,.5),new ci(-.5,-.5),new ci(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(a,o,e),a+=o,o=0;function l(t){const a=n.length/3,l=t.extractPoints(e);let h=l.shape;const c=l.holes;!1===$o.isClockWise(h)&&(h=h.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===$o.isClockWise(e)&&(c[t]=e.reverse())}const u=$o.triangulateShape(h,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];h=h.concat(e)}for(let t=0,e=h.length;t<e;t++){const e=h[t];n.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],n=e[0]+a,r=e[1]+a,s=e[2]+a;i.push(n,r,s),o+=3}}this.setIndex(i),this.setAttribute("position",new cr(n,3)),this.setAttribute("normal",new cr(r,3)),this.setAttribute("uv",new cr(s,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const i=[];for(let n=0,r=t.shapes.length;n<r;n++){const r=e[t.shapes[n]];i.push(r)}return new ll(i,t.curveSegments)}}class hl extends Mr{constructor(t=1,e=32,i=16,n=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(s+a,Math.PI);let l=0;const h=[],c=new di,u=new di,d=[],p=[],m=[],f=[];for(let d=0;d<=i;d++){const g=[],y=d/i;let _=0;0===d&&0===s?_=.5/e:d===i&&o===Math.PI&&(_=-.5/e);for(let i=0;i<=e;i++){const o=i/e;c.x=-t*Math.cos(n+o*r)*Math.sin(s+y*a),c.y=t*Math.cos(s+y*a),c.z=t*Math.sin(n+o*r)*Math.sin(s+y*a),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),f.push(o+_,1-y),g.push(l++)}h.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=h[t][n+1],r=h[t][n],a=h[t+1][n],l=h[t+1][n+1];(0!==t||s>0)&&d.push(e,r,l),(t!==i-1||o<Math.PI)&&d.push(r,a,l)}this.setIndex(d),this.setAttribute("position",new cr(p,3)),this.setAttribute("normal",new cr(m,3)),this.setAttribute("uv",new cr(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class cl extends qa{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new cl(t.radius,t.detail)}}class ul extends Mr{constructor(t=1,e=.4,i=12,n=48,r=2*Math.PI,s=0,a=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r,thetaStart:s,thetaLength:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],h=[],c=[],u=new di,d=new di,p=new di;for(let o=0;o<=i;o++){const m=s+o/i*a;for(let s=0;s<=n;s++){const a=s/n*r;d.x=(t+e*Math.cos(m))*Math.cos(a),d.y=(t+e*Math.cos(m))*Math.sin(a),d.z=e*Math.sin(m),l.push(d.x,d.y,d.z),u.x=t*Math.cos(a),u.y=t*Math.sin(a),p.subVectors(d,u).normalize(),h.push(p.x,p.y,p.z),c.push(s/n),c.push(o/i)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*t+e-1,r=(n+1)*(t-1)+e-1,s=(n+1)*(t-1)+e,a=(n+1)*t+e;o.push(i,r,a),o.push(r,s,a)}this.setIndex(o),this.setAttribute("position",new cr(l,3)),this.setAttribute("normal",new cr(h,3)),this.setAttribute("uv",new cr(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ul(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class dl extends Mr{constructor(t=1,e=.4,i=64,n=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:s},i=Math.floor(i),n=Math.floor(n);const a=[],o=[],l=[],h=[],c=new di,u=new di,d=new di,p=new di,m=new di,f=new di,g=new di;for(let a=0;a<=i;++a){const _=a/i*r*Math.PI*2;y(_,r,s,t,d),y(_+.01,r,s,t,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=n;++t){const r=t/n*Math.PI*2,s=-e*Math.cos(r),p=e*Math.sin(r);c.x=d.x+(s*g.x+p*m.x),c.y=d.y+(s*g.y+p*m.y),c.z=d.z+(s*g.z+p*m.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(a/i),h.push(t/n)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),r=(n+1)*t+(e-1),s=(n+1)*t+e,o=(n+1)*(t-1)+e;a.push(i,r,o),a.push(r,s,o)}function y(t,e,i,n,r){const s=Math.cos(t),a=Math.sin(t),o=i/e*t,l=Math.cos(o);r.x=n*(2+l)*.5*s,r.y=n*(2+l)*a*.5,r.z=n*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new cr(o,3)),this.setAttribute("normal",new cr(l,3)),this.setAttribute("uv",new cr(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dl(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class pl extends Mr{constructor(t=new vo(new di(-1,-1,0),new di(-1,1,0),new di(1,1,0)),e=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r};const s=t.computeFrenetFrames(e,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new di,o=new di,l=new ci;let h=new di;const c=[],u=[],d=[],p=[];function m(r){h=t.getPointAt(r/e,h);const l=s.normals[r],d=s.binormals[r];for(let t=0;t<=n;t++){const e=t/n*Math.PI*2,r=Math.sin(e),s=-Math.cos(e);o.x=s*l.x+r*d.x,o.y=s*l.y+r*d.y,o.z=s*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=h.x+i*o.x,a.y=h.y+i*o.y,a.z=h.z+i*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let i=0;i<=n;i++)l.x=t/e,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),r=(n+1)*t+(e-1),s=(n+1)*t+e,a=(n+1)*(t-1)+e;p.push(i,r,a),p.push(r,s,a)}}()}(),this.setIndex(p),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}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new pl((new bo[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class ml extends Mr{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],i=new Set,n=new di,r=new di;if(null!==t.index){const s=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],h=l.start;for(let t=h,o=h+l.count;t<o;t+=3)for(let o=0;o<3;o++){const l=a.getX(t+o),h=a.getX(t+(o+1)%3);n.fromBufferAttribute(s,l),r.fromBufferAttribute(s,h),!0===fl(n,r,i)&&(e.push(n.x,n.y,n.z),e.push(r.x,r.y,r.z))}}}else{const s=t.attributes.position;for(let t=0,a=s.count/3;t<a;t++)for(let a=0;a<3;a++){const o=3*t+a,l=3*t+(a+1)%3;n.fromBufferAttribute(s,o),r.fromBufferAttribute(s,l),!0===fl(n,r,i)&&(e.push(n.x,n.y,n.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new cr(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function fl(t,e,i){const n=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==i.has(n)&&!0!==i.has(r)&&(i.add(n),i.add(r),!0)}var gl=Object.freeze({__proto__:null,BoxGeometry:Ga,CapsuleGeometry:Ha,CircleGeometry:Wa,ConeGeometry:Xa,CylinderGeometry:ja,DodecahedronGeometry:Ya,EdgesGeometry:Qa,ExtrudeGeometry:el,IcosahedronGeometry:nl,LatheGeometry:rl,OctahedronGeometry:sl,PlaneGeometry:al,PolyhedronGeometry:qa,RingGeometry:ol,ShapeGeometry:ll,SphereGeometry:hl,TetrahedronGeometry:cl,TorusGeometry:ul,TorusKnotGeometry:dl,TubeGeometry:pl,WireframeGeometry:ml});class yl extends Cr{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new _n(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}function _l(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];if(xl(r))r.isRenderTargetTexture?(Ye("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[i][n]=null):e[i][n]=r.clone();else if(Array.isArray(r))if(xl(r[0])){const t=[];for(let e=0,i=r.length;e<i;e++)t[e]=r[e].clone();e[i][n]=t}else e[i][n]=r.slice();else e[i][n]=r}}return e}function vl(t){const e={};for(let i=0;i<t.length;i++){const n=_l(t[i]);for(const t in n)e[t]=n[t]}return e}function xl(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function bl(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:xi.workingColorSpace}const Ml={clone:_l,merge:vl};class Sl extends Cr{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=_l(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const 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<n)){for(let s=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===s)break;if(r=n,n=e[++i],t<n)break e}s=e.length;break i}if(!(t>=r)){const a=e[1];t<a&&(i=2,r=a);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(i===s)break;if(n=r,r=e[--i-1],t>=r)break e}s=i,i=0;break i}break t}for(;i<s;){const n=i+s>>>1;t<e[n]?s=n:i=n+1}if(n=e[i],r=e[i-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n;for(let t=0;t!==n;++t)e[t]=i[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Bl extends kl{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ge,endingEnd:ge}}intervalChanged_(t,e,i){const n=this.parameterPositions;let r=t-2,s=t+1,a=n[r],o=n[s];if(void 0===a)switch(this.getSettings_().endingStart){case ye:r=t,a=2*e-i;break;case _e:r=n.length-2,a=e+n[r]-n[r+1];break;default:r=t,a=i}if(void 0===o)switch(this.getSettings_().endingEnd){case ye:s=t,o=2*i-e;break;case _e:s=1,o=i+n[1]-n[0];break;default:s=t-1,o=e}const l=.5*(i-e),h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-i),this._offsetPrev=r*h,this._offsetNext=s*h}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,y=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,_=(-1-d)*f+(1.5+d)*m+.5*p,v=d*f-d*m;for(let t=0;t!==a;++t)r[t]=g*s[h+t]+y*s[l+t]+_*s[o+t]+v*s[c+t];return r}}class Vl 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=t*a,l=o-a,h=(i-e)/(n-e),c=1-h;for(let t=0;t!==a;++t)r[t]=s[l+t]*c+s[o+t]*h;return r}}class Gl extends kl{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class Hl extends kl{interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this.settings||this.DefaultSettings_,c=h.inTangents,u=h.outTangents;if(!c||!u){const t=(i-e)/(n-e),h=1-t;for(let e=0;e!==a;++e)r[e]=s[l+e]*h+s[o+e]*t;return r}const d=2*a,p=t-1;for(let h=0;h!==a;++h){const a=s[l+h],m=s[o+h],f=p*d+2*h,g=u[f],y=u[f+1],_=t*d+2*h,v=c[_],x=c[_+1];let b,M,S,T,w,E=(i-e)/(n-e);for(let t=0;t<8;t++){b=E*E,M=b*E,S=1-E,T=S*S,w=T*S;const t=w*e+3*T*E*g+3*S*b*v+M*n-i;if(Math.abs(t)<1e-10)break;const r=3*T*(g-e)+6*S*E*(v-g)+3*b*(n-v);if(Math.abs(r)<1e-10)break;E-=t/r,E=Math.max(0,Math.min(1,E))}r[h]=w*a+3*T*E*y+3*S*b*x+M*m}return r}}class Wl{constructor(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ol(e,this.TimeBufferType),this.values=Ol(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Ol(t.times,Array),values:Ol(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new Gl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Vl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Bl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new Hl(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case de:e=this.InterpolantFactoryMethodDiscrete;break;case pe:e=this.InterpolantFactoryMethodLinear;break;case me:e=this.InterpolantFactoryMethodSmooth;break;case fe:e=this.InterpolantFactoryMethodBezier}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return Ye("KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return de;case this.InterpolantFactoryMethodLinear:return pe;case this.InterpolantFactoryMethodSmooth:return me;case this.InterpolantFactoryMethodBezier:return fe}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<t;)++r;for(;-1!==s&&i[s]>e;)--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;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(n)r=!0;else{const t=a*i,n=t-i,s=t+i;for(let a=0;a!==i;++a){const i=e[t+a];if(i!==e[n+a]||i!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];const n=a*i,r=s*i;for(let t=0;t!==i;++t)e[r+t]=e[n+t]}++s}}if(r>0){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;t<r;t++){let a=[],o=[];a.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=Ul(a);a=Fl(a,1,l),o=Fl(o,1,l),n||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new ql(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/i))}return new this(t,-1,s)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<i.length;t++)if(i[t].name===e)return i[t];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.name.match(r);if(s&&s.length>1){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<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let i=0;i<r[e].morphTargets.length;i++)t[r[e].morphTargets[i]]=-1;for(const i in t){const t=[],s=[];for(let n=0;n!==r[e].morphTargets.length;++n){const n=r[e];t.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new ql(".morphTargetInfluence["+i+"]",t,s))}o=t.length*s}else{const s=".bones["+e[t].name+"]";i(Jl,s+".position",r,"pos",n),i(Zl,s+".quaternion",r,"rot",n),i(Jl,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,o,n,a)}resetDuration(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function Ql(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ql;case"vector":case"vector2":case"vector3":case"vector4":return Jl;case"color":return Xl;case"quaternion":return Zl;case"bool":case"boolean":return jl;case"string":return Kl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];zl(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const th={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(eh(t)||(this.files[t]=e))},get:function(t){if(!1!==this.enabled&&!eh(t))return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function eh(t){try{const e=t.slice(t.indexOf(":")+1);return"blob:"===new URL(e).protocol}catch(t){return!1}}class ih{constructor(t,e,i){const n=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(t){o++,!1===s&&void 0!==n.onStart&&n.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=l.length;e<i;e+=2){const i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const nh=new ih;class rh{constructor(t){this.manager=void 0!==t?t:nh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,r){i.load(t,n,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}rh.DEFAULT_MATERIAL_NAME="__DEFAULT";const sh={};class ah extends Error{constructor(t,e){super(t),this.response=e}}class oh extends rh{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=th.get(`file:${t}`);if(void 0!==r)return this.manager.itemStart(t),void setTimeout(()=>{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<e;t++){const e=i[t];e.onProgress&&e.onProgress(n)}t.enqueue(r),e()}},e=>{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<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}}).catch(e=>{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<n;t++){const n=i[t];n.onError&&n.onError(e)}this.manager.itemError(t)}).finally(()=>{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;e<i;++e)h(e);else o.load(t,function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}a.image=s}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=rt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}}const hh=new WeakMap;class ch extends rh{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=th.get(`image:${t}`);if(void 0!==s){if(!0===s.complete)r.manager.itemStart(t),setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0);else{let t=hh.get(s);void 0===t&&(t=[],hh.set(s,t)),t.push({onLoad:e,onError:n})}return s}const a=Ge("img");function o(){h(),e&&e(this);const i=hh.get(this)||[];for(let t=0;t<i.length;t++){const e=i[t];e.onLoad&&e.onLoad(this)}hh.delete(this),r.manager.itemEnd(t)}function l(e){h(),n&&n(e),th.remove(`image:${t}`);const i=hh.get(this)||[];for(let t=0;t<i.length;t++){const n=i[t];n.onError&&n.onError(e)}hh.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),th.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}}class uh extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Es,a=new oh(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(t){let i;try{i=r.parse(t)}catch(t){return void(void 0!==n?n(t):Ze(t))}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:Q,s.wrapT=void 0!==i.wrapT?i.wrapT:Q,s.magFilter=void 0!==i.magFilter?i.magFilter:rt,s.minFilter=void 0!==i.minFilter?i.minFilter:rt,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=at),1===i.mipmapCount&&(s.minFilter=rt),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)},i,n),s}}class dh extends rh{constructor(t){super(t)}load(t,e,i,n){const r=new Ni,s=new ch(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)},i,n),r}}class ph extends cn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new _n(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class mh extends ph{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(cn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _n(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const fh=new Ui,gh=new di,yh=new di;class _h{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ci(512,512),this.mapType=ot,this.map=null,this.mapPass=null,this.matrix=new Ui,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Xs,this._frameExtents=new ci(1,1),this._viewportCount=1,this._viewports=[new Ii(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;gh.setFromMatrixPosition(t.matrixWorld),e.position.copy(gh),yh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(yh),e.updateMatrixWorld(),fh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===ze||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(fh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const vh=new di,xh=new ui,bh=new di;class Mh extends cn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ui,this.projectionMatrix=new Ui,this.projectionMatrixInverse=new Ui,this.coordinateSystem=Fe,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(vh,xh,bh),1===bh.x&&1===bh.y&&1===bh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(vh,xh,bh.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(vh,xh,bh),1===bh.x&&1===bh.y&&1===bh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(vh,xh,bh.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const Sh=new di,Th=new ci,wh=new ci;class Eh extends Mh{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ii*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ei*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*ii*Math.atan(Math.tan(.5*ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){Sh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Sh.x,Sh.y).multiplyScalar(-t/Sh.z),Sh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Sh.x,Sh.y).multiplyScalar(-t/Sh.z)}getViewSize(t,e){return this.getViewBounds(t,Th,wh),e.subVectors(wh,Th)}setViewOffset(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ei*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/a,n*=s.width/t,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class Ah extends _h{constructor(){super(new Eh(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=2*ii*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Ch extends ph{constructor(t,e,i=0,n=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(cn.DEFAULT_UP),this.updateMatrix(),this.target=new cn,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Ah}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class Rh extends _h{constructor(){super(new Eh(90,1,.5,500)),this.isPointLightShadow=!0}}class Nh extends ph{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Rh}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Ih extends Mh{constructor(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class Ph extends _h{constructor(){super(new Ih(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Lh extends ph{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(cn.DEFAULT_UP),this.updateMatrix(),this.target=new cn,this.shadow=new Ph}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class Dh extends ph{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Oh extends ph{constructor(t,e,i=10,n=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Uh{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new di)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*n),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*i),e.addScaledVector(s[4],i*n*1.092548),e.addScaledVector(s[5],n*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],i*r*1.092548),e.addScaledVector(s[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*n),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*i),e.addScaledVector(s[4],.858086*i*n),e.addScaledVector(s[5],.858086*n*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*i*r),e.addScaledVector(s[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}class Fh extends ph{constructor(t=new Uh,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class zh extends rh{constructor(t){super(t),this.textures={}}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=this.textures;function i(t){return void 0===e[t]&&Ye("MaterialLoader: Undefined texture",t),e[t]}const n=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=t.sheen),void 0!==t.sheenColor&&(n.sheenColor=(new _n).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(n.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.specularIntensity&&(n.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(n.dispersion=t.dispersion),void 0!==t.iridescence&&(n.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(n.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(n.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.thickness&&(n.thickness=t.thickness),void 0!==t.attenuationDistance&&(n.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(n.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(n.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.shadowSide&&(n.shadowSide=t.shadowSide),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(n.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(n.depthFunc=t.depthFunc),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(n.blendSrc=t.blendSrc),void 0!==t.blendDst&&(n.blendDst=t.blendDst),void 0!==t.blendEquation&&(n.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(n.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(n.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(n.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==n.blendColor&&n.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(n.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),void 0!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.alphaToCoverage&&(n.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(n.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(n.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(n.allowOverride=t.allowOverride),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0: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<r;e++){const r=i[e];let a;if(r.isInterleavedBufferAttribute){const e=n(t.data,r.data);a=new Er(e,r.itemSize,r.offset,r.normalized)}else{const t=Be(r.type,r.array);a=new ar(t,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),s.push(a)}r.morphAttributes[e]=s}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];r.addGroup(e.start,e.count,e.materialIndex)}const h=t.data.boundingSphere;return void 0!==h&&(r.boundingSphere=(new mr).fromJSON(h)),t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const Gh={};const Hh={UVMapping:X,CubeReflectionMapping:q,CubeRefractionMapping:Y,EquirectangularReflectionMapping:Z,EquirectangularRefractionMapping:K,CubeUVReflectionMapping:J},Wh={RepeatWrapping:$,ClampToEdgeWrapping:Q,MirroredRepeatWrapping:tt},jh={NearestFilter:et,NearestMipmapNearestFilter:it,NearestMipmapLinearFilter:nt,LinearFilter:rt,LinearMipmapNearestFilter:st,LinearMipmapLinearFilter:at},Xh=new WeakMap;class qh extends rh{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&Ye("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&Ye("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=th.get(`image-bitmap:${t}`);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then(i=>{!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;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;Ye("Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(Ye("Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;Ye("Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),"buffer"!==t.sourceType?(Ye("Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const cc=new di,uc=new ui,dc=new di,pc=new di;class mc{constructor(t,e,i){let n,r,s;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,r=t*n+n;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==n;++t)i[r+t]=i[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(i,r,0,t,n)}this.cumulativeWeight=s}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-r,e)}s>0&&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<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,r){if(n>=.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;n<t.length;n++){const r=t[n];if(r.name===e||r.uuid===e)return r;const s=i(r.children);if(s)return s}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let r=e.propertyIndex;if(t||(t=bc.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void Ye("PropertyBinding: No target node found for track: "+this.path+".");if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return void Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void Ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void Ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void Ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[i])return void Ze("PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==n){if(void 0===t[n])return void Ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[n]}}const s=t[n];if(void 0===s){return void Ze("PropertyBinding: Trying to update property for track: "+e.nodeName+"."+n+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?a=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}bc.Composite=class{constructor(t,e,i){const n=i||bc.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}},bc.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},bc.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},bc.prototype.GetterByBindingType=[bc.prototype._getValue_direct,bc.prototype._getValue_array,bc.prototype._getValue_arrayElement,bc.prototype._getValue_toArray],bc.prototype.SetterByBindingTypeAndVersioning=[[bc.prototype._setValue_direct,bc.prototype._setValue_direct_setNeedsUpdate,bc.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bc.prototype._setValue_array,bc.prototype._setValue_array_setNeedsUpdate,bc.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bc.prototype._setValue_arrayElement,bc.prototype._setValue_arrayElement_setNeedsUpdate,bc.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bc.prototype._setValue_fromArray,bc.prototype._setValue_fromArray_setNeedsUpdate,bc.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Mc{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:ge,endingEnd:ge};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings&&Object.assign(o,e.settings),e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),!0===i){const i=this._clip.duration,n=t._clip.duration,r=n/i,s=i/n;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,r=n.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+i,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const n=(t-r)*i;n<0||0===i?e=0:(this._startTime=null,e=i*n)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){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;n<r;n++)Rc(t[n],this,i,e);return i.sort(Cc),i}}function Cc(t,e){return t.distance-e.distance}function Rc(t,e,i,n){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,i)&&(r=!1)}if(!0===r&&!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)Rc(n[t],e,i,!0)}}class Nc{constructor(t=1,e=0,i=0){this.radius=t,this.phi=e,this.theta=i}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=ri(this.phi,t,Math.PI-t),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(ri(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}let Ic=class t{static{t.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const r=this.elements;return r[0]=t,r[2]=e,r[1]=i,r[3]=n,this}};const Pc=new ci;const Lc=new di,Dc=new di,Oc=new di,Uc=new di,Fc=new di,zc=new di,kc=new di;const Bc=new di;const Vc=new di,Gc=new Ui,Hc=new Ui;function Wc(t){const e=[];!0===t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push(...Wc(t.children[i]));return e}const jc=new di,Xc=new _n,qc=new _n;const Yc=new di,Zc=new di,Kc=new di;const Jc=new di,$c=new Mh;function Qc(t,e,i,n,r,s,a){Jc.set(r,s,a).unproject(n);const o=e[t];if(void 0!==o){const t=i.getAttribute("position");for(let e=0,i=o.length;e<i;e++)t.setXYZ(o[e],Jc.x,Jc.y,Jc.z)}}const tu=new Fn;const eu=new di;let iu,nu;class ru{constructor(){this.type="ShapePath",this.color=new _n,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new So,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],a=e[s],o=a.x-i.x,l=a.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=e[s],o=-o,a=e[r],l=-l),t.y<i.y||t.y>a.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;e<a;e++)s=n[e],u=s.getPoints(),r=i(u),r=t?!r:r,r?(!l&&c[m]&&m++,c[m]={s:new To,p:u},c[m].s.curves=s.curves,l&&m++,p[m]=[]):p[m].push({h:s,p:u[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new To;r.curves=n.curves,e.push(r)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)h[t]=[];for(let n=0,r=c.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(n!==r&&i++,o?(o=!1,h[r].push(a)):t=!0);o&&h[n].push(a)}}i>0&&!1===t&&(p=h)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),d=p[t];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}}class su extends $e{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){void 0!==t?(null!==this.domElement&&this.disconnect(),this.domElement=t):Ye("Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}}function au(t,e,i,n){const r=function(t){switch(t){case ot:case lt:return{byteLength:1,components:1};case ct:case ht:case mt:return{byteLength:2,components:1};case ft:case gt:return{byteLength:2,components:4};case dt:case ut:case pt:return{byteLength:4,components:1};case _t:case vt:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(n);switch(i){case xt:return t*e;case wt:case Et:return t*e/r.components*r.byteLength;case At:case Ct:return t*e*2/r.components*r.byteLength;case bt:return t*e*3/r.components*r.byteLength;case Mt:case Rt:return t*e*4/r.components*r.byteLength;case Nt:case It:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Pt:case Lt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Ot:case Ft:return Math.max(t,16)*Math.max(e,8)/4;case Dt:case Ut:return Math.max(t,8)*Math.max(e,8)/2;case zt:case kt:case Vt:case Gt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Bt:case Ht:case Wt:case jt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Xt:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case qt:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Yt:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case Zt:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Kt:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case Jt:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case $t:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Qt:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case te:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case ee:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case ie:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case ne:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case re:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case se:case ae:case oe:return Math.ceil(t/4)*Math.ceil(e/4)*16;case le:case he:return Math.ceil(t/4)*Math.ceil(e/4)*8;case ce:case ue:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${i} format.`)}
/**
* @license
* Copyright 2010-2026 Three.js Authors
* SPDX-License-Identifier: MIT
*/
function ou(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&null!==t&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){null!==t&&t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function lu(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);const hu={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 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( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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 <lightprobes_pars_fragment>",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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <cube_uv_reflection_fragment>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\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 <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\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<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function u(t){d(t,0)}function d(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function f(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,l,f,g){let y=!1;const _=function(e,i,r,s){const a=!0===s.wireframe;let o=n[i.id];void 0===o&&(o={},n[i.id]=o);const l=!0===e.isInstancedMesh?e.id:0;let c=o[l];void 0===c&&(c={},o[l]=c);let u=c[r.id];void 0===u&&(u={},c[r.id]=u);let d=u[a];void 0===d&&(d=h(t.createVertexArray()),u[a]=d);return d}(i,f,l,r);s!==_&&(s=_,o(s.object)),y=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const l=i.getAttributes();for(const e in l){if(l[e].location>=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;t<r.locationSize;t++)d(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)u(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,l*p,(g+a/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)d(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)u(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)m(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,f)}}else if(void 0!==l){const e=l[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,l,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i){const e=i[t];for(const t in e)l(e[t].object),delete e[t];delete i[t]}}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i){const e=i[t];for(const t in e)l(e[t].object),delete e[t];delete i[t]}}delete n[t.id]},releaseStatesOfObject:function(t){for(const e in n){const i=n[e],r=!0===t.isInstancedMesh?t.id:0,s=i[r];if(void 0!==s){for(const t in s){const e=s[t];for(const t in e)l(e[t].object),delete e[t];delete s[t]}delete i[r],0===Object.keys(i).length&&delete n[e]}}},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}}},initAttributes:c,enableAttribute:u,disableUnusedAttributes:p}}function yu(t,e,i){let n;this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=function(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))},this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)}}function _u(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&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.length<e)&&(h=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(h,i),h[i+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=h(t,e,0)},this.setState=function(a,o,c){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===u||0===u.length||s&&!p)s?h(null):function(){l.value!==i&&(l.value=i,l.needsUpdate=n>0);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;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Tu,wu,Eu),this._renderer.xr.enabled=Au,t.scissorTest=!1,Iu(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===q||t.mapping===Y?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Tu=this._renderer.getRenderTarget(),wu=this._renderer.getActiveCubeFace(),Eu=this._renderer.getActiveMipmapLevel(),Au=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:rt,minFilter:rt,generateMipmaps:!1,type:mt,format:Mt,colorSpace:Se,depthBuffer:!1},n=Nu(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Nu(t,e,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+xu.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);e.push(s);let o=1/s;a>t-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;t<d;t++){const e=t%3*2/3-1,i=t>2?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 <cube_uv_reflection_fragment>\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 <cube_uv_reflection_fragment>\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;e<n;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[i];a.material=s;const o=s.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),c=Math.sqrt(l*l-h*h)*(0+1.25*l),{_lodMax:u}=this,d=this._sizeLods[i],p=3*d*(i>u-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;t<bu;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:y}=this;c.dTheta.value=d,c.mipInt.value=y-i;const _=this._sizeLods[n];Iu(e,3*_*(n>y-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 <common>\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 <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\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 <common>\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;n<i;n++)void 0!==t[n]&&e++;return e===i}(l)?(null===n&&(n=new Ru(t)),r=s?n.fromEquirectangular(e):n.fromCubemap(e),r.texture.pmremVersion=e.pmremVersion,i.set(e,r),e.addEventListener("dispose",a),r.texture):null}}}return e}(o):function(i){if(i&&i.isTexture){const n=i.mapping;if(n===Z||n===K){if(e.has(i)){return r(e.get(i).texture,i.mapping)}{const n=i.image;if(n&&n.height>0){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<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const o=new(r.count>=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.version<i.version&&o(t)}else o(t);return s.get(t)}}}function ku(t,e,i){let n,r,s;this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=function(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))},this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)}}function Bu(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:Ze("WebGLInfo: Unknown draw mode:",n)}}}}function Vu(t,e,i){const n=new WeakMap,r=new Ii;return{update:function(s,a,o){const l=s.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==h?h.length:0;let u=n.get(a);if(void 0===u||u.count!==c){void 0!==u&&u.texture.dispose();const d=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let _=0;!0===d&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let v=a.attributes.position.count*_,x=1;v>e.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<c;w++){const E=f[w],A=g[w],C=y[w],R=v*x*4*w;for(let N=0;N<E.count;N++){const I=N*S;!0===d&&(r.fromBufferAttribute(E,N),b[R+I+0]=r.x,b[R+I+1]=r.y,b[R+I+2]=r.z,b[R+I+3]=0),!0===p&&(r.fromBufferAttribute(A,N),b[R+I+4]=r.x,b[R+I+5]=r.y,b[R+I+6]=r.z,b[R+I+7]=0),!0===m&&(r.fromBufferAttribute(C,N),b[R+I+8]=r.x,b[R+I+9]=r.y,b[R+I+10]=r.z,b[R+I+11]=4===C.itemSize?r.w:1)}}function T(){M.dispose(),n.delete(a),a.removeEventListener("dispose",T)}u={count:c,texture:M,size:new ci(v,x)},n.set(a,u),a.addEventListener("dispose",T)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let P=0;for(let D=0;D<l.length;D++)P+=l[D];const L=a.morphTargetsRelative?1:1-P;o.getUniforms().setValue(t,"morphTargetBaseInfluence",L),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",u.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",u.size)}}}function Gu(t,e,i,n,r){let s=new WeakMap;function a(t){const e=t.target;e.removeEventListener("dispose",a),n.releaseStatesOfObject(e),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(n){const o=r.render.frame,l=n.geometry,h=e.get(n,l);if(s.get(h)!==o&&(e.update(h),s.set(h,o)),n.isInstancedMesh&&(!1===n.hasEventListener("dispose",a)&&n.addEventListener("dispose",a),s.get(n)!==o&&(i.update(n.instanceMatrix,t.ARRAY_BUFFER),null!==n.instanceColor&&i.update(n.instanceColor,t.ARRAY_BUFFER),s.set(n,o))),n.isSkinnedMesh){const t=n.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return h},dispose:function(){s=new WeakMap}}}const Hu={[F]:"LINEAR_TONE_MAPPING",[z]:"REINHARD_TONE_MAPPING",[k]:"CINEON_TONE_MAPPING",[B]:"ACES_FILMIC_TONE_MAPPING",[G]:"AGX_TONE_MAPPING",[H]:"NEUTRAL_TONE_MAPPING",[V]:"CUSTOM_TONE_MAPPING"};function Wu(t,e,i,n,r){const s=new Li(e,i,{type:t,depthBuffer:n,stencilBuffer:r,depthTexture:n?new ka(e,i):void 0}),a=new Li(e,i,{type:mt,depthBuffer:!1,stencilBuffer:!1}),o=new Mr;o.setAttribute("position",new cr([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new cr([0,2,0,0,2,0],2));const l=new Tl({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\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;i<g.length;i++){const n=g[i];n.setSize&&n.setSize(t,e)}},this.setEffects=function(t){g=t,y=g.length>0&&!0===g[0].isRenderPass;const e=s.width,i=s.height;for(let t=0;t<g.length;t++){const n=g[t];n.setSize&&n.setSize(e,i)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(f=e,null!==e){const t=e.width,i=e.height;s.width===t&&s.height===i||this.setSize(t,i)}return!1===y&&t.setRenderTarget(s),u=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return y},this.end=function(t,e){t.toneMapping=u,m=!0;let i=s,n=a;for(let r=0;r<g.length;r++){const s=g[r];if(!1!==s.enabled&&(s.render(t,n,i,e),!1!==s.needsSwap)){const t=i;i=n,n=t}}if(d!==t.outputColorSpace||p!==t.toneMapping){d=t.outputColorSpace,p=t.toneMapping,l.defines={},xi.getTransfer(d)===we&&(l.defines.SRGB_TRANSFER="");const e=Hu[p];e&&(l.defines[e]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=i.texture,t.setRenderTarget(f),t.render(h,c),f=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){s.depthTexture&&s.depthTexture.dispose(),s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const ju=new Ni,Xu=new ka(1,1),qu=new Di,Yu=new Oi,Zu=new za,Ku=[],Ju=[],$u=new Float32Array(16),Qu=new Float32Array(9),td=new Float32Array(4);function ed(t,e,i){const n=t[0];if(n<=0||n>0)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;i<n;i++)if(t[i]!==e[i])return!1;return!0}function nd(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function rd(t,e){let i=Ju[e];void 0===i&&(i=new Int32Array(e),Ju[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function sd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function ad(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(id(i,e))return;t.uniform2fv(this.addr,e),nd(i,e)}}function od(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(id(i,e))return;t.uniform3fv(this.addr,e),nd(i,e)}}function ld(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(id(i,e))return;t.uniform4fv(this.addr,e),nd(i,e)}}function hd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(id(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),nd(i,e)}else{if(id(i,n))return;td.set(n),t.uniformMatrix2fv(this.addr,!1,td),nd(i,n)}}function cd(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(id(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),nd(i,e)}else{if(id(i,n))return;Qu.set(n),t.uniformMatrix3fv(this.addr,!1,Qu),nd(i,n)}}function ud(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(id(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),nd(i,e)}else{if(id(i,n))return;$u.set(n),t.uniformMatrix4fv(this.addr,!1,$u),nd(i,n)}}function dd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function pd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(id(i,e))return;t.uniform2iv(this.addr,e),nd(i,e)}}function md(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(id(i,e))return;t.uniform3iv(this.addr,e),nd(i,e)}}function fd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(id(i,e))return;t.uniform4iv(this.addr,e),nd(i,e)}}function gd(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function yd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(id(i,e))return;t.uniform2uiv(this.addr,e),nd(i,e)}}function _d(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(id(i,e))return;t.uniform3uiv(this.addr,e),nd(i,e)}}function vd(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(id(i,e))return;t.uniform4uiv(this.addr,e),nd(i,e)}}function xd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Xu.compareFunction=i.isReversedDepthBuffer()?Le:Ne,s=Xu):s=ju,i.setTexture2D(e||s,r)}function bd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Yu,r)}function Md(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Zu,r)}function Sd(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||qu,r)}function Td(t,e){t.uniform1fv(this.addr,e)}function wd(t,e){const i=ed(e,this.size,2);t.uniform2fv(this.addr,i)}function Ed(t,e){const i=ed(e,this.size,3);t.uniform3fv(this.addr,i)}function Ad(t,e){const i=ed(e,this.size,4);t.uniform4fv(this.addr,i)}function Cd(t,e){const i=ed(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Rd(t,e){const i=ed(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Nd(t,e){const i=ed(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Id(t,e){t.uniform1iv(this.addr,e)}function Pd(t,e){t.uniform2iv(this.addr,e)}function Ld(t,e){t.uniform3iv(this.addr,e)}function Dd(t,e){t.uniform4iv(this.addr,e)}function Od(t,e){t.uniform1uiv(this.addr,e)}function Ud(t,e){t.uniform2uiv(this.addr,e)}function Fd(t,e){t.uniform3uiv(this.addr,e)}function zd(t,e){t.uniform4uiv(this.addr,e)}function kd(t,e,i){const n=this.cache,r=e.length,s=rd(i,r);let a;id(n,s)||(t.uniform1iv(this.addr,s),nd(n,s)),a=this.type===t.SAMPLER_2D_SHADOW?Xu:ju;for(let t=0;t!==r;++t)i.setTexture2D(e[t]||a,s[t])}function Bd(t,e,i){const n=this.cache,r=e.length,s=rd(i,r);id(n,s)||(t.uniform1iv(this.addr,s),nd(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||Yu,s[t])}function Vd(t,e,i){const n=this.cache,r=e.length,s=rd(i,r);id(n,s)||(t.uniform1iv(this.addr,s),nd(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Zu,s[t])}function Gd(t,e,i){const n=this.cache,r=e.length,s=rd(i,r);id(n,s)||(t.uniform1iv(this.addr,s),nd(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||qu,s[t])}class Hd{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return sd;case 35664:return ad;case 35665:return od;case 35666:return ld;case 35674:return hd;case 35675:return cd;case 35676:return ud;case 5124:case 35670:return dd;case 35667:case 35671:return pd;case 35668:case 35672:return md;case 35669:case 35673:return fd;case 5125:return gd;case 36294:return yd;case 36295:return _d;case 36296:return vd;case 35678:case 36198:case 36298:case 36306:case 35682:return xd;case 35679:case 36299:case 36307:return bd;case 35680:case 36300:case 36308:case 36293:return Md;case 36289:case 36303:case 36311:case 36292:return Sd}}(e.type)}}class Wd{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Td;case 35664:return wd;case 35665:return Ed;case 35666:return Ad;case 35674:return Cd;case 35675:return Rd;case 35676:return Nd;case 5124:case 35670:return Id;case 35667:case 35671:return Pd;case 35668:case 35672:return Ld;case 35669:case 35673:return Dd;case 5125:return Od;case 36294:return Ud;case 36295:return Fd;case 36296:return zd;case 35678:case 36198:case 36298:case 36306:case 35682:return kd;case 35679:case 36299:case 36307:return Bd;case 35680:case 36300:case 36308:case 36293:return Vd;case 36289:case 36303:case 36311:case 36292:return Gd}}(e.type)}}class jd{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const Xd=/(\w+)(\])?(\[|\.)?/g;function qd(t,e){t.seq.push(e),t.map[e.id]=e}function Yd(t,e,i){const n=t.name,r=n.length;for(Xd.lastIndex=0;;){const s=Xd.exec(n),a=Xd.lastIndex;let o=s[1];const l="]"===s[2],h=s[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===r){qd(i,void 0===h?new Hd(o,t,e):new Wd(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new jd(o),qd(i,t)),i=t}}}class Zd{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Yd(i,t.getUniformLocation(e,i.name),this)}const n=[],r=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?n.push(e):r.push(e);n.length>0&&(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<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${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);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function fp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const gp={[n]:"SHADOWMAP_TYPE_PCF",[r]:"SHADOWMAP_TYPE_VSM"};const yp={[q]:"ENVMAP_TYPE_CUBE",[Y]:"ENVMAP_TYPE_CUBE",[J]:"ENVMAP_TYPE_CUBE_UV"};const _p={[Y]:"ENVMAP_MODE_REFRACTION"};const vp={[D]:"ENVMAP_BLENDING_MULTIPLY",[O]:"ENVMAP_BLENDING_MIX",[U]:"ENVMAP_BLENDING_ADD"};function xp(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const l=function(t){return gp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(i),h=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":yp[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(i),c=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":_p[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(i),u=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":vp[t.combine]||"ENVMAP_BLENDING_NONE"}(i),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sp).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),f=r.createProgram();let g,y,_=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(sp).join("\n"),g.length>0&&(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;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,f)}let T,w;r.attachShader(f,b),r.attachShader(f,M),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===T&&S(this),T},this.getAttributes=function(){return void 0===w&&S(this),w};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=r.getProgramParameter(f,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Jd++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=M,this}let bp=0;class Mp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Sp(t),e.set(t,i)),i}}class Sp{constructor(t){this.id=bp++,this.code=t,this.usedTimes=0}}function Tp(t,e,i,n,r,s){const a=new qi,o=new Mp,l=new Set,h=[],c=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,a,h,c,f,g){const y=c.fog,_=f.geometry,v=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?c.environment:null,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,b=e.get(r.envMap||v,x),M=b&&b.mapping===J?b.image.height:null,S=p[r.type];null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&Ye("WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead."));const T=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=void 0!==T?T.length:0;let E,A,C,R,N=0;if(void 0!==_.morphAttributes.position&&(N=1),void 0!==_.morphAttributes.normal&&(N=2),void 0!==_.morphAttributes.color&&(N=3),S){const t=uu[S];E=t.vertexShader,A=t.fragmentShader}else E=r.vertexShader,A=r.fragmentShader,o.update(r),C=o.getVertexShaderID(r),R=o.getFragmentShaderID(r);const I=t.getRenderTarget(),P=t.state.buffers.depth.getReversed(),L=!0===f.isInstancedMesh,D=!0===f.isBatchedMesh,O=!!r.map,U=!!r.matcap,F=!!b,z=!!r.aoMap,k=!!r.lightMap,B=!!r.bumpMap,V=!!r.normalMap,G=!!r.displacementMap,H=!!r.emissiveMap,W=!!r.metalnessMap,j=!!r.roughnessMap,X=r.anisotropy>0,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;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&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;t<v;t++){const v=r[t],x=v.color,b=v.intensity,M=v.distance;let S=null;if(v.shadow&&v.shadow.map&&(S=v.shadow.map.texture.format===At?v.shadow.map.texture:v.shadow.map.depthTexture||v.shadow.map.texture),v.isAmbientLight)s+=x.r*b,a+=x.g*b,o+=x.b*b;else if(v.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(v.sh.coefficients[t],b);_++}else if(v.isDirectionalLight){const t=e.get(v);if(t.color.copy(v.color).multiplyScalar(v.intensity),v.castShadow){const t=v.shadow,e=i.get(v);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[l]=e,n.directionalShadowMap[l]=S,n.directionalShadowMatrix[l]=v.shadow.matrix,p++}n.directional[l]=t,l++}else if(v.isSpotLight){const t=e.get(v);t.position.setFromMatrixPosition(v.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=M,t.coneCos=Math.cos(v.angle),t.penumbraCos=Math.cos(v.angle*(1-v.penumbra)),t.decay=v.decay,n.spot[c]=t;const r=v.shadow;if(v.map&&(n.spotLightMap[g]=v.map,g++,r.updateMatrices(v),v.castShadow&&y++),n.spotLightMatrix[c]=r.matrix,v.castShadow){const t=i.get(v);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=S,f++}c++}else if(v.isRectAreaLight){const t=e.get(v);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*v.width,0,0),t.halfHeight.set(0,.5*v.height,0),n.rectArea[u]=t,u++}else if(v.isPointLight){const t=e.get(v);if(t.color.copy(v.color).multiplyScalar(v.intensity),t.distance=v.distance,t.decay=v.decay,v.castShadow){const t=v.shadow,e=i.get(v);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[h]=e,n.pointShadowMap[h]=S,n.pointShadowMatrix[h]=v.shadow.matrix,m++}n.point[h]=t,h++}else if(v.isHemisphereLight){const t=e.get(v);t.skyColor.copy(v.color).multiplyScalar(b),t.groundColor.copy(v.groundColor).multiplyScalar(b),n.hemi[d]=t,d++}}u>0&&(!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<d;e++){const d=t[e];if(d.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=n.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const t=n.rectArea[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),s.copy(d.matrixWorld),s.premultiply(u),a.extractRotation(s),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(d.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),o++}else if(d.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),c++}}},state:n}}function Dp(t){const e=new Lp(t),i=[],n=[],r=[];const s={lightsArray:i,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:function(t){s.camera=t,i.length=0,n.length=0,r.length=0},state:s,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)},pushLightProbeGrid:function(t){r.push(t)}}}function Op(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new Dp(t),e.set(i,[s])):n>=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;h<c;h++){const c=e[h],u=l[c.materialIndex];if(u&&u.visible){const e=M(i,u,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(l.visible){const e=M(i,l,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const l=i.children;for(let t=0,e=l.length;t<e;t++)S(l[t],r,s,a,o)}function T(t){t.target.removeEventListener("dispose",T);for(const e in d){const i=d[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,s){if(!1===v.enabled)return;if(!1===v.autoUpdate&&!1===v.needsUpdate)return;if(0===e.length)return;2===this.type&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const a=t.getRenderTarget(),o=t.getActiveCubeFace(),c=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const d=x!==this.type;d&&i.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.needsUpdate=!0):t.material.needsUpdate=!0)});for(let a=0,o=e.length;a<o;a++){const o=e[a],c=o.shadow;if(void 0===c){Ye("WebGLShadowMap:",o,"has no shadow.");continue}if(!1===c.autoUpdate&&!1===c.needsUpdate)continue;r.copy(c.mapSize);const m=c.getFrameExtents();r.multiply(m),l.copy(c.mapSize),(r.x>p||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<g;e++){if(c.map.isWebGLCubeRenderTarget)t.setRenderTarget(c.map,e),t.clear();else{0===e&&(t.setRenderTarget(c.map),t.clear());const i=c.getViewport(e);h.set(l.x*i.x,l.y*i.y,l.x*i.z,l.y*i.w),u.viewport(h)}if(o.isPointLight){const t=c.camera,i=c.matrix,n=o.distance||t.far;n!==t.far&&(t.far=n,t.updateProjectionMatrix()),kp.setFromMatrixPosition(o.matrixWorld),t.position.copy(kp),Bp.copy(t.position),Bp.add(Up[e]),t.up.copy(Fp[e]),t.lookAt(Bp),t.updateMatrixWorld(),i.makeTranslation(-kp.x,-kp.y,-kp.z),zp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),c._frustum.setFromProjectionMatrix(zp,t.coordinateSystem,t.reversedDepth)}else c.updateMatrices(o);n=c.getFrustum(),S(i,s,c.camera,o,this.type)}!0!==c.isPointLightShadow&&3===this.type&&b(c,s),c.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(a,o,c)}}function Gp(t,e){const i=new function(){let e=!1;const i=new Ii;let n=null;const r=new Ii(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const r=a;a=null,this.setClear(r)}},getReversed:function(){return n},setTest:function(e){e?st(t.DEPTH_TEST):at(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=Je[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(a=e,n&&(e=1-e),t.clearDepth(e))},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(i){e||(i?st(t.STENCIL_TEST):at(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&l===n||(t.stencilOp(e,i,n),a=e,o=i,l=n)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,h=null}}},s=new WeakMap,a=new WeakMap;let o={},E={},A={},C=new WeakMap,R=[],N=null,I=!1,P=null,L=null,D=null,O=null,U=null,F=null,z=null,k=new _n(0,0,0),B=0,V=!1,G=null,H=null,W=null,j=null,X=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,Z=0;const K=t.getParameter(t.VERSION);-1!==K.indexOf("WebGL")?(Z=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=Z>=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;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const rt={};function st(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function at(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}rt[t.TEXTURE_2D]=nt(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=nt(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[t.TEXTURE_2D_ARRAY]=nt(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=nt(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),st(t.DEPTH_TEST),n.setFunc(3),ct(!1),ut(1),st(t.CULL_FACE),ht(0);const ot={[l]:t.FUNC_ADD,[h]:t.FUNC_SUBTRACT,[c]:t.FUNC_REVERSE_SUBTRACT};ot[103]=t.MIN,ot[104]=t.MAX;const lt={[u]:t.ZERO,[d]:t.ONE,[p]:t.SRC_COLOR,[f]:t.SRC_ALPHA,[b]:t.SRC_ALPHA_SATURATE,[v]:t.DST_COLOR,[y]:t.DST_ALPHA,[m]:t.ONE_MINUS_SRC_COLOR,[g]:t.ONE_MINUS_SRC_ALPHA,[x]:t.ONE_MINUS_DST_COLOR,[_]:t.ONE_MINUS_DST_ALPHA,[M]:t.CONSTANT_COLOR,[S]:t.ONE_MINUS_CONSTANT_COLOR,[T]:t.CONSTANT_ALPHA,[w]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,h,c,u){if(0!==e){if(!1===I&&(st(t.BLEND),I=!0),5===e)s=s||i,a=a||n,o=o||r,i===L&&s===U||(t.blendEquationSeparate(ot[i],ot[s]),L=i,U=s),n===D&&r===O&&a===F&&o===z||(t.blendFuncSeparate(lt[n],lt[r],lt[a],lt[o]),D=n,O=r,F=a,z=o),!1!==h.equals(k)&&c===B||(t.blendColor(h.r,h.g,h.b,c),k.copy(h),B=c),P=e,V=!1;else if(e!==P||u!==V){if(L===l&&U===l||(t.blendEquation(t.FUNC_ADD),L=l,U=l),u)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ze("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:Ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ze("WebGLState: Invalid blending: ",e)}D=null,O=null,F=null,z=null,k.set(0,0,0),B=0,P=e,V=u}}else!0===I&&(at(t.BLEND),I=!1)}function ct(e){G!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),G=e)}function ut(e){0!==e?(st(t.CULL_FACE),e!==H&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):at(t.CULL_FACE),H=e}function dt(e,i,r){e?(st(t.POLYGON_OFFSET_FILL),j===i&&X===r||(j=i,X=r,n.getReversed()&&(i=-i),t.polygonOffset(i,r))):at(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:st,disable:at,bindFramebuffer:function(e,i){return A[e]!==i&&(t.bindFramebuffer(e,i),A[e]=i,e===t.DRAW_FRAMEBUFFER&&(A[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(A[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=R,r=!1;if(e){n=C.get(i),void 0===n&&(n=[],C.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return N!==e&&(t.useProgram(e),N=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?at(t.CULL_FACE):st(t.CULL_FACE);let a=1===e.side;s&&(a=!a),ct(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?st(t.SAMPLE_ALPHA_TO_COVERAGE):at(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ct,setCullFace:ut,setLineWidth:function(e){e!==W&&(Y&&t.lineWidth(e),W=e)},setPolygonOffset:dt,setScissorTest:function(e){e?st(t.SCISSOR_TEST):at(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+q-1),J!==e&&(t.activeTexture(e),J=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===J?t.TEXTURE0+q-1:J);let r=$[n];void 0===r&&(r={type:void 0,texture:void 0},$[n]=r),r.type===e&&r.texture===i||(J!==n&&(t.activeTexture(n),J=n),t.bindTexture(e,i||rt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=$[J];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){Ze("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){Ze("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){Ze("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){Ze("WebGLState:",t)}},pixelStorei:function(e,i){E[e]!==i&&(t.pixelStorei(e,i),E[e]=i)},getParameter:function(e){return void 0!==E[e]?E[e]:t.getParameter(e)},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){Ze("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){Ze("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){Ze("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){Ze("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){Ze("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){Ze("WebGLState:",t)}},scissor:function(e){!1===et.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),et.copy(e))},viewport:function(e){!1===it.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),it.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),o={},E={},J=null,$={},A={},C=new WeakMap,R=[],N=null,I=!1,P=null,L=null,D=null,O=null,U=null,F=null,z=null,k=new _n(0,0,0),B=0,V=!1,G=null,H=null,W=null,j=null,X=null,et.set(0,0,t.canvas.width,t.canvas.height),it.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function Hp(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),h=new ci,c=new WeakMap,u=new Set;let d;const p=new WeakMap;let m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function f(t,e){return m?new OffscreenCanvas(t,e):Ge("canvas")}function g(t,e,i){let n=1;const r=W(t);if((r.width>i||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;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function w(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete p.get(r)[i.__cacheKey],a.memory.textures--}let E=0;function A(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&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;e<r;e++)m=v[e],S?w&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,n,p,m.data):i.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,n,p,m.data);a.generateMipmaps=!1}else S?(T&&i.texStorage2D(t.TEXTURE_2D,E,f,e.width,e.height),w&&function(e,n,r,s){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,r,s,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],r=e.start+e.count,s=L(i.start,n.width,4),l=L(e.start,n.width,4);i.start<=r+1&&s===l&&L(i.start+i.count-1,n.width,4)===s?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const l=i.getParameter(t.UNPACK_ROW_LENGTH),h=i.getParameter(t.UNPACK_SKIP_PIXELS),c=i.getParameter(t.UNPACK_SKIP_ROWS);i.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],l=Math.floor(o.start/4),h=Math.ceil(o.count/4),c=l%n.width,u=Math.floor(l/n.width),d=h,p=1;i.pixelStorei(t.UNPACK_SKIP_PIXELS,c),i.pixelStorei(t.UNPACK_SKIP_ROWS,u),i.texSubImage2D(t.TEXTURE_2D,0,c,u,d,p,r,s,n.data)}e.clearUpdateRanges(),i.pixelStorei(t.UNPACK_ROW_LENGTH,l),i.pixelStorei(t.UNPACK_SKIP_PIXELS,h),i.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,e,n,p)):i.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,n,p,e.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){S&&T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,E,f,v[0].width,v[0].height,e.depth);for(let r=0,s=v.length;r<s;r++)if(m=v[r],a.format!==Mt)if(null!==n)if(S){if(w)if(a.layerUpdates.size>0){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;e<r;e++)m=v[e],a.format!==Mt?null!==n?S?w&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,n,m.data):i.compressedTexImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,m.data):Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):S?w&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,n,p,m.data):i.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,n,p,m.data)}else if(a.isDataArrayTexture)if(S){if(T&&i.texStorage3D(t.TEXTURE_2D_ARRAY,E,f,e.width,e.height,e.depth),w)if(a.layerUpdates.size>0){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<E;e++)i.texImage2D(t.TEXTURE_2D,e,f,r,s,0,n,p,null),r>>=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<r;e++)m=v[e],S?w&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,n,p,m):i.texImage2D(t.TEXTURE_2D,e,f,n,p,m);a.generateMipmaps=!1}else if(S){if(T){const n=W(e);i.texStorage2D(t.TEXTURE_2D,E,f,n.width,n.height)}w&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,n,p,e)}else i.texImage2D(t.TEXTURE_2D,0,f,n,p,e);y(a)&&_(l),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function O(e,r,a,l,h,c){const u=s.convert(a.format,a.colorSpace),d=s.convert(a.type),p=x(a.internalFormat,u,d,a.normalized,a.colorSpace),m=n.get(r),f=n.get(a);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>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<e.length;r++){const a=e[r],l=s.convert(a.format,a.colorSpace),h=s.convert(a.type),c=x(a.internalFormat,l,h,a.normalized,a.colorSpace);G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,V(i),c,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,V(i),c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function F(e,r,a){const l=!0===r.isWebGLCubeRenderTarget;if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const h=n.get(r.depthTexture);if(h.__renderTarget=r,h.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===h.__webglInit&&(h.__webglInit=!0,r.depthTexture.addEventListener("dispose",S)),void 0===h.__webglTexture){h.__webglTexture=t.createTexture(),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),I(t.TEXTURE_CUBE_MAP,r.depthTexture);const e=s.convert(r.depthTexture.format),n=s.convert(r.depthTexture.type);let a;r.depthTexture.format===St?a=t.DEPTH_COMPONENT24:r.depthTexture.format===Tt&&(a=t.DEPTH24_STENCIL8);for(let i=0;i<6;i++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,a,r.width,r.height,0,e,n,null)}}else A(r.depthTexture,0);const c=h.__webglTexture,u=V(r),d=l?t.TEXTURE_CUBE_MAP_POSITIVE_X+a:t.TEXTURE_2D,p=r.depthTexture.format===Tt?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(r.depthTexture.format===St)G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,c,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,c,0);else{if(r.depthTexture.format!==Tt)throw new Error("Unknown depthTexture format");G(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,c,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,c,0)}}function z(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{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;n<A.length;n++){const r=A[n];a.format!==Mt?null!==v?T?E&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,v,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,r.data):Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):T?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,v,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,S,r.width,r.height,0,v,b,r.data)}}}else{if(A=a.mipmaps,T&&w){A.length>0&&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;n<A.length;n++){const r=A[n].image[e].image;T?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,v,b,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,r.width,r.height,0,v,b,r.data)}}else{T?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,v,b,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,v,b,m[e]);for(let n=0;n<A.length;n++){const r=A[n];T?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,v,b,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,S,v,b,r.image[e])}}}y(a)&&_(t.TEXTURE_CUBE_MAP),c.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&O(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&z(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),l=n.get(r);e.addEventListener("dispose",T);const h=e.textures,c=!0===e.isWebGLCubeRenderTarget,u=h.length>1;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;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(u)for(let e=0,i=h.length;e<i;e++){const i=n.get(h[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<h.length;i++){const n=h[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),l=x(n.internalFormat,r,a,n.normalized,n.colorSpace,!0===e.isXRRenderTarget),c=V(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),U(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),I(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);y(r)&&_(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(u){for(let r=0,s=h.length;r<s;r++){const s=h[r],a=n.get(s);let l=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(l=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(l,a.__webglTexture),I(l,s),O(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,l,0),y(s)&&_(l)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,l.__webglTexture),I(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);y(r)&&_(n),i.unbindTexture()}e.depthBuffer&&z(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(y(s)){const e=v(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),_(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)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;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const d=e.texture.mipmaps;d&&d.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),u){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===l&&(k.length=0,B.length=0,k.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(k.push(h),B.push(h),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,B)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,k))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),u)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function Wp(t,e){return{convert:function(i,n=""){let r;const s=xi.getTransfer(n);if(i===ot)return t.UNSIGNED_BYTE;if(i===ft)return t.UNSIGNED_SHORT_4_4_4_4;if(i===gt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===_t)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===vt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===lt)return t.BYTE;if(i===ht)return t.SHORT;if(i===ct)return t.UNSIGNED_SHORT;if(i===ut)return t.INT;if(i===dt)return t.UNSIGNED_INT;if(i===pt)return t.FLOAT;if(i===mt)return t.HALF_FLOAT;if(i===xt)return t.ALPHA;if(i===bt)return t.RGB;if(i===Mt)return t.RGBA;if(i===St)return t.DEPTH_COMPONENT;if(i===Tt)return t.DEPTH_STENCIL;if(i===wt)return t.RED;if(i===Et)return t.RED_INTEGER;if(i===At)return t.RG;if(i===Ct)return t.RG_INTEGER;if(i===Rt)return t.RGBA_INTEGER;if(i===Nt||i===It||i===Pt||i===Lt)if(s===we){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Nt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===It)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Pt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Lt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Nt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===It)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Pt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Lt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Dt||i===Ot||i===Ut||i===Ft){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Dt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ot)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ut)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ft)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===zt||i===kt||i===Bt||i===Vt||i===Gt||i===Ht||i===Wt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===zt||i===kt)return s===we?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Bt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Vt)return r.COMPRESSED_R11_EAC;if(i===Gt)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ht)return r.COMPRESSED_RG11_EAC;if(i===Wt)return r.COMPRESSED_SIGNED_RG11_EAC}if(i===jt||i===Xt||i===qt||i===Yt||i===Zt||i===Kt||i===Jt||i===$t||i===Qt||i===te||i===ee||i===ie||i===ne||i===re){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===jt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Xt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===qt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Yt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Zt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Kt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Jt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===$t)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Qt)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===te)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ee)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ie)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ne)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===re)return s===we?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===se||i===ae||i===oe){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===se)return s===we?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ae)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===oe)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===le||i===he||i===ce||i===ue){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===le)return r.COMPRESSED_RED_RGTC1_EXT;if(i===he)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ce)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===yt?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class jp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new Va(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new Sl({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 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<x.length;t++){const e=b[t];null!==e&&(b[t]=null,x[t].disconnect(e))}C=null,R=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(_),d=null,u=null,c=null,n=null,v=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(S),t.setSize(M.width,M.height,!1),i.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=b.indexOf(i);n>=0&&(b[n]=null,x[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=b.indexOf(i);if(-1===n){for(let t=0;t<x.length;t++){if(t>=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;t<s.length;t++)O(s[t],r);2===s.length?function(t,e,i){L.setFromMatrixPosition(e.matrixWorld),D.setFromMatrixPosition(i.matrixWorld);const n=L.distanceTo(D),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*c,p=a*u,m=n/(-c+u),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,r=d-f,s=p+(n-f),c=l*o/i*e,u=h*o/i*e;t.projectionMatrix.makePerspective(r,s,c,u,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,T,w):A.projectionMatrix.copy(T.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*ii*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new ou;F.setAnimationLoop(function(e,r){if(h=r.getViewerPose(l||s),p=r,null!==h){const e=h.views;null!==d&&(t.setRenderTargetFramebuffer(v,d.framebuffer),t.setRenderTarget(v));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let i=0;i<e.length;i++){const n=e[i];let s=null;if(null!==d)s=d.getViewport(n);else{const e=c.getViewSubImage(u,n);s=e.viewport,0===i&&(t.setRenderTargetTextures(v,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(v))}let a=E[i];void 0===a&&(a=new Eh,a.layers.enable(i),a.viewport=new Ii,E[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(a)}const s=n.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&m){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,n.renderState)}if(s&&s.includes("camera-access")&&m){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new Va,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=b[t],i=x[t];null!==e&&void 0!==i&&i.update(e,r,l||s)}U&&U(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const qp=new Ui,Yp=new fi;function Zp(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(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;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=h(s[t]),a=i%n,o=a%r.boundary,l=a+o;i+=o,0!==l&&n-l<r.storage&&(i+=n-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return Ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=d,i.addEventListener("dispose",c));const p=u.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===l(r,e,n,s)){const e=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const a=i[s],o=h(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):ArrayBuffer.isView(a)?r.__data.set(new a.constructor(a.buffer,a.byteOffset,r.__data.length)):(a.toArray(r.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}Yp.set(-1,0,0,0,1,0,0,0,1);const Jp=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let $p=null;var Qp=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:l,AddOperation:2,AdditiveAnimationBlendMode:xe,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:xt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Dh,AnimationAction:Mc,AnimationClip:$l,AnimationLoader:class 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(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=[];for(let i=0;i<t.length;i++){const n=$l.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends $e{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,l=this._bindingsByRootAndName;let h=l[o];void 0===h&&(h={},l[o]=h);for(let t=0;t!==r;++t){const r=n[t],l=r.name;let c=h[l];if(void 0!==c)++c.referenceCount,s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,l));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new mc(bc.create(i,l,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,l),s[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,l=o[o.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new Vl(new Float32Array(2),new Float32Array(2),1,Sc),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?$l.findByName(n,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===i&&(i=null!==s?s.blendMode:ve),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;l=o.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const h=new Mc(this,s,e,i);return this._bindAction(h,l),this._addInactiveAction(h,a,r),h}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?$l.findByName(i,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=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<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ni(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){const c=arguments[h],u=c.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new bc(c,i[t],n[t]))}else if(d<l){a=t[d];const o=--l,h=t[o];e[h.uuid]=d,t[d]=h,e[u]=o,t[o]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[d];e[d]=s,void 0===a&&(a=new bc(c,i[t],n[t])),e[o]=a}}else t[d]!==a&&Ze("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,l=e[o];if(void 0!==l&&l>=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],l<r){const a=--r,o=t[a],h=--s,c=t[h];e[o.uuid]=l,t[l]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],r=e[h];e[l]=n,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(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<s.tracks.length;++t){const e=s.tracks[t],o=e.getValueSize(),l=[],h=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<i||s>=n)){l.push(e.times[t]);for(let i=0;i<o;++i)h.push(e.values[t*o+i])}}0!==l.length&&(e.times=Ol(l,e.times.constructor),e.values=Ol(h,e.values.constructor),a.push(e))}s.tracks=a;let o=1/0;for(let t=0;t<s.tracks.length;++t)o>s.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*o);return s.resetDuration(),s}(t,e,i,n,r)}static makeClipAdditive(t,e=0,i=t,n=30){return function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,s=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const a=t.tracks.find(function(t){return t.name===n.name&&t.ValueTypeName===r});if(void 0===a)continue;let o=0;const l=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let h=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);const u=n.times.length-1;let d;if(s<=n.times[0]){const t=o,e=l-o;d=n.values.slice(t,e)}else if(s>=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<p;++t){const e=t*c+h;if("quaternion"===r)ui.multiplyQuaternionsFlat(a.values,e,d,0,a.values,e);else{const t=c-2*h;for(let i=0;i<t;++i)a.values[e+i]-=d[i]}}}return t.blendMode=xe,t}(t,e,i,n)}},ArcCurve:io,ArrayCamera:ec,ArrowHelper:class extends cn{constructor(t=new di(0,0,1),e=new di(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===iu&&(iu=new Mr,iu.setAttribute("position",new cr([0,0,0,0,1,0],3)),nu=new Xa(.5,1,5,1),nu.translate(0,-.5,0)),this.position.copy(e),this.line=new Sa(iu,new fa({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ps(nu,new es({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}setDirection(t){if(t.y>.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<e.length;i++)t+=e[i];return t/e.length}},AudioContext:Zh,AudioListener:class extends cn{constructor(){super(),this.type="AudioListener",this.context=Zh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new ic}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t),this._timer.update();const e=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(rc,sc,ac),oc.set(0,0,-1).applyQuaternion(sc),lc.set(0,1,0).applyQuaternion(sc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(rc.x,t),e.positionY.linearRampToValueAtTime(rc.y,t),e.positionZ.linearRampToValueAtTime(rc.z,t),e.forwardX.linearRampToValueAtTime(oc.x,t),e.forwardY.linearRampToValueAtTime(oc.y,t),e.forwardZ.linearRampToValueAtTime(oc.z,t),e.upX.linearRampToValueAtTime(lc.x,t),e.upY.linearRampToValueAtTime(lc.y,t),e.upZ.linearRampToValueAtTime(lc.z,t)}else e.setPosition(rc.x,rc.y,rc.z),e.setOrientation(oc.x,oc.y,oc.z,lc.x,lc.y,lc.z)}},AudioLoader:class extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new oh(this.manager);function a(e){n?n(e):Ze(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(i){try{const n=i.slice(0),s=Zh.getContext(),o=t+"#decode";r.manager.itemStart(o),s.decodeAudioData(n,function(t){e(t),r.manager.itemEnd(o)}).catch(function(t){a(t),r.manager.itemEnd(o)})}catch(t){a(t)}},i,n)}},AxesHelper:class extends Aa{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Mr;i.setAttribute("position",new cr(e,3)),i.setAttribute("color",new cr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new fa({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new _n,r=this.geometry.attributes.color.array;return n.set(t),n.toArray(r,0),n.toArray(r,3),n.set(e),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:ma,BezierInterpolant:Hl,Bone:ws,BooleanKeyframeTrack:jl,Box2:class{constructor(t=new ci(1/0,1/0),e=new ci(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Pc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=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<t.length;++e)o(e);return r}},CubeUVReflectionMapping:J,CubicBezierCurve:mo,CubicBezierCurve3:fo,CubicInterpolant:Bl,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:to,CurvePath:Mo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:ja,Cylindrical:class{constructor(t=1,e=0,i=0){this.radius=t,this.theta=e,this.y=i}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Oi,DataArrayTexture:Di,DataTexture:Es,DataTextureLoader:uh,DataUtils:ir,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:nh,DepthFormat:St,DepthStencilFormat:Tt,DepthTexture:ka,DetachedBindMode:j,DirectionalLight:Lh,DirectionalLightHelper:class extends cn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new Mr;n.setAttribute("position",new cr([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new fa({fog:!1,toneMapped:!1});this.lightPlane=new Sa(n,r),this.add(this.lightPlane),n=new Mr,n.setAttribute("position",new cr([0,0,0,0,0,1],3)),this.targetLine=new Sa(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Yc.setFromMatrixPosition(this.light.matrixWorld),Zc.setFromMatrixPosition(this.light.target.matrixWorld),Kc.subVectors(Zc,Yc),this.lightPlane.lookAt(Zc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Zc),this.targetLine.scale.z=Kc.length()}},DiscreteInterpolant:Gl,DodecahedronGeometry:Ya,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:Qa,EllipseCurve:eo,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:Z,EquirectangularRefractionMapping:K,Euler:Xi,EventDispatcher:$e,ExternalTexture:Va,ExtrudeGeometry:el,FileLoader:oh,Float16BufferAttribute:class extends ar{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=er(this.array[t*this.itemSize]);return this.normalized&&(e=oi(e,this.array)),e}setX(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize]=tr(e),this}getY(t){let e=er(this.array[t*this.itemSize+1]);return this.normalized&&(e=oi(e,this.array)),e}setY(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+1]=tr(e),this}getZ(t){let e=er(this.array[t*this.itemSize+2]);return this.normalized&&(e=oi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+2]=tr(e),this}getW(t){let e=er(this.array[t*this.itemSize+3]);return this.normalized&&(e=oi(e,this.array)),e}setW(t,e){return this.normalized&&(e=li(e,this.array)),this.array[t*this.itemSize+3]=tr(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array)),this.array[t+0]=tr(e),this.array[t+1]=tr(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array)),this.array[t+0]=tr(e),this.array[t+1]=tr(i),this.array[t+2]=tr(n),this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=li(e,this.array),i=li(i,this.array),n=li(n,this.array),r=li(r,this.array)),this.array[t+0]=tr(e),this.array[t+1]=tr(i),this.array[t+2]=tr(n),this.array[t+3]=tr(r),this}},Float32BufferAttribute:cr,FloatType:pt,Fog:bn,FogExp2:xn,FramebufferTexture:class extends Ni{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=et,this.minFilter=et,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:Xs,FrustumArray:Zs,GLBufferAttribute:class{constructor(t,e,i,n,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.normalized=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:Ue,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Le,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends Aa{constructor(t=10,e=10,i=4473924,n=8947848){i=new _n(i),n=new _n(n);const r=e/2,s=t/e,a=t/2,o=[],l=[];for(let t=0,h=0,c=-a;t<=e;t++,c+=s){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?i:n;e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3}const h=new Mr;h.setAttribute("position",new cr(o,3)),h.setAttribute("color",new cr(l,3));super(h,new fa({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:un,HTMLTexture:class extends Ni{constructor(t,e,i,n,r,s,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;const h=t?t.parentNode:null;null!==h&&"requestPaint"in h&&(h.onpaint=()=>{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;t<i;t++){const n=t<i/2?Xc:qc;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(jc.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:nl,ImageBitmapLoader:qh,ImageLoader:ch,ImageUtils:Ti,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Ns,InstancedBufferGeometry:Bh,InstancedInterleavedBuffer:class extends Sr{constructor(t,e,i=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},InstancedMesh:zs,Int16BufferAttribute:class extends ar{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:lr,Int8BufferAttribute:class extends ar{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:ut,InterleavedBuffer:Sr,InterleavedBufferAttribute:Er,Interpolant:kl,InterpolateBezier:fe,InterpolateDiscrete:de,InterpolateLinear:pe,InterpolateSmooth:me,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:Ee,KeyframeTrack:Wl,LOD:Xr,LatheGeometry:rl,Layers:qi,LessCompare:513,LessDepth:2,LessEqualCompare:Ne,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:ph,LightProbe:Fh,Line:Sa,Line3:class{constructor(t=new di,e=new di){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Lc.subVectors(t,this.start),Dc.subVectors(this.end,this.start);const i=Dc.dot(Dc);if(0===i)return 0;let n=Dc.dot(Lc)/i;return e&&(n=ri(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).add(this.start)}distanceSqToLine3(t,e=zc,i=kc){const n=1e-8*1e-8;let r,s;const a=this.start,o=t.start,l=this.end,h=t.end;Oc.subVectors(l,a),Uc.subVectors(h,o),Fc.subVectors(a,o);const c=Oc.dot(Oc),u=Uc.dot(Uc),d=Uc.dot(Fc);if(c<=n&&u<=n)return e.copy(a),i.copy(o),e.sub(i),e.dot(e);if(c<=n)r=0,s=d/u,s=ri(s,0,1);else{const t=Oc.dot(Fc);if(u<=n)s=0,r=ri(-t/c,0,1);else{const e=Oc.dot(Uc),i=c*u-e*e;r=0!==i?ri((e*d-t*u)/i,0,1):0,s=(e*r+d)/u,s<0?(s=0,r=ri(-t/c,0,1)):s>1&&(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;i<n;i++){const n=(new To).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Rs).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Vh;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(a);break;default:a.type in gl?s=gl[a.type].fromJSON(a,e):a.type in Gh?s=Gh[a.type].fromJSON(a,e):Ye(`ObjectLoader: Unknown geometry type "${a.type}". Use .registerGeometry() before starting the deserialization process.`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new zh;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=$l.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:Be(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new ih(e);r=new ch(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=s(r[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Es(i.data,i.width,i.height)))}n[i.uuid]=new Ei(t)}else{const t=s(i.url);n[i.uuid]=new Ei(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function r(t){if("string"==typeof t){const i=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(r)}return t.data?{data:Be(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new ch(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=s[e],n=await r(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Es(n.data,n.width,n.height)))}i[n.uuid]=new Ei(t)}else{const t=await r(n.url);i[n.uuid]=new Ei(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(Ye("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&Ye('ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&Ye("ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let l;Array.isArray(o)?(l=new za,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Es:new Ni,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=i(s.mapping,Hh)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=i(s.wrap[0],Wh),l.wrapT=i(s.wrap[1],Wh)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.minFilter&&(l.minFilter=i(s.minFilter,jh)),void 0!==s.magFilter&&(l.magFilter=i(s.magFilter,jh)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.normalized&&(l.normalized=s.normalized),void 0!==s.userData&&(l.userData=s.userData),n[s.uuid]=l}return n}parseObject(t,e,i,n,r){let s,a,o;function l(t){return void 0===e[t]&&Ye("ObjectLoader: Undefined geometry",t),e[t]}function h(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&Ye("ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&Ye("ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&Ye("ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":s=new Mn,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new _n(t.background):s.background=c(t.background)),void 0!==t.environment&&(s.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new bn(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new xn(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new Eh(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new Ih(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new Dh(t.color,t.intensity);break;case"DirectionalLight":s=new Lh(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new Nh(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new Oh(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new Ch(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new mh(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Uh).fromArray(t.sh);s=new Fh(e,t.intensity);break;case"SkinnedMesh":a=l(t.geometry),o=h(t.material),s=new Ts(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=h(t.material),s=new ps(a,o);break;case"InstancedMesh":a=l(t.geometry),o=h(t.material);const i=t.count,n=t.instanceMatrix,r=t.instanceColor;s=new zs(a,o,i),s.instanceMatrix=new Ns(new Float32Array(n.array),16),void 0!==r&&(s.instanceColor=new Ns(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=h(t.material),s=new ma(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._geometryInfo=t.geometryInfo.map(t=>{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;t<a.length;t++)s.add(this.parseObject(a[t],e,i,n,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];s.animations.push(r[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?Ye("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new cn}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:sl,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:g,OneMinusSrcColorFactor:203,OrthographicCamera:Ih,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Ru,Path:So,PerspectiveCamera:Eh,Plane:Gs,PlaneGeometry:al,PlaneHelper:class extends Sa{constructor(t,e=1,i=16776960){const n=i,r=new Mr;r.setAttribute("position",new cr([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new fa({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new Mr;s.setAttribute("position",new cr([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new ps(s,new es({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:Nh,PointLightHelper:class extends ps{constructor(t,e,i){super(new hl(e,4,2),new es({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:Da,PointsMaterial:Ra,PolarGridHelper:class extends Aa{constructor(t=10,e=16,i=8,n=64,r=4473924,s=8947848){r=new _n(r),s=new _n(s);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),l=Math.sin(n)*t,h=Math.cos(n)*t;a.push(0,0,0),a.push(l,0,h);const c=1&i?r:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const l=1&e?r:s,h=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*h,r=Math.cos(e)*h;a.push(i,0,r),o.push(l.r,l.g,l.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*h,r=Math.cos(e)*h,a.push(i,0,r),o.push(l.r,l.g,l.b)}}const l=new Mr;l.setAttribute("position",new cr(a,3)),l.setAttribute("color",new cr(o,3));super(l,new fa({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:qa,PositionalAudio:class extends hc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(cc,uc,dc),pc.set(0,0,1).applyQuaternion(uc);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(cc.x,t),e.positionY.linearRampToValueAtTime(cc.y,t),e.positionZ.linearRampToValueAtTime(cc.z,t),e.orientationX.linearRampToValueAtTime(pc.x,t),e.orientationY.linearRampToValueAtTime(pc.y,t),e.orientationZ.linearRampToValueAtTime(pc.z,t)}else e.setPosition(cc.x,cc.y,cc.z),e.setOrientation(pc.x,pc.y,pc.z)}},PropertyBinding:bc,PropertyMixer:mc,QuadraticBezierCurve:_o,QuadraticBezierCurve3:vo,Quaternion:ui,QuaternionKeyframeTrack:Zl,QuaternionLinearInterpolant:Yl,R11_EAC_Format:Vt,RED_GREEN_RGTC2_Format:ce,RED_RGTC1_Format:le,REVISION:t,RG11_EAC_Format:Ht,RGBADepthPacking:3201,RGBAFormat:Mt,RGBAIntegerFormat:Rt,RGBA_ASTC_10x10_Format:ie,RGBA_ASTC_10x5_Format:Qt,RGBA_ASTC_10x6_Format:te,RGBA_ASTC_10x8_Format:ee,RGBA_ASTC_12x10_Format:ne,RGBA_ASTC_12x12_Format:re,RGBA_ASTC_4x4_Format:jt,RGBA_ASTC_5x4_Format:Xt,RGBA_ASTC_5x5_Format:qt,RGBA_ASTC_6x5_Format:Yt,RGBA_ASTC_6x6_Format:Zt,RGBA_ASTC_8x5_Format:Kt,RGBA_ASTC_8x6_Format:Jt,RGBA_ASTC_8x8_Format:$t,RGBA_BPTC_Format:se,RGBA_ETC2_EAC_Format:Bt,RGBA_PVRTC_2BPPV1_Format:Ft,RGBA_PVRTC_4BPPV1_Format:Ut,RGBA_S3TC_DXT1_Format:It,RGBA_S3TC_DXT3_Format:Pt,RGBA_S3TC_DXT5_Format:Lt,RGBDepthPacking:3202,RGBFormat:bt,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:ae,RGB_BPTC_UNSIGNED_Format:oe,RGB_ETC1_Format:zt,RGB_ETC2_Format:kt,RGB_PVRTC_2BPPV1_Format:Ot,RGB_PVRTC_4BPPV1_Format:Dt,RGB_S3TC_DXT1_Format:Nt,RGDepthPacking:3203,RGFormat:At,RGIntegerFormat:Ct,RawShaderMaterial:Tl,Ray:ts,Raycaster:Ac,RectAreaLight:Oh,RedFormat:wt,RedIntegerFormat:Et,ReinhardToneMapping:2,RenderTarget:Pi,RenderTarget3D:class extends Pi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Oi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:$,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:ol,SIGNED_R11_EAC_Format:Gt,SIGNED_RED_GREEN_RGTC2_Format:ue,SIGNED_RED_RGTC1_Format:he,SIGNED_RG11_EAC_Format:Wt,SRGBColorSpace:Me,SRGBTransfer:we,Scene:Mn,ShaderChunk:hu,ShaderLib:uu,ShaderMaterial:Sl,ShadowMaterial:yl,Shape:To,ShapeGeometry:ll,ShapePath:ru,ShapeUtils:$o,ShortType:ht,Skeleton:Rs,SkeletonHelper:class extends Aa{constructor(t){const e=Wc(t),i=new Mr,n=[],r=[];for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new cr(n,3)),i.setAttribute("color",new cr(r,3));super(i,new fa({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const s=new _n(255),a=new _n(65280);this.setColors(s,a)}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Hc.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(Gc.multiplyMatrices(Hc,r.matrixWorld),Vc.setFromMatrixPosition(Gc),n.setXYZ(i,Vc.x,Vc.y,Vc.z),Gc.multiplyMatrices(Hc,r.parent.matrixWorld),Vc.setFromMatrixPosition(Gc),n.setXYZ(i+1,Vc.x,Vc.y,Vc.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,t.r,t.g,t.b),i.setXYZ(n+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Ts,Source:Ei,Sphere:mr,SphereGeometry:hl,Spherical:Nc,SphericalHarmonics3:Uh,SplineCurve:xo,SpotLight:Ch,SpotLightHelper:class extends cn{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Mr,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new cr(n,3));const r=new fa({fog:!1,toneMapped:!1});this.cone=new Aa(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Bc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Bc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:Gr,SpriteMaterial:Rr,SrcAlphaFactor:f,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Oe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Eh,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Eh,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,$h.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,r=e.near*Math.tan(ei*e.fov*.5)/e.zoom;let s,a;Jh.elements[12]=-i,Kh.elements[12]=i,s=-r*e.aspect+n,a=r*e.aspect+n,$h.elements[0]=2*e.near/(a-s),$h.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy($h),s=-r*e.aspect-n,a=r*e.aspect-n,$h.elements[0]=2*e.near/(a-s),$h.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy($h)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Jh),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Kh)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Kl,SubtractEquation:101,SubtractiveBlending:3,TOUCH:i,TangentSpaceNormalMap:0,TetrahedronGeometry:cl,Texture:Ni,TextureLoader:dh,TextureUtils:class{static contain(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=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;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:cu,UniformsUtils:Ml,UnsignedByteType:ot,UnsignedInt101111Type:vt,UnsignedInt248Type:yt,UnsignedInt5999Type:_t,UnsignedIntType:dt,UnsignedShort4444Type:ft,UnsignedShort5551Type:gt,UnsignedShortType:ct,VSMShadowMap:3,Vector2:ci,Vector3:di,Vector4:Ii,VectorKeyframeTrack:Jl,VideoFrameTexture:class extends Ua{constructor(t,e,i,n,r,s,a,o){super({},t,e,i,n,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:Ua,WebGL3DRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Oi(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Di(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:Fe,WebGLCubeRenderTarget:Ou,WebGLRenderTarget:Li,WebGLRenderer:class{constructor(e={}){const{canvas:i=He(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=ot}=e;let m;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const f=p,g=new Set([Rt,Ct,Et]),y=new Set([ot,dt,ct,yt,ft,gt]),_=new Uint32Array(4),v=new Int32Array(4),x=new di;let b=null,M=null;const S=[],T=[];let w=null;this.domElement=i,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let A=!1,C=null;this._outputColorSpace=Me;let R=0,N=0,I=null,P=-1,L=null;const D=new Ii,O=new Ii;let U=null;const F=new _n(0);let z=0,k=i.width,B=i.height,V=1,G=null,H=null;const W=new Ii(0,0,k,B),j=new Ii(0,0,k,B);let X=!1;const q=new Xs;let Y=!1,Z=!1;const K=new Ui,J=new di,$=new Ii,tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function it(){return null===I?V:1}let nt,st,lt,ht,ut,pt,_t,vt,xt,bt,Mt,St,Tt,wt,Nt,It,Pt,Lt,Dt,Ot,Ut,Ft,zt,kt=n;function Bt(t,e){return i.getContext(t,e)}try{const e={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${t}`),i.addEventListener("webglcontextlost",Ht,!1),i.addEventListener("webglcontextrestored",Wt,!1),i.addEventListener("webglcontextcreationerror",jt,!1),null===kt){const t="webgl2";if(kt=Bt(t,e),null===kt)throw Bt(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw Ze("WebGLRenderer: "+t.message),t}function Vt(){nt=new Fu(kt),nt.init(),Ut=new Wp(kt,nt),st=new _u(kt,nt,e,Ut),lt=new Gp(kt,nt),st.reversedDepthBuffer&&d&&lt.buffers.depth.setReversed(!0),ht=new Bu(kt),ut=new wp,pt=new Hp(kt,nt,lt,ut,st,Ut,ht),_t=new Uu(E),vt=new lu(kt),Ft=new gu(kt,vt),xt=new zu(kt,vt,ht,Ft),bt=new Gu(kt,xt,vt,Ft,ht),Lt=new Vu(kt,st,pt),Nt=new vu(ut),Mt=new Tp(E,_t,nt,st,Ft,Nt),St=new Zp(E,ut),Tt=new Rp,wt=new Op(nt),Pt=new fu(E,_t,lt,bt,m,l),It=new Vp(E,bt,st),zt=new Kp(kt,ht,st,lt),Dt=new yu(kt,nt,ht),Ot=new ku(kt,nt,ht),ht.programs=Mt.programs,E.capabilities=st,E.extensions=nt,E.properties=ut,E.renderLists=Tt,E.shadowMap=It,E.state=lt,E.info=ht}Vt(),f!==ot&&(w=new Wu(f,i.width,i.height,r,s));const Gt=new Xp(E,kt);function Ht(t){t.preventDefault(),Xe("WebGLRenderer: Context Lost."),A=!0}function Wt(){Xe("WebGLRenderer: Context Restored."),A=!1;const t=ht.autoReset,e=It.enabled,i=It.autoUpdate,n=It.needsUpdate,r=It.type;Vt(),ht.autoReset=t,It.enabled=e,It.autoUpdate=i,It.needsUpdate=n,It.type=r}function jt(t){Ze("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Xt(t){const e=t.target;e.removeEventListener("dispose",Xt),function(t){(function(t){const e=ut.get(t).programs;void 0!==e&&(e.forEach(function(t){Mt.releaseProgram(t)}),t.isShaderMaterial&&Mt.releaseShaderCache(t))})(t),ut.remove(t)}(e)}function qt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,ne(t,e,i),t.side=0,t.needsUpdate=!0,ne(t,e,i),t.side=2):ne(t,e,i)}this.xr=Gt,this.getContext=function(){return kt},this.getContextAttributes=function(){return kt.getContextAttributes()},this.forceContextLoss=function(){const t=nt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=nt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(t){void 0!==t&&(V=t,this.setSize(k,B,!1))},this.getSize=function(t){return t.set(k,B)},this.setSize=function(t,e,n=!0){Gt.isPresenting?Ye("WebGLRenderer: Can't change size while VR device is presenting."):(k=t,B=e,i.width=Math.floor(t*V),i.height=Math.floor(e*V),!0===n&&(i.style.width=t+"px",i.style.height=e+"px"),null!==w&&w.setSize(i.width,i.height),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(t){return t.set(k*V,B*V).floor()},this.setDrawingBufferSize=function(t,e,n){k=t,B=e,V=n,i.width=Math.floor(t*n),i.height=Math.floor(e*n),this.setViewport(0,0,t,e)},this.setEffects=function(t){if(f!==ot){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){Ye("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}w.setEffects(t||[])}else Ze("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(D)},this.getViewport=function(t){return t.copy(W)},this.setViewport=function(t,e,i,n){t.isVector4?W.set(t.x,t.y,t.z,t.w):W.set(t,e,i,n),lt.viewport(D.copy(W).multiplyScalar(V).round())},this.getScissor=function(t){return t.copy(j)},this.setScissor=function(t,e,i,n){t.isVector4?j.set(t.x,t.y,t.z,t.w):j.set(t,e,i,n),lt.scissor(O.copy(j).multiplyScalar(V).round())},this.getScissorTest=function(){return X},this.setScissorTest=function(t){lt.setScissorTest(X=t)},this.setOpaqueSort=function(t){G=t},this.setTransparentSort=function(t){H=t},this.getClearColor=function(t){return t.copy(Pt.getClearColor())},this.setClearColor=function(){Pt.setClearColor(...arguments)},this.getClearAlpha=function(){return Pt.getClearAlpha()},this.setClearAlpha=function(){Pt.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==I){const e=I.texture.format;t=g.has(e)}if(t){const t=I.texture.type,e=y.has(t),i=Pt.getClearColor(),n=Pt.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(_[0]=r,_[1]=s,_[2]=a,_[3]=n,kt.clearBufferuiv(kt.COLOR,0,_)):(v[0]=r,v[1]=s,v[2]=a,v[3]=n,kt.clearBufferiv(kt.COLOR,0,v))}else n|=kt.COLOR_BUFFER_BIT}e&&(n|=kt.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),i&&(n|=kt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==n&&kt.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(t){t.setRenderer(this),C=t},this.dispose=function(){i.removeEventListener("webglcontextlost",Ht,!1),i.removeEventListener("webglcontextrestored",Wt,!1),i.removeEventListener("webglcontextcreationerror",jt,!1),Pt.dispose(),Tt.dispose(),wt.dispose(),ut.dispose(),_t.dispose(),bt.dispose(),Ft.dispose(),zt.dispose(),Mt.dispose(),Gt.dispose(),Gt.removeEventListener("sessionstart",Zt),Gt.removeEventListener("sessionend",Kt),Jt.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=tt);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=tt);pt.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial?e.environment:null,o=null===I?E.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:xi.workingColorSpace,l=n.isMeshStandardMaterial||n.isMeshLambertMaterial&&!n.envMap||n.isMeshPhongMaterial&&!n.envMap,h=_t.get(n.envMap||a,l),c=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,u=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),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;e<i;e++){const i=t[e];if(null!==i.texture&&i.boundingBox.containsPoint(x))return i}return null}(M.state.lightProbeGridArray,r);_.lightProbeGrid!==t&&(_.lightProbeGrid=t,w=!0)}if(T||L!==t){lt.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),R.setValue(kt,"projectionMatrix",t.projectionMatrix),R.setValue(kt,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(kt,J.setFromMatrixPosition(t.matrixWorld)),st.logarithmicDepthBuffer&&R.setValue(kt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(kt,"isOrthographic",!0===t.isOrthographicCamera),L!==t&&(L=t,w=!0,A=!0)}_.needsLights&&(v.state.directionalShadowMap.length>0&&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<i;e++){const i=t[e];zt.update(i,S),zt.bind(i,S)}}return S}(t,e,i,n,r);lt.setMaterial(n,a);let l=i.index,h=1;if(!0===n.wireframe){if(l=xt.getWireframeAttribute(i),void 0===l)return;h=2}const c=i.drawRange,u=i.attributes.position;let d=c.start*h,p=(c.start+c.count)*h;null!==s&&(d=Math.max(d,s.start*h),p=Math.min(p,(s.start+s.count)*h)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const m=p-d;if(m<0||m===1/0)return;let f;Ft.setup(r,n,o,i,l);let g=Dt;if(null!==l&&(f=vt.get(l),g=Ot,g.setIndex(f)),r.isMesh)!0===n.wireframe?(lt.setLineWidth(n.wireframeLinewidth*it()),g.setMode(kt.LINES)):g.setMode(kt.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),lt.setLineWidth(t*it()),r.isLineSegments?g.setMode(kt.LINES):r.isLineLoop?g.setMode(kt.LINE_LOOP):g.setMode(kt.LINE_STRIP)}else r.isPoints?g.setMode(kt.POINTS):r.isSprite&&g.setMode(kt.TRIANGLES);if(r.isBatchedMesh)if(nt.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=l?vt.get(l).bytesPerElement:1,a=ut.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(kt,"_gl_DrawID",n),g.render(t[n]/s,e[n])}else if(r.isInstancedMesh)g.renderInstances(d,m,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);g.renderInstances(d,m,e)}else g.render(d,m)},this.compile=function(t,e,i=null){null===i&&(i=t),M=wt.get(i),M.init(e),T.push(M),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(M.pushLight(t),t.castShadow&&M.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(M.pushLight(t),t.castShadow&&M.pushShadow(t))}),M.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];qt(s,i,t),n.add(s)}else qt(e,i,t),n.add(e)}),M=T.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(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;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&b.push(t,e,o,i,$.z,a)}}else r.visible&&b.push(t,e,r,i,$.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)$t(r[t],e,i,n)}function Qt(t,e,i,n){const{opaque:r,transmissive:s,transparent:a}=t;M.setupLightsView(i),!0===Y&&Nt.setGlobalState(E.clippingPlanes,i),n&&lt.viewport(D.copy(n)),r.length>0&&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;r<s;r++){const s=e[r],{object:a,geometry:o,material:l,group:h}=s;if(2===l.side&&a.layers.test(n.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,ie(a,i,n,o,l,h),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(pt.updateMultisampleRenderTarget(r),pt.updateRenderTargetMipmap(r))}E.setRenderTarget(o,l,h),E.setClearColor(F,z),void 0!==u&&(n.viewport=u),E.toneMapping=c}function ee(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],{object:a,geometry:o,group:l}=s;let h=s.material;!0===h.allowOverride&&null!==n&&(h=n),a.layers.test(i.layers)&&ie(a,e,i,o,h,l)}}function ie(t,e,i,n,r,s){t.onBeforeRender(E,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(E,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,E.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,E.renderBufferDirect(i,e,n,r,t,s),r.side=2):E.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(E,e,i,n,r,s)}function ne(t,e,i){!0!==e.isScene&&(e=tt);const n=ut.get(t),r=M.state.lights,s=M.state.shadowsArray,a=r.state.version,o=Mt.getParameters(t,r.state,s,e,i,M.state.lightProbeGridArray),l=Mt.getProgramCacheKey(o);let h=n.programs;n.environment=t.isMeshStandardMaterial||t.isMeshLambertMaterial||t.isMeshPhongMaterial?e.environment:null,n.fog=e.fog;const c=t.isMeshStandardMaterial||t.isMeshLambertMaterial&&!t.envMap||t.isMeshPhongMaterial&&!t.envMap;n.envMap=_t.get(t.envMap||n.environment,c),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===h&&(t.addEventListener("dispose",Xt),h=new Map,n.programs=h);let u=h.get(l);if(void 0!==u){if(n.currentProgram===u&&n.lightsStateVersion===a)return se(t,o),u}else o.uniforms=Mt.getUniforms(t),null!==C&&t.isNodeMaterial&&C.build(t,i,o),t.onBeforeCompile(o,E),u=Mt.acquireProgram(o,l),h.set(l,u),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=Nt.uniform),se(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),n.lightProbeGrid=M.state.lightProbeGridArray.length>0,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;e<s;e++){te(i,n,t,r[e])}et&&Pt.render(t);for(let e=0,i=r.length;e<i;e++){const i=r[e];Qt(b,t,i,i.viewport)}}else n.length>0&&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)&&lt.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;e<t.textures.length;e++){const r=ut.get(t.textures[e]);kt.framebufferTextureLayer(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0+e,r.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=ut.get(t.texture);kt.framebufferTexture2D(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,e.__webglTexture,i)}P=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)return void Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ut.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){lt.bindFramebuffer(kt.FRAMEBUFFER,l);try{const a=t.textures[o],l=a.format,h=a.type;if(t.textures.length>1&&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;i<l;i++)T&&(kt.framebufferTextureLayer(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,ut.get(t).__webglTexture,r,u+i),kt.framebufferTextureLayer(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,ut.get(e).__webglTexture,s,m+i)),kt.blitFramebuffer(h,c,a,o,d,p,a,o,kt.DEPTH_BUFFER_BIT,kt.NEAREST);lt.bindFramebuffer(kt.READ_FRAMEBUFFER,null),lt.bindFramebuffer(kt.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||ut.has(t)){const i=ut.get(t),n=ut.get(e);lt.bindFramebuffer(kt.READ_FRAMEBUFFER,oe),lt.bindFramebuffer(kt.DRAW_FRAMEBUFFER,le);for(let t=0;t<l;t++)T?kt.framebufferTextureLayer(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,i.__webglTexture,r,u+t):kt.framebufferTexture2D(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,i.__webglTexture,r),w?kt.framebufferTextureLayer(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,n.__webglTexture,s,m+t):kt.framebufferTexture2D(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,n.__webglTexture,s),0!==r?kt.blitFramebuffer(h,c,a,o,d,p,a,o,kt.COLOR_BUFFER_BIT,kt.NEAREST):w?kt.copyTexSubImage3D(_,s,d,p,m+t,h,c,a,o):kt.copyTexSubImage2D(_,s,d,p,h,c,a,o);lt.bindFramebuffer(kt.READ_FRAMEBUFFER,null),lt.bindFramebuffer(kt.DRAW_FRAMEBUFFER,null)}else w?t.isDataTexture||t.isData3DTexture?kt.texSubImage3D(_,s,d,p,m,a,o,l,g,y,f.data):e.isCompressedArrayTexture?kt.compressedTexSubImage3D(_,s,d,p,m,a,o,l,g,f.data):kt.texSubImage3D(_,s,d,p,m,a,o,l,g,y,f):t.isDataTexture?kt.texSubImage2D(kt.TEXTURE_2D,s,d,p,a,o,g,y,f.data):t.isCompressedTexture?kt.compressedTexSubImage2D(kt.TEXTURE_2D,s,d,p,f.width,f.height,g,f.data):kt.texSubImage2D(kt.TEXTURE_2D,s,d,p,a,o,g,y,f);lt.pixelStorei(kt.UNPACK_ROW_LENGTH,v),lt.pixelStorei(kt.UNPACK_IMAGE_HEIGHT,x),lt.pixelStorei(kt.UNPACK_SKIP_PIXELS,b),lt.pixelStorei(kt.UNPACK_SKIP_ROWS,M),lt.pixelStorei(kt.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&kt.generateMipmap(_),lt.unbindTexture()},this.initRenderTarget=function(t){void 0===ut.get(t).__webglFramebuffer&&pt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?pt.setTextureCube(t,0):t.isData3DTexture?pt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?pt.setTexture2DArray(t,0):pt.setTexture2D(t,0),lt.unbindTexture()},this.resetState=function(){R=0,N=0,I=null,lt.reset(),Ft.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Fe}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=xi._getDrawingBufferColorSpace(t),e.unpackColorSpace=xi._getUnpackColorSpace()}},WebGLUtils:Wp,WebGPUCoordinateSystem:ze,WebXRController:pn,WireframeGeometry:ml,WrapAroundEnding:_e,ZeroCurvatureEnding:ge,ZeroFactor:200,ZeroSlopeEnding:ye,ZeroStencilOp:0,createCanvasElement:He,error:Ze,getConsoleFunction:function(){return je},log:Xe,setConsoleFunction:function(t){je=t},warn:Ye,warnOnce:Ke}),tm=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return this.None(t)},Out:function(t){return this.None(t)},InOut:function(t){return this.None(t)}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(t){var e=1.70158;return 1===t?1:t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return 0===t?0:--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}}),Bounce:Object.freeze({In:function(t){return 1-tm.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*tm.Bounce.In(2*t):.5*tm.Bounce.Out(2*t-1)+.5}}),generatePow:function(t){return void 0===t&&(t=4),t=(t=t<Number.EPSILON?Number.EPSILON:t)>1e4?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;n<i.length;n++){var r=this._tweens[i[n]],s=!e;r&&!1===r.update(t,s)&&!e&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),nm={Linear:function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n),s=nm.Utils.Linear;return e<0?s(t[0],t[1],n):e>1?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;u<d;u+=1){var p=this._handleRelativeValue(a,g[u]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}c.push(p)}h&&(i[s]=c)}if("object"!==l&&!o||!a||h)(void 0===e[s]||r)&&(e[s]=a),o||(e[s]*=1),n[s]=h?i[s].slice().reverse():e[s]||0;else{e[s]=o?[]:{};var m=a;for(var f in m)e[s][f]=m[f];n[s]=o?[]:{};var g=i[s];if(!this._isDynamic){var y={};for(var f in g)y[f]=g[f];i[s]=g=y}this._setupProperties(m,e[s],g,n[s],r)}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=em()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=em()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return void 0===t&&(t=sm),this._group=t,this},t.prototype.delay=function(t){return void 0===t&&(t=0),this._delayTime=t,this},t.prototype.repeat=function(t){return void 0===t&&(t=0),this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return void 0===t&&(t=!1),this._yoyo=t,this},t.prototype.easing=function(t){return void 0===t&&(t=tm.Linear.None),this._easingFunction=t,this},t.prototype.interpolation=function(t){return void 0===t&&(t=nm.Linear),this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){var i,n,r=this;if(void 0===t&&(t=em()),void 0===e&&(e=!0),this._isPaused)return!0;var s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>s)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),!1===this._onEveryStartCallbackFired&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=t-this._startTime,o=this._duration+(null!==(i=this._repeatDelayTime)&&void 0!==i?i:this._delayTime),l=this._duration+this._repeat*o,h=function(){if(0===r._duration)return 1;if(a>l)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<p;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,i,n){for(var r in i)if(void 0!==e[r]){var s=e[r]||0,a=i[r],o=Array.isArray(t[r]),l=Array.isArray(a);!o&&l?t[r]=this._interpolationFunction(a,n):"object"==typeof a&&a?this._updateProperties(t[r],s,a,n):"number"==typeof(a=this._handleRelativeValue(s,a))&&(t[r]=s+(a-s)*n)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof i?this._valuesStartRepeat[t]+parseFloat(i):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),om=sm;om.getAll.bind(om),om.removeAll.bind(om),om.add.bind(om),om.remove.bind(om),om.update.bind(om);var lm={Easing:tm,Tween:am};const hm="vertex",cm="none",um="frame",dm="render",pm="object",mm=["x","y","z","w"],fm=1001,gm=1003,ym=1006,_m="srgb",vm="srgb-linear",xm="linear",bm="srgb",Mm=35044,Sm=2e3,Tm=2001,wm="depthTextureCompare";function Em(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const Am={};function Cm(...t){const e="THREE."+t.shift();console.log(e,...t)}function Rm(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 Nm(...t){const e="THREE."+(t=Rm(t)).shift();{const i=t[0];i&&i.isStackTrace?console.warn(i.getError(e)):console.warn(e,...t)}}function Im(...t){const e="THREE."+(t=Rm(t)).shift();{const i=t[0];i&&i.isStackTrace?console.error(i.getError(e)):console.error(e,...t)}}function Pm(...t){const e=t.join(" ");e in Am||(Am[e]=!0,Nm(...t))}const Lm=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Dm=1234567;const Om=Math.PI/180,Um=180/Math.PI;function Fm(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Lm[255&t]+Lm[t>>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+(n<r?6:0);break;case n:o=(r-i)/t+2;break;case r:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=Zm.workingColorSpace){return Zm.workingToColorSpace(rf.copy(this),e),t.r=rf.r,t.g=rf.g,t.b=rf.b,t}getStyle(t=_m){Zm.workingToColorSpace(rf.copy(this),t);const e=rf.r,i=rf.g,n=rf.b;return t!==_m?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(Qm),this.setHSL(Qm.h+t,Qm.s+e,Qm.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Qm),t.getHSL(tf);const i=Bm(Qm.h,tf.h,e),n=Bm(Qm.s,tf.s,e),r=Bm(Qm.l,tf.l,e);return this.setHSL(i,n,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,r=t.elements;return this.r=r[0]*e+r[3]*i+r[6]*n,this.g=r[1]*e+r[4]*i+r[7]*n,this.b=r[2]*e+r[5]*i+r[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const rf=new nf;nf.NAMES=$m;class sf{static{sf.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const r=this.elements;return r[0]=t,r[2]=e,r[1]=i,r[3]=n,this}}let af=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:Nm("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(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)<s&&Math.abs(c-m)<s&&Math.abs(p-f)<s){if(Math.abs(h+u)<a&&Math.abs(c+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,y=(g+1)/2,_=(h+u)/4,v=(c+m)/4,x=(p+f)/4;return t>o&&t>y?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=_/i,r=v/i):o>y?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=_/n,r=x/n):y<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(y),i=v/r,n=x/r),this.set(i,n,r,e),this}let y=Math.sqrt((f-p)*(f-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(f-p)/y,this.y=(c-m)/y,this.z=(u-h)/y,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=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.w=zm(this.w,t.w,e.w),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.w=zm(this.w,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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,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.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}const xf=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];class bf{constructor(t=null){this.isStackTrace=!0,this.stack=function(t){const e=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return t.split("\n").map(t=>{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<t.length;r++)e=t[r],i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);else for(let e,r=0;r<t.length;r++)e=t.charCodeAt(r),i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);return i=Math.imul(i^i>>>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;i<n;i++)e[i].call(this,t);t.target=null}}}const Cf={analyze:"setup",generate:"analyze"};let Rf=0,Nf=class t extends Af{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=cm,this.updateBeforeType=cm,this.updateAfterType=cm,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=Rf++,this.stackTrace=null,!0===t.captureStackTrace&&(this.stackTrace=new bf)}set needsUpdate(t){!0===t&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=Hm.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,um)}onRenderUpdate(t){return this.onUpdate(t,dm)}onObjectUpdate(t){return this.onUpdate(t,pm)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){const e=[];t.add(this);for(const i of Object.getOwnPropertyNames(this)){const n=this[i];if(!0!==i.startsWith("_")&&!t.has(n))if(!0===Array.isArray(n))for(let t=0;t<n.length;t++){const r=n[t];r&&!0===r.isNode&&e.push({property:i,index:t,childNode:r})}else if(n&&!0===n.isNode)e.push({property:i,childNode:n});else if(n&&Object.getPrototypeOf(n)===Object.prototype)for(const t in n){if(!0===t.startsWith("_"))continue;const r=n[t];r&&!0===r.isNode&&e.push({property:i,index:t,childNode:r})}}return e}getCacheKey(t=!1,e=null){if(!0===(t=t||this.version!==this._cacheKeyVersion)||null===this._cacheKey){null===e&&(e=new Set);const i=[];for(const{property:n,childNode:r}of this._getChildren(e))i.push(Sf(n.slice(0,-4)),r.getCacheKey(t,e));this._cacheKey=Tf((t=>Mf(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<h;t++){const e=mm[t];e===i[0]?(c.push(o),t+=i.length-1):c.push(l+"."+e)}return`${t.getType(r)}( ${c.join(", ")} )`}}class zf extends If{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:i}=this,n=this.getNodeType(t),r=i.build(t),s=t.getVarFromNode(this),a=t.getPropertyName(s);t.addLineFlowCode(a+" = "+r,this);const o=t.getTypeLength(n),l=[];let h=0;for(let t=0;t<o;t++){const i=mm[t];i===e[h]?(l.push("1.0 - "+a+"."+i),h++):l.push(a+"."+i)}return`${t.getType(n)}( ${l.join(", ")} )`}}class kf extends Nf{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}generateNodeType(){return null===this.nodeType?wf(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=wf(this.value),t.nodeType=this.nodeType,"ArrayBuffer"===t.valueType&&(t.value=function(t){let e="";const i=new Uint8Array(t);for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return btoa(e)}(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?Ef(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){Nm("Abstract function.")}}const Bf=/float|u?int/;class Vf extends kf{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const i=this.getNodeType(t);return Bf.test(i)&&Bf.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),i,e)}}class Gf extends Nf{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(t))&&"void"!==this.structNode.getMemberType(t,this.property)}generateNodeType(t){return!1===this.hasMember(t)?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(!1===this.hasMember(t))return"float";const i=this.getNodeType(t);return t.getStructTypeNode(i).getMemberType(t,e)}generate(t){if(!1===this.hasMember(t)){Nm(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const e=this.getNodeType(t);return t.generateConst(e)}return this.structNode.build(t)+"."+this.property}}const Hf=new Map;function Wf(t,e){if(Hf.has(t))Nm(`TSL: Redefinition of method chaining '${t}'.`);else{if("function"!=typeof e)throw new Error(`THREE.TSL: Node element ${t} is not a function`);Hf.set(t,e),"assign"!==t&&(Nf.prototype[t]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},Nf.prototype[t+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}}const jf=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;n<i;n++)t[n]=yg(t[n],e);return t},tg=function(t,e=null,i=null,n=null){function r(t){return null!==n?(t=yg(Object.assign(t,n)),!0===n.intent&&(t=t.toVarIntent())):t=yg(t),t}let s,a,o,l=e;function h(e){let i;return i=l?/[a-z]/i.test(l)?l+"()":l:t.type,void 0!==a&&e.length<a?(Im(`TSL: "${i}" parameter length is less than minimum required.`,new bf),e.concat(new Array(a-e.length).fill(0))):void 0!==o&&e.length>o?(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;e<l.components.length;e++){const i=l.components[e];t.addLineFlowCode(`${h}.${i} = ${r}[ ${e} ]`,this)}"void"!==e&&(c=s)}else c=`${s} = ${o}`,"void"!==e&&"void"!==l||(t.addLineFlowCode(c,this),"void"!==e&&(c=s));return h.initialized=!0,t.format(c,a,e)}}Wf("assign",bg(Kg).setParameterLength(2));class Jg extends Nf{static get type(){return"UniformGroupNode"}constructor(t,e=!1,i=1,n=null){super("string"),this.name=t,this.shared=e,this.order=i,this.updateType=n,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const $g=(t,e=1,i=null)=>new 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<n.length)for(Im("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");r.length<n.length;)r.push(Ng(0));for(let t=0;t<r.length;t++)e.push(s(r[t],n[t]))}else for(const t of n){const i=r[t.name];void 0!==i?e.push(s(i,t)):(Im(`TSL: Input '${t.name}' not found in 'Fn()'.`),e.push(s(Ng(0),t)))}return`${i.build(t,"property")}( ${e.join(", ")} )`}}Wf("call",(t,...e)=>(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<n.length-1;e++)r=new ly(t,r,n[e]);e=r,i=n[n.length-1]}this.op=t,this.aNode=e,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(oy[this.op],e)}generateNodeType(t,e=null){const i=this.op,n=this.aNode,r=this.bNode,s=n.getNodeType(t),a=r?r.getNodeType(t):null;if("void"===s||"void"===a)return e||"void";if("%"===i)return s;if("~"===i||"&"===i||"|"===i||"^"===i||">>"===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;e<arguments.length-1;e++)r=new Dy(t,r,arguments[e]);e=r,i=arguments[arguments.length-1],n=null}this.method=t,this.aNode=e,this.bNode=i,this.cNode=n,this.isMathNode=!0}getInputType(t){const e=this.aNode.getNodeType(t),i=this.bNode?this.bNode.getNodeType(t):null,n=this.cNode?this.cNode.getNodeType(t):null,r=t.isMatrix(e)?0:t.getTypeLength(e),s=t.isMatrix(i)?0:t.getTypeLength(i),a=t.isMatrix(n)?0:t.getTypeLength(n);return r>s&&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;t<e.length;t++)i=i[e[t]];return i}updateReference(t){return this.reference=null!==this.object?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class nv extends iv{static get type(){return"RendererReferenceNode"}constructor(t,e,i=null){super(t,e,i),this.renderer=i,this.setGroup(ty)}updateReference(t){return this.reference=null!==this.renderer?this.renderer:t.renderer,this.reference}}const rv=(t,e,i=null)=>new 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;n<r;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)lv.fromBufferAttribute(this,e),lv.applyMatrix3(t),this.setXY(e,lv.x,lv.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)ov.fromBufferAttribute(this,e),ov.applyMatrix3(t),this.setXYZ(e,ov.x,ov.y,ov.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)ov.fromBufferAttribute(this,e),ov.applyMatrix4(t),this.setXYZ(e,ov.x,ov.y,ov.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)ov.fromBufferAttribute(this,e),ov.applyNormalMatrix(t),this.setXYZ(e,ov.x,ov.y,ov.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)ov.fromBufferAttribute(this,e),ov.transformDirection(t),this.setXYZ(e,ov.x,ov.y,ov.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Vm(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Gm(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Vm(e,this.array)),e}setX(t,e){return this.normalized&&(e=Gm(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Vm(e,this.array)),e}setY(t,e){return this.normalized&&(e=Gm(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Vm(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Gm(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Vm(e,this.array)),e}setW(t,e){return this.normalized&&(e=Gm(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array),n=Gm(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array),n=Gm(n,this.array),r=Gm(r,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Mm&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}const uv=new of;class dv{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)uv.fromBufferAttribute(this,e),uv.applyMatrix4(t),this.setXYZ(e,uv.x,uv.y,uv.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)uv.fromBufferAttribute(this,e),uv.applyNormalMatrix(t),this.setXYZ(e,uv.x,uv.y,uv.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)uv.fromBufferAttribute(this,e),uv.transformDirection(t),this.setXYZ(e,uv.x,uv.y,uv.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Vm(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Gm(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=Gm(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Gm(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Gm(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Gm(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Vm(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Vm(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Vm(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Vm(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array),n=Gm(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Gm(e,this.array),i=Gm(i,this.array),n=Gm(n,this.array),r=Gm(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this}clone(t){if(void 0===t){Cm("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new cv(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new dv(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){Cm("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class pv{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Mm,this.updateRanges=[],this.version=0,this.uuid=Fm()}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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Fm()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Fm()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const mv=new WeakMap;function fv(t,e){let i=mv.get(t);return void 0===i&&(i=new pv(t,e),mv.set(t,i)),i}class gv extends kf{static get type(){return"BufferAttributeNode"}constructor(t,e=null,i=0,n=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=i,this.bufferOffset=n,this.usage=Mm,this.instanced=!1,this.attribute=null,this.global=!0,t&&!0===t.isBufferAttribute&&t.itemSize<=4&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){let e;if(0===this.bufferStride&&0===this.bufferOffset){let i=t.globalCache.getData(this.value);void 0===i&&(i={node:this},t.globalCache.setData(this.value,i)),e=i.node.id}else e=this.id;return String(e)}generateNodeType(t){return null===this.bufferType&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(null!==this.attribute)return;const e=this.getNodeType(t),i=t.getTypeLength(e),n=this.value,r=this.bufferStride||i,s=this.bufferOffset;let a;a=!0===n.isInterleavedBuffer?n:!0===n.isBufferAttribute?fv(n.array,r):fv(n,r);const o=new dv(a,i,s);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),i=t.getBufferAttributeFromNode(this,e),n=t.getPropertyName(i);let r=null;if("vertex"===t.shaderStage||"compute"===t.shaderStage)this.name=n,r=n;else{r=Z_(this).build(t,e)}return r}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}const yv=(t,e=null,i=0,n=0)=>function(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<e.length;t++){const i=e[t];("number"!=typeof i||i<=0||!Number.isInteger(i))&&Im(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`,new bf)}for(;e.length<3;)e.push(1);return new xv(yg(t),e)};Wf("compute",(t,e,i)=>{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;t<r.length;t++)r[t]=255*Km(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Km(e[t]/255)):e[t]=Km(e[t]);return{data:e,width:t.width,height:t.height}}return Nm("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Vv=0;class Gv{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Vv++}),this.uuid=Fm(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(Hv(n[e].image)):t.push(Hv(n[e]))}else t=Hv(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Hv(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Bv.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Nm("Texture: Unable to serialize Texture."),{})}let Wv=0;const jv=new of;class Xv extends Af{constructor(t=Xv.DEFAULT_IMAGE,e=Xv.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=1009,l=Xv.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wv++}),this.uuid=Fm(),this.name="",this.source=new Gv(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new _f(0,0),this.repeat=new _f(1,1),this.center=new _f(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Wm,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,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;i<t.length;i++){e[4*i]=t[i]}else if("color"===i)for(let i=0;i<t.length;i++){const n=4*i,r=t[i];e[n]=r.r,e[n+1]=r.g,e[n+2]=r.b||0}else if("mat2"===i)for(let i=0;i<t.length;i++){const n=4*i,r=t[i];e[n]=r.elements[0],e[n+1]=r.elements[1],e[n+2]=r.elements[2],e[n+3]=r.elements[3]}else if("mat3"===i)for(let i=0;i<t.length;i++){const n=16*i,r=t[i];e[n]=r.elements[0],e[n+1]=r.elements[1],e[n+2]=r.elements[2],e[n+4]=r.elements[3],e[n+5]=r.elements[4],e[n+6]=r.elements[5],e[n+8]=r.elements[6],e[n+9]=r.elements[7],e[n+10]=r.elements[8],e[n+15]=1}else if("mat4"===i)for(let i=0;i<t.length;i++){const n=16*i,r=t[i];for(let t=0;t<r.elements.length;t++)e[n+t]=r.elements[t]}else for(let i=0;i<t.length;i++){const n=4*i,r=t[i];e[n]=r.x,e[n+1]=r.y,e[n+2]=r.z||0,e[n+3]=r.w||0}}setup(t){const e=this.array.length,i=this.elementType;let n=Float32Array;const r=this.paddedType,s=t.getTypeLength(r);return"i"===i.charAt(0)&&(n=Int32Array),"u"===i.charAt(0)&&(n=Uint32Array),this.value=new n(e*s),this.bufferCount=e,this.bufferType=r,this.update(),super.setup(t)}element(t){return new $v(this,yg(t))}}const tx=(t,e)=>new 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<i;e+=3)this.expandByPoint(vx.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(vx.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=vx.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,i=n.count;e<i;e++)!0===t.isMesh?t.getVertexPosition(e,vx):vx.fromBufferAttribute(n,e),vx.applyMatrix4(t.matrixWorld),this.expandByPoint(vx);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),xx.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),xx.copy(i.boundingBox)),xx.applyMatrix4(t.matrixWorld),this.union(xx)}const n=t.children;for(let t=0,i=n.length;t<i;t++)this.expandByObject(n[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,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;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;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;t<e.length;t++)i=i[e[t]];return i}updateReference(t){return this.reference=null!==this.object?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const gb=(t,e,i)=>new 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;t<e;t++){const e=this.params[t],n=!0!==e.isNode&&e.name||this.getVarName(t),r=!0!==e.isNode&&e.type||"int";i[n]=Av(n,r)}const n=t.addStack(),r=this.params[this.params.length-1](i);e.returnsNode=r.context({nodeLoop:r}),e.stackNode=n;const s=this.params[0];if(!0!==s.isNode&&"function"==typeof s.update){const t=Eg(this.params[0].update)(i);e.updateNode=t.context({nodeLoop:t})}return t.removeStack(),e}setup(t){if(this.getProperties(t),t.fnCall){t.getDataFromNode(t.fnCall.shaderNode).hasLoop=!0}}generate(t){const e=this.getProperties(t),i=this.params,n=e.stackNode;for(let n=0,r=i.length-1;n<r;n++){const r=i[n];let s,a=!1,o=null,l=null,h=null,c=null,u=null,d=null;if(r.isNode?"bool"===r.getNodeType(t)?(a=!0,c="bool",l=r.build(t,c)):(c="int",h=this.getVarName(n),o="0",l=r.build(t,c),u="<"):(c=r.type||"int",h=r.name||this.getVarName(n),o=r.start,l=r.end,u=r.condition,d=r.update,"number"==typeof o?o=t.generateConst(c,o):o&&o.isNode&&(o=o.build(t,c)),"number"==typeof l?l=t.generateConst(c,l):l&&l.isNode&&(l=l.build(t,c)),void 0!==o&&void 0===l?(o+=" - 1",l="0",u=">="):void 0!==l&&void 0===o&&(o="0",u="<"),void 0===u&&(u=Number(o)>Number(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;e<i;e++)t.addFlowCode((0===e?"":t.tab)+"}\n\n").removeFlowTab();t.addFlowTab()}}const Yb=(...t)=>new 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;t<s;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(t={}){const e={minFilter:ym,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let t=0;t<this.textures.length;t++){this.textures[t].setValues(e)}}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,!0!==this.textures[n].isData3DTexture&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Gv(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}}Eg(({texture:t,uv: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;r<i;r++){const i=s[r];e[i].assign(n(t[i]))}return e}}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]});return s}setup(t){const{method:e,aNode:i}=this,{renderer:n}=t;if(n.backend.isWebGPUBackend)return super.setup(t);const r=this.getInputType(t),s=t.getElementType(r),a=t.getTypeLength(r),o=`${e}_base_${s}`,l=`${e}_${r}`;let h=_M[o];if(void 0===h){switch(e){case vM.COUNT_LEADING_ZEROS:h=this._createLeadingZerosBaseLayout(o,s);break;case vM.COUNT_TRAILING_ZEROS:h=this._createTrailingZerosBaseLayout(o,s);break;case vM.COUNT_ONE_BITS:h=this._createOneBitsBaseLayout(o,s)}_M[o]=h}let c=_M[l];void 0===c&&(c=this._createMainLayout(l,r,a,h),_M[l]=c);return Eg(()=>c(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))<AM?this.object.lookAt(this.target):(EM.setFromNormalAndCoplanarPoint(this.object.up,this.target),wM.intersectPlane(EM,this.target))))}else if(this.object.isOrthographicCamera){const t=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),t!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,!!(r||this._lastPosition.distanceToSquared(this.object.position)>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;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return void this._pointers.splice(e,1)}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];void 0===e&&(e=new ci,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100}return t.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function BM(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t),"grab"===this._cursorStyle&&(this.domElement.style.cursor="grabbing")))}function VM(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function GM(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(TM),this.state=NM,"grab"===this._cursorStyle&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],i=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:i.x,pageY:i.y})}}function HM(t){let i;switch(t.button){case 0:i=this.mouseButtons.LEFT;break;case 1:i=this.mouseButtons.MIDDLE;break;case 2:i=this.mouseButtons.RIGHT;break;default:i=-1}switch(i){case e.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=PM;break;case e.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=LM}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=IM}break;case e.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=IM}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=LM}break;default:this.state=NM}this.state!==NM&&this.dispatchEvent(SM)}function WM(t){switch(this.state){case IM:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case PM:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case LM:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function jM(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===NM&&(t.preventDefault(),this.dispatchEvent(SM),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(TM))}function XM(t){!1!==this.enabled&&this._handleKeyDown(t)}function qM(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case i.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=DM;break;case i.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=OM;break;default:this.state=NM}break;case 2:switch(this.touches.TWO){case i.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=UM;break;case i.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=FM;break;default:this.state=NM}break;default:this.state=NM}this.state!==NM&&this.dispatchEvent(SM)}function YM(t){switch(this._trackPointer(t),this.state){case DM:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case OM:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case UM:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case FM:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=NM}}function ZM(t){!1!==this.enabled&&t.preventDefault()}function KM(t){if("Control"===t.key){this._controlActive=!0;this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}function JM(t){if("Control"===t.key){this._controlActive=!1;this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}const $M=new Ac,QM=new di,tS=new di,eS=new ui,iS={X:new di(1,0,0),Y:new di(0,1,0),Z:new di(0,0,1)},nS={type:"change"},rS={type:"mouseDown",mode:null},sS={type:"mouseUp",mode:null},aS={type:"objectChange"};class oS extends su{constructor(t,e=null){super(void 0,e);const i=new CS(this);this._root=i;const n=new RS;this._gizmo=n,i.add(n);const r=new NS;this._plane=r,i.add(r);const s=this;function a(t,e){let i=e;Object.defineProperty(s,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,r[t]=e,n[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(nS))}}),s[t]=e,r[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("showXY",!0),a("showYZ",!0),a("showXZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new di,l=new di,h=new ui,c=new ui,u=new di,d=new ui,p=new di,m=new di,f=new di,g=new di;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",h),a("worldQuaternionStart",c),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new di,this._startNorm=new di,this._endNorm=new di,this._cameraScale=new di,this._parentPosition=new di,this._parentQuaternion=new ui,this._parentQuaternionInv=new ui,this._parentScale=new di,this._worldScaleStart=new di,this._worldQuaternionInv=new ui,this._worldScale=new di,this._positionStart=new di,this._quaternionStart=new ui,this._scaleStart=new di,this._getPointer=lS.bind(this),this._onPointerDown=cS.bind(this),this._onPointerHover=hS.bind(this),this._onPointerMove=uS.bind(this),this._onPointerUp=dS.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction=""}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&$M.setFromCamera(t,this.camera);const e=pS(this._gizmo.picker[this.mode],$M);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&$M.setFromCamera(t,this.camera);const e=pS(this._plane,$M,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,rS.mode=this.mode,this.dispatchEvent(rS)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let r=this.space;if("scale"===i?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&$M.setFromCamera(t,this.camera);const s=pS(this._plane,$M,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(n.position.applyQuaternion(eS.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===r&&(n.parent&&n.position.add(QM.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(QM.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),tS.set(t,t,t)}else QM.copy(this.pointStart),tS.copy(this.pointEnd),QM.applyQuaternion(this._worldQuaternionInv),tS.applyQuaternion(this._worldQuaternionInv),tS.divide(QM),-1===e.search("X")&&(tS.x=1),-1===e.search("Y")&&(tS.y=1),-1===e.search("Z")&&(tS.z=1);n.scale.copy(this._scaleStart).multiply(tS),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(QM.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(QM.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(iS[e]),QM.copy(iS[e]),"local"===r&&QM.applyQuaternion(this.worldQuaternion),QM.cross(this.eye),0===QM.length()?i=!0:this.rotationAngle=this._offset.dot(QM.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(eS.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(eS.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(nS),this.dispatchEvent(aS)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(sS.mode=this.mode,this.dispatchEvent(sS)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(nS),this.dispatchEvent(aS),this.pointStart.copy(this.pointEnd))}getRaycaster(){return $M}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,i,n){const r=this._gizmo.materialLib;r.xAxis.color.set(t),r.yAxis.color.set(e),r.zAxis.color.set(i),r.active.color.set(n),r.xAxisTransparent.color.set(t),r.yAxisTransparent.color.set(e),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(n),r.xAxis._color&&r.xAxis._color.set(t),r.yAxis._color&&r.yAxis._color.set(e),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(n),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(t),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(e),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(n)}}function lS(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function hS(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function cS(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function uS(t){this.enabled&&this.pointerMove(this._getPointer(t))}function dS(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function pS(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const mS=new Xi,fS=new di(0,1,0),gS=new di(0,0,0),yS=new Ui,_S=new ui,vS=new ui,xS=new di,bS=new Ui,MS=new di(1,0,0),SS=new di(0,1,0),TS=new di(0,0,1),wS=new di,ES=new di,AS=new di;class CS extends cn{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class RS extends cn{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new es({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new fa({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const l=t.clone();l.color.setHex(65280),l.opacity=.5;const h=t.clone();h.color.setHex(255),h.opacity=.5;const c=t.clone();c.opacity=.25;const u=t.clone();u.color.setHex(16776960),u.opacity=.25;const d=t.clone();d.color.setHex(16776960);const p=t.clone();p.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:s,zAxis:a,active:d,xAxisTransparent:o,yAxisTransparent:l,zAxisTransparent:h,activeTransparent:u};const m=new ja(0,.04,.1,12);m.translate(0,.05,0);const f=new Ga(.08,.08,.08);f.translate(0,.04,0);const g=new Mr;g.setAttribute("position",new cr([0,0,0,1,0,0],3));const y=new ja(.0075,.0075,.5,3);function _(t,e){const i=new ul(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}y.translate(0,.25,0);const v={X:[[new ps(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new ps(m,r),[-.5,0,0],[0,0,Math.PI/2]],[new ps(y,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ps(m,s),[0,.5,0]],[new ps(m,s),[0,-.5,0],[Math.PI,0,0]],[new ps(y,s)]],Z:[[new ps(m,a),[0,0,.5],[Math.PI/2,0,0]],[new ps(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new ps(y,a),null,[Math.PI/2,0,0]]],XYZ:[[new ps(new sl(.1,0),c),[0,0,0]]],XY:[[new ps(new Ga(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new ps(new Ga(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ps(new Ga(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new ps(new ja(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ps(new ja(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ps(new ja(.2,0,.6,4),i),[0,.3,0]],[new ps(new ja(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ps(new ja(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ps(new ja(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ps(new sl(.2,0),i)]],XY:[[new ps(new Ga(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ps(new Ga(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ps(new Ga(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new ps(new sl(.01,2),n),null,null,null,"helper"]],END:[[new ps(new sl(.01,2),n),null,null,null,"helper"]],DELTA:[[new Sa(function(){const t=new Mr;return t.setAttribute("position",new cr([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Sa(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Sa(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Sa(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new ps(_(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new ps(_(.5,.5),r)]],Y:[[new ps(_(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new ps(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new ps(_(.75,1),u),null,[0,Math.PI/2,0]]]},S={AXIS:[[new Sa(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new ps(new hl(.25,10,8),i)]],X:[[new ps(new ul(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ps(new ul(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ps(new ul(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ps(new ul(.75,.1,2,24),i)]]},w={X:[[new ps(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new ps(y,r),[0,0,0],[0,0,-Math.PI/2]],[new ps(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ps(f,s),[0,.5,0]],[new ps(y,s)],[new ps(f,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ps(f,a),[0,0,.5],[Math.PI/2,0,0]],[new ps(y,a),[0,0,0],[Math.PI/2,0,0]],[new ps(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ps(new Ga(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new ps(new Ga(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ps(new Ga(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ps(new Ga(.1,.1,.1),c)]]},E={X:[[new ps(new ja(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ps(new ja(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ps(new ja(.2,0,.6,4),i),[0,.3,0]],[new ps(new ja(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ps(new ja(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ps(new ja(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ps(new Ga(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ps(new Ga(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ps(new Ga(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ps(new Ga(.2,.2,.2),i),[0,0,0]]]},A={X:[[new Sa(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Sa(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Sa(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new cn;for(const i in t)for(let n=t[i].length;n--;){const r=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],o=t[i][n][3],l=t[i][n][4];r.name=i,r.tag=l,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const h=r.geometry.clone();h.applyMatrix4(r.matrix),r.geometry=h,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(v)),this.add(this.gizmo.rotate=C(M)),this.add(this.gizmo.scale=C(w)),this.add(this.picker.translate=C(x)),this.add(this.picker.rotate=C(T)),this.add(this.picker.scale=C(E)),this.add(this.helper.translate=C(b)),this.add(this.helper.rotate=C(S)),this.add(this.helper.scale=C(A)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:vS;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let r;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(fS.copy(MS).applyQuaternion(e).dot(this.eye))>t&&(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))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(fS.copy(MS).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(fS.copy(SS).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(_S.copy(e),fS.copy(this.eye).applyQuaternion(eS.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(yS.lookAt(this.eye,gS,SS)),"X"===n.name&&(eS.setFromAxisAngle(MS,Math.atan2(-fS.y,fS.z)),eS.multiplyQuaternions(_S,eS),n.quaternion.copy(eS)),"Y"===n.name&&(eS.setFromAxisAngle(SS,Math.atan2(fS.x,fS.z)),eS.multiplyQuaternions(_S,eS),n.quaternion.copy(eS)),"Z"===n.name&&(eS.setFromAxisAngle(TS,Math.atan2(fS.y,fS.x)),eS.multiplyQuaternions(_S,eS),n.quaternion.copy(eS)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("XY")||this.showXY),n.visible=n.visible&&(-1===n.name.indexOf("YZ")||this.showYZ),n.visible=n.visible&&(-1===n.name.indexOf("XZ")||this.showXZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(t){return n.name===t}))&&(n.material.color.copy(this.materialLib.active.color),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(eS.setFromEuler(mS.set(0,0,0)),n.quaternion.copy(e).multiply(eS),Math.abs(fS.copy(MS).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<r.length;t++){const e=r[t];if("\n"===e)l=0,h-=a;else{const t=LS(e,s,l,h,i);"tb"==n?(l=0,h+=i.ascender*s):l+=t.offsetX,o.push(t.path)}}return o}(t,e,this.data,i);for(let t=0,e=r.length;t<e;t++)n.push(...r[t].toShapes());return n}}function LS(t,e,i,n,r){const s=r.glyphs[t]||r.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".");const a=new ru;let o,l,h,c,u,d,p,m;if(s.o){const t=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let r=0,s=t.length;r<s;){switch(t[r++]){case"m":o=t[r++]*e+i,l=t[r++]*e+n,a.moveTo(o,l);break;case"l":o=t[r++]*e+i,l=t[r++]*e+n,a.lineTo(o,l);break;case"q":h=t[r++]*e+i,c=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,a.quadraticCurveTo(u,d,h,c);break;case"b":h=t[r++]*e+i,c=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,p=t[r++]*e+i,m=t[r++]*e+n,a.bezierCurveTo(u,d,p,m,h,c)}}}return{offsetX:s.ha*e,path:a}}const DS=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let OS=1234567;const US=Math.PI/180,FS=180/Math.PI;function zS(t,e,i){return Math.max(e,Math.min(i,t))}function kS(t,e){return(t%e+e)%e}function BS(t,e,i){return(1-i)*t+i*e}var VS=Object.freeze({__proto__:null,DEG2RAD:US,RAD2DEG:FS,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(DS[255&t]+DS[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 i<Number.EPSILON?(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(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<n;t++)for(let t=0;t<i;t++){const t=s[l];l++;const e=s[l];l++;const i=s[l];l++;const n=s[l];l++,a[o]=i,o++,a[o]=e,o++,a[o]=t,o++,a[o]=n,o++}return a}function s(t,e,i,n){const r=new Uint8Array(t,e,i*n*3),s=new Uint8Array(i*n*4);let a=0,o=0;for(let t=0;t<n;t++)for(let t=0;t<i;t++){const t=r[o];o++;const e=r[o];o++;const i=r[o];o++,s[a]=i,a++,s[a]=e,a++,s[a]=t,a++,s[a]=255,a++}return s}const a=n("DXT1"),o=n("DXT3"),l=n("DXT5"),h=n("ETC1"),c=n("DX10"),u=new Int32Array(t,0,31);if(542327876!==u[0])return console.error("THREE.DDSLoader.parse: Invalid magic number in DDS header."),i;let d;const p=u[21];let m=!1,f=!1,g=u[1]+4;switch(p){case a:d=8,i.format=Nt;break;case o:d=16,i.format=Pt;break;case l:d=16,i.format=Lt;break;case h:d=8,i.format=zt;break;case c:g+=20;const e=new Int32Array(t,128,5)[0];switch(e){case 96:d=16,i.format=ae;break;case 95:d=16,i.format=oe;break;default:return console.error("THREE.DDSLoader.parse: Unsupported DXGI_FORMAT code ",e),i}break;default:if(32===u[22]&&16711680&u[23]&&65280&u[24]&&255&u[25]&&4278190080&u[26])m=!0,d=64,i.format=Mt;else{if(!(24===u[22]&&16711680&u[23]&&65280&u[24]&&255&u[25]))return console.error("THREE.DDSLoader.parse: Unsupported FourCC code ",(y=p,String.fromCharCode(255&y,y>>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<v;e++){let e=i.width,n=i.height;for(let a=0;a<i.mipmapCount;a++){let a,o;m?(a=r(t,g,e,n),o=a.length):f?(a=s(t,g,e,n),o=e*n*3):(o=Math.max(4,e)/4*Math.max(4,n)/4*d,a=new Uint8Array(t,g,o));const l={data:a,width:e,height:n};i.mipmaps.push(l),g+=o,e=Math.max(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<i.length;t++){let e=i[t];if(e=e.trim(),0===e.length||"#"===e.charAt(0))continue;const a=e.indexOf(" ");let o=a>=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<n;i++){const n=this.parseVertexIndex(t[i],e);this.addVertexPoint(n),this.addColor(n)}},addLineGeometry:function(t,e){this.object.geometry.type="Line";const i=this.vertices.length,n=this.uvs.length;for(let e=0,n=t.length;e<n;e++)this.addVertexLine(this.parseVertexIndex(t[e],i));for(let t=0,i=e.length;t<i;t++)this.addUVLine(this.parseUVIndex(e[t],n))}};return t.startObject("",!1),t}var vT=Object.freeze({__proto__:null,OBJLoader:class extends rh{constructor(t){super(t),this.materials=null}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)}setMaterials(t){return this.materials=t,this}parse(t){const e=new _T;-1!==t.indexOf("\r\n")&&(t=t.replace(/\r\n/g,"\n")),-1!==t.indexOf("\\\n")&&(t=t.replace(/\\\n/g,""));const i=t.split("\n");let n=[];for(let t=0,r=i.length;t<r;t++){const r=i[t].trimStart();if(0===r.length)continue;const s=r.charAt(0);if("#"!==s)if("v"===s){const t=r.split(uT);switch(t[0]){case"v":e.vertices.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),t.length>=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;e<n;e++){const n=t[e];if(n.length>0){const t=n.split("/");i.push(t)}}const n=i[0];for(let t=1,r=i.length-1;t<r;t++){const r=i[t],s=i[t+1];e.addFace(n[0],r[0],s[0],n[1],r[1],s[1],n[2],r[2],s[2])}}else if("l"===s){const t=r.substring(1).trim().split(" ");let i=[];const n=[];if(-1===r.indexOf("/"))i=t;else for(let e=0,r=t.length;e<r;e++){const r=t[e].split("/");""!==r[0]&&i.push(r[0]),""!==r[1]&&n.push(r[1])}e.addLineGeometry(i,n)}else if("p"===s){const t=r.slice(1).trim().split(" ");e.addPointGeometry(t)}else if(null!==(n=oT.exec(r))){const t=(" "+n[0].slice(1).trim()).slice(1);e.startObject(t)}else if(hT.test(r))e.object.startMaterial(r.substring(7).trim(),e.materialLibraries);else if(lT.test(r))e.materialLibraries.push(r.substring(7).trim());else if(cT.test(r))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===s){if(n=r.split(" "),n.length>1){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;t<i;t++){const i=e.objects[t],n=i.geometry,s=i.materials,a="Line"===n.type,o="Points"===n.type;let l=!1;if(0===n.vertices.length)continue;const h=new Mr;h.setAttribute("position",new cr(n.vertices,3)),n.normals.length>0&&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;t<i;t++){const i=s[t],n=i.name+"_"+i.smooth+"_"+l;let r=e.materials[n];if(null!==this.materials)if(r=this.materials.create(i.name),!a||!r||r instanceof fa){if(o&&r&&!(r instanceof Ra)){const t=new Ra({size:10,sizeAttenuation:!1});Cr.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,r=t}}else{const t=new fa;Cr.prototype.copy.call(t,r),t.color.copy(r.color),r=t}void 0===r&&(r=a?new fa:o?new Ra({size:1,sizeAttenuation:!1}):new Al,r.name=i.name,r.flatShading=!i.smooth,r.vertexColors=l,e.materials[n]=r),c.push(r)}let u;if(c.length>1){for(let t=0,e=s.length;t<e;t++){const e=s[t];h.addGroup(e.groupStart,e.groupCount,t)}u=a?new Aa(h,c):o?new Da(h,c):new ps(h,c)}else u=a?new Aa(h,c[0]):o?new Da(h,c[0]):new ps(h,c[0]);u.name=i.name,r.add(u)}else if(e.vertices.length>0){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<<t[n-1];var r=new MT(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},AT=ET(ST,2),CT=AT.b,RT=AT.r;
/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
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&LT)>>2|(13107&LT)<<2))>>4|(3855&LT)<<4,IT[PT]=((65280&LT)>>8|(255&LT)<<8)>>1}var DT=function(t,e,i){for(var n=t.length,r=0,s=new bT(e);r<n;++r)t[r]&&++s[t[r]-1];var a,o=new bT(e);for(r=1;r<e;++r)o[r]=o[r-1]+s[r-1]<<1;if(i){a=new bT(1<<e);var l=15-e;for(r=0;r<n;++r)if(t[r])for(var h=r<<4|t[r],c=e-t[r],u=o[t[r]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)a[IT[u]>>l]=h}else for(a=new bT(n),r=0;r<n;++r)t[r]&&(a[r]=IT[o[t[r]-1]++]>>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;i<t.length;++i)t[i]>e&&(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<x;++T)S[wT[T]]=BT(t,h+3*T,7);h+=3*x;var w=kT(S),E=(1<<w)-1,A=DT(S,w,1);for(T=0;T<b;){var C,R=A[BT(t,h,E)];if(h+=15&R,(C=R>>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<<p)-1,O=(1<<m)-1,U=h;;U=h){var F=(N=u[VT(t,h)&D])>>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<<k)-1)+CT[T],h+=k}var B=d[VT(t,h)&O],V=B>>4;B||WT(3),h+=15&B;L=NT[V];if(V>3){k=TT[V];L+=VT(t,h)&(1<<k)-1,h+=k}if(h>f){WT(0);break}a&&o(c+131072);var G=c+z;if(c<L){var H=0-L,W=Math.min(L,G);for(H+c<0&&WT(3);c<W;++c)i[c]=n[H+c]}for(;c<G;++c)i[c]=i[c-L]}}e.l=u,e.p=U,e.b=c,e.f=l,u&&(l=1,e.m=p,e.d=d,e.n=m)}while(!l);return c!=i.length&&s?function(t,e,i){return(null==i||i>t.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]||e>=i[a+1];)e<i[a]?s=a:r=a,a=Math.floor((r+s)/2);return a}function KT(t,e){let i=1;for(let e=2;e<=t;++e)i*=e;let n=1;for(let t=2;t<=e;++t)n*=t;for(let i=2;i<=t-e;++i)n*=i;return i/n}function JT(t,e,i,n,r){const s=function(t,e,i,n,r){const s=r<t?r:t,a=[],o=ZT(t,n,e),l=function(t,e,i,n,r){const s=[];for(let t=0;t<=i;++t)s[t]=0;const a=[];for(let t=0;t<=n;++t)a[t]=s.slice(0);const o=[];for(let t=0;t<=i;++t)o[t]=s.slice(0);o[0][0]=1;const l=s.slice(0),h=s.slice(0);for(let n=1;n<=i;++n){l[n]=e-r[t+1-n],h[n]=r[t+n]-e;let i=0;for(let t=0;t<n;++t){const e=h[t+1],r=l[n-t];o[n][t]=e+r;const s=o[t][n-1]/o[n][t];o[t][n]=i+e*s,i=r*s}o[n][n]=i}for(let t=0;t<=i;++t)a[0][t]=o[t][i];for(let t=0;t<=i;++t){let e=0,r=1;const l=[];for(let t=0;t<=i;++t)l[t]=s.slice(0);l[0][0]=1;for(let s=1;s<=n;++s){let n=0;const h=t-s,c=i-s;t>=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;t<i.length;++t){const e=i[t].clone(),n=e.w;e.x*=n,e.y*=n,e.z*=n,h[t]=e}for(let e=0;e<=s;++e){const i=h[o-t].clone().multiplyScalar(l[e][0]);for(let n=1;n<=t;++n)i.add(h[o-t+n].clone().multiplyScalar(l[e][n]));a[e]=i}for(let t=s+1;t<=r+1;++t)a[t]=new Ii(0,0,0);return a}(t,e,i,n,r);return function(t){const e=t.length,i=[],n=[];for(let r=0;r<e;++r){const e=t[r];i[r]=new di(e.x,e.y,e.z),n[r]=e.w}const r=[];for(let t=0;t<e;++t){const e=i[t].clone();for(let i=1;i<=t;++i)e.sub(r[t-i].clone().multiplyScalar(KT(t,i)*n[i]));r[t]=e.divideScalar(n[0])}return r}(s)}class $T extends to{constructor(t,e,i,n,r){super();const s=e?e.length-1:0,a=i?i.length:0;this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=n||0,this.endKnot=r||s;for(let t=0;t<a;++t){const e=i[t];this.controlPoints[t]=new Ii(e.x,e.y,e.z,e.w)}}getPoint(t,e=new di){const i=e,n=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=function(t,e,i,n){const r=ZT(t,n,e),s=function(t,e,i,n){const r=[],s=[],a=[];r[0]=1;for(let o=1;o<=i;++o){s[o]=e-n[t+1-o],a[o]=n[t+o]-e;let i=0;for(let t=0;t<o;++t){const e=a[t+1],n=s[o-t],l=r[t]/(e+n);r[t]=i+e*l,i=n*l}r[o]=i}return r}(r,n,t,e),a=new Ii(0,0,0,0);for(let e=0;e<=t;++e){const n=i[r-t+e],o=s[e],l=n.w*o;a.x+=n.x*l,a.y+=n.y*l,a.z+=n.z*l,a.w+=n.w*o}return a}(this.degree,this.knots,this.controlPoints,n);return 1!==r.w&&r.divideScalar(r.w),i.set(r.x,r.y,r.z)}getTangent(t,e=new di){const i=e,n=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),r=JT(this.degree,this.knots,this.controlPoints,n,1);return i.copy(r[1]).normalize(),i}toJSON(){const t=super.toJSON();return t.degree=this.degree,t.knots=[...this.knots],t.controlPoints=this.controlPoints.map(t=>t.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;n<t.children.length;n++){const r=t.children[n],s=e[r.ID],a={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;a.geoID=tw.get(parseInt(r.ID)).children.filter(function(t){return void 0===t.relationship})[0].ID,i.push(a)}return i}parseScene(t,e,i){ew=new un;const n=this.parseModels(t.skeletons,e,i),r=QT.Objects.Model,s=this;n.forEach(function(t){const e=r[t.ID];s.setLookAtProperties(t,e);tw.get(t.ID).parents.forEach(function(e){const i=n.get(e.ID);void 0!==i&&i.add(t)}),null===t.parent&&ew.add(t)}),this.addGlobalSceneSettings(),ew.traverse(function(t){if(t.userData.transformData){t.parent&&(t.userData.transformData.parentMatrix=t.parent.matrix,t.userData.transformData.parentMatrixWorld=t.parent.matrixWorld);const e=fw(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}});const a=this.parsePoseNodes(),o=new Set;for(const e in t.skeletons)t.skeletons[e].rawBones.forEach(function(i,n){const r=t.skeletons[e].bones[n];r&&o.add(r.ID)});const l=new Ui;ew.traverse(function(t){if(t.isBone&&void 0!==t.ID&&!o.has(t.ID)){const e=a[t.ID];void 0!==e&&(t.parent?(l.copy(t.parent.matrixWorld).invert(),l.multiply(e)):l.copy(e),l.decompose(t.position,t.quaternion,t.scale),t.updateMatrix(),t.matrixWorld.copy(e))}}),this.bindSkeleton(t.skeletons,e,n);const h=(new rw).parse();if(1===ew.children.length&&ew.children[0].isGroup&&(ew.children[0].animations=h,ew=ew.children[0]),ew.animations=h,"GlobalSettings"in QT&&"UpAxis"in QT.GlobalSettings){2===QT.GlobalSettings.UpAxis.value&&(console.warn("THREE.FBXLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted."),ew.rotation.set(-Math.PI/2,0,0))}}parseModels(t,e,i){const n=new Map,r=QT.Objects.Model;for(const s in r){const a=parseInt(s),o=r[s],l=tw.get(a);let h=this.buildSkeleton(l,t,a,o.attrName);if(!h){switch(o.attrType){case"Camera":h=this.createCamera(l);break;case"Light":h=this.createLight(l);break;case"Mesh":h=this.createMesh(l,e,i);break;case"NurbsCurve":h=this.createCurve(l,e);break;case"LimbNode":case"Root":h=new ws;break;default:h=new un}h.name=o.attrName?bc.sanitizeNodeName(o.attrName):"",h.userData.originalName=o.attrName,h.ID=a}this.getTransformData(h,o),n.set(a,h)}return n}buildSkeleton(t,e,i,n){let r=null;return t.parents.forEach(function(t){for(const s in e){const a=e[s];a.rawBones.forEach(function(e,s){if(e.ID===t.ID){const t=r;r=new ws,r.matrixWorld.copy(e.transformLink),r.name=n?bc.sanitizeNodeName(n):"",r.userData.originalName=n,r.ID=i,a.bones[s]=r,null!==t&&r.add(t)}})}}),r}createCamera(t){let e,i;if(t.children.forEach(function(t){const e=QT.Objects.NodeAttribute[t.ID];void 0!==e&&(i=e)}),void 0===i)e=new cn;else{let t=0;void 0!==i.CameraProjectionType&&1===i.CameraProjectionType.value&&(t=1);let n=1;void 0!==i.NearPlane&&(n=i.NearPlane.value/1e3);let r=1e3;void 0!==i.FarPlane&&(r=i.FarPlane.value/1e3);let s=window.innerWidth,a=window.innerHeight;void 0!==i.AspectWidth&&void 0!==i.AspectHeight&&(s=i.AspectWidth.value,a=i.AspectHeight.value);const o=s/a;let l=45;void 0!==i.FieldOfView&&(l=i.FieldOfView.value);const h=i.FocalLength?i.FocalLength.value:null;switch(t){case 0:e=new Eh(l,o,n,r),null!==h&&e.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),e=new cn;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),e=new cn}}return e}createLight(t){let e,i;if(t.children.forEach(function(t){const e=QT.Objects.NodeAttribute[t.ID];void 0!==e&&(i=e)}),void 0===i)e=new cn;else{let t;t=void 0===i.LightType?0:i.LightType.value;let n=16777215;void 0!==i.Color&&(n=xi.colorSpaceToWorking((new _n).fromArray(i.Color.value),Me));let r=void 0===i.Intensity?1:i.Intensity.value/100;void 0!==i.CastLightOnObject&&0===i.CastLightOnObject.value&&(r=0);let s=0;void 0!==i.FarAttenuationEnd&&(s=void 0!==i.EnableFarAttenuation&&0===i.EnableFarAttenuation.value?0:i.FarAttenuationEnd.value);const a=1;switch(t){case 0:e=new Nh(n,r,s,a);break;case 1:e=new Lh(n,r);break;case 2:let t=Math.PI/3,o=0;void 0!==i.OuterAngle?(t=hi.degToRad(i.OuterAngle.value),void 0!==i.InnerAngle&&(o=1-i.InnerAngle.value/i.OuterAngle.value,o=Math.max(0,o))):void 0!==i.InnerAngle&&(t=hi.degToRad(i.InnerAngle.value)),e=new Ch(n,r,s,t,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+i.LightType.value+", defaulting to a PointLight."),e=new Nh(n,r)}void 0!==i.CastShadows&&1===i.CastShadows.value&&(e.castShadow=!0)}return e}createMesh(t,e,i){let n,r=null,s=null;const a=[];if(t.children.forEach(function(t){e.has(t.ID)&&(r=e.get(t.ID)),i.has(t.ID)&&a.push(i.get(t.ID))}),a.length>1?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<i;e++){const i=r.groups[e];(i.materialIndex<0||i.materialIndex>=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;t<e;t++){const e=new Ui;r.bones[t]&&r.rawBones[t]&&e.copy(r.rawBones[t].transformLink).invert(),s.push(e)}tw.get(parseInt(r.ID)).parents.forEach(function(t){if(e.has(t.ID)){const e=t.ID;tw.get(e).parents.forEach(function(t){if(i.has(t.ID)){const e=i.get(t.ID);e.updateMatrixWorld(!0),e.bind(new Rs(r.bones,s),e.matrixWorld)}})}})}}parsePoseNodes(){const t={};if("Pose"in QT.Objects){const e=QT.Objects.Pose;for(const i in e)if("BindPose"===e[i].attrType&&e[i].NbPoseNodes>0){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<t.length;i++){const n=t[i],r=t[(i+1)%t.length];e.x+=(n.y-r.y)*(n.z+r.z),e.y+=(n.z-r.z)*(n.x+r.x),e.z+=(n.x-r.x)*(n.y+r.y)}return e.normalize(),e}getNormalTangentAndBitangent(t){const e=this.getNormalNewell(t),i=(Math.abs(e.z)>.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;e<i.length;e+=3)t.push(new di(n[i[e]],n[i[e+1]],n[i[e+2]]));const{tangent:r,bitangent:s}=this.getNormalTangentAndBitangent(t),a=[];for(const e of t)a.push(this.flattenVertex(e,r,s));c=$o.triangulateShape(a,[])}else c=[[0,1,2]];for(const[h,u,d]of c)t.vertex.push(e.vertexPositions[i[3*h]]),t.vertex.push(e.vertexPositions[i[3*h+1]]),t.vertex.push(e.vertexPositions[i[3*h+2]]),t.vertex.push(e.vertexPositions[i[3*u]]),t.vertex.push(e.vertexPositions[i[3*u+1]]),t.vertex.push(e.vertexPositions[i[3*u+2]]),t.vertex.push(e.vertexPositions[i[3*d]]),t.vertex.push(e.vertexPositions[i[3*d+1]]),t.vertex.push(e.vertexPositions[i[3*d+2]]),e.skeleton&&(t.vertexWeights.push(o[4*h]),t.vertexWeights.push(o[4*h+1]),t.vertexWeights.push(o[4*h+2]),t.vertexWeights.push(o[4*h+3]),t.vertexWeights.push(o[4*u]),t.vertexWeights.push(o[4*u+1]),t.vertexWeights.push(o[4*u+2]),t.vertexWeights.push(o[4*u+3]),t.vertexWeights.push(o[4*d]),t.vertexWeights.push(o[4*d+1]),t.vertexWeights.push(o[4*d+2]),t.vertexWeights.push(o[4*d+3]),t.weightsIndices.push(l[4*h]),t.weightsIndices.push(l[4*h+1]),t.weightsIndices.push(l[4*h+2]),t.weightsIndices.push(l[4*h+3]),t.weightsIndices.push(l[4*u]),t.weightsIndices.push(l[4*u+1]),t.weightsIndices.push(l[4*u+2]),t.weightsIndices.push(l[4*u+3]),t.weightsIndices.push(l[4*d]),t.weightsIndices.push(l[4*d+1]),t.weightsIndices.push(l[4*d+2]),t.weightsIndices.push(l[4*d+3])),e.color&&(t.colors.push(s[3*h]),t.colors.push(s[3*h+1]),t.colors.push(s[3*h+2]),t.colors.push(s[3*u]),t.colors.push(s[3*u+1]),t.colors.push(s[3*u+2]),t.colors.push(s[3*d]),t.colors.push(s[3*d+1]),t.colors.push(s[3*d+2])),e.material&&"AllSame"!==e.material.mappingType&&(t.materialIndex.push(n),t.materialIndex.push(n),t.materialIndex.push(n)),e.normal&&(t.normal.push(r[3*h]),t.normal.push(r[3*h+1]),t.normal.push(r[3*h+2]),t.normal.push(r[3*u]),t.normal.push(r[3*u+1]),t.normal.push(r[3*u+2]),t.normal.push(r[3*d]),t.normal.push(r[3*d+1]),t.normal.push(r[3*d+2])),e.uv&&e.uv.forEach(function(e,i){void 0===t.uvs[i]&&(t.uvs[i]=[]),t.uvs[i].push(a[i][2*h]),t.uvs[i].push(a[i][2*h+1]),t.uvs[i].push(a[i][2*u]),t.uvs[i].push(a[i][2*u+1]),t.uvs[i].push(a[i][2*d]),t.uvs[i].push(a[i][2*d+1])})}addMorphTargets(t,e,i,n){if(0===i.length)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const r=n.clone().setPosition(0,0,0),s=this;i.forEach(function(i){i.rawTargets.forEach(function(i){const n=QT.Objects.Geometry[i.geoID];void 0!==n&&s.genMorphGeometry(t,e,n,r,i.name)})})}genMorphGeometry(t,e,i,n,r){const s=void 0!==e.Vertices?e.Vertices.a:[],a=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],o=void 0!==i.Vertices?i.Vertices.a:[],l=void 0!==i.Indexes?i.Indexes.a:[],h=3*t.attributes.position.count,c=new Float32Array(h);for(let t=0;t<l.length;t++){const e=3*l[t];c[e]=o[3*t],c[e+1]=o[3*t+1],c[e+2]=o[3*t+2]}const u={vertexIndices:a,vertexPositions:c,baseVertexPositions:s},d=this.genBuffers(u),p=new cr(d.vertex,3);p.name=r||i.attrName,p.applyMatrix4(n),t.morphAttributes.position.push(p)}parseNormals(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.Normals.a;let r=[];return"IndexToDirect"===i&&("NormalIndex"in t?r=t.NormalIndex.a:"NormalsIndex"in t&&(r=t.NormalsIndex.a)),{dataSize:3,buffer:n,indices:r,mappingType:e,referenceType:i}}parseUVs(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.UV.a;let r=[];return"IndexToDirect"===i&&(r=t.UVIndex.a),{dataSize:2,buffer:n,indices:r,mappingType:e,referenceType:i}}parseVertexColors(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.Colors.a;let r=[];"IndexToDirect"===i&&(r=t.ColorIndex.a);for(let t=0,e=new _n;t<n.length;t+=4)e.fromArray(n,t),xi.colorSpaceToWorking(e,Me),e.toArray(n,t);return{dataSize:4,buffer:n,indices:r,mappingType:e,referenceType:i}}parseMaterialIndices(t){const e=t.MappingInformationType,i=t.ReferenceInformationType;if("NoMappingInformation"===e)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};const n=t.Materials.a,r=[];for(let t=0;t<n.length;++t)r.push(t);return{dataSize:1,buffer:n,indices:r,mappingType:e,referenceType:i}}parseNurbsGeometry(t){const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new Mr;const i=e-1,n=t.KnotVector.a,r=[],s=t.Points.a;for(let t=0,e=s.length;t<e;t+=4)r.push((new Ii).fromArray(s,t));let a,o;if("Closed"===t.Form)r.push(r[0]);else if("Periodic"===t.Form){a=i,o=n.length-1-a;for(let t=0;t<i;++t)r.push(r[t])}const l=new $T(i,n,r,a,o).getPoints(12*r.length);return(new Mr).setFromPoints(l)}}class rw{parse(){const t=[],e=this.parseClips();if(void 0!==e)for(const i in e){const n=e[i],r=this.addClip(n);t.push(r)}return t}parseClips(){if(void 0===QT.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=QT.Objects.AnimationCurveNode,e=new Map;for(const i in t){const n=t[i];if(null!==n.attrName.match(/S|R|T|DeformPercent/)){const t={id:n.id,attr:n.attrName,curves:{}};e.set(t.id,t)}}return e}parseAnimationCurves(t){const e=QT.Objects.AnimationCurve;for(const i in e){const n={id:e[i].id,times:e[i].KeyTime.a.map(cw),values:e[i].KeyValueFloat.a},r=tw.get(n.id);if(void 0!==r){const e=r.parents[0].ID,i=r.parents[0].relationship;i.match(/X/)?t.get(e).curves.x=n:i.match(/Y/)?t.get(e).curves.y=n:i.match(/Z/)?t.get(e).curves.z=n:i.match(/DeformPercent/)&&t.has(e)&&(t.get(e).curves.morph=n)}}}parseAnimationLayers(t){const e=QT.Objects.AnimationLayer,i=new Map;for(const n in e){const e=[],r=tw.get(parseInt(n));if(void 0!==r){r.children.forEach(function(i,n){if(t.has(i.ID)){const r=t.get(i.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===e[n]){const t=tw.get(i.ID).parents.filter(function(t){return void 0!==t.relationship});if(0===t.length)return;const r=t[0].ID;if(void 0!==r){const t=QT.Objects.Model[r.toString()];if(void 0===t)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",i);const s={modelName:t.attrName?bc.sanitizeNodeName(t.attrName):"",ID:t.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ew.traverse(function(e){e.ID===t.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder,e.userData.transformData.rotation&&(s.initialRotation=e.userData.transformData.rotation)))}),s.transform||(s.transform=new Ui),"PreRotation"in t&&(s.preRotation=t.PreRotation.value),"PostRotation"in t&&(s.postRotation=t.PostRotation.value),e[n]=s}}e[n]&&(e[n][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===e[n]){const t=tw.get(i.ID).parents.filter(function(t){return void 0!==t.relationship});if(0===t.length)return;const r=t[0].ID,s=tw.get(r).parents[0].ID,a=tw.get(s).parents[0].ID,o=tw.get(a).parents[0].ID,l=QT.Objects.Model[o],h={modelName:l.attrName?bc.sanitizeNodeName(l.attrName):"",morphName:QT.Objects.Deformer[r].attrName};e[n]=h}e[n][r.attr]=r}}}),i.set(parseInt(n),e)}}return i}parseAnimStacks(t){const e=QT.Objects.AnimationStack,i={};for(const n in e){const r=tw.get(parseInt(n)).children;r.length>1&&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;t<o.length;t+=3){if(c.set(o[t],o[t+1],o[t+2],r),h.setFromEuler(c),void 0!==i&&h.premultiply(i),void 0!==n&&h.multiply(n),t>2){(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;n<e.length;n++){const r=e[n];r!==i&&(e[t]=r,i=r,t++)}e=e.slice(0,t)}return e}getKeyframeTrackValues(t,e,i){const n=i,r=[];let s=-1,a=-1,o=-1;return t.forEach(function(t){if(e.x&&(s=e.x.times.indexOf(t)),e.y&&(a=e.y.times.indexOf(t)),e.z&&(o=e.z.times.indexOf(t)),-1!==s){const t=e.x.values[s];r.push(t),n[0]=t}else r.push(n[0]);if(-1!==a){const t=e.y.values[a];r.push(t),n[1]=t}else r.push(n[1]);if(-1!==o){const t=e.z.values[o];r.push(t),n[2]=t}else r.push(n[2])}),r}synchronizeCurve(t,e,i){if(void 0===t)return{times:e,values:e.map(()=>i)};if(t.times.length===e.length)return t;const n=[];for(let r=0;r<e.length;r++)n.push(this.sampleCurveValue(t,e[r],i));return{times:e,values:n}}sampleCurveValue(t,e,i){const n=t.times,r=t.values;if(e<=n[0])return r[0];if(e>=n[n.length-1])return r[r.length-1];for(let t=0;t<n.length-1;t++)if(e>=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<t.values.length;a++){const o=[t.values[a-1],e.values[a-1],i.values[a-1]];if(isNaN(o[0])||isNaN(o[1])||isNaN(o[2]))continue;const l=o.map(hi.degToRad),h=[t.values[a],e.values[a],i.values[a]];if(isNaN(h[0])||isNaN(h[1])||isNaN(h[2]))continue;const c=h.map(hi.degToRad),u=[h[0]-o[0],h[1]-o[1],h[2]-o[2]],d=[Math.abs(u[0]),Math.abs(u[1]),Math.abs(u[2])];if(d[0]>=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<r;i++,n++)t[n]=e[i]}(r,a),void 0===s[n]&&(s[n]=[])}"Node"===n&&(s.id=r),n in s&&Array.isArray(s[n])?s[n].push(r):"a"!==n?s[n]=r:s.a=r,this.setCurrentProp(s,n),"a"===n&&","!==r.slice(-1)&&(s.a=yw(r))}else this.parseNodeSpecialProperty(t,n,r)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=yw(e.a))}parseNodeSpecialProperty(t,e,i){const n=i.split('",').map(function(t){return t.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=n[0],s=n[1],a=n[2],o=n[3];let l=n[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=yw(l)}this.getPrevNode()[r]={type:s,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class aw{parse(t){const e=new ow(t);e.skip(23);const i=e.getUint32();if(i<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+i);const n=new lw;for(;!this.endOfContent(e);){const t=this.parseNode(e,i);null!==t&&n.add(t.name,t)}return n}endOfContent(t){return t.size()%16==0?(t.getOffset()+160+16&-16)>=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;e<r;e++)o.push(this.parseProperty(t));const l=o.length>0?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<t;i++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),2147483648&e?(e=4294967295&~e,t=4294967295&~t,4294967295===t&&(e=e+1&4294967295),t=t+1&4294967295,-(4294967296*e+t)):4294967296*e+t}getInt64Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),4294967296*e+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){const e=this.offset;let i=new Uint8Array(this.dv.buffer,e,t);this.skip(t);const n=i.indexOf(0);return n>=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<n;r++,s++)t[s]=e[r];return t}(uw,n.buffer,s,a)}const pw=new Xi,mw=new di;function fw(t){const e=new Ui,i=new Ui,n=new Ui,r=new Ui,s=new Ui,a=new Ui,o=new Ui,l=new Ui,h=new Ui,c=new Ui,u=new Ui,d=new Ui,p=t.inheritType?t.inheritType:0;t.translation&&e.setPosition(mw.fromArray(t.translation));const m=gw(0);if(t.preRotation){const e=t.preRotation.map(hi.degToRad);e.push(m),i.makeRotationFromEuler(pw.fromArray(e))}if(t.rotation){const e=t.rotation.map(hi.degToRad);e.push(t.eulerOrder||m),n.makeRotationFromEuler(pw.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(hi.degToRad);e.push(m),r.makeRotationFromEuler(pw.fromArray(e)),r.invert()}t.scale&&s.scale(mw.fromArray(t.scale)),t.scalingOffset&&o.setPosition(mw.fromArray(t.scalingOffset)),t.scalingPivot&&a.setPosition(mw.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(mw.fromArray(t.rotationOffset)),t.rotationPivot&&h.setPosition(mw.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),c.copy(t.parentMatrixWorld));const f=i.clone().multiply(n).multiply(r),g=new Ui;g.extractRotation(c);const y=new Ui;y.copyPosition(c);const _=y.clone().invert().multiply(c),v=g.clone().invert().multiply(_),x=s,b=new Ui;if(0===p)b.copy(g).multiply(f).multiply(v).multiply(x);else if(1===p)b.copy(g).multiply(v).multiply(f).multiply(x);else{const t=(new Ui).scale((new di).setFromMatrixScale(u)).clone().invert(),e=v.clone().multiply(t);b.copy(g).multiply(f).multiply(e).multiply(x)}const M=h.clone().invert(),S=a.clone().invert();let T=e.clone().multiply(l).multiply(h).multiply(i).multiply(n).multiply(r).multiply(M).multiply(o).multiply(a).multiply(s).multiply(S);const w=(new Ui).copyPosition(T),E=c.clone().multiply(w);return d.copyPosition(E),T=d.clone().multiply(b),T.premultiply(c.invert()),T}function gw(t){const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(t=t||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[t]}function yw(t){return t.split(",").map(function(t){return parseFloat(t)})}function _w(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=t.byteLength),(new TextDecoder).decode(new Uint8Array(t,e,i))}var vw=Object.freeze({__proto__:null,FBXLoader:class extends rh{constructor(t){super(t)}load(t,e,i,n){const r=this,s=""===r.path?kh.extractUrlBase(t):r.path,a=new oh(this.manager);a.setPath(r.path),a.setResponseType("arraybuffer"),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.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){if(function(t){const e="Kaydara FBX Binary \0";return t.byteLength>=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<e.length;++t){if(n(1)===e[t])return!1}return!0}(e))throw new Error("THREE.FBXLoader: Unknown format.");if(hw(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+hw(e));QT=(new sw).parse(e)}const i=new dh(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new iw(i,this.manager).parse(QT)}}});const xw=new _n;class bw{constructor(t){this.arr=t,this.i=0}empty(){return this.i>=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;t<s.length;t++){let e=s[t];if(e=e.trim(),""===e)continue;const i=e.split(/\s+/),n=i.shift();switch(e=i.join(" "),n){case"format":r.format=i[0],r.version=i[1];break;case"comment":r.comments.push(e);break;case"element":void 0!==a&&r.elements.push(a),a={},a.name=i[0],a.count=parseInt(i[1]),a.properties=[];break;case"property":a.properties.push(o(i,d.propertyNameMapping));break;case"obj_info":r.objInfo=e;break;default:console.log("unhandled",n,i)}}return void 0!==a&&r.elements.push(a),r}function i(t,e){switch(e){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(t);case"float":case"double":case"float32":case"float64":return parseFloat(t)}}function n(t,e){const n={};for(let r=0;r<t.length;r++){if(e.empty())return null;if("list"===t[r].type){const s=[],a=i(e.next(),t[r].countType);for(let n=0;n<a;n++){if(e.empty())return null;s.push(i(e.next(),t[r].itemType))}n[t[r].name]=s}else n[t[r].name]=i(e.next(),t[r].type)}return n}function r(){const t={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[],faceVertexColors:[]};for(const e of Object.keys(d.customPropertyMapping))t[e]=[];return t}function s(t){const e=t.map(t=>t.name);function i(t){for(let i=0,n=t.length;i<n;i++){const n=t[i];if(e.includes(n))return n}return null}return{attrX:i(["x","px","posx"])||"x",attrY:i(["y","py","posy"])||"y",attrZ:i(["z","pz","posz"])||"z",attrNX:i(["nx","normalx"]),attrNY:i(["ny","normaly"]),attrNZ:i(["nz","normalz"]),attrS:i(["s","u","texture_u","tx"]),attrT:i(["t","v","texture_v","ty"]),attrR:i(["red","diffuse_red","r","diffuse_r"]),attrG:i(["green","diffuse_green","g","diffuse_g"]),attrB:i(["blue","diffuse_blue","b","diffuse_b"])}}function a(t,e){const i=r();let a,h;a=null!==(h=/end_header\s+(\S[\s\S]*\S|\S)\s*$/.exec(t))?h[1].split(/\s+/):[];const c=new bw(a);t:for(let t=0;t<e.elements.length;t++){const r=e.elements[t],a=s(r.properties);for(let t=0;t<r.count;t++){const t=n(r.properties,c);if(!t)break t;l(i,r.name,t,a)}}return o(i)}function o(t){let e=new Mr;t.indices.length>0&&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;r<e.length;r++){const s=e[r],a=s.valueReader;if("list"===s.type){const e=[],r=s.countReader.read(t+n);n+=s.countReader.size;for(let i=0;i<r;i++)e.push(a.read(t+n)),n+=a.size;i[s.name]=e}else i[s.name]=a.read(t+n),n+=a.size}return[i,n]}function c(t,e,i){function n(t,e,i){switch(e){case"int8":case"char":return{read:e=>t.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;r<s;r++){const s=t[r];"list"===s.type?(s.countReader=n(e,s.countType,i),s.valueReader=n(e,s.itemType,i)):s.valueReader=n(e,s.type,i)}}let u;const d=this;if(t instanceof ArrayBuffer){const i=new Uint8Array(t),{headerText:n,headerLength:d}=function(t){let e=0,i=!0,n="";const r=[],s=(new TextDecoder).decode(t.subarray(0,5)),a=/^ply\r\n/.test(s);do{const s=String.fromCharCode(t[e++]);"\n"!==s&&"\r"!==s?n+=s:("end_header"===n&&(i=!1),""!==n&&(r.push(n),n=""))}while(i&&e<t.length);return!0===a&&e++,{headerText:r.join("\r")+"\r",headerLength:e}}(i),p=e(n,d);if("ascii"===p.format){u=a((new TextDecoder).decode(i),p)}else u=function(t,e){const i=r(),n="binary_little_endian"===e.format,a=new DataView(t,e.headerLength);let u,d=0;for(let t=0;t<e.elements.length;t++){const r=e.elements[t],o=r.properties,p=s(o);c(o,a,n);for(let t=0;t<r.count;t++){u=h(d,o),d+=u[1];const t=u[0];l(i,r.name,t,p)}}return o(i)}(t,p)}else u=a(t,e(t));return u}}});class Sw extends uh{constructor(t){super(t)}parse(t){const e=0,i=1,n=2,r=3,s=9,a=10,o=11,l=48,h=4,c=0,u=1,d=2,p=3;if(t.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let m=0;const f=new Uint8Array(t),g={id_length:f[m++],colormap_type:f[m++],image_type:f[m++],colormap_index:f[m++]|f[m++]<<8,colormap_length:f[m++]|f[m++]<<8,colormap_size:f[m++],origin:[f[m++]|f[m++]<<8,f[m++]|f[m++]<<8],width:f[m++]|f[m++]<<8,height:f[m++]|f[m++]<<8,pixel_size:f[m++],flags:f[m++]};if(function(t){switch(t.image_type){case i:case s:if(t.colormap_length>256||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<l;)if(t=r[n++],e=1+(127&t),128&t){for(i=0;i<o;++i)h[i]=r[n++];for(i=0;i<e;++i)s.set(h,a+i*o);a+=o*e}else{for(e*=o,i=0;i<e;++i)s[a+i]=r[n++];a+=e}}else s=r.subarray(n,n+=e?i.width*i.height:l);return{pixel_data:s,palettes:a}}(y,_,g,m,f);return function(t,e,i,n,r){let s,a,o,m,f,y;switch((g.flags&l)>>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;t<r;t++){const r=n[t];r.nodeName===e&&i.push(r)}return i}function ww(t){return 0===t.length?[]:t.trim().split(/\s+/)}function Ew(t){return 0===t.length?[]:t.trim().split(/\s+/).map(parseFloat)}function Aw(t){return 0===t.length?[]:t.trim().split(/\s+/).map(t=>parseInt(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;e<t.length;e++)n(t[e])}}parseAnimation(t){const e={sources:{},samplers:{},channels:{}};let i=!1;for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1!==r.nodeType)continue;let s;switch(r.nodeName){case"source":s=r.getAttribute("id"),e.sources[s]=this.parseSource(r);break;case"sampler":s=r.getAttribute("id"),e.samplers[s]=this.parseAnimationSampler(r);break;case"channel":s=r.getAttribute("target"),e.channels[s]=this.parseAnimationChannel(r);break;case"animation":this.parseAnimation(r),i=!0}}!1===i&&(this.library.animations[t.getAttribute("id")||hi.generateUUID()]=e)}parseAnimationSampler(t){const e={inputs:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){const t=Cw(n.getAttribute("source")),i=n.getAttribute("semantic");e.inputs[i]=t}}return e}parseAnimationChannel(t){const e={};let i=t.getAttribute("target").split("/");const n=i.shift();let r=i.shift();const s=-1!==r.indexOf("("),a=-1!==r.indexOf(".");if(a)i=r.split("."),r=i.shift(),e.member=i.shift();else if(s){const t=r.split("(");r=t.shift();for(let e=0;e<t.length;e++)t[e]=parseInt(t[e].replace(/\)/,""));e.indices=t}return e.id=n,e.sid=r,e.arraySyntax=s,e.memberSyntax=a,e.sampler=Cw(t.getAttribute("source")),e}parseAnimationClip(t){const e={name:t.getAttribute("id")||"default",start:parseFloat(t.getAttribute("start")||0),end:parseFloat(t.getAttribute("end")||0),animations:[]};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"instance_animation"===n.nodeName)e.animations.push(Cw(n.getAttribute("url")))}this.library.clips[t.getAttribute("id")]=e}parseController(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"skin":e.id=Cw(n.getAttribute("source")),e.skin=this.parseSkin(n);break;case"morph":e.id=Cw(n.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}this.library.controllers[t.getAttribute("id")]=e}parseSkin(t){const e={sources:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"bind_shape_matrix":e.bindShapeMatrix=Ew(n.textContent);break;case"source":const t=n.getAttribute("id");e.sources[t]=this.parseSource(n);break;case"joints":e.joints=this.parseJoints(n);break;case"vertex_weights":e.vertexWeights=this.parseVertexWeights(n)}}return e}parseJoints(t){const e={inputs:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){const t=n.getAttribute("semantic"),i=Cw(n.getAttribute("source"));e.inputs[t]=i}}return e}parseVertexWeights(t){const e={inputs:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":const t=n.getAttribute("semantic"),i=Cw(n.getAttribute("source")),r=parseInt(n.getAttribute("offset"));e.inputs[t]={id:i,offset:r};break;case"vcount":e.vcount=Aw(n.textContent);break;case"v":e.v=Aw(n.textContent)}}return e}parseImage(t){const e={init_from:Tw(t,"init_from")[0].textContent};this.library.images[t.getAttribute("id")]=e}parseEffect(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"profile_COMMON"===n.nodeName)e.profile=this.parseEffectProfileCOMMON(n)}this.library.effects[t.getAttribute("id")]=e}parseEffectProfileCOMMON(t){const e={surfaces:{},samplers:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"newparam":this.parseEffectNewparam(n,e);break;case"technique":e.technique=this.parseEffectTechnique(n);break;case"extra":e.extra=this.parseEffectExtra(n)}}return e}parseEffectNewparam(t,e){const i=t.getAttribute("sid");for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"surface":e.surfaces[i]=this.parseEffectSurface(r);break;case"sampler2D":e.samplers[i]=this.parseEffectSampler(r)}}}parseEffectSurface(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"init_from"===n.nodeName)e.init_from=n.textContent}return e}parseEffectSampler(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"source"===n.nodeName)e.source=n.textContent}return e}parseEffectTechnique(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"constant":case"lambert":case"blinn":case"phong":e.type=n.nodeName,e.parameters=this.parseEffectParameters(n);break;case"extra":e.extra=this.parseEffectExtra(n)}}return e}parseEffectParameters(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":e[n.nodeName]=this.parseEffectParameter(n);break;case"transparent":e[n.nodeName]={opaque:n.hasAttribute("opaque")?n.getAttribute("opaque"):"A_ONE",data:this.parseEffectParameter(n)}}}return e}parseEffectParameter(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":e[n.nodeName]=Ew(n.textContent);break;case"float":e[n.nodeName]=parseFloat(n.textContent);break;case"texture":e[n.nodeName]={id:n.getAttribute("texture"),extra:this.parseEffectParameterTexture(n)}}}return e}parseEffectParameterTexture(t){const e={technique:{}};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"extra"===n.nodeName)this.parseEffectParameterTextureExtra(n,e)}return e}parseEffectParameterTextureExtra(t,e){for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"technique"===n.nodeName)this.parseEffectParameterTextureExtraTechnique(n,e)}}parseEffectParameterTextureExtraTechnique(t,e){for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":e.technique[n.nodeName]=parseFloat(n.textContent);break;case"wrapU":case"wrapV":"TRUE"===n.textContent.toUpperCase()?e.technique[n.nodeName]=1:"FALSE"===n.textContent.toUpperCase()?e.technique[n.nodeName]=0:e.technique[n.nodeName]=parseInt(n.textContent);break;case"bump":e[n.nodeName]=this.parseEffectExtraTechniqueBump(n)}}}parseEffectExtra(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"technique"===n.nodeName)e.technique=this.parseEffectExtraTechnique(n)}return e}parseEffectExtraTechnique(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"double_sided":e[n.nodeName]=parseInt(n.textContent);break;case"bump":e[n.nodeName]=this.parseEffectExtraTechniqueBump(n)}}return e}parseEffectExtraTechniqueBump(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"texture"===n.nodeName)e[n.nodeName]={id:n.getAttribute("texture"),texcoord:n.getAttribute("texcoord"),extra:this.parseEffectParameterTexture(n)}}return e}parseMaterial(t){const e={name:t.getAttribute("name")};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"instance_effect"===n.nodeName)e.url=Cw(n.getAttribute("url"))}this.library.materials[t.getAttribute("id")]=e}parseCamera(t){const e={name:t.getAttribute("name")};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"optics"===n.nodeName)e.optics=this.parseCameraOptics(n)}this.library.cameras[t.getAttribute("id")]=e}parseCameraOptics(t){for(let e=0;e<t.childNodes.length;e++){const i=t.childNodes[e];if("technique_common"===i.nodeName)return this.parseCameraTechnique(i)}return{}}parseCameraTechnique(t){const e={};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];switch(n.nodeName){case"perspective":case"orthographic":e.technique=n.nodeName,e.parameters=this.parseCameraParameters(n)}}return e}parseCameraParameters(t){const e={};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];switch(n.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":e[n.nodeName]=parseFloat(n.textContent)}}return e}parseLight(t){let e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)e=this.parseLightTechnique(n)}this.library.lights[t.getAttribute("id")]=e}parseLightTechnique(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"directional":case"point":case"spot":case"ambient":e.technique=n.nodeName,e.parameters=this.parseLightParameters(n)}}return e}parseLightParameters(t){const e={};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":const t=Ew(n.textContent);e.color=(new _n).fromArray(t),xi.colorSpaceToWorking(e.color,Me);break;case"falloff_angle":e.falloffAngle=parseFloat(n.textContent);break;case"quadratic_attenuation":const i=parseFloat(n.textContent);e.distance=i?Math.sqrt(1/i):0}}return e}parseGeometry(t){const e={name:t.getAttribute("name"),sources:{},vertices:{},primitives:[]},i=Tw(t,"mesh")[0];if(void 0!==i){for(let t=0;t<i.childNodes.length;t++){const n=i.childNodes[t];if(1!==n.nodeType)continue;const r=n.getAttribute("id");switch(n.nodeName){case"source":e.sources[r]=this.parseSource(n);break;case"vertices":e.vertices=this.parseGeometryVertices(n);break;case"polygons":case"lines":case"linestrips":case"polylist":case"triangles":e.primitives.push(this.parseGeometryPrimitive(n))}}this.library.geometries[t.getAttribute("id")]=e}}parseSource(t){const e={array:[],stride:3};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"float_array":e.array=Ew(n.textContent);break;case"Name_array":e.array=ww(n.textContent);break;case"technique_common":const t=Tw(n,"accessor")[0];void 0!==t&&(e.stride=parseInt(t.getAttribute("stride")))}}return e}parseGeometryVertices(t){const e={};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];1===n.nodeType&&(e[n.getAttribute("semantic")]=Cw(n.getAttribute("source")))}return e}parseGeometryPrimitive(t){const e={type:t.nodeName,material:t.getAttribute("material"),count:parseInt(t.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let i=0,n=t.childNodes.length;i<n;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":const t=Cw(n.getAttribute("source")),i=n.getAttribute("semantic"),r=parseInt(n.getAttribute("offset")),s=parseInt(n.getAttribute("set")),a=s>0?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<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)this.parseKinematicsTechniqueCommon(n,e)}this.library.kinematicsModels[t.getAttribute("id")]=e}parseKinematicsTechniqueCommon(t,e){for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"joint":e.joints[n.getAttribute("sid")]=this.parseKinematicsJoint(n);break;case"instance_joint":e.joints[n.getAttribute("sid")]=this.library.joints[Cw(n.getAttribute("url"))];break;case"link":e.links.push(this.parseKinematicsLink(n))}}}parseKinematicsJoint(t){let e;for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"prismatic":case"revolute":e=this.parseKinematicsJointParameter(n)}}return e}parseKinematicsJointParameter(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new di,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"axis":const t=Ew(n.textContent);e.axis.fromArray(t);break;case"limits":const i=n.getElementsByTagName("max")[0],r=n.getElementsByTagName("min")[0];e.limits.max=parseFloat(i.textContent),e.limits.min=parseFloat(r.textContent)}}return e.limits.min>=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;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"attachment_full":e.attachments.push(this.parseKinematicsAttachment(n));break;case"matrix":case"translate":case"rotate":e.transforms.push(this.parseKinematicsTransform(n))}}return e}parseKinematicsAttachment(t){const e={joint:t.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"link":e.links.push(this.parseKinematicsLink(n));break;case"matrix":case"translate":case"rotate":e.transforms.push(this.parseKinematicsTransform(n))}}return e}parseKinematicsTransform(t){const e={type:t.nodeName},i=Ew(t.textContent);switch(e.type){case"matrix":e.obj=new Ui,e.obj.fromArray(i).transpose();break;case"translate":e.obj=new di,e.obj.fromArray(i);break;case"rotate":e.obj=new di,e.obj.fromArray(i),e.angle=hi.degToRad(i[3])}return e}parsePhysicsModel(t){const e={name:t.getAttribute("name")||"",rigidBodies:{}};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType&&"rigid_body"===n.nodeName)e.rigidBodies[n.getAttribute("name")]={},this.parsePhysicsRigidBody(n,e.rigidBodies[n.getAttribute("name")])}this.library.physicsModels[t.getAttribute("id")]=e}parsePhysicsRigidBody(t,e){for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)this.parsePhysicsTechniqueCommon(n,e)}}parsePhysicsTechniqueCommon(t,e){for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"inertia":e.inertia=Ew(n.textContent);break;case"mass":e.mass=Ew(n.textContent)[0]}}}parseKinematicsScene(t){const e={bindJointAxis:[]};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType&&"bind_joint_axis"===n.nodeName)e.bindJointAxis.push(this.parseKinematicsBindJointAxis(n))}this.library.kinematicsScenes[Cw(t.getAttribute("url"))]=e}parseKinematicsBindJointAxis(t){const e={target:t.getAttribute("target").split("/").pop()};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];if(1===n.nodeType&&"axis"===n.nodeName){const t=n.getElementsByTagName("param")[0];e.axis=t.textContent;const i=e.axis.split("inst_").pop().split("axis")[0];e.jointIndex=i.substring(0,i.length-1)}}return e}prepareNodes(t){const e=t.getElementsByTagName("node");for(let t=0;t<e.length;t++){const i=e[t];!1===i.hasAttribute("id")&&i.setAttribute("id",this.generateId())}}parseNode(t){const e=new Ui,i=new di,n={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new Ui,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{},transformData:{},transformOrder:[]};for(let r=0;r<t.childNodes.length;r++){const s=t.childNodes[r];if(1!==s.nodeType)continue;let a;switch(s.nodeName){case"node":n.nodes.push(s.getAttribute("id")),this.parseNode(s);break;case"instance_camera":n.instanceCameras.push(Cw(s.getAttribute("url")));break;case"instance_controller":n.instanceControllers.push(this.parseNodeInstance(s));break;case"instance_light":n.instanceLights.push(Cw(s.getAttribute("url")));break;case"instance_geometry":n.instanceGeometries.push(this.parseNodeInstance(s));break;case"instance_node":n.instanceNodes.push(Cw(s.getAttribute("url")));break;case"matrix":a=Ew(s.textContent),n.matrix.multiply(e.fromArray(a).transpose());{const t=s.getAttribute("sid");n.transforms[t]=s.nodeName,n.transformData[t]={type:"matrix",array:a},n.transformOrder.push(t)}break;case"translate":a=Ew(s.textContent),i.fromArray(a),n.matrix.multiply(e.makeTranslation(i.x,i.y,i.z));{const t=s.getAttribute("sid");n.transforms[t]=s.nodeName,n.transformData[t]={type:"translate",x:a[0],y:a[1],z:a[2]},n.transformOrder.push(t)}break;case"rotate":a=Ew(s.textContent);{const t=hi.degToRad(a[3]);n.matrix.multiply(e.makeRotationAxis(i.fromArray(a),t));const r=s.getAttribute("sid");n.transforms[r]=s.nodeName,n.transformData[r]={type:"rotate",axis:[a[0],a[1],a[2]],angle:a[3]},n.transformOrder.push(r)}break;case"scale":a=Ew(s.textContent),n.matrix.scale(i.fromArray(a));{const t=s.getAttribute("sid");n.transforms[t]=s.nodeName,n.transformData[t]={type:"scale",x:a[0],y:a[1],z:a[2]},n.transformOrder.push(t)}}}return this.hasNode(n.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",n.id):this.library.nodes[n.id]=n,n}parseNodeInstance(t){const e={id:Cw(t.getAttribute("url")),materials:{},skeletons:[]};for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i];switch(n.nodeName){case"bind_material":const t=n.getElementsByTagName("instance_material");for(let i=0;i<t.length;i++){const n=t[i],r=n.getAttribute("symbol"),s=n.getAttribute("target");e.materials[r]=Cw(s)}break;case"skeleton":e.skeletons.push(Cw(n.textContent))}}return e}parseVisualScene(t){const e={name:t.getAttribute("name"),children:[]};this.prepareNodes(t);const i=Tw(t,"node");for(let t=0;t<i.length;t++)e.children.push(this.parseNode(i[t]));this.library.visualScenes[t.getAttribute("id")]=e}hasNode(t){return void 0!==this.library.nodes[t]}}class Nw{constructor(t,e,i,n){this.library=t,this.collada=e,this.textureLoader=i,this.tgaLoader=n,this.tempColor=new _n,this.animations=[],this.kinematics={},this.position=new di,this.scale=new di,this.quaternion=new ui,this.matrix=new Ui,this.deferredPivotAnimations={},this.transformNodes={}}compose(){const t=this.library;this.buildLibrary(t.animations,this.buildAnimation.bind(this)),this.buildLibrary(t.clips,this.buildAnimationClip.bind(this)),this.buildLibrary(t.controllers,this.buildController.bind(this)),this.buildLibrary(t.images,this.buildImage.bind(this)),this.buildLibrary(t.effects,this.buildEffect.bind(this)),this.buildLibrary(t.materials,this.buildMaterial.bind(this)),this.buildLibrary(t.cameras,this.buildCamera.bind(this)),this.buildLibrary(t.lights,this.buildLight.bind(this)),this.buildLibrary(t.geometries,this.buildGeometry.bind(this)),this.buildLibrary(t.visualScenes,this.buildVisualScene.bind(this)),this.setupAnimations(),this.setupKinematics();const e=this.parseScene(Tw(this.collada,"scene")[0]);return e.animations=this.animations,{scene:e,animations:this.animations,kinematics:this.kinematics}}buildLibrary(t,e){for(const i in t){t[i].build=e(t[i])}}getBuild(t,e){return void 0!==t.build||(t.build=e(t)),t.build}isEmpty(t){return 0===Object.keys(t).length}buildAnimation(t){const e=[],i=t.channels,n=t.samplers,r=t.sources,s=this.aggregateAnimationChannels(i,n,r);for(const t in s){const i=this.library.nodes[t];if(!i)continue;const n=s[t];if(this.hasPivotTransforms(i))this.collectDeferredPivotAnimation(t,n);else{const r=this.getNode(t);let s=!1;for(const t in n){const a=i.transforms[t],o=i.transformData[t],l=n[t];switch(a){case"matrix":this.buildMatrixTracks(r,l,i,e);break;case"translate":this.buildTranslateTrack(r,l,o,e);break;case"rotate":s||(this.buildRotateTrack(r,t,l,o,i,e),s=!0);break;case"scale":this.buildScaleTrack(r,l,o,e)}}}}return e}collectDeferredPivotAnimation(t,e){this.deferredPivotAnimations[t]||(this.deferredPivotAnimations[t]={});const i=this.deferredPivotAnimations[t];for(const t in e){i[t]||(i[t]={});for(const n in e[t])i[t][n]=e[t][n]}}hasPivotTransforms(t){const e=["rotatePivot","rotatePivotInverse","rotatePivotTranslation","scalePivot","scalePivotInverse","scalePivotTranslation"];for(const i of e)if(void 0!==t.transforms[i])return!0;return!1}getAnimation(t){return this.getBuild(this.library.animations[t],this.buildAnimation.bind(this))}aggregateAnimationChannels(t,e,i){const n={};for(const r in t){if(!t.hasOwnProperty(r))continue;const s=t[r],a=e[s.sampler],o=a.inputs.INPUT,l=a.inputs.OUTPUT,h=i[o],c=i[l],u=a.inputs.INTERPOLATION,d=a.inputs.IN_TANGENT,p=a.inputs.OUT_TANGENT,m=u?i[u]:null,f=d?i[d]:null,g=p?i[p]:null,y=s.id,_=s.sid,v=s.member||"default";n[y]||(n[y]={}),n[y][_]||(n[y][_]={}),n[y][_][v]={times:h.array,values:c.array,stride:c.stride,arraySyntax:s.arraySyntax,indices:s.indices,interpolation:m?m.array:null,inTangent:f?f.array:null,outTangent:g?g.array:null,inTangentStride:f?f.stride:0,outTangentStride:g?g.stride:0}}return n}buildMatrixTracks(t,e,i,n){const r=i.matrix.clone().transpose(),s={};for(const t in e){const i=e[t],n=i.times,r=i.values,a=i.stride;for(let t=0,e=n.length;t<e;t++){const e=n[t],o=t*a;if(void 0===s[e]&&(s[e]={}),!0===i.arraySyntax){const t=r[o],n=i.indices[0]+4*i.indices[1];s[e][n]=t}else for(let t=0;t<a;t++)s[e][t]=r[o+t]}}const a=this.prepareAnimationData(s,r),o={name:t.uuid,keyframes:a};this.createKeyframeTracks(o,n)}buildTranslateTrack(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+".position",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;t<r.length;t++){const n=r[t],a=this.getValueAtTime(e.X,n,i.x),o=this.getValueAtTime(e.Y,n,i.y),l=this.getValueAtTime(e.Z,n,i.z);s.push(a,o,l)}const o=new Jl(t.uuid+".position",r,s);this.applyInterpolation(o,a),n.push(o)}buildRotateTrack(t,e,i,n,r,s){const a=i.ANGLE||i.default;if(!a)return;const o=Array.from(a.times);if(0===o.length)return;const l=[];for(const t of r.transformOrder){if("rotate"===r.transforms[t]){const e=r.transformData[t];l.push({sid:t,axis:new di(e.axis[0],e.axis[1],e.axis[2]),defaultAngle:e.angle})}}const h=new ui,c=new ui,u=new ui,d=[],p=this.getInterpolationInfo(i);for(let t=0;t<o.length;t++){const i=o[t];h.identity();for(const t of l){let n;n=t.sid===e?this.getValueAtTime(a,i,t.defaultAngle):t.defaultAngle;const r=hi.degToRad(n);u.setFromAxisAngle(t.axis,r),h.multiply(u)}t>0&&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;t<r.length;t++){const n=r[t],a=this.getValueAtTime(e.X,n,i.x),o=this.getValueAtTime(e.Y,n,i.y),l=this.getValueAtTime(e.Z,n,i.z);s.push(a,o,l)}const o=new Jl(t.uuid+".scale",r,s);this.applyInterpolation(o,a),n.push(o)}getTimesForAllAxes(t){let e=[];return t.X&&(e=e.concat(Array.from(t.X.times))),t.Y&&(e=e.concat(Array.from(t.Y.times))),t.Z&&(e=e.concat(Array.from(t.Z.times))),t.ANGLE&&(e=e.concat(Array.from(t.ANGLE.times))),t.default&&(e=e.concat(Array.from(t.default.times))),e=[...new Set(e)].sort((t,e)=>t-e),e}getValueAtTime(t,e,i){if(!t)return i;const n=t.times,r=t.values,s=t.interpolation;for(let i=0;i<n.length;i++){if(n[i]===e)return r[i];if(n[i]>e){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;t<s.length;t++){const e=s[t];null===i?i=e:e!==i&&(n=!1)}}return{type:i||"LINEAR",uniform:n}}applyInterpolation(t,e,i=null){if("STEP"===e.type&&e.uniform)t.setInterpolation(de);else if("BEZIER"===e.type&&e.uniform&&i){const e=i.default;e&&e.inTangent&&e.outTangent&&(t.setInterpolation(fe),t.settings={inTangents:new Float32Array(e.inTangent),outTangents:new Float32Array(e.outTangent)})}}prepareAnimationData(t,e){const i=[];for(const e in t)i.push({time:parseFloat(e),value:t[e]});i.sort((t,e)=>t.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;t<e;t++){const e=i[t],n=e.time,d=e.value;u.fromArray(d).transpose(),u.decompose(l,h,c),r.push(n),s.push(l.x,l.y,l.z),a.push(h.x,h.y,h.z,h.w),o.push(c.x,c.y,c.z)}return s.length>0&&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<s;r++)n=t[r],void 0===n.value[e]?n.value[e]=null:a=!1;if(!0===a)for(r=0,s=t.length;r<s;r++)n=t[r],n.value[e]=i;else this.createMissingKeyframes(t,e)}createMissingKeyframes(t,e){let i,n;for(let r=0,s=t.length;r<s;r++){const s=t[r];if(null===s.value[e]){if(i=this.getPrev(t,r,e),n=this.getNext(t,r,e),null===i){s.value[e]=n.value[e];continue}if(null===n){s.value[e]=i.value[e];continue}this.interpolate(s,i,n,e)}}}getPrev(t,e,i){for(;e>=0;){const n=t[e];if(null!==n.value[i])return n;e--}return null}getNext(t,e,i){for(;e<t.length;){const n=t[e];if(null!==n.value[i])return n;e++}return null}interpolate(t,e,i,n){i.time-e.time!==0?t.value[n]=(t.time-e.time)*(i.value[n]-e.value[n])/(i.time-e.time)+e.value[n]:t.value[n]=e.value[n]}buildAnimationClip(t){const e=[],i=t.name,n=t.end-t.start||-1,r=t.animations;for(let t=0,i=r.length;t<i;t++){const i=this.getAnimation(r[t]);for(let t=0,n=i.length;t<n;t++)e.push(i[t])}return new $l(i,n,e)}getAnimationClip(t){return this.getBuild(this.library.clips[t],this.buildAnimationClip.bind(this))}buildController(t){const e={id:t.id},i=this.library.geometries[e.id];return void 0!==t.skin&&(e.skin=this.buildSkin(t.skin),i.sources.skinIndices=e.skin.indices,i.sources.skinWeights=e.skin.weights),e}buildSkin(t){const e={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},i=t.sources,n=t.vertexWeights,r=n.vcount,s=n.v,a=n.inputs.JOINT.offset,o=n.inputs.WEIGHT.offset,l=t.sources[t.joints.inputs.JOINT],h=t.sources[t.joints.inputs.INV_BIND_MATRIX],c=i[n.inputs.WEIGHT.id].array;let u,d,p,m=0;for(u=0,p=r.length;u<p;u++){const t=r[u],i=[];for(d=0;d<t;d++){const t=s[m+a],e=c[s[m+o]];i.push({index:t,weight:e}),m+=2}for(i.sort(f),d=0;d<4;d++){const t=i[d];void 0!==t?(e.indices.array.push(t.index),e.weights.array.push(t.weight)):(e.indices.array.push(0),e.weights.array.push(0))}}for(t.bindShapeMatrix?e.bindMatrix=(new Ui).fromArray(t.bindShapeMatrix).transpose():e.bindMatrix=(new Ui).identity(),u=0,p=l.array.length;u<p;u++){const t=l.array[u],i=(new Ui).fromArray(h.array,u*h.stride).transpose();e.joints.push({name:t,boneInverse:i})}return e;function f(t,e){return e.weight-t.weight}}getController(t){return this.getBuild(this.library.controllers[t],this.buildController.bind(this))}buildImage(t){return void 0!==t.build?t.build:t.init_from}getImage(t){const e=this.library.images[t];return void 0!==e?this.getBuild(e,this.buildImage.bind(this)):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",t),null)}buildEffect(t){return t}getEffect(t){return this.getBuild(this.library.effects[t],this.buildEffect.bind(this))}getTextureLoader(t){let e,i=t.slice((t.lastIndexOf(".")-1>>>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;i<t.length;i++){const n=t[i];void 0===e[n.type]&&(e[n.type]=[]),e[n.type].push(n)}return e}checkUVCoordinates(t){let e=0;for(let i=0,n=t.length;i<n;i++){!0===t[i].hasUV&&e++}e>0&&e<t.length&&(t.uvsNeedsFix=!0)}buildGeometry(t){const e={},i=t.sources,n=t.vertices,r=t.primitives;if(0===r.length)return{};const s=this.groupPrimitives(r);for(const t in s){const r=s[t];this.checkUVCoordinates(r),e[t]=this.buildGeometryType(r,i,n)}return e}buildGeometryType(t,e,i){const n={},r={array:[],stride:0},s={array:[],stride:0},a={array:[],stride:0},o={array:[],stride:0},l={array:[],stride:0},h=[],c=4,u=[],d=4,p=new Mr,m=[];let f=0;for(let n=0;n<t.length;n++){const c=t[n],d=c.inputs;let g=0;switch(c.type){case"lines":case"linestrips":g=2*c.count;break;case"triangles":g=3*c.count;break;case"polygons":case"polylist":for(let t=0;t<c.count;t++){const e=c.vcount[t];switch(e){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(e-2)}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",c.type)}p.addGroup(f,g,n),f+=g,c.material&&m.push(c.material);for(const n in d){const p=d[n];switch(n){case"VERTEX":for(const n in i){const d=i[n];switch(n){case"POSITION":const i=r.array.length;if(this.buildGeometryData(c,e[d],p.offset,r.array),r.stride=e[d].stride,e.skinWeights&&e.skinIndices&&(this.buildGeometryData(c,e.skinIndices,p.offset,h),this.buildGeometryData(c,e.skinWeights,p.offset,u)),!1===c.hasUV&&!0===t.uvsNeedsFix){const t=(r.array.length-i)/r.stride;for(let e=0;e<t;e++)a.array.push(0,0)}break;case"NORMAL":this.buildGeometryData(c,e[d],p.offset,s.array),s.stride=e[d].stride;break;case"COLOR":this.buildGeometryData(c,e[d],p.offset,l.array),l.stride=e[d].stride;break;case"TEXCOORD":this.buildGeometryData(c,e[d],p.offset,a.array),a.stride=e[d].stride;break;case"TEXCOORD1":this.buildGeometryData(c,e[d],p.offset,o.array),a.stride=e[d].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',n)}}break;case"NORMAL":this.buildGeometryData(c,e[p.id],p.offset,s.array),s.stride=e[p.id].stride;break;case"COLOR":this.buildGeometryData(c,e[p.id],p.offset,l.array,!0),l.stride=e[p.id].stride;break;case"TEXCOORD":this.buildGeometryData(c,e[p.id],p.offset,a.array),a.stride=e[p.id].stride;break;case"TEXCOORD1":this.buildGeometryData(c,e[p.id],p.offset,o.array),o.stride=e[p.id].stride}}}return r.array.length>0&&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(;e<a;e++)n.push(c[e]);if(r){const t=n.length-u-1;l.setRGB(n[t+0],n[t+1],n[t+2],Me),n[t+0]=l.r,n[t+1]=l.g,n[t+2]=l.b}}const c=e.array,u=e.stride;if(void 0!==t.vcount){let t=0;for(let e=0,i=o.length;e<i;e++){const i=o[e];if(4===i){const e=t+1*a,i=t+2*a,n=t+3*a;h(t+0*a),h(e),h(n),h(e),h(i),h(n)}else if(3===i){const e=t+1*a,i=t+2*a;h(t+0*a),h(e),h(i)}else if(i>4){const e=[];for(let n=0;n<i;n++){const i=s[t+a*n]*u,r=c[i],o=c[i+1],l=c[i+2];e.push(new di(r,o,l))}const n=new di,r=new Un;r.a=e[0],r.b=e[1],r.c=e[2],r.getNormal(n);const o=[];if(Math.abs(n.x)>Math.abs(n.y)&&Math.abs(n.x)>Math.abs(n.z))for(let t=0;t<i;t++)o.push(new ci(e[t].y,e[t].z));else if(Math.abs(n.y)>Math.abs(n.z))for(let t=0;t<i;t++)o.push(new ci(e[t].x,e[t].z));else for(let t=0;t<i;t++)o.push(new ci(e[t].x,e[t].y));const l=$o.isClockWise(o);!0===l&&o.reverse();const d=$o.triangulateShape(o,[]);for(let e=0;e<d.length;e++){const n=d[e];let r,s,o;!1===l?(r=n[0],s=n[1],o=n[2]):(r=i-1-n[0],s=i-1-n[2],o=i-1-n[1]);const c=t+a*s,u=t+a*o;h(t+a*r),h(c),h(u)}}t+=a*i}}else for(let t=0,e=s.length;t<e;t+=a)h(t)}getGeometry(t){return this.getBuild(this.library.geometries[t],this.buildGeometry.bind(this))}buildKinematicsModel(t){return void 0!==t.build?t.build:t}getKinematicsModel(t){return this.getBuild(this.library.kinematicsModels[t],this.buildKinematicsModel.bind(this))}buildKinematicsScene(t){return void 0!==t.build?t.build:t}getKinematicsScene(t){return this.getBuild(this.library.kinematicsScenes[t],this.buildKinematicsScene.bind(this))}setupKinematics(){const t=Object.keys(this.library.kinematicsModels)[0],e=Object.keys(this.library.kinematicsScenes)[0],i=Object.keys(this.library.visualScenes)[0];if(void 0===t||void 0===e)return;const n=this.getKinematicsModel(t),r=this.getKinematicsScene(e),s=this.getVisualScene(i),a=r.bindJointAxis,o={},l=this.collada,h=this;for(let t=0,e=a.length;t<e;t++){const e=a[t],i=l.querySelector('[sid="'+e.target+'"]');if(i){const t=i.parentElement;c(e.jointIndex,t)}}function c(t,e){const i=e.getAttribute("name"),r=n.joints[t],a=h.buildTransformList(e);s.traverse(function(e){e.name===i&&(o[t]={object:e,transforms:a,joint:r,position:r.zeroPosition})})}const u=new Ui,d=this.matrix;this.kinematics={joints:n&&n.joints,getJointValue:function(t){const e=o[t];if(e)return e.position;console.warn("THREE.ColladaLoader: Joint "+t+" doesn't exist.")},setJointValue:function(t,e){const i=o[t];if(i){const n=i.joint;if(e>n.limits.max||e<n.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+e+" outside of limits (min: "+n.limits.min+", max: "+n.limits.max+").");else if(n.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const r=i.object,s=n.axis,a=i.transforms;d.identity();for(let i=0;i<a.length;i++){const r=a[i];if(r.sid&&-1!==r.sid.indexOf(t))switch(n.type){case"revolute":d.multiply(u.makeRotationAxis(s,hi.degToRad(e)));break;case"prismatic":d.multiply(u.makeTranslation(s.x*e,s.y*e,s.z*e));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+n.type)}else switch(r.type){case"matrix":d.multiply(r.obj);break;case"translate":d.multiply(u.makeTranslation(r.obj.x,r.obj.y,r.obj.z));break;case"scale":d.scale(r.obj);break;case"rotate":d.multiply(u.makeRotationAxis(r.obj,r.angle))}}r.matrix.copy(d),r.matrix.decompose(r.position,r.quaternion,r.scale),o[t].position=e}}else console.warn("THREE.ColladaLoader: Joint "+t+" does not exist.")}}}buildTransformList(t){const e=[],i=this.collada.querySelector('[id="'+t.id+'"]');for(let t=0;t<i.childNodes.length;t++){const n=i.childNodes[t];if(1!==n.nodeType)continue;let r,s;switch(n.nodeName){case"matrix":r=Ew(n.textContent);const t=(new Ui).fromArray(r).transpose();e.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:t});break;case"translate":case"scale":r=Ew(n.textContent),s=(new di).fromArray(r),e.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:s});break;case"rotate":r=Ew(n.textContent),s=(new di).fromArray(r);const i=hi.degToRad(r[3]);e.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:s,angle:i})}}return e}buildSkeleton(t,e){const i=[],n=[];let r,s,a;for(r=0;r<t.length;r++){const n=t[r];let s;if(this.hasNode(n))s=this.getNode(n),this.buildBoneHierarchy(s,e,i);else if(this.hasVisualScene(n)){const t=this.library.visualScenes[n].children;for(let n=0;n<t.length;n++){const r=t[n];if("JOINT"===r.type){const t=this.getNode(r.id);this.buildBoneHierarchy(t,e,i)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",n)}for(r=0;r<e.length;r++)for(s=0;s<i.length;s++)if(a=i[s],a.bone.name===e[r].name){n[r]=a,a.processed=!0;break}for(r=0;r<i.length;r++)a=i[r],!1===a.processed&&(n.push(a),a.processed=!0);const o=[],l=[];for(r=0;r<n.length;r++)a=n[r],o.push(a.bone),l.push(a.boneInverse);return new Rs(o,l)}buildBoneHierarchy(t,e,i){t.traverse(function(t){if(!0===t.isBone){let n;for(let i=0;i<e.length;i++){const r=e[i];if(r.name===t.name){n=r.boneInverse;break}}void 0===n&&(n=new Ui),i.push({bone:t,boneInverse:n,processed:!1})}})}buildNode(t){const e=[],i=t.matrix,n=t.nodes,r=t.type,s=t.instanceCameras,a=t.instanceControllers,o=t.instanceLights,l=t.instanceGeometries,h=t.instanceNodes;for(let t=0,i=n.length;t<i;t++)e.push(this.getNode(n[t]));for(let t=0,i=s.length;t<i;t++){const i=this.getCamera(s[t]);null!==i&&e.push(i.clone())}for(let t=0,i=a.length;t<i;t++){const i=a[t],n=this.getController(i.id),r=this.getGeometry(n.id),s=this.buildObjects(r,i.materials),o=i.skeletons,l=n.skin.joints,h=this.buildSkeleton(o,l);for(let t=0,i=s.length;t<i;t++){const i=s[t];i.isSkinnedMesh&&(i.bind(h,n.skin.bindMatrix),i.normalizeSkinWeights()),e.push(i)}}for(let t=0,i=o.length;t<i;t++){const i=this.getLight(o[t]);null!==i&&e.push(i.clone())}for(let t=0,i=l.length;t<i;t++){const i=l[t],n=this.getGeometry(i.id),r=this.buildObjects(n,i.materials);for(let t=0,i=r.length;t<i;t++)e.push(r[t])}for(let t=0,i=h.length;t<i;t++)e.push(this.getNode(h[t]).clone());let c;if(0===n.length&&1===e.length)c=e[0];else{c="JOINT"===r?new ws:new un;for(let t=0;t<e.length;t++)c.add(e[t])}return c.name="JOINT"===r?t.sid:t.name,"JOINT"!==r&&this.hasPivotTransforms(t)?this.wrapWithTransformHierarchy(c,t):(c.matrix.copy(i),c.matrix.decompose(c.position,c.quaternion,c.scale),c)}wrapWithTransformHierarchy(t,e){const i=e.id;this.transformNodes[i]={};const n=e.transformOrder,r=e.transformData,s=new un;s.name=e.name;let a=s;for(let t=0;t<n.length;t++){const s=n[t],o=r[s],l=new un;switch(l.name=e.name+"_"+s,o.type){case"translate":l.position.set(o.x,o.y,o.z);break;case"rotate":{const t=new di(o.axis[0],o.axis[1],o.axis[2]),e=hi.degToRad(o.angle);l.quaternion.setFromAxisAngle(t,e),l.userData.rotationAxis=t;break}case"scale":l.scale.set(o.x,o.y,o.z);break;case"matrix":(new Ui).fromArray(o.array).transpose().decompose(l.position,l.quaternion,l.scale);break}this.transformNodes[i][s]=l,a.add(l),a=l}return a.add(t),s}resolveMaterialBinding(t,e){const i=[];for(let n=0,r=t.length;n<r;n++){const r=e[t[n]];void 0===r?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",t[n]),i.push(this.fallbackMaterial)):i.push(this.getMaterial(r))}return i}get fallbackMaterial(){return void 0===this._fallbackMaterial&&(this._fallbackMaterial=new es({name:rh.DEFAULT_MATERIAL_NAME,color:16711935})),this._fallbackMaterial}buildObjects(t,e){const i=[];for(const n in t){const r=t[n],s=this.resolveMaterialBinding(r.materialKeys,e);if(0===s.length&&("lines"===n||"linestrips"===n?s.push(new fa):s.push(new Al)),"lines"===n||"linestrips"===n)for(let t=0,e=s.length;t<e;t++){const e=s[t];if(!0===e.isMeshPhongMaterial||!0===e.isMeshLambertMaterial){const i=new fa;i.color.copy(e.color),i.opacity=e.opacity,i.transparent=e.transparent,s[t]=i}}const a=void 0!==r.data.attributes.skinIndex,o=1===s.length?s[0]:s;let l;switch(n){case"lines":l=new Aa(r.data,o);break;case"linestrips":l=new Sa(r.data,o);break;case"triangles":case"polygons":case"polylist":l=a?new Ts(r.data,o):new ps(r.data,o)}i.push(l)}return i}hasNode(t){return void 0!==this.library.nodes[t]}getNode(t){return this.getBuild(this.library.nodes[t],this.buildNode.bind(this))}buildVisualScene(t){const e=new un;e.name=t.name;const i=t.children;for(let t=0;t<i.length;t++){const n=i[t];e.add(this.getNode(n.id))}return e}hasVisualScene(t){return void 0!==this.library.visualScenes[t]}getVisualScene(t){return this.getBuild(this.library.visualScenes[t],this.buildVisualScene.bind(this))}parseScene(t){const e=Tw(t,"instance_visual_scene")[0];return this.getVisualScene(this.parseId(e.getAttribute("url")))}parseId(t){return t.substring(1)}setupAnimations(){const t=this.library.clips;if(!0===this.isEmpty(t)){if(!1===this.isEmpty(this.library.animations)){const t=[];for(const e in this.library.animations){const i=this.getAnimation(e);for(let e=0,n=i.length;e<n;e++)t.push(i[e])}this.buildDeferredPivotAnimationTracks(t),this.animations.push(new $l("default",-1,t))}}else for(const e in t)this.animations.push(this.getAnimationClip(e))}buildDeferredPivotAnimationTracks(t){for(const e in this.deferredPivotAnimations){const i=this.library.nodes[e];if(!i)continue;const n=this.deferredPivotAnimations[e];this.buildTransformHierarchyTracks(e,n,i,t)}}buildTransformHierarchyTracks(t,e,i,n){const r=this.transformNodes[t];if(r)for(const t in e){const s=r[t];if(!s)continue;const a=i.transforms[t],o=i.transformData[t],l=e[t];switch(a){case"translate":this.buildHierarchyTranslateTrack(s,l,o,n);break;case"rotate":this.buildHierarchyRotateTrack(s,l,o,n);break;case"scale":this.buildHierarchyScaleTrack(s,l,o,n)}}else console.warn("THREE.ColladaLoader: Transform hierarchy not found for node:",t)}buildHierarchyTranslateTrack(t,e,i,n){if(e.default&&3===e.default.stride){const i=e.default,r=new Jl(t.uuid+".position",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<r.length;t++){const n=r[t],a=this.getValueAtTime(e.X,n,i.x),o=this.getValueAtTime(e.Y,n,i.y),l=this.getValueAtTime(e.Z,n,i.z);s.push(a,o,l)}const o=new Jl(t.uuid+".position",r,s);this.applyInterpolation(o,a),n.push(o)}buildHierarchyRotateTrack(t,e,i,n){const r=e.ANGLE||e.default;if(!r)return;const s=Array.from(r.times);if(0===s.length)return;const a=t.userData.rotationAxis||new di(i.axis[0],i.axis[1],i.axis[2]),o=new ui,l=new ui,h=[],c=this.getInterpolationInfo(e);for(let t=0;t<s.length;t++){const e=s[t],n=this.getValueAtTime(r,e,i.angle),c=hi.degToRad(n);o.setFromAxisAngle(a,c),t>0&&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<r.length;t++){const n=r[t],a=this.getValueAtTime(e.X,n,i.x),o=this.getValueAtTime(e.Y,n,i.y),l=this.getValueAtTime(e.Z,n,i.z);s.push(a,o,l)}const o=new Jl(t.uuid+".scale",r,s);this.applyInterpolation(o,a),n.push(o)}}var Iw=Object.freeze({__proto__:null,ColladaLoader:class extends rh{load(t,e,i,n){const r=this,s=""===r.path?kh.extractUrlBase(t):r.path,a=new oh(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.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){if(0===t.length)return{scene:new Mn};const i=(new Rw).parse(t);if(null===i)return null;const{library:n,asset:r,collada:s}=i,a=new dh(this.manager);let o;a.setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin),Sw&&(o=new Sw(this.manager),o.setPath(this.resourcePath||e));const l=new Nw(n,s,a,o),{scene:h,animations:c,kinematics:u}=l.compose();return h.animations=c,"Z_UP"===r.upAxis&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),h.rotation.set(-Math.PI/2,0,0)),h.scale.multiplyScalar(r.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),c},kinematics:u,library:n,scene:h}}}});var Pw=Object.freeze({__proto__:null,STLLoader:class extends rh{constructor(t){super(t)}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)}parse(t){function e(t,e,i){for(let n=0,r=t.length;n<r;n++)if(t[n]!==e.getUint8(i+n))return!1;return!0}const i=function(t){if("string"==typeof t){const e=new Uint8Array(t.length);for(let i=0;i<t.length;i++)e[i]=255&t.charCodeAt(i);return e.buffer||e}return t}(t);return function(t){const i=new DataView(t);if(84+50*i.getUint32(80,!0)===i.byteLength)return!0;const n=[115,111,108,105,100];for(let t=0;t<5;t++)if(e(n,i,t))return!1;return!0}(i)?function(t){const e=new DataView(t),i=e.getUint32(80,!0);let n,r,s,a,o,l,h,c,u=!1;for(let t=0;t<70;t++)1129270351==e.getUint32(t,!1)&&82==e.getUint8(t+4)&&61==e.getUint8(t+5)&&(u=!0,a=new Float32Array(3*i*3),o=e.getUint8(t+6)/255,l=e.getUint8(t+7)/255,h=e.getUint8(t+8)/255,c=e.getUint8(t+9)/255);const d=new Mr,p=new Float32Array(3*i*3),m=new Float32Array(3*i*3),f=new _n;for(let t=0;t<i;t++){const i=84+50*t,c=e.getFloat32(i,!0),d=e.getFloat32(i+4,!0),g=e.getFloat32(i+8,!0);if(u){const t=e.getUint16(i+48,!0);32768&t?(n=o,r=l,s=h):(n=(31&t)/31,r=(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<this.meshes.length;t++)this.group.add(this.meshes[t]);return this.group}readFile(t,e){const i=new DataView(t),n=new Dw(i,0,this.debugMessage);if(n.id===Uw||n.id===Fw||n.id===Ow){let t=n.readChunk();for(;t;){if(t.id===zw){const e=t.readDWord();this.debugMessage("3DS file version: "+e)}else t.id===jw?this.readMeshData(t,e):this.debugMessage("Unknown main chunk: "+t.hexId);t=n.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(t,e){let i=t.readChunk();for(;i;){if(i.id===Xw){const t=+i.readDWord();this.debugMessage("Mesh Version: "+t)}else if(i.id===qw){const t=i.readFloat();this.debugMessage("Master scale: "+t),this.group.scale.set(t,t,t)}else i.id===mE?(this.debugMessage("Named Object"),this.readNamedObject(i)):i.id===Yw?(this.debugMessage("Material"),this.readMaterialEntry(i,e)):this.debugMessage("Unknown MDATA chunk: "+i.hexId);i=t.readChunk()}}readNamedObject(t){const e=t.readString();let i=t.readChunk();for(;i;){if(i.id===fE){const t=this.readMesh(i);t.name=e,this.meshes.push(t)}else this.debugMessage("Unknown named object chunk: "+i.hexId);i=t.readChunk()}}readMaterialEntry(t,e){let i=t.readChunk();const n=new Al;for(;i;){if(i.id===Zw)n.name=i.readString(),this.debugMessage(" Name: "+n.name);else if(i.id===nE)this.debugMessage(" Wireframe"),n.wireframe=!0;else if(i.id===rE){const t=i.readByte();n.wireframeLinewidth=t,this.debugMessage(" Wireframe Thickness: "+t)}else if(i.id===eE)n.side=2,this.debugMessage(" DoubleSided");else if(i.id===iE)this.debugMessage(" Additive Blending"),n.blending=2;else if(i.id===Jw)this.debugMessage(" Diffuse Color"),n.color=this.readColor(i);else if(i.id===$w)this.debugMessage(" Specular Color"),n.specular=this.readColor(i);else if(i.id===Kw)this.debugMessage(" Ambient color"),n.color=this.readColor(i);else if(i.id===Qw){const t=this.readPercentage(i);n.shininess=100*t,this.debugMessage(" Shininess : "+t)}else if(i.id===tE){const t=this.readPercentage(i);n.opacity=1-t,this.debugMessage(" Transparency : "+t),n.transparent=n.opacity<1}else i.id===sE?(this.debugMessage(" ColorMap"),n.map=this.readMap(i,e)):i.id===oE?(this.debugMessage(" BumpMap"),n.bumpMap=this.readMap(i,e)):i.id===aE?(this.debugMessage(" OpacityMap"),n.alphaMap=this.readMap(i,e)):i.id===lE?(this.debugMessage(" SpecularMap"),n.specularMap=this.readMap(i,e)):this.debugMessage(" Unknown material chunk: "+i.hexId);i=t.readChunk()}this.materials[n.name]=n}readMesh(t){let e=t.readChunk();const i=new Mr,n=new Al,r=new ps(i,n);for(r.name="mesh";e;){if(e.id===gE){const t=e.readWord();this.debugMessage(" Vertex: "+t);const n=[];for(let i=0;i<t;i++)n.push(e.readFloat()),n.push(e.readFloat()),n.push(e.readFloat());i.setAttribute("position",new cr(n,3))}else if(e.id===yE)this.readFaceArray(e,r);else if(e.id===vE){const t=e.readWord();this.debugMessage(" UV: "+t);const n=[];for(let i=0;i<t;i++)n.push(e.readFloat()),n.push(e.readFloat());i.setAttribute("uv",new cr(n,2))}else if(e.id===xE){this.debugMessage(" Transformation Matrix (TODO)");const t=[];for(let i=0;i<12;i++)t[i]=e.readFloat();const n=new Ui;n.elements[0]=t[0],n.elements[1]=t[6],n.elements[2]=t[3],n.elements[3]=t[9],n.elements[4]=t[2],n.elements[5]=t[8],n.elements[6]=t[5],n.elements[7]=t[11],n.elements[8]=t[1],n.elements[9]=t[7],n.elements[10]=t[4],n.elements[11]=t[10],n.elements[12]=0,n.elements[13]=0,n.elements[14]=0,n.elements[15]=1,n.transpose();const s=new Ui;s.copy(n).invert(),i.applyMatrix4(s),n.decompose(r.position,r.quaternion,r.scale)}else this.debugMessage(" Unknown mesh chunk: "+e.hexId);e=t.readChunk()}return i.computeVertexNormals(),r}readFaceArray(t,e){const i=t.readWord();this.debugMessage(" Faces: "+i);const n=[];for(let e=0;e<i;++e)n.push(t.readWord(),t.readWord(),t.readWord()),t.readWord();e.geometry.setIndex(n);let r=0,s=0;for(;!t.endOfChunk;){const i=t.readChunk();if(i.id===_E){this.debugMessage(" Material Group");const t=this.readMaterialGroup(i),n=3*t.index.length;e.geometry.addGroup(s,n,r),s+=n,r++;const a=this.materials[t.name];!1===Array.isArray(e.material)&&(e.material=[]),void 0!==a&&e.material.push(a)}else this.debugMessage(" Unknown face array chunk: "+i.hexId)}1===e.material.length&&(e.material=e.material[0])}readMap(t,e){let i=t.readChunk(),n={};const r=new dh(this.manager);for(r.setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);i;){if(i.id===hE){const t=i.readString();n=r.load(t),this.debugMessage(" File: "+e+t)}else i.id===dE?(n.offset.x=i.readFloat(),this.debugMessage(" OffsetX: "+n.offset.x)):i.id===pE?(n.offset.y=i.readFloat(),this.debugMessage(" OffsetY: "+n.offset.y)):i.id===cE?(n.repeat.x=i.readFloat(),this.debugMessage(" RepeatX: "+n.repeat.x)):i.id===uE?(n.repeat.y=i.readFloat(),this.debugMessage(" RepeatY: "+n.repeat.y)):this.debugMessage(" Unknown map chunk: "+i.hexId);i=t.readChunk()}return n}readMaterialGroup(t){const e=t.readString(),i=t.readWord();this.debugMessage(" Name: "+e),this.debugMessage(" Faces: "+i);const n=[];for(let e=0;e<i;++e)n.push(t.readWord());return{name:e,index:n}}readColor(t){const e=t.readChunk(),i=new _n;if(e.id===Bw||e.id===Vw){const t=e.readByte(),n=e.readByte(),r=e.readByte();i.setRGB(t/255,n/255,r/255),this.debugMessage(" Color: "+i.r+", "+i.g+", "+i.b)}else if(e.id===kw||e.id===Gw){const t=e.readFloat(),n=e.readFloat(),r=e.readFloat();i.setRGB(t,n,r),this.debugMessage(" Color: "+i.r+", "+i.g+", "+i.b)}else this.debugMessage(" Unknown color chunk: "+e.hexId);return i}readPercentage(t){const e=t.readChunk();switch(e.id){case Hw:return e.readShort()/100;case Ww:return e.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+e.hexId),0}}debugMessage(t){this.debug&&console.log(t)}}});var ME=Object.freeze({__proto__:null,PCDLoader:class extends rh{constructor(t){super(t),this.littleEndian=!0}load(t,e,i,n){const r=this,s=new oh(r.manager);s.setPath(r.path),s.setResponseType("arraybuffer"),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.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)}_getDataView(t,e,i,n){switch(i){case"F":return 8===n?t.getFloat64(e,this.littleEndian):t.getFloat32(e,this.littleEndian);case"I":return 1===n?t.getInt8(e):2===n?t.getInt16(e,this.littleEndian):t.getInt32(e,this.littleEndian);case"U":return 1===n?t.getUint8(e):2===n?t.getUint16(e,this.littleEndian):t.getUint32(e,this.littleEndian)}}parse(t){const e=function(t){const e={},i=new Uint8Array(t);let n="",r="",s=0,a=!1;const o=i.length;for(;s<o&&!1===a;){const t=String.fromCharCode(i[s++]);"\n"===t||"\r"===t?(r.trim().toLowerCase().startsWith("data")&&(a=!0),r=""):r+=t,n+=t}const l=n.search(/[\r\n]DATA\s(\S*)\s/i),h=/[\r\n]DATA\s(\S*)\s/i.exec(n.slice(l-1));if(e.data=h[1],e.headerLen=h[0].length+l,e.str=n.slice(0,e.headerLen),e.str=e.str.replace(/#.*/gi,""),e.version=/^VERSION (.*)/im.exec(e.str),e.fields=/^FIELDS (.*)/im.exec(e.str),e.size=/^SIZE (.*)/im.exec(e.str),e.type=/^TYPE (.*)/im.exec(e.str),e.count=/^COUNT (.*)/im.exec(e.str),e.width=/^WIDTH (.*)/im.exec(e.str),e.height=/^HEIGHT (.*)/im.exec(e.str),e.viewpoint=/^VIEWPOINT (.*)/im.exec(e.str),e.points=/^POINTS (.*)/im.exec(e.str),null!==e.version&&(e.version=parseFloat(e.version[1])),e.fields=null!==e.fields?e.fields[1].split(" "):[],null!==e.type&&(e.type=e.type[1].split(" ")),null!==e.width&&(e.width=parseInt(e.width[1])),null!==e.height&&(e.height=parseInt(e.height[1])),null!==e.viewpoint&&(e.viewpoint=e.viewpoint[1]),null!==e.points&&(e.points=parseInt(e.points[1],10)),null===e.points&&(e.points=e.width*e.height),null!==e.size&&(e.size=e.size[1].split(" ").map(function(t){return parseInt(t,10)})),null!==e.count)e.count=e.count[1].split(" ").map(function(t){return parseInt(t,10)});else{e.count=[];for(let t=0,i=e.fields.length;t<i;t++)e.count.push(1)}e.offset={};let c=0;for(let t=0,i=e.fields.length;t<i;t++)"ascii"===e.data?e.offset[e.fields[t]]=t:(e.offset[e.fields[t]]=c,c+=e.size[t]*e.count[t]);return e.rowSize=c,e}(t),i=[],n=[],r=[],s=[],a=[],o=new _n;if("ascii"===e.data){const l=e.offset,h=(new TextDecoder).decode(t).slice(e.headerLen).split("\n");for(let t=0,c=h.length;t<c;t++){if(""===h[t])continue;const c=h[t].split(" ");if(void 0!==l.x&&(i.push(parseFloat(c[l.x])),i.push(parseFloat(c[l.y])),i.push(parseFloat(c[l.z]))),void 0!==l.rgb){const t=e.fields.findIndex(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(o<i);return n}(new Uint8Array(t,e.headerLen+8,h),c),d=new DataView(u.buffer),p=e.offset;for(let t=0;t<e.points;t++){if(void 0!==p.x){const n=e.fields.indexOf("x"),r=e.fields.indexOf("y"),s=e.fields.indexOf("z");i.push(this._getDataView(d,e.points*p.x+e.size[n]*t,e.type[n],e.size[n])),i.push(this._getDataView(d,e.points*p.y+e.size[r]*t,e.type[r],e.size[r])),i.push(this._getDataView(d,e.points*p.z+e.size[s]*t,e.type[s],e.size[s]))}if(void 0!==p.rgb){const i=e.fields.indexOf("rgb"),n=d.getUint8(e.points*p.rgb+e.size[i]*t+2)/255,s=d.getUint8(e.points*p.rgb+e.size[i]*t+1)/255,a=d.getUint8(e.points*p.rgb+e.size[i]*t+0)/255;o.setRGB(n,s,a,Me),r.push(o.r,o.g,o.b)}if(void 0!==p.normal_x){const i=e.fields.indexOf("normal_x"),r=e.fields.indexOf("normal_y"),s=e.fields.indexOf("normal_z");n.push(this._getDataView(d,e.points*p.normal_x+e.size[i]*t,e.type[i],e.size[i])),n.push(this._getDataView(d,e.points*p.normal_y+e.size[r]*t,e.type[r],e.size[r])),n.push(this._getDataView(d,e.points*p.normal_z+e.size[s]*t,e.type[s],e.size[s]))}if(void 0!==p.intensity){const i=e.fields.indexOf("intensity");s.push(this._getDataView(d,e.points*p.intensity+e.size[i]*t,e.type[i],e.size[i]))}if(void 0!==p.label){const i=e.fields.indexOf("label");a.push(this._getDataView(d,e.points*p.label+e.size[i]*t,e.type[i],e.size[i]))}}}if("binary"===e.data){const l=new DataView(t,e.headerLen),h=e.offset;for(let t=0,c=0;t<e.points;t++,c+=e.rowSize){if(void 0!==h.x){const t=e.fields.indexOf("x"),n=e.fields.indexOf("y"),r=e.fields.indexOf("z");i.push(this._getDataView(l,c+h.x,e.type[t],e.size[t])),i.push(this._getDataView(l,c+h.y,e.type[n],e.size[n])),i.push(this._getDataView(l,c+h.z,e.type[r],e.size[r]))}if(void 0!==h.rgb){const t=l.getUint8(c+h.rgb+2)/255,e=l.getUint8(c+h.rgb+1)/255,i=l.getUint8(c+h.rgb+0)/255;o.setRGB(t,e,i,Me),r.push(o.r,o.g,o.b)}if(void 0!==h.normal_x){const t=e.fields.indexOf("normal_x"),i=e.fields.indexOf("normal_y"),r=e.fields.indexOf("normal_z");n.push(this._getDataView(l,c+h.normal_x,e.type[t],e.size[t])),n.push(this._getDataView(l,c+h.normal_y,e.type[i],e.size[i])),n.push(this._getDataView(l,c+h.normal_z,e.type[r],e.size[r]))}if(void 0!==h.intensity){const t=e.fields.indexOf("intensity");s.push(this._getDataView(l,c+h.intensity,e.type[t],e.size[t]))}if(void 0!==h.label){const t=e.fields.indexOf("label");a.push(this._getDataView(l,c+h.label,e.type[t],e.size[t]))}}}const l=new Mr;i.length>0&&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<t.length;++c){const u=t[c];let d=0;if(i!==(null!==u.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in u.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===s[t]&&(s[t]=[]),s[t].push(u.attributes[t]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in u.morphAttributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(u.morphAttributes[t])}if(e){let t;if(i)t=u.index.count;else{if(void 0===u.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=u.attributes.position.count}l.addGroup(h,t,c),h+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const r=t[n].index;for(let t=0;t<r.count;++t)i.push(r.getX(t)+e);e+=t[n].attributes.position.count}l.setIndex(i)}for(const t in s){const e=TE(s[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;l.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0!==e){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=TE(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;l.morphAttributes[t].push(n)}}}return l}function TE(t){let e,i,n,r=-1,s=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=o.count*i}const a=new e(s),o=new ar(a,i,n);let l=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=l/i;for(let e=0,r=n.count;e<r;e++)for(let r=0;r<i;r++){const i=n.getComponent(e,r);o.setComponent(e+t,r,i)}}else a.set(n.array,l);l+=n.count*i}return void 0!==r&&(o.gpuType=r),o}function wE(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),i=t.getIndex()}const n=i.count-2,r=[];if(2===e)for(let t=1;t<=n;t++)r.push(i.getX(0)),r.push(i.getX(t)),r.push(i.getX(t+1));else for(let t=0;t<n;t++)t%2==0?(r.push(i.getX(t)),r.push(i.getX(t+1)),r.push(i.getX(t+2))):(r.push(i.getX(t+2)),r.push(i.getX(t+1)),r.push(i.getX(t)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}function EE(t){const e=new Map,i=new Map,n=t.clone();return AE(t,n,function(t,n){e.set(n,t),i.set(t,n)}),n.traverse(function(t){if(!t.isSkinnedMesh)return;const n=t,r=e.get(t),s=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=s.map(function(t){return i.get(t)}),n.bind(n.skeleton,n.bindMatrix)}),n}function AE(t,e,i){i(t,e);for(let n=0;n<t.children.length;n++)AE(t.children[n],e.children[n],i)}function CE(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}function RE(t,e,i){const n=t.json.materials[e];return n.extensions&&n.extensions[i]?n.extensions[i]:null}const NE={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class IE{constructor(t){this.parser=t,this.name=NE.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i<n;i++){const n=e[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const e=this.parser,i="light:"+t;let n=e.cache.get(i);if(n)return n;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new _n(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],Se);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Lh(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Nh(o),a.distance=l;break;case"spot":a=new Ch(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),_A(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),n=Promise.resolve(a),e.cache.add(i,n),n}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,i=this.parser,n=i.json.nodes[t],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(t){return i._getNodeRef(e.cache,r,t)})}}class PE{constructor(){this.name=NE.KHR_MATERIALS_UNLIT}getMaterialType(){return es}extendParams(t,e,i){const n=[];t.color=new _n(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],Se),t.opacity=e[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(t,"map",r.baseColorTexture,Me))}return Promise.all(n)}}class LE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);return null===i||void 0!==i.emissiveStrength&&(e.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class DE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];if(void 0!==i.clearcoatFactor&&(e.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&n.push(this.parser.assignTexture(e,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(e.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&n.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(n.push(this.parser.assignTexture(e,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const t=i.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new ci(t,t)}return Promise.all(n)}}class OE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_DISPERSION}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);return null===i||(e.dispersion=void 0!==i.dispersion?i.dispersion:0),Promise.resolve()}}class UE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.iridescenceFactor&&(e.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&n.push(this.parser.assignTexture(e,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(e.iridescenceIOR=i.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&n.push(this.parser.assignTexture(e,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class FE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_SHEEN}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];if(e.sheenColor=new _n(0,0,0),e.sheenRoughness=0,e.sheen=1,void 0!==i.sheenColorFactor){const t=i.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],Se)}return void 0!==i.sheenRoughnessFactor&&(e.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&n.push(this.parser.assignTexture(e,"sheenColorMap",i.sheenColorTexture,Me)),void 0!==i.sheenRoughnessTexture&&n.push(this.parser.assignTexture(e,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class zE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.transmissionFactor&&(e.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&n.push(this.parser.assignTexture(e,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class kE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_VOLUME}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];e.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&n.push(this.parser.assignTexture(e,"thicknessMap",i.thicknessTexture)),e.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return e.attenuationColor=(new _n).setRGB(r[0],r[1],r[2],Se),Promise.all(n)}}class BE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_IOR}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);return null===i||(e.ior=void 0!==i.ior?i.ior:1.5,0===e.ior&&(e.ior=1e3)),Promise.resolve()}}class VE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_SPECULAR}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];e.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&n.push(this.parser.assignTexture(e,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return e.specularColor=(new _n).setRGB(r[0],r[1],r[2],Se),void 0!==i.specularColorTexture&&n.push(this.parser.assignTexture(e,"specularColorMap",i.specularColorTexture,Me)),Promise.all(n)}}class GE{constructor(t){this.parser=t,this.name=NE.EXT_MATERIALS_BUMP}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];return e.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&n.push(this.parser.assignTexture(e,"bumpMap",i.bumpTexture)),Promise.all(n)}}class HE{constructor(t){this.parser=t,this.name=NE.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return null!==RE(this.parser,t,this.name)?El:null}extendMaterialParams(t,e){const i=RE(this.parser,t,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.anisotropyStrength&&(e.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(e.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&n.push(this.parser.assignTexture(e,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class WE{constructor(t){this.parser=t,this.name=NE.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,i=e.json,n=i.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=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<n;t++)a.TRANSLATION&&i.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,t),a.SCALE&&o.fromBufferAttribute(a.SCALE,t),l.setMatrixAt(t,e.compose(i,s,o));for(const e in a)if("_COLOR_0"===e){const t=a[e];l.instanceColor=new Ns(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);cn.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),r.push(l)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]}))}}const ZE="glTF",KE=1313821514,JE=5130562;class $E{constructor(t){this.name=NE.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==ZE)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<n;){const e=r.getUint32(s,!0);s+=4;const n=r.getUint32(s,!0);if(s+=4,n===KE){const n=new Uint8Array(t,12+s,e);this.content=i.decode(n)}else if(n===JE){const i=12+s;this.body=t.slice(i,i+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class QE{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=NE.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const t in s){const e=cA[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const n=cA[e]||e.toLowerCase();if(void 0!==s[e]){const r=i.accessors[t.attributes[e]],s=aA[r.componentType];l[n]=s.name,o[n]=!0===r.normalized}}return e.getDependency("bufferView",r).then(function(t){return new Promise(function(e,i){n.decodeDracoFile(t,function(t){for(const e in t.attributes){const i=t.attributes[e],n=o[e];void 0!==n&&(i.normalized=n)}e(t)},a,l,Se,i)})})}}class tA{constructor(){this.name=NE.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class eA{constructor(){this.name=NE.KHR_MESH_QUANTIZATION}}class iA extends kl{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let t=0;t!==n;t++)e[t]=i[r+t];return e}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=n-e,c=(i-e)/h,u=c*c,d=u*c,p=t*l,m=p-l,f=-2*d+3*u,g=d-u,y=1-f,_=g-u+c;for(let t=0;t!==a;t++){const e=s[m+t+a],i=s[m+t+o]*h,n=s[p+t+a],l=s[p+t]*h;r[t]=y*e+_*i+f*n+g*l}return r}}const nA=new ui;class rA extends iA{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return nA.fromArray(r).normalize().toArray(r),r}}const sA={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},aA={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oA={9728:et,9729:rt,9984:it,9985:st,9986:nt,9987:at},lA={33071:Q,33648:tt,10497:$},hA={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cA={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},uA={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},dA={CUBICSPLINE:void 0,LINEAR:pe,STEP:de},pA="OPAQUE",mA="MASK",fA="BLEND";function gA(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new wl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function yA(t,e,i){for(const n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function _A(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function vA(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,n=e.weights.length;i<n;i++)t.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(t.morphTargetInfluences.length===i.length){t.morphTargetDictionary={};for(let e=0,n=i.length;e<n;e++)t.morphTargetDictionary[i[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function xA(t){let e;const i=t.extensions&&t.extensions[NE.KHR_DRACO_MESH_COMPRESSION];if(e=i?"draco:"+i.bufferView+":"+i.indices+":"+bA(i.attributes):t.indices+":"+bA(t.attributes)+":"+t.mode,void 0!==t.targets)for(let i=0,n=t.targets.length;i<n;i++)e+=":"+bA(t.targets[i]);return e}function bA(t){let e="";const i=Object.keys(t).sort();for(let n=0,r=i.length;n<r;n++)e+=i[n]+":"+t[i[n]]+";";return e}function MA(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const SA=new Ui;class TA{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new CE,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,s=-1;if("undefined"!=typeof navigator&&void 0!==navigator.userAgent){const t=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);n=i&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-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<n;i++){const n=e[i].joints;for(let e=0,i=n.length;e<i;e++)t[n[e]].isBone=!0}for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,i){if(t.refs[e]<=1)return i;const n=i.clone(),r=(t,e)=>{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<e.length;i++){const n=t(e[i]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const i=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&i.push(r)}return i}getDependency(t,e){const i=t+":"+e;let n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":n=this._invokeOne(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t)}this.cache.add(i,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const i=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map(function(e,n){return i.getDependency(t,n)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],i=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[NE.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(t,r){i.load(kh.resolveURL(e.uri,n.path),t,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const i=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+i)})}loadAccessor(t){const e=this,i=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=hA[n.type],e=aA[n.componentType],i=!0===n.normalized,r=new e(n.count*t);return Promise.resolve(new ar(r,t,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(t){const r=t[0],s=hA[n.type],a=aA[n.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,h=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,u=!0===n.normalized;let d,p;if(c&&c!==l){const t=Math.floor(h/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let l=e.cache.get(i);l||(d=new a(r,t*c,n.count*c/o),l=new Sr(d,c/o),e.cache.add(i,l)),p=new Er(l,s,h%c/o,u)}else d=null===r?new a(n.count*s):new a(r,h,n.count*s),p=new ar(d,s,u);if(void 0!==n.sparse){const e=hA.SCALAR,i=aA[n.sparse.indices.componentType],o=n.sparse.indices.byteOffset||0,l=n.sparse.values.byteOffset||0,h=new i(t[1],o,n.sparse.count*e),c=new a(t[2],l,n.sparse.count*s);null!==r&&(p=new ar(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(p.setX(e,c[t*s]),s>=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;i<a;i++){const a=t[i],o=xA(a),l=n[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[NE.KHR_DRACO_MESH_COMPRESSION]?r(a):wA(new Mr,a,e),n[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,i=this.json,n=this.extensions,r=i.meshes[t],s=r.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?gA(this.cache):this.getDependency("material",s[t].material);a.push(e)}return a.push(e.loadGeometries(s)),Promise.all(a).then(function(i){const a=i.slice(0,i.length-1),o=i[i.length-1],l=[];for(let i=0,h=o.length;i<h;i++){const h=o[i],c=s[i];let u;const d=a[i];if(c.mode===sA.TRIANGLES||c.mode===sA.TRIANGLE_STRIP||c.mode===sA.TRIANGLE_FAN||void 0===c.mode)u=!0===r.isSkinnedMesh?new Ts(h,d):new ps(h,d),!0===u.isSkinnedMesh&&u.normalizeSkinWeights(),c.mode===sA.TRIANGLE_STRIP?u.geometry=wE(u.geometry,1):c.mode===sA.TRIANGLE_FAN&&(u.geometry=wE(u.geometry,2));else if(c.mode===sA.LINES)u=new Aa(h,d);else if(c.mode===sA.LINE_STRIP)u=new Sa(h,d);else if(c.mode===sA.LINE_LOOP)u=new Ca(h,d);else{if(c.mode!==sA.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);u=new Da(h,d)}Object.keys(u.geometry.morphAttributes).length>0&&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;i<n;i++)e.associations.set(l[i],{meshes:t,primitives:i});if(1===l.length)return r.extensions&&yA(n,l[0],r),l[0];const h=new un;r.extensions&&yA(n,h,r),e.associations.set(h,{meshes:t});for(let t=0,e=l.length;t<e;t++)h.add(l[t]);return h})}loadCamera(t){let e;const i=this.json.cameras[t],n=i[i.type];if(n)return"perspective"===i.type?e=new Eh(hi.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(e=new Ih(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(e.name=this.createUniqueName(i.name)),_A(e,i),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],i=[];for(let t=0,n=e.joints.length;t<n;t++)i.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?i.push(this.getDependency("accessor",e.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(t){const i=t.pop(),n=t,r=[],s=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];if(a){r.push(a);const e=new Ui;null!==i&&e.fromArray(i.array,16*t),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new Rs(r,s)})}loadAnimation(t){const e=this.json,i=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,s=[],a=[],o=[],l=[],h=[];for(let t=0,e=n.channels.length;t<e;t++){const e=n.channels[t],i=n.samplers[e.sampler],r=e.target,c=r.node,u=void 0!==n.parameters?n.parameters[i.input]:i.input,d=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),a.push(this.getDependency("accessor",u)),o.push(this.getDependency("accessor",d)),l.push(i),h.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(h)]).then(function(t){const e=t[0],s=t[1],a=t[2],o=t[3],l=t[4],h=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],r=s[t],c=a[t],u=o[t],d=l[t];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const p=i._createAnimationTracks(n,r,c,u,d);if(p)for(let t=0;t<p.length;t++)h.push(p[t])}const c=new $l(r,void 0,h);return _A(c,n),c})}createNodeMesh(t){const e=this.json,i=this,n=e.nodes[t];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then(function(t){const e=i._getNodeRef(i.meshCache,n.mesh,t);return void 0!==n.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,i=n.weights.length;e<i;e++)t.morphTargetInfluences[e]=n.weights[e]}),e})}loadNode(t){const e=this,i=this.json.nodes[t],n=e._loadNodeShallow(t),r=[],s=i.children||[];for(let t=0,i=s.length;t<i;t++)r.push(e.getDependency("node",s[t]));const a=void 0===i.skin?Promise.resolve(null):e.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),a]).then(function(t){const e=t[0],i=t[1],n=t[2];null!==n&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(n,SA)});for(let t=0,n=i.length;t<n;t++)e.add(i[t]);if(void 0!==e.userData.pivot&&i.length>0){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;t<i;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),_A(a,r),r.extensions&&yA(i,a,r),void 0!==r.matrix){const t=new Ui;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);if(n.associations.has(a)){if(void 0!==r.mesh&&n.meshCache.refs[r.mesh]>1){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<e;t++)a.push(n.getDependency("node",s[t]));return Promise.all(a).then(function(t){for(let e=0,i=t.length;e<i;e++){const i=t[e];null!==i.parent?r.add(EE(i)):r.add(i)}return n.associations=(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<i;t++){const i=new h(o[t]+"."+uA[r.path],e.array,u,c);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(i),s.push(i)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=MA(e.constructor),i=new Float32Array(e.length);for(let n=0,r=e.length;n<r;n++)i[n]=e[n]*t;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Zl?rA:iA)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function wA(t,e,i){const n=e.attributes,r=[];function s(e,n){return i.getDependency("accessor",e).then(function(e){t.setAttribute(n,e)})}for(const e in n){const i=cA[e]||e.toLowerCase();i in t.attributes||r.push(s(n[e],i))}if(void 0!==e.indices&&!t.index){const n=i.getDependency("accessor",e.indices).then(function(e){t.setIndex(e)});r.push(n)}return xi.workingColorSpace!==Se&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${xi.workingColorSpace}" not supported.`),_A(t,e),function(t,e,i){const n=e.attributes,r=new Fn;if(void 0===n.POSITION)return;{const t=i.json.accessors[n.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new di(e[0],e[1],e[2]),new di(s[0],s[1],s[2])),t.normalized){const e=MA(aA[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new di,e=new di;for(let n=0,r=s.length;n<r;n++){const r=s[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],s=n.min,a=n.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),n.normalized){const t=MA(aA[n.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new mr;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,i),Promise.all(r).then(function(){return void 0!==e.targets?function(t,e,i){let n=!1,r=!1,s=!1;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(t);const a=[],o=[],l=[];for(let h=0,c=e.length;h<c;h++){const c=e[h];if(n){const e=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):t.attributes.color;l.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(e){const i=e[0],a=e[1],o=e[2];return n&&(t.morphAttributes.position=i),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t})}(t,e.targets,i):t})}var EA=Object.freeze({__proto__:null,GLTFLoader:class extends rh{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new DE(t)}),this.register(function(t){return new OE(t)}),this.register(function(t){return new WE(t)}),this.register(function(t){return new jE(t)}),this.register(function(t){return new XE(t)}),this.register(function(t){return new FE(t)}),this.register(function(t){return new zE(t)}),this.register(function(t){return new kE(t)}),this.register(function(t){return new BE(t)}),this.register(function(t){return new LE(t)}),this.register(function(t){return new VE(t)}),this.register(function(t){return new UE(t)}),this.register(function(t){return new HE(t)}),this.register(function(t){return new GE(t)}),this.register(function(t){return new IE(t)}),this.register(function(t){return new qE(t,NE.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new qE(t,NE.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new YE(t)})}load(t,e,i,n){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=kh.extractUrlBase(t);s=kh.resolveURL(e,this.path)}else s=kh.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){n?n(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new oh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(i){try{r.parse(i,s,function(i){e(i),r.manager.itemEnd(t)},a)}catch(t){a(t)}},i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,i,n){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===ZE){try{s[NE.KHR_BINARY_GLTF]=new $E(t)}catch(t){return void(n&&n(t))}r=JSON.parse(s[NE.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=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<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],i=r.extensionsRequired||[];switch(e){case NE.KHR_MATERIALS_UNLIT:s[e]=new PE;break;case NE.KHR_DRACO_MESH_COMPRESSION:s[e]=new QE(r,this.dracoLoader);break;case NE.KHR_TEXTURE_TRANSFORM:s[e]=new tA;break;case NE.KHR_MESH_QUANTIZATION:s[e]=new eA;break;default:i.indexOf(e)>=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<i;e++){for(let i=0;i<o;i++)g[t+i]=f[e*o+i];t+=u}}return t._free(m),{name:n,count:a,itemSize:o,array:g,stride:u}}onmessage=function(n){const r=n.data;switch(r.type){case"init":t=r.decoderConfig,e=new Promise(function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)});break;case"decode":const n=r.buffer,s=r.taskConfig;e.then(t=>{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<t.attributes.length;i++){const{name:n,array:r,itemSize:s,stride:a,vertexColorSpace:o}=t.attributes[i];let l;if(s===a)l=new ar(r,s);else{const t=new Sr(r,a);l=new Er(t,s,0)}"color"===n&&(this._assignVertexColorSpace(l,o),l.normalized=r instanceof Float32Array==!1),e.setAttribute(n,l)}return e}_assignVertexColorSpace(t,e){if(e!==Me)return;const i=new _n;for(let e=0,n=t.count;e<n;e++)i.fromBufferAttribute(t,e),xi.colorSpaceToWorking(i,Me),t.setXYZ(e,i.r,i.g,i.b)}_loadLibrary(t,e){const i=new oh(this.manager);return i.setPath(this.decoderPath),i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((e,n)=>{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.length<this.workerLimit){const t=new Worker(this.workerSourceURL);t._callbacks={},t._taskCosts={},t._taskLoad=0,t.postMessage({type:"init",decoderConfig:this.decoderConfig}),t.onmessage=function(e){const i=e.data;switch(i.type){case"decode":t._callbacks[i.id].resolve(i);break;case"error":t._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(t)}else this.workerPool.sort(function(t,e){return t._taskLoad>e._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<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}});function NA(t){return new Nl({color:0,emissive:16777215,emissiveIntensity:t})}var IA=Object.freeze({__proto__:null,RoomEnvironment:class extends Mn{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;const t=new Ga;t.deleteAttribute("uv");const e=new wl({side:1}),i=new wl,n=new Nh(16777215,900,28,2);n.position.set(.418,16.199,.3),this.add(n);const r=new ps(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new zs(t,i,6),a=new cn;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),s.setMatrixAt(0,a.matrix),a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),s.setMatrixAt(1,a.matrix),a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),s.setMatrixAt(2,a.matrix),a.position.set(-2.017,.018,6.124),a.rotation.set(0,.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),s.setMatrixAt(3,a.matrix),a.position.set(2.291,-.756,-2.621),a.rotation.set(0,-.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),s.setMatrixAt(4,a.matrix),a.position.set(-2.193,-.369,-5.547),a.rotation.set(0,.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),s.setMatrixAt(5,a.matrix),this.add(s);const o=new ps(t,NA(50));o.position.set(-16.116,14.37,8.208),o.scale.set(.1,2.428,2.739),this.add(o);const l=new ps(t,NA(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);const h=new ps(t,NA(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);const c=new ps(t,NA(43));c.position.set(-.462,8.89,14.52),c.scale.set(4.38,5.441,.088),this.add(c);const u=new ps(t,NA(20));u.position.set(3.235,11.486,-12.541),u.scale.set(2.5,2,.1),this.add(u);const d=new ps(t,NA(100));d.position.set(0,20,0),d.scale.set(1,.1,1),this.add(d)}dispose(){const t=new Set;this.traverse(e=>{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<e&&n<t.byteLength;)a+=o,s+=o.length,n+=128,o=String.fromCharCode.apply(null,new Uint16Array(t.subarray(n,n+128)));return-1<r&&(t.pos+=s+r+1,a+o.slice(0,r))},n=function(t,e,i,n){const r=t[e+3],s=Math.pow(2,r-128)/255;i[n+0]=t[e+0]*s,i[n+1]=t[e+1]*s,i[n+2]=t[e+2]*s,i[n+3]=1},r=function(t,e,i,n){const r=t[e+3],s=Math.pow(2,r-128)/255;i[n+0]=ir.toHalfFloat(Math.min(t[e+0]*s,65504)),i[n+1]=ir.toHalfFloat(Math.min(t[e+1]*s,65504)),i[n+2]=ir.toHalfFloat(Math.min(t[e+2]*s,65504)),i[n+3]=ir.toHalfFloat(1)},s=new Uint8Array(t);s.pos=0;const a=function(t){const n=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,h;for((t.pos>=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&&o<t.byteLength;){o+4>t.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(;n<l&&o<t.byteLength;){i=t[o++];const r=i>128;if(r&&(i-=128),(0===i||n+i>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t<i;t++)c[n++]=e}else c.set(t.subarray(o,o+i),n),n+=i,o+=i}const d=r;for(let t=0;t<d;t++){let e=0;s[a]=c[t+e],e+=r,s[a+1]=c[t+e],e+=r,s[a+2]=c[t+e],e+=r,s[a+3]=c[t+e],a+=4}u--}return s}(s.subarray(s.pos),o,l);let c,u,d;switch(this.type){case pt:d=h.length/4;const t=new Float32Array(4*d);for(let e=0;e<d;e++)n(h,4*e,t,4*e);c=t,u=pt;break;case mt:d=h.length/4;const e=new Uint16Array(4*d);for(let t=0;t<d;t++)r(h,4*t,e,4*t);c=e,u=mt;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:o,height:l,data:c,header:a.string,gamma:a.gamma,exposure:a.exposure,type:u}}setDataType(t){return this.type=t,this}load(t,e,i,n){return super.load(t,function(t,i){switch(t.type){case pt:case mt:t.colorSpace=Se,t.minFilter=rt,t.magFilter=rt,t.generateMipmaps=!1,t.flipY=!0}e&&e(t,i)},i,n)}}});export{Mr as B,_n as C,o as D,iT as E,IS as F,EA as G,PA as H,rh as L,XS as M,kM as O,Mw as P,GS as Q,IA as R,Pw as S,Qp as T,HS as V,Lw as X,VS as a,oS as b,nT as c,oh as d,lm as e,ps as f,Nl as g,Ui as h,ar as i,rT as j,aT as k,vT as l,SE as m,vw as n,Iw as o,bE as p,ME as q,RA as r};
//# sourceMappingURL=three.js.map