vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Render images and 3D models in the browser views
3b2bcc30534f24b4628b6365e69dcb9065115065 · Keenan Nemetz · 13d ago · parent 87bab8e1
Render images and 3D models in the browser views A blob whose name is an image is served as that image, so the <img> a README already emitted works and the source view can show it. An SVG keeps its source view and previews on request. The instance introduction resolves assets/, so a landing-page picture is no longer a broken link. A changed image or model shows both sides in the commit, compare, and change request diffs, where git only says "binary". The 3D viewer is a vendored three.js bundle, loaded only when a page has a model, with a download fallback for a reader without JavaScript or WebGL. closes: 01M7XQ9AKKKFNEX0F679JRRYQD
server/web/static/models/three.bundle.js +4243
| @@ -0,0 +1,4243 @@ | |||
| 1 | /* three.js r187 for Vole's 3D preview: three.module.js with the | ||
| 2 | OrbitControls, STL, OBJ, glTF and 3MF loaders. Generated by | ||
| 3 | scripts/vendor-three.py; edit that, not this file. MIT license: three.LICENSE. */ | ||
| 4 | var Ci={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ii={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},cu=0,Tl=1,hu=2;var br=1,uu=2,Ps=3,Vn=0,en=1,vn=2,Zi=0,Ls=1,Al=2,wl=3,El=4,fu=5;var Ki=100,du=101,pu=102,mu=103,gu=104,_u=200,xu=201,vu=202,yu=203,Rl=204,Cl=205,Mu=206,Su=207,bu=208,Tu=209,Au=210,wu=211,Eu=212,Ru=213,Cu=214,mo=0,go=1,_o=2,gs=3,xo=4,vo=5,yo=6,Mo=7,Vo=0,Iu=1,Pu=2,Hn=0,Il=1,Pl=2,Ll=3,Dl=4,Nl=5,Ul=6,Fl=7,fl="attached",Lu="detached",Ol=300,Ji=301,Ds=302,Ho=303,Wo=304,un=1e3,jt=1001,ii=1002,Tt=1003,Xo=1004;var ji=1005;var At=1006,Ns=1007;var tn=1008;var on=1009,Bl=1010,zl=1011,Us=1012,qo=1013,Pn=1014,dn=1015,Ln=1016,Yo=1017,Zo=1018,$i=1020,kl=35902,Gl=35899,Vl=1021,Hl=1022,yn=1023,si=1026,pi=1027,Ko=1028,Jo=1029,Pi=1030,jo=1031;var $o=1033,Tr=33776,Ar=33777,wr=33778,Er=33779,Qo=35840,ea=35841,ta=35842,na=35843,ia=36196,sa=37492,ra=37496,oa=37488,aa=37489,Rr=37490,la=37491,ca=37808,ha=37809,ua=37810,fa=37811,da=37812,pa=37813,ma=37814,ga=37815,_a=37816,xa=37817,va=37818,ya=37819,Ma=37820,Sa=37821,ba=36492,Ta=36494,Aa=36495,wa=36283,Ea=36284,Cr=36285,Ra=36286;var Gi=2300,Vi=2301,fo=2302,dl=2303,pl=2400,ml=2401,gl=2402,Du=2500;var Wl=0,Ir=1,Fs=2,Nu=3200;var Pr=0,Uu=1,mi="",Mt="srgb",$t="srgb-linear",er="linear",pt="srgb";var po=7680;var Fu=519,Ou=512,Bu=513,zu=514,Xl=515,ku=516,Gu=517,ql=518,Yl=519,Zl=35044;var Kl="300 es",_n=2e3,_s=2001;function sd(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function rd(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function xs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Vu(){let i=xs("canvas");return i.style.display="block",i}var bh={},vs=null;function tr(...i){let e="THREE."+i.shift();vs?vs("log",e,...i):console.log(e,...i)}function Hu(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function ze(...i){i=Hu(i);let e="THREE."+i.shift();if(vs)vs("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function qe(...i){i=Hu(i);let e="THREE."+i.shift();if(vs)vs("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ki(...i){let e=i.join(" ");e in bh||(bh[e]=!0,ze(...i))}function Wu(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var Xu={[mo]:mo,[_o]:yo,[xo]:xo,[gs]:vo,[go]:go,[yo]:_o,[Mo]:Mo,[vo]:gs},Rn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},qt=["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"],Th=1234567,$s=Math.PI/180,Hi=180/Math.PI;function Wn(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[n&255]+qt[n>>8&255]+qt[n>>16&255]+qt[n>>24&255]).toLowerCase()}function nt(i,e,t){return Math.max(e,Math.min(t,i))}function Jl(i,e){return(i%e+e)%e}function od(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function ad(i,e,t){return i!==e?(t-i)/(e-i):0}function Qs(i,e,t){return(1-t)*i+t*e}function ld(i,e,t,n){return Qs(i,e,1-Math.exp(-t*n))}function cd(i,e=1){return e-Math.abs(Jl(i,e*2)-e)}function hd(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ud(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function fd(i,e){return i+Math.floor(Math.random()*(e-i+1))}function dd(i,e){return i+Math.random()*(e-i)}function pd(i){return i*(.5-Math.random())}function md(i){i!==void 0&&(Th=i);let e=Th+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function gd(i){return i*$s}function _d(i){return i*Hi}function xd(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function vd(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function jl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function yd(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),f=o((e-n)/2),d=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*h,c*u,c*f,a*l);break;case"YZY":i.set(c*f,a*h,c*u,a*l);break;case"ZXZ":i.set(c*u,c*f,a*h,a*l);break;case"XZX":i.set(a*h,c*g,c*d,a*l);break;case"YXY":i.set(c*d,a*h,c*g,a*l);break;case"ZYZ":i.set(c*g,c*d,a*h,a*l);break;default:ze("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Ca(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function $l(i,e){if(e.constructor===Float32Array)return i;let t=Ca(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function Ql(i,e){if(e.constructor===Float32Array)return i;let t=Ca(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var Os={DEG2RAD:$s,RAD2DEG:Hi,generateUUID:Wn,clamp:nt,euclideanModulo:Jl,mapLinear:od,inverseLerp:ad,lerp:Qs,damp:ld,pingpong:cd,smoothstep:hd,smootherstep:ud,randInt:fd,randFloat:dd,randFloatSpread:pd,seededRandom:md,degToRad:gd,radToDeg:_d,isPowerOfTwo:xd,ceilPowerOfTwo:vd,floorPowerOfTwo:jl,setQuaternionFromProperEuler:yd,normalize:Ql,denormalize:$l},sc=class sc{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=nt(this.x,e.x,t.x),this.y=nt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=nt(this.x,e,t),this.y=nt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(nt(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(nt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};sc.prototype.isVector2=!0;var We=sc,zt=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3],f=r[o+0],d=r[o+1],g=r[o+2],x=r[o+3];if(u!==x||c!==f||l!==d||h!==g){let m=c*f+l*d+h*g+u*x;m<0&&(f=-f,d=-d,g=-g,x=-x,m=-m);let p=1-a;if(m<.9995){let M=Math.acos(m),A=Math.sin(M);p=Math.sin(p*M)/A,a=Math.sin(a*M)/A,c=c*p+f*a,l=l*p+d*a,h=h*p+g*a,u=u*p+x*a}else{c=c*p+f*a,l=l*p+d*a,h=h*p+g*a,u=u*p+x*a;let M=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=M,l*=M,h*=M,u*=M}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[o],f=r[o+1],d=r[o+2],g=r[o+3];return e[t]=a*g+h*u+c*d-l*f,e[t+1]=c*g+h*f+l*u-a*d,e[t+2]=l*g+h*d+a*f-c*u,e[t+3]=h*g-a*u-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(s/2),u=a(r/2),f=c(n/2),d=c(s/2),g=c(r/2);switch(o){case"XYZ":this._x=f*h*u+l*d*g,this._y=l*d*u-f*h*g,this._z=l*h*g+f*d*u,this._w=l*h*u-f*d*g;break;case"YXZ":this._x=f*h*u+l*d*g,this._y=l*d*u-f*h*g,this._z=l*h*g-f*d*u,this._w=l*h*u+f*d*g;break;case"ZXY":this._x=f*h*u-l*d*g,this._y=l*d*u+f*h*g,this._z=l*h*g+f*d*u,this._w=l*h*u-f*d*g;break;case"ZYX":this._x=f*h*u-l*d*g,this._y=l*d*u+f*h*g,this._z=l*h*g-f*d*u,this._w=l*h*u+f*d*g;break;case"YZX":this._x=f*h*u+l*d*g,this._y=l*d*u+f*h*g,this._z=l*h*g-f*d*u,this._w=l*h*u-f*d*g;break;case"XZY":this._x=f*h*u-l*d*g,this._y=l*d*u-f*h*g,this._z=l*h*g+f*d*u,this._w=l*h*u+f*d*g;break;default:ze("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],f=n+a+u;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-c)*d,this._y=(r-l)*d,this._z=(o-s)*d}else if(n>a&&n>u){let d=2*Math.sqrt(1+n-a-u);this._w=(h-c)/d,this._x=.25*d,this._y=(s+o)/d,this._z=(r+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-n-u);this._w=(r-l)/d,this._x=(s+o)/d,this._y=.25*d,this._z=(c+h)/d}else{let d=2*Math.sqrt(1+u-n-a);this._w=(o-s)/d,this._x=(r+l)/d,this._y=(c+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(nt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+s*l-r*c,this._y=s*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-s*a,this._w=o*h-n*a-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let c=1-t;if(a<.9995){let l=Math.acos(a),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},rc=class rc{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ah.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ah.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*s-a*n),h=2*(a*t-r*s),u=2*(r*n-o*t);return this.x=t+c*l+o*u-a*h,this.y=n+c*h+a*l-r*u,this.z=s+c*u+r*h-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=nt(this.x,e.x,t.x),this.y=nt(this.y,e.y,t.y),this.z=nt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=nt(this.x,e,t),this.y=nt(this.y,e,t),this.z=nt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(nt(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=s*c-r*a,this.y=r*o-n*c,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Va.copy(this).projectOnVector(e),this.sub(Va)}reflect(e){return this.sub(Va.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(nt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};rc.prototype.isVector3=!0;var O=rc,Va=new O,Ah=new zt,oc=class oc{constructor(e,t,n,s,r,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,c,l)}set(e,t,n,s,r,o,a,c,l){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],u=n[7],f=n[2],d=n[5],g=n[8],x=s[0],m=s[3],p=s[6],M=s[1],A=s[4],S=s[7],E=s[2],T=s[5],_=s[8];return r[0]=o*x+a*M+c*E,r[3]=o*m+a*A+c*T,r[6]=o*p+a*S+c*_,r[1]=l*x+h*M+u*E,r[4]=l*m+h*A+u*T,r[7]=l*p+h*S+u*_,r[2]=f*x+d*M+g*E,r[5]=f*m+d*A+g*T,r[8]=f*p+d*S+g*_,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-n*r*h+n*a*c+s*r*l-s*o*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*o-a*l,f=a*c-h*r,d=l*r-o*c,g=t*u+n*f+s*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return e[0]=u*x,e[1]=(s*l-h*n)*x,e[2]=(a*n-s*o)*x,e[3]=f*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-a*t)*x,e[6]=d*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-s*l,s*c,-s*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return ki("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ha.makeScale(e,t)),this}rotate(e){return ki("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ha.makeRotation(-e)),this}translate(e,t){return ki("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ha.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};oc.prototype.isMatrix3=!0;var Ke=oc,Ha=new Ke,wh=new Ke().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eh=new Ke().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Md(){let i={enabled:!0,workingColorSpace:$t,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===pt&&(s.r=ni(s.r),s.g=ni(s.g),s.b=ni(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===pt&&(s.r=ms(s.r),s.g=ms(s.g),s.b=ms(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===mi?er:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[o].fromXYZ).multiply(this.spaces[r].toXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[$t]:{primaries:e,whitePoint:n,transfer:er,toXYZ:wh,fromXYZ:Eh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Mt},outputColorSpaceConfig:{drawingBufferColorSpace:Mt}},[Mt]:{primaries:e,whitePoint:n,transfer:pt,toXYZ:wh,fromXYZ:Eh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Mt}}}),i}var tt=Md();function ni(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ms(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ts,So=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ts===void 0&&(ts=xs("canvas")),ts.width=e.width,ts.height=e.height;let s=ts.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ts}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=xs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=ni(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ni(t[n]/255)*255):t[n]=ni(t[n]);return{data:t,width:e.width,height:e.height}}else return ze("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Sd=0,ys=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Sd++}),this.uuid=Wn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width||0,t.height||0,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Wa(s[o].image)):r.push(Wa(s[o]))}else r=Wa(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Wa(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?So.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(ze("Texture: Unable to serialize Texture."),{})}var bd=0,Xa=new O,kt=class i extends Rn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=jt,s=jt,r=At,o=tn,a=yn,c=on,l=i.DEFAULT_ANISOTROPY,h=mi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:bd++}),this.uuid=Wn(),this.name="",this.source=new ys(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new We(0,0),this.repeat=new We(1,1),this.center=new We(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!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=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Xa).x}get height(){return this.source.getSize(Xa).y}get depth(){return this.source.getSize(Xa).z}get image(){return this.source.data}set image(e){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.mipmapsAutoUpdate=e.mipmapsAutoUpdate,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){ze(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){ze(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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,mipmapsAutoUpdate:this.mipmapsAutoUpdate,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ol)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case un:e.x=e.x-Math.floor(e.x);break;case jt:e.x=e.x<0?0:1;break;case ii:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case un:e.y=e.y-Math.floor(e.y);break;case jt:e.y=e.y<0?0:1;break;case ii:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};kt.DEFAULT_IMAGE=null;kt.DEFAULT_MAPPING=Ol;kt.DEFAULT_ANISOTROPY=1;var ac=class ac{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,c=e.elements,l=c[0],h=c[4],u=c[8],f=c[1],d=c[5],g=c[9],x=c[2],m=c[6],p=c[10];if(Math.abs(h-f)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,S=(d+1)/2,E=(p+1)/2,T=(h+f)/4,_=(u+x)/4,b=(g+m)/4;return A>S&&A>E?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=T/n,r=_/n):S>E?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=T/s,r=b/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=_/r,s=b/r),this.set(n,s,r,t),this}let M=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(f-h)*(f-h));return Math.abs(M)<.001&&(M=1),this.x=(m-g)/M,this.y=(u-x)/M,this.z=(f-h)/M,this.w=Math.acos((l+d+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=nt(this.x,e.x,t.x),this.y=nt(this.y,e.y,t.y),this.z=nt(this.z,e.z,t.z),this.w=nt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=nt(this.x,e,t),this.y=nt(this.y,e,t),this.z=nt(this.z,e,t),this.w=nt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(nt(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}};ac.prototype.isVector4=!0;var gt=ac,bo=class extends Rn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];let s=n.count;for(let r=0;r<s;r++)this.textures[r]=new kt({width:e,height:t,depth:n.depth}),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:At,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new ys(s)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},fn=class extends bo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},nr=class extends kt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var To=class extends kt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var Go=class Go{constructor(e,t,n,s,r,o,a,c,l,h,u,f,d,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,c,l,h,u,f,d,g,x,m)}set(e,t,n,s,r,o,a,c,l,h,u,f,d,g,x,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=f,p[3]=d,p[7]=g,p[11]=x,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Go().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,s=1/ns.setFromMatrixColumn(e,0).length(),r=1/ns.setFromMatrixColumn(e,1).length(),o=1/ns.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=o*h,d=o*u,g=a*h,x=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=d+g*l,t[5]=f-x*l,t[9]=-a*c,t[2]=x-f*l,t[6]=g+d*l,t[10]=o*c}else if(e.order==="YXZ"){let f=c*h,d=c*u,g=l*h,x=l*u;t[0]=f+x*a,t[4]=g*a-d,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=d*a-g,t[6]=x+f*a,t[10]=o*c}else if(e.order==="ZXY"){let f=c*h,d=c*u,g=l*h,x=l*u;t[0]=f-x*a,t[4]=-o*u,t[8]=g+d*a,t[1]=d+g*a,t[5]=o*h,t[9]=x-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let f=o*h,d=o*u,g=a*h,x=a*u;t[0]=c*h,t[4]=g*l-d,t[8]=f*l+x,t[1]=c*u,t[5]=x*l+f,t[9]=d*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let f=o*c,d=o*l,g=a*c,x=a*l;t[0]=c*h,t[4]=x-f*u,t[8]=g*u+d,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=d*u+g,t[10]=f-x*u}else if(e.order==="XZY"){let f=o*c,d=o*l,g=a*c,x=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=f*u+x,t[5]=o*h,t[9]=d*u-g,t[2]=g*u-d,t[6]=a*h,t[10]=x*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Td,e,Ad)}lookAt(e,t,n){let s=this.elements;return ln.subVectors(e,t),ln.lengthSq()===0&&(ln.z=1),ln.normalize(),vi.crossVectors(n,ln),vi.lengthSq()===0&&(Math.abs(n.z)===1?ln.x+=1e-4:ln.z+=1e-4,ln.normalize(),vi.crossVectors(n,ln)),vi.normalize(),Gr.crossVectors(ln,vi),s[0]=vi.x,s[4]=Gr.x,s[8]=ln.x,s[1]=vi.y,s[5]=Gr.y,s[9]=ln.y,s[2]=vi.z,s[6]=Gr.z,s[10]=ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],u=n[5],f=n[9],d=n[13],g=n[2],x=n[6],m=n[10],p=n[14],M=n[3],A=n[7],S=n[11],E=n[15],T=s[0],_=s[4],b=s[8],F=s[12],P=s[1],L=s[5],B=s[9],K=s[13],C=s[2],q=s[6],X=s[10],W=s[14],ae=s[3],Y=s[7],oe=s[11],le=s[15];return r[0]=o*T+a*P+c*C+l*ae,r[4]=o*_+a*L+c*q+l*Y,r[8]=o*b+a*B+c*X+l*oe,r[12]=o*F+a*K+c*W+l*le,r[1]=h*T+u*P+f*C+d*ae,r[5]=h*_+u*L+f*q+d*Y,r[9]=h*b+u*B+f*X+d*oe,r[13]=h*F+u*K+f*W+d*le,r[2]=g*T+x*P+m*C+p*ae,r[6]=g*_+x*L+m*q+p*Y,r[10]=g*b+x*B+m*X+p*oe,r[14]=g*F+x*K+m*W+p*le,r[3]=M*T+A*P+S*C+E*ae,r[7]=M*_+A*L+S*q+E*Y,r[11]=M*b+A*B+S*X+E*oe,r[15]=M*F+A*K+S*W+E*le,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],f=e[10],d=e[14],g=e[3],x=e[7],m=e[11],p=e[15],M=c*d-l*f,A=a*d-l*u,S=a*f-c*u,E=o*d-l*h,T=o*f-c*h,_=o*u-a*h;return t*(x*M-m*A+p*S)-n*(g*M-m*E+p*T)+s*(g*A-x*E+p*_)-r*(g*S-x*T+m*_)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],o=e[5],a=e[9],c=e[2],l=e[6],h=e[10];return t*(o*h-a*l)-n*(r*h-a*c)+s*(r*l-o*c)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],g=e[12],x=e[13],m=e[14],p=e[15],M=t*a-n*o,A=t*c-s*o,S=t*l-r*o,E=n*c-s*a,T=n*l-r*a,_=s*l-r*c,b=h*x-u*g,F=h*m-f*g,P=h*p-d*g,L=u*m-f*x,B=u*p-d*x,K=f*p-d*m,C=M*K-A*B+S*L+E*P-T*F+_*b;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let q=1/C;return e[0]=(a*K-c*B+l*L)*q,e[1]=(s*B-n*K-r*L)*q,e[2]=(x*_-m*T+p*E)*q,e[3]=(f*T-u*_-d*E)*q,e[4]=(c*P-o*K-l*F)*q,e[5]=(t*K-s*P+r*F)*q,e[6]=(m*S-g*_-p*A)*q,e[7]=(h*_-f*S+d*A)*q,e[8]=(o*B-a*P+l*b)*q,e[9]=(n*P-t*B-r*b)*q,e[10]=(g*T-x*S+p*M)*q,e[11]=(u*S-h*T-d*M)*q,e[12]=(a*F-o*L-c*b)*q,e[13]=(t*L-n*F+s*b)*q,e[14]=(x*A-g*E-m*M)*q,e[15]=(h*E-u*A+f*M)*q,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-s*c,l*c+s*a,0,l*a+s*c,h*a+n,h*c-s*o,0,l*c-s*a,h*c+s*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,f=r*l,d=r*h,g=r*u,x=o*h,m=o*u,p=a*u,M=c*l,A=c*h,S=c*u,E=n.x,T=n.y,_=n.z;return s[0]=(1-(x+p))*E,s[1]=(d+S)*E,s[2]=(g-A)*E,s[3]=0,s[4]=(d-S)*T,s[5]=(1-(f+p))*T,s[6]=(m+M)*T,s[7]=0,s[8]=(g+A)*_,s[9]=(m-M)*_,s[10]=(1-(f+x))*_,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let o=ns.set(s[0],s[1],s[2]).length(),a=ns.set(s[4],s[5],s[6]).length(),c=ns.set(s[8],s[9],s[10]).length();r<0&&(o=-o),An.copy(this);let l=1/o,h=1/a,u=1/c;return An.elements[0]*=l,An.elements[1]*=l,An.elements[2]*=l,An.elements[4]*=h,An.elements[5]*=h,An.elements[6]*=h,An.elements[8]*=u,An.elements[9]*=u,An.elements[10]*=u,t.setFromRotationMatrix(An),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,r,o,a=_n,c=!1){let l=this.elements,h=2*r/(t-e),u=2*r/(n-s),f=(t+e)/(t-e),d=(n+s)/(n-s),g,x;if(c)g=r/(o-r),x=o*r/(o-r);else if(a===_n)g=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===_s)g=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=_n,c=!1){let l=this.elements,h=2/(t-e),u=2/(n-s),f=-(t+e)/(t-e),d=-(n+s)/(n-s),g,x;if(c)g=1/(o-r),x=o/(o-r);else if(a===_n)g=-2/(o-r),x=-(o+r)/(o-r);else if(a===_s)g=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=0,l[12]=f,l[1]=0,l[5]=u,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};Go.prototype.isMatrix4=!0;var Ze=Go,ns=new O,An=new Ze,Td=new O(0,0,0),Ad=new O(1,1,1),vi=new O,Gr=new O,ln=new O,Rh=new Ze,Ch=new zt,Fn=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],o=s[4],a=s[8],c=s[1],l=s[5],h=s[9],u=s[2],f=s[6],d=s[10];switch(t){case"XYZ":this._y=Math.asin(nt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-nt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(nt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-nt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(nt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-nt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:ze("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Rh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Rh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ch.setFromEuler(this),this.setFromQuaternion(Ch,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Fn.DEFAULT_ORDER="XYZ";var ir=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},wd=0,Ih=new O,is=new zt,Jn=new Ze,Vr=new O,Hs=new O,Ed=new O,Rd=new zt,Ph=new O(1,0,0),Lh=new O(0,1,0),Dh=new O(0,0,1),Nh={type:"added"},Cd={type:"removed"},ss={type:"childadded",child:null},qa={type:"childremoved",child:null},wt=class i extends Rn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wd++}),this.uuid=Wn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new O,t=new Fn,n=new zt,s=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Ze},normalMatrix:{value:new Ke}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ir,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return is.setFromAxisAngle(e,t),this.quaternion.multiply(is),this}rotateOnWorldAxis(e,t){return is.setFromAxisAngle(e,t),this.quaternion.premultiply(is),this}rotateX(e){return this.rotateOnAxis(Ph,e)}rotateY(e){return this.rotateOnAxis(Lh,e)}rotateZ(e){return this.rotateOnAxis(Dh,e)}translateOnAxis(e,t){return Ih.copy(e).applyQuaternion(this.quaternion),this.position.add(Ih.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ph,e)}translateY(e){return this.translateOnAxis(Lh,e)}translateZ(e){return this.translateOnAxis(Dh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Vr.copy(e):Vr.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Hs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jn.lookAt(Hs,Vr,this.up):Jn.lookAt(Vr,Hs,this.up),this.quaternion.setFromRotationMatrix(Jn),s&&(Jn.extractRotation(s.matrixWorld),is.setFromRotationMatrix(Jn),this.quaternion.premultiply(is.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(qe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Nh),ss.child=e,this.dispatchEvent(ss),ss.child=null):qe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Cd),qa.child=e,this.dispatchEvent(qa),qa.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Jn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Nh),ss.child=e,this.dispatchEvent(ss),ss.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hs,e,Ed),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hs,Rd,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];s.animations.push(r(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),f=o(e.skeletons),d=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let c=[];for(let l in a){let h=a[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};wt.DEFAULT_UP=new O(0,1,0);wt.DEFAULT_MATRIX_AUTO_UPDATE=!0;wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Bt=class extends wt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Id={type:"move"},Ms=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Bt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let x of e.hand.values()){let m=t.getJointPose(x,n),p=this._getHandJoint(l,x);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.quaternion,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,g=.005;l.inputState.pinching&&f>d+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.quaternion,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Id)))}return a!==null&&(a.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Bt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},qu={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},yi={h:0,s:0,l:0},Hr={h:0,s:0,l:0};function Ya(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Be=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=tt.workingColorSpace){return this.r=e,this.g=t,this.b=n,tt.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=tt.workingColorSpace){if(e=Jl(e,1),t=nt(t,0,1),n=nt(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Ya(o,r,e+1/3),this.g=Ya(o,r,e),this.b=Ya(o,r,e-1/3)}return tt.colorSpaceToWorking(this,s),this}setStyle(e,t=Mt){function n(r){r!==void 0&&parseFloat(r)<1&&ze("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseFloat(r[1]))/100,Math.min(100,parseFloat(r[2]))/100,Math.min(100,parseFloat(r[3]))/100,t);break;case"hsl":case"hsla":if(r=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:ze("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);ze("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Mt){let n=qu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):ze("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ni(e.r),this.g=ni(e.g),this.b=ni(e.b),this}copyLinearToSRGB(e){return this.r=ms(e.r),this.g=ms(e.g),this.b=ms(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mt){return tt.workingToColorSpace(Yt.copy(this),e),Math.round(nt(Yt.r*255,0,255))*65536+Math.round(nt(Yt.g*255,0,255))*256+Math.round(nt(Yt.b*255,0,255))}getHexString(e=Mt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tt.workingColorSpace){tt.workingToColorSpace(Yt.copy(this),t);let n=Yt.r,s=Yt.g,r=Yt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),c,l,h=(a+o)/2;if(a===o)c=0,l=0;else{let u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=tt.workingColorSpace){return tt.workingToColorSpace(Yt.copy(this),t),e.r=Yt.r,e.g=Yt.g,e.b=Yt.b,e}getStyle(e=Mt){tt.workingToColorSpace(Yt.copy(this),e);let t=Yt.r,n=Yt.g,s=Yt.b;return e!==Mt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(yi),this.setHSL(yi.h+e,yi.s+t,yi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(yi),e.getHSL(Hr);let n=Qs(yi.h,Hr.h,t),s=Qs(yi.s,Hr.s,t),r=Qs(yi.l,Hr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Yt=new Be;Be.NAMES=qu;var Ao=class extends wt{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 Fn,this.environmentIntensity=1,this.environmentRotation=new Fn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background!==null?e.background.clone():null,this.environment=e.environment!==null?e.environment.clone():null,this.fog=e.fog!==null?e.fog.clone():null,this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial!==null?e.overrideMaterial.clone():null,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},wn=new O,jn=new O,Za=new O,$n=new O,rs=new O,os=new O,Uh=new O,Ka=new O,Ja=new O,ja=new O,$a=new gt,Qa=new gt,el=new gt,Ai=class i{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),wn.subVectors(e,t),s.cross(wn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){wn.subVectors(s,t),jn.subVectors(n,t),Za.subVectors(e,t);let o=wn.dot(wn),a=wn.dot(jn),c=wn.dot(Za),l=jn.dot(jn),h=jn.dot(Za),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;let f=1/u,d=(l*c-a*h)*f,g=(o*h-a*c)*f;return r.set(1-d-g,g,d)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,$n)===null?!1:$n.x>=0&&$n.y>=0&&$n.x+$n.y<=1}static getInterpolation(e,t,n,s,r,o,a,c){return this.getBarycoord(e,t,n,s,$n)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,$n.x),c.addScaledVector(o,$n.y),c.addScaledVector(a,$n.z),c)}static getInterpolatedAttribute(e,t,n,s,r,o){return $a.setScalar(0),Qa.setScalar(0),el.setScalar(0),$a.fromBufferAttribute(e,t),Qa.fromBufferAttribute(e,n),el.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector($a,r.x),o.addScaledVector(Qa,r.y),o.addScaledVector(el,r.z),o}static isFrontFacing(e,t,n,s){return wn.subVectors(n,t),jn.subVectors(e,t),wn.cross(jn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wn.subVectors(this.c,this.b),jn.subVectors(this.a,this.b),wn.cross(jn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;rs.subVectors(s,n),os.subVectors(r,n),Ka.subVectors(e,n);let c=rs.dot(Ka),l=os.dot(Ka);if(c<=0&&l<=0)return t.copy(n);Ja.subVectors(e,s);let h=rs.dot(Ja),u=os.dot(Ja);if(h>=0&&u<=h)return t.copy(s);let f=c*u-h*l;if(f<=0&&c>=0&&h<=0&&c-h>0)return o=c/(c-h),t.copy(n).addScaledVector(rs,o);ja.subVectors(e,r);let d=rs.dot(ja),g=os.dot(ja);if(g>=0&&d<=g)return t.copy(r);let x=d*l-c*g;if(x<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(os,a);let m=h*g-d*u;if(m<=0&&u-h>=0&&d-g>=0)return Uh.subVectors(r,s),a=(u-h)/(u-h+(d-g)),t.copy(s).addScaledVector(Uh,a);let p=1/(m+x+f);return o=x*p,a=f*p,t.copy(n).addScaledVector(rs,o).addScaledVector(os,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},nn=class{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(En.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(En.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=En.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,En):En.fromBufferAttribute(r,o),En.applyMatrix4(e.matrixWorld),this.expandByPoint(En);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Wr.copy(n.boundingBox)),Wr.applyMatrix4(e.matrixWorld),this.union(Wr)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,En),En.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ws),Xr.subVectors(this.max,Ws),as.subVectors(e.a,Ws),ls.subVectors(e.b,Ws),cs.subVectors(e.c,Ws),Mi.subVectors(ls,as),Si.subVectors(cs,ls),Fi.subVectors(as,cs);let t=[0,-Mi.z,Mi.y,0,-Si.z,Si.y,0,-Fi.z,Fi.y,Mi.z,0,-Mi.x,Si.z,0,-Si.x,Fi.z,0,-Fi.x,-Mi.y,Mi.x,0,-Si.y,Si.x,0,-Fi.y,Fi.x,0];return!tl(t,as,ls,cs,Xr)||(t=[1,0,0,0,1,0,0,0,1],!tl(t,as,ls,cs,Xr))?!1:(qr.crossVectors(Mi,Si),t=[qr.x,qr.y,qr.z],tl(t,as,ls,cs,Xr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,En).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(En).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Qn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Qn=[new O,new O,new O,new O,new O,new O,new O,new O],En=new O,Wr=new nn,as=new O,ls=new O,cs=new O,Mi=new O,Si=new O,Fi=new O,Ws=new O,Xr=new O,qr=new O,Oi=new O;function tl(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Oi.fromArray(i,r);let a=s.x*Math.abs(Oi.x)+s.y*Math.abs(Oi.y)+s.z*Math.abs(Oi.z),c=e.dot(Oi),l=t.dot(Oi),h=n.dot(Oi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}var It=new O,Yr=new We,Pd=0,St=class extends Rn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Pd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Zl,this.updateRanges=[],this.gpuType=dn,this.version=0,this._normalizationScale=e!==void 0?Ca(e):void 0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Yr.fromBufferAttribute(this,t),Yr.applyMatrix3(e),this.setXY(t,Yr.x,Yr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)It.fromBufferAttribute(this,t),It.applyMatrix3(e),this.setXYZ(t,It.x,It.y,It.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)It.fromBufferAttribute(this,t),It.applyMatrix4(e),this.setXYZ(t,It.x,It.y,It.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)It.fromBufferAttribute(this,t),It.applyNormalMatrix(e),this.setXYZ(t,It.x,It.y,It.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)It.fromBufferAttribute(this,t),It.transformDirection(e),this.setXYZ(t,It.x,It.y,It.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}_denormalize(e){let t=this._normalizationScale;return t!==void 0?Math.max(e/t,-1):$l(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):Ql(e,this.array)}};var sr=class extends St{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var rr=class extends St{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var st=class extends St{constructor(e,t,n){super(new Float32Array(e),t,n)}},Ld=new nn,Xs=new O,nl=new O,sn=class{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):Ld.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Xs.subVectors(e,this.center);let t=Xs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Xs,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(nl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xs.copy(e.center).add(nl)),this.expandByPoint(Xs.copy(e.center).sub(nl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Dd=0,gn=new Ze,il=new wt,hs=new O,cn=new nn,qs=new nn,Ft=new O,_t=class i extends Rn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Dd++}),this.uuid=Wn(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(sd(e)?rr:sr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return gn.makeRotationFromQuaternion(e),this.applyMatrix4(gn),this}rotateX(e){return gn.makeRotationX(e),this.applyMatrix4(gn),this}rotateY(e){return gn.makeRotationY(e),this.applyMatrix4(gn),this}rotateZ(e){return gn.makeRotationZ(e),this.applyMatrix4(gn),this}translate(e,t,n){return gn.makeTranslation(e,t,n),this.applyMatrix4(gn),this}scale(e,t,n){return gn.makeScale(e,t,n),this.applyMatrix4(gn),this}lookAt(e){return il.lookAt(e),il.updateMatrix(),this.applyMatrix4(il.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hs).negate(),this.translate(hs.x,hs.y,hs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new st(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&ze("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new nn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];cn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ft.addVectors(this.boundingBox.min,cn.min),this.boundingBox.expandByPoint(Ft),Ft.addVectors(this.boundingBox.max,cn.max),this.boundingBox.expandByPoint(Ft)):(this.boundingBox.expandByPoint(cn.min),this.boundingBox.expandByPoint(cn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&qe('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new sn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(cn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];qs.setFromBufferAttribute(a),this.morphTargetsRelative?(Ft.addVectors(cn.min,qs.min),cn.expandByPoint(Ft),Ft.addVectors(cn.max,qs.max),cn.expandByPoint(Ft)):(cn.expandByPoint(qs.min),cn.expandByPoint(qs.max))}cn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Ft.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Ft));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)Ft.fromBufferAttribute(a,l),c&&(hs.fromBufferAttribute(e,l),Ft.add(hs)),s=Math.max(s,n.distanceToSquared(Ft))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&qe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,o=this.getAttribute("tangent");(o===void 0||o.count!==n.count)&&(o=new St(new Float32Array(4*n.count),4),this.setAttribute("tangent",o));let a=[],c=[],l=new Uint8Array(n.count);for(let F=0;F<n.count;F++)a[F]=new O,c[F]=new O;let h=new O,u=new O,f=new O,d=new We,g=new We,x=new We,m=new O,p=new O;function M(F,P,L){l[F]=l[P]=l[L]=1,h.fromBufferAttribute(n,F),u.fromBufferAttribute(n,P),f.fromBufferAttribute(n,L),d.fromBufferAttribute(r,F),g.fromBufferAttribute(r,P),x.fromBufferAttribute(r,L),u.sub(h),f.sub(h),g.sub(d),x.sub(d);let B=1/(g.x*x.y-x.x*g.y);isFinite(B)&&(m.copy(u).multiplyScalar(x.y).addScaledVector(f,-g.y).multiplyScalar(B),p.copy(f).multiplyScalar(g.x).addScaledVector(u,-x.x).multiplyScalar(B),a[F].add(m),a[P].add(m),a[L].add(m),c[F].add(p),c[P].add(p),c[L].add(p))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let F=0,P=A.length;F<P;++F){let L=A[F],B=L.start,K=L.count;for(let C=B,q=B+K;C<q;C+=3)M(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let S=new O,E=new O,T=new O,_=new O;function b(F){T.fromBufferAttribute(s,F),_.copy(T);let P=a[F];S.copy(P),S.sub(T.multiplyScalar(T.dot(P))).normalize(),E.crossVectors(_,P);let B=E.dot(c[F])<0?-1:1;o.setXYZW(F,S.x,S.y,S.z,B)}for(let F=0,P=n.count;F<P;++F)l[F]&&b(F);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new St(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);let s=new O,r=new O,o=new O,a=new O,c=new O,l=new O,h=new O,u=new O;if(e)for(let f=0,d=e.count;f<d;f+=3){let g=e.getX(f+0),x=e.getX(f+1),m=e.getX(f+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),a.add(h),c.add(h),l.add(h),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,d=t.count;f<d;f+=3)s.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ft.fromBufferAttribute(e,t),Ft.normalize(),e.setXYZ(t,Ft.x,Ft.y,Ft.z)}toNonIndexed(){function e(a,c){let l=a.array,h=a.itemSize,u=a.normalized,f=new l.constructor(c.length*h),d=0,g=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?d=c[x]*a.data.stride+a.offset:d=c[x]*h;for(let p=0;p<h;p++)f[g++]=l[d++]}return new St(f,h,u)}if(this.index===null)return ze("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let a in s){let c=s[a],l=e(c,n);t.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){let f=l[h],d=e(f,n);c.push(d)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,f=l.length;u<f;u++){let d=l[u];h.push(d.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],u=r[l];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,h=o.length;l<h;l++){let u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ss=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Zl,this.updateRanges=[],this.version=0,this.uuid=Wn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Fh(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),s=new this.constructor(n,this.stride);return s.setUsage(this.usage),s}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Fh(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}};function Fh(i){return i.buffer._uuid===void 0&&(i.buffer._uuid=Wn()),i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer._uuid:i.buffer._uuid+":"+i.byteOffset+":"+i.byteLength}var Jt=new O,bs=class i{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s,this._normalizationScale=e!==void 0?Ca(e.array):void 0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix4(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Jt.fromBufferAttribute(this,t),Jt.applyNormalMatrix(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Jt.fromBufferAttribute(this,t),Jt.transformDirection(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){tr("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new St(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){tr("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t!==void 0?Math.max(e/t,-1):$l(e,this.data.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):Ql(e,this.data.array)}},sl=new O,Nd=new O,Ud=new Ke,hn=class{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=sl.subVectors(n,t).cross(Nd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let s=e.delta(sl),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let o=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Ud.getNormalMatrix(e),s=this.coplanarPoint(sl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Fd=0,Gt=class extends Rn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Fd++}),this.uuid=Wn(),this.name="",this.type="Material",this.blending=Ls,this.side=Vn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Rl,this.blendDst=Cl,this.blendEquation=Ki,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Be(0,0,0),this.blendAlpha=0,this.depthFunc=gs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Fu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=po,this.stencilZFail=po,this.stencilZPass=po,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){ze(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){ze(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Be().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new hn().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new We().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new We().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var ei=new O,rl=new O,Zr=new O,Kr=new O,ri=class{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ei)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ei.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ei.copy(this.origin).addScaledVector(this.direction,t),ei.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){rl.copy(e).add(t).multiplyScalar(.5),Zr.copy(t).sub(e).normalize(),Kr.copy(this.origin).sub(rl);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Zr),a=Kr.dot(this.direction),c=-Kr.dot(Zr),l=Kr.lengthSq(),h=Math.abs(1-o*o),u,f,d,g;if(h>0)if(u=o*c-a,f=o*a-c,g=r*h,u>=0)if(f>=-g)if(f<=g){let x=1/h;u*=x,f*=x,d=u*(u+o*f+2*a)+f*(o*u+f+2*c)+l}else f=r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;else f=-r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;else f<=-g?(u=Math.max(0,-(-o*r+a)),f=u>0?-r:Math.min(Math.max(-r,-c),r),d=-u*u+f*(f+2*c)+l):f<=g?(u=0,f=Math.min(Math.max(-r,-c),r),d=f*(f+2*c)+l):(u=Math.max(0,-(o*r+a)),f=u>0?r:Math.min(Math.max(-r,-c),r),d=-u*u+f*(f+2*c)+l);else f=o>0?-r:r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(rl).addScaledVector(Zr,f),d}intersectSphere(e,t){if(e.radius<0)return null;ei.subVectors(e.center,this.origin);let n=ei.dot(this.direction),s=ei.dot(ei)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,s=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,s=(e.min.x-f.x)*l),h>=0?(r=(e.min.y-f.y)*h,o=(e.max.y-f.y)*h):(r=(e.max.y-f.y)*h,o=(e.min.y-f.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-f.z)*u,c=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,c=(e.min.z-f.z)*u),n>c||a>s)||((a>n||n!==n)&&(n=a),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,ei)!==null}intersectTriangle(e,t,n,s,r){let o=this.origin,a=this.direction,c=a.x,l=a.y,h=a.z,u=e.x-o.x,f=e.y-o.y,d=e.z-o.z,g=t.x-o.x,x=t.y-o.y,m=t.z-o.z,p=n.x-o.x,M=n.y-o.y,A=n.z-o.z,S=Math.abs(c),E=Math.abs(l),T=Math.abs(h),_,b,F,P,L,B,K,C,q,X,W,ae;if(S>=E&&S>=T?(F=c,B=u,q=g,ae=p,c>=0?(_=l,b=h,P=f,L=d,K=x,C=m,X=M,W=A):(_=h,b=l,P=d,L=f,K=m,C=x,X=A,W=M)):E>=T?(F=l,B=f,q=x,ae=M,l>=0?(_=h,b=c,P=d,L=u,K=m,C=g,X=A,W=p):(_=c,b=h,P=u,L=d,K=g,C=m,X=p,W=A)):(F=h,B=d,q=m,ae=A,h>=0?(_=c,b=l,P=u,L=f,K=g,C=x,X=p,W=M):(_=l,b=c,P=f,L=u,K=x,C=g,X=M,W=p)),F===0)return null;let Y=_/F,oe=b/F,le=1/F,Ie=P-Y*B,He=L-oe*B,ee=K-Y*q,ye=C-oe*q,Ce=X-Y*ae,ke=W-oe*ae,I=Ce*ye-ke*ee,D=Ie*ke-He*Ce,j=ee*He-ye*Ie;if(s){if(I<0||D<0||j<0)return null}else if((I<0||D<0||j<0)&&(I>0||D>0||j>0))return null;let k=I+D+j;if(k===0)return null;let J=le*(I*B+D*q+j*ae);return(k>0?J<0:J>0)?null:this.at(J/k,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},On=class extends Gt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Be(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 Fn,this.combine=Vo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Oh=new Ze,Bi=new ri,Jr=new sn,Bh=new O,jr=new O,$r=new O,Qr=new O,ol=new O,eo=new O,zh=new O,to=new O,bt=class extends wt{constructor(e=new _t,t=new On){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){eo.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=a[c],u=r[c];h!==0&&(ol.fromBufferAttribute(u,e),o?eo.addScaledVector(ol,h):eo.addScaledVector(ol.sub(t),h))}t.add(eo)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Jr.copy(n.boundingSphere),Jr.applyMatrix4(r),Bi.copy(e.ray).recast(e.near),!(Jr.containsPoint(Bi.origin)===!1&&(Bi.intersectSphere(Jr,Bh)===null||Bi.origin.distanceToSquared(Bh)>(e.far-e.near)**2))&&(Oh.copy(r).invert(),Bi.copy(e.ray).applyMatrix4(Oh),!(n.boundingBox!==null&&Bi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Bi)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,f=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,x=f.length;g<x;g++){let m=f[g],p=o[m.materialIndex],M=Math.max(m.start,d.start),A=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let S=M,E=A;S<E;S+=3){let T=a.getX(S),_=a.getX(S+1),b=a.getX(S+2);s=no(this,p,e,n,l,h,u,T,_,b),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,d.start),x=Math.min(a.count,d.start+d.count);for(let m=g,p=x;m<p;m+=3){let M=a.getX(m),A=a.getX(m+1),S=a.getX(m+2);s=no(this,o,e,n,l,h,u,M,A,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,x=f.length;g<x;g++){let m=f[g],p=o[m.materialIndex],M=Math.max(m.start,d.start),A=Math.min(c.count,Math.min(m.start+m.count,d.start+d.count));for(let S=M,E=A;S<E;S+=3){let T=S,_=S+1,b=S+2;s=no(this,p,e,n,l,h,u,T,_,b),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,d.start),x=Math.min(c.count,d.start+d.count);for(let m=g,p=x;m<p;m+=3){let M=m,A=m+1,S=m+2;s=no(this,o,e,n,l,h,u,M,A,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Od(i,e,t,n,s,r,o,a){let c;if(e.side===en?c=n.intersectTriangle(o,r,s,!0,a):c=n.intersectTriangle(s,r,o,e.side===Vn,a),c===null)return null;to.copy(a),to.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(to);return l<t.near||l>t.far?null:{distance:l,point:to.clone(),object:i}}function no(i,e,t,n,s,r,o,a,c,l){i.getVertexPosition(a,jr),i.getVertexPosition(c,$r),i.getVertexPosition(l,Qr);let h=Od(i,e,t,n,jr,$r,Qr,zh);if(h){let u=new O;Ai.getBarycoord(zh,jr,$r,Qr,u),s&&(h.uv=Ai.getInterpolatedAttribute(s,a,c,l,u,new We)),r&&(h.uv1=Ai.getInterpolatedAttribute(r,a,c,l,u,new We)),o&&(h.normal=Ai.getInterpolatedAttribute(o,a,c,l,u,new O),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let f={a,b:c,c:l,normal:new O,materialIndex:0};Ai.getNormal(jr,$r,Qr,f.normal),h.face=f,h.barycoord=u}return h}var Ys=new gt,kh=new gt,Gh=new gt,Bd=new gt,Vh=new Ze,io=new O,al=new sn,Hh=new Ze,ll=new ri,or=class extends bt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=fl,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new nn),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,io),this.boundingBox.expandByPoint(io)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new sn),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,io),this.boundingSphere.expandByPoint(io)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this}raycast(e,t){let n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),al.copy(this.boundingSphere),al.applyMatrix4(s),e.ray.intersectsSphere(al)!==!1&&(Hh.copy(s).invert(),ll.copy(e.ray).applyMatrix4(Hh),!(this.boundingBox!==null&&ll.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ll)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new gt,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===fl?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Lu?this.bindMatrixInverse.copy(this.bindMatrix).invert():ze("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,s=this.geometry;kh.fromBufferAttribute(s.attributes.skinIndex,e),Gh.fromBufferAttribute(s.attributes.skinWeight,e),t.isVector4?(Ys.copy(t),t.set(0,0,0,0)):(Ys.set(t.x,t.y,t.z,1),t.set(0,0,0)),Ys.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let o=Gh.getComponent(r);if(o!==0){let a=kh.getComponent(r);Vh.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(Bd.copy(Ys).applyMatrix4(Vh),o)}}return t.isVector4&&(t.w=Ys.w),t.applyMatrix4(this.bindMatrixInverse)}},Ts=class extends wt{constructor(){super(),this.isBone=!0,this.type="Bone"}},As=class extends kt{constructor(e=null,t=1,n=1,s,r,o,a,c,l=Tt,h=Tt,u,f){super(null,o,a,c,l,h,s,r,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Wh=new Ze,zd=new Ze,ar=class i{constructor(e=[],t=[]){this.uuid=Wn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.previousBoneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){ze("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ze;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,o=e.length;r<o;r++){let a=e[r]?e[r].matrixWorld:zd;Wh.multiplyMatrices(a,t[r]),Wh.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new i(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new As(t,e,e,yn,dn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null),this.previousBoneTexture!==null&&(this.previousBoneTexture.dispose(),this.previousBoneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){let r=e.bones[n],o=t[r];o===void 0&&(ze("Skeleton: No bone found with UUID:",r),o=new Ts),this.bones.push(o),this.boneInverses.push(new Ze().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){let o=t[s];e.bones.push(o.uuid);let a=n[s];e.boneInverses.push(a.toArray())}return e}},oi=class extends St{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},us=new Ze,Xh=new Ze,so=[],qh=new nn,kd=new Ze,Zs=new bt,Ks=new sn,lr=class extends bt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new oi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,kd)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new nn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,us),qh.copy(e.boundingBox).applyMatrix4(us),this.boundingBox.union(qh)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new sn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,us),Ks.copy(e.boundingSphere).applyMatrix4(us),this.boundingSphere.union(Ks)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),this.morphTexture=e.morphTexture!==null?e.morphTexture.clone():null,this.instanceColor=e.instanceColor!==null?e.instanceColor.clone():null,this.count=e.count,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=s[o+a]}raycast(e,t){let n=this.matrixWorld,s=this.count;if(Zs.geometry=this.geometry,Zs.material=this.material,Zs.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ks.copy(this.boundingSphere),Ks.applyMatrix4(n),e.ray.intersectsSphere(Ks)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,us),Xh.multiplyMatrices(n,us),Zs.matrixWorld=Xh,Zs.raycast(e,so);for(let o=0,a=so.length;o<a;o++){let c=so[o];c.instanceId=r,c.object=this,t.push(c)}so.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new oi(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new As(new Float32Array(s*this.count),s,this.count,Ko,dn));let r=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=s*e;return r[c]=a,r.set(n,c+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.instanceMatrix.dispose(),this.instanceColor!==null&&this.instanceColor.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},zi=new sn,Gd=new We(.5,.5),ro=new O,wi=class{constructor(e=new hn,t=new hn,n=new hn,s=new hn,r=new hn,o=new hn){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=_n,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],h=r[4],u=r[5],f=r[6],d=r[7],g=r[8],x=r[9],m=r[10],p=r[11],M=r[12],A=r[13],S=r[14],E=r[15];if(s[0].setComponents(l-o,d-h,p-g,E-M).normalize(),s[1].setComponents(l+o,d+h,p+g,E+M).normalize(),s[2].setComponents(l+a,d+u,p+x,E+A).normalize(),s[3].setComponents(l-a,d-u,p-x,E-A).normalize(),n)s[4].setComponents(c,f,m,S).normalize(),s[5].setComponents(l-c,d-f,p-m,E-S).normalize();else if(s[4].setComponents(l-c,d-f,p-m,E-S).normalize(),t===_n)s[5].setComponents(l+c,d+f,p+m,E+S).normalize();else if(t===_s)s[5].setComponents(c,f,m,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),zi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zi)}intersectsSprite(e){zi.center.set(0,0,0);let t=Gd.distanceTo(e.center);return zi.radius=.7071067811865476+t,zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(zi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(ro.x=s.normal.x>0?e.max.x:e.min.x,ro.y=s.normal.y>0?e.max.y:e.min.y,ro.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ro)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Yh=new Ze,wo=class i{constructor(){this.coordinateSystem=_n,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let s=0;s<t.length;s++){let r=t[s];Yh.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new wi),n[s].setFromProjectionMatrix(Yh,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let s=0;s<e._count;s++)t[s]===void 0&&(t[s]=new wi),t[s].copy(n[s]);return this._count=e._count,this}clone(){return new i().copy(this)}};var Bn=class extends Gt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Be(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Eo=new O,Ro=new O,Zh=new Ze,Js=new ri,oo=new sn,cl=new O,Kh=new O,Wi=class extends wt{constructor(e=new _t,t=new Bn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Eo.fromBufferAttribute(t,s-1),Ro.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Eo.distanceTo(Ro);e.setAttribute("lineDistance",new st(n,1))}else ze("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),oo.copy(n.boundingSphere),oo.applyMatrix4(s),oo.radius+=r,e.ray.intersectsSphere(oo)===!1)return;Zh.copy(s).invert(),Js.copy(e.ray).applyMatrix4(Zh);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){let d=Math.max(0,o.start),g=Math.min(h.count,o.start+o.count);for(let x=d,m=g-1;x<m;x+=l){let p=h.getX(x),M=h.getX(x+1),A=ao(this,e,Js,c,p,M,x);A&&t.push(A)}if(this.isLineLoop){let x=h.getX(g-1),m=h.getX(d),p=ao(this,e,Js,c,x,m,g-1);p&&t.push(p)}}else{let d=Math.max(0,o.start),g=Math.min(f.count,o.start+o.count);for(let x=d,m=g-1;x<m;x+=l){let p=ao(this,e,Js,c,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){let x=ao(this,e,Js,c,g-1,d,g-1);x&&t.push(x)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function ao(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(Eo.fromBufferAttribute(a,s),Ro.fromBufferAttribute(a,r),t.distanceSqToSegment(Eo,Ro,cl,Kh)>n)return;cl.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(cl);if(!(l<e.near||l>e.far))return{distance:l,point:Kh.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Jh=new O,jh=new O,Ei=class extends Wi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Jh.fromBufferAttribute(t,s),jh.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Jh.distanceTo(jh);e.setAttribute("lineDistance",new st(n,1))}else ze("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},cr=class extends Wi{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Cn=class extends Gt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Be(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},$h=new Ze,_l=new ri,lo=new sn,co=new O,ai=class extends wt{constructor(e=new _t,t=new Cn){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),lo.copy(n.boundingSphere),lo.applyMatrix4(s),lo.radius+=r,e.ray.intersectsSphere(lo)===!1)return;$h.copy(s).invert(),_l.copy(e.ray).applyMatrix4($h);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,u=n.attributes.position;if(l!==null){let f=Math.max(0,o.start),d=Math.min(l.count,o.start+o.count);for(let g=f,x=d;g<x;g++){let m=l.getX(g);co.fromBufferAttribute(u,m),Qh(co,m,c,s,e,t,this)}}else{let f=Math.max(0,o.start),d=Math.min(u.count,o.start+o.count);for(let g=f,x=d;g<x;g++)co.fromBufferAttribute(u,g),Qh(co,g,c,s,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Qh(i,e,t,n,s,r,o){let a=_l.distanceSqToPoint(i);if(a<t){let c=new O;_l.closestPointToPoint(i,c),c.applyMatrix4(n);let l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var hr=class extends kt{constructor(e=[],t=Ji,n,s,r,o,a,c,l,h){super(e,t,n,s,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var li=class extends kt{constructor(e,t,n=Pn,s,r,o,a=Tt,c=Tt,l,h=si,u=1){if(h!==si&&h!==pi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,s,r,o,a,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ys(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},ur=class extends li{constructor(e,t=Pn,n=Ji,s,r,o=Tt,a=Tt,c,l=si){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},fr=class extends kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ws=class i extends _t{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],h=[],u=[],f=0,d=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new st(l,3)),this.setAttribute("normal",new st(h,3)),this.setAttribute("uv",new st(u,2));function g(x,m,p,M,A,S,E,T,_,b,F){let P=S/_,L=E/b,B=S/2,K=E/2,C=T/2,q=_+1,X=b+1,W=0,ae=0,Y=new O;for(let oe=0;oe<X;oe++){let le=oe*L-K;for(let Ie=0;Ie<q;Ie++){let He=Ie*P-B;Y[x]=He*M,Y[m]=le*A,Y[p]=C,l.push(Y.x,Y.y,Y.z),Y[x]=0,Y[m]=0,Y[p]=T>0?1:-1,h.push(Y.x,Y.y,Y.z),u.push(Ie/_),u.push(1-oe/b),W+=1}}for(let oe=0;oe<b;oe++)for(let le=0;le<_;le++){let Ie=f+le+q*oe,He=f+le+q*(oe+1),ee=f+(le+1)+q*(oe+1),ye=f+(le+1)+q*oe;c.push(Ie,He,ye),c.push(He,ee,ye),ae+=6}a.addGroup(d,ae,F),d+=ae,f+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var dr=class i extends _t{constructor(e=1,t=1,n=1,s=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};let l=this;s=Math.floor(s),r=Math.floor(r);let h=[],u=[],f=[],d=[],g=0,x=[],m=n/2,p=0;M(),o===!1&&(e>0&&A(!0),t>0&&A(!1)),this.setIndex(h),this.setAttribute("position",new st(u,3)),this.setAttribute("normal",new st(f,3)),this.setAttribute("uv",new st(d,2));function M(){let S=new O,E=new O,T=0,_=(t-e)/n;for(let b=0;b<=r;b++){let F=[],P=b/r,L=P*(t-e)+e;for(let B=0;B<=s;B++){let K=B/s,C=K*c+a,q=Math.sin(C),X=Math.cos(C);E.x=L*q,E.y=-P*n+m,E.z=L*X,u.push(E.x,E.y,E.z),S.set(q,_,X).normalize(),f.push(S.x,S.y,S.z),d.push(K,1-P),F.push(g++)}x.push(F)}for(let b=0;b<s;b++)for(let F=0;F<r;F++){let P=x[F][b],L=x[F+1][b],B=x[F+1][b+1],K=x[F][b+1];(e>0||F!==0)&&(h.push(P,L,K),T+=3),(t>0||F!==r-1)&&(h.push(L,B,K),T+=3)}l.addGroup(p,T,0),p+=T}function A(S){let E=g,T=new We,_=new O,b=0,F=S===!0?e:t,P=S===!0?1:-1;for(let B=1;B<=s;B++)u.push(0,m*P,0),f.push(0,P,0),d.push(.5,.5),g++;let L=g;for(let B=0;B<=s;B++){let C=B/s*c+a,q=Math.cos(C),X=Math.sin(C);_.x=F*X,_.y=m*P,_.z=F*q,u.push(_.x,_.y,_.z),f.push(0,P,0),T.x=q*.5+.5,T.y=X*.5*P+.5,d.push(T.x,T.y),g++}for(let B=0;B<s;B++){let K=E+B,C=L+B;S===!0?h.push(C,C+1,K):h.push(C+1,C,K),b+=3}l.addGroup(p,b,S===!0?1:2),p+=b}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var pr=class i extends _t{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(s),l=a+1,h=c+1,u=e/a,f=t/c,d=[],g=[],x=[],m=[];for(let p=0;p<h;p++){let M=p*f-o;for(let A=0;A<l;A++){let S=A*u-r;g.push(S,-M,0),x.push(0,0,1),m.push(A/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let M=0;M<a;M++){let A=M+l*p,S=M+l*(p+1),E=M+1+l*(p+1),T=M+1+l*p;d.push(A,S,T),d.push(S,E,T)}this.setIndex(d),this.setAttribute("position",new st(g,3)),this.setAttribute("normal",new st(x,3)),this.setAttribute("uv",new st(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};var mr=class i extends _t{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let c=Math.min(o+a,Math.PI),l=0,h=[],u=new O,f=new O,d=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){let M=[],A=p/n,S=o+A*a,E=e*Math.cos(S),T=Math.sqrt(e*e-E*E),_=0;p===0&&o===0?_=.5/t:p===n&&c===Math.PI&&(_=-.5/t);for(let b=0;b<=t;b++){let F=b/t,P=s+F*r;u.x=-T*Math.cos(P),u.y=E,u.z=T*Math.sin(P),g.push(u.x,u.y,u.z),f.copy(u).normalize(),x.push(f.x,f.y,f.z),m.push(F+_,1-A),M.push(l++)}h.push(M)}for(let p=0;p<n;p++)for(let M=0;M<t;M++){let A=h[p][M+1],S=h[p][M],E=h[p+1][M],T=h[p+1][M+1];(p!==0||o>0)&&d.push(A,S,T),(p!==n-1||c<Math.PI)&&d.push(S,E,T)}this.setIndex(d),this.setAttribute("position",new st(g,3)),this.setAttribute("normal",new st(x,3)),this.setAttribute("uv",new st(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};function Qi(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(eu(s))s.isRenderTargetTexture?(ze("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(eu(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Zt(i){let e={};for(let t=0;t<i.length;t++){let n=Qi(i[t]);for(let s in n)e[s]=n[s]}return e}function eu(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Vd(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function ec(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:tt.workingColorSpace}var Yu={clone:Qi,merge:Zt},Hd=`void main() { | ||
| 5 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); | ||
| 6 | }`,Wd=`void main() { | ||
| 7 | gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); | ||
| 8 | }`,zn=class extends Gt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hd,this.fragmentShader=Wd,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Qi(e.uniforms),this.uniformsGroups=Vd(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Be().setHex(s.value);break;case"v2":this.uniforms[n].value=new We().fromArray(s.value);break;case"v3":this.uniforms[n].value=new O().fromArray(s.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ke().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Ze().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Co=class extends zn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},kn=class extends Gt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Be(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 Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pr,this.normalScale=new We(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 Fn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Qt=class extends kn{constructor(e){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 We(1,1),this.clearcoatNormalMap=null,this.diffuseRoughnessMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nt(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.iridescenceThicknessMinimum=100,this.iridescenceThicknessMaximum=400,this.iridescenceThicknessMap=null,this.sheenColor=new Be(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 Be(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Be(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._diffuseRoughness=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get diffuseRoughness(){return this._diffuseRoughness}set diffuseRoughness(e){this._diffuseRoughness>0!=e>0&&this.version++,this._diffuseRoughness=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}get iridescenceThicknessRange(){return ki('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),[this.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum]}set iridescenceThicknessRange(e){ki('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),this.iridescenceThicknessMinimum=e[0],this.iridescenceThicknessMaximum=e[1]}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.diffuseRoughness=e.diffuseRoughness,this.diffuseRoughnessMap=e.diffuseRoughnessMap,this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},In=class extends Gt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Be(16777215),this.specular=new Be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pr,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fn,this.combine=Vo,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var Io=class extends Gt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Nu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Po=class extends Gt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Ti(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function js(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function Xd(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function tu(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let c=0;c!==e;++c)s[o++]=i[a+c]}return s}function qd(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push(...o)),r=i[s++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=i[s++];while(r!==void 0)}var Gn=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Lo=class extends Gn{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:pl,endingEnd:pl}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],c=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case ml:r=e,a=2*t-n;break;case gl:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case ml:o=e,c=2*n-t;break;case gl:o=1,c=n+s[1]-s[0];break;default:o=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,g=(n-t)/(s-t),x=g*g,m=x*g,p=-f*m+2*f*x-f*g,M=(1+f)*m+(-1.5-2*f)*x+(-.5+f)*g+1,A=(-1-d)*m+(1.5+d)*x+.5*g,S=d*m-d*x;for(let E=0;E!==a;++E)r[E]=p*o[h+E]+M*o[l+E]+A*o[c+E]+S*o[u+E];return r}},Do=class extends Gn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(s-t),u=1-h;for(let f=0;f!==a;++f)r[f]=o[l+f]*u+o[c+f]*h;return r}},No=class extends Gn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},Uo=class extends Gn{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this.inTangents,u=this.outTangents;if(!h||!u){let g=(n-t)/(s-t),x=1-g;for(let m=0;m!==a;++m)r[m]=o[l+m]*x+o[c+m]*g;return r}let f=a*2,d=e-1;for(let g=0;g!==a;++g){let x=o[l+g],m=o[c+g],p=d*f+g*2,M=u[p],A=u[p+1],S=e*f+g*2,E=h[S],T=h[S+1],_=Zd(n,t,M,E,s);r[g]=Zu(_,x,A,T,m)}return r}};function Zu(i,e,t,n,s){let r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Yd(i,e,t,n,s){let r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function Zd(i,e,t,n,s){let r=(i-e)/(s-e);for(let o=0;o<8;o++){let a=Zu(r,e,t,n,s)-i;if(Math.abs(a)<1e-10)break;let c=Yd(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-a/c))}return r}var rn=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ti(t,this.TimeBufferType),this.values=Ti(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ti(e.times,Array),values:Ti(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),js(e.settings)&&(n.settings={inTangents:Ti(e.settings.inTangents,Array),outTangents:Ti(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new No(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Do(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Lo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Uo(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Gi:t=this.InterpolantFactoryMethodDiscrete;break;case Vi:t=this.InterpolantFactoryMethodLinear;break;case fo:t=this.InterpolantFactoryMethodSmooth;break;case dl:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return ze("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Gi;case this.InterpolantFactoryMethodLinear:return Vi;case this.InterpolantFactoryMethodSmooth:return fo;case this.InterpolantFactoryMethodBezier:return dl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e;js(this.settings)&&(nu(this.settings.inTangents,e),nu(this.settings.outTangents,e))}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e;js(this.settings)&&(iu(this.settings.inTangents,e),iu(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(qe("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(qe("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){qe("KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){qe("KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(s!==void 0&&rd(s))for(let a=0,c=s.length;a!==c;++a){let l=s[a];if(isNaN(l)){qe("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===fo,r=e.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(s)c=!0;else{let u=a*n,f=u-n,d=u+n;for(let g=0;g!==n;++g){let x=t[u+g];if(x!==t[f+g]||x!==t[d+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let u=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,js(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function nu(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function iu(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}rn.prototype.ValueTypeName="";rn.prototype.TimeBufferType=Float32Array;rn.prototype.ValueBufferType=Float32Array;rn.prototype.DefaultInterpolation=Vi;var ci=class extends rn{constructor(e,t,n){super(e,t,n)}};ci.prototype.ValueTypeName="bool";ci.prototype.ValueBufferType=Array;ci.prototype.DefaultInterpolation=Gi;ci.prototype.InterpolantFactoryMethodLinear=void 0;ci.prototype.InterpolantFactoryMethodSmooth=void 0;var gr=class extends rn{constructor(e,t,n,s){super(e,t,n,s)}};gr.prototype.ValueTypeName="color";var hi=class extends rn{constructor(e,t,n,s){super(e,t,n,s)}};hi.prototype.ValueTypeName="number";var Fo=class extends Gn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(s-t),l=e*a;for(let h=l+a;l!==h;l+=4)zt.slerpFlat(r,0,o,l-a,o,l,c);return r}},ui=class extends rn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Fo(this.times,this.values,this.getValueSize(),e)}};ui.prototype.ValueTypeName="quaternion";ui.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends rn{constructor(e,t,n){super(e,t,n)}};fi.prototype.ValueTypeName="string";fi.prototype.ValueBufferType=Array;fi.prototype.DefaultInterpolation=Gi;fi.prototype.InterpolantFactoryMethodLinear=void 0;fi.prototype.InterpolantFactoryMethodSmooth=void 0;var Ri=class extends rn{constructor(e,t,n,s){super(e,t,n,s)}};Ri.prototype.ValueTypeName="vector";var _r=class{constructor(e="",t=-1,n=[],s=Du){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Wn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(Jd(n[o]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,o=n.length;r!==o;++r)t.push(rn.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);let h=Xd(c);c=tu(c,1,h),l=tu(l,1,h),!s&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new hi(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let s={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],h=l.name.match(r);if(h&&h.length>1){let u=h[1],f=s[u];f||(s[u]=f=[]),f.push(l)}}let o=[];for(let a in s)o.push(this.CreateFromMorphTargetSequence(a,s[a],t,n));return o}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};function Kd(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return hi;case"vector":case"vector2":case"vector3":case"vector4":return Ri;case"color":return gr;case"quaternion":return ui;case"bool":case"boolean":return ci;case"string":return fi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Jd(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=Kd(i.type);if(i.times===void 0){let n=[],s=[];qd(i.keys,n,s,"value"),i.times=n,i.values=s}let t;return e.parse!==void 0?t=e.parse(i):t=new e(i.name,i.times,i.values,i.interpolation),js(i.settings)&&(t.settings={inTangents:Ti(i.settings.inTangents,Float32Array),outTangents:Ti(i.settings.outTangents,Float32Array)}),t}var Un={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(su(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!su(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function su(i){try{let e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}var Oo=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=l.length;u<f;u+=2){let d=l[u],g=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Ku=new Oo,Vt=class{constructor(e){this.manager=e!==void 0?e:Ku,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},this.priority="auto",this.cache="default",typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}setPriority(e){return this.priority=e,this}setCache(e){return this.cache=e,this}abort(){return this}};Vt.DEFAULT_MATERIAL_NAME="__DEFAULT";var ti={},xl=class extends Error{constructor(e,t){super(e),this.response=t}},xn=class extends Vt{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=Un.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(ti[e]!==void 0){ti[e].push({onLoad:t,onProgress:n,onError:s});return}ti[e]=[],ti[e].push({onLoad:t,onProgress:n,onError:s});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",priority:this.priority,cache:this.cache,signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&ze("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=ti[e],u=l.body.getReader(),f=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),d=f?parseInt(f):0,g=d!==0,x=0,m=new ReadableStream({start(p){M();function M(){u.read().then(({done:A,value:S})=>{if(A)p.close();else{x+=S.byteLength;let E=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:d});for(let T=0,_=h.length;T<_;T++){let b=h[T];b.onProgress&&b.onProgress(E)}p.enqueue(S),M()}},A=>{p.error(A)})}}});return new Response(m)}else throw new xl(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a==="")return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(g=>d.decode(g))}}}).then(l=>{Un.add(`file:${e}`,l);let h=ti[e];delete ti[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=ti[e];if(h===void 0)throw this.manager.itemError(e),l;delete ti[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var fs=new WeakMap,Bo=class extends Vt{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Un.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);else{let u=fs.get(o);u===void 0&&(u=[],fs.set(o,u)),u.push({onLoad:t,onError:s})}return o}let a=xs("img");function c(){h(),t&&t(this);let u=fs.get(this)||[];for(let f=0;f<u.length;f++){let d=u[f];d.onLoad&&d.onLoad(this)}fs.delete(this),r.manager.itemEnd(e)}function l(u){h(),s&&s(u),Un.remove(`image:${e}`);let f=fs.get(this)||[];for(let d=0;d<f.length;d++){let g=f[d];g.onError&&g.onError(u)}fs.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Un.add(`image:${e}`,a),r.manager.itemStart(e),a.fetchPriority=this.priority,a.src=e,a}};var Xi=class extends Vt{constructor(e){super(e)}load(e,t,n,s){let r=new kt,o=new Bo(this.manager);return o.setPriority(this.priority),o.setCache(this.cache),o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}},qi=class extends wt{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Be(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},zo=class extends qi{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Be(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},hl=new Ze,ru=new O,ou=new O,Es=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new We(512,512),this.mapType=on,this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wi,this._frameExtents=new We(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ru.setFromMatrixPosition(e.matrixWorld),t.position.copy(ru),ou.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ou),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){hl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(hl,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,o=s?s.z/r.x:1,a=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===_s||e.reversedDepth?t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,1,0,0,0,0,1):t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,.5,.5,0,0,0,1),t.multiply(hl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.mapType=e.mapType,this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.mapType=this.mapType,e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},ho=new O,uo=new zt,Nn=new O,xr=class extends wt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=_n,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ho,uo,Nn),Nn.x===1&&Nn.y===1&&Nn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ho,uo,Nn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ho,uo,Nn),Nn.x===1&&Nn.y===1&&Nn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ho,uo,Nn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},bi=new O,au=new We,lu=new We,Ot=class extends xr{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Hi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan($s*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hi*2*Math.atan(Math.tan($s*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){bi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(bi.x,bi.y).multiplyScalar(-e/bi.z),bi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bi.x,bi.y).multiplyScalar(-e/bi.z)}getViewSize(e,t){return this.getViewBounds(e,au,lu),t.subVectors(lu,au)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan($s*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*s/c,t-=o.offsetY*n/l,s*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},vl=class extends Es{constructor(){super(new Ot(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Hi*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}},vr=class extends qi{constructor(e,t,n=0,s=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.target=new wt,this.distance=n,this.angle=s,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new vl}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},yl=class extends Es{constructor(){super(new Ot(90,1,.5,500)),this.isPointLightShadow=!0}},yr=class extends qi{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new yl}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},Yi=class extends xr{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,c=s-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ml=class extends Es{constructor(){super(new Yi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Rs=class extends qi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.target=new wt,this.shadow=new Ml}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var di=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}};var ul=new WeakMap,Mr=class extends Vt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&ze("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ze("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Un.get(`image-bitmap:${e}`);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{ul.has(o)===!0?(s&&s(ul.get(o)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.withCredentials||this.crossOrigin!=="anonymous"?"include":"same-origin",a.headers=this.requestHeader,a.priority=this.priority,a.cache=this.cache,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Un.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){s&&s(l),ul.set(c,l),Un.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Un.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var ds=-90,ps=1,Cs=class extends wt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Ot(ds,ps,e,t);s.layers=this.layers,this.add(s);let r=new Ot(ds,ps,e,t);r.layers=this.layers,this.add(r);let o=new Ot(ds,ps,e,t);o.layers=this.layers,this.add(o);let a=new Ot(ds,ps,e,t);a.layers=this.layers,this.add(a);let c=new Ot(ds,ps,e,t);c.layers=this.layers,this.add(c);let l=new Ot(ds,ps,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,c]=t;for(let l of t)this.remove(l);if(e===_n)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===_s)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,c,l,h]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.mipmapsAutoUpdate=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,f,d),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},ko=class extends Ot{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var tc="\\[\\]\\.:\\/",jd=new RegExp("["+tc+"]","g"),nc="[^"+tc+"]",$d="[^"+tc.replace("\\.","")+"]",Qd=/((?:WC+[\/:])*)/.source.replace("WC",nc),ep=/(WCOD+)?/.source.replace("WCOD",$d),tp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nc),np=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nc),ip=new RegExp("^"+Qd+ep+tp+np+"$"),sp=["material","materials","bones","map"],Sl=class{constructor(e,t,n){let s=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},vt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(jd,"")}static parseTrackName(e){let t=ip.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);sp.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let c=n(a.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ze("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){qe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){qe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){qe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){qe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){qe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[s];if(o===void 0){let l=t.nodeName;qe("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){qe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){qe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};vt.Composite=Sl;vt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};vt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};vt.prototype.GetterByBindingType=[vt.prototype._getValue_direct,vt.prototype._getValue_array,vt.prototype._getValue_arrayElement,vt.prototype._getValue_toArray];vt.prototype.SetterByBindingTypeAndVersioning=[[vt.prototype._setValue_direct,vt.prototype._setValue_direct_setNeedsUpdate,vt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_array,vt.prototype._setValue_array_setNeedsUpdate,vt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_arrayElement,vt.prototype._setValue_arrayElement_setNeedsUpdate,vt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_fromArray,vt.prototype._setValue_fromArray_setNeedsUpdate,vt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ox=new Float32Array(1);var Is=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=nt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(nt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var lc=class lc{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};lc.prototype.isMatrix2=!0;var bl=lc;var Sr=class extends Rn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function ic(i,e,t,n){let s=rp(n);switch(t){case Vl:return i*e;case Ko:return i*e/s.components*s.byteLength;case Jo:return i*e/s.components*s.byteLength;case Pi:return i*e*2/s.components*s.byteLength;case jo:return i*e*2/s.components*s.byteLength;case Hl:return i*e*3/s.components*s.byteLength;case yn:return i*e*4/s.components*s.byteLength;case $o:return i*e*4/s.components*s.byteLength;case Tr:case Ar:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case wr:case Er:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ea:case na:return Math.max(i,16)*Math.max(e,8)/4;case Qo:case ta:return Math.max(i,8)*Math.max(e,8)/2;case ia:case sa:case oa:case aa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ra:case Rr:case la:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ca:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ha:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case ua:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case fa:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case da:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case pa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case ma:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case ga:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case _a:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case xa:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case va:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ya:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ma:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Sa:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ba:case Ta:case Aa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case wa:case Ea:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Cr:case Ra:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function rp(i){switch(i){case on:case Bl:return{byteLength:1,components:1};case Us:case zl:case Ln:return{byteLength:2,components:1};case Yo:case Zo:return{byteLength:2,components:4};case Pn:case qo:case dn:return{byteLength:4,components:1};case kl:case Gl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"187"}}));typeof window<"u"&&(window.__THREE__?ze("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function xf(){let i=null,e=!1,t=null,n=null;function s(r,o){n=i.requestAnimationFrame(s),t(r,o)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function ap(i){let e=new WeakMap;function t(a,c){let l=a.array,h=a.usage,u=l.byteLength,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,l,h),a.onUploadCallback();let d;if(l instanceof Float32Array)d=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=i.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=i.SHORT;else if(l instanceof Uint32Array)d=i.UNSIGNED_INT;else if(l instanceof Int32Array)d=i.INT;else if(l instanceof Int8Array)d=i.BYTE;else if(l instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,c,l){let h=c.array,u=c.updateRanges;if(i.bindBuffer(l,a),u.length===0)i.bufferSubData(l,0,h);else{u.sort((d,g)=>d.start-g.start);let f=0;for(let d=1;d<u.length;d++){let g=u[f],x=u[d];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++f,u[f]=x)}u.length=f+1;for(let d=0,g=u.length;d<g;d++){let x=u[d];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:s,remove:r,update:o}}var lp=`#ifdef USE_ALPHAHASH | ||
| 9 | if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; | ||
| 10 | #endif`,cp=`#ifdef USE_ALPHAHASH | ||
| 11 | const float ALPHA_HASH_SCALE = 0.05; | ||
| 12 | float hash2D( vec2 value ) { | ||
| 13 | return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); | ||
| 14 | } | ||
| 15 | float hash3D( vec3 value ) { | ||
| 16 | return hash2D( vec2( hash2D( value.xy ), value.z ) ); | ||
| 17 | } | ||
| 18 | float getAlphaHashThreshold( vec3 position ) { | ||
| 19 | float maxDeriv = max( | ||
| 20 | length( dFdx( position.xyz ) ), | ||
| 21 | length( dFdy( position.xyz ) ) | ||
| 22 | ); | ||
| 23 | float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); | ||
| 24 | vec2 pixScales = vec2( | ||
| 25 | exp2( floor( log2( pixScale ) ) ), | ||
| 26 | exp2( ceil( log2( pixScale ) ) ) | ||
| 27 | ); | ||
| 28 | vec2 alpha = vec2( | ||
| 29 | hash3D( floor( pixScales.x * position.xyz ) ), | ||
| 30 | hash3D( floor( pixScales.y * position.xyz ) ) | ||
| 31 | ); | ||
| 32 | float lerpFactor = fract( log2( pixScale ) ); | ||
| 33 | float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; | ||
| 34 | float a = min( lerpFactor, 1.0 - lerpFactor ); | ||
| 35 | vec3 cases = vec3( | ||
| 36 | x * x / ( 2.0 * a * ( 1.0 - a ) ), | ||
| 37 | ( x - 0.5 * a ) / ( 1.0 - a ), | ||
| 38 | 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) | ||
| 39 | ); | ||
| 40 | float threshold = ( x < ( 1.0 - a ) ) | ||
| 41 | ? ( ( x < a ) ? cases.x : cases.y ) | ||
| 42 | : cases.z; | ||
| 43 | return clamp( threshold , 1.0e-6, 1.0 ); | ||
| 44 | } | ||
| 45 | #endif`,hp=`#ifdef USE_ALPHAMAP | ||
| 46 | diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; | ||
| 47 | #endif`,up=`#ifdef USE_ALPHAMAP | ||
| 48 | uniform sampler2D alphaMap; | ||
| 49 | #endif`,fp=`#ifdef USE_ALPHATEST | ||
| 50 | #ifdef ALPHA_TO_COVERAGE | ||
| 51 | diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); | ||
| 52 | if ( diffuseColor.a == 0.0 ) discard; | ||
| 53 | #else | ||
| 54 | if ( diffuseColor.a < alphaTest ) discard; | ||
| 55 | #endif | ||
| 56 | #endif`,dp=`#ifdef USE_ALPHATEST | ||
| 57 | uniform float alphaTest; | ||
| 58 | #endif`,pp=`#ifdef USE_AOMAP | ||
| 59 | float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; | ||
| 60 | reflectedLight.indirectDiffuse *= ambientOcclusion; | ||
| 61 | #if defined( USE_CLEARCOAT ) | ||
| 62 | clearcoatSpecularIndirect *= ambientOcclusion; | ||
| 63 | #endif | ||
| 64 | #if defined( USE_SHEEN ) | ||
| 65 | sheenSpecularIndirect *= ambientOcclusion; | ||
| 66 | #endif | ||
| 67 | #if defined( USE_ENVMAP ) && defined( STANDARD ) | ||
| 68 | float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); | ||
| 69 | reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); | ||
| 70 | #endif | ||
| 71 | #endif`,mp=`#ifdef USE_AOMAP | ||
| 72 | uniform sampler2D aoMap; | ||
| 73 | uniform float aoMapIntensity; | ||
| 74 | #endif`,gp=`#ifdef USE_BATCHING | ||
| 75 | #if ! defined( GL_ANGLE_multi_draw ) | ||
| 76 | #define gl_DrawID _gl_DrawID | ||
| 77 | uniform int _gl_DrawID; | ||
| 78 | #endif | ||
| 79 | uniform highp sampler2D batchingTexture; | ||
| 80 | uniform highp usampler2D batchingIdTexture; | ||
| 81 | mat4 getBatchingMatrix( const in float i ) { | ||
| 82 | int size = textureSize( batchingTexture, 0 ).x; | ||
| 83 | int j = int( i ) * 4; | ||
| 84 | int x = j % size; | ||
| 85 | int y = j / size; | ||
| 86 | vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); | ||
| 87 | vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); | ||
| 88 | vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); | ||
| 89 | vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); | ||
| 90 | return mat4( v1, v2, v3, v4 ); | ||
| 91 | } | ||
| 92 | float getIndirectIndex( const in int i ) { | ||
| 93 | int size = textureSize( batchingIdTexture, 0 ).x; | ||
| 94 | int x = i % size; | ||
| 95 | int y = i / size; | ||
| 96 | return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); | ||
| 97 | } | ||
| 98 | #endif | ||
| 99 | #ifdef USE_BATCHING_COLOR | ||
| 100 | uniform sampler2D batchingColorTexture; | ||
| 101 | vec4 getBatchingColor( const in float i ) { | ||
| 102 | int size = textureSize( batchingColorTexture, 0 ).x; | ||
| 103 | int j = int( i ); | ||
| 104 | int x = j % size; | ||
| 105 | int y = j / size; | ||
| 106 | return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ); | ||
| 107 | } | ||
| 108 | #endif`,_p=`#ifdef USE_BATCHING | ||
| 109 | mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); | ||
| 110 | #endif`,xp=`vec3 transformed = vec3( position ); | ||
| 111 | #ifdef USE_ALPHAHASH | ||
| 112 | vPosition = vec3( position ); | ||
| 113 | #endif`,vp=`vec3 objectNormal = vec3( normal ); | ||
| 114 | #ifdef USE_TANGENT | ||
| 115 | vec3 objectTangent = vec3( tangent.xyz ); | ||
| 116 | #endif`,yp=`float G_BlinnPhong_Implicit( ) { | ||
| 117 | return 0.25; | ||
| 118 | } | ||
| 119 | float D_BlinnPhong( const in float shininess, const in float dotNH ) { | ||
| 120 | return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); | ||
| 121 | } | ||
| 122 | vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { | ||
| 123 | vec3 halfDir = normalize( lightDir + viewDir ); | ||
| 124 | float dotNH = saturate( dot( normal, halfDir ) ); | ||
| 125 | float dotVH = saturate( dot( viewDir, halfDir ) ); | ||
| 126 | vec3 F = F_Schlick( specularColor, 1.0, dotVH ); | ||
| 127 | float G = G_BlinnPhong_Implicit( ); | ||
| 128 | float D = D_BlinnPhong( shininess, dotNH ); | ||
| 129 | return F * ( G * D ); | ||
| 130 | } // validated`,Mp=`#ifdef USE_IRIDESCENCE | ||
| 131 | const mat3 XYZ_TO_REC709 = mat3( | ||
| 132 | 3.2404542, -0.9692660, 0.0556434, | ||
| 133 | -1.5371385, 1.8760108, -0.2040259, | ||
| 134 | -0.4985314, 0.0415560, 1.0572252 | ||
| 135 | ); | ||
| 136 | vec3 Fresnel0ToIor( vec3 fresnel0 ) { | ||
| 137 | vec3 sqrtF0 = sqrt( fresnel0 ); | ||
| 138 | return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); | ||
| 139 | } | ||
| 140 | vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { | ||
| 141 | return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); | ||
| 142 | } | ||
| 143 | float IorToFresnel0( float transmittedIor, float incidentIor ) { | ||
| 144 | return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); | ||
| 145 | } | ||
| 146 | vec3 evalSensitivity( float OPD, vec3 shift ) { | ||
| 147 | float phase = 2.0 * PI * OPD * 1.0e-9; | ||
| 148 | vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); | ||
| 149 | vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); | ||
| 150 | vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); | ||
| 151 | vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); | ||
| 152 | xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); | ||
| 153 | xyz /= 1.0685e-7; | ||
| 154 | vec3 rgb = XYZ_TO_REC709 * xyz; | ||
| 155 | return rgb; | ||
| 156 | } | ||
| 157 | vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { | ||
| 158 | vec3 I; | ||
| 159 | float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); | ||
| 160 | float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); | ||
| 161 | float cosTheta2Sq = 1.0 - sinTheta2Sq; | ||
| 162 | if ( cosTheta2Sq < 0.0 ) { | ||
| 163 | return vec3( 1.0 ); | ||
| 164 | } | ||
| 165 | float cosTheta2 = sqrt( cosTheta2Sq ); | ||
| 166 | float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); | ||
| 167 | float R12 = F_Schlick( R0, 1.0, cosTheta1 ); | ||
| 168 | float T121 = 1.0 - R12; | ||
| 169 | float phi12 = 0.0; | ||
| 170 | if ( iridescenceIOR < outsideIOR ) phi12 = PI; | ||
| 171 | float phi21 = PI - phi12; | ||
| 172 | vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); | ||
| 173 | vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); | ||
| 174 | vec3 phi23 = vec3( 0.0 ); | ||
| 175 | if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; | ||
| 176 | if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; | ||
| 177 | if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; | ||
| 178 | float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; | ||
| 179 | vec3 phi = vec3( phi21 ) + phi23; | ||
| 180 | vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); | ||
| 181 | vec3 r123 = sqrt( R123 ); | ||
| 182 | vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); | ||
| 183 | vec3 C0 = R12 + Rs; | ||
| 184 | I = C0; | ||
| 185 | vec3 Cm = Rs - T121; | ||
| 186 | for ( int m = 1; m <= 2; ++ m ) { | ||
| 187 | Cm *= r123; | ||
| 188 | vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); | ||
| 189 | I += Cm * Sm; | ||
| 190 | } | ||
| 191 | return max( I, vec3( 0.0 ) ); | ||
| 192 | } | ||
| 193 | #endif`,Sp=`#ifdef USE_BUMPMAP | ||
| 194 | uniform sampler2D bumpMap; | ||
| 195 | uniform float bumpScale; | ||
| 196 | vec2 dHdxy_fwd() { | ||
| 197 | vec2 dSTdx = dFdx( vBumpMapUv ); | ||
| 198 | vec2 dSTdy = dFdy( vBumpMapUv ); | ||
| 199 | float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; | ||
| 200 | float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; | ||
| 201 | float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; | ||
| 202 | return vec2( dBx, dBy ); | ||
| 203 | } | ||
| 204 | vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { | ||
| 205 | vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); | ||
| 206 | vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); | ||
| 207 | vec3 vN = surf_norm; | ||
| 208 | vec3 R1 = cross( vSigmaY, vN ); | ||
| 209 | vec3 R2 = cross( vN, vSigmaX ); | ||
| 210 | float fDet = dot( vSigmaX, R1 ) * faceDirection; | ||
| 211 | vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); | ||
| 212 | return normalize( abs( fDet ) * surf_norm - vGrad ); | ||
| 213 | } | ||
| 214 | #endif`,bp=`#if NUM_CLIPPING_PLANES > 0 | ||
| 215 | vec4 plane; | ||
| 216 | #ifdef ALPHA_TO_COVERAGE | ||
| 217 | float distanceToPlane, distanceGradient; | ||
| 218 | float clipOpacity = 1.0; | ||
| 219 | #pragma unroll_loop_start | ||
| 220 | for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { | ||
| 221 | plane = clippingPlanes[ i ]; | ||
| 222 | distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; | ||
| 223 | distanceGradient = fwidth( distanceToPlane ) / 2.0; | ||
| 224 | clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); | ||
| 225 | if ( clipOpacity == 0.0 ) discard; | ||
| 226 | } | ||
| 227 | #pragma unroll_loop_end | ||
| 228 | #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES | ||
| 229 | float unionClipOpacity = 1.0; | ||
| 230 | #pragma unroll_loop_start | ||
| 231 | for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { | ||
| 232 | plane = clippingPlanes[ i ]; | ||
| 233 | distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; | ||
| 234 | distanceGradient = fwidth( distanceToPlane ) / 2.0; | ||
| 235 | unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); | ||
| 236 | } | ||
| 237 | #pragma unroll_loop_end | ||
| 238 | clipOpacity *= 1.0 - unionClipOpacity; | ||
| 239 | #endif | ||
| 240 | diffuseColor.a *= clipOpacity; | ||
| 241 | if ( diffuseColor.a == 0.0 ) discard; | ||
| 242 | #else | ||
| 243 | #pragma unroll_loop_start | ||
| 244 | for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { | ||
| 245 | plane = clippingPlanes[ i ]; | ||
| 246 | if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; | ||
| 247 | } | ||
| 248 | #pragma unroll_loop_end | ||
| 249 | #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES | ||
| 250 | bool clipped = true; | ||
| 251 | #pragma unroll_loop_start | ||
| 252 | for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { | ||
| 253 | plane = clippingPlanes[ i ]; | ||
| 254 | clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; | ||
| 255 | } | ||
| 256 | #pragma unroll_loop_end | ||
| 257 | if ( clipped ) discard; | ||
| 258 | #endif | ||
| 259 | #endif | ||
| 260 | #endif`,Tp=`#if NUM_CLIPPING_PLANES > 0 | ||
| 261 | varying vec3 vClipPosition; | ||
| 262 | uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; | ||
| 263 | #endif`,Ap=`#if NUM_CLIPPING_PLANES > 0 | ||
| 264 | varying vec3 vClipPosition; | ||
| 265 | #endif`,wp=`#if NUM_CLIPPING_PLANES > 0 | ||
| 266 | vClipPosition = - mvPosition.xyz; | ||
| 267 | #endif`,Ep=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) | ||
| 268 | diffuseColor *= vColor; | ||
| 269 | #endif`,Rp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) | ||
| 270 | varying vec4 vColor; | ||
| 271 | #endif`,Cp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) | ||
| 272 | varying vec4 vColor; | ||
| 273 | #endif`,Ip=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) | ||
| 274 | vColor = vec4( 1.0 ); | ||
| 275 | #endif | ||
| 276 | #ifdef USE_COLOR_ALPHA | ||
| 277 | vColor *= color; | ||
| 278 | #elif defined( USE_COLOR ) | ||
| 279 | vColor.rgb *= color; | ||
| 280 | #endif | ||
| 281 | #ifdef USE_INSTANCING_COLOR | ||
| 282 | vColor.rgb *= instanceColor.rgb; | ||
| 283 | #endif | ||
| 284 | #ifdef USE_BATCHING_COLOR | ||
| 285 | vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); | ||
| 286 | #endif`,Pp=`#define PI 3.141592653589793 | ||
| 287 | #define PI2 6.283185307179586 | ||
| 288 | #define PI_HALF 1.5707963267948966 | ||
| 289 | #define RECIPROCAL_PI 0.3183098861837907 | ||
| 290 | #define RECIPROCAL_PI2 0.15915494309189535 | ||
| 291 | #define EPSILON 1e-6 | ||
| 292 | #ifndef saturate | ||
| 293 | #define saturate( a ) clamp( a, 0.0, 1.0 ) | ||
| 294 | #endif | ||
| 295 | #define whiteComplement( a ) ( 1.0 - saturate( a ) ) | ||
| 296 | float pow2( const in float x ) { return x*x; } | ||
| 297 | vec3 pow2( const in vec3 x ) { return x*x; } | ||
| 298 | float pow3( const in float x ) { return x*x*x; } | ||
| 299 | float pow4( const in float x ) { float x2 = x*x; return x2*x2; } | ||
| 300 | float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } | ||
| 301 | float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } | ||
| 302 | highp float rand( const in vec2 uv ) { | ||
| 303 | const highp float a = 12.9898, b = 78.233, c = 43758.5453; | ||
| 304 | highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); | ||
| 305 | return fract( sin( sn ) * c ); | ||
| 306 | } | ||
| 307 | #ifdef HIGH_PRECISION | ||
| 308 | float precisionSafeLength( vec3 v ) { return length( v ); } | ||
| 309 | #else | ||
| 310 | float precisionSafeLength( vec3 v ) { | ||
| 311 | float maxComponent = max3( abs( v ) ); | ||
| 312 | return length( v / maxComponent ) * maxComponent; | ||
| 313 | } | ||
| 314 | #endif | ||
| 315 | struct IncidentLight { | ||
| 316 | vec3 color; | ||
| 317 | vec3 direction; | ||
| 318 | bool visible; | ||
| 319 | }; | ||
| 320 | struct ReflectedLight { | ||
| 321 | vec3 directDiffuse; | ||
| 322 | vec3 directSpecular; | ||
| 323 | vec3 indirectDiffuse; | ||
| 324 | vec3 indirectSpecular; | ||
| 325 | }; | ||
| 326 | #ifdef USE_ALPHAHASH | ||
| 327 | varying vec3 vPosition; | ||
| 328 | #endif | ||
| 329 | vec3 transformDirection( in vec3 dir, in mat4 matrix ) { | ||
| 330 | return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); | ||
| 331 | } | ||
| 332 | #define inverseTransformDirection transformDirectionByInverseViewMatrix | ||
| 333 | vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { | ||
| 334 | return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); | ||
| 335 | } | ||
| 336 | vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { | ||
| 337 | return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); | ||
| 338 | } | ||
| 339 | bool isPerspectiveMatrix( mat4 m ) { | ||
| 340 | return m[ 2 ][ 3 ] == - 1.0; | ||
| 341 | } | ||
| 342 | vec2 equirectUv( in vec3 dir ) { | ||
| 343 | float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; | ||
| 344 | float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; | ||
| 345 | return vec2( u, v ); | ||
| 346 | } | ||
| 347 | vec3 BRDF_Lambert( const in vec3 diffuseColor ) { | ||
| 348 | return RECIPROCAL_PI * diffuseColor; | ||
| 349 | } | ||
| 350 | vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { | ||
| 351 | float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); | ||
| 352 | return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); | ||
| 353 | } | ||
| 354 | float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { | ||
| 355 | float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); | ||
| 356 | return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); | ||
| 357 | } // validated`,Lp=`vec3 transformedNormal = objectNormal; | ||
| 358 | #ifdef USE_TANGENT | ||
| 359 | vec3 transformedTangent = objectTangent; | ||
| 360 | #endif | ||
| 361 | #ifdef USE_BATCHING | ||
| 362 | mat3 bm = mat3( batchingMatrix ); | ||
| 363 | transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); | ||
| 364 | transformedNormal = bm * transformedNormal; | ||
| 365 | #ifdef USE_TANGENT | ||
| 366 | transformedTangent = bm * transformedTangent; | ||
| 367 | #endif | ||
| 368 | #endif | ||
| 369 | #ifdef USE_INSTANCING | ||
| 370 | mat3 im = mat3( instanceMatrix ); | ||
| 371 | transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); | ||
| 372 | transformedNormal = im * transformedNormal; | ||
| 373 | #ifdef USE_TANGENT | ||
| 374 | transformedTangent = im * transformedTangent; | ||
| 375 | #endif | ||
| 376 | #endif | ||
| 377 | transformedNormal = normalMatrix * transformedNormal; | ||
| 378 | #ifdef FLIP_SIDED | ||
| 379 | transformedNormal = - transformedNormal; | ||
| 380 | #endif | ||
| 381 | #ifdef USE_TANGENT | ||
| 382 | transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; | ||
| 383 | #endif`,Dp=`#ifdef USE_DISPLACEMENTMAP | ||
| 384 | uniform sampler2D displacementMap; | ||
| 385 | uniform float displacementScale; | ||
| 386 | uniform float displacementBias; | ||
| 387 | #endif`,Np=`#ifdef USE_DISPLACEMENTMAP | ||
| 388 | transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); | ||
| 389 | #endif`,Up=`#ifdef USE_EMISSIVEMAP | ||
| 390 | vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); | ||
| 391 | #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE | ||
| 392 | emissiveColor = sRGBTransferEOTF( emissiveColor ); | ||
| 393 | #endif | ||
| 394 | totalEmissiveRadiance *= emissiveColor.rgb; | ||
| 395 | #endif`,Fp=`#ifdef USE_EMISSIVEMAP | ||
| 396 | uniform sampler2D emissiveMap; | ||
| 397 | #endif`,Op="gl_FragColor = linearToOutputTexel( gl_FragColor );",Bp=`vec4 LinearTransferOETF( in vec4 value ) { | ||
| 398 | return value; | ||
| 399 | } | ||
| 400 | vec4 sRGBTransferEOTF( in vec4 value ) { | ||
| 401 | return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); | ||
| 402 | } | ||
| 403 | vec4 sRGBTransferOETF( in vec4 value ) { | ||
| 404 | return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); | ||
| 405 | }`,zp=`#ifdef USE_ENVMAP | ||
| 406 | #ifdef ENV_WORLDPOS | ||
| 407 | vec3 cameraToFrag; | ||
| 408 | if ( isOrthographic ) { | ||
| 409 | cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); | ||
| 410 | } else { | ||
| 411 | cameraToFrag = normalize( vWorldPosition - cameraPosition ); | ||
| 412 | } | ||
| 413 | vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); | ||
| 414 | #ifdef ENVMAP_MODE_REFLECTION | ||
| 415 | vec3 reflectVec = reflect( cameraToFrag, worldNormal ); | ||
| 416 | #else | ||
| 417 | vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); | ||
| 418 | #endif | ||
| 419 | #else | ||
| 420 | vec3 reflectVec = vReflect; | ||
| 421 | #endif | ||
| 422 | #ifdef ENVMAP_TYPE_CUBE | ||
| 423 | vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); | ||
| 424 | #ifdef ENVMAP_BLENDING_MULTIPLY | ||
| 425 | outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); | ||
| 426 | #elif defined( ENVMAP_BLENDING_MIX ) | ||
| 427 | outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); | ||
| 428 | #elif defined( ENVMAP_BLENDING_ADD ) | ||
| 429 | outgoingLight += envColor.xyz * specularStrength * reflectivity; | ||
| 430 | #endif | ||
| 431 | #endif | ||
| 432 | #endif`,kp=`#ifdef USE_ENVMAP | ||
| 433 | uniform float envMapIntensity; | ||
| 434 | uniform mat3 envMapRotation; | ||
| 435 | uniform samplerCube envMap; | ||
| 436 | #ifdef ENVMAP_TYPE_PMREM | ||
| 437 | float roughnessToMip( const in float roughness ) { | ||
| 438 | float r = clamp( roughness, 0.0, 1.0 ); | ||
| 439 | return ENVMAP_MAX_LOD * r * ( 2.0 - r ); | ||
| 440 | } | ||
| 441 | #endif | ||
| 442 | #endif`,Gp=`#ifdef USE_ENVMAP | ||
| 443 | uniform float reflectivity; | ||
| 444 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) | ||
| 445 | #define ENV_WORLDPOS | ||
| 446 | #endif | ||
| 447 | #ifdef ENV_WORLDPOS | ||
| 448 | varying vec3 vWorldPosition; | ||
| 449 | uniform float refractionRatio; | ||
| 450 | #else | ||
| 451 | varying vec3 vReflect; | ||
| 452 | #endif | ||
| 453 | #endif`,Vp=`#ifdef USE_ENVMAP | ||
| 454 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) | ||
| 455 | #define ENV_WORLDPOS | ||
| 456 | #endif | ||
| 457 | #ifdef ENV_WORLDPOS | ||
| 458 | |||
| 459 | varying vec3 vWorldPosition; | ||
| 460 | #else | ||
| 461 | varying vec3 vReflect; | ||
| 462 | uniform float refractionRatio; | ||
| 463 | #endif | ||
| 464 | #endif`,Hp=`#ifdef USE_ENVMAP | ||
| 465 | #ifdef ENV_WORLDPOS | ||
| 466 | vWorldPosition = worldPosition.xyz; | ||
| 467 | #else | ||
| 468 | vec3 cameraToVertex; | ||
| 469 | if ( isOrthographic ) { | ||
| 470 | cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); | ||
| 471 | } else { | ||
| 472 | cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); | ||
| 473 | } | ||
| 474 | vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); | ||
| 475 | #ifdef ENVMAP_MODE_REFLECTION | ||
| 476 | vReflect = reflect( cameraToVertex, worldNormal ); | ||
| 477 | #else | ||
| 478 | vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); | ||
| 479 | #endif | ||
| 480 | #endif | ||
| 481 | #endif`,Wp=`#ifdef USE_FOG | ||
| 482 | vFogDepth = - mvPosition.z; | ||
| 483 | #endif`,Xp=`#ifdef USE_FOG | ||
| 484 | varying float vFogDepth; | ||
| 485 | #endif`,qp=`#ifdef USE_FOG | ||
| 486 | #ifdef FOG_EXP2 | ||
| 487 | float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); | ||
| 488 | #else | ||
| 489 | float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); | ||
| 490 | #endif | ||
| 491 | gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); | ||
| 492 | #endif`,Yp=`#ifdef USE_FOG | ||
| 493 | uniform vec3 fogColor; | ||
| 494 | varying float vFogDepth; | ||
| 495 | #ifdef FOG_EXP2 | ||
| 496 | uniform float fogDensity; | ||
| 497 | #else | ||
| 498 | uniform float fogNear; | ||
| 499 | uniform float fogFar; | ||
| 500 | #endif | ||
| 501 | #endif`,Zp=`#ifdef USE_GRADIENTMAP | ||
| 502 | uniform sampler2D gradientMap; | ||
| 503 | #endif | ||
| 504 | vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { | ||
| 505 | float dotNL = dot( normal, lightDirection ); | ||
| 506 | vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); | ||
| 507 | #ifdef USE_GRADIENTMAP | ||
| 508 | return vec3( texture2D( gradientMap, coord ).r ); | ||
| 509 | #else | ||
| 510 | vec2 fw = fwidth( coord ) * 0.5; | ||
| 511 | return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); | ||
| 512 | #endif | ||
| 513 | }`,Kp=`#ifdef USE_LIGHTMAP | ||
| 514 | uniform sampler2D lightMap; | ||
| 515 | uniform float lightMapIntensity; | ||
| 516 | #endif`,Jp=`LambertMaterial material; | ||
| 517 | material.diffuseColor = diffuseColor.rgb; | ||
| 518 | material.specularStrength = specularStrength;`,jp=`varying vec3 vViewPosition; | ||
| 519 | struct LambertMaterial { | ||
| 520 | vec3 diffuseColor; | ||
| 521 | float specularStrength; | ||
| 522 | }; | ||
| 523 | void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 524 | float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); | ||
| 525 | vec3 irradiance = dotNL * directLight.color; | ||
| 526 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 527 | } | ||
| 528 | void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 529 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 530 | } | ||
| 531 | #define RE_Direct RE_Direct_Lambert | ||
| 532 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,$p=`uniform bool receiveShadow; | ||
| 533 | uniform vec3 ambientLightColor; | ||
| 534 | #if defined( USE_LIGHT_PROBES ) | ||
| 535 | uniform vec3 lightProbe[ 9 ]; | ||
| 536 | #endif | ||
| 537 | vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { | ||
| 538 | float x = normal.x, y = normal.y, z = normal.z; | ||
| 539 | vec3 result = shCoefficients[ 0 ] * 0.886227; | ||
| 540 | result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; | ||
| 541 | result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; | ||
| 542 | result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; | ||
| 543 | result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; | ||
| 544 | result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; | ||
| 545 | result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); | ||
| 546 | result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; | ||
| 547 | result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); | ||
| 548 | return result; | ||
| 549 | } | ||
| 550 | vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { | ||
| 551 | vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); | ||
| 552 | vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); | ||
| 553 | return irradiance; | ||
| 554 | } | ||
| 555 | vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { | ||
| 556 | vec3 irradiance = ambientLightColor; | ||
| 557 | return irradiance; | ||
| 558 | } | ||
| 559 | float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { | ||
| 560 | float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); | ||
| 561 | if ( cutoffDistance > 0.0 ) { | ||
| 562 | distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); | ||
| 563 | } | ||
| 564 | return distanceFalloff; | ||
| 565 | } | ||
| 566 | float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { | ||
| 567 | return smoothstep( coneCosine, penumbraCosine, angleCosine ); | ||
| 568 | } | ||
| 569 | #if NUM_SUN_LIGHTS > 0 | ||
| 570 | struct SunLight { | ||
| 571 | vec3 direction; | ||
| 572 | vec3 color; | ||
| 573 | }; | ||
| 574 | uniform SunLight sunLights[ NUM_SUN_LIGHTS ]; | ||
| 575 | void getSunLightInfo( const in SunLight sunLight, out IncidentLight light ) { | ||
| 576 | light.color = sunLight.color; | ||
| 577 | light.direction = sunLight.direction; | ||
| 578 | light.visible = true; | ||
| 579 | } | ||
| 580 | #endif | ||
| 581 | #if NUM_DIR_LIGHTS > 0 | ||
| 582 | struct DirectionalLight { | ||
| 583 | vec3 direction; | ||
| 584 | vec3 color; | ||
| 585 | }; | ||
| 586 | uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; | ||
| 587 | void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { | ||
| 588 | light.color = directionalLight.color; | ||
| 589 | light.direction = directionalLight.direction; | ||
| 590 | light.visible = true; | ||
| 591 | } | ||
| 592 | #endif | ||
| 593 | #if NUM_POINT_LIGHTS > 0 | ||
| 594 | struct PointLight { | ||
| 595 | vec3 position; | ||
| 596 | vec3 color; | ||
| 597 | float distance; | ||
| 598 | float decay; | ||
| 599 | }; | ||
| 600 | uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; | ||
| 601 | void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { | ||
| 602 | vec3 lVector = pointLight.position - geometryPosition; | ||
| 603 | light.direction = normalize( lVector ); | ||
| 604 | float lightDistance = length( lVector ); | ||
| 605 | light.color = pointLight.color; | ||
| 606 | light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); | ||
| 607 | light.visible = ( light.color != vec3( 0.0 ) ); | ||
| 608 | } | ||
| 609 | #endif | ||
| 610 | #if NUM_SPOT_LIGHTS > 0 | ||
| 611 | struct SpotLight { | ||
| 612 | vec3 position; | ||
| 613 | vec3 direction; | ||
| 614 | vec3 color; | ||
| 615 | float distance; | ||
| 616 | float decay; | ||
| 617 | float coneCos; | ||
| 618 | float penumbraCos; | ||
| 619 | }; | ||
| 620 | uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; | ||
| 621 | void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { | ||
| 622 | vec3 lVector = spotLight.position - geometryPosition; | ||
| 623 | light.direction = normalize( lVector ); | ||
| 624 | float angleCos = dot( light.direction, spotLight.direction ); | ||
| 625 | float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); | ||
| 626 | if ( spotAttenuation > 0.0 ) { | ||
| 627 | float lightDistance = length( lVector ); | ||
| 628 | light.color = spotLight.color * spotAttenuation; | ||
| 629 | light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); | ||
| 630 | light.visible = ( light.color != vec3( 0.0 ) ); | ||
| 631 | } else { | ||
| 632 | light.color = vec3( 0.0 ); | ||
| 633 | light.visible = false; | ||
| 634 | } | ||
| 635 | } | ||
| 636 | #endif | ||
| 637 | #if NUM_RECT_AREA_LIGHTS > 0 | ||
| 638 | struct RectAreaLight { | ||
| 639 | vec3 color; | ||
| 640 | vec3 position; | ||
| 641 | vec3 halfWidth; | ||
| 642 | vec3 halfHeight; | ||
| 643 | }; | ||
| 644 | uniform sampler2D ltc_1; uniform sampler2D ltc_2; | ||
| 645 | uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; | ||
| 646 | #endif | ||
| 647 | #if NUM_HEMI_LIGHTS > 0 | ||
| 648 | struct HemisphereLight { | ||
| 649 | vec3 direction; | ||
| 650 | vec3 skyColor; | ||
| 651 | vec3 groundColor; | ||
| 652 | }; | ||
| 653 | uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; | ||
| 654 | vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { | ||
| 655 | float dotNL = dot( normal, hemiLight.direction ); | ||
| 656 | float hemiDiffuseWeight = 0.5 * dotNL + 0.5; | ||
| 657 | vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); | ||
| 658 | return irradiance; | ||
| 659 | } | ||
| 660 | #endif | ||
| 661 | #include <lightprobes_pars_fragment>`,Qp=`#ifdef USE_ENVMAP | ||
| 662 | vec3 getIBLIrradiance( const in vec3 normal ) { | ||
| 663 | #ifdef ENVMAP_TYPE_PMREM | ||
| 664 | vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); | ||
| 665 | vec4 envMapColor = textureLod( envMap, envMapRotation * worldNormal, ENVMAP_MAX_LOD ); | ||
| 666 | return PI * envMapColor.rgb * envMapIntensity; | ||
| 667 | #else | ||
| 668 | return vec3( 0.0 ); | ||
| 669 | #endif | ||
| 670 | } | ||
| 671 | vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { | ||
| 672 | #ifdef ENVMAP_TYPE_PMREM | ||
| 673 | vec3 reflectVec = reflect( - viewDir, normal ); | ||
| 674 | reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); | ||
| 675 | reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); | ||
| 676 | vec4 envMapColor = textureLod( envMap, envMapRotation * reflectVec, roughnessToMip( roughness ) ); | ||
| 677 | return envMapColor.rgb * envMapIntensity; | ||
| 678 | #else | ||
| 679 | return vec3( 0.0 ); | ||
| 680 | #endif | ||
| 681 | } | ||
| 682 | #ifdef USE_RETROREFLECTION | ||
| 683 | vec3 getIBLRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { | ||
| 684 | #ifdef ENVMAP_TYPE_PMREM | ||
| 685 | vec3 retroVec = normalize( mix( viewDir, normal, pow4( roughness ) ) ); | ||
| 686 | retroVec = transformDirectionByInverseViewMatrix( retroVec, viewMatrix ); | ||
| 687 | vec4 envMapColor = textureLod( envMap, envMapRotation * retroVec, roughnessToMip( roughness ) ); | ||
| 688 | return envMapColor.rgb * envMapIntensity; | ||
| 689 | #else | ||
| 690 | return vec3( 0.0 ); | ||
| 691 | #endif | ||
| 692 | } | ||
| 693 | #endif | ||
| 694 | #ifdef USE_ANISOTROPY | ||
| 695 | vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { | ||
| 696 | #ifdef ENVMAP_TYPE_PMREM | ||
| 697 | vec3 bentNormal = cross( bitangent, viewDir ); | ||
| 698 | bentNormal = normalize( cross( bentNormal, bitangent ) ); | ||
| 699 | bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); | ||
| 700 | return getIBLRadiance( viewDir, bentNormal, roughness ); | ||
| 701 | #else | ||
| 702 | return vec3( 0.0 ); | ||
| 703 | #endif | ||
| 704 | } | ||
| 705 | #ifdef USE_RETROREFLECTION | ||
| 706 | vec3 getIBLAnisotropyRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { | ||
| 707 | #ifdef ENVMAP_TYPE_PMREM | ||
| 708 | vec3 bentNormal = cross( bitangent, viewDir ); | ||
| 709 | bentNormal = normalize( cross( bentNormal, bitangent ) ); | ||
| 710 | bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); | ||
| 711 | return getIBLRetroRadiance( viewDir, bentNormal, roughness ); | ||
| 712 | #else | ||
| 713 | return vec3( 0.0 ); | ||
| 714 | #endif | ||
| 715 | } | ||
| 716 | #endif | ||
| 717 | #endif | ||
| 718 | #endif`,em=`ToonMaterial material; | ||
| 719 | material.diffuseColor = diffuseColor.rgb;`,tm=`varying vec3 vViewPosition; | ||
| 720 | struct ToonMaterial { | ||
| 721 | vec3 diffuseColor; | ||
| 722 | }; | ||
| 723 | void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 724 | vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; | ||
| 725 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 726 | } | ||
| 727 | void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 728 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 729 | } | ||
| 730 | #define RE_Direct RE_Direct_Toon | ||
| 731 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,nm=`BlinnPhongMaterial material; | ||
| 732 | material.diffuseColor = diffuseColor.rgb; | ||
| 733 | material.specularColor = specular; | ||
| 734 | material.specularShininess = shininess; | ||
| 735 | material.specularStrength = specularStrength;`,im=`varying vec3 vViewPosition; | ||
| 736 | struct BlinnPhongMaterial { | ||
| 737 | vec3 diffuseColor; | ||
| 738 | vec3 specularColor; | ||
| 739 | float specularShininess; | ||
| 740 | float specularStrength; | ||
| 741 | }; | ||
| 742 | void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 743 | float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); | ||
| 744 | vec3 irradiance = dotNL * directLight.color; | ||
| 745 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 746 | reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; | ||
| 747 | } | ||
| 748 | void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 749 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); | ||
| 750 | } | ||
| 751 | #define RE_Direct RE_Direct_BlinnPhong | ||
| 752 | #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,sm=`PhysicalMaterial material; | ||
| 753 | material.diffuseColor = diffuseColor.rgb; | ||
| 754 | material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); | ||
| 755 | material.metalness = metalnessFactor; | ||
| 756 | vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); | ||
| 757 | float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); | ||
| 758 | material.roughness = max( roughnessFactor, 0.045 ); | ||
| 759 | material.roughness += geometryRoughness; | ||
| 760 | material.roughness = min( material.roughness, 1.0 ); | ||
| 761 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 762 | float diffuseRoughnessFactor = diffuseRoughness; | ||
| 763 | #ifdef USE_DIFFUSE_ROUGHNESSMAP | ||
| 764 | diffuseRoughnessFactor *= texture2D( diffuseRoughnessMap, vDiffuseRoughnessMapUv ).r; | ||
| 765 | #endif | ||
| 766 | material.diffuseRoughness = saturate( diffuseRoughnessFactor ); | ||
| 767 | #endif | ||
| 768 | #ifdef IOR | ||
| 769 | material.ior = ior; | ||
| 770 | #ifdef USE_SPECULAR | ||
| 771 | float specularIntensityFactor = specularIntensity; | ||
| 772 | vec3 specularColorFactor = specularColor; | ||
| 773 | #ifdef USE_SPECULAR_COLORMAP | ||
| 774 | specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; | ||
| 775 | #endif | ||
| 776 | #ifdef USE_SPECULAR_INTENSITYMAP | ||
| 777 | specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; | ||
| 778 | #endif | ||
| 779 | material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); | ||
| 780 | #else | ||
| 781 | float specularIntensityFactor = 1.0; | ||
| 782 | vec3 specularColorFactor = vec3( 1.0 ); | ||
| 783 | material.specularF90 = 1.0; | ||
| 784 | #endif | ||
| 785 | material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; | ||
| 786 | material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); | ||
| 787 | #else | ||
| 788 | material.specularColor = vec3( 0.04 ); | ||
| 789 | material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); | ||
| 790 | material.specularF90 = 1.0; | ||
| 791 | #endif | ||
| 792 | #ifdef USE_CLEARCOAT | ||
| 793 | material.clearcoat = clearcoat; | ||
| 794 | material.clearcoatRoughness = clearcoatRoughness; | ||
| 795 | material.clearcoatF0 = vec3( 0.04 ); | ||
| 796 | material.clearcoatF90 = 1.0; | ||
| 797 | #ifdef USE_CLEARCOATMAP | ||
| 798 | material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; | ||
| 799 | #endif | ||
| 800 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP | ||
| 801 | material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; | ||
| 802 | #endif | ||
| 803 | material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.045 ); | ||
| 804 | material.clearcoatRoughness += geometryRoughness; | ||
| 805 | material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); | ||
| 806 | #endif | ||
| 807 | #ifdef USE_DISPERSION | ||
| 808 | material.dispersion = dispersion; | ||
| 809 | #endif | ||
| 810 | #ifdef USE_RETROREFLECTION | ||
| 811 | material.retroreflectivity = retroreflectivity; | ||
| 812 | #endif | ||
| 813 | #ifdef USE_IRIDESCENCE | ||
| 814 | material.iridescence = iridescence; | ||
| 815 | material.iridescenceIOR = iridescenceIOR; | ||
| 816 | #ifdef USE_IRIDESCENCEMAP | ||
| 817 | material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; | ||
| 818 | #endif | ||
| 819 | #ifdef USE_IRIDESCENCE_THICKNESSMAP | ||
| 820 | material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; | ||
| 821 | #else | ||
| 822 | material.iridescenceThickness = iridescenceThicknessMaximum; | ||
| 823 | #endif | ||
| 824 | #endif | ||
| 825 | #ifdef USE_SHEEN | ||
| 826 | material.sheenColor = sheenColor; | ||
| 827 | #ifdef USE_SHEEN_COLORMAP | ||
| 828 | material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; | ||
| 829 | #endif | ||
| 830 | material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); | ||
| 831 | #ifdef USE_SHEEN_ROUGHNESSMAP | ||
| 832 | material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; | ||
| 833 | #endif | ||
| 834 | #endif | ||
| 835 | #ifdef USE_ANISOTROPY | ||
| 836 | #ifdef USE_ANISOTROPYMAP | ||
| 837 | mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); | ||
| 838 | vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; | ||
| 839 | vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; | ||
| 840 | #else | ||
| 841 | vec2 anisotropyV = anisotropyVector; | ||
| 842 | #endif | ||
| 843 | material.anisotropy = length( anisotropyV ); | ||
| 844 | if( material.anisotropy == 0.0 ) { | ||
| 845 | anisotropyV = vec2( 1.0, 0.0 ); | ||
| 846 | } else { | ||
| 847 | anisotropyV /= material.anisotropy; | ||
| 848 | material.anisotropy = saturate( material.anisotropy ); | ||
| 849 | } | ||
| 850 | material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); | ||
| 851 | material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; | ||
| 852 | material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; | ||
| 853 | #endif`,rm=`uniform sampler2D dfgLUT; | ||
| 854 | struct PhysicalMaterial { | ||
| 855 | vec3 diffuseColor; | ||
| 856 | vec3 diffuseContribution; | ||
| 857 | vec3 specularColor; | ||
| 858 | vec3 specularColorBlended; | ||
| 859 | float roughness; | ||
| 860 | float metalness; | ||
| 861 | float specularF90; | ||
| 862 | float dispersion; | ||
| 863 | vec2 dfg; | ||
| 864 | vec3 multiScatteringCompensation; | ||
| 865 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 866 | float diffuseRoughness; | ||
| 867 | #endif | ||
| 868 | #ifdef USE_RETROREFLECTION | ||
| 869 | float retroreflectivity; | ||
| 870 | #endif | ||
| 871 | #ifdef USE_CLEARCOAT | ||
| 872 | float clearcoat; | ||
| 873 | float clearcoatRoughness; | ||
| 874 | vec3 clearcoatF0; | ||
| 875 | float clearcoatF90; | ||
| 876 | #endif | ||
| 877 | #ifdef USE_IRIDESCENCE | ||
| 878 | float iridescence; | ||
| 879 | float iridescenceIOR; | ||
| 880 | float iridescenceThickness; | ||
| 881 | vec3 iridescenceFresnel; | ||
| 882 | vec3 iridescenceF0Dielectric; | ||
| 883 | vec3 iridescenceF0Metallic; | ||
| 884 | #endif | ||
| 885 | #ifdef USE_SHEEN | ||
| 886 | vec3 sheenColor; | ||
| 887 | float sheenRoughness; | ||
| 888 | #endif | ||
| 889 | #ifdef IOR | ||
| 890 | float ior; | ||
| 891 | #endif | ||
| 892 | #ifdef USE_TRANSMISSION | ||
| 893 | float transmission; | ||
| 894 | float transmissionAlpha; | ||
| 895 | float thickness; | ||
| 896 | float attenuationDistance; | ||
| 897 | vec3 attenuationColor; | ||
| 898 | #endif | ||
| 899 | #ifdef USE_ANISOTROPY | ||
| 900 | float anisotropy; | ||
| 901 | float alphaT; | ||
| 902 | vec3 anisotropyT; | ||
| 903 | vec3 anisotropyB; | ||
| 904 | #endif | ||
| 905 | }; | ||
| 906 | vec3 clearcoatSpecularDirect = vec3( 0.0 ); | ||
| 907 | vec3 clearcoatSpecularIndirect = vec3( 0.0 ); | ||
| 908 | vec3 sheenSpecularDirect = vec3( 0.0 ); | ||
| 909 | vec3 sheenSpecularIndirect = vec3(0.0 ); | ||
| 910 | vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { | ||
| 911 | float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); | ||
| 912 | float x2 = x * x; | ||
| 913 | float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); | ||
| 914 | return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); | ||
| 915 | } | ||
| 916 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 917 | const float EON_EPSILON = 1e-7; | ||
| 918 | float FON_DirectionalAlbedo( const in float mu, const in float roughness, const in float A ) { | ||
| 919 | float muComp = 1.0 - mu; | ||
| 920 | float gOverPi = muComp * ( 0.0571085289 + muComp * ( 0.491881867 + muComp * ( - 0.332181442 + muComp * 0.0714429953 ) ) ); | ||
| 921 | return A * ( 1.0 + roughness * gOverPi ); | ||
| 922 | } | ||
| 923 | vec3 BRDF_EON( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 diffuseColor, const in float roughness ) { | ||
| 924 | vec3 rho = saturate( diffuseColor ); | ||
| 925 | if ( roughness <= EON_EPSILON ) return BRDF_Lambert( rho ); | ||
| 926 | float dotNL = saturate( dot( normal, lightDir ) ); | ||
| 927 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 928 | float s = dot( lightDir, viewDir ) - dotNL * dotNV; | ||
| 929 | float sOverT = ( s > 0.0 ) ? s / max( max( dotNL, dotNV ), EON_EPSILON ) : s; | ||
| 930 | float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness ); | ||
| 931 | vec3 singleScatter = rho * RECIPROCAL_PI * A * ( 1.0 + roughness * sOverT ); | ||
| 932 | float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness ); | ||
| 933 | float albedoV = FON_DirectionalAlbedo( dotNV, roughness, A ); | ||
| 934 | float albedoL = FON_DirectionalAlbedo( dotNL, roughness, A ); | ||
| 935 | vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) ); | ||
| 936 | vec3 multiScatter = rhoMultiScatter * RECIPROCAL_PI | ||
| 937 | * max( EON_EPSILON, 1.0 - albedoV ) | ||
| 938 | * max( EON_EPSILON, 1.0 - albedoL ) | ||
| 939 | / max( EON_EPSILON, 1.0 - averageAlbedo ); | ||
| 940 | return singleScatter + multiScatter; | ||
| 941 | } | ||
| 942 | vec3 EON_DirectionalAlbedo( const in vec3 diffuseColor, const in float roughness, const in float dotNV ) { | ||
| 943 | vec3 rho = saturate( diffuseColor ); | ||
| 944 | if ( roughness <= EON_EPSILON ) return rho; | ||
| 945 | float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness ); | ||
| 946 | float directionalAlbedo = FON_DirectionalAlbedo( dotNV, roughness, A ); | ||
| 947 | float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness ); | ||
| 948 | vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) ); | ||
| 949 | return rho * directionalAlbedo + rhoMultiScatter * ( 1.0 - directionalAlbedo ); | ||
| 950 | } | ||
| 951 | #endif | ||
| 952 | float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { | ||
| 953 | float a2 = pow2( alpha ); | ||
| 954 | float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); | ||
| 955 | float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); | ||
| 956 | return 0.5 / max( gv + gl, EPSILON ); | ||
| 957 | } | ||
| 958 | float D_GGX( const in float alpha, const in float dotNH ) { | ||
| 959 | float a2 = pow2( alpha ); | ||
| 960 | float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; | ||
| 961 | return RECIPROCAL_PI * a2 / pow2( denom ); | ||
| 962 | } | ||
| 963 | #ifdef USE_ANISOTROPY | ||
| 964 | float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { | ||
| 965 | float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); | ||
| 966 | float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); | ||
| 967 | return 0.5 / max( gv + gl, EPSILON ); | ||
| 968 | } | ||
| 969 | float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { | ||
| 970 | float a2 = alphaT * alphaB; | ||
| 971 | highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); | ||
| 972 | highp float v2 = dot( v, v ); | ||
| 973 | float w2 = a2 / v2; | ||
| 974 | return RECIPROCAL_PI * a2 * pow2 ( w2 ); | ||
| 975 | } | ||
| 976 | #endif | ||
| 977 | #ifdef USE_CLEARCOAT | ||
| 978 | vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { | ||
| 979 | vec3 f0 = material.clearcoatF0; | ||
| 980 | float f90 = material.clearcoatF90; | ||
| 981 | float roughness = max( material.clearcoatRoughness, 0.045 ); | ||
| 982 | float alpha = pow2( roughness ); | ||
| 983 | vec3 halfDir = normalize( lightDir + viewDir ); | ||
| 984 | float dotNL = saturate( dot( normal, lightDir ) ); | ||
| 985 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 986 | float dotNH = saturate( dot( normal, halfDir ) ); | ||
| 987 | float dotVH = saturate( dot( viewDir, halfDir ) ); | ||
| 988 | vec3 F = F_Schlick( f0, f90, dotVH ); | ||
| 989 | float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); | ||
| 990 | float D = D_GGX( alpha, dotNH ); | ||
| 991 | return F * ( V * D ); | ||
| 992 | } | ||
| 993 | #endif | ||
| 994 | vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { | ||
| 995 | vec3 f0 = material.specularColorBlended; | ||
| 996 | float f90 = material.specularF90; | ||
| 997 | float roughness = max( material.roughness, 0.045 ); | ||
| 998 | float alpha = pow2( roughness ); | ||
| 999 | vec3 halfDir = normalize( lightDir + viewDir ); | ||
| 1000 | float dotNL = saturate( dot( normal, lightDir ) ); | ||
| 1001 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 1002 | float dotNH = saturate( dot( normal, halfDir ) ); | ||
| 1003 | float dotVH = saturate( dot( viewDir, halfDir ) ); | ||
| 1004 | vec3 F = F_Schlick( f0, f90, dotVH ); | ||
| 1005 | #ifdef USE_IRIDESCENCE | ||
| 1006 | F = mix( F, material.iridescenceFresnel, material.iridescence ); | ||
| 1007 | #endif | ||
| 1008 | #ifdef USE_ANISOTROPY | ||
| 1009 | float dotTL = dot( material.anisotropyT, lightDir ); | ||
| 1010 | float dotTV = dot( material.anisotropyT, viewDir ); | ||
| 1011 | float dotTH = dot( material.anisotropyT, halfDir ); | ||
| 1012 | float dotBL = dot( material.anisotropyB, lightDir ); | ||
| 1013 | float dotBV = dot( material.anisotropyB, viewDir ); | ||
| 1014 | float dotBH = dot( material.anisotropyB, halfDir ); | ||
| 1015 | float alphaT = max( material.alphaT, alpha ); | ||
| 1016 | float V = V_GGX_SmithCorrelated_Anisotropic( alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); | ||
| 1017 | float D = D_GGX_Anisotropic( alphaT, alpha, dotNH, dotTH, dotBH ); | ||
| 1018 | #else | ||
| 1019 | float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); | ||
| 1020 | float D = D_GGX( alpha, dotNH ); | ||
| 1021 | #endif | ||
| 1022 | return F * ( V * D ); | ||
| 1023 | } | ||
| 1024 | vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { | ||
| 1025 | const float LUT_SIZE = 64.0; | ||
| 1026 | const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; | ||
| 1027 | const float LUT_BIAS = 0.5 / LUT_SIZE; | ||
| 1028 | float dotNV = saturate( dot( N, V ) ); | ||
| 1029 | vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); | ||
| 1030 | uv = uv * LUT_SCALE + LUT_BIAS; | ||
| 1031 | return uv; | ||
| 1032 | } | ||
| 1033 | float LTC_ClippedSphereFormFactor( const in vec3 f ) { | ||
| 1034 | float l = length( f ); | ||
| 1035 | return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); | ||
| 1036 | } | ||
| 1037 | vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { | ||
| 1038 | float x = dot( v1, v2 ); | ||
| 1039 | float y = abs( x ); | ||
| 1040 | float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; | ||
| 1041 | float b = 3.4175940 + ( 4.1616724 + y ) * y; | ||
| 1042 | float v = a / b; | ||
| 1043 | float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; | ||
| 1044 | return cross( v1, v2 ) * theta_sintheta; | ||
| 1045 | } | ||
| 1046 | vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { | ||
| 1047 | vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; | ||
| 1048 | vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; | ||
| 1049 | vec3 lightNormal = cross( v1, v2 ); | ||
| 1050 | if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); | ||
| 1051 | vec3 T1, T2; | ||
| 1052 | T1 = normalize( V - N * dot( V, N ) ); | ||
| 1053 | T2 = - cross( N, T1 ); | ||
| 1054 | mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); | ||
| 1055 | vec3 coords[ 4 ]; | ||
| 1056 | coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); | ||
| 1057 | coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); | ||
| 1058 | coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); | ||
| 1059 | coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); | ||
| 1060 | coords[ 0 ] = normalize( coords[ 0 ] ); | ||
| 1061 | coords[ 1 ] = normalize( coords[ 1 ] ); | ||
| 1062 | coords[ 2 ] = normalize( coords[ 2 ] ); | ||
| 1063 | coords[ 3 ] = normalize( coords[ 3 ] ); | ||
| 1064 | vec3 vectorFormFactor = vec3( 0.0 ); | ||
| 1065 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); | ||
| 1066 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); | ||
| 1067 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); | ||
| 1068 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); | ||
| 1069 | float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); | ||
| 1070 | return vec3( result ); | ||
| 1071 | } | ||
| 1072 | #if defined( USE_SHEEN ) | ||
| 1073 | float D_Charlie( float roughness, float dotNH ) { | ||
| 1074 | float alpha = pow2( roughness ); | ||
| 1075 | float invAlpha = 1.0 / alpha; | ||
| 1076 | float cos2h = dotNH * dotNH; | ||
| 1077 | float sin2h = max( 1.0 - cos2h, 0.0078125 ); | ||
| 1078 | return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); | ||
| 1079 | } | ||
| 1080 | float V_Neubelt( float dotNV, float dotNL ) { | ||
| 1081 | return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); | ||
| 1082 | } | ||
| 1083 | vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { | ||
| 1084 | vec3 halfDir = normalize( lightDir + viewDir ); | ||
| 1085 | float dotNL = saturate( dot( normal, lightDir ) ); | ||
| 1086 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 1087 | float dotNH = saturate( dot( normal, halfDir ) ); | ||
| 1088 | float D = D_Charlie( sheenRoughness, dotNH ); | ||
| 1089 | float V = V_Neubelt( dotNV, dotNL ); | ||
| 1090 | return sheenColor * ( D * V ); | ||
| 1091 | } | ||
| 1092 | #endif | ||
| 1093 | float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { | ||
| 1094 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 1095 | float r2 = roughness * roughness; | ||
| 1096 | float rInv = 1.0 / ( roughness + 0.1 ); | ||
| 1097 | float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; | ||
| 1098 | float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; | ||
| 1099 | float DG = exp( a * dotNV + b ); | ||
| 1100 | return saturate( DG ); | ||
| 1101 | } | ||
| 1102 | vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { | ||
| 1103 | float dotNV = saturate( dot( normal, viewDir ) ); | ||
| 1104 | vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; | ||
| 1105 | return specularColor * fab.x + specularF90 * fab.y; | ||
| 1106 | } | ||
| 1107 | #ifdef USE_IRIDESCENCE | ||
| 1108 | void computeMultiscatteringIridescence( const in vec2 fab, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, inout vec3 singleScatter, inout vec3 multiScatter ) { | ||
| 1109 | #else | ||
| 1110 | void computeMultiscattering( const in vec2 fab, const in vec3 specularColor, const in float specularF90, inout vec3 singleScatter, inout vec3 multiScatter ) { | ||
| 1111 | #endif | ||
| 1112 | #ifdef USE_IRIDESCENCE | ||
| 1113 | vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); | ||
| 1114 | #else | ||
| 1115 | vec3 Fr = specularColor; | ||
| 1116 | #endif | ||
| 1117 | vec3 FssEss = Fr * fab.x + specularF90 * fab.y; | ||
| 1118 | float Ess = fab.x + fab.y; | ||
| 1119 | float Ems = 1.0 - Ess; | ||
| 1120 | vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); | ||
| 1121 | singleScatter += FssEss; | ||
| 1122 | multiScatter += Fms * Ems; | ||
| 1123 | } | ||
| 1124 | #if NUM_RECT_AREA_LIGHTS > 0 | ||
| 1125 | void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 1126 | vec3 normal = geometryNormal; | ||
| 1127 | vec3 viewDir = geometryViewDir; | ||
| 1128 | vec3 position = geometryPosition; | ||
| 1129 | vec3 lightPos = rectAreaLight.position; | ||
| 1130 | vec3 halfWidth = rectAreaLight.halfWidth; | ||
| 1131 | vec3 halfHeight = rectAreaLight.halfHeight; | ||
| 1132 | vec3 lightColor = rectAreaLight.color; | ||
| 1133 | float roughness = material.roughness; | ||
| 1134 | vec3 rectCoords[ 4 ]; | ||
| 1135 | rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; | ||
| 1136 | rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; | ||
| 1137 | rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; | ||
| 1138 | vec2 uv = LTC_Uv( normal, viewDir, roughness ); | ||
| 1139 | vec4 t1 = texture2D( ltc_1, uv ); | ||
| 1140 | vec4 t2 = texture2D( ltc_2, uv ); | ||
| 1141 | mat3 mInv = mat3( | ||
| 1142 | vec3( t1.x, 0, t1.y ), | ||
| 1143 | vec3( 0, 1, 0 ), | ||
| 1144 | vec3( t1.z, 0, t1.w ) | ||
| 1145 | ); | ||
| 1146 | vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); | ||
| 1147 | reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); | ||
| 1148 | reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); | ||
| 1149 | #ifdef USE_CLEARCOAT | ||
| 1150 | vec3 Ncc = geometryClearcoatNormal; | ||
| 1151 | vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); | ||
| 1152 | vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); | ||
| 1153 | vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); | ||
| 1154 | mat3 mInvClearcoat = mat3( | ||
| 1155 | vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), | ||
| 1156 | vec3( 0, 1, 0 ), | ||
| 1157 | vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) | ||
| 1158 | ); | ||
| 1159 | vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; | ||
| 1160 | clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); | ||
| 1161 | #endif | ||
| 1162 | } | ||
| 1163 | #endif | ||
| 1164 | void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 1165 | float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); | ||
| 1166 | vec3 irradiance = dotNL * directLight.color; | ||
| 1167 | #ifdef USE_CLEARCOAT | ||
| 1168 | float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); | ||
| 1169 | vec3 ccIrradiance = dotNLcc * directLight.color; | ||
| 1170 | clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); | ||
| 1171 | #endif | ||
| 1172 | #ifdef USE_SHEEN | ||
| 1173 | |||
| 1174 | sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); | ||
| 1175 | |||
| 1176 | float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); | ||
| 1177 | float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); | ||
| 1178 | |||
| 1179 | float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); | ||
| 1180 | |||
| 1181 | irradiance *= sheenEnergyComp; | ||
| 1182 | |||
| 1183 | #endif | ||
| 1184 | vec3 specularBRDF = BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); | ||
| 1185 | #ifdef USE_RETROREFLECTION | ||
| 1186 | vec3 retroViewDir = reflect( - geometryViewDir, geometryNormal ); | ||
| 1187 | vec3 retroSpecularBRDF = BRDF_GGX( directLight.direction, retroViewDir, geometryNormal, material ); | ||
| 1188 | specularBRDF = mix( specularBRDF, retroSpecularBRDF, saturate( material.retroreflectivity ) ); | ||
| 1189 | #endif | ||
| 1190 | reflectedLight.directSpecular += irradiance * specularBRDF * material.multiScatteringCompensation; | ||
| 1191 | vec3 halfDir = normalize( directLight.direction + geometryViewDir ); | ||
| 1192 | float dotVH = saturate( dot( geometryViewDir, halfDir ) ); | ||
| 1193 | vec3 F = F_Schlick( material.specularColor, material.specularF90, dotVH ); | ||
| 1194 | #ifdef USE_RETROREFLECTION | ||
| 1195 | vec3 retroHalfDir = normalize( directLight.direction + retroViewDir ); | ||
| 1196 | float dotRetroVH = saturate( dot( retroViewDir, retroHalfDir ) ); | ||
| 1197 | vec3 retroF = F_Schlick( material.specularColor, material.specularF90, dotRetroVH ); | ||
| 1198 | F = mix( F, retroF, saturate( material.retroreflectivity ) ); | ||
| 1199 | #endif | ||
| 1200 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 1201 | vec3 diffuseBRDF = BRDF_EON( directLight.direction, geometryViewDir, geometryNormal, material.diffuseColor, material.diffuseRoughness ) * ( 1.0 - material.metalness ); | ||
| 1202 | #else | ||
| 1203 | vec3 diffuseBRDF = BRDF_Lambert( material.diffuseContribution ); | ||
| 1204 | #endif | ||
| 1205 | reflectedLight.directDiffuse += irradiance * diffuseBRDF * ( 1.0 - F ); | ||
| 1206 | } | ||
| 1207 | void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { | ||
| 1208 | vec3 singleScattering = vec3( 0.0 ); | ||
| 1209 | vec3 multiScattering = vec3( 0.0 ); | ||
| 1210 | #ifdef USE_IRIDESCENCE | ||
| 1211 | computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScattering, multiScattering ); | ||
| 1212 | #else | ||
| 1213 | computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScattering, multiScattering ); | ||
| 1214 | #endif | ||
| 1215 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 1216 | float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); | ||
| 1217 | vec3 diffuseAlbedo = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness ); | ||
| 1218 | vec3 diffuse = irradiance * RECIPROCAL_PI * diffuseAlbedo * ( 1.0 - singleScattering - multiScattering ); | ||
| 1219 | #else | ||
| 1220 | vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - singleScattering - multiScattering ); | ||
| 1221 | #endif | ||
| 1222 | #ifdef USE_SHEEN | ||
| 1223 | float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); | ||
| 1224 | sheenSpecularIndirect += irradiance * material.sheenColor * sheenAlbedo * RECIPROCAL_PI; | ||
| 1225 | float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; | ||
| 1226 | diffuse *= sheenEnergyComp; | ||
| 1227 | #endif | ||
| 1228 | reflectedLight.indirectDiffuse += diffuse; | ||
| 1229 | } | ||
| 1230 | void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { | ||
| 1231 | #ifdef USE_CLEARCOAT | ||
| 1232 | clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); | ||
| 1233 | #endif | ||
| 1234 | #ifdef USE_SHEEN | ||
| 1235 | sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; | ||
| 1236 | #endif | ||
| 1237 | vec3 singleScatteringDielectric = vec3( 0.0 ); | ||
| 1238 | vec3 multiScatteringDielectric = vec3( 0.0 ); | ||
| 1239 | vec3 singleScatteringMetallic = vec3( 0.0 ); | ||
| 1240 | vec3 multiScatteringMetallic = vec3( 0.0 ); | ||
| 1241 | #ifdef USE_IRIDESCENCE | ||
| 1242 | computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScatteringDielectric, multiScatteringDielectric ); | ||
| 1243 | computeMultiscatteringIridescence( material.dfg, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceF0Metallic, singleScatteringMetallic, multiScatteringMetallic ); | ||
| 1244 | #else | ||
| 1245 | computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScatteringDielectric, multiScatteringDielectric ); | ||
| 1246 | computeMultiscattering( material.dfg, material.diffuseColor, material.specularF90, singleScatteringMetallic, multiScatteringMetallic ); | ||
| 1247 | #endif | ||
| 1248 | vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); | ||
| 1249 | vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); | ||
| 1250 | vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; | ||
| 1251 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 1252 | float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); | ||
| 1253 | vec3 diffuse = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness ) * ( 1.0 - totalScatteringDielectric ); | ||
| 1254 | #else | ||
| 1255 | vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); | ||
| 1256 | #endif | ||
| 1257 | vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; | ||
| 1258 | vec3 indirectSpecular = radiance * singleScattering; | ||
| 1259 | indirectSpecular += multiScattering * cosineWeightedIrradiance; | ||
| 1260 | vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; | ||
| 1261 | #ifdef USE_SHEEN | ||
| 1262 | float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); | ||
| 1263 | float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; | ||
| 1264 | indirectSpecular *= sheenEnergyComp; | ||
| 1265 | indirectDiffuse *= sheenEnergyComp; | ||
| 1266 | #endif | ||
| 1267 | reflectedLight.indirectSpecular += indirectSpecular; | ||
| 1268 | reflectedLight.indirectDiffuse += indirectDiffuse; | ||
| 1269 | } | ||
| 1270 | #define RE_Direct RE_Direct_Physical | ||
| 1271 | #define RE_Direct_RectArea RE_Direct_RectArea_Physical | ||
| 1272 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical | ||
| 1273 | #define RE_IndirectSpecular RE_IndirectSpecular_Physical | ||
| 1274 | float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { | ||
| 1275 | return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); | ||
| 1276 | }`,om=` | ||
| 1277 | vec3 geometryPosition = - vViewPosition; | ||
| 1278 | vec3 geometryNormal = normal; | ||
| 1279 | vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); | ||
| 1280 | vec3 geometryClearcoatNormal = vec3( 0.0 ); | ||
| 1281 | #ifdef USE_CLEARCOAT | ||
| 1282 | geometryClearcoatNormal = clearcoatNormal; | ||
| 1283 | #endif | ||
| 1284 | #ifdef USE_IRIDESCENCE | ||
| 1285 | float dotNVi = saturate( dot( normal, geometryViewDir ) ); | ||
| 1286 | if ( material.iridescenceThickness == 0.0 ) { | ||
| 1287 | material.iridescence = 0.0; | ||
| 1288 | } else { | ||
| 1289 | material.iridescence = saturate( material.iridescence ); | ||
| 1290 | } | ||
| 1291 | if ( material.iridescence > 0.0 ) { | ||
| 1292 | vec3 iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); | ||
| 1293 | vec3 iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); | ||
| 1294 | material.iridescenceFresnel = mix( iridescenceFresnelDielectric, iridescenceFresnelMetallic, material.metalness ); | ||
| 1295 | material.iridescenceF0Dielectric = Schlick_to_F0( iridescenceFresnelDielectric, 1.0, dotNVi ); | ||
| 1296 | material.iridescenceF0Metallic = Schlick_to_F0( iridescenceFresnelMetallic, 1.0, dotNVi ); | ||
| 1297 | } | ||
| 1298 | #endif | ||
| 1299 | #ifdef STANDARD | ||
| 1300 | float dotNVms = saturate( dot( geometryNormal, geometryViewDir ) ); | ||
| 1301 | material.dfg = texture2D( dfgLUT, vec2( material.roughness, dotNVms ) ).rg; | ||
| 1302 | #if ( NUM_SUN_LIGHTS > 0 || NUM_DIR_LIGHTS > 0 || NUM_POINT_LIGHTS > 0 || NUM_SPOT_LIGHTS > 0 ) | ||
| 1303 | float EssMs = material.dfg.x + material.dfg.y; | ||
| 1304 | material.multiScatteringCompensation = 1.0 + material.specularColorBlended * ( 1.0 / EssMs - 1.0 ); | ||
| 1305 | #endif | ||
| 1306 | #endif | ||
| 1307 | IncidentLight directLight; | ||
| 1308 | #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) | ||
| 1309 | PointLight pointLight; | ||
| 1310 | #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 | ||
| 1311 | PointLightShadow pointLightShadow; | ||
| 1312 | #endif | ||
| 1313 | #pragma unroll_loop_start | ||
| 1314 | for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { | ||
| 1315 | pointLight = pointLights[ i ]; | ||
| 1316 | getPointLightInfo( pointLight, geometryPosition, directLight ); | ||
| 1317 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) | ||
| 1318 | pointLightShadow = pointLightShadows[ i ]; | ||
| 1319 | directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; | ||
| 1320 | #endif | ||
| 1321 | RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1322 | } | ||
| 1323 | #pragma unroll_loop_end | ||
| 1324 | #endif | ||
| 1325 | #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) | ||
| 1326 | SpotLight spotLight; | ||
| 1327 | vec4 spotColor; | ||
| 1328 | vec3 spotLightCoord; | ||
| 1329 | bool inSpotLightMap; | ||
| 1330 | #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 | ||
| 1331 | SpotLightShadow spotLightShadow; | ||
| 1332 | #endif | ||
| 1333 | #pragma unroll_loop_start | ||
| 1334 | for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { | ||
| 1335 | spotLight = spotLights[ i ]; | ||
| 1336 | getSpotLightInfo( spotLight, geometryPosition, directLight ); | ||
| 1337 | #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) | ||
| 1338 | #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX | ||
| 1339 | #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) | ||
| 1340 | #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS | ||
| 1341 | #else | ||
| 1342 | #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) | ||
| 1343 | #endif | ||
| 1344 | #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) | ||
| 1345 | spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; | ||
| 1346 | inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); | ||
| 1347 | spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); | ||
| 1348 | directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; | ||
| 1349 | #endif | ||
| 1350 | #undef SPOT_LIGHT_MAP_INDEX | ||
| 1351 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) | ||
| 1352 | spotLightShadow = spotLightShadows[ i ]; | ||
| 1353 | directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; | ||
| 1354 | #endif | ||
| 1355 | RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1356 | } | ||
| 1357 | #pragma unroll_loop_end | ||
| 1358 | #endif | ||
| 1359 | #if ( NUM_SUN_LIGHTS > 0 ) && defined( RE_Direct ) | ||
| 1360 | SunLight sunLight; | ||
| 1361 | #if defined( USE_SHADOWMAP ) && NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 1362 | SunLightShadow sunLightShadow; | ||
| 1363 | #endif | ||
| 1364 | #pragma unroll_loop_start | ||
| 1365 | for ( int i = 0; i < NUM_SUN_LIGHTS; i ++ ) { | ||
| 1366 | sunLight = sunLights[ i ]; | ||
| 1367 | getSunLightInfo( sunLight, directLight ); | ||
| 1368 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SUN_LIGHT_SHADOWS ) | ||
| 1369 | sunLightShadow = sunLightShadows[ i ]; | ||
| 1370 | directLight.color *= ( directLight.visible && receiveShadow ) ? getSunShadow( sunShadowMap[ i ], sunLightShadow, UNROLLED_LOOP_INDEX ) : 1.0; | ||
| 1371 | #endif | ||
| 1372 | RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1373 | } | ||
| 1374 | #pragma unroll_loop_end | ||
| 1375 | #endif | ||
| 1376 | #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) | ||
| 1377 | DirectionalLight directionalLight; | ||
| 1378 | #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 | ||
| 1379 | DirectionalLightShadow directionalLightShadow; | ||
| 1380 | #endif | ||
| 1381 | #pragma unroll_loop_start | ||
| 1382 | for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { | ||
| 1383 | directionalLight = directionalLights[ i ]; | ||
| 1384 | getDirectionalLightInfo( directionalLight, directLight ); | ||
| 1385 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) | ||
| 1386 | directionalLightShadow = directionalLightShadows[ i ]; | ||
| 1387 | directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
| 1388 | #endif | ||
| 1389 | RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1390 | } | ||
| 1391 | #pragma unroll_loop_end | ||
| 1392 | #endif | ||
| 1393 | #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) | ||
| 1394 | RectAreaLight rectAreaLight; | ||
| 1395 | #pragma unroll_loop_start | ||
| 1396 | for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { | ||
| 1397 | rectAreaLight = rectAreaLights[ i ]; | ||
| 1398 | RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1399 | } | ||
| 1400 | #pragma unroll_loop_end | ||
| 1401 | #endif | ||
| 1402 | #if defined( RE_IndirectDiffuse ) | ||
| 1403 | vec3 iblIrradiance = vec3( 0.0 ); | ||
| 1404 | vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); | ||
| 1405 | #if defined( USE_LIGHT_PROBES ) | ||
| 1406 | irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); | ||
| 1407 | #endif | ||
| 1408 | #if ( NUM_HEMI_LIGHTS > 0 ) | ||
| 1409 | #pragma unroll_loop_start | ||
| 1410 | for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { | ||
| 1411 | irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); | ||
| 1412 | } | ||
| 1413 | #pragma unroll_loop_end | ||
| 1414 | #endif | ||
| 1415 | #if NUM_LIGHT_PROBE_GRIDS > 0 | ||
| 1416 | vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; | ||
| 1417 | vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); | ||
| 1418 | int probeGrid = - 1; | ||
| 1419 | #pragma unroll_loop_start | ||
| 1420 | for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) { | ||
| 1421 | if ( isInsideLightProbeGrid( probeWorldPos, probeWorldNormal, probesMin[ i ], probesMax[ i ], probesResolution[ i ] ) ) probeGrid = UNROLLED_LOOP_INDEX; | ||
| 1422 | } | ||
| 1423 | #pragma unroll_loop_end | ||
| 1424 | #pragma unroll_loop_start | ||
| 1425 | for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) { | ||
| 1426 | if ( probeGrid == UNROLLED_LOOP_INDEX ) irradiance += getLightProbeGridIrradiance( probesSH[ i ], probesMin[ i ], probesMax[ i ], probesResolution[ i ], probeWorldPos, probeWorldNormal ); | ||
| 1427 | } | ||
| 1428 | #pragma unroll_loop_end | ||
| 1429 | #endif | ||
| 1430 | #endif | ||
| 1431 | #if defined( RE_IndirectSpecular ) | ||
| 1432 | vec3 radiance = vec3( 0.0 ); | ||
| 1433 | vec3 clearcoatRadiance = vec3( 0.0 ); | ||
| 1434 | #endif`,am=`#if defined( RE_IndirectDiffuse ) | ||
| 1435 | #ifdef USE_LIGHTMAP | ||
| 1436 | vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); | ||
| 1437 | vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; | ||
| 1438 | irradiance += lightMapIrradiance; | ||
| 1439 | #endif | ||
| 1440 | #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_PMREM ) | ||
| 1441 | #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) | ||
| 1442 | iblIrradiance += getIBLIrradiance( geometryNormal ); | ||
| 1443 | #endif | ||
| 1444 | #endif | ||
| 1445 | #endif | ||
| 1446 | #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) | ||
| 1447 | #ifdef USE_ANISOTROPY | ||
| 1448 | vec3 iblRadiance = getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); | ||
| 1449 | #else | ||
| 1450 | vec3 iblRadiance = getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); | ||
| 1451 | #endif | ||
| 1452 | #ifdef USE_RETROREFLECTION | ||
| 1453 | #ifdef USE_ANISOTROPY | ||
| 1454 | vec3 retroIBLRadiance = getIBLAnisotropyRetroRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); | ||
| 1455 | #else | ||
| 1456 | vec3 retroIBLRadiance = getIBLRetroRadiance( geometryViewDir, geometryNormal, material.roughness ); | ||
| 1457 | #endif | ||
| 1458 | iblRadiance = mix( iblRadiance, retroIBLRadiance, saturate( material.retroreflectivity ) ); | ||
| 1459 | #endif | ||
| 1460 | radiance += iblRadiance; | ||
| 1461 | #ifdef USE_CLEARCOAT | ||
| 1462 | clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); | ||
| 1463 | #endif | ||
| 1464 | #endif`,lm=`#if defined( RE_IndirectDiffuse ) | ||
| 1465 | #if defined( LAMBERT ) || defined( PHONG ) | ||
| 1466 | irradiance += iblIrradiance; | ||
| 1467 | #endif | ||
| 1468 | RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1469 | #endif | ||
| 1470 | #if defined( RE_IndirectSpecular ) | ||
| 1471 | RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); | ||
| 1472 | #endif`,cm=`#if NUM_LIGHT_PROBE_GRIDS > 0 | ||
| 1473 | uniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ]; | ||
| 1474 | uniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ]; | ||
| 1475 | uniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ]; | ||
| 1476 | uniform vec3 probesResolution[ NUM_LIGHT_PROBE_GRIDS ]; | ||
| 1477 | bool isInsideLightProbeGrid( vec3 worldPos, vec3 worldNormal, vec3 probesMin, vec3 probesMax, vec3 probesResolution ) { | ||
| 1478 | vec3 spacing = ( probesMax - probesMin ) / probesResolution; | ||
| 1479 | vec3 samplePos = worldPos + worldNormal * spacing * 0.5; | ||
| 1480 | vec3 margin = spacing * 0.01; | ||
| 1481 | return all( greaterThanEqual( samplePos, probesMin - margin ) ) && all( lessThanEqual( samplePos, probesMax + margin ) ); | ||
| 1482 | } | ||
| 1483 | vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 probesMax, vec3 probesResolution, vec3 worldPos, vec3 worldNormal ) { | ||
| 1484 | vec3 res = probesResolution; | ||
| 1485 | vec3 gridRange = probesMax - probesMin; | ||
| 1486 | vec3 probeSpacing = gridRange / res; | ||
| 1487 | vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; | ||
| 1488 | vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.5 / res, 1.0 - 0.5 / res ); | ||
| 1489 | float nz = res.z; | ||
| 1490 | float paddedSlices = nz + 2.0; | ||
| 1491 | float atlasDepth = 7.0 * paddedSlices; | ||
| 1492 | float uvZBase = uvw.z * nz + 1.0; | ||
| 1493 | vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); | ||
| 1494 | vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); | ||
| 1495 | vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); | ||
| 1496 | vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); | ||
| 1497 | vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); | ||
| 1498 | vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); | ||
| 1499 | vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); | ||
| 1500 | vec3 c0 = s0.xyz; | ||
| 1501 | vec3 c1 = vec3( s0.w, s1.xy ); | ||
| 1502 | vec3 c2 = vec3( s1.zw, s2.x ); | ||
| 1503 | vec3 c3 = s2.yzw; | ||
| 1504 | vec3 c4 = s3.xyz; | ||
| 1505 | vec3 c5 = vec3( s3.w, s4.xy ); | ||
| 1506 | vec3 c6 = vec3( s4.zw, s5.x ); | ||
| 1507 | vec3 c7 = s5.yzw; | ||
| 1508 | vec3 c8 = s6.xyz; | ||
| 1509 | float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; | ||
| 1510 | vec3 result = c0 * 0.886227; | ||
| 1511 | result += c1 * 2.0 * 0.511664 * y; | ||
| 1512 | result += c2 * 2.0 * 0.511664 * z; | ||
| 1513 | result += c3 * 2.0 * 0.511664 * x; | ||
| 1514 | result += c4 * 2.0 * 0.429043 * x * y; | ||
| 1515 | result += c5 * 2.0 * 0.429043 * y * z; | ||
| 1516 | result += c6 * ( 0.743125 * z * z - 0.247708 ); | ||
| 1517 | result += c7 * 2.0 * 0.429043 * x * z; | ||
| 1518 | result += c8 * 0.429043 * ( x * x - y * y ); | ||
| 1519 | return max( result, vec3( 0.0 ) ); | ||
| 1520 | } | ||
| 1521 | #endif`,hm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) | ||
| 1522 | gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; | ||
| 1523 | #endif`,um=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) | ||
| 1524 | uniform float logDepthBufFC; | ||
| 1525 | varying float vFragDepth; | ||
| 1526 | varying float vIsPerspective; | ||
| 1527 | #endif`,fm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER | ||
| 1528 | varying float vFragDepth; | ||
| 1529 | varying float vIsPerspective; | ||
| 1530 | #endif`,dm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER | ||
| 1531 | vFragDepth = 1.0 + gl_Position.w; | ||
| 1532 | vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); | ||
| 1533 | #endif`,pm=`#ifdef USE_MAP | ||
| 1534 | vec4 sampledDiffuseColor = texture2D( map, vMapUv ); | ||
| 1535 | #ifdef DECODE_VIDEO_TEXTURE | ||
| 1536 | sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); | ||
| 1537 | #endif | ||
| 1538 | diffuseColor *= sampledDiffuseColor; | ||
| 1539 | #endif`,mm=`#ifdef USE_MAP | ||
| 1540 | uniform sampler2D map; | ||
| 1541 | #endif`,gm=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) | ||
| 1542 | #if defined( USE_POINTS_UV ) | ||
| 1543 | vec2 uv = vUv; | ||
| 1544 | #else | ||
| 1545 | vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; | ||
| 1546 | #endif | ||
| 1547 | #endif | ||
| 1548 | #ifdef USE_MAP | ||
| 1549 | diffuseColor *= texture2D( map, uv ); | ||
| 1550 | #endif | ||
| 1551 | #ifdef USE_ALPHAMAP | ||
| 1552 | diffuseColor.a *= texture2D( alphaMap, uv ).g; | ||
| 1553 | #endif`,_m=`#if defined( USE_POINTS_UV ) | ||
| 1554 | varying vec2 vUv; | ||
| 1555 | #else | ||
| 1556 | #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) | ||
| 1557 | uniform mat3 uvTransform; | ||
| 1558 | #endif | ||
| 1559 | #endif | ||
| 1560 | #ifdef USE_MAP | ||
| 1561 | uniform sampler2D map; | ||
| 1562 | #endif | ||
| 1563 | #ifdef USE_ALPHAMAP | ||
| 1564 | uniform sampler2D alphaMap; | ||
| 1565 | #endif`,xm=`float metalnessFactor = metalness; | ||
| 1566 | #ifdef USE_METALNESSMAP | ||
| 1567 | vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); | ||
| 1568 | metalnessFactor *= texelMetalness.b; | ||
| 1569 | #endif`,vm=`#ifdef USE_METALNESSMAP | ||
| 1570 | uniform sampler2D metalnessMap; | ||
| 1571 | #endif`,ym=`#ifdef USE_INSTANCING_MORPH | ||
| 1572 | float morphTargetInfluences[ MORPHTARGETS_COUNT ]; | ||
| 1573 | float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; | ||
| 1574 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { | ||
| 1575 | morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; | ||
| 1576 | } | ||
| 1577 | #endif`,Mm=`#if defined( USE_MORPHCOLORS ) | ||
| 1578 | #if defined( USE_COLOR_ALPHA ) | ||
| 1579 | vColor *= morphTargetBaseInfluence; | ||
| 1580 | #elif defined( USE_COLOR ) | ||
| 1581 | vColor.rgb *= morphTargetBaseInfluence; | ||
| 1582 | #endif | ||
| 1583 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { | ||
| 1584 | #if defined( USE_COLOR_ALPHA ) | ||
| 1585 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; | ||
| 1586 | #elif defined( USE_COLOR ) | ||
| 1587 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; | ||
| 1588 | #endif | ||
| 1589 | } | ||
| 1590 | #endif`,Sm=`#ifdef USE_MORPHNORMALS | ||
| 1591 | objectNormal *= morphTargetBaseInfluence; | ||
| 1592 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { | ||
| 1593 | if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; | ||
| 1594 | } | ||
| 1595 | #endif`,bm=`#ifdef USE_MORPHTARGETS | ||
| 1596 | #ifndef USE_INSTANCING_MORPH | ||
| 1597 | uniform float morphTargetBaseInfluence; | ||
| 1598 | uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; | ||
| 1599 | #endif | ||
| 1600 | uniform sampler2DArray morphTargetsTexture; | ||
| 1601 | uniform ivec2 morphTargetsTextureSize; | ||
| 1602 | vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { | ||
| 1603 | int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; | ||
| 1604 | int y = texelIndex / morphTargetsTextureSize.x; | ||
| 1605 | int x = texelIndex - y * morphTargetsTextureSize.x; | ||
| 1606 | ivec3 morphUV = ivec3( x, y, morphTargetIndex ); | ||
| 1607 | return texelFetch( morphTargetsTexture, morphUV, 0 ); | ||
| 1608 | } | ||
| 1609 | #endif`,Tm=`#ifdef USE_MORPHTARGETS | ||
| 1610 | transformed *= morphTargetBaseInfluence; | ||
| 1611 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { | ||
| 1612 | if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; | ||
| 1613 | } | ||
| 1614 | #endif`,Am=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; | ||
| 1615 | #ifdef FLAT_SHADED | ||
| 1616 | vec3 fdx = dFdx( vViewPosition ); | ||
| 1617 | vec3 fdy = dFdy( vViewPosition ); | ||
| 1618 | vec3 normal = normalize( cross( fdx, fdy ) ); | ||
| 1619 | #else | ||
| 1620 | vec3 normal = normalize( vNormal ); | ||
| 1621 | #ifdef DOUBLE_SIDED | ||
| 1622 | normal *= faceDirection; | ||
| 1623 | #endif | ||
| 1624 | #endif | ||
| 1625 | #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) | ||
| 1626 | #ifdef USE_TANGENT | ||
| 1627 | mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); | ||
| 1628 | #else | ||
| 1629 | mat3 tbn = getTangentFrame( - vViewPosition, normal, | ||
| 1630 | #if defined( USE_NORMALMAP ) | ||
| 1631 | vNormalMapUv | ||
| 1632 | #elif defined( USE_CLEARCOAT_NORMALMAP ) | ||
| 1633 | vClearcoatNormalMapUv | ||
| 1634 | #else | ||
| 1635 | vUv | ||
| 1636 | #endif | ||
| 1637 | ); | ||
| 1638 | #endif | ||
| 1639 | #ifdef DOUBLE_SIDED | ||
| 1640 | tbn[0] *= faceDirection; | ||
| 1641 | tbn[1] *= faceDirection; | ||
| 1642 | #endif | ||
| 1643 | #endif | ||
| 1644 | #ifdef USE_CLEARCOAT_NORMALMAP | ||
| 1645 | #ifdef USE_TANGENT | ||
| 1646 | mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); | ||
| 1647 | #else | ||
| 1648 | mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); | ||
| 1649 | #endif | ||
| 1650 | #ifdef DOUBLE_SIDED | ||
| 1651 | tbn2[0] *= faceDirection; | ||
| 1652 | tbn2[1] *= faceDirection; | ||
| 1653 | #endif | ||
| 1654 | #endif | ||
| 1655 | vec3 nonPerturbedNormal = normal;`,wm=`#ifdef USE_NORMALMAP_OBJECTSPACE | ||
| 1656 | normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; | ||
| 1657 | #ifdef FLIP_SIDED | ||
| 1658 | normal = - normal; | ||
| 1659 | #endif | ||
| 1660 | #ifdef DOUBLE_SIDED | ||
| 1661 | normal = normal * faceDirection; | ||
| 1662 | #endif | ||
| 1663 | normal = normalize( normalMatrix * normal ); | ||
| 1664 | #elif defined( USE_NORMALMAP_TANGENTSPACE ) | ||
| 1665 | vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; | ||
| 1666 | #if defined( USE_PACKED_NORMALMAP ) | ||
| 1667 | mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); | ||
| 1668 | #endif | ||
| 1669 | mapN.xy *= normalScale; | ||
| 1670 | normal = normalize( tbn * mapN ); | ||
| 1671 | #elif defined( USE_BUMPMAP ) | ||
| 1672 | normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); | ||
| 1673 | #endif`,Em=`#ifndef FLAT_SHADED | ||
| 1674 | varying vec3 vNormal; | ||
| 1675 | #ifdef USE_TANGENT | ||
| 1676 | varying vec3 vTangent; | ||
| 1677 | varying vec3 vBitangent; | ||
| 1678 | #endif | ||
| 1679 | #endif`,Rm=`#ifndef FLAT_SHADED | ||
| 1680 | varying vec3 vNormal; | ||
| 1681 | #ifdef USE_TANGENT | ||
| 1682 | varying vec3 vTangent; | ||
| 1683 | varying vec3 vBitangent; | ||
| 1684 | #endif | ||
| 1685 | #endif`,Cm=`#ifndef FLAT_SHADED | ||
| 1686 | vNormal = normalize( transformedNormal ); | ||
| 1687 | #ifdef USE_TANGENT | ||
| 1688 | vTangent = normalize( transformedTangent ); | ||
| 1689 | vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); | ||
| 1690 | #ifdef FLIP_SIDED | ||
| 1691 | vBitangent = - vBitangent; | ||
| 1692 | #endif | ||
| 1693 | #endif | ||
| 1694 | #endif`,Im=`#ifdef USE_NORMALMAP | ||
| 1695 | uniform sampler2D normalMap; | ||
| 1696 | uniform vec2 normalScale; | ||
| 1697 | #endif | ||
| 1698 | #ifdef USE_NORMALMAP_OBJECTSPACE | ||
| 1699 | uniform mat3 normalMatrix; | ||
| 1700 | #endif | ||
| 1701 | #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) | ||
| 1702 | mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { | ||
| 1703 | vec3 q0 = dFdx( eye_pos.xyz ); | ||
| 1704 | vec3 q1 = dFdy( eye_pos.xyz ); | ||
| 1705 | vec2 st0 = dFdx( uv.st ); | ||
| 1706 | vec2 st1 = dFdy( uv.st ); | ||
| 1707 | vec3 N = surf_norm; | ||
| 1708 | vec3 q1perp = cross( q1, N ); | ||
| 1709 | vec3 q0perp = cross( N, q0 ); | ||
| 1710 | vec3 T = q1perp * st0.x + q0perp * st1.x; | ||
| 1711 | vec3 B = q1perp * st0.y + q0perp * st1.y; | ||
| 1712 | float det = max( dot( T, T ), dot( B, B ) ); | ||
| 1713 | float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); | ||
| 1714 | return mat3( T * scale, B * scale, N ); | ||
| 1715 | } | ||
| 1716 | #endif`,Pm=`#ifdef USE_CLEARCOAT | ||
| 1717 | vec3 clearcoatNormal = nonPerturbedNormal; | ||
| 1718 | #endif`,Lm=`#ifdef USE_CLEARCOAT_NORMALMAP | ||
| 1719 | vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; | ||
| 1720 | clearcoatMapN.xy *= clearcoatNormalScale; | ||
| 1721 | clearcoatNormal = normalize( tbn2 * clearcoatMapN ); | ||
| 1722 | #endif`,Dm=`#ifdef USE_CLEARCOATMAP | ||
| 1723 | uniform sampler2D clearcoatMap; | ||
| 1724 | #endif | ||
| 1725 | #ifdef USE_CLEARCOAT_NORMALMAP | ||
| 1726 | uniform sampler2D clearcoatNormalMap; | ||
| 1727 | uniform vec2 clearcoatNormalScale; | ||
| 1728 | #endif | ||
| 1729 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP | ||
| 1730 | uniform sampler2D clearcoatRoughnessMap; | ||
| 1731 | #endif`,Nm=`#ifdef USE_IRIDESCENCEMAP | ||
| 1732 | uniform sampler2D iridescenceMap; | ||
| 1733 | #endif | ||
| 1734 | #ifdef USE_IRIDESCENCE_THICKNESSMAP | ||
| 1735 | uniform sampler2D iridescenceThicknessMap; | ||
| 1736 | #endif`,Um=`#ifdef OPAQUE | ||
| 1737 | diffuseColor.a = 1.0; | ||
| 1738 | #endif | ||
| 1739 | #ifdef USE_TRANSMISSION | ||
| 1740 | diffuseColor.a *= material.transmissionAlpha; | ||
| 1741 | #endif | ||
| 1742 | gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Fm=`vec3 packNormalToRGB( const in vec3 normal ) { | ||
| 1743 | return normalize( normal ) * 0.5 + 0.5; | ||
| 1744 | } | ||
| 1745 | vec3 unpackRGBToNormal( const in vec3 rgb ) { | ||
| 1746 | return 2.0 * rgb.xyz - 1.0; | ||
| 1747 | } | ||
| 1748 | const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; | ||
| 1749 | const float Inv255 = 1. / 255.; | ||
| 1750 | const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); | ||
| 1751 | const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); | ||
| 1752 | const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); | ||
| 1753 | const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); | ||
| 1754 | vec4 packDepthToRGBA( const in float v ) { | ||
| 1755 | if( v <= 0.0 ) | ||
| 1756 | return vec4( 0., 0., 0., 0. ); | ||
| 1757 | if( v >= 1.0 ) | ||
| 1758 | return vec4( 1., 1., 1., 1. ); | ||
| 1759 | float vuf; | ||
| 1760 | float af = modf( v * PackFactors.a, vuf ); | ||
| 1761 | float bf = modf( vuf * ShiftRight8, vuf ); | ||
| 1762 | float gf = modf( vuf * ShiftRight8, vuf ); | ||
| 1763 | return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); | ||
| 1764 | } | ||
| 1765 | vec3 packDepthToRGB( const in float v ) { | ||
| 1766 | if( v <= 0.0 ) | ||
| 1767 | return vec3( 0., 0., 0. ); | ||
| 1768 | if( v >= 1.0 ) | ||
| 1769 | return vec3( 1., 1., 1. ); | ||
| 1770 | float vuf; | ||
| 1771 | float bf = modf( v * PackFactors.b, vuf ); | ||
| 1772 | float gf = modf( vuf * ShiftRight8, vuf ); | ||
| 1773 | return vec3( vuf * Inv255, gf * PackUpscale, bf ); | ||
| 1774 | } | ||
| 1775 | vec2 packDepthToRG( const in float v ) { | ||
| 1776 | if( v <= 0.0 ) | ||
| 1777 | return vec2( 0., 0. ); | ||
| 1778 | if( v >= 1.0 ) | ||
| 1779 | return vec2( 1., 1. ); | ||
| 1780 | float vuf; | ||
| 1781 | float gf = modf( v * 256., vuf ); | ||
| 1782 | return vec2( vuf * Inv255, gf ); | ||
| 1783 | } | ||
| 1784 | float unpackRGBAToDepth( const in vec4 v ) { | ||
| 1785 | return dot( v, UnpackFactors4 ); | ||
| 1786 | } | ||
| 1787 | float unpackRGBToDepth( const in vec3 v ) { | ||
| 1788 | return dot( v, UnpackFactors3 ); | ||
| 1789 | } | ||
| 1790 | float unpackRGToDepth( const in vec2 v ) { | ||
| 1791 | return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; | ||
| 1792 | } | ||
| 1793 | vec4 pack2HalfToRGBA( const in vec2 v ) { | ||
| 1794 | vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); | ||
| 1795 | return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); | ||
| 1796 | } | ||
| 1797 | vec2 unpackRGBATo2Half( const in vec4 v ) { | ||
| 1798 | return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); | ||
| 1799 | } | ||
| 1800 | float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { | ||
| 1801 | return ( viewZ + near ) / ( near - far ); | ||
| 1802 | } | ||
| 1803 | float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { | ||
| 1804 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1805 | |||
| 1806 | return depth * ( far - near ) - far; | ||
| 1807 | #else | ||
| 1808 | return depth * ( near - far ) - near; | ||
| 1809 | #endif | ||
| 1810 | } | ||
| 1811 | float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { | ||
| 1812 | return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); | ||
| 1813 | } | ||
| 1814 | float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { | ||
| 1815 | |||
| 1816 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1817 | return ( near * far ) / ( ( near - far ) * depth - near ); | ||
| 1818 | #else | ||
| 1819 | return ( near * far ) / ( ( far - near ) * depth - far ); | ||
| 1820 | #endif | ||
| 1821 | }`,Om=`#ifdef PREMULTIPLIED_ALPHA | ||
| 1822 | gl_FragColor.rgb *= gl_FragColor.a; | ||
| 1823 | #endif`,Bm=`vec4 mvPosition = vec4( transformed, 1.0 ); | ||
| 1824 | #ifdef USE_BATCHING | ||
| 1825 | mvPosition = batchingMatrix * mvPosition; | ||
| 1826 | #endif | ||
| 1827 | #ifdef USE_INSTANCING | ||
| 1828 | mvPosition = instanceMatrix * mvPosition; | ||
| 1829 | #endif | ||
| 1830 | mvPosition = modelViewMatrix * mvPosition; | ||
| 1831 | gl_Position = projectionMatrix * mvPosition;`,zm=`#ifdef DITHERING | ||
| 1832 | gl_FragColor.rgb = dithering( gl_FragColor.rgb ); | ||
| 1833 | #endif`,km=`#ifdef DITHERING | ||
| 1834 | vec3 dithering( vec3 color ) { | ||
| 1835 | float grid_position = rand( gl_FragCoord.xy ); | ||
| 1836 | vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); | ||
| 1837 | dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); | ||
| 1838 | return color + dither_shift_RGB; | ||
| 1839 | } | ||
| 1840 | #endif`,Gm=`float roughnessFactor = roughness; | ||
| 1841 | #ifdef USE_ROUGHNESSMAP | ||
| 1842 | vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); | ||
| 1843 | roughnessFactor *= texelRoughness.g; | ||
| 1844 | #endif`,Vm=`#ifdef USE_ROUGHNESSMAP | ||
| 1845 | uniform sampler2D roughnessMap; | ||
| 1846 | #endif`,Hm=`#if NUM_SPOT_LIGHT_COORDS > 0 | ||
| 1847 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; | ||
| 1848 | #endif | ||
| 1849 | #if NUM_SPOT_LIGHT_MAPS > 0 | ||
| 1850 | uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; | ||
| 1851 | #endif | ||
| 1852 | #ifdef USE_SHADOWMAP | ||
| 1853 | #if NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 1854 | #define SUN_LIGHT_CASCADES 2 | ||
| 1855 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1856 | uniform sampler2DShadow sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ]; | ||
| 1857 | #else | ||
| 1858 | uniform sampler2D sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ]; | ||
| 1859 | #endif | ||
| 1860 | uniform mat4 sunShadowMatrix[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ]; | ||
| 1861 | uniform vec4 sunShadowCascade[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ]; | ||
| 1862 | varying vec4 vSunShadowWorldPosition; | ||
| 1863 | varying vec3 vSunShadowWorldNormal; | ||
| 1864 | struct SunLightShadow { | ||
| 1865 | float shadowIntensity; | ||
| 1866 | float shadowBias; | ||
| 1867 | float shadowNormalBias; | ||
| 1868 | float shadowRadius; | ||
| 1869 | vec2 shadowMapSize; | ||
| 1870 | }; | ||
| 1871 | uniform SunLightShadow sunLightShadows[ NUM_SUN_LIGHT_SHADOWS ]; | ||
| 1872 | #endif | ||
| 1873 | #if NUM_DIR_LIGHT_SHADOWS > 0 | ||
| 1874 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1875 | uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 1876 | #else | ||
| 1877 | uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 1878 | #endif | ||
| 1879 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 1880 | struct DirectionalLightShadow { | ||
| 1881 | float shadowIntensity; | ||
| 1882 | float shadowBias; | ||
| 1883 | float shadowNormalBias; | ||
| 1884 | float shadowRadius; | ||
| 1885 | vec2 shadowMapSize; | ||
| 1886 | }; | ||
| 1887 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 1888 | #endif | ||
| 1889 | #if NUM_SPOT_LIGHT_SHADOWS > 0 | ||
| 1890 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1891 | uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; | ||
| 1892 | #else | ||
| 1893 | uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; | ||
| 1894 | #endif | ||
| 1895 | struct SpotLightShadow { | ||
| 1896 | float shadowIntensity; | ||
| 1897 | float shadowBias; | ||
| 1898 | float shadowNormalBias; | ||
| 1899 | float shadowRadius; | ||
| 1900 | vec2 shadowMapSize; | ||
| 1901 | }; | ||
| 1902 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; | ||
| 1903 | #endif | ||
| 1904 | #if NUM_POINT_LIGHT_SHADOWS > 0 | ||
| 1905 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1906 | uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 1907 | #elif defined( SHADOWMAP_TYPE_BASIC ) | ||
| 1908 | uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 1909 | #endif | ||
| 1910 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 1911 | struct PointLightShadow { | ||
| 1912 | float shadowIntensity; | ||
| 1913 | float shadowBias; | ||
| 1914 | float shadowNormalBias; | ||
| 1915 | float shadowRadius; | ||
| 1916 | vec2 shadowMapSize; | ||
| 1917 | float shadowCameraNear; | ||
| 1918 | float shadowCameraFar; | ||
| 1919 | }; | ||
| 1920 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 1921 | #endif | ||
| 1922 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1923 | float interleavedGradientNoise( vec2 position ) { | ||
| 1924 | return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); | ||
| 1925 | } | ||
| 1926 | vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { | ||
| 1927 | const float goldenAngle = 2.399963229728653; | ||
| 1928 | float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); | ||
| 1929 | float theta = float( sampleIndex ) * goldenAngle + phi; | ||
| 1930 | return vec2( cos( theta ), sin( theta ) ) * r; | ||
| 1931 | } | ||
| 1932 | #endif | ||
| 1933 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 1934 | float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { | ||
| 1935 | float shadow = 1.0; | ||
| 1936 | shadowCoord.xyz /= shadowCoord.w; | ||
| 1937 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1938 | shadowCoord.z -= shadowBias; | ||
| 1939 | #else | ||
| 1940 | shadowCoord.z += shadowBias; | ||
| 1941 | #endif | ||
| 1942 | bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; | ||
| 1943 | bool frustumTest = inFrustum && shadowCoord.z <= 1.0; | ||
| 1944 | if ( frustumTest ) { | ||
| 1945 | vec2 texelSize = vec2( 1.0 ) / shadowMapSize; | ||
| 1946 | vec2 radius = shadowRadius * texelSize; | ||
| 1947 | float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; | ||
| 1948 | shadow = ( | ||
| 1949 | texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + | ||
| 1950 | texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + | ||
| 1951 | texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + | ||
| 1952 | texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + | ||
| 1953 | texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) | ||
| 1954 | ) * 0.2; | ||
| 1955 | } | ||
| 1956 | return mix( 1.0, shadow, shadowIntensity ); | ||
| 1957 | } | ||
| 1958 | #elif defined( SHADOWMAP_TYPE_VSM ) | ||
| 1959 | float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { | ||
| 1960 | float shadow = 1.0; | ||
| 1961 | shadowCoord.xyz /= shadowCoord.w; | ||
| 1962 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1963 | shadowCoord.z -= shadowBias; | ||
| 1964 | #else | ||
| 1965 | shadowCoord.z += shadowBias; | ||
| 1966 | #endif | ||
| 1967 | bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; | ||
| 1968 | bool frustumTest = inFrustum && shadowCoord.z <= 1.0; | ||
| 1969 | if ( frustumTest ) { | ||
| 1970 | vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; | ||
| 1971 | float mean = distribution.x; | ||
| 1972 | float variance = distribution.y * distribution.y; | ||
| 1973 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1974 | float hard_shadow = step( mean, shadowCoord.z ); | ||
| 1975 | #else | ||
| 1976 | float hard_shadow = step( shadowCoord.z, mean ); | ||
| 1977 | #endif | ||
| 1978 | |||
| 1979 | if ( hard_shadow == 1.0 ) { | ||
| 1980 | shadow = 1.0; | ||
| 1981 | } else { | ||
| 1982 | variance = max( variance, 0.0000001 ); | ||
| 1983 | float d = shadowCoord.z - mean; | ||
| 1984 | float p_max = variance / ( variance + d * d ); | ||
| 1985 | p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); | ||
| 1986 | shadow = max( hard_shadow, p_max ); | ||
| 1987 | } | ||
| 1988 | } | ||
| 1989 | return mix( 1.0, shadow, shadowIntensity ); | ||
| 1990 | } | ||
| 1991 | #else | ||
| 1992 | float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { | ||
| 1993 | float shadow = 1.0; | ||
| 1994 | shadowCoord.xyz /= shadowCoord.w; | ||
| 1995 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 1996 | shadowCoord.z -= shadowBias; | ||
| 1997 | #else | ||
| 1998 | shadowCoord.z += shadowBias; | ||
| 1999 | #endif | ||
| 2000 | bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; | ||
| 2001 | bool frustumTest = inFrustum && shadowCoord.z <= 1.0; | ||
| 2002 | if ( frustumTest ) { | ||
| 2003 | float depth = texture2D( shadowMap, shadowCoord.xy ).r; | ||
| 2004 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 2005 | shadow = step( depth, shadowCoord.z ); | ||
| 2006 | #else | ||
| 2007 | shadow = step( shadowCoord.z, depth ); | ||
| 2008 | #endif | ||
| 2009 | } | ||
| 2010 | return mix( 1.0, shadow, shadowIntensity ); | ||
| 2011 | } | ||
| 2012 | #endif | ||
| 2013 | #if NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 2014 | float getSunShadow( | ||
| 2015 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 2016 | sampler2DShadow shadowMap, | ||
| 2017 | #else | ||
| 2018 | sampler2D shadowMap, | ||
| 2019 | #endif | ||
| 2020 | SunLightShadow sunLightShadow, | ||
| 2021 | int shadowIndex | ||
| 2022 | ) { | ||
| 2023 | vec4 shadowWorldPosition = vec4( vSunShadowWorldPosition.xyz + vSunShadowWorldNormal * sunLightShadow.shadowNormalBias, 1.0 ); | ||
| 2024 | float viewDepth = vSunShadowWorldPosition.w; | ||
| 2025 | int cascadeOffset = shadowIndex * SUN_LIGHT_CASCADES; | ||
| 2026 | float shadow = 1.0; | ||
| 2027 | for ( int i = SUN_LIGHT_CASCADES - 1; i >= 0; i -- ) { | ||
| 2028 | vec4 cascade = sunShadowCascade[ cascadeOffset + i ]; | ||
| 2029 | if ( viewDepth >= cascade.x && viewDepth < cascade.y ) { | ||
| 2030 | float cascadeShadow = getShadow( | ||
| 2031 | shadowMap, | ||
| 2032 | sunLightShadow.shadowMapSize, | ||
| 2033 | sunLightShadow.shadowIntensity, | ||
| 2034 | sunLightShadow.shadowBias, | ||
| 2035 | sunLightShadow.shadowRadius, | ||
| 2036 | sunShadowMatrix[ cascadeOffset + i ] * shadowWorldPosition | ||
| 2037 | ); | ||
| 2038 | shadow = mix( cascadeShadow, shadow, smoothstep( cascade.z, cascade.y, viewDepth ) ); | ||
| 2039 | } | ||
| 2040 | } | ||
| 2041 | return shadow; | ||
| 2042 | } | ||
| 2043 | #endif | ||
| 2044 | #if NUM_POINT_LIGHT_SHADOWS > 0 | ||
| 2045 | #if defined( SHADOWMAP_TYPE_PCF ) | ||
| 2046 | float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { | ||
| 2047 | float shadow = 1.0; | ||
| 2048 | vec3 lightToPosition = shadowCoord.xyz; | ||
| 2049 | vec3 bd3D = normalize( lightToPosition ); | ||
| 2050 | vec3 absVec = abs( lightToPosition ); | ||
| 2051 | float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); | ||
| 2052 | if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { | ||
| 2053 | float lightDistance = length( lightToPosition ); | ||
| 2054 | float depthRange = shadowCameraFar - shadowCameraNear; | ||
| 2055 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 2056 | float depthA = - shadowCameraNear / depthRange - shadowBias; | ||
| 2057 | float depthB = shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance ); | ||
| 2058 | #else | ||
| 2059 | float depthA = shadowCameraFar / depthRange + shadowBias; | ||
| 2060 | float depthB = - shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance ); | ||
| 2061 | #endif | ||
| 2062 | float texelSize = shadowRadius / shadowMapSize.x; | ||
| 2063 | vec3 absDir = abs( bd3D ); | ||
| 2064 | vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); | ||
| 2065 | tangent = normalize( cross( bd3D, tangent ) ); | ||
| 2066 | vec3 bitangent = cross( bd3D, tangent ); | ||
| 2067 | float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; | ||
| 2068 | shadow = 0.0; | ||
| 2069 | for ( int i = 0; i < 5; i ++ ) { | ||
| 2070 | vec2 offset = vogelDiskSample( i, 5, phi ); | ||
| 2071 | vec3 direction = bd3D + ( tangent * offset.x + bitangent * offset.y ) * texelSize; | ||
| 2072 | vec3 absDirection = abs( direction ); | ||
| 2073 | float dp = depthA + depthB / max( max( absDirection.x, absDirection.y ), absDirection.z ); | ||
| 2074 | shadow += texture( shadowMap, vec4( direction, dp ) ); | ||
| 2075 | } | ||
| 2076 | shadow *= 0.2; | ||
| 2077 | } | ||
| 2078 | return mix( 1.0, shadow, shadowIntensity ); | ||
| 2079 | } | ||
| 2080 | #elif defined( SHADOWMAP_TYPE_BASIC ) | ||
| 2081 | float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { | ||
| 2082 | float shadow = 1.0; | ||
| 2083 | vec3 lightToPosition = shadowCoord.xyz; | ||
| 2084 | vec3 absVec = abs( lightToPosition ); | ||
| 2085 | float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); | ||
| 2086 | if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { | ||
| 2087 | float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); | ||
| 2088 | dp += shadowBias; | ||
| 2089 | vec3 bd3D = normalize( lightToPosition ); | ||
| 2090 | float depth = textureCube( shadowMap, bd3D ).r; | ||
| 2091 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 2092 | depth = 1.0 - depth; | ||
| 2093 | #endif | ||
| 2094 | shadow = step( dp, depth ); | ||
| 2095 | } | ||
| 2096 | return mix( 1.0, shadow, shadowIntensity ); | ||
| 2097 | } | ||
| 2098 | #endif | ||
| 2099 | #endif | ||
| 2100 | #endif`,Wm=`#if NUM_SPOT_LIGHT_COORDS > 0 | ||
| 2101 | uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; | ||
| 2102 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; | ||
| 2103 | #endif | ||
| 2104 | #ifdef USE_SHADOWMAP | ||
| 2105 | #if NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 2106 | varying vec4 vSunShadowWorldPosition; | ||
| 2107 | varying vec3 vSunShadowWorldNormal; | ||
| 2108 | #endif | ||
| 2109 | #if NUM_DIR_LIGHT_SHADOWS > 0 | ||
| 2110 | uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 2111 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 2112 | struct DirectionalLightShadow { | ||
| 2113 | float shadowIntensity; | ||
| 2114 | float shadowBias; | ||
| 2115 | float shadowNormalBias; | ||
| 2116 | float shadowRadius; | ||
| 2117 | vec2 shadowMapSize; | ||
| 2118 | }; | ||
| 2119 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; | ||
| 2120 | #endif | ||
| 2121 | #if NUM_SPOT_LIGHT_SHADOWS > 0 | ||
| 2122 | struct SpotLightShadow { | ||
| 2123 | float shadowIntensity; | ||
| 2124 | float shadowBias; | ||
| 2125 | float shadowNormalBias; | ||
| 2126 | float shadowRadius; | ||
| 2127 | vec2 shadowMapSize; | ||
| 2128 | }; | ||
| 2129 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; | ||
| 2130 | #endif | ||
| 2131 | #if NUM_POINT_LIGHT_SHADOWS > 0 | ||
| 2132 | uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 2133 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 2134 | struct PointLightShadow { | ||
| 2135 | float shadowIntensity; | ||
| 2136 | float shadowBias; | ||
| 2137 | float shadowNormalBias; | ||
| 2138 | float shadowRadius; | ||
| 2139 | vec2 shadowMapSize; | ||
| 2140 | float shadowCameraNear; | ||
| 2141 | float shadowCameraFar; | ||
| 2142 | }; | ||
| 2143 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; | ||
| 2144 | #endif | ||
| 2145 | #endif`,Xm=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) | ||
| 2146 | #ifdef HAS_NORMAL | ||
| 2147 | vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); | ||
| 2148 | #else | ||
| 2149 | vec3 shadowWorldNormal = vec3( 0.0 ); | ||
| 2150 | #endif | ||
| 2151 | vec4 shadowWorldPosition; | ||
| 2152 | #endif | ||
| 2153 | #if defined( USE_SHADOWMAP ) | ||
| 2154 | #if NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 2155 | vSunShadowWorldPosition = vec4( worldPosition.xyz, - mvPosition.z ); | ||
| 2156 | vSunShadowWorldNormal = shadowWorldNormal; | ||
| 2157 | #endif | ||
| 2158 | #if NUM_DIR_LIGHT_SHADOWS > 0 | ||
| 2159 | #pragma unroll_loop_start | ||
| 2160 | for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { | ||
| 2161 | shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); | ||
| 2162 | vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; | ||
| 2163 | } | ||
| 2164 | #pragma unroll_loop_end | ||
| 2165 | #endif | ||
| 2166 | #if NUM_POINT_LIGHT_SHADOWS > 0 | ||
| 2167 | #pragma unroll_loop_start | ||
| 2168 | for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { | ||
| 2169 | shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); | ||
| 2170 | vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; | ||
| 2171 | } | ||
| 2172 | #pragma unroll_loop_end | ||
| 2173 | #endif | ||
| 2174 | #endif | ||
| 2175 | #if NUM_SPOT_LIGHT_COORDS > 0 | ||
| 2176 | #pragma unroll_loop_start | ||
| 2177 | for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { | ||
| 2178 | shadowWorldPosition = worldPosition; | ||
| 2179 | #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) | ||
| 2180 | shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; | ||
| 2181 | #endif | ||
| 2182 | vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; | ||
| 2183 | } | ||
| 2184 | #pragma unroll_loop_end | ||
| 2185 | #endif`,qm=`float getShadowMask() { | ||
| 2186 | float shadow = 1.0; | ||
| 2187 | #ifdef USE_SHADOWMAP | ||
| 2188 | #if NUM_SUN_LIGHT_SHADOWS > 0 | ||
| 2189 | SunLightShadow sunLight; | ||
| 2190 | #pragma unroll_loop_start | ||
| 2191 | for ( int i = 0; i < NUM_SUN_LIGHT_SHADOWS; i ++ ) { | ||
| 2192 | sunLight = sunLightShadows[ i ]; | ||
| 2193 | shadow *= receiveShadow ? getSunShadow( sunShadowMap[ i ], sunLight, UNROLLED_LOOP_INDEX ) : 1.0; | ||
| 2194 | } | ||
| 2195 | #pragma unroll_loop_end | ||
| 2196 | #endif | ||
| 2197 | #if NUM_DIR_LIGHT_SHADOWS > 0 | ||
| 2198 | DirectionalLightShadow directionalLight; | ||
| 2199 | #pragma unroll_loop_start | ||
| 2200 | for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { | ||
| 2201 | directionalLight = directionalLightShadows[ i ]; | ||
| 2202 | shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
| 2203 | } | ||
| 2204 | #pragma unroll_loop_end | ||
| 2205 | #endif | ||
| 2206 | #if NUM_SPOT_LIGHT_SHADOWS > 0 | ||
| 2207 | SpotLightShadow spotLight; | ||
| 2208 | #pragma unroll_loop_start | ||
| 2209 | for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { | ||
| 2210 | spotLight = spotLightShadows[ i ]; | ||
| 2211 | shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; | ||
| 2212 | } | ||
| 2213 | #pragma unroll_loop_end | ||
| 2214 | #endif | ||
| 2215 | #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) | ||
| 2216 | PointLightShadow pointLight; | ||
| 2217 | #pragma unroll_loop_start | ||
| 2218 | for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { | ||
| 2219 | pointLight = pointLightShadows[ i ]; | ||
| 2220 | shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; | ||
| 2221 | } | ||
| 2222 | #pragma unroll_loop_end | ||
| 2223 | #endif | ||
| 2224 | #endif | ||
| 2225 | return shadow; | ||
| 2226 | }`,Ym=`#ifdef USE_SKINNING | ||
| 2227 | mat4 boneMatX = getBoneMatrix( skinIndex.x ); | ||
| 2228 | mat4 boneMatY = getBoneMatrix( skinIndex.y ); | ||
| 2229 | mat4 boneMatZ = getBoneMatrix( skinIndex.z ); | ||
| 2230 | mat4 boneMatW = getBoneMatrix( skinIndex.w ); | ||
| 2231 | #endif`,Zm=`#ifdef USE_SKINNING | ||
| 2232 | uniform mat4 bindMatrix; | ||
| 2233 | uniform mat4 bindMatrixInverse; | ||
| 2234 | uniform highp sampler2D boneTexture; | ||
| 2235 | mat4 getBoneMatrix( const in float i ) { | ||
| 2236 | int size = textureSize( boneTexture, 0 ).x; | ||
| 2237 | int j = int( i ) * 4; | ||
| 2238 | int x = j % size; | ||
| 2239 | int y = j / size; | ||
| 2240 | vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); | ||
| 2241 | vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); | ||
| 2242 | vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); | ||
| 2243 | vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); | ||
| 2244 | return mat4( v1, v2, v3, v4 ); | ||
| 2245 | } | ||
| 2246 | #endif`,Km=`#ifdef USE_SKINNING | ||
| 2247 | vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); | ||
| 2248 | vec4 skinned = vec4( 0.0 ); | ||
| 2249 | skinned += boneMatX * skinVertex * skinWeight.x; | ||
| 2250 | skinned += boneMatY * skinVertex * skinWeight.y; | ||
| 2251 | skinned += boneMatZ * skinVertex * skinWeight.z; | ||
| 2252 | skinned += boneMatW * skinVertex * skinWeight.w; | ||
| 2253 | transformed = ( bindMatrixInverse * skinned ).xyz; | ||
| 2254 | #endif`,Jm=`#ifdef USE_SKINNING | ||
| 2255 | mat4 skinMatrix = mat4( 0.0 ); | ||
| 2256 | skinMatrix += skinWeight.x * boneMatX; | ||
| 2257 | skinMatrix += skinWeight.y * boneMatY; | ||
| 2258 | skinMatrix += skinWeight.z * boneMatZ; | ||
| 2259 | skinMatrix += skinWeight.w * boneMatW; | ||
| 2260 | skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; | ||
| 2261 | objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; | ||
| 2262 | #ifdef USE_TANGENT | ||
| 2263 | objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; | ||
| 2264 | #endif | ||
| 2265 | #endif`,jm=`float specularStrength; | ||
| 2266 | #ifdef USE_SPECULARMAP | ||
| 2267 | vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); | ||
| 2268 | specularStrength = texelSpecular.r; | ||
| 2269 | #else | ||
| 2270 | specularStrength = 1.0; | ||
| 2271 | #endif`,$m=`#ifdef USE_SPECULARMAP | ||
| 2272 | uniform sampler2D specularMap; | ||
| 2273 | #endif`,Qm=`#if defined( TONE_MAPPING ) | ||
| 2274 | gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); | ||
| 2275 | #endif`,eg=`#ifndef saturate | ||
| 2276 | #define saturate( a ) clamp( a, 0.0, 1.0 ) | ||
| 2277 | #endif | ||
| 2278 | uniform float toneMappingExposure; | ||
| 2279 | vec3 LinearToneMapping( vec3 color ) { | ||
| 2280 | return saturate( toneMappingExposure * color ); | ||
| 2281 | } | ||
| 2282 | vec3 ReinhardToneMapping( vec3 color ) { | ||
| 2283 | color *= toneMappingExposure; | ||
| 2284 | return saturate( color / ( vec3( 1.0 ) + color ) ); | ||
| 2285 | } | ||
| 2286 | vec3 CineonToneMapping( vec3 color ) { | ||
| 2287 | color *= toneMappingExposure; | ||
| 2288 | color = max( vec3( 0.0 ), color - 0.004 ); | ||
| 2289 | return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); | ||
| 2290 | } | ||
| 2291 | vec3 RRTAndODTFit( vec3 v ) { | ||
| 2292 | vec3 a = v * ( v + 0.0245786 ) - 0.000090537; | ||
| 2293 | vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; | ||
| 2294 | return a / b; | ||
| 2295 | } | ||
| 2296 | vec3 ACESFilmicToneMapping( vec3 color ) { | ||
| 2297 | const mat3 ACESInputMat = mat3( | ||
| 2298 | vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), | ||
| 2299 | vec3( 0.04823, 0.01566, 0.83777 ) | ||
| 2300 | ); | ||
| 2301 | const mat3 ACESOutputMat = mat3( | ||
| 2302 | vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), | ||
| 2303 | vec3( -0.07367, -0.00605, 1.07602 ) | ||
| 2304 | ); | ||
| 2305 | color *= toneMappingExposure / 0.6; | ||
| 2306 | color = ACESInputMat * color; | ||
| 2307 | color = RRTAndODTFit( color ); | ||
| 2308 | color = ACESOutputMat * color; | ||
| 2309 | return saturate( color ); | ||
| 2310 | } | ||
| 2311 | const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( | ||
| 2312 | vec3( 1.6605, - 0.1246, - 0.0182 ), | ||
| 2313 | vec3( - 0.5876, 1.1329, - 0.1006 ), | ||
| 2314 | vec3( - 0.0728, - 0.0083, 1.1187 ) | ||
| 2315 | ); | ||
| 2316 | const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( | ||
| 2317 | vec3( 0.6274, 0.0691, 0.0164 ), | ||
| 2318 | vec3( 0.3293, 0.9195, 0.0880 ), | ||
| 2319 | vec3( 0.0433, 0.0113, 0.8956 ) | ||
| 2320 | ); | ||
| 2321 | vec3 agxDefaultContrastApprox( vec3 x ) { | ||
| 2322 | vec3 x2 = x * x; | ||
| 2323 | vec3 x4 = x2 * x2; | ||
| 2324 | return + 15.5 * x4 * x2 | ||
| 2325 | - 40.14 * x4 * x | ||
| 2326 | + 31.96 * x4 | ||
| 2327 | - 6.868 * x2 * x | ||
| 2328 | + 0.4298 * x2 | ||
| 2329 | + 0.1191 * x | ||
| 2330 | - 0.00232; | ||
| 2331 | } | ||
| 2332 | vec3 AgXToneMapping( vec3 color ) { | ||
| 2333 | const mat3 AgXInsetMatrix = mat3( | ||
| 2334 | vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), | ||
| 2335 | vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), | ||
| 2336 | vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) | ||
| 2337 | ); | ||
| 2338 | const mat3 AgXOutsetMatrix = mat3( | ||
| 2339 | vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), | ||
| 2340 | vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), | ||
| 2341 | vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) | ||
| 2342 | ); | ||
| 2343 | const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; | ||
| 2344 | color *= toneMappingExposure; | ||
| 2345 | color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; | ||
| 2346 | color = AgXInsetMatrix * color; | ||
| 2347 | color = max( color, 1e-10 ); color = log2( color ); | ||
| 2348 | color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); | ||
| 2349 | color = clamp( color, 0.0, 1.0 ); | ||
| 2350 | color = agxDefaultContrastApprox( color ); | ||
| 2351 | color = AgXOutsetMatrix * color; | ||
| 2352 | color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); | ||
| 2353 | color = LINEAR_REC2020_TO_LINEAR_SRGB * color; | ||
| 2354 | color = clamp( color, 0.0, 1.0 ); | ||
| 2355 | return color; | ||
| 2356 | } | ||
| 2357 | vec3 NeutralToneMapping( vec3 color ) { | ||
| 2358 | const float StartCompression = 0.8 - 0.04; | ||
| 2359 | const float Desaturation = 0.15; | ||
| 2360 | color *= toneMappingExposure; | ||
| 2361 | float x = min( color.r, min( color.g, color.b ) ); | ||
| 2362 | float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; | ||
| 2363 | color -= offset; | ||
| 2364 | float peak = max( color.r, max( color.g, color.b ) ); | ||
| 2365 | if ( peak < StartCompression ) return color; | ||
| 2366 | float d = 1. - StartCompression; | ||
| 2367 | float newPeak = 1. - d * d / ( peak + d - StartCompression ); | ||
| 2368 | color *= newPeak / peak; | ||
| 2369 | float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); | ||
| 2370 | return mix( color, vec3( newPeak ), g ); | ||
| 2371 | } | ||
| 2372 | vec3 CustomToneMapping( vec3 color ) { return color; }`,tg=`#ifdef USE_TRANSMISSION | ||
| 2373 | material.transmission = transmission; | ||
| 2374 | material.transmissionAlpha = 1.0; | ||
| 2375 | material.thickness = thickness; | ||
| 2376 | material.attenuationDistance = attenuationDistance; | ||
| 2377 | material.attenuationColor = attenuationColor; | ||
| 2378 | #ifdef USE_TRANSMISSIONMAP | ||
| 2379 | material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; | ||
| 2380 | #endif | ||
| 2381 | #ifdef USE_THICKNESSMAP | ||
| 2382 | material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; | ||
| 2383 | #endif | ||
| 2384 | vec3 pos = vWorldPosition; | ||
| 2385 | vec3 v = normalize( cameraPosition - pos ); | ||
| 2386 | vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); | ||
| 2387 | vec4 transmitted = getIBLVolumeRefraction( | ||
| 2388 | n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, | ||
| 2389 | pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, | ||
| 2390 | material.attenuationColor, material.attenuationDistance ); | ||
| 2391 | material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); | ||
| 2392 | totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); | ||
| 2393 | #endif`,ng=`#ifdef USE_TRANSMISSION | ||
| 2394 | uniform float transmission; | ||
| 2395 | uniform float thickness; | ||
| 2396 | uniform float attenuationDistance; | ||
| 2397 | uniform vec3 attenuationColor; | ||
| 2398 | #ifdef USE_TRANSMISSIONMAP | ||
| 2399 | uniform sampler2D transmissionMap; | ||
| 2400 | #endif | ||
| 2401 | #ifdef USE_THICKNESSMAP | ||
| 2402 | uniform sampler2D thicknessMap; | ||
| 2403 | #endif | ||
| 2404 | uniform vec2 transmissionSamplerSize; | ||
| 2405 | uniform sampler2D transmissionSamplerMap; | ||
| 2406 | uniform mat4 modelMatrix; | ||
| 2407 | uniform mat4 projectionMatrix; | ||
| 2408 | varying vec3 vWorldPosition; | ||
| 2409 | float w0( float a ) { | ||
| 2410 | return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); | ||
| 2411 | } | ||
| 2412 | float w1( float a ) { | ||
| 2413 | return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); | ||
| 2414 | } | ||
| 2415 | float w2( float a ){ | ||
| 2416 | return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); | ||
| 2417 | } | ||
| 2418 | float w3( float a ) { | ||
| 2419 | return ( 1.0 / 6.0 ) * ( a * a * a ); | ||
| 2420 | } | ||
| 2421 | float g0( float a ) { | ||
| 2422 | return w0( a ) + w1( a ); | ||
| 2423 | } | ||
| 2424 | float g1( float a ) { | ||
| 2425 | return w2( a ) + w3( a ); | ||
| 2426 | } | ||
| 2427 | float h0( float a ) { | ||
| 2428 | return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); | ||
| 2429 | } | ||
| 2430 | float h1( float a ) { | ||
| 2431 | return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); | ||
| 2432 | } | ||
| 2433 | vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { | ||
| 2434 | uv = uv * texelSize.zw + 0.5; | ||
| 2435 | vec2 iuv = floor( uv ); | ||
| 2436 | vec2 fuv = fract( uv ); | ||
| 2437 | float g0x = g0( fuv.x ); | ||
| 2438 | float g1x = g1( fuv.x ); | ||
| 2439 | float h0x = h0( fuv.x ); | ||
| 2440 | float h1x = h1( fuv.x ); | ||
| 2441 | float h0y = h0( fuv.y ); | ||
| 2442 | float h1y = h1( fuv.y ); | ||
| 2443 | vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; | ||
| 2444 | vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; | ||
| 2445 | vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; | ||
| 2446 | vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; | ||
| 2447 | return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + | ||
| 2448 | g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); | ||
| 2449 | } | ||
| 2450 | vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { | ||
| 2451 | vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); | ||
| 2452 | vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); | ||
| 2453 | vec2 fLodSizeInv = 1.0 / fLodSize; | ||
| 2454 | vec2 cLodSizeInv = 1.0 / cLodSize; | ||
| 2455 | vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); | ||
| 2456 | vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); | ||
| 2457 | return mix( fSample, cSample, fract( lod ) ); | ||
| 2458 | } | ||
| 2459 | vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { | ||
| 2460 | vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); | ||
| 2461 | vec3 modelScale; | ||
| 2462 | modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); | ||
| 2463 | modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); | ||
| 2464 | modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); | ||
| 2465 | return normalize( refractionVector ) * thickness * modelScale; | ||
| 2466 | } | ||
| 2467 | float applyIorToRoughness( const in float roughness, const in float ior ) { | ||
| 2468 | return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); | ||
| 2469 | } | ||
| 2470 | vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { | ||
| 2471 | float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); | ||
| 2472 | return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); | ||
| 2473 | } | ||
| 2474 | vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { | ||
| 2475 | if ( isinf( attenuationDistance ) ) { | ||
| 2476 | return vec3( 1.0 ); | ||
| 2477 | } else { | ||
| 2478 | vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; | ||
| 2479 | vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; | ||
| 2480 | } | ||
| 2481 | } | ||
| 2482 | vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, | ||
| 2483 | const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, | ||
| 2484 | const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, | ||
| 2485 | const in vec3 attenuationColor, const in float attenuationDistance ) { | ||
| 2486 | vec4 transmittedLight; | ||
| 2487 | vec3 transmittance; | ||
| 2488 | #ifdef USE_DISPERSION | ||
| 2489 | float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; | ||
| 2490 | vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); | ||
| 2491 | for ( int i = 0; i < 3; i ++ ) { | ||
| 2492 | vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); | ||
| 2493 | vec3 refractedRayExit = position + transmissionRay; | ||
| 2494 | vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); | ||
| 2495 | vec2 refractionCoords = ndcPos.xy / ndcPos.w; | ||
| 2496 | refractionCoords += 1.0; | ||
| 2497 | refractionCoords /= 2.0; | ||
| 2498 | vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); | ||
| 2499 | transmittedLight[ i ] = transmissionSample[ i ]; | ||
| 2500 | transmittedLight.a += transmissionSample.a; | ||
| 2501 | transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; | ||
| 2502 | } | ||
| 2503 | transmittedLight.a /= 3.0; | ||
| 2504 | #else | ||
| 2505 | vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); | ||
| 2506 | vec3 refractedRayExit = position + transmissionRay; | ||
| 2507 | vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); | ||
| 2508 | vec2 refractionCoords = ndcPos.xy / ndcPos.w; | ||
| 2509 | refractionCoords += 1.0; | ||
| 2510 | refractionCoords /= 2.0; | ||
| 2511 | transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); | ||
| 2512 | transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); | ||
| 2513 | #endif | ||
| 2514 | vec3 attenuatedColor = transmittance * transmittedLight.rgb; | ||
| 2515 | vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); | ||
| 2516 | float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; | ||
| 2517 | return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); | ||
| 2518 | } | ||
| 2519 | #endif`,ig=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) | ||
| 2520 | varying vec2 vUv; | ||
| 2521 | #endif | ||
| 2522 | #ifdef USE_MAP | ||
| 2523 | varying vec2 vMapUv; | ||
| 2524 | #endif | ||
| 2525 | #ifdef USE_ALPHAMAP | ||
| 2526 | varying vec2 vAlphaMapUv; | ||
| 2527 | #endif | ||
| 2528 | #ifdef USE_LIGHTMAP | ||
| 2529 | varying vec2 vLightMapUv; | ||
| 2530 | #endif | ||
| 2531 | #ifdef USE_AOMAP | ||
| 2532 | varying vec2 vAoMapUv; | ||
| 2533 | #endif | ||
| 2534 | #ifdef USE_BUMPMAP | ||
| 2535 | varying vec2 vBumpMapUv; | ||
| 2536 | #endif | ||
| 2537 | #ifdef USE_NORMALMAP | ||
| 2538 | varying vec2 vNormalMapUv; | ||
| 2539 | #endif | ||
| 2540 | #ifdef USE_EMISSIVEMAP | ||
| 2541 | varying vec2 vEmissiveMapUv; | ||
| 2542 | #endif | ||
| 2543 | #ifdef USE_METALNESSMAP | ||
| 2544 | varying vec2 vMetalnessMapUv; | ||
| 2545 | #endif | ||
| 2546 | #ifdef USE_ROUGHNESSMAP | ||
| 2547 | varying vec2 vRoughnessMapUv; | ||
| 2548 | #endif | ||
| 2549 | #ifdef USE_DIFFUSE_ROUGHNESSMAP | ||
| 2550 | varying vec2 vDiffuseRoughnessMapUv; | ||
| 2551 | #endif | ||
| 2552 | #ifdef USE_ANISOTROPYMAP | ||
| 2553 | varying vec2 vAnisotropyMapUv; | ||
| 2554 | #endif | ||
| 2555 | #ifdef USE_CLEARCOATMAP | ||
| 2556 | varying vec2 vClearcoatMapUv; | ||
| 2557 | #endif | ||
| 2558 | #ifdef USE_CLEARCOAT_NORMALMAP | ||
| 2559 | varying vec2 vClearcoatNormalMapUv; | ||
| 2560 | #endif | ||
| 2561 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP | ||
| 2562 | varying vec2 vClearcoatRoughnessMapUv; | ||
| 2563 | #endif | ||
| 2564 | #ifdef USE_IRIDESCENCEMAP | ||
| 2565 | varying vec2 vIridescenceMapUv; | ||
| 2566 | #endif | ||
| 2567 | #ifdef USE_IRIDESCENCE_THICKNESSMAP | ||
| 2568 | varying vec2 vIridescenceThicknessMapUv; | ||
| 2569 | #endif | ||
| 2570 | #ifdef USE_SHEEN_COLORMAP | ||
| 2571 | varying vec2 vSheenColorMapUv; | ||
| 2572 | #endif | ||
| 2573 | #ifdef USE_SHEEN_ROUGHNESSMAP | ||
| 2574 | varying vec2 vSheenRoughnessMapUv; | ||
| 2575 | #endif | ||
| 2576 | #ifdef USE_SPECULARMAP | ||
| 2577 | varying vec2 vSpecularMapUv; | ||
| 2578 | #endif | ||
| 2579 | #ifdef USE_SPECULAR_COLORMAP | ||
| 2580 | varying vec2 vSpecularColorMapUv; | ||
| 2581 | #endif | ||
| 2582 | #ifdef USE_SPECULAR_INTENSITYMAP | ||
| 2583 | varying vec2 vSpecularIntensityMapUv; | ||
| 2584 | #endif | ||
| 2585 | #ifdef USE_TRANSMISSIONMAP | ||
| 2586 | uniform mat3 transmissionMapTransform; | ||
| 2587 | varying vec2 vTransmissionMapUv; | ||
| 2588 | #endif | ||
| 2589 | #ifdef USE_THICKNESSMAP | ||
| 2590 | uniform mat3 thicknessMapTransform; | ||
| 2591 | varying vec2 vThicknessMapUv; | ||
| 2592 | #endif`,sg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) | ||
| 2593 | varying vec2 vUv; | ||
| 2594 | #endif | ||
| 2595 | #ifdef USE_MAP | ||
| 2596 | uniform mat3 mapTransform; | ||
| 2597 | varying vec2 vMapUv; | ||
| 2598 | #endif | ||
| 2599 | #ifdef USE_ALPHAMAP | ||
| 2600 | uniform mat3 alphaMapTransform; | ||
| 2601 | varying vec2 vAlphaMapUv; | ||
| 2602 | #endif | ||
| 2603 | #ifdef USE_LIGHTMAP | ||
| 2604 | uniform mat3 lightMapTransform; | ||
| 2605 | varying vec2 vLightMapUv; | ||
| 2606 | #endif | ||
| 2607 | #ifdef USE_AOMAP | ||
| 2608 | uniform mat3 aoMapTransform; | ||
| 2609 | varying vec2 vAoMapUv; | ||
| 2610 | #endif | ||
| 2611 | #ifdef USE_BUMPMAP | ||
| 2612 | uniform mat3 bumpMapTransform; | ||
| 2613 | varying vec2 vBumpMapUv; | ||
| 2614 | #endif | ||
| 2615 | #ifdef USE_NORMALMAP | ||
| 2616 | uniform mat3 normalMapTransform; | ||
| 2617 | varying vec2 vNormalMapUv; | ||
| 2618 | #endif | ||
| 2619 | #ifdef USE_DISPLACEMENTMAP | ||
| 2620 | uniform mat3 displacementMapTransform; | ||
| 2621 | varying vec2 vDisplacementMapUv; | ||
| 2622 | #endif | ||
| 2623 | #ifdef USE_EMISSIVEMAP | ||
| 2624 | uniform mat3 emissiveMapTransform; | ||
| 2625 | varying vec2 vEmissiveMapUv; | ||
| 2626 | #endif | ||
| 2627 | #ifdef USE_METALNESSMAP | ||
| 2628 | uniform mat3 metalnessMapTransform; | ||
| 2629 | varying vec2 vMetalnessMapUv; | ||
| 2630 | #endif | ||
| 2631 | #ifdef USE_ROUGHNESSMAP | ||
| 2632 | uniform mat3 roughnessMapTransform; | ||
| 2633 | varying vec2 vRoughnessMapUv; | ||
| 2634 | #endif | ||
| 2635 | #ifdef USE_DIFFUSE_ROUGHNESSMAP | ||
| 2636 | uniform mat3 diffuseRoughnessMapTransform; | ||
| 2637 | varying vec2 vDiffuseRoughnessMapUv; | ||
| 2638 | #endif | ||
| 2639 | #ifdef USE_ANISOTROPYMAP | ||
| 2640 | uniform mat3 anisotropyMapTransform; | ||
| 2641 | varying vec2 vAnisotropyMapUv; | ||
| 2642 | #endif | ||
| 2643 | #ifdef USE_CLEARCOATMAP | ||
| 2644 | uniform mat3 clearcoatMapTransform; | ||
| 2645 | varying vec2 vClearcoatMapUv; | ||
| 2646 | #endif | ||
| 2647 | #ifdef USE_CLEARCOAT_NORMALMAP | ||
| 2648 | uniform mat3 clearcoatNormalMapTransform; | ||
| 2649 | varying vec2 vClearcoatNormalMapUv; | ||
| 2650 | #endif | ||
| 2651 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP | ||
| 2652 | uniform mat3 clearcoatRoughnessMapTransform; | ||
| 2653 | varying vec2 vClearcoatRoughnessMapUv; | ||
| 2654 | #endif | ||
| 2655 | #ifdef USE_SHEEN_COLORMAP | ||
| 2656 | uniform mat3 sheenColorMapTransform; | ||
| 2657 | varying vec2 vSheenColorMapUv; | ||
| 2658 | #endif | ||
| 2659 | #ifdef USE_SHEEN_ROUGHNESSMAP | ||
| 2660 | uniform mat3 sheenRoughnessMapTransform; | ||
| 2661 | varying vec2 vSheenRoughnessMapUv; | ||
| 2662 | #endif | ||
| 2663 | #ifdef USE_IRIDESCENCEMAP | ||
| 2664 | uniform mat3 iridescenceMapTransform; | ||
| 2665 | varying vec2 vIridescenceMapUv; | ||
| 2666 | #endif | ||
| 2667 | #ifdef USE_IRIDESCENCE_THICKNESSMAP | ||
| 2668 | uniform mat3 iridescenceThicknessMapTransform; | ||
| 2669 | varying vec2 vIridescenceThicknessMapUv; | ||
| 2670 | #endif | ||
| 2671 | #ifdef USE_SPECULARMAP | ||
| 2672 | uniform mat3 specularMapTransform; | ||
| 2673 | varying vec2 vSpecularMapUv; | ||
| 2674 | #endif | ||
| 2675 | #ifdef USE_SPECULAR_COLORMAP | ||
| 2676 | uniform mat3 specularColorMapTransform; | ||
| 2677 | varying vec2 vSpecularColorMapUv; | ||
| 2678 | #endif | ||
| 2679 | #ifdef USE_SPECULAR_INTENSITYMAP | ||
| 2680 | uniform mat3 specularIntensityMapTransform; | ||
| 2681 | varying vec2 vSpecularIntensityMapUv; | ||
| 2682 | #endif | ||
| 2683 | #ifdef USE_TRANSMISSIONMAP | ||
| 2684 | uniform mat3 transmissionMapTransform; | ||
| 2685 | varying vec2 vTransmissionMapUv; | ||
| 2686 | #endif | ||
| 2687 | #ifdef USE_THICKNESSMAP | ||
| 2688 | uniform mat3 thicknessMapTransform; | ||
| 2689 | varying vec2 vThicknessMapUv; | ||
| 2690 | #endif`,rg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) | ||
| 2691 | vUv = vec3( uv, 1 ).xy; | ||
| 2692 | #endif | ||
| 2693 | #ifdef USE_MAP | ||
| 2694 | vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; | ||
| 2695 | #endif | ||
| 2696 | #ifdef USE_ALPHAMAP | ||
| 2697 | vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; | ||
| 2698 | #endif | ||
| 2699 | #ifdef USE_LIGHTMAP | ||
| 2700 | vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; | ||
| 2701 | #endif | ||
| 2702 | #ifdef USE_AOMAP | ||
| 2703 | vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; | ||
| 2704 | #endif | ||
| 2705 | #ifdef USE_BUMPMAP | ||
| 2706 | vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; | ||
| 2707 | #endif | ||
| 2708 | #ifdef USE_NORMALMAP | ||
| 2709 | vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; | ||
| 2710 | #endif | ||
| 2711 | #ifdef USE_DISPLACEMENTMAP | ||
| 2712 | vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; | ||
| 2713 | #endif | ||
| 2714 | #ifdef USE_EMISSIVEMAP | ||
| 2715 | vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; | ||
| 2716 | #endif | ||
| 2717 | #ifdef USE_METALNESSMAP | ||
| 2718 | vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; | ||
| 2719 | #endif | ||
| 2720 | #ifdef USE_ROUGHNESSMAP | ||
| 2721 | vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; | ||
| 2722 | #endif | ||
| 2723 | #ifdef USE_DIFFUSE_ROUGHNESSMAP | ||
| 2724 | vDiffuseRoughnessMapUv = ( diffuseRoughnessMapTransform * vec3( DIFFUSE_ROUGHNESSMAP_UV, 1 ) ).xy; | ||
| 2725 | #endif | ||
| 2726 | #ifdef USE_ANISOTROPYMAP | ||
| 2727 | vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; | ||
| 2728 | #endif | ||
| 2729 | #ifdef USE_CLEARCOATMAP | ||
| 2730 | vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; | ||
| 2731 | #endif | ||
| 2732 | #ifdef USE_CLEARCOAT_NORMALMAP | ||
| 2733 | vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; | ||
| 2734 | #endif | ||
| 2735 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP | ||
| 2736 | vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; | ||
| 2737 | #endif | ||
| 2738 | #ifdef USE_IRIDESCENCEMAP | ||
| 2739 | vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; | ||
| 2740 | #endif | ||
| 2741 | #ifdef USE_IRIDESCENCE_THICKNESSMAP | ||
| 2742 | vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; | ||
| 2743 | #endif | ||
| 2744 | #ifdef USE_SHEEN_COLORMAP | ||
| 2745 | vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; | ||
| 2746 | #endif | ||
| 2747 | #ifdef USE_SHEEN_ROUGHNESSMAP | ||
| 2748 | vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; | ||
| 2749 | #endif | ||
| 2750 | #ifdef USE_SPECULARMAP | ||
| 2751 | vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; | ||
| 2752 | #endif | ||
| 2753 | #ifdef USE_SPECULAR_COLORMAP | ||
| 2754 | vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; | ||
| 2755 | #endif | ||
| 2756 | #ifdef USE_SPECULAR_INTENSITYMAP | ||
| 2757 | vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; | ||
| 2758 | #endif | ||
| 2759 | #ifdef USE_TRANSMISSIONMAP | ||
| 2760 | vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; | ||
| 2761 | #endif | ||
| 2762 | #ifdef USE_THICKNESSMAP | ||
| 2763 | vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; | ||
| 2764 | #endif`,og=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 | ||
| 2765 | vec4 worldPosition = vec4( transformed, 1.0 ); | ||
| 2766 | #ifdef USE_BATCHING | ||
| 2767 | worldPosition = batchingMatrix * worldPosition; | ||
| 2768 | #endif | ||
| 2769 | #ifdef USE_INSTANCING | ||
| 2770 | worldPosition = instanceMatrix * worldPosition; | ||
| 2771 | #endif | ||
| 2772 | worldPosition = modelMatrix * worldPosition; | ||
| 2773 | #endif`,ag=`varying vec2 vUv; | ||
| 2774 | uniform mat3 uvTransform; | ||
| 2775 | void main() { | ||
| 2776 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy; | ||
| 2777 | gl_Position = vec4( position.xy, 1.0, 1.0 ); | ||
| 2778 | }`,lg=`uniform sampler2D t2D; | ||
| 2779 | uniform float backgroundIntensity; | ||
| 2780 | varying vec2 vUv; | ||
| 2781 | void main() { | ||
| 2782 | vec4 texColor = texture2D( t2D, vUv ); | ||
| 2783 | #ifdef DECODE_VIDEO_TEXTURE | ||
| 2784 | texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); | ||
| 2785 | #endif | ||
| 2786 | texColor.rgb *= backgroundIntensity; | ||
| 2787 | gl_FragColor = texColor; | ||
| 2788 | #include <tonemapping_fragment> | ||
| 2789 | #include <colorspace_fragment> | ||
| 2790 | }`,cg=`varying vec3 vWorldDirection; | ||
| 2791 | #include <common> | ||
| 2792 | void main() { | ||
| 2793 | vWorldDirection = transformDirection( position, modelMatrix ); | ||
| 2794 | #include <begin_vertex> | ||
| 2795 | #include <project_vertex> | ||
| 2796 | gl_Position.z = gl_Position.w; | ||
| 2797 | }`,hg=`uniform float backgroundBlurriness; | ||
| 2798 | uniform float backgroundIntensity; | ||
| 2799 | uniform mat3 backgroundRotation; | ||
| 2800 | varying vec3 vWorldDirection; | ||
| 2801 | #include <envmap_common_pars_fragment> | ||
| 2802 | void main() { | ||
| 2803 | #ifdef ENVMAP_TYPE_PMREM | ||
| 2804 | vec4 texColor = textureLod( envMap, backgroundRotation * vWorldDirection, roughnessToMip( backgroundBlurriness ) ); | ||
| 2805 | #else | ||
| 2806 | vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); | ||
| 2807 | #endif | ||
| 2808 | texColor.rgb *= backgroundIntensity; | ||
| 2809 | gl_FragColor = texColor; | ||
| 2810 | #include <tonemapping_fragment> | ||
| 2811 | #include <colorspace_fragment> | ||
| 2812 | }`,ug=`varying vec3 vWorldDirection; | ||
| 2813 | #include <common> | ||
| 2814 | void main() { | ||
| 2815 | vWorldDirection = transformDirection( position, modelMatrix ); | ||
| 2816 | #include <begin_vertex> | ||
| 2817 | #include <project_vertex> | ||
| 2818 | gl_Position.z = gl_Position.w; | ||
| 2819 | }`,fg=`uniform samplerCube tCube; | ||
| 2820 | uniform float tFlip; | ||
| 2821 | uniform float opacity; | ||
| 2822 | varying vec3 vWorldDirection; | ||
| 2823 | void main() { | ||
| 2824 | vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); | ||
| 2825 | gl_FragColor = texColor; | ||
| 2826 | gl_FragColor.a *= opacity; | ||
| 2827 | #include <tonemapping_fragment> | ||
| 2828 | #include <colorspace_fragment> | ||
| 2829 | }`,dg=`#include <common> | ||
| 2830 | #include <batching_pars_vertex> | ||
| 2831 | #include <uv_pars_vertex> | ||
| 2832 | #include <displacementmap_pars_vertex> | ||
| 2833 | #include <morphtarget_pars_vertex> | ||
| 2834 | #include <skinning_pars_vertex> | ||
| 2835 | #include <logdepthbuf_pars_vertex> | ||
| 2836 | #include <clipping_planes_pars_vertex> | ||
| 2837 | varying vec2 vHighPrecisionZW; | ||
| 2838 | void main() { | ||
| 2839 | #include <uv_vertex> | ||
| 2840 | #include <batching_vertex> | ||
| 2841 | #include <skinbase_vertex> | ||
| 2842 | #include <morphinstance_vertex> | ||
| 2843 | #ifdef USE_DISPLACEMENTMAP | ||
| 2844 | #include <beginnormal_vertex> | ||
| 2845 | #include <morphnormal_vertex> | ||
| 2846 | #include <skinnormal_vertex> | ||
| 2847 | #endif | ||
| 2848 | #include <begin_vertex> | ||
| 2849 | #include <morphtarget_vertex> | ||
| 2850 | #include <skinning_vertex> | ||
| 2851 | #include <displacementmap_vertex> | ||
| 2852 | #include <project_vertex> | ||
| 2853 | #include <logdepthbuf_vertex> | ||
| 2854 | #include <clipping_planes_vertex> | ||
| 2855 | vHighPrecisionZW = gl_Position.zw; | ||
| 2856 | }`,pg=`#if DEPTH_PACKING == 3200 | ||
| 2857 | uniform float opacity; | ||
| 2858 | #endif | ||
| 2859 | #include <common> | ||
| 2860 | #include <packing> | ||
| 2861 | #include <uv_pars_fragment> | ||
| 2862 | #include <map_pars_fragment> | ||
| 2863 | #include <alphamap_pars_fragment> | ||
| 2864 | #include <alphatest_pars_fragment> | ||
| 2865 | #include <alphahash_pars_fragment> | ||
| 2866 | #include <logdepthbuf_pars_fragment> | ||
| 2867 | #include <clipping_planes_pars_fragment> | ||
| 2868 | varying vec2 vHighPrecisionZW; | ||
| 2869 | void main() { | ||
| 2870 | vec4 diffuseColor = vec4( 1.0 ); | ||
| 2871 | #include <clipping_planes_fragment> | ||
| 2872 | #if DEPTH_PACKING == 3200 | ||
| 2873 | diffuseColor.a = opacity; | ||
| 2874 | #endif | ||
| 2875 | #include <map_fragment> | ||
| 2876 | #include <alphamap_fragment> | ||
| 2877 | #include <alphatest_fragment> | ||
| 2878 | #include <alphahash_fragment> | ||
| 2879 | #include <logdepthbuf_fragment> | ||
| 2880 | #ifdef USE_REVERSED_DEPTH_BUFFER | ||
| 2881 | float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; | ||
| 2882 | #else | ||
| 2883 | float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; | ||
| 2884 | #endif | ||
| 2885 | #if DEPTH_PACKING == 3200 | ||
| 2886 | gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); | ||
| 2887 | #elif DEPTH_PACKING == 3201 | ||
| 2888 | gl_FragColor = packDepthToRGBA( fragCoordZ ); | ||
| 2889 | #elif DEPTH_PACKING == 3202 | ||
| 2890 | gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); | ||
| 2891 | #elif DEPTH_PACKING == 3203 | ||
| 2892 | gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); | ||
| 2893 | #endif | ||
| 2894 | }`,mg=`#define DISTANCE | ||
| 2895 | varying vec3 vWorldPosition; | ||
| 2896 | #include <common> | ||
| 2897 | #include <batching_pars_vertex> | ||
| 2898 | #include <uv_pars_vertex> | ||
| 2899 | #include <displacementmap_pars_vertex> | ||
| 2900 | #include <morphtarget_pars_vertex> | ||
| 2901 | #include <skinning_pars_vertex> | ||
| 2902 | #include <clipping_planes_pars_vertex> | ||
| 2903 | void main() { | ||
| 2904 | #include <uv_vertex> | ||
| 2905 | #include <batching_vertex> | ||
| 2906 | #include <skinbase_vertex> | ||
| 2907 | #include <morphinstance_vertex> | ||
| 2908 | #ifdef USE_DISPLACEMENTMAP | ||
| 2909 | #include <beginnormal_vertex> | ||
| 2910 | #include <morphnormal_vertex> | ||
| 2911 | #include <skinnormal_vertex> | ||
| 2912 | #endif | ||
| 2913 | #include <begin_vertex> | ||
| 2914 | #include <morphtarget_vertex> | ||
| 2915 | #include <skinning_vertex> | ||
| 2916 | #include <displacementmap_vertex> | ||
| 2917 | #include <project_vertex> | ||
| 2918 | #include <worldpos_vertex> | ||
| 2919 | #include <clipping_planes_vertex> | ||
| 2920 | vWorldPosition = worldPosition.xyz; | ||
| 2921 | }`,gg=`#define DISTANCE | ||
| 2922 | uniform vec3 referencePosition; | ||
| 2923 | uniform float nearDistance; | ||
| 2924 | uniform float farDistance; | ||
| 2925 | varying vec3 vWorldPosition; | ||
| 2926 | #include <common> | ||
| 2927 | #include <uv_pars_fragment> | ||
| 2928 | #include <map_pars_fragment> | ||
| 2929 | #include <alphamap_pars_fragment> | ||
| 2930 | #include <alphatest_pars_fragment> | ||
| 2931 | #include <alphahash_pars_fragment> | ||
| 2932 | #include <clipping_planes_pars_fragment> | ||
| 2933 | void main() { | ||
| 2934 | vec4 diffuseColor = vec4( 1.0 ); | ||
| 2935 | #include <clipping_planes_fragment> | ||
| 2936 | #include <map_fragment> | ||
| 2937 | #include <alphamap_fragment> | ||
| 2938 | #include <alphatest_fragment> | ||
| 2939 | #include <alphahash_fragment> | ||
| 2940 | float dist = length( vWorldPosition - referencePosition ); | ||
| 2941 | dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); | ||
| 2942 | dist = saturate( dist ); | ||
| 2943 | gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); | ||
| 2944 | }`,_g=`varying vec3 vWorldDirection; | ||
| 2945 | #include <common> | ||
| 2946 | void main() { | ||
| 2947 | vWorldDirection = transformDirection( position, modelMatrix ); | ||
| 2948 | #include <begin_vertex> | ||
| 2949 | #include <project_vertex> | ||
| 2950 | }`,xg=`uniform sampler2D tEquirect; | ||
| 2951 | varying vec3 vWorldDirection; | ||
| 2952 | #include <common> | ||
| 2953 | void main() { | ||
| 2954 | vec3 direction = normalize( vWorldDirection ); | ||
| 2955 | vec2 sampleUV = equirectUv( direction ); | ||
| 2956 | gl_FragColor = texture2D( tEquirect, sampleUV ); | ||
| 2957 | #include <tonemapping_fragment> | ||
| 2958 | #include <colorspace_fragment> | ||
| 2959 | }`,vg=`uniform float scale; | ||
| 2960 | attribute float lineDistance; | ||
| 2961 | varying float vLineDistance; | ||
| 2962 | #include <common> | ||
| 2963 | #include <uv_pars_vertex> | ||
| 2964 | #include <color_pars_vertex> | ||
| 2965 | #include <fog_pars_vertex> | ||
| 2966 | #include <morphtarget_pars_vertex> | ||
| 2967 | #include <logdepthbuf_pars_vertex> | ||
| 2968 | #include <clipping_planes_pars_vertex> | ||
| 2969 | void main() { | ||
| 2970 | vLineDistance = scale * lineDistance; | ||
| 2971 | #include <uv_vertex> | ||
| 2972 | #include <color_vertex> | ||
| 2973 | #include <morphinstance_vertex> | ||
| 2974 | #include <morphcolor_vertex> | ||
| 2975 | #include <begin_vertex> | ||
| 2976 | #include <morphtarget_vertex> | ||
| 2977 | #include <project_vertex> | ||
| 2978 | #include <logdepthbuf_vertex> | ||
| 2979 | #include <clipping_planes_vertex> | ||
| 2980 | #include <fog_vertex> | ||
| 2981 | }`,yg=`uniform vec3 diffuse; | ||
| 2982 | uniform float opacity; | ||
| 2983 | uniform float dashSize; | ||
| 2984 | uniform float totalSize; | ||
| 2985 | varying float vLineDistance; | ||
| 2986 | #include <common> | ||
| 2987 | #include <color_pars_fragment> | ||
| 2988 | #include <uv_pars_fragment> | ||
| 2989 | #include <map_pars_fragment> | ||
| 2990 | #include <fog_pars_fragment> | ||
| 2991 | #include <logdepthbuf_pars_fragment> | ||
| 2992 | #include <clipping_planes_pars_fragment> | ||
| 2993 | void main() { | ||
| 2994 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 2995 | #include <clipping_planes_fragment> | ||
| 2996 | if ( mod( vLineDistance, totalSize ) > dashSize ) { | ||
| 2997 | discard; | ||
| 2998 | } | ||
| 2999 | vec3 outgoingLight = vec3( 0.0 ); | ||
| 3000 | #include <logdepthbuf_fragment> | ||
| 3001 | #include <map_fragment> | ||
| 3002 | #include <color_fragment> | ||
| 3003 | outgoingLight = diffuseColor.rgb; | ||
| 3004 | #include <opaque_fragment> | ||
| 3005 | #include <tonemapping_fragment> | ||
| 3006 | #include <colorspace_fragment> | ||
| 3007 | #include <fog_fragment> | ||
| 3008 | #include <premultiplied_alpha_fragment> | ||
| 3009 | }`,Mg=`#include <common> | ||
| 3010 | #include <batching_pars_vertex> | ||
| 3011 | #include <uv_pars_vertex> | ||
| 3012 | #include <envmap_pars_vertex> | ||
| 3013 | #include <color_pars_vertex> | ||
| 3014 | #include <fog_pars_vertex> | ||
| 3015 | #include <morphtarget_pars_vertex> | ||
| 3016 | #include <skinning_pars_vertex> | ||
| 3017 | #include <logdepthbuf_pars_vertex> | ||
| 3018 | #include <clipping_planes_pars_vertex> | ||
| 3019 | void main() { | ||
| 3020 | #include <uv_vertex> | ||
| 3021 | #include <color_vertex> | ||
| 3022 | #include <morphinstance_vertex> | ||
| 3023 | #include <morphcolor_vertex> | ||
| 3024 | #include <batching_vertex> | ||
| 3025 | #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) | ||
| 3026 | #include <beginnormal_vertex> | ||
| 3027 | #include <morphnormal_vertex> | ||
| 3028 | #include <skinbase_vertex> | ||
| 3029 | #include <skinnormal_vertex> | ||
| 3030 | #include <defaultnormal_vertex> | ||
| 3031 | #endif | ||
| 3032 | #include <begin_vertex> | ||
| 3033 | #include <morphtarget_vertex> | ||
| 3034 | #include <skinning_vertex> | ||
| 3035 | #include <project_vertex> | ||
| 3036 | #include <logdepthbuf_vertex> | ||
| 3037 | #include <clipping_planes_vertex> | ||
| 3038 | #include <worldpos_vertex> | ||
| 3039 | #include <envmap_vertex> | ||
| 3040 | #include <fog_vertex> | ||
| 3041 | }`,Sg=`uniform vec3 diffuse; | ||
| 3042 | uniform float opacity; | ||
| 3043 | #ifndef FLAT_SHADED | ||
| 3044 | varying vec3 vNormal; | ||
| 3045 | #endif | ||
| 3046 | #include <common> | ||
| 3047 | #include <dithering_pars_fragment> | ||
| 3048 | #include <color_pars_fragment> | ||
| 3049 | #include <uv_pars_fragment> | ||
| 3050 | #include <map_pars_fragment> | ||
| 3051 | #include <alphamap_pars_fragment> | ||
| 3052 | #include <alphatest_pars_fragment> | ||
| 3053 | #include <alphahash_pars_fragment> | ||
| 3054 | #include <aomap_pars_fragment> | ||
| 3055 | #include <lightmap_pars_fragment> | ||
| 3056 | #include <envmap_common_pars_fragment> | ||
| 3057 | #include <envmap_pars_fragment> | ||
| 3058 | #include <fog_pars_fragment> | ||
| 3059 | #include <specularmap_pars_fragment> | ||
| 3060 | #include <logdepthbuf_pars_fragment> | ||
| 3061 | #include <clipping_planes_pars_fragment> | ||
| 3062 | void main() { | ||
| 3063 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3064 | #include <clipping_planes_fragment> | ||
| 3065 | #include <logdepthbuf_fragment> | ||
| 3066 | #include <map_fragment> | ||
| 3067 | #include <color_fragment> | ||
| 3068 | #include <alphamap_fragment> | ||
| 3069 | #include <alphatest_fragment> | ||
| 3070 | #include <alphahash_fragment> | ||
| 3071 | #include <specularmap_fragment> | ||
| 3072 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | ||
| 3073 | #ifdef USE_LIGHTMAP | ||
| 3074 | vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); | ||
| 3075 | reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; | ||
| 3076 | #else | ||
| 3077 | reflectedLight.indirectDiffuse += vec3( 1.0 ); | ||
| 3078 | #endif | ||
| 3079 | #include <aomap_fragment> | ||
| 3080 | reflectedLight.indirectDiffuse *= diffuseColor.rgb; | ||
| 3081 | vec3 outgoingLight = reflectedLight.indirectDiffuse; | ||
| 3082 | #include <envmap_fragment> | ||
| 3083 | #include <opaque_fragment> | ||
| 3084 | #include <tonemapping_fragment> | ||
| 3085 | #include <colorspace_fragment> | ||
| 3086 | #include <fog_fragment> | ||
| 3087 | #include <premultiplied_alpha_fragment> | ||
| 3088 | #include <dithering_fragment> | ||
| 3089 | }`,bg=`#define LAMBERT | ||
| 3090 | varying vec3 vViewPosition; | ||
| 3091 | #include <common> | ||
| 3092 | #include <batching_pars_vertex> | ||
| 3093 | #include <uv_pars_vertex> | ||
| 3094 | #include <displacementmap_pars_vertex> | ||
| 3095 | #include <envmap_pars_vertex> | ||
| 3096 | #include <color_pars_vertex> | ||
| 3097 | #include <fog_pars_vertex> | ||
| 3098 | #include <normal_pars_vertex> | ||
| 3099 | #include <morphtarget_pars_vertex> | ||
| 3100 | #include <skinning_pars_vertex> | ||
| 3101 | #include <shadowmap_pars_vertex> | ||
| 3102 | #include <logdepthbuf_pars_vertex> | ||
| 3103 | #include <clipping_planes_pars_vertex> | ||
| 3104 | void main() { | ||
| 3105 | #include <uv_vertex> | ||
| 3106 | #include <color_vertex> | ||
| 3107 | #include <morphinstance_vertex> | ||
| 3108 | #include <morphcolor_vertex> | ||
| 3109 | #include <batching_vertex> | ||
| 3110 | #include <beginnormal_vertex> | ||
| 3111 | #include <morphnormal_vertex> | ||
| 3112 | #include <skinbase_vertex> | ||
| 3113 | #include <skinnormal_vertex> | ||
| 3114 | #include <defaultnormal_vertex> | ||
| 3115 | #include <normal_vertex> | ||
| 3116 | #include <begin_vertex> | ||
| 3117 | #include <morphtarget_vertex> | ||
| 3118 | #include <skinning_vertex> | ||
| 3119 | #include <displacementmap_vertex> | ||
| 3120 | #include <project_vertex> | ||
| 3121 | #include <logdepthbuf_vertex> | ||
| 3122 | #include <clipping_planes_vertex> | ||
| 3123 | vViewPosition = - mvPosition.xyz; | ||
| 3124 | #include <worldpos_vertex> | ||
| 3125 | #include <envmap_vertex> | ||
| 3126 | #include <shadowmap_vertex> | ||
| 3127 | #include <fog_vertex> | ||
| 3128 | }`,Tg=`#define LAMBERT | ||
| 3129 | uniform vec3 diffuse; | ||
| 3130 | uniform vec3 emissive; | ||
| 3131 | uniform float opacity; | ||
| 3132 | #include <common> | ||
| 3133 | #include <dithering_pars_fragment> | ||
| 3134 | #include <color_pars_fragment> | ||
| 3135 | #include <uv_pars_fragment> | ||
| 3136 | #include <map_pars_fragment> | ||
| 3137 | #include <alphamap_pars_fragment> | ||
| 3138 | #include <alphatest_pars_fragment> | ||
| 3139 | #include <alphahash_pars_fragment> | ||
| 3140 | #include <aomap_pars_fragment> | ||
| 3141 | #include <lightmap_pars_fragment> | ||
| 3142 | #include <emissivemap_pars_fragment> | ||
| 3143 | #include <envmap_common_pars_fragment> | ||
| 3144 | #include <envmap_pars_fragment> | ||
| 3145 | #include <envmap_physical_pars_fragment> | ||
| 3146 | #include <fog_pars_fragment> | ||
| 3147 | #include <bsdfs> | ||
| 3148 | #include <lights_pars_begin> | ||
| 3149 | #include <normal_pars_fragment> | ||
| 3150 | #include <lights_lambert_pars_fragment> | ||
| 3151 | #include <shadowmap_pars_fragment> | ||
| 3152 | #include <bumpmap_pars_fragment> | ||
| 3153 | #include <normalmap_pars_fragment> | ||
| 3154 | #include <specularmap_pars_fragment> | ||
| 3155 | #include <logdepthbuf_pars_fragment> | ||
| 3156 | #include <clipping_planes_pars_fragment> | ||
| 3157 | void main() { | ||
| 3158 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3159 | #include <clipping_planes_fragment> | ||
| 3160 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | ||
| 3161 | vec3 totalEmissiveRadiance = emissive; | ||
| 3162 | #include <logdepthbuf_fragment> | ||
| 3163 | #include <map_fragment> | ||
| 3164 | #include <color_fragment> | ||
| 3165 | #include <alphamap_fragment> | ||
| 3166 | #include <alphatest_fragment> | ||
| 3167 | #include <alphahash_fragment> | ||
| 3168 | #include <specularmap_fragment> | ||
| 3169 | #include <normal_fragment_begin> | ||
| 3170 | #include <normal_fragment_maps> | ||
| 3171 | #include <emissivemap_fragment> | ||
| 3172 | #include <lights_lambert_fragment> | ||
| 3173 | #include <lights_fragment_begin> | ||
| 3174 | #include <lights_fragment_maps> | ||
| 3175 | #include <lights_fragment_end> | ||
| 3176 | #include <aomap_fragment> | ||
| 3177 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; | ||
| 3178 | #include <envmap_fragment> | ||
| 3179 | #include <opaque_fragment> | ||
| 3180 | #include <tonemapping_fragment> | ||
| 3181 | #include <colorspace_fragment> | ||
| 3182 | #include <fog_fragment> | ||
| 3183 | #include <premultiplied_alpha_fragment> | ||
| 3184 | #include <dithering_fragment> | ||
| 3185 | }`,Ag=`#define MATCAP | ||
| 3186 | varying vec3 vViewPosition; | ||
| 3187 | #include <common> | ||
| 3188 | #include <batching_pars_vertex> | ||
| 3189 | #include <uv_pars_vertex> | ||
| 3190 | #include <color_pars_vertex> | ||
| 3191 | #include <displacementmap_pars_vertex> | ||
| 3192 | #include <fog_pars_vertex> | ||
| 3193 | #include <normal_pars_vertex> | ||
| 3194 | #include <morphtarget_pars_vertex> | ||
| 3195 | #include <skinning_pars_vertex> | ||
| 3196 | #include <logdepthbuf_pars_vertex> | ||
| 3197 | #include <clipping_planes_pars_vertex> | ||
| 3198 | void main() { | ||
| 3199 | #include <uv_vertex> | ||
| 3200 | #include <color_vertex> | ||
| 3201 | #include <morphinstance_vertex> | ||
| 3202 | #include <morphcolor_vertex> | ||
| 3203 | #include <batching_vertex> | ||
| 3204 | #include <beginnormal_vertex> | ||
| 3205 | #include <morphnormal_vertex> | ||
| 3206 | #include <skinbase_vertex> | ||
| 3207 | #include <skinnormal_vertex> | ||
| 3208 | #include <defaultnormal_vertex> | ||
| 3209 | #include <normal_vertex> | ||
| 3210 | #include <begin_vertex> | ||
| 3211 | #include <morphtarget_vertex> | ||
| 3212 | #include <skinning_vertex> | ||
| 3213 | #include <displacementmap_vertex> | ||
| 3214 | #include <project_vertex> | ||
| 3215 | #include <logdepthbuf_vertex> | ||
| 3216 | #include <clipping_planes_vertex> | ||
| 3217 | #include <fog_vertex> | ||
| 3218 | vViewPosition = - mvPosition.xyz; | ||
| 3219 | }`,wg=`#define MATCAP | ||
| 3220 | uniform vec3 diffuse; | ||
| 3221 | uniform float opacity; | ||
| 3222 | uniform sampler2D matcap; | ||
| 3223 | varying vec3 vViewPosition; | ||
| 3224 | #include <common> | ||
| 3225 | #include <dithering_pars_fragment> | ||
| 3226 | #include <color_pars_fragment> | ||
| 3227 | #include <uv_pars_fragment> | ||
| 3228 | #include <map_pars_fragment> | ||
| 3229 | #include <alphamap_pars_fragment> | ||
| 3230 | #include <alphatest_pars_fragment> | ||
| 3231 | #include <alphahash_pars_fragment> | ||
| 3232 | #include <fog_pars_fragment> | ||
| 3233 | #include <normal_pars_fragment> | ||
| 3234 | #include <bumpmap_pars_fragment> | ||
| 3235 | #include <normalmap_pars_fragment> | ||
| 3236 | #include <logdepthbuf_pars_fragment> | ||
| 3237 | #include <clipping_planes_pars_fragment> | ||
| 3238 | void main() { | ||
| 3239 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3240 | #include <clipping_planes_fragment> | ||
| 3241 | #include <logdepthbuf_fragment> | ||
| 3242 | #include <map_fragment> | ||
| 3243 | #include <color_fragment> | ||
| 3244 | #include <alphamap_fragment> | ||
| 3245 | #include <alphatest_fragment> | ||
| 3246 | #include <alphahash_fragment> | ||
| 3247 | #include <normal_fragment_begin> | ||
| 3248 | #include <normal_fragment_maps> | ||
| 3249 | vec3 viewDir = normalize( vViewPosition ); | ||
| 3250 | vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); | ||
| 3251 | vec3 y = cross( viewDir, x ); | ||
| 3252 | vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; | ||
| 3253 | #ifdef USE_MATCAP | ||
| 3254 | vec4 matcapColor = texture2D( matcap, uv ); | ||
| 3255 | #else | ||
| 3256 | vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); | ||
| 3257 | #endif | ||
| 3258 | vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; | ||
| 3259 | #include <opaque_fragment> | ||
| 3260 | #include <tonemapping_fragment> | ||
| 3261 | #include <colorspace_fragment> | ||
| 3262 | #include <fog_fragment> | ||
| 3263 | #include <premultiplied_alpha_fragment> | ||
| 3264 | #include <dithering_fragment> | ||
| 3265 | }`,Eg=`#define NORMAL | ||
| 3266 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) | ||
| 3267 | varying vec3 vViewPosition; | ||
| 3268 | #endif | ||
| 3269 | #include <common> | ||
| 3270 | #include <batching_pars_vertex> | ||
| 3271 | #include <uv_pars_vertex> | ||
| 3272 | #include <displacementmap_pars_vertex> | ||
| 3273 | #include <normal_pars_vertex> | ||
| 3274 | #include <morphtarget_pars_vertex> | ||
| 3275 | #include <skinning_pars_vertex> | ||
| 3276 | #include <logdepthbuf_pars_vertex> | ||
| 3277 | #include <clipping_planes_pars_vertex> | ||
| 3278 | void main() { | ||
| 3279 | #include <uv_vertex> | ||
| 3280 | #include <batching_vertex> | ||
| 3281 | #include <beginnormal_vertex> | ||
| 3282 | #include <morphinstance_vertex> | ||
| 3283 | #include <morphnormal_vertex> | ||
| 3284 | #include <skinbase_vertex> | ||
| 3285 | #include <skinnormal_vertex> | ||
| 3286 | #include <defaultnormal_vertex> | ||
| 3287 | #include <normal_vertex> | ||
| 3288 | #include <begin_vertex> | ||
| 3289 | #include <morphtarget_vertex> | ||
| 3290 | #include <skinning_vertex> | ||
| 3291 | #include <displacementmap_vertex> | ||
| 3292 | #include <project_vertex> | ||
| 3293 | #include <logdepthbuf_vertex> | ||
| 3294 | #include <clipping_planes_vertex> | ||
| 3295 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) | ||
| 3296 | vViewPosition = - mvPosition.xyz; | ||
| 3297 | #endif | ||
| 3298 | }`,Rg=`#define NORMAL | ||
| 3299 | uniform float opacity; | ||
| 3300 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) | ||
| 3301 | varying vec3 vViewPosition; | ||
| 3302 | #endif | ||
| 3303 | #include <uv_pars_fragment> | ||
| 3304 | #include <normal_pars_fragment> | ||
| 3305 | #include <bumpmap_pars_fragment> | ||
| 3306 | #include <normalmap_pars_fragment> | ||
| 3307 | #include <logdepthbuf_pars_fragment> | ||
| 3308 | #include <clipping_planes_pars_fragment> | ||
| 3309 | void main() { | ||
| 3310 | vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); | ||
| 3311 | #include <clipping_planes_fragment> | ||
| 3312 | #include <logdepthbuf_fragment> | ||
| 3313 | #include <normal_fragment_begin> | ||
| 3314 | #include <normal_fragment_maps> | ||
| 3315 | gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); | ||
| 3316 | #ifdef OPAQUE | ||
| 3317 | gl_FragColor.a = 1.0; | ||
| 3318 | #endif | ||
| 3319 | }`,Cg=`#define PHONG | ||
| 3320 | varying vec3 vViewPosition; | ||
| 3321 | #include <common> | ||
| 3322 | #include <batching_pars_vertex> | ||
| 3323 | #include <uv_pars_vertex> | ||
| 3324 | #include <displacementmap_pars_vertex> | ||
| 3325 | #include <envmap_pars_vertex> | ||
| 3326 | #include <color_pars_vertex> | ||
| 3327 | #include <fog_pars_vertex> | ||
| 3328 | #include <normal_pars_vertex> | ||
| 3329 | #include <morphtarget_pars_vertex> | ||
| 3330 | #include <skinning_pars_vertex> | ||
| 3331 | #include <shadowmap_pars_vertex> | ||
| 3332 | #include <logdepthbuf_pars_vertex> | ||
| 3333 | #include <clipping_planes_pars_vertex> | ||
| 3334 | void main() { | ||
| 3335 | #include <uv_vertex> | ||
| 3336 | #include <color_vertex> | ||
| 3337 | #include <morphcolor_vertex> | ||
| 3338 | #include <batching_vertex> | ||
| 3339 | #include <beginnormal_vertex> | ||
| 3340 | #include <morphinstance_vertex> | ||
| 3341 | #include <morphnormal_vertex> | ||
| 3342 | #include <skinbase_vertex> | ||
| 3343 | #include <skinnormal_vertex> | ||
| 3344 | #include <defaultnormal_vertex> | ||
| 3345 | #include <normal_vertex> | ||
| 3346 | #include <begin_vertex> | ||
| 3347 | #include <morphtarget_vertex> | ||
| 3348 | #include <skinning_vertex> | ||
| 3349 | #include <displacementmap_vertex> | ||
| 3350 | #include <project_vertex> | ||
| 3351 | #include <logdepthbuf_vertex> | ||
| 3352 | #include <clipping_planes_vertex> | ||
| 3353 | vViewPosition = - mvPosition.xyz; | ||
| 3354 | #include <worldpos_vertex> | ||
| 3355 | #include <envmap_vertex> | ||
| 3356 | #include <shadowmap_vertex> | ||
| 3357 | #include <fog_vertex> | ||
| 3358 | }`,Ig=`#define PHONG | ||
| 3359 | uniform vec3 diffuse; | ||
| 3360 | uniform vec3 emissive; | ||
| 3361 | uniform vec3 specular; | ||
| 3362 | uniform float shininess; | ||
| 3363 | uniform float opacity; | ||
| 3364 | #include <common> | ||
| 3365 | #include <dithering_pars_fragment> | ||
| 3366 | #include <color_pars_fragment> | ||
| 3367 | #include <uv_pars_fragment> | ||
| 3368 | #include <map_pars_fragment> | ||
| 3369 | #include <alphamap_pars_fragment> | ||
| 3370 | #include <alphatest_pars_fragment> | ||
| 3371 | #include <alphahash_pars_fragment> | ||
| 3372 | #include <aomap_pars_fragment> | ||
| 3373 | #include <lightmap_pars_fragment> | ||
| 3374 | #include <emissivemap_pars_fragment> | ||
| 3375 | #include <envmap_common_pars_fragment> | ||
| 3376 | #include <envmap_pars_fragment> | ||
| 3377 | #include <envmap_physical_pars_fragment> | ||
| 3378 | #include <fog_pars_fragment> | ||
| 3379 | #include <bsdfs> | ||
| 3380 | #include <lights_pars_begin> | ||
| 3381 | #include <normal_pars_fragment> | ||
| 3382 | #include <lights_phong_pars_fragment> | ||
| 3383 | #include <shadowmap_pars_fragment> | ||
| 3384 | #include <bumpmap_pars_fragment> | ||
| 3385 | #include <normalmap_pars_fragment> | ||
| 3386 | #include <specularmap_pars_fragment> | ||
| 3387 | #include <logdepthbuf_pars_fragment> | ||
| 3388 | #include <clipping_planes_pars_fragment> | ||
| 3389 | void main() { | ||
| 3390 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3391 | #include <clipping_planes_fragment> | ||
| 3392 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | ||
| 3393 | vec3 totalEmissiveRadiance = emissive; | ||
| 3394 | #include <logdepthbuf_fragment> | ||
| 3395 | #include <map_fragment> | ||
| 3396 | #include <color_fragment> | ||
| 3397 | #include <alphamap_fragment> | ||
| 3398 | #include <alphatest_fragment> | ||
| 3399 | #include <alphahash_fragment> | ||
| 3400 | #include <specularmap_fragment> | ||
| 3401 | #include <normal_fragment_begin> | ||
| 3402 | #include <normal_fragment_maps> | ||
| 3403 | #include <emissivemap_fragment> | ||
| 3404 | #include <lights_phong_fragment> | ||
| 3405 | #include <lights_fragment_begin> | ||
| 3406 | #include <lights_fragment_maps> | ||
| 3407 | #include <lights_fragment_end> | ||
| 3408 | #include <aomap_fragment> | ||
| 3409 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; | ||
| 3410 | #include <envmap_fragment> | ||
| 3411 | #include <opaque_fragment> | ||
| 3412 | #include <tonemapping_fragment> | ||
| 3413 | #include <colorspace_fragment> | ||
| 3414 | #include <fog_fragment> | ||
| 3415 | #include <premultiplied_alpha_fragment> | ||
| 3416 | #include <dithering_fragment> | ||
| 3417 | }`,Pg=`#define STANDARD | ||
| 3418 | varying vec3 vViewPosition; | ||
| 3419 | #ifdef USE_TRANSMISSION | ||
| 3420 | varying vec3 vWorldPosition; | ||
| 3421 | #endif | ||
| 3422 | #include <common> | ||
| 3423 | #include <batching_pars_vertex> | ||
| 3424 | #include <uv_pars_vertex> | ||
| 3425 | #include <displacementmap_pars_vertex> | ||
| 3426 | #include <color_pars_vertex> | ||
| 3427 | #include <fog_pars_vertex> | ||
| 3428 | #include <normal_pars_vertex> | ||
| 3429 | #include <morphtarget_pars_vertex> | ||
| 3430 | #include <skinning_pars_vertex> | ||
| 3431 | #include <shadowmap_pars_vertex> | ||
| 3432 | #include <logdepthbuf_pars_vertex> | ||
| 3433 | #include <clipping_planes_pars_vertex> | ||
| 3434 | void main() { | ||
| 3435 | #include <uv_vertex> | ||
| 3436 | #include <color_vertex> | ||
| 3437 | #include <morphinstance_vertex> | ||
| 3438 | #include <morphcolor_vertex> | ||
| 3439 | #include <batching_vertex> | ||
| 3440 | #include <beginnormal_vertex> | ||
| 3441 | #include <morphnormal_vertex> | ||
| 3442 | #include <skinbase_vertex> | ||
| 3443 | #include <skinnormal_vertex> | ||
| 3444 | #include <defaultnormal_vertex> | ||
| 3445 | #include <normal_vertex> | ||
| 3446 | #include <begin_vertex> | ||
| 3447 | #include <morphtarget_vertex> | ||
| 3448 | #include <skinning_vertex> | ||
| 3449 | #include <displacementmap_vertex> | ||
| 3450 | #include <project_vertex> | ||
| 3451 | #include <logdepthbuf_vertex> | ||
| 3452 | #include <clipping_planes_vertex> | ||
| 3453 | vViewPosition = - mvPosition.xyz; | ||
| 3454 | #include <worldpos_vertex> | ||
| 3455 | #include <shadowmap_vertex> | ||
| 3456 | #include <fog_vertex> | ||
| 3457 | #ifdef USE_TRANSMISSION | ||
| 3458 | vWorldPosition = worldPosition.xyz; | ||
| 3459 | #endif | ||
| 3460 | }`,Lg=`#define STANDARD | ||
| 3461 | #ifdef PHYSICAL | ||
| 3462 | #define IOR | ||
| 3463 | #define USE_SPECULAR | ||
| 3464 | #endif | ||
| 3465 | uniform vec3 diffuse; | ||
| 3466 | uniform vec3 emissive; | ||
| 3467 | uniform float roughness; | ||
| 3468 | uniform float metalness; | ||
| 3469 | uniform float opacity; | ||
| 3470 | #ifdef IOR | ||
| 3471 | uniform float ior; | ||
| 3472 | #endif | ||
| 3473 | #ifdef USE_SPECULAR | ||
| 3474 | uniform float specularIntensity; | ||
| 3475 | uniform vec3 specularColor; | ||
| 3476 | #ifdef USE_SPECULAR_COLORMAP | ||
| 3477 | uniform sampler2D specularColorMap; | ||
| 3478 | #endif | ||
| 3479 | #ifdef USE_SPECULAR_INTENSITYMAP | ||
| 3480 | uniform sampler2D specularIntensityMap; | ||
| 3481 | #endif | ||
| 3482 | #endif | ||
| 3483 | #ifdef USE_CLEARCOAT | ||
| 3484 | uniform float clearcoat; | ||
| 3485 | uniform float clearcoatRoughness; | ||
| 3486 | #endif | ||
| 3487 | #ifdef USE_DIFFUSE_ROUGHNESS | ||
| 3488 | uniform float diffuseRoughness; | ||
| 3489 | #ifdef USE_DIFFUSE_ROUGHNESSMAP | ||
| 3490 | uniform sampler2D diffuseRoughnessMap; | ||
| 3491 | #endif | ||
| 3492 | #endif | ||
| 3493 | #ifdef USE_DISPERSION | ||
| 3494 | uniform float dispersion; | ||
| 3495 | #endif | ||
| 3496 | #ifdef USE_RETROREFLECTION | ||
| 3497 | uniform float retroreflectivity; | ||
| 3498 | #endif | ||
| 3499 | #ifdef USE_IRIDESCENCE | ||
| 3500 | uniform float iridescence; | ||
| 3501 | uniform float iridescenceIOR; | ||
| 3502 | uniform float iridescenceThicknessMinimum; | ||
| 3503 | uniform float iridescenceThicknessMaximum; | ||
| 3504 | #endif | ||
| 3505 | #ifdef USE_SHEEN | ||
| 3506 | uniform vec3 sheenColor; | ||
| 3507 | uniform float sheenRoughness; | ||
| 3508 | #ifdef USE_SHEEN_COLORMAP | ||
| 3509 | uniform sampler2D sheenColorMap; | ||
| 3510 | #endif | ||
| 3511 | #ifdef USE_SHEEN_ROUGHNESSMAP | ||
| 3512 | uniform sampler2D sheenRoughnessMap; | ||
| 3513 | #endif | ||
| 3514 | #endif | ||
| 3515 | #ifdef USE_ANISOTROPY | ||
| 3516 | uniform vec2 anisotropyVector; | ||
| 3517 | #ifdef USE_ANISOTROPYMAP | ||
| 3518 | uniform sampler2D anisotropyMap; | ||
| 3519 | #endif | ||
| 3520 | #endif | ||
| 3521 | varying vec3 vViewPosition; | ||
| 3522 | #include <common> | ||
| 3523 | #include <dithering_pars_fragment> | ||
| 3524 | #include <color_pars_fragment> | ||
| 3525 | #include <uv_pars_fragment> | ||
| 3526 | #include <map_pars_fragment> | ||
| 3527 | #include <alphamap_pars_fragment> | ||
| 3528 | #include <alphatest_pars_fragment> | ||
| 3529 | #include <alphahash_pars_fragment> | ||
| 3530 | #include <aomap_pars_fragment> | ||
| 3531 | #include <lightmap_pars_fragment> | ||
| 3532 | #include <emissivemap_pars_fragment> | ||
| 3533 | #include <iridescence_fragment> | ||
| 3534 | #include <envmap_common_pars_fragment> | ||
| 3535 | #include <envmap_physical_pars_fragment> | ||
| 3536 | #include <fog_pars_fragment> | ||
| 3537 | #include <lights_pars_begin> | ||
| 3538 | #include <normal_pars_fragment> | ||
| 3539 | #include <lights_physical_pars_fragment> | ||
| 3540 | #include <transmission_pars_fragment> | ||
| 3541 | #include <shadowmap_pars_fragment> | ||
| 3542 | #include <bumpmap_pars_fragment> | ||
| 3543 | #include <normalmap_pars_fragment> | ||
| 3544 | #include <clearcoat_pars_fragment> | ||
| 3545 | #include <iridescence_pars_fragment> | ||
| 3546 | #include <roughnessmap_pars_fragment> | ||
| 3547 | #include <metalnessmap_pars_fragment> | ||
| 3548 | #include <logdepthbuf_pars_fragment> | ||
| 3549 | #include <clipping_planes_pars_fragment> | ||
| 3550 | void main() { | ||
| 3551 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3552 | #include <clipping_planes_fragment> | ||
| 3553 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | ||
| 3554 | vec3 totalEmissiveRadiance = emissive; | ||
| 3555 | #include <logdepthbuf_fragment> | ||
| 3556 | #include <map_fragment> | ||
| 3557 | #include <color_fragment> | ||
| 3558 | #include <alphamap_fragment> | ||
| 3559 | #include <alphatest_fragment> | ||
| 3560 | #include <alphahash_fragment> | ||
| 3561 | #include <roughnessmap_fragment> | ||
| 3562 | #include <metalnessmap_fragment> | ||
| 3563 | #include <normal_fragment_begin> | ||
| 3564 | #include <normal_fragment_maps> | ||
| 3565 | #include <clearcoat_normal_fragment_begin> | ||
| 3566 | #include <clearcoat_normal_fragment_maps> | ||
| 3567 | #include <emissivemap_fragment> | ||
| 3568 | #include <lights_physical_fragment> | ||
| 3569 | #include <lights_fragment_begin> | ||
| 3570 | #include <lights_fragment_maps> | ||
| 3571 | #include <lights_fragment_end> | ||
| 3572 | #include <aomap_fragment> | ||
| 3573 | vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; | ||
| 3574 | vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; | ||
| 3575 | #include <transmission_fragment> | ||
| 3576 | vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; | ||
| 3577 | #ifdef USE_SHEEN | ||
| 3578 | |||
| 3579 | outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; | ||
| 3580 | |||
| 3581 | #endif | ||
| 3582 | #ifdef USE_CLEARCOAT | ||
| 3583 | float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); | ||
| 3584 | vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); | ||
| 3585 | outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; | ||
| 3586 | #endif | ||
| 3587 | #include <opaque_fragment> | ||
| 3588 | #include <tonemapping_fragment> | ||
| 3589 | #include <colorspace_fragment> | ||
| 3590 | #include <fog_fragment> | ||
| 3591 | #include <premultiplied_alpha_fragment> | ||
| 3592 | #include <dithering_fragment> | ||
| 3593 | }`,Dg=`#define TOON | ||
| 3594 | varying vec3 vViewPosition; | ||
| 3595 | #include <common> | ||
| 3596 | #include <batching_pars_vertex> | ||
| 3597 | #include <uv_pars_vertex> | ||
| 3598 | #include <displacementmap_pars_vertex> | ||
| 3599 | #include <color_pars_vertex> | ||
| 3600 | #include <fog_pars_vertex> | ||
| 3601 | #include <normal_pars_vertex> | ||
| 3602 | #include <morphtarget_pars_vertex> | ||
| 3603 | #include <skinning_pars_vertex> | ||
| 3604 | #include <shadowmap_pars_vertex> | ||
| 3605 | #include <logdepthbuf_pars_vertex> | ||
| 3606 | #include <clipping_planes_pars_vertex> | ||
| 3607 | void main() { | ||
| 3608 | #include <uv_vertex> | ||
| 3609 | #include <color_vertex> | ||
| 3610 | #include <morphinstance_vertex> | ||
| 3611 | #include <morphcolor_vertex> | ||
| 3612 | #include <batching_vertex> | ||
| 3613 | #include <beginnormal_vertex> | ||
| 3614 | #include <morphnormal_vertex> | ||
| 3615 | #include <skinbase_vertex> | ||
| 3616 | #include <skinnormal_vertex> | ||
| 3617 | #include <defaultnormal_vertex> | ||
| 3618 | #include <normal_vertex> | ||
| 3619 | #include <begin_vertex> | ||
| 3620 | #include <morphtarget_vertex> | ||
| 3621 | #include <skinning_vertex> | ||
| 3622 | #include <displacementmap_vertex> | ||
| 3623 | #include <project_vertex> | ||
| 3624 | #include <logdepthbuf_vertex> | ||
| 3625 | #include <clipping_planes_vertex> | ||
| 3626 | vViewPosition = - mvPosition.xyz; | ||
| 3627 | #include <worldpos_vertex> | ||
| 3628 | #include <shadowmap_vertex> | ||
| 3629 | #include <fog_vertex> | ||
| 3630 | }`,Ng=`#define TOON | ||
| 3631 | uniform vec3 diffuse; | ||
| 3632 | uniform vec3 emissive; | ||
| 3633 | uniform float opacity; | ||
| 3634 | #include <common> | ||
| 3635 | #include <dithering_pars_fragment> | ||
| 3636 | #include <color_pars_fragment> | ||
| 3637 | #include <uv_pars_fragment> | ||
| 3638 | #include <map_pars_fragment> | ||
| 3639 | #include <alphamap_pars_fragment> | ||
| 3640 | #include <alphatest_pars_fragment> | ||
| 3641 | #include <alphahash_pars_fragment> | ||
| 3642 | #include <aomap_pars_fragment> | ||
| 3643 | #include <lightmap_pars_fragment> | ||
| 3644 | #include <emissivemap_pars_fragment> | ||
| 3645 | #include <gradientmap_pars_fragment> | ||
| 3646 | #include <fog_pars_fragment> | ||
| 3647 | #include <bsdfs> | ||
| 3648 | #include <lights_pars_begin> | ||
| 3649 | #include <normal_pars_fragment> | ||
| 3650 | #include <lights_toon_pars_fragment> | ||
| 3651 | #include <shadowmap_pars_fragment> | ||
| 3652 | #include <bumpmap_pars_fragment> | ||
| 3653 | #include <normalmap_pars_fragment> | ||
| 3654 | #include <logdepthbuf_pars_fragment> | ||
| 3655 | #include <clipping_planes_pars_fragment> | ||
| 3656 | void main() { | ||
| 3657 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3658 | #include <clipping_planes_fragment> | ||
| 3659 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | ||
| 3660 | vec3 totalEmissiveRadiance = emissive; | ||
| 3661 | #include <logdepthbuf_fragment> | ||
| 3662 | #include <map_fragment> | ||
| 3663 | #include <color_fragment> | ||
| 3664 | #include <alphamap_fragment> | ||
| 3665 | #include <alphatest_fragment> | ||
| 3666 | #include <alphahash_fragment> | ||
| 3667 | #include <normal_fragment_begin> | ||
| 3668 | #include <normal_fragment_maps> | ||
| 3669 | #include <emissivemap_fragment> | ||
| 3670 | #include <lights_toon_fragment> | ||
| 3671 | #include <lights_fragment_begin> | ||
| 3672 | #include <lights_fragment_maps> | ||
| 3673 | #include <lights_fragment_end> | ||
| 3674 | #include <aomap_fragment> | ||
| 3675 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; | ||
| 3676 | #include <opaque_fragment> | ||
| 3677 | #include <tonemapping_fragment> | ||
| 3678 | #include <colorspace_fragment> | ||
| 3679 | #include <fog_fragment> | ||
| 3680 | #include <premultiplied_alpha_fragment> | ||
| 3681 | #include <dithering_fragment> | ||
| 3682 | }`,Ug=`uniform float size; | ||
| 3683 | uniform float scale; | ||
| 3684 | #include <common> | ||
| 3685 | #include <color_pars_vertex> | ||
| 3686 | #include <fog_pars_vertex> | ||
| 3687 | #include <morphtarget_pars_vertex> | ||
| 3688 | #include <logdepthbuf_pars_vertex> | ||
| 3689 | #include <clipping_planes_pars_vertex> | ||
| 3690 | #ifdef USE_POINTS_UV | ||
| 3691 | varying vec2 vUv; | ||
| 3692 | uniform mat3 uvTransform; | ||
| 3693 | #endif | ||
| 3694 | void main() { | ||
| 3695 | #ifdef USE_POINTS_UV | ||
| 3696 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy; | ||
| 3697 | #endif | ||
| 3698 | #include <color_vertex> | ||
| 3699 | #include <morphinstance_vertex> | ||
| 3700 | #include <morphcolor_vertex> | ||
| 3701 | #include <begin_vertex> | ||
| 3702 | #include <morphtarget_vertex> | ||
| 3703 | #include <project_vertex> | ||
| 3704 | gl_PointSize = size; | ||
| 3705 | #ifdef USE_SIZEATTENUATION | ||
| 3706 | bool isPerspective = isPerspectiveMatrix( projectionMatrix ); | ||
| 3707 | if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); | ||
| 3708 | #endif | ||
| 3709 | #include <logdepthbuf_vertex> | ||
| 3710 | #include <clipping_planes_vertex> | ||
| 3711 | #include <worldpos_vertex> | ||
| 3712 | #include <fog_vertex> | ||
| 3713 | }`,Fg=`uniform vec3 diffuse; | ||
| 3714 | uniform float opacity; | ||
| 3715 | #include <common> | ||
| 3716 | #include <color_pars_fragment> | ||
| 3717 | #include <map_particle_pars_fragment> | ||
| 3718 | #include <alphatest_pars_fragment> | ||
| 3719 | #include <alphahash_pars_fragment> | ||
| 3720 | #include <fog_pars_fragment> | ||
| 3721 | #include <logdepthbuf_pars_fragment> | ||
| 3722 | #include <clipping_planes_pars_fragment> | ||
| 3723 | void main() { | ||
| 3724 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3725 | #include <clipping_planes_fragment> | ||
| 3726 | vec3 outgoingLight = vec3( 0.0 ); | ||
| 3727 | #include <logdepthbuf_fragment> | ||
| 3728 | #include <map_particle_fragment> | ||
| 3729 | #include <color_fragment> | ||
| 3730 | #include <alphatest_fragment> | ||
| 3731 | #include <alphahash_fragment> | ||
| 3732 | outgoingLight = diffuseColor.rgb; | ||
| 3733 | #include <opaque_fragment> | ||
| 3734 | #include <tonemapping_fragment> | ||
| 3735 | #include <colorspace_fragment> | ||
| 3736 | #include <fog_fragment> | ||
| 3737 | #include <premultiplied_alpha_fragment> | ||
| 3738 | }`,Og=`#include <common> | ||
| 3739 | #include <batching_pars_vertex> | ||
| 3740 | #include <fog_pars_vertex> | ||
| 3741 | #include <morphtarget_pars_vertex> | ||
| 3742 | #include <skinning_pars_vertex> | ||
| 3743 | #include <logdepthbuf_pars_vertex> | ||
| 3744 | #include <shadowmap_pars_vertex> | ||
| 3745 | void main() { | ||
| 3746 | #include <batching_vertex> | ||
| 3747 | #include <beginnormal_vertex> | ||
| 3748 | #include <morphinstance_vertex> | ||
| 3749 | #include <morphnormal_vertex> | ||
| 3750 | #include <skinbase_vertex> | ||
| 3751 | #include <skinnormal_vertex> | ||
| 3752 | #include <defaultnormal_vertex> | ||
| 3753 | #include <begin_vertex> | ||
| 3754 | #include <morphtarget_vertex> | ||
| 3755 | #include <skinning_vertex> | ||
| 3756 | #include <project_vertex> | ||
| 3757 | #include <logdepthbuf_vertex> | ||
| 3758 | #include <worldpos_vertex> | ||
| 3759 | #include <shadowmap_vertex> | ||
| 3760 | #include <fog_vertex> | ||
| 3761 | }`,Bg=`uniform vec3 color; | ||
| 3762 | uniform float opacity; | ||
| 3763 | #include <common> | ||
| 3764 | #include <fog_pars_fragment> | ||
| 3765 | #include <bsdfs> | ||
| 3766 | #include <lights_pars_begin> | ||
| 3767 | #include <logdepthbuf_pars_fragment> | ||
| 3768 | #include <shadowmap_pars_fragment> | ||
| 3769 | #include <shadowmask_pars_fragment> | ||
| 3770 | void main() { | ||
| 3771 | #include <logdepthbuf_fragment> | ||
| 3772 | gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); | ||
| 3773 | #include <tonemapping_fragment> | ||
| 3774 | #include <colorspace_fragment> | ||
| 3775 | #include <fog_fragment> | ||
| 3776 | #include <premultiplied_alpha_fragment> | ||
| 3777 | }`,zg=`uniform float rotation; | ||
| 3778 | uniform vec2 center; | ||
| 3779 | #include <common> | ||
| 3780 | #include <uv_pars_vertex> | ||
| 3781 | #include <fog_pars_vertex> | ||
| 3782 | #include <logdepthbuf_pars_vertex> | ||
| 3783 | #include <clipping_planes_pars_vertex> | ||
| 3784 | void main() { | ||
| 3785 | #include <uv_vertex> | ||
| 3786 | vec4 mvPosition = modelViewMatrix[ 3 ]; | ||
| 3787 | vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); | ||
| 3788 | #ifndef USE_SIZEATTENUATION | ||
| 3789 | bool isPerspective = isPerspectiveMatrix( projectionMatrix ); | ||
| 3790 | if ( isPerspective ) scale *= - mvPosition.z; | ||
| 3791 | #endif | ||
| 3792 | vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; | ||
| 3793 | vec2 rotatedPosition; | ||
| 3794 | rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; | ||
| 3795 | rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; | ||
| 3796 | mvPosition.xy += rotatedPosition; | ||
| 3797 | gl_Position = projectionMatrix * mvPosition; | ||
| 3798 | #include <logdepthbuf_vertex> | ||
| 3799 | #include <clipping_planes_vertex> | ||
| 3800 | #include <fog_vertex> | ||
| 3801 | }`,kg=`uniform vec3 diffuse; | ||
| 3802 | uniform float opacity; | ||
| 3803 | #include <common> | ||
| 3804 | #include <uv_pars_fragment> | ||
| 3805 | #include <map_pars_fragment> | ||
| 3806 | #include <alphamap_pars_fragment> | ||
| 3807 | #include <alphatest_pars_fragment> | ||
| 3808 | #include <alphahash_pars_fragment> | ||
| 3809 | #include <fog_pars_fragment> | ||
| 3810 | #include <logdepthbuf_pars_fragment> | ||
| 3811 | #include <clipping_planes_pars_fragment> | ||
| 3812 | void main() { | ||
| 3813 | vec4 diffuseColor = vec4( diffuse, opacity ); | ||
| 3814 | #include <clipping_planes_fragment> | ||
| 3815 | vec3 outgoingLight = vec3( 0.0 ); | ||
| 3816 | #include <logdepthbuf_fragment> | ||
| 3817 | #include <map_fragment> | ||
| 3818 | #include <alphamap_fragment> | ||
| 3819 | #include <alphatest_fragment> | ||
| 3820 | #include <alphahash_fragment> | ||
| 3821 | outgoingLight = diffuseColor.rgb; | ||
| 3822 | #include <opaque_fragment> | ||
| 3823 | #include <tonemapping_fragment> | ||
| 3824 | #include <colorspace_fragment> | ||
| 3825 | #include <fog_fragment> | ||
| 3826 | }`,et={alphahash_fragment:lp,alphahash_pars_fragment:cp,alphamap_fragment:hp,alphamap_pars_fragment:up,alphatest_fragment:fp,alphatest_pars_fragment:dp,aomap_fragment:pp,aomap_pars_fragment:mp,batching_pars_vertex:gp,batching_vertex:_p,begin_vertex:xp,beginnormal_vertex:vp,bsdfs:yp,iridescence_fragment:Mp,bumpmap_pars_fragment:Sp,clipping_planes_fragment:bp,clipping_planes_pars_fragment:Tp,clipping_planes_pars_vertex:Ap,clipping_planes_vertex:wp,color_fragment:Ep,color_pars_fragment:Rp,color_pars_vertex:Cp,color_vertex:Ip,common:Pp,defaultnormal_vertex:Lp,displacementmap_pars_vertex:Dp,displacementmap_vertex:Np,emissivemap_fragment:Up,emissivemap_pars_fragment:Fp,colorspace_fragment:Op,colorspace_pars_fragment:Bp,envmap_fragment:zp,envmap_common_pars_fragment:kp,envmap_pars_fragment:Gp,envmap_pars_vertex:Vp,envmap_physical_pars_fragment:Qp,envmap_vertex:Hp,fog_vertex:Wp,fog_pars_vertex:Xp,fog_fragment:qp,fog_pars_fragment:Yp,gradientmap_pars_fragment:Zp,lightmap_pars_fragment:Kp,lights_lambert_fragment:Jp,lights_lambert_pars_fragment:jp,lights_pars_begin:$p,lights_toon_fragment:em,lights_toon_pars_fragment:tm,lights_phong_fragment:nm,lights_phong_pars_fragment:im,lights_physical_fragment:sm,lights_physical_pars_fragment:rm,lights_fragment_begin:om,lights_fragment_maps:am,lights_fragment_end:lm,lightprobes_pars_fragment:cm,logdepthbuf_fragment:hm,logdepthbuf_pars_fragment:um,logdepthbuf_pars_vertex:fm,logdepthbuf_vertex:dm,map_fragment:pm,map_pars_fragment:mm,map_particle_fragment:gm,map_particle_pars_fragment:_m,metalnessmap_fragment:xm,metalnessmap_pars_fragment:vm,morphinstance_vertex:ym,morphcolor_vertex:Mm,morphnormal_vertex:Sm,morphtarget_pars_vertex:bm,morphtarget_vertex:Tm,normal_fragment_begin:Am,normal_fragment_maps:wm,normal_pars_fragment:Em,normal_pars_vertex:Rm,normal_vertex:Cm,normalmap_pars_fragment:Im,clearcoat_normal_fragment_begin:Pm,clearcoat_normal_fragment_maps:Lm,clearcoat_pars_fragment:Dm,iridescence_pars_fragment:Nm,opaque_fragment:Um,packing:Fm,premultiplied_alpha_fragment:Om,project_vertex:Bm,dithering_fragment:zm,dithering_pars_fragment:km,roughnessmap_fragment:Gm,roughnessmap_pars_fragment:Vm,shadowmap_pars_fragment:Hm,shadowmap_pars_vertex:Wm,shadowmap_vertex:Xm,shadowmask_pars_fragment:qm,skinbase_vertex:Ym,skinning_pars_vertex:Zm,skinning_vertex:Km,skinnormal_vertex:Jm,specularmap_fragment:jm,specularmap_pars_fragment:$m,tonemapping_fragment:Qm,tonemapping_pars_fragment:eg,transmission_fragment:tg,transmission_pars_fragment:ng,uv_pars_fragment:ig,uv_pars_vertex:sg,uv_vertex:rg,worldpos_vertex:og,background_vert:ag,background_frag:lg,backgroundCube_vert:cg,backgroundCube_frag:hg,cube_vert:ug,cube_frag:fg,depth_vert:dg,depth_frag:pg,distance_vert:mg,distance_frag:gg,equirect_vert:_g,equirect_frag:xg,linedashed_vert:vg,linedashed_frag:yg,meshbasic_vert:Mg,meshbasic_frag:Sg,meshlambert_vert:bg,meshlambert_frag:Tg,meshmatcap_vert:Ag,meshmatcap_frag:wg,meshnormal_vert:Eg,meshnormal_frag:Rg,meshphong_vert:Cg,meshphong_frag:Ig,meshphysical_vert:Pg,meshphysical_frag:Lg,meshtoon_vert:Dg,meshtoon_frag:Ng,points_vert:Ug,points_frag:Fg,shadow_vert:Og,shadow_frag:Bg,sprite_vert:zg,sprite_frag:kg},Ae={common:{diffuse:{value:new Be(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new We(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new Be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new Be(16777215)},opacity:{value:1},center:{value:new We(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},qn={basic:{uniforms:Zt([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.fog]),vertexShader:et.meshbasic_vert,fragmentShader:et.meshbasic_frag},lambert:{uniforms:Zt([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,Ae.lights,{emissive:{value:new Be(0)},envMapIntensity:{value:1}}]),vertexShader:et.meshlambert_vert,fragmentShader:et.meshlambert_frag},phong:{uniforms:Zt([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,Ae.lights,{emissive:{value:new Be(0)},specular:{value:new Be(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:et.meshphong_vert,fragmentShader:et.meshphong_frag},standard:{uniforms:Zt([Ae.common,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.roughnessmap,Ae.metalnessmap,Ae.fog,Ae.lights,{emissive:{value:new Be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag},toon:{uniforms:Zt([Ae.common,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.gradientmap,Ae.fog,Ae.lights,{emissive:{value:new Be(0)}}]),vertexShader:et.meshtoon_vert,fragmentShader:et.meshtoon_frag},matcap:{uniforms:Zt([Ae.common,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,{matcap:{value:null}}]),vertexShader:et.meshmatcap_vert,fragmentShader:et.meshmatcap_frag},points:{uniforms:Zt([Ae.points,Ae.fog]),vertexShader:et.points_vert,fragmentShader:et.points_frag},dashed:{uniforms:Zt([Ae.common,Ae.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:et.linedashed_vert,fragmentShader:et.linedashed_frag},depth:{uniforms:Zt([Ae.common,Ae.displacementmap]),vertexShader:et.depth_vert,fragmentShader:et.depth_frag},normal:{uniforms:Zt([Ae.common,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,{opacity:{value:1}}]),vertexShader:et.meshnormal_vert,fragmentShader:et.meshnormal_frag},sprite:{uniforms:Zt([Ae.sprite,Ae.fog]),vertexShader:et.sprite_vert,fragmentShader:et.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:et.background_vert,fragmentShader:et.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:et.backgroundCube_vert,fragmentShader:et.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:et.cube_vert,fragmentShader:et.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:et.equirect_vert,fragmentShader:et.equirect_frag},distance:{uniforms:Zt([Ae.common,Ae.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:et.distance_vert,fragmentShader:et.distance_frag},shadow:{uniforms:Zt([Ae.lights,Ae.fog,{color:{value:new Be(0)},opacity:{value:1}}]),vertexShader:et.shadow_vert,fragmentShader:et.shadow_frag}};qn.physical={uniforms:Zt([qn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new We(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Ke},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new Be(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new We},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new Be(0)},specularColor:{value:new Be(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new We},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag};var Ia={r:0,b:0,g:0},Gg=new Ze,vf=new Ke;vf.set(-1,0,0,0,1,0,0,0,1);function Vg(i,e,t,n,s,r){let o=new Be(0),a=s===!0?0:1,c,l,h=null,u=0,f=null;function d(M){let A=M.isScene===!0?M.background:null;if(A&&A.isTexture){let S=M.backgroundBlurriness>0;A=e.get(A,S)}return A}function g(M){let A=!1,S=d(M);S===null?m(o,a):S&&S.isColor&&(m(S,1),A=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(M,A){let S=d(A);S&&S.isCubeTexture?(l===void 0&&(l=new bt(new ws(1,1,1),new zn({name:"BackgroundCubeMaterial",uniforms:Qi(qn.backgroundCube.uniforms),vertexShader:qn.backgroundCube.vertexShader,fragmentShader:qn.backgroundCube.fragmentShader,side:en,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,T,_){this.matrixWorld.copyPosition(_.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Gg.makeRotationFromEuler(A.backgroundRotation)).transpose(),S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(vf),l.material.toneMapped=tt.getTransfer(S.colorSpace)!==pt,(h!==S||u!==S.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,f=i.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new bt(new pr(2,2),new zn({name:"BackgroundMaterial",uniforms:Qi(qn.background.uniforms),vertexShader:qn.background.vertexShader,fragmentShader:qn.background.fragmentShader,side:Vn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=tt.getTransfer(S.colorSpace)!==pt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,f=i.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function m(M,A){M.getRGB(Ia,ec(i)),t.buffers.color.setClear(Ia.r,Ia.g,Ia.b,A,r)}function p(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(M,A=1){o.set(M),a=A,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,m(o,a)},render:g,addToRenderList:x,dispose:p}}function Hg(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=f(null),r=s,o=!1;function a(L,B,K,C,q){let X=!1,W=u(L,C,K,B);r!==W&&(r=W,l(r.object)),X=d(L,C,K,q),X&&g(L,C,K,q),q!==null&&e.update(q,i.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,S(L,B,K,C),q!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function c(){return i.createVertexArray()}function l(L){return i.bindVertexArray(L)}function h(L){return i.deleteVertexArray(L)}function u(L,B,K,C){let q=C.wireframe===!0,X=n[B.id];X===void 0&&(X={},n[B.id]=X);let W=L.isInstancedMesh===!0?L.id:0,ae=X[W];ae===void 0&&(ae={},X[W]=ae);let Y=ae[K.id];Y===void 0&&(Y={},ae[K.id]=Y);let oe=Y[q];return oe===void 0&&(oe=f(c()),Y[q]=oe),oe}function f(L){let B=[],K=[],C=[];for(let q=0;q<t;q++)B[q]=0,K[q]=0,C[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:K,attributeDivisors:C,object:L,attributes:{},index:null}}function d(L,B,K,C){let q=r.attributes,X=B.attributes,W=0,ae=K.getAttributes();for(let Y in ae)if(ae[Y].location>=0){let le=q[Y],Ie=X[Y];if(Ie===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(Ie=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(Ie=L.instanceColor)),le===void 0||le.attribute!==Ie||Ie&&le.data!==Ie.data)return!0;W++}return r.attributesNum!==W||r.index!==C}function g(L,B,K,C){let q={},X=B.attributes,W=0,ae=K.getAttributes();for(let Y in ae)if(ae[Y].location>=0){let le=X[Y];le===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(le=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(le=L.instanceColor));let Ie={};Ie.attribute=le,le&&le.data&&(Ie.data=le.data),q[Y]=Ie,W++}r.attributes=q,r.attributesNum=W,r.index=C}function x(){let L=r.newAttributes;for(let B=0,K=L.length;B<K;B++)L[B]=0}function m(L){p(L,0)}function p(L,B){let K=r.newAttributes,C=r.enabledAttributes,q=r.attributeDivisors;K[L]=1,C[L]===0&&(i.enableVertexAttribArray(L),C[L]=1),q[L]!==B&&(i.vertexAttribDivisor(L,B),q[L]=B)}function M(){let L=r.newAttributes,B=r.enabledAttributes;for(let K=0,C=B.length;K<C;K++)B[K]!==L[K]&&(i.disableVertexAttribArray(K),B[K]=0)}function A(L,B,K,C,q,X,W){W===!0?i.vertexAttribIPointer(L,B,K,q,X):i.vertexAttribPointer(L,B,K,C,q,X)}function S(L,B,K,C){x();let q=C.attributes,X=K.getAttributes(),W=B.defaultAttributeValues;for(let ae in X){let Y=X[ae];if(Y.location>=0){let oe=q[ae];if(oe===void 0&&(ae==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),ae==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),oe!==void 0){let le=oe.normalized,Ie=oe.itemSize,He=e.get(oe);if(He===void 0)continue;let ee=He.buffer,ye=He.type,Ce=He.bytesPerElement,ke=ye===i.INT||ye===i.UNSIGNED_INT||oe.gpuType===qo;if(oe.isInterleavedBufferAttribute){let I=oe.data,D=I.isInterleavedBuffer===!0?I.stride:I.itemSize,j=oe.offset;if(I.isInstancedInterleavedBuffer||I.isInstancedBufferAttribute){for(let k=0;k<Y.locationSize;k++)p(Y.location+k,I.meshPerAttribute);L.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=I.meshPerAttribute*I.count)}else for(let k=0;k<Y.locationSize;k++)m(Y.location+k);i.bindBuffer(i.ARRAY_BUFFER,ee);for(let k=0;k<Y.locationSize;k++)A(Y.location+k,Ie/Y.locationSize,ye,le,D*Ce,(j+Ie/Y.locationSize*k)*Ce,ke)}else{if(oe.isInstancedBufferAttribute){for(let I=0;I<Y.locationSize;I++)p(Y.location+I,oe.meshPerAttribute);L.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let I=0;I<Y.locationSize;I++)m(Y.location+I);i.bindBuffer(i.ARRAY_BUFFER,ee);for(let I=0;I<Y.locationSize;I++)A(Y.location+I,Ie/Y.locationSize,ye,le,Ie*Ce,Ie/Y.locationSize*I*Ce,ke)}}else if(W!==void 0){let le=W[ae];if(le!==void 0)switch(le.length){case 2:i.vertexAttrib2fv(Y.location,le);break;case 3:i.vertexAttrib3fv(Y.location,le);break;case 4:i.vertexAttrib4fv(Y.location,le);break;default:i.vertexAttrib1fv(Y.location,le)}}}}M()}function E(){F();for(let L in n){let B=n[L];for(let K in B){let C=B[K];for(let q in C){let X=C[q];for(let W in X)h(X[W].object),delete X[W];delete C[q]}}delete n[L]}}function T(L){if(n[L.id]===void 0)return;let B=n[L.id];for(let K in B){let C=B[K];for(let q in C){let X=C[q];for(let W in X)h(X[W].object),delete X[W];delete C[q]}}delete n[L.id]}function _(L){for(let B in n){let K=n[B];for(let C in K){let q=K[C];if(q[L.id]===void 0)continue;let X=q[L.id];for(let W in X)h(X[W].object),delete X[W];delete q[L.id]}}}function b(L){for(let B in n){let K=n[B],C=L.isInstancedMesh===!0?L.id:0,q=K[C];if(q!==void 0){for(let X in q){let W=q[X];for(let ae in W)h(W[ae].object),delete W[ae];delete q[X]}delete K[C],Object.keys(K).length===0&&delete n[B]}}}function F(){P(),o=!0,r!==s&&(r=s,l(r.object))}function P(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:F,resetDefaultState:P,dispose:E,releaseStatesOfGeometry:T,releaseStatesOfObject:b,releaseStatesOfProgram:_,initAttributes:x,enableAttribute:m,disableUnusedAttributes:M}}function Wg(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function o(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function a(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let f=0;for(let d=0;d<h;d++)f+=l[d];t.update(f,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function Xg(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let _=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(_.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(_){return!(_!==yn&&n.convert(_)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(_){let b=_===Ln&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(_!==on&&_!==dn&&!b&&n.convert(_)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(_){if(_==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";_="mediump"}return _==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(ze("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),f=t.logarithmicDepthBuffer===!0&&u===!1;t.reversedDepthBuffer===!0&&u===!1&&ze("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&u===!0&&ze("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),M=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=i.getParameter(i.MAX_SAMPLES),T=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:u,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:M,maxVaryings:A,maxFragmentUniforms:S,maxSamples:E,samples:T}}function qg(i){let e=this,t=null,n=0,s=!1,r=!1,o=new hn,a=new Ke,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){let d=u.length!==0||f||n!==0||s;return s=f,n=u.length,d},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){let g=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{let M=r?0:n,A=M*4,S=p.clippingState||null;c.value=S,S=h(g,f,A,d);for(let E=0;E!==A;++E)S[E]=t[E];p.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=M}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,g){let x=u!==null?u.length:0,m=null;if(x!==0){if(m=c.value,g!==!0||m===null){let p=d+x*4,M=f.matrixWorldInverse;a.getNormalMatrix(M),(m===null||m.length<p)&&(m=new Float32Array(p));for(let A=0,S=d;A!==x;++A,S+=4)o.copy(u[A]).applyMatrix4(M,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}var Nr=class extends fn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new hr(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` | ||
| 3827 | |||
| 3828 | varying vec3 vWorldDirection; | ||
| 3829 | |||
| 3830 | vec3 transformDirection( in vec3 dir, in mat4 matrix ) { | ||
| 3831 | |||
| 3832 | return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); | ||
| 3833 | |||
| 3834 | } | ||
| 3835 | |||
| 3836 | void main() { | ||
| 3837 | |||
| 3838 | vWorldDirection = transformDirection( position, modelMatrix ); | ||
| 3839 | |||
| 3840 | #include <begin_vertex> | ||
| 3841 | #include <project_vertex> | ||
| 3842 | |||
| 3843 | } | ||
| 3844 | `,fragmentShader:` | ||
| 3845 | |||
| 3846 | uniform sampler2D tEquirect; | ||
| 3847 | |||
| 3848 | varying vec3 vWorldDirection; | ||
| 3849 | |||
| 3850 | #include <common> | ||
| 3851 | |||
| 3852 | void main() { | ||
| 3853 | |||
| 3854 | vec3 direction = normalize( vWorldDirection ); | ||
| 3855 | |||
| 3856 | vec2 sampleUV = equirectUv( direction ); | ||
| 3857 | |||
| 3858 | gl_FragColor = texture2D( tEquirect, sampleUV ); | ||
| 3859 | |||
| 3860 | } | ||
| 3861 | `},s=new ws(5,5,5),r=new zn({name:"CubemapFromEquirect",uniforms:Qi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:en,blending:Zi});r.uniforms.tEquirect.value=t;let o=new bt(s,r),a=t.minFilter;return t.minFilter===tn&&(t.minFilter=At),new Cs(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},Ju=256,Yg=3,Zg=20,yf=256,Mf=16,Kg=3,Jg=new O,jg=new Be,La=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new Cs(1,10,null),this._boxMesh=new bt(new ws(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:o=256,position:a=Jg}=r,c=this._renderer;this._setSize(o);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let u=c.autoClear,f=c.autoClearColor,d=c.autoClearDepth,g=c.autoClearStencil,x=e.background;c.autoClear=!0,c.autoClearColor=!0,c.autoClearDepth=!0,c.autoClearStencil=!0,x===null&&(e.background=c.getClearColor(jg));let m=new Cs(n,s,h);return m.position.copy(a),m.update(c,e),c.autoClear=u,c.autoClearColor=f,c.autoClearDepth=d,c.autoClearStencil=g,e.background=x,t>0&&(h.texture.mipmapsAutoUpdate=!0,this._blur(l,t)),this._applyPMREM(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Qu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=$u(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(Ju,jl(e))}_fromTexture(e,t){e.mapping===Ji||e.mapping===Ds?this._setSize(e.image.length===0?Ju:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=ju(e,!1,!1),n=Math.log2(e)-Yg;for(let s=0;s<=n;s++)t.texture.mipmaps.push({width:e>>s,height:e>>s});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=ju(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let s=this._boxMesh,r=this._cubeCamera;s.material=n,r.renderTarget=e,r.activeMipmapLevel=t;let o=e.width>>t;e.viewport.set(0,0,o,o),r.update(this._renderer,s),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===Ji||e.mapping===Ds?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qu()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=$u()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=$g(),this._integrationMaterial=Qg());let t=this._cubeSize,n=e.texture.mipmaps.length-1,s=this._ggxMaterial.uniforms;s.envMap.value=this._sourceTarget.texture;let r=this._integrationMaterial.uniforms;r.envMap.value=this._sourceTarget.texture,r.sourceLod.value=Math.log2(t/Mf);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-Kg)r.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let c=a>0?Math.log2(t)+.5*Math.log2(6/(yf*Math.pow(a,4)))+.5:0;s.roughness.value=a,s.lodBias.value=c,this._renderCube(e,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=e0());let n=this._blurMaterial,s=n.uniforms,r=this._sourceTarget;s.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,s.envMap.value=r.texture,this._renderCube(e,0,n),s.envMap.value=e.texture,this._renderCube(r,0,n)}};function ju(i,e,t){return new Nr(i,{minFilter:tn,generateMipmaps:e,type:Ln,colorSpace:$t,depthBuffer:t})}function Ur(i,e,t){return new zn({name:i,uniforms:e,vertexShader:et.cube_vert,fragmentShader:t,side:en,blending:Zi,depthTest:!1,depthWrite:!1})}function $g(){return Ur("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},` | ||
| 3862 | |||
| 3863 | #define GGX_SAMPLES ${yf}u | ||
| 3864 | |||
| 3865 | varying vec3 vWorldDirection; | ||
| 3866 | |||
| 3867 | uniform samplerCube envMap; | ||
| 3868 | uniform float roughness; | ||
| 3869 | uniform float lodBias; | ||
| 3870 | |||
| 3871 | #include <common> | ||
| 3872 | |||
| 3873 | // Van der Corput radical inverse | ||
| 3874 | float radicalInverse_VdC( uint bits ) { | ||
| 3875 | |||
| 3876 | bits = ( bits << 16u ) | ( bits >> 16u ); | ||
| 3877 | bits = ( ( bits & 0x55555555u ) << 1u ) | ( ( bits & 0xAAAAAAAAu ) >> 1u ); | ||
| 3878 | bits = ( ( bits & 0x33333333u ) << 2u ) | ( ( bits & 0xCCCCCCCCu ) >> 2u ); | ||
| 3879 | bits = ( ( bits & 0x0F0F0F0Fu ) << 4u ) | ( ( bits & 0xF0F0F0F0u ) >> 4u ); | ||
| 3880 | bits = ( ( bits & 0x00FF00FFu ) << 8u ) | ( ( bits & 0xFF00FF00u ) >> 8u ); | ||
| 3881 | return float( bits ) * 2.3283064365386963e-10; // / 0x100000000 | ||
| 3882 | |||
| 3883 | } | ||
| 3884 | |||
| 3885 | // Hammersley sequence | ||
| 3886 | vec2 hammersley( uint i, uint N ) { | ||
| 3887 | |||
| 3888 | return vec2( float( i ) / float( N ), radicalInverse_VdC( i ) ); | ||
| 3889 | |||
| 3890 | } | ||
| 3891 | |||
| 3892 | void main() { | ||
| 3893 | |||
| 3894 | vec3 N = normalize( vWorldDirection ); | ||
| 3895 | |||
| 3896 | // For very low roughness, just sample the environment directly | ||
| 3897 | if ( roughness < 0.001 ) { | ||
| 3898 | |||
| 3899 | gl_FragColor = vec4( textureLod( envMap, N, 0.0 ).rgb, 1.0 ); | ||
| 3900 | return; | ||
| 3901 | |||
| 3902 | } | ||
| 3903 | |||
| 3904 | float alpha = roughness * roughness; | ||
| 3905 | float alpha2 = alpha * alpha; | ||
| 3906 | |||
| 3907 | // Tangent space basis for VNDF sampling | ||
| 3908 | vec3 up = abs( N.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 ); | ||
| 3909 | vec3 tangent = normalize( cross( up, N ) ); | ||
| 3910 | vec3 bitangent = cross( N, tangent ); | ||
| 3911 | |||
| 3912 | vec3 prefilteredColor = vec3( 0.0 ); | ||
| 3913 | float totalWeight = 0.0; | ||
| 3914 | |||
| 3915 | for ( uint i = 0u; i < GGX_SAMPLES; i ++ ) { | ||
| 3916 | |||
| 3917 | vec2 Xi = hammersley( i, GGX_SAMPLES ); | ||
| 3918 | |||
| 3919 | // With V = N, sample the reflected direction directly. | ||
| 3920 | float invQ = 1.0 / ( 1.0 - Xi.x + alpha2 * Xi.x ); | ||
| 3921 | float NdotL = ( 1.0 - Xi.x - alpha2 * Xi.x ) * invQ; | ||
| 3922 | |||
| 3923 | if ( NdotL > 0.0 ) { | ||
| 3924 | |||
| 3925 | float phi = 2.0 * PI * Xi.y; | ||
| 3926 | float sinTheta = 2.0 * alpha * sqrt( Xi.x * ( 1.0 - Xi.x ) ) * invQ; | ||
| 3927 | vec3 L = N * NdotL + ( tangent * cos( phi ) + bitangent * sin( phi ) ) * sinTheta; | ||
| 3928 | |||
| 3929 | // Match the source mip to the sample's solid angle. The terms | ||
| 3930 | // independent of the sample are precomputed in lodBias. | ||
| 3931 | float d = alpha2 * invQ; | ||
| 3932 | float lod = max( log2( d ) + lodBias, 0.0 ); | ||
| 3933 | |||
| 3934 | // Weight by NdotL for the split-sum approximation | ||
| 3935 | prefilteredColor += textureLod( envMap, L, lod ).rgb * NdotL; | ||
| 3936 | totalWeight += NdotL; | ||
| 3937 | |||
| 3938 | } | ||
| 3939 | |||
| 3940 | } | ||
| 3941 | |||
| 3942 | gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 ); | ||
| 3943 | |||
| 3944 | } | ||
| 3945 | `)}function Qg(){return Ur("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:Mf}},` | ||
| 3946 | |||
| 3947 | varying vec3 vWorldDirection; | ||
| 3948 | |||
| 3949 | uniform samplerCube envMap; | ||
| 3950 | uniform float roughness; | ||
| 3951 | uniform float sourceLod; | ||
| 3952 | uniform int sourceSize; | ||
| 3953 | |||
| 3954 | void main() { | ||
| 3955 | |||
| 3956 | vec3 N = normalize( vWorldDirection ); | ||
| 3957 | |||
| 3958 | float alpha = roughness * roughness; | ||
| 3959 | float alpha2 = alpha * alpha; | ||
| 3960 | |||
| 3961 | float texelSize = 2.0 / float( sourceSize ); | ||
| 3962 | |||
| 3963 | vec3 prefilteredColor = vec3( 0.0 ); | ||
| 3964 | float totalWeight = 0.0; | ||
| 3965 | |||
| 3966 | // Pair opposite texels: only the one in N's hemisphere contributes. | ||
| 3967 | for ( int face = 0; face < 3; face ++ ) { | ||
| 3968 | |||
| 3969 | for ( int y = 0; y < sourceSize; y ++ ) { | ||
| 3970 | |||
| 3971 | for ( int x = 0; x < sourceSize; x ++ ) { | ||
| 3972 | |||
| 3973 | vec2 uv = ( vec2( x, y ) + 0.5 ) * texelSize - 1.0; | ||
| 3974 | vec3 texelDirection = face == 0 ? vec3( 1.0, uv ) : ( face == 1 ? vec3( uv.x, 1.0, uv.y ) : vec3( uv, 1.0 ) ); | ||
| 3975 | |||
| 3976 | float invDistance = inversesqrt( 1.0 + dot( uv, uv ) ); | ||
| 3977 | float NdotL = dot( N, texelDirection ); | ||
| 3978 | texelDirection *= NdotL < 0.0 ? - 1.0 : 1.0; | ||
| 3979 | NdotL = abs( NdotL ) * invDistance; | ||
| 3980 | |||
| 3981 | // With V = N, NdotH squared is ( 1 + NdotL ) / 2. Common factors | ||
| 3982 | // in the GGX distribution and texel solid angle cancel when normalized. | ||
| 3983 | float d = 1.0 + alpha2 + ( alpha2 - 1.0 ) * NdotL; | ||
| 3984 | float weight = NdotL * invDistance * invDistance * invDistance / ( d * d ); | ||
| 3985 | |||
| 3986 | prefilteredColor += textureLod( envMap, texelDirection, sourceLod ).rgb * weight; | ||
| 3987 | totalWeight += weight; | ||
| 3988 | |||
| 3989 | } | ||
| 3990 | |||
| 3991 | } | ||
| 3992 | |||
| 3993 | } | ||
| 3994 | |||
| 3995 | gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 ); | ||
| 3996 | |||
| 3997 | } | ||
| 3998 | `)}function e0(){return Ur("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},` | ||
| 3999 | |||
| 4000 | #define SAMPLES ${Zg} | ||
| 4001 | #define GOLDEN_ANGLE 2.39996322973 | ||
| 4002 | |||
| 4003 | varying vec3 vWorldDirection; | ||
| 4004 | |||
| 4005 | uniform samplerCube envMap; | ||
| 4006 | uniform float sigma; | ||
| 4007 | |||
| 4008 | #include <common> | ||
| 4009 | |||
| 4010 | void main() { | ||
| 4011 | |||
| 4012 | vec3 outputDirection = normalize( vWorldDirection ); | ||
| 4013 | |||
| 4014 | vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 ); | ||
| 4015 | vec3 tangent = normalize( cross( up, outputDirection ) ); | ||
| 4016 | vec3 bitangent = cross( outputDirection, tangent ); | ||
| 4017 | |||
| 4018 | // Truncate the kernel at three standard deviations or at the antipode. | ||
| 4019 | float thetaMax = min( 3.0 * sigma, PI ); | ||
| 4020 | float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) ); | ||
| 4021 | |||
| 4022 | vec3 accumColor = vec3( 0.0 ); | ||
| 4023 | float accumWeight = 0.0; | ||
| 4024 | |||
| 4025 | for ( int i = 0; i < SAMPLES; i ++ ) { | ||
| 4026 | |||
| 4027 | // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral. | ||
| 4028 | float stratum = ( float( i ) + 0.5 ) / float( SAMPLES ); | ||
| 4029 | float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) ); | ||
| 4030 | float phi = float( i ) * GOLDEN_ANGLE; | ||
| 4031 | |||
| 4032 | vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent; | ||
| 4033 | vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset; | ||
| 4034 | |||
| 4035 | // Correct the planar sample density to solid angle. | ||
| 4036 | float weight = sin( theta ) / theta; | ||
| 4037 | |||
| 4038 | accumColor += weight * textureLod( envMap, sampleDirection, 0.0 ).rgb; | ||
| 4039 | accumWeight += weight; | ||
| 4040 | |||
| 4041 | } | ||
| 4042 | |||
| 4043 | gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); | ||
| 4044 | |||
| 4045 | } | ||
| 4046 | `)}function $u(){return Ur("PMREMEquirectangularToCubemap",{envMap:{value:null}},` | ||
| 4047 | |||
| 4048 | varying vec3 vWorldDirection; | ||
| 4049 | |||
| 4050 | uniform sampler2D envMap; | ||
| 4051 | |||
| 4052 | #include <common> | ||
| 4053 | |||
| 4054 | void main() { | ||
| 4055 | |||
| 4056 | // Average four subpixel samples to preserve small, bright features. | ||
| 4057 | vec3 direction = normalize( vWorldDirection ); | ||
| 4058 | vec3 dx = dFdx( direction ) * 0.25; | ||
| 4059 | vec3 dy = dFdy( direction ) * 0.25; | ||
| 4060 | |||
| 4061 | vec3 color = textureLod( envMap, equirectUv( normalize( direction - dx - dy ) ), 0.0 ).rgb; | ||
| 4062 | color += textureLod( envMap, equirectUv( normalize( direction + dx - dy ) ), 0.0 ).rgb; | ||
| 4063 | color += textureLod( envMap, equirectUv( normalize( direction - dx + dy ) ), 0.0 ).rgb; | ||
| 4064 | color += textureLod( envMap, equirectUv( normalize( direction + dx + dy ) ), 0.0 ).rgb; | ||
| 4065 | gl_FragColor = vec4( color * 0.25, 1.0 ); | ||
| 4066 | |||
| 4067 | } | ||
| 4068 | `)}function Qu(){return Ur("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},` | ||
| 4069 | |||
| 4070 | varying vec3 vWorldDirection; | ||
| 4071 | |||
| 4072 | uniform samplerCube envMap; | ||
| 4073 | uniform float flipEnvMap; | ||
| 4074 | |||
| 4075 | void main() { | ||
| 4076 | |||
| 4077 | gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 ); | ||
| 4078 | |||
| 4079 | } | ||
| 4080 | `)}function t0(i){let e=new WeakMap,t=new WeakMap,n=null;function s(f,d=!1){return f==null?null:d?o(f):r(f)}function r(f){if(f&&f.isTexture){let d=f.mapping;if(d===Ho||d===Wo)if(e.has(f)){let g=e.get(f).texture;return a(g,f.mapping)}else{let g=f.image;if(g&&g.height>0){let x=new Nr(g.height);return x.fromEquirectangularTexture(i,f),e.set(f,x),f.addEventListener("dispose",l),a(x.texture,f.mapping)}else return null}}return f}function o(f){if(f&&f.isTexture&&f.isPMREMTexture!==!0){let d=f.mapping,g=d===Ho||d===Wo,x=d===Ji||d===Ds;if(g||x){let m=t.get(f),p=m!==void 0?m.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p)return n===null&&(n=new La(i)),m=g?n.fromEquirectangular(f,m):n.fromCubemap(f,m),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),m.texture;if(m!==void 0)return m.texture;{let M=f.image;return g&&M&&M.height>0||x&&M&&c(M)?(n===null&&(n=new La(i)),m=g?n.fromEquirectangular(f):n.fromCubemap(f),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),f.addEventListener("dispose",h),m.texture):null}}}return f}function a(f,d){return d===Ho?f.mapping=Ji:d===Wo&&(f.mapping=Ds),f}function c(f){let d=0,g=6;for(let x=0;x<g;x++)f[x]!==void 0&&d++;return d===g}function l(f){let d=f.target;d.removeEventListener("dispose",l);let g=e.get(d);g!==void 0&&(e.delete(d),g.dispose())}function h(f){let d=f.target;d.removeEventListener("dispose",h);let g=t.get(d);g!==void 0&&(t.delete(d),g.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function n0(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&ki("WebGLRenderer: "+n+" extension not supported."),s}}}function i0(i,e,t,n){let s={},r=new WeakMap,o=new FinalizationRegistry(g=>delete s[g]);function a(g){c(g.target)}function c(g){g.index!==null&&e.remove(g.index);for(let m in g.attributes)e.remove(g.attributes[m]);g.removeEventListener("dispose",a),delete s[g.id],o.unregister(g);let x=r.get(g);x&&(e.remove(x),r.delete(g)),n.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,t.memory.geometries--}function l(g,x){return s[x.id]!==void 0||(x.addEventListener("dispose",a),s[x.id]=new WeakRef(x),o.register(x,x.id,x),t.memory.geometries++),x}function h(g){let x=g.attributes;for(let m in x)e.update(x[m],i.ARRAY_BUFFER)}function u(g){let x=g.index,m=g.attributes.position,p=0;if(m===void 0)return;let M=x!==null?x.array.length:m.array.length/3-1,A=m.count>=65535?rr:sr,S=new A(Math.ceil(M/3)*6,1),E=S.array;if(x!==null){let _=x.array;p=x.version;for(let b=0,F=0;b<M;b+=3){let P=_[b+0],L=_[b+1],B=_[b+2];E[F++]=P,E[F++]=L,E[F++]=L,E[F++]=B,E[F++]=B,E[F++]=P}}else{p=m.version;for(let _=0,b=0;_<M;_+=3){let F=_+0,P=_+1,L=_+2;E[b++]=F,E[b++]=P,E[b++]=P,E[b++]=L,E[b++]=L,E[b++]=F}}S.version=p;let T=r.get(g);T&&e.remove(T),r.set(g,S)}function f(g){let x=r.get(g);if(x){let m=g.index;m!==null&&x.version<m.version&&u(g)}else u(g);return r.get(g)}function d(){for(let g in s){let x=s[g].deref();x!==void 0&&c(x)}}return{get:l,update:h,getWireframeAttribute:f,dispose:d}}function s0(i,e,t){let n;function s(u){n=u}let r,o;function a(u){r=u.type,o=u.bytesPerElement}function c(u,f){i.drawElements(n,f,r,u*o),t.update(f,n,1)}function l(u,f,d){d!==0&&(i.drawElementsInstanced(n,f,r,u*o,d),t.update(f,n,d))}function h(u,f,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,u,0,d);let x=0;for(let m=0;m<d;m++)x+=f[m];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function r0(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:qe("WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function o0(i,e,t){let n=new WeakMap,s=new gt;function r(o,a,c){let l=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,f=n.get(a);if(f===void 0||f.count!==u){let F=function(){_.dispose(),n.delete(a),a.removeEventListener("dispose",F)};f!==void 0&&f.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],A=0;d===!0&&(A=1),g===!0&&(A=2),x===!0&&(A=3);let S=a.attributes.position.count*A,E=1;S>e.maxTextureSize&&(E=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let T=new Float32Array(S*E*4*u),_=new nr(T,S,E,u);_.type=dn,_.needsUpdate=!0;let b=A*4;for(let P=0;P<u;P++){let L=m[P],B=p[P],K=M[P],C=S*E*4*P;for(let q=0;q<L.count;q++){let X=q*b;d===!0&&(s.fromBufferAttribute(L,q),T[C+X+0]=s.x,T[C+X+1]=s.y,T[C+X+2]=s.z,T[C+X+3]=0),g===!0&&(s.fromBufferAttribute(B,q),T[C+X+4]=s.x,T[C+X+5]=s.y,T[C+X+6]=s.z,T[C+X+7]=0),x===!0&&(s.fromBufferAttribute(K,q),T[C+X+8]=s.x,T[C+X+9]=s.y,T[C+X+10]=s.z,T[C+X+11]=K.itemSize===4?s.w:1)}}f={count:u,texture:_,size:new We(S,E)},n.set(a,f),a.addEventListener("dispose",F)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",f.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:r}}function a0(i,e,t,n,s){let r=new WeakMap;function o(l){let h=s.render.frame,u=l.geometry,f=e.get(l,u);if(r.get(f)!==h&&(e.update(f),r.set(f,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){let d=l.skeleton;r.get(d)!==h&&(d.update(),r.set(d,h))}return f}function a(){r=new WeakMap}function c(l){let h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}var l0={[Il]:"LINEAR_TONE_MAPPING",[Pl]:"REINHARD_TONE_MAPPING",[Ll]:"CINEON_TONE_MAPPING",[Dl]:"ACES_FILMIC_TONE_MAPPING",[Ul]:"AGX_TONE_MAPPING",[Fl]:"NEUTRAL_TONE_MAPPING",[Nl]:"CUSTOM_TONE_MAPPING"};function c0(i,e,t,n,s,r){let o=new fn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=null,h=new _t;h.setAttribute("position",new st([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new st([0,2,0,0,2,0],2));let u=new Co({uniforms:{tDiffuse:{value:null}},vertexShader:` | ||
| 4081 | precision highp float; | ||
| 4082 | |||
| 4083 | uniform mat4 modelViewMatrix; | ||
| 4084 | uniform mat4 projectionMatrix; | ||
| 4085 | |||
| 4086 | attribute vec3 position; | ||
| 4087 | attribute vec2 uv; | ||
| 4088 | |||
| 4089 | varying vec2 vUv; | ||
| 4090 | |||
| 4091 | void main() { | ||
| 4092 | vUv = uv; | ||
| 4093 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); | ||
| 4094 | }`,fragmentShader:` | ||
| 4095 | precision highp float; | ||
| 4096 | |||
| 4097 | uniform sampler2D tDiffuse; | ||
| 4098 | |||
| 4099 | varying vec2 vUv; | ||
| 4100 | |||
| 4101 | #include <tonemapping_pars_fragment> | ||
| 4102 | #include <colorspace_pars_fragment> | ||
| 4103 | |||
| 4104 | void main() { | ||
| 4105 | gl_FragColor = texture2D( tDiffuse, vUv ); | ||
| 4106 | |||
| 4107 | #ifdef LINEAR_TONE_MAPPING | ||
| 4108 | gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); | ||
| 4109 | #elif defined( REINHARD_TONE_MAPPING ) | ||
| 4110 | gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); | ||
| 4111 | #elif defined( CINEON_TONE_MAPPING ) | ||
| 4112 | gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); | ||
| 4113 | #elif defined( ACES_FILMIC_TONE_MAPPING ) | ||
| 4114 | gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); | ||
| 4115 | #elif defined( AGX_TONE_MAPPING ) | ||
| 4116 | gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); | ||
| 4117 | #elif defined( NEUTRAL_TONE_MAPPING ) | ||
| 4118 | gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); | ||
| 4119 | #elif defined( CUSTOM_TONE_MAPPING ) | ||
| 4120 | gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); | ||
| 4121 | #endif | ||
| 4122 | |||
| 4123 | #ifdef SRGB_TRANSFER | ||
| 4124 | gl_FragColor = sRGBTransferOETF( gl_FragColor ); | ||
| 4125 | #endif | ||
| 4126 | }`,depthTest:!1,depthWrite:!1}),f=new bt(h,u),d=new Yi(-1,1,1,-1,0,1),g=null,x=null,m=!1,p,M=null,A=[],S=!1;this.setSize=function(E,T){o.setSize(E,T),a!==null&&a.setSize(E,T),c!==null&&c.setSize(E,T);for(let _=0;_<A.length;_++){let b=A[_];b.setSize&&b.setSize(E,T)}},this.setEffects=function(E){A=E,S=A.length>0&&A[0].isRenderPass===!0;let T=o.width,_=o.height;A.length>0&&a===null&&(a=new fn(T,_,{type:Ln,depthBuffer:!1,stencilBuffer:!1}),c=new fn(T,_,{type:Ln,depthBuffer:!1,stencilBuffer:!1}));let b=s===!0&&A.some(F=>F.needsDepthTexture===!0);b!==(o.depthTexture!==null)&&(b===!0&&l===null&&(l=new li(T,_),r===!0&&(l.format=pi,l.type=$i)),o.dispose(),o.depthTexture=b?l:null,o.resolveDepthBuffer=b,o.storeMultisampledDepthBuffer=b);for(let F=0;F<A.length;F++){let P=A[F];P.setSize&&P.setSize(T,_),b&&P.needsDepthTexture===!0&&P.setDepthTexture&&P.setDepthTexture(l)}},this.begin=function(E,T){if(m||E.toneMapping===Hn&&A.length===0)return!1;if(M=T,T!==null){let _=T.width,b=T.height;(o.width!==_||o.height!==b)&&this.setSize(_,b)}return S===!1&&E.setRenderTarget(o),p=E.toneMapping,E.toneMapping=Hn,!0},this.hasRenderPass=function(){return S},this.end=function(E,T){E.toneMapping=p,m=!0;let _=o,b=a;for(let F=0;F<A.length;F++){let P=A[F];P.enabled!==!1&&(P.render(E,b,_,T),P.needsSwap!==!1&&(_=b,b=b===a?c:a))}if(g!==E.outputColorSpace||x!==E.toneMapping){g=E.outputColorSpace,x=E.toneMapping,u.defines={},tt.getTransfer(g)===pt&&(u.defines.SRGB_TRANSFER="");let F=l0[x];F&&(u.defines[F]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=_.texture,E.setRenderTarget(M),E.render(f,d),M=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),c!==null&&c.dispose(),h.dispose(),u.dispose()}}var Sf=new kt,bf=new li(1,1),Tf=new ur(1),Af=new nr,wf=new To,Ef=new hr,ef=[],tf=[],nf=new Float32Array(16),sf=new Float32Array(9),rf=new Float32Array(4);function zs(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=ef[s];if(r===void 0&&(r=new Float32Array(s),ef[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Pt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Lt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Da(i,e){let t=tf[e];t===void 0&&(t=new Int32Array(e),tf[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function h0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function u0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;i.uniform2fv(this.addr,e),Lt(t,e)}}function f0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Pt(t,e))return;i.uniform3fv(this.addr,e),Lt(t,e)}}function d0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;i.uniform4fv(this.addr,e),Lt(t,e)}}function p0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,n))return;rf.set(n),i.uniformMatrix2fv(this.addr,!1,rf),Lt(t,n)}}function m0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,n))return;sf.set(n),i.uniformMatrix3fv(this.addr,!1,sf),Lt(t,n)}}function g0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,n))return;nf.set(n),i.uniformMatrix4fv(this.addr,!1,nf),Lt(t,n)}}function _0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function x0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;i.uniform2iv(this.addr,e),Lt(t,e)}}function v0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;i.uniform3iv(this.addr,e),Lt(t,e)}}function y0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;i.uniform4iv(this.addr,e),Lt(t,e)}}function M0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function S0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;i.uniform2uiv(this.addr,e),Lt(t,e)}}function b0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;i.uniform3uiv(this.addr,e),Lt(t,e)}}function T0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;i.uniform4uiv(this.addr,e),Lt(t,e)}}function Na(i){return i.version===0&&(i.compareFunction=Yl,i.needsUpdate=!0),i}function A0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?r=Na(bf):r=Sf,t.setTexture2D(e||r,s)}function w0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||wf,s)}function E0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_CUBE_SHADOW?r=Na(Tf):r=Ef,t.setTextureCube(e||r,s)}function R0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||Af,s)}function C0(i){switch(i){case 5126:return h0;case 35664:return u0;case 35665:return f0;case 35666:return d0;case 35674:return p0;case 35675:return m0;case 35676:return g0;case 5124:case 35670:return _0;case 35667:case 35671:return x0;case 35668:case 35672:return v0;case 35669:case 35673:return y0;case 5125:return M0;case 36294:return S0;case 36295:return b0;case 36296:return T0;case 35678:case 36198:case 36298:case 36306:case 35682:return A0;case 35679:case 36299:case 36307:return w0;case 35680:case 36300:case 36308:case 36293:return E0;case 36289:case 36303:case 36311:case 36292:return R0}}function I0(i,e){i.uniform1fv(this.addr,e)}function P0(i,e){let t=zs(e,this.size,2);i.uniform2fv(this.addr,t)}function L0(i,e){let t=zs(e,this.size,3);i.uniform3fv(this.addr,t)}function D0(i,e){let t=zs(e,this.size,4);i.uniform4fv(this.addr,t)}function N0(i,e){let t=zs(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function U0(i,e){let t=zs(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function F0(i,e){let t=zs(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function O0(i,e){i.uniform1iv(this.addr,e)}function B0(i,e){i.uniform2iv(this.addr,e)}function z0(i,e){i.uniform3iv(this.addr,e)}function k0(i,e){i.uniform4iv(this.addr,e)}function G0(i,e){i.uniform1uiv(this.addr,e)}function V0(i,e){i.uniform2uiv(this.addr,e)}function H0(i,e){i.uniform3uiv(this.addr,e)}function W0(i,e){i.uniform4uiv(this.addr,e)}function X0(i,e,t){let n=this.cache,s=e.length,r=Da(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),Lt(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=Na(bf):o=Sf;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function q0(i,e,t){let n=this.cache,s=e.length,r=Da(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||wf,r[o])}function Y0(i,e,t){let n=this.cache,s=e.length,r=Da(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),Lt(n,r));let o;this.type===i.SAMPLER_CUBE_SHADOW?o=Na(Tf):o=Ef;for(let a=0;a!==s;++a)t.setTextureCube(e[a]||o,r[a])}function Z0(i,e,t){let n=this.cache,s=e.length,r=Da(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||Af,r[o])}function K0(i){switch(i){case 5126:return I0;case 35664:return P0;case 35665:return L0;case 35666:return D0;case 35674:return N0;case 35675:return U0;case 35676:return F0;case 5124:case 35670:return O0;case 35667:case 35671:return B0;case 35668:case 35672:return z0;case 35669:case 35673:return k0;case 5125:return G0;case 36294:return V0;case 36295:return H0;case 36296:return W0;case 35678:case 36198:case 36298:case 36306:case 35682:return X0;case 35679:case 36299:case 36307:return q0;case 35680:case 36300:case 36308:case 36293:return Y0;case 36289:case 36303:case 36311:case 36292:return Z0}}var uc=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=C0(t.type)}},fc=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=K0(t.type)}},dc=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},cc=/(\w+)(\])?(\[|\.)?/g;function of(i,e){i.seq.push(e),i.map[e.id]=e}function J0(i,e,t){let n=i.name,s=n.length;for(cc.lastIndex=0;;){let r=cc.exec(n),o=cc.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===s){of(t,l===void 0?new uc(a,i,e):new fc(a,i,e));break}else{let u=t.map[a];u===void 0&&(u=new dc(a),of(t,u)),t=u}}}var Bs=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=e.getActiveUniform(t,o),c=e.getUniformLocation(t,a.name);J0(a,c,this)}let s=[],r=[];for(let o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function af(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var j0=37297,$0=0;function Q0(i,e){let t=i.split(` | ||
| 4127 | `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(` | ||
| 4128 | `)}var lf=new Ke;function e_(i){tt._getMatrix(lf,tt.workingColorSpace,i);let e=`mat3( ${lf.elements.map(t=>t.toFixed(4))} )`;switch(tt.getTransfer(i)){case er:return[e,"LinearTransferOETF"];case pt:return[e,"sRGBTransferOETF"];default:return ze("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function cf(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` | ||
| 4129 | |||
| 4130 | `+r+` | ||
| 4131 | |||
| 4132 | `+Q0(i.getShaderSource(e),a)}else return r}function t_(i,e){let t=e_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(` | ||
| 4133 | `)}var n_={[Il]:"Linear",[Pl]:"Reinhard",[Ll]:"Cineon",[Dl]:"ACESFilmic",[Ul]:"AgX",[Fl]:"Neutral",[Nl]:"Custom"};function i_(i,e){let t=n_[e];return t===void 0?(ze("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Pa=new O;function s_(){tt.getLuminanceCoefficients(Pa);let i=Pa.x.toFixed(4),e=Pa.y.toFixed(4),t=Pa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` | ||
| 4134 | `)}function r_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Dr).join(` | ||
| 4135 | `)}function o_(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` | ||
| 4136 | `)}function a_(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function Dr(i){return i!==""}function hf(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).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,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).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).replace(/NUM_LIGHT_PROBE_GRIDS/g,e.numLightProbeGrids)}function uf(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var l_=/^[ \t]*#include +<([\w\d./]+)>/gm;function pc(i){return i.replace(l_,c_)}function c_(i,e){let t=et[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return pc(t)}var h_=/#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 ff(i){return i.replace(h_,u_)}function u_(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function df(i){let e=`precision ${i.precision} float; | ||
| 4137 | precision ${i.precision} int; | ||
| 4138 | precision ${i.precision} sampler2D; | ||
| 4139 | precision ${i.precision} samplerCube; | ||
| 4140 | precision ${i.precision} sampler3D; | ||
| 4141 | precision ${i.precision} sampler2DArray; | ||
| 4142 | precision ${i.precision} sampler2DShadow; | ||
| 4143 | precision ${i.precision} samplerCubeShadow; | ||
| 4144 | precision ${i.precision} sampler2DArrayShadow; | ||
| 4145 | precision ${i.precision} isampler2D; | ||
| 4146 | precision ${i.precision} isampler3D; | ||
| 4147 | precision ${i.precision} isamplerCube; | ||
| 4148 | precision ${i.precision} isampler2DArray; | ||
| 4149 | precision ${i.precision} usampler2D; | ||
| 4150 | precision ${i.precision} usampler3D; | ||
| 4151 | precision ${i.precision} usamplerCube; | ||
| 4152 | precision ${i.precision} usampler2DArray; | ||
| 4153 | `;return i.precision==="highp"?e+=` | ||
| 4154 | #define HIGH_PRECISION`:i.precision==="mediump"?e+=` | ||
| 4155 | #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=` | ||
| 4156 | #define LOW_PRECISION`),e}var f_={[br]:"SHADOWMAP_TYPE_PCF",[Ps]:"SHADOWMAP_TYPE_VSM"};function d_(i){return f_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var p_={[Ds]:"ENVMAP_MODE_REFRACTION"};function m_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":p_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var g_={[Vo]:"ENVMAP_BLENDING_MULTIPLY",[Iu]:"ENVMAP_BLENDING_MIX",[Pu]:"ENVMAP_BLENDING_ADD"};function __(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":g_[i.combine]||"ENVMAP_BLENDING_NONE"}function x_(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,c=d_(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=m_(t),u=__(t),f=r_(t),d=o_(r),g=s.createProgram(),x,m,p=t.glslVersion?"#version "+t.glslVersion+` | ||
| 4157 | `:"";t.isRawShaderMaterial?(x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d].filter(Dr).join(` | ||
| 4158 | `),x.length>0&&(x+=` | ||
| 4159 | `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d].filter(Dr).join(` | ||
| 4160 | `),m.length>0&&(m+=` | ||
| 4161 | `)):(x=[df(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` | ||
| 4162 | `].filter(Dr).join(` | ||
| 4163 | `),m=[df(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Hn?"#define TONE_MAPPING":"",t.toneMapping!==Hn?et.tonemapping_pars_fragment:"",t.toneMapping!==Hn?i_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",et.colorspace_pars_fragment,t_("linearToOutputTexel",t.outputColorSpace),s_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` | ||
| 4164 | `].filter(Dr).join(` | ||
| 4165 | `)),o=pc(o),o=hf(o,t),o=uf(o,t),a=pc(a),a=hf(a,t),a=uf(a,t),o=ff(o),a=ff(a),t.isRawShaderMaterial!==!0&&(p=`#version 300 es | ||
| 4166 | `,x=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` | ||
| 4167 | `)+` | ||
| 4168 | `+x,m=["#define varying in",t.glslVersion===Kl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Kl?"":"#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(` | ||
| 4169 | `)+` | ||
| 4170 | `+m);let M=p+x+o,A=p+m+a,S=af(s,s.VERTEX_SHADER,M),E=af(s,s.FRAGMENT_SHADER,A);s.attachShader(g,S),s.attachShader(g,E),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function T(P){if(i.debug.checkShaderErrors){let L=s.getProgramInfoLog(g)||"",B=s.getShaderInfoLog(S)||"",K=s.getShaderInfoLog(E)||"",C=L.trim(),q=B.trim(),X=K.trim(),W=!0,ae=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(W=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,g,S,E);else{let Y=cf(s,S,"vertex"),oe=cf(s,E,"fragment");qe("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+` | ||
| 4171 | |||
| 4172 | Material Name: `+P.name+` | ||
| 4173 | Material Type: `+P.type+` | ||
| 4174 | |||
| 4175 | Program Info Log: `+C+` | ||
| 4176 | `+Y+` | ||
| 4177 | `+oe)}else C!==""?ze("WebGLProgram: Program Info Log:",C):(q===""||X==="")&&(ae=!1);ae&&(P.diagnostics={runnable:W,programLog:C,vertexShader:{log:q,prefix:x},fragmentShader:{log:X,prefix:m}})}s.deleteShader(S),s.deleteShader(E),_=new Bs(s,g),b=a_(s,g)}let _;this.getUniforms=function(){return _===void 0&&T(this),_};let b;this.getAttributes=function(){return b===void 0&&T(this),b};let F=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return F===!1&&(F=s.getProgramParameter(g,j0)),F},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=$0++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=S,this.fragmentShader=E,this}var v_=0,mc=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new gc(e),t.set(e,n)),n}},gc=class{constructor(e){this.id=v_++,this.code=e,this.usedTimes=0}};function y_(i){return i===Pi||i===Rr||i===Cr}function M_(i,e,t,n,s,r){let o=new ir,a=new mc,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer,f={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 d(_){return c.add(_),_===0?"uv":`uv${_}`}function g(_,b,F,P,L,B){let K=P.fog,C=L.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,W=e.get(_.envMap||q,X),ae=f[_.type],Y=n.precision;_.precision!==null&&(Y=n.getMaxPrecision(_.precision),Y!==_.precision&&ze("WebGLProgram.getParameters:",_.precision,"not supported, using",Y,"instead."));let oe=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,le=oe!==void 0?oe.length:0,Ie=0;C.morphAttributes.position!==void 0&&(Ie=1),C.morphAttributes.normal!==void 0&&(Ie=2),C.morphAttributes.color!==void 0&&(Ie=3);let He,ee,ye,Ce;if(ae){let Te=qn[ae];He=Te.vertexShader,ee=Te.fragmentShader}else{He=_.vertexShader,ee=_.fragmentShader;let Te=a.getVertexShaderStage(_),mt=a.getFragmentShaderStage(_);a.update(_,Te,mt),ye=Te.id,Ce=mt.id}let ke=i.getRenderTarget(),I=i.state.buffers.depth.getReversed(),D=L.isInstancedMesh===!0,j=L.isBatchedMesh===!0,k=!!_.map,J=!!_.matcap,H=!!W,$=H&&W.isPMREMTexture===!0,ce=!!_.aoMap,re=!!_.lightMap,he=!!_.bumpMap&&_.wireframe===!1,we=!!_.normalMap,de=!!_.displacementMap,Ye=!!_.emissiveMap,je=!!_.metalnessMap,at=!!_.roughnessMap,ct=_.anisotropy>0,N=_.clearcoat>0,Ee=_.diffuseRoughness>0,Pe=_.dispersion>0,Xe=_.retroreflectivity>0,me=_.iridescence>0,ht=_.sheen>0,Ue=_.transmission>0,Oe=ct&&!!_.anisotropyMap,w=N&&!!_.clearcoatMap,v=N&&!!_.clearcoatNormalMap,G=N&&!!_.clearcoatRoughnessMap,ue=Ee&&!!_.diffuseRoughnessMap,se=me&&!!_.iridescenceMap,ge=me&&!!_.iridescenceThicknessMap,Se=ht&&!!_.sheenColorMap,te=ht&&!!_.sheenRoughnessMap,ne=!!_.specularMap,xe=!!_.specularColorMap,R=!!_.specularIntensityMap,ie=Ue&&!!_.transmissionMap,Q=Ue&&!!_.thicknessMap,ve=!!_.gradientMap,pe=!!_.alphaMap,_e=_.alphaTest>0,Ge=!!_.alphaHash,Qe=!!_.extensions,fe=Hn;_.toneMapped&&(ke===null||ke.isXRRenderTarget===!0)&&(fe=i.toneMapping);let Ve=$?W.isCompressedCubeTexture?W.image[0].mipmaps:W.mipmaps:null,$e={shaderID:ae,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:ee,defines:_.defines,customVertexShaderID:ye,customFragmentShaderID:Ce,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:Y,batching:j,batchingColor:j&&L._colorsTexture!==null,instancing:D,instancingColor:D&&L.instanceColor!==null,instancingMorph:D&&L.morphTexture!==null,outputColorSpace:ke===null?i.outputColorSpace:ke.isXRRenderTarget===!0?ke.texture.colorSpace:tt.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:k,matcap:J,envMap:H,envMapMode:H&&W.mapping,envMapPMREM:$,envMapMaxLod:$?Ve.length-1:null,envMapSize:$?Ve[0].width:null,aoMap:ce,lightMap:re,bumpMap:he,normalMap:we,displacementMap:de,emissiveMap:Ye,normalMapObjectSpace:we&&_.normalMapType===Uu,normalMapTangentSpace:we&&_.normalMapType===Pr,packedNormalMap:we&&_.normalMapType===Pr&&y_(_.normalMap.format),metalnessMap:je,roughnessMap:at,anisotropy:ct,anisotropyMap:Oe,clearcoat:N,clearcoatMap:w,clearcoatNormalMap:v,clearcoatRoughnessMap:G,diffuseRoughness:Ee,diffuseRoughnessMap:ue,dispersion:Pe,retroreflection:Xe,iridescence:me,iridescenceMap:se,iridescenceThicknessMap:ge,sheen:ht,sheenColorMap:Se,sheenRoughnessMap:te,specularMap:ne,specularColorMap:xe,specularIntensityMap:R,transmission:Ue,transmissionMap:ie,thicknessMap:Q,gradientMap:ve,opaque:_.transparent===!1&&_.blending===Ls&&_.alphaToCoverage===!1,alphaMap:pe,alphaTest:_e,alphaHash:Ge,combine:_.combine,mapUv:k&&d(_.map.channel),aoMapUv:ce&&d(_.aoMap.channel),lightMapUv:re&&d(_.lightMap.channel),bumpMapUv:he&&d(_.bumpMap.channel),normalMapUv:we&&d(_.normalMap.channel),displacementMapUv:de&&d(_.displacementMap.channel),emissiveMapUv:Ye&&d(_.emissiveMap.channel),metalnessMapUv:je&&d(_.metalnessMap.channel),roughnessMapUv:at&&d(_.roughnessMap.channel),anisotropyMapUv:Oe&&d(_.anisotropyMap.channel),clearcoatMapUv:w&&d(_.clearcoatMap.channel),clearcoatNormalMapUv:v&&d(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:G&&d(_.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:ue&&d(_.diffuseRoughnessMap.channel),iridescenceMapUv:se&&d(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&d(_.iridescenceThicknessMap.channel),sheenColorMapUv:Se&&d(_.sheenColorMap.channel),sheenRoughnessMapUv:te&&d(_.sheenRoughnessMap.channel),specularMapUv:ne&&d(_.specularMap.channel),specularColorMapUv:xe&&d(_.specularColorMap.channel),specularIntensityMapUv:R&&d(_.specularIntensityMap.channel),transmissionMapUv:ie&&d(_.transmissionMap.channel),thicknessMapUv:Q&&d(_.thicknessMap.channel),alphaMapUv:pe&&d(_.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(we||ct),vertexNormals:!!C.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!C.attributes.uv&&(k||pe),fog:!!K,useFog:_.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||C.attributes.normal===void 0&&we===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:I,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:C.attributes.position!==void 0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:Ie,numSunLights:b.sun.length,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numSunLightShadows:b.sunShadowMap.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:B.filter(Te=>Te.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&F.length>0,shadowMapType:i.shadowMap.type,toneMapping:fe,decodeVideoTexture:k&&_.map.isVideoTexture===!0&&tt.getTransfer(_.map.colorSpace)===pt,decodeVideoTextureEmissive:Ye&&_.emissiveMap.isVideoTexture===!0&&tt.getTransfer(_.emissiveMap.colorSpace)===pt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===vn,flipSided:_.side===en,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:Qe&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Qe&&_.extensions.multiDraw===!0||j)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return $e.vertexUv1s=c.has(1),$e.vertexUv2s=c.has(2),$e.vertexUv3s=c.has(3),c.clear(),$e}function x(_){let b=[];if(_.shaderID?b.push(_.shaderID):(b.push(_.customVertexShaderID),b.push(_.customFragmentShaderID)),_.defines!==void 0)for(let F in _.defines)b.push(F),b.push(_.defines[F]);return _.isRawShaderMaterial===!1&&(m(b,_),p(b,_),b.push(i.outputColorSpace)),b.push(_.customProgramCacheKey),b.join()}function m(_,b){_.push(b.precision),_.push(b.outputColorSpace),_.push(b.envMapMode),_.push(b.envMapPMREM),_.push(b.envMapMaxLod),_.push(b.envMapSize),_.push(b.mapUv),_.push(b.alphaMapUv),_.push(b.lightMapUv),_.push(b.aoMapUv),_.push(b.bumpMapUv),_.push(b.normalMapUv),_.push(b.displacementMapUv),_.push(b.emissiveMapUv),_.push(b.metalnessMapUv),_.push(b.roughnessMapUv),_.push(b.anisotropyMapUv),_.push(b.clearcoatMapUv),_.push(b.clearcoatNormalMapUv),_.push(b.clearcoatRoughnessMapUv),_.push(b.diffuseRoughnessMapUv),_.push(b.iridescenceMapUv),_.push(b.iridescenceThicknessMapUv),_.push(b.sheenColorMapUv),_.push(b.sheenRoughnessMapUv),_.push(b.specularMapUv),_.push(b.specularColorMapUv),_.push(b.specularIntensityMapUv),_.push(b.transmissionMapUv),_.push(b.thicknessMapUv),_.push(b.combine),_.push(b.fogExp2),_.push(b.sizeAttenuation),_.push(b.morphTargetsCount),_.push(b.numSunLights),_.push(b.numDirLights),_.push(b.numPointLights),_.push(b.numSpotLights),_.push(b.numSpotLightMaps),_.push(b.numHemiLights),_.push(b.numRectAreaLights),_.push(b.numSunLightShadows),_.push(b.numDirLightShadows),_.push(b.numPointLightShadows),_.push(b.numSpotLightShadows),_.push(b.numSpotLightShadowsWithMaps),_.push(b.numLightProbes),_.push(b.numLightProbeGrids),_.push(b.shadowMapType),_.push(b.toneMapping),_.push(b.numClippingPlanes),_.push(b.numClipIntersection),_.push(b.depthPacking)}function p(_,b){o.disableAll(),b.instancing&&o.enable(0),b.instancingColor&&o.enable(1),b.instancingMorph&&o.enable(2),b.matcap&&o.enable(3),b.envMap&&o.enable(4),b.normalMapObjectSpace&&o.enable(5),b.normalMapTangentSpace&&o.enable(6),b.clearcoat&&o.enable(7),b.iridescence&&o.enable(8),b.alphaTest&&o.enable(9),b.vertexColors&&o.enable(10),b.vertexAlphas&&o.enable(11),b.vertexUv1s&&o.enable(12),b.vertexUv2s&&o.enable(13),b.vertexUv3s&&o.enable(14),b.vertexTangents&&o.enable(15),b.anisotropy&&o.enable(16),b.alphaHash&&o.enable(17),b.batching&&o.enable(18),b.dispersion&&o.enable(19),b.retroreflection&&o.enable(24),b.diffuseRoughness&&o.enable(25),b.batchingColor&&o.enable(20),b.gradientMap&&o.enable(21),b.packedNormalMap&&o.enable(22),b.vertexNormals&&o.enable(23),_.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),b.numLightProbeGrids>0&&o.enable(22),b.hasPositionAttribute&&o.enable(23),_.push(o.mask)}function M(_){let b=f[_.type],F;if(b){let P=qn[b];F=Yu.clone(P.uniforms)}else F=_.uniforms;return F}function A(_,b){let F=h.get(b);return F!==void 0?++F.usedTimes:(F=new x_(i,b,_,s),l.push(F),h.set(b,F)),F}function S(_){if(--_.usedTimes===0){let b=l.indexOf(_);l[b]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function E(_){a.remove(_)}function T(){a.dispose()}return{getParameters:g,getProgramCacheKey:x,getUniforms:M,acquireProgram:A,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:T}}function S_(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,c){i.get(o)[a]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function b_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function pf(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function mf(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(f){let d=0;return f.isInstancedMesh&&(d+=2),f.isSkinnedMesh&&(d+=1),d}function a(f,d,g,x,m,p){let M=i[e];return M===void 0?(M={id:f.id,object:f,geometry:d,material:g,materialVariant:o(f),groupOrder:x,renderOrder:f.renderOrder,z:m,group:p},i[e]=M):(M.id=f.id,M.object=f,M.geometry=d,M.material=g,M.materialVariant=o(f),M.groupOrder=x,M.renderOrder=f.renderOrder,M.z=m,M.group=p),e++,M}function c(f,d,g,x,m,p,M){M.reversedDepth===!0&&(m=-m);let A=a(f,d,g,x,m,p);g.transmission>0?n.push(A):g.transparent===!0?s.push(A):t.push(A)}function l(f,d,g,x,m,p){let M=a(f,d,g,x,m,p);g.transmission>0?n.unshift(M):g.transparent===!0?s.unshift(M):t.unshift(M)}function h(f,d){t.length>1&&t.sort(f||b_),n.length>1&&n.sort(d||pf),s.length>1&&s.sort(d||pf)}function u(){for(let f=e,d=i.length;f<d;f++){let g=i[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function T_(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new mf,i.set(n,[o])):s>=r.length?(o=new mf,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function A_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new O,color:new Be};break;case"SpotLight":t={position:new O,direction:new O,color:new Be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new Be,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new Be,groundColor:new Be};break;case"RectAreaLight":t={color:new Be,position:new O,halfWidth:new O,halfHeight:new O};break}return i[e.id]=t,t}}}function w_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var E_=0;function R_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function C_(i){let e=new A_,t=w_(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new O);let s=new O,r=new Ze,o=new Ze;function a(l){let h=0,u=0,f=0;for(let B=0;B<9;B++)n.probe[B].set(0,0,0);let d=0,g=0,x=0,m=0,p=0,M=0,A=0,S=0,E=0,T=0,_=0,b=0,F=0,P=0;l.sort(R_);for(let B=0,K=l.length;B<K;B++){let C=l[B],q=C.color,X=C.intensity,W=C.distance,ae=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Pi?ae=C.shadow.map.texture:ae=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=q.r*X,u+=q.g*X,f+=q.b*X;else if(C.isLightProbe){for(let Y=0;Y<9;Y++)n.probe[Y].addScaledVector(C.sh.coefficients[Y],X);P++}else if(C.isSunLight){let Y=e.get(C);if(Y.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let oe=C.shadow,le=t.get(C);le.shadowIntensity=oe.intensity,le.shadowBias=oe.bias,le.shadowNormalBias=oe.normalBias,le.shadowRadius=oe.radius,le.shadowMapSize.copy(oe.mapSize).multiply(oe.getFrameExtents()),n.sunShadow[g]=le,n.sunShadowMap[g]=ae;let Ie=oe.getViewportCount();for(let He=0;He<Ie;He++)n.sunShadowMatrix[x+He]=oe.getMatrix(He),n.sunShadowCascade[x+He]=oe._cascadeData[He];x+=Ie,g++}n.sun[d]=Y,d++}else if(C.isDirectionalLight){let Y=e.get(C);if(Y.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let oe=C.shadow,le=t.get(C);le.shadowIntensity=oe.intensity,le.shadowBias=oe.bias,le.shadowNormalBias=oe.normalBias,le.shadowRadius=oe.radius,le.shadowMapSize=oe.mapSize,n.directionalShadow[m]=le,n.directionalShadowMap[m]=ae,n.directionalShadowMatrix[m]=C.shadow.matrix,E++}n.directional[m]=Y,m++}else if(C.isSpotLight){let Y=e.get(C);Y.position.setFromMatrixPosition(C.matrixWorld),Y.color.copy(q).multiplyScalar(X),Y.distance=W,Y.coneCos=Math.cos(C.angle),Y.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),Y.decay=C.decay,n.spot[M]=Y;let oe=C.shadow;if(C.map&&(n.spotLightMap[b]=C.map,b++,oe.updateMatrices(C),C.castShadow&&F++),n.spotLightMatrix[M]=oe.matrix,C.castShadow){let le=t.get(C);le.shadowIntensity=oe.intensity,le.shadowBias=oe.bias,le.shadowNormalBias=oe.normalBias,le.shadowRadius=oe.radius,le.shadowMapSize=oe.mapSize,n.spotShadow[M]=le,n.spotShadowMap[M]=ae,_++}M++}else if(C.isRectAreaLight){let Y=e.get(C);Y.color.copy(q).multiplyScalar(X),Y.halfWidth.set(C.width*.5,0,0),Y.halfHeight.set(0,C.height*.5,0),n.rectArea[A]=Y,A++}else if(C.isPointLight){let Y=e.get(C);if(Y.color.copy(C.color).multiplyScalar(C.intensity),Y.distance=C.distance,Y.decay=C.decay,C.castShadow){let oe=C.shadow,le=t.get(C);le.shadowIntensity=oe.intensity,le.shadowBias=oe.bias,le.shadowNormalBias=oe.normalBias,le.shadowRadius=oe.radius,le.shadowMapSize=oe.mapSize,le.shadowCameraNear=oe.camera.near,le.shadowCameraFar=oe.camera.far,n.pointShadow[p]=le,n.pointShadowMap[p]=ae,n.pointShadowMatrix[p]=C.shadow.matrix,T++}n.point[p]=Y,p++}else if(C.isHemisphereLight){let Y=e.get(C);Y.skyColor.copy(C.color).multiplyScalar(X),Y.groundColor.copy(C.groundColor).multiplyScalar(X),n.hemi[S]=Y,S++}}A>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ae.LTC_FLOAT_1,n.rectAreaLTC2=Ae.LTC_FLOAT_2):(n.rectAreaLTC1=Ae.LTC_HALF_1,n.rectAreaLTC2=Ae.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=f;let L=n.hash;(L.sunLength!==d||L.directionalLength!==m||L.pointLength!==p||L.spotLength!==M||L.rectAreaLength!==A||L.hemiLength!==S||L.numSunShadows!==g||L.numDirectionalShadows!==E||L.numPointShadows!==T||L.numSpotShadows!==_||L.numSpotMaps!==b||L.numLightProbes!==P)&&(n.sun.length=d,n.directional.length=m,n.spot.length=M,n.rectArea.length=A,n.point.length=p,n.hemi.length=S,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=E,n.directionalShadowMap.length=E,n.directionalShadowMatrix.length=E,n.pointShadow.length=T,n.pointShadowMap.length=T,n.pointShadowMatrix.length=T,n.spotShadow.length=_,n.spotShadowMap.length=_,n.spotLightMatrix.length=_+b-F,n.spotLightMap.length=b,n.numSpotLightShadowsWithMaps=F,n.numLightProbes=P,L.sunLength=d,L.directionalLength=m,L.pointLength=p,L.spotLength=M,L.rectAreaLength=A,L.hemiLength=S,L.numSunShadows=g,L.numDirectionalShadows=E,L.numPointShadows=T,L.numSpotShadows=_,L.numSpotMaps=b,L.numLightProbes=P,n.version=E_++)}function c(l,h){let u=0,f=0,d=0,g=0,x=0,m=0,p=h.matrixWorldInverse;for(let M=0,A=l.length;M<A;M++){let S=l[M];if(S.isSunLight){let E=n.sun[u];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),u++}else if(S.isDirectionalLight){let E=n.directional[f];E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),f++}else if(S.isSpotLight){let E=n.spot[g];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),g++}else if(S.isRectAreaLight){let E=n.rectArea[x];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),o.identity(),r.copy(S.matrixWorld),r.premultiply(p),o.extractRotation(r),E.halfWidth.set(S.width*.5,0,0),E.halfHeight.set(0,S.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let E=n.point[d];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),d++}else if(S.isHemisphereLight){let E=n.hemi[m];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),m++}}}return{setup:a,setupView:c,state:n}}function gf(i){let e=new C_(i),t=[],n=[],s=[];function r(u){h.camera=u,t.length=0,n.length=0,s.length=0}function o(u){u.isLightProbeGrid?s.push(u):t.push(u)}function a(u){n.push(u)}function c(){e.setup(t),s.sort((u,f)=>u.priority-f.priority||u.id-f.id)}function l(u){e.setupView(t,u)}let h={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function I_(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new gf(i),e.set(s,[a])):r>=o.length?(a=new gf(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var P_=`void main() { | ||
| 4178 | gl_Position = vec4( position, 1.0 ); | ||
| 4179 | }`,L_=`uniform sampler2D shadow_pass; | ||
| 4180 | uniform vec2 resolution; | ||
| 4181 | uniform float radius; | ||
| 4182 | void main() { | ||
| 4183 | const float samples = float( VSM_SAMPLES ); | ||
| 4184 | float mean = 0.0; | ||
| 4185 | float squared_mean = 0.0; | ||
| 4186 | float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); | ||
| 4187 | float uvStart = samples <= 1.0 ? 0.0 : - 1.0; | ||
| 4188 | for ( float i = 0.0; i < samples; i ++ ) { | ||
| 4189 | float uvOffset = uvStart + i * uvStride; | ||
| 4190 | #ifdef HORIZONTAL_PASS | ||
| 4191 | vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; | ||
| 4192 | mean += distribution.x; | ||
| 4193 | squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; | ||
| 4194 | #else | ||
| 4195 | float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; | ||
| 4196 | mean += depth; | ||
| 4197 | squared_mean += depth * depth; | ||
| 4198 | #endif | ||
| 4199 | } | ||
| 4200 | mean = mean / samples; | ||
| 4201 | squared_mean = squared_mean / samples; | ||
| 4202 | float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); | ||
| 4203 | gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); | ||
| 4204 | }`,D_=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],N_=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],_f=new Ze,Lr=new O,hc=new O;function U_(i,e,t){let n=new wi,s=new We,r=new We,o=new gt,a=new Io,c=new Po,l={},h=t.maxTextureSize,u={[Vn]:en,[en]:Vn,[vn]:vn},f=new zn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new We},radius:{value:4}},vertexShader:P_,fragmentShader:L_}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let g=new _t;g.setAttribute("position",new St(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new bt(g,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=br;let p=this.type;this.render=function(T,_,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;this.type===uu&&(ze("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=br);let F=i.getRenderTarget(),P=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),B=i.state;B.setBlending(Zi),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);let K=p!==this.type;K&&_.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(q=>q.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,q=T.length;C<q;C++){let X=T[C],W=X.shadow;if(W===void 0){ze("WebGLShadowMap:",X,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;s.copy(W.mapSize);let ae=W.getFrameExtents();s.multiply(ae),r.copy(W.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ae.x),s.x=r.x*ae.x,W.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ae.y),s.y=r.y*ae.y,W.mapSize.y=r.y));let Y=i.state.buffers.depth.getReversed();if(W.camera._reversedDepth=Y,W.map===null||K===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===Ps){if(X.isPointLight){ze("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new fn(s.x,s.y,{format:Pi,type:Ln,minFilter:At,magFilter:At,generateMipmaps:!1}),W.map.texture.name=X.name+".shadowMap",W.map.depthTexture=new li(s.x,s.y,dn),W.map.depthTexture.name=X.name+".shadowMapDepth",W.map.depthTexture.format=si,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Tt,W.map.depthTexture.magFilter=Tt}else X.isPointLight?(W.map=new Nr(s.x),W.map.depthTexture=new ur(s.x,Pn)):(W.map=new fn(s.x,s.y),W.map.depthTexture=new li(s.x,s.y,Pn)),W.map.depthTexture.name=X.name+".shadowMap",W.map.depthTexture.format=si,this.type===br?(W.map.depthTexture.compareFunction=Y?ql:Xl,W.map.depthTexture.minFilter=At,W.map.depthTexture.magFilter=At):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Tt,W.map.depthTexture.magFilter=Tt);W.camera.updateProjectionMatrix()}W.map.isWebGLCubeRenderTarget!==!0&&(W.map.width!==s.x||W.map.height!==s.y)&&W.map.setSize(s.x,s.y);let oe=W.map.isWebGLCubeRenderTarget?6:W.getViewportCount();X.isPointLight!==!0&&W.updateMatrices(X,b);let le=(W.camera.layers.mask&4294967294)!==0?W.camera.layers:b.layers;for(let Ie=0;Ie<oe;Ie++){let He=W.getCamera(Ie);if(X.isPointLight){let ee=W.camera,ye=W.matrix,Ce=X.distance||ee.far;Ce!==ee.far&&(ee.far=Ce,ee.updateProjectionMatrix()),Lr.setFromMatrixPosition(X.matrixWorld),ee.position.copy(Lr),hc.copy(ee.position),hc.add(D_[Ie]),ee.up.copy(N_[Ie]),ee.lookAt(hc),ee.updateMatrixWorld(),ye.makeTranslation(-Lr.x,-Lr.y,-Lr.z),_f.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),W._frustum.setFromProjectionMatrix(_f,ee.coordinateSystem,ee.reversedDepth)}if(W.map.isWebGLCubeRenderTarget)i.setRenderTarget(W.map,Ie),i.clear();else{Ie===0&&(i.setRenderTarget(W.map),i.clear());let ee=W.getViewport(Ie);o.set(r.x*ee.x,r.y*ee.y,r.x*ee.z,r.y*ee.w),B.viewport(o)}n=W.getFrustum(Ie),S(_,b,He,X,le,this.type)}W.isPointLightShadow!==!0&&this.type===Ps&&M(W,b),W.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(F,P,L)};function M(T,_){let b=e.update(x);f.defines.VSM_SAMPLES!==T.blurSamples&&(f.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),T.mapPass===null?T.mapPass=new fn(s.x,s.y,{format:Pi,type:Ln}):(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)&&T.mapPass.setSize(T.map.width,T.map.height),f.uniforms.shadow_pass.value=T.map.depthTexture,f.uniforms.resolution.value.set(T.map.width,T.map.height),f.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(_,null,b,f,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(_,null,b,d,x,null)}function A(T,_,b,F){let P=null,L=b.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(L!==void 0)P=L;else if(P=b.isPointLight===!0?c:a,i.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0||_.alphaToCoverage===!0){let B=P.uuid,K=_.uuid,C=l[B];C===void 0&&(C={},l[B]=C);let q=C[K];q===void 0&&(q=P.clone(),C[K]=q,_.addEventListener("dispose",E)),P=q}if(P.visible=_.visible,P.wireframe=_.wireframe,F===Ps?P.side=_.shadowSide!==null?_.shadowSide:_.side:P.side=_.shadowSide!==null?_.shadowSide:u[_.side],P.alphaMap=_.alphaMap,P.alphaTest=_.alphaToCoverage===!0?.5:_.alphaTest,P.map=_.map,P.clipShadows=_.clipShadows,P.clippingPlanes=_.clippingPlanes,P.clipIntersection=_.clipIntersection,P.displacementMap=_.displacementMap,P.displacementScale=_.displacementScale,P.displacementBias=_.displacementBias,P.wireframeLinewidth=_.wireframeLinewidth,P.linewidth=_.linewidth,b.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let B=i.properties.get(P);B.light=b}return P}function S(T,_,b,F,P,L){if(T.visible===!1)return;if(T.layers.test(P)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&L===Ps)&&(!T.frustumCulled||T.intersectsFrustum(n))){T.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,T.matrixWorld);let C=e.update(T),q=T.material;if(Array.isArray(q)){let X=C.groups;for(let W=0,ae=X.length;W<ae;W++){let Y=X[W],oe=q[Y.materialIndex];if(oe&&oe.visible){let le=A(T,oe,F,L);T.onBeforeShadow(i,T,_,b,C,le,Y),i.renderBufferDirect(b,null,C,le,T,Y),T.onAfterShadow(i,T,_,b,C,le,Y)}}}else if(q.visible){let X=A(T,q,F,L);T.onBeforeShadow(i,T,_,b,C,X,null),i.renderBufferDirect(b,null,C,X,T,null),T.onAfterShadow(i,T,_,b,C,X,null)}}let K=T.children;for(let C=0,q=K.length;C<q;C++)S(K[C],_,b,F,P,L)}function E(T){T.target.removeEventListener("dispose",E);for(let b in l){let F=l[b],P=T.target.uuid;P in F&&(F[P].dispose(),delete F[P])}}}function F_(i,e){function t(){let R=!1,ie=new gt,Q=null,ve=new gt(0,0,0,0);return{setMask:function(pe){Q!==pe&&!R&&(i.colorMask(pe,pe,pe,pe),Q=pe)},setLocked:function(pe){R=pe},setClear:function(pe,_e,Ge,Qe,fe){fe===!0&&(pe*=Qe,_e*=Qe,Ge*=Qe),ie.set(pe,_e,Ge,Qe),ve.equals(ie)===!1&&(i.clearColor(pe,_e,Ge,Qe),ve.copy(ie))},reset:function(){R=!1,Q=null,ve.set(-1,0,0,0)}}}function n(){let R=!1,ie=!1,Q=null,ve=null,pe=null;return{setReversed:function(_e){if(ie!==_e){let Ge=e.get("EXT_clip_control");_e?Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.ZERO_TO_ONE_EXT):Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.NEGATIVE_ONE_TO_ONE_EXT),ie=_e;let Qe=pe;pe=null,this.setClear(Qe)}},getReversed:function(){return ie},setTest:function(_e){_e?I(i.DEPTH_TEST):D(i.DEPTH_TEST)},setMask:function(_e){Q!==_e&&!R&&(i.depthMask(_e),Q=_e)},setFunc:function(_e){if(ie&&(_e=Xu[_e]),ve!==_e){switch(_e){case mo:i.depthFunc(i.NEVER);break;case go:i.depthFunc(i.ALWAYS);break;case _o:i.depthFunc(i.LESS);break;case gs:i.depthFunc(i.LEQUAL);break;case xo:i.depthFunc(i.EQUAL);break;case vo:i.depthFunc(i.GEQUAL);break;case yo:i.depthFunc(i.GREATER);break;case Mo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ve=_e}},setLocked:function(_e){R=_e},setClear:function(_e){pe!==_e&&(pe=_e,ie&&(_e=1-_e),i.clearDepth(_e))},reset:function(){R=!1,Q=null,ve=null,pe=null,ie=!1}}}function s(){let R=!1,ie=null,Q=null,ve=null,pe=null,_e=null,Ge=null,Qe=null,fe=null;return{setTest:function(Ve){R||(Ve?I(i.STENCIL_TEST):D(i.STENCIL_TEST))},setMask:function(Ve){ie!==Ve&&!R&&(i.stencilMask(Ve),ie=Ve)},setFunc:function(Ve,$e,Te){(Q!==Ve||ve!==$e||pe!==Te)&&(i.stencilFunc(Ve,$e,Te),Q=Ve,ve=$e,pe=Te)},setOp:function(Ve,$e,Te){(_e!==Ve||Ge!==$e||Qe!==Te)&&(i.stencilOp(Ve,$e,Te),_e=Ve,Ge=$e,Qe=Te)},setLocked:function(Ve){R=Ve},setClear:function(Ve){fe!==Ve&&(i.clearStencil(Ve),fe=Ve)},reset:function(){R=!1,ie=null,Q=null,ve=null,pe=null,_e=null,Ge=null,Qe=null,fe=null}}}let r=new t,o=new n,a=new s,c={},l=new WeakMap,h={},u={},f={},d=new WeakMap,g=[],x=null,m=!1,p=null,M=null,A=null,S=null,E=null,T=null,_=null,b=new Be(0,0,0),F=0,P=!1,L=null,B=null,K=null,C=null,q=null,X=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,ae=0,Y=i.getParameter(i.VERSION);Y.indexOf("WebGL")!==-1?(ae=parseFloat(/^WebGL (\d)/.exec(Y)[1]),W=ae>=1):Y.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),W=ae>=2);let oe=null,le={},Ie=i.getParameter(i.SCISSOR_BOX),He=i.getParameter(i.VIEWPORT),ee=new gt().fromArray(Ie),ye=new gt().fromArray(He);function Ce(R,ie,Q,ve){let pe=new Uint8Array(4),_e=i.createTexture();i.bindTexture(R,_e),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ge=0;Ge<Q;Ge++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(ie,0,i.RGBA,1,1,ve,0,i.RGBA,i.UNSIGNED_BYTE,pe):i.texImage2D(ie+Ge,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,pe);return _e}let ke={};ke[i.TEXTURE_2D]=Ce(i.TEXTURE_2D,i.TEXTURE_2D,1),ke[i.TEXTURE_CUBE_MAP]=Ce(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ke[i.TEXTURE_2D_ARRAY]=Ce(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ke[i.TEXTURE_3D]=Ce(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),I(i.DEPTH_TEST),o.setFunc(gs),he(!1),we(Tl),I(i.CULL_FACE),ce(Zi);function I(R){h[R]!==!0&&(i.enable(R),h[R]=!0)}function D(R){h[R]!==!1&&(i.disable(R),h[R]=!1)}function j(R,ie){return f[R]!==ie?(i.bindFramebuffer(R,ie),f[R]=ie,R===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=ie),R===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=ie),!0):!1}function k(R,ie){let Q=g,ve=!1;if(R){Q=d.get(ie),Q===void 0&&(Q=[],d.set(ie,Q));let pe=R.textures;if(Q.length!==pe.length||Q[0]!==i.COLOR_ATTACHMENT0){for(let _e=0,Ge=pe.length;_e<Ge;_e++)Q[_e]=i.COLOR_ATTACHMENT0+_e;Q.length=pe.length,ve=!0}}else Q[0]!==i.BACK&&(Q[0]=i.BACK,ve=!0);ve&&i.drawBuffers(Q)}function J(R){return x!==R?(i.useProgram(R),x=R,!0):!1}let H={[Ki]:i.FUNC_ADD,[du]:i.FUNC_SUBTRACT,[pu]:i.FUNC_REVERSE_SUBTRACT};H[mu]=i.MIN,H[gu]=i.MAX;let $={[_u]:i.ZERO,[xu]:i.ONE,[vu]:i.SRC_COLOR,[Rl]:i.SRC_ALPHA,[Au]:i.SRC_ALPHA_SATURATE,[bu]:i.DST_COLOR,[Mu]:i.DST_ALPHA,[yu]:i.ONE_MINUS_SRC_COLOR,[Cl]:i.ONE_MINUS_SRC_ALPHA,[Tu]:i.ONE_MINUS_DST_COLOR,[Su]:i.ONE_MINUS_DST_ALPHA,[wu]:i.CONSTANT_COLOR,[Eu]:i.ONE_MINUS_CONSTANT_COLOR,[Ru]:i.CONSTANT_ALPHA,[Cu]:i.ONE_MINUS_CONSTANT_ALPHA};function ce(R,ie,Q,ve,pe,_e,Ge,Qe,fe,Ve){if(R===Zi){m===!0&&(D(i.BLEND),m=!1);return}if(m===!1&&(I(i.BLEND),m=!0),R!==fu){if(R!==p||Ve!==P){if((M!==Ki||E!==Ki)&&(i.blendEquation(i.FUNC_ADD),M=Ki,E=Ki),Ve)switch(R){case Ls:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Al:i.blendFunc(i.ONE,i.ONE);break;case wl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case El:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:qe("WebGLState: Invalid blending: ",R);break}else switch(R){case Ls:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Al:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case wl:qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case El:qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:qe("WebGLState: Invalid blending: ",R);break}A=null,S=null,T=null,_=null,b.set(0,0,0),F=0,p=R,P=Ve}return}pe=pe||ie,_e=_e||Q,Ge=Ge||ve,(ie!==M||pe!==E)&&(i.blendEquationSeparate(H[ie],H[pe]),M=ie,E=pe),(Q!==A||ve!==S||_e!==T||Ge!==_)&&(i.blendFuncSeparate($[Q],$[ve],$[_e],$[Ge]),A=Q,S=ve,T=_e,_=Ge),(Qe.equals(b)===!1||fe!==F)&&(i.blendColor(Qe.r,Qe.g,Qe.b,fe),b.copy(Qe),F=fe),p=R,P=!1}function re(R,ie){R.side===vn?D(i.CULL_FACE):I(i.CULL_FACE);let Q=R.side===en;ie&&(Q=!Q),he(Q),R.blending===Ls&&R.transparent===!1?ce(Zi):ce(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),o.setFunc(R.depthFunc),o.setTest(R.depthTest),o.setMask(R.depthWrite),r.setMask(R.colorWrite);let ve=R.stencilWrite;a.setTest(ve),ve&&(a.setMask(R.stencilWriteMask),a.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),a.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),Ye(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?I(i.SAMPLE_ALPHA_TO_COVERAGE):D(i.SAMPLE_ALPHA_TO_COVERAGE)}function he(R){L!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),L=R)}function we(R){R!==cu?(I(i.CULL_FACE),R!==B&&(R===Tl?i.cullFace(i.BACK):R===hu?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):D(i.CULL_FACE),B=R}function de(R){R!==K&&(W&&i.lineWidth(R),K=R)}function Ye(R,ie,Q){R?(I(i.POLYGON_OFFSET_FILL),(C!==ie||q!==Q)&&(C=ie,q=Q,o.getReversed()&&(ie=-ie,Q=-Q),i.polygonOffset(ie,Q))):D(i.POLYGON_OFFSET_FILL)}function je(R){R?I(i.SCISSOR_TEST):D(i.SCISSOR_TEST)}function at(R){R===void 0&&(R=i.TEXTURE0+X-1),oe!==R&&(i.activeTexture(R),oe=R)}function ct(R,ie,Q){Q===void 0&&(oe===null?Q=i.TEXTURE0+X-1:Q=oe);let ve=le[Q];ve===void 0&&(ve={type:void 0,texture:void 0},le[Q]=ve),(ve.type!==R||ve.texture!==ie)&&(oe!==Q&&(i.activeTexture(Q),oe=Q),i.bindTexture(R,ie||ke[R]),ve.type=R,ve.texture=ie)}function N(){let R=le[oe];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function Ee(){try{i.compressedTexImage2D(...arguments)}catch(R){qe("WebGLState:",R)}}function Pe(){try{i.compressedTexImage3D(...arguments)}catch(R){qe("WebGLState:",R)}}function Xe(){try{i.texSubImage2D(...arguments)}catch(R){qe("WebGLState:",R)}}function me(){try{i.texSubImage3D(...arguments)}catch(R){qe("WebGLState:",R)}}function ht(){try{i.compressedTexSubImage2D(...arguments)}catch(R){qe("WebGLState:",R)}}function Ue(){try{i.compressedTexSubImage3D(...arguments)}catch(R){qe("WebGLState:",R)}}function Oe(){try{i.texStorage2D(...arguments)}catch(R){qe("WebGLState:",R)}}function w(){try{i.texStorage3D(...arguments)}catch(R){qe("WebGLState:",R)}}function v(){try{i.texImage2D(...arguments)}catch(R){qe("WebGLState:",R)}}function G(){try{i.texImage3D(...arguments)}catch(R){qe("WebGLState:",R)}}function ue(R){return u[R]!==void 0?u[R]:i.getParameter(R)}function se(R,ie){u[R]!==ie&&(i.pixelStorei(R,ie),u[R]=ie)}function ge(R){ee.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),ee.copy(R))}function Se(R){ye.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),ye.copy(R))}function te(R,ie){let Q=l.get(ie);Q===void 0&&(Q=new WeakMap,l.set(ie,Q));let ve=Q.get(R);ve===void 0&&(ve=i.getUniformBlockIndex(ie,R.name),i.uniformBlockBinding(ie,ve,ve),Q.set(R,ve))}function ne(R,ie,Q){let pe=l.get(ie).get(R);c[pe]!==Q&&(i.bindBufferBase(i.UNIFORM_BUFFER,pe,Q),c[pe]=Q)}function xe(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},oe=null,le={},f={},c={},d=new WeakMap,g=[],x=null,m=!1,p=null,M=null,A=null,S=null,E=null,T=null,_=null,b=new Be(0,0,0),F=0,P=!1,L=null,B=null,K=null,C=null,q=null,ee.set(0,0,i.canvas.width,i.canvas.height),ye.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:I,disable:D,bindFramebuffer:j,drawBuffers:k,useProgram:J,setBlending:ce,setMaterial:re,setFlipSided:he,setCullFace:we,setLineWidth:de,setPolygonOffset:Ye,setScissorTest:je,activeTexture:at,bindTexture:ct,unbindTexture:N,compressedTexImage2D:Ee,compressedTexImage3D:Pe,texImage2D:v,texImage3D:G,pixelStorei:se,getParameter:ue,updateUBOMapping:te,uniformBlockBinding:ne,texStorage2D:Oe,texStorage3D:w,texSubImage2D:Xe,texSubImage3D:me,compressedTexSubImage2D:ht,compressedTexSubImage3D:Ue,scissor:ge,viewport:Se,reset:xe}}function O_(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new We,h=new WeakMap,u=new Set,f,d=new WeakMap,g=new Set,x=new FinalizationRegistry(w=>g.delete(w)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(w,v){return m?new OffscreenCanvas(w,v):xs("canvas")}function M(w,v,G){let ue=1,se=Oe(w);if((se.width>G||se.height>G)&&(ue=G/Math.max(se.width,se.height)),ue<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ge=Math.floor(ue*se.width),Se=Math.floor(ue*se.height);f===void 0&&(f=p(ge,Se));let te=v?p(ge,Se):f;return te.width=ge,te.height=Se,te.getContext("2d").drawImage(w,0,0,ge,Se),ze("WebGLRenderer: Texture has been resized from ("+se.width+"x"+se.height+") to ("+ge+"x"+Se+")."),te}else return"data"in w&&ze("WebGLRenderer: Image in DataTexture is too big ("+se.width+"x"+se.height+")."),w;return w}function A(w){return w.generateMipmaps}function S(w){i.generateMipmap(w)}function E(w){return w.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?i.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function T(w,v,G,ue,se,ge=!1){if(w!==null){if(i[w]!==void 0)return i[w];ze("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let Se;ue&&(Se=e.get("EXT_texture_norm16"),Se||ze("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let te=v;if(v===i.RED&&(G===i.FLOAT&&(te=i.R32F),G===i.HALF_FLOAT&&(te=i.R16F),G===i.UNSIGNED_BYTE&&(te=i.R8),G===i.UNSIGNED_SHORT&&Se&&(te=Se.R16_EXT),G===i.SHORT&&Se&&(te=Se.R16_SNORM_EXT)),v===i.RED_INTEGER&&(G===i.UNSIGNED_BYTE&&(te=i.R8UI),G===i.UNSIGNED_SHORT&&(te=i.R16UI),G===i.UNSIGNED_INT&&(te=i.R32UI),G===i.BYTE&&(te=i.R8I),G===i.SHORT&&(te=i.R16I),G===i.INT&&(te=i.R32I)),v===i.RG&&(G===i.FLOAT&&(te=i.RG32F),G===i.HALF_FLOAT&&(te=i.RG16F),G===i.UNSIGNED_BYTE&&(te=i.RG8),G===i.UNSIGNED_SHORT&&Se&&(te=Se.RG16_EXT),G===i.SHORT&&Se&&(te=Se.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(G===i.UNSIGNED_BYTE&&(te=i.RG8UI),G===i.UNSIGNED_SHORT&&(te=i.RG16UI),G===i.UNSIGNED_INT&&(te=i.RG32UI),G===i.BYTE&&(te=i.RG8I),G===i.SHORT&&(te=i.RG16I),G===i.INT&&(te=i.RG32I)),v===i.RGB_INTEGER&&(G===i.UNSIGNED_BYTE&&(te=i.RGB8UI),G===i.UNSIGNED_SHORT&&(te=i.RGB16UI),G===i.UNSIGNED_INT&&(te=i.RGB32UI),G===i.BYTE&&(te=i.RGB8I),G===i.SHORT&&(te=i.RGB16I),G===i.INT&&(te=i.RGB32I)),v===i.RGBA_INTEGER&&(G===i.UNSIGNED_BYTE&&(te=i.RGBA8UI),G===i.UNSIGNED_SHORT&&(te=i.RGBA16UI),G===i.UNSIGNED_INT&&(te=i.RGBA32UI),G===i.BYTE&&(te=i.RGBA8I),G===i.SHORT&&(te=i.RGBA16I),G===i.INT&&(te=i.RGBA32I)),v===i.RGB&&(G===i.UNSIGNED_SHORT&&Se&&(te=Se.RGB16_EXT),G===i.SHORT&&Se&&(te=Se.RGB16_SNORM_EXT),G===i.UNSIGNED_INT_5_9_9_9_REV&&(te=i.RGB9_E5),G===i.UNSIGNED_INT_10F_11F_11F_REV&&(te=i.R11F_G11F_B10F)),v===i.RGBA){let ne=ge?er:tt.getTransfer(se);G===i.FLOAT&&(te=i.RGBA32F),G===i.HALF_FLOAT&&(te=i.RGBA16F),G===i.UNSIGNED_BYTE&&(te=ne===pt?i.SRGB8_ALPHA8:i.RGBA8),G===i.UNSIGNED_SHORT&&Se&&(te=Se.RGBA16_EXT),G===i.SHORT&&Se&&(te=Se.RGBA16_SNORM_EXT),G===i.UNSIGNED_SHORT_4_4_4_4&&(te=i.RGBA4),G===i.UNSIGNED_SHORT_5_5_5_1&&(te=i.RGB5_A1)}return(te===i.R16F||te===i.R32F||te===i.RG16F||te===i.RG32F||te===i.RGBA16F||te===i.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function _(w,v){let G;return w?v===null||v===Pn||v===$i?G=i.DEPTH24_STENCIL8:v===dn?G=i.DEPTH32F_STENCIL8:v===Us&&(G=i.DEPTH24_STENCIL8,ze("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Pn||v===$i?G=i.DEPTH_COMPONENT24:v===dn?G=i.DEPTH_COMPONENT32F:v===Us&&(G=i.DEPTH_COMPONENT16),G}function b(w,v){return A(w)===!0||w.isFramebufferTexture&&w.minFilter!==Tt&&w.minFilter!==At?Math.log2(Math.max(v.width,v.height))+1:w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?v.mipmaps.length:1}function F(w){let v=new WeakRef(w);n.get(w).__ref=v,g.add(v),x.register(w,v,v)}function P(w){let v=n.get(w).__ref;v!==void 0&&(g.delete(v),x.unregister(v))}function L(w){K(w.target)}function B(w){C(w.target)}function K(w){w.removeEventListener("dispose",L),P(w),X(w),w.isVideoTexture&&h.delete(w),w.isHTMLTexture&&u.delete(w)}function C(w){w.removeEventListener("dispose",B),P(w),ae(w)}function q(){for(let w of g){let v=w.deref();v!==void 0&&(v.isRenderTarget===!0?C(v):K(v))}g.clear(),u.clear()}function X(w){let v=n.get(w);if(v.__webglInit===void 0)return;let G=w.source,ue=d.get(G);if(ue){let se=ue[v.__cacheKey];se.usedTimes--,se.usedTimes===0&&W(w),Object.keys(ue).length===0&&d.delete(G)}n.remove(w)}function W(w){let v=n.get(w);i.deleteTexture(v.__webglTexture);let G=w.source,ue=d.get(G);delete ue[v.__cacheKey],o.memory.textures--}function ae(w){let v=n.get(w);v.__depthDisposeCallback&&v.__depthDisposeCallback();let G=w.depthTexture;if(G&&G.renderTarget===w&&K(G),w.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(v.__webglFramebuffer[se]))for(let ge=0;ge<v.__webglFramebuffer[se].length;ge++)i.deleteFramebuffer(v.__webglFramebuffer[se][ge]);else i.deleteFramebuffer(v.__webglFramebuffer[se]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[se])}else{if(Array.isArray(v.__webglFramebuffer))for(let se=0;se<v.__webglFramebuffer.length;se++)i.deleteFramebuffer(v.__webglFramebuffer[se]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let se=0;se<v.__webglColorRenderbuffer.length;se++)v.__webglColorRenderbuffer[se]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[se]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let ue=w.textures;for(let se=0,ge=ue.length;se<ge;se++){let Se=n.get(ue[se]);Se.__webglTexture&&(i.deleteTexture(Se.__webglTexture),o.memory.textures--),n.remove(ue[se])}n.remove(w)}let Y=0;function oe(){Y=0}function le(){return Y}function Ie(w){Y=w}function He(){let w=Y;return w>=s.maxTextures&&ze("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+s.maxTextures),Y+=1,w}function ee(w){let v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.mipmapsAutoUpdate),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function ye(w,v){let G=n.get(w);if(w.isVideoTexture&&ht(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&G.__version!==w.version){let ue=w.image;if(ue===null)ze("WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)ze("WebGLRenderer: Texture marked for update but image is incomplete");else{re(G,w,v);return}}else w.isExternalTexture&&(G.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,G.__webglTexture,i.TEXTURE0+v)}function Ce(w,v){let G=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&G.__version!==w.version){re(G,w,v);return}else w.isExternalTexture&&(G.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,G.__webglTexture,i.TEXTURE0+v)}function ke(w,v){let G=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&G.__version!==w.version){re(G,w,v);return}t.bindTexture(i.TEXTURE_3D,G.__webglTexture,i.TEXTURE0+v)}function I(w,v){let G=n.get(w);if(w.version>0&&G.__version!==w.version){he(G,w,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture,i.TEXTURE0+v)}let D={[un]:i.REPEAT,[jt]:i.CLAMP_TO_EDGE,[ii]:i.MIRRORED_REPEAT},j={[Tt]:i.NEAREST,[Xo]:i.NEAREST_MIPMAP_NEAREST,[ji]:i.NEAREST_MIPMAP_LINEAR,[At]:i.LINEAR,[Ns]:i.LINEAR_MIPMAP_NEAREST,[tn]:i.LINEAR_MIPMAP_LINEAR},k={[Ou]:i.NEVER,[Yl]:i.ALWAYS,[Bu]:i.LESS,[Xl]:i.LEQUAL,[zu]:i.EQUAL,[ql]:i.GEQUAL,[ku]:i.GREATER,[Gu]:i.NOTEQUAL};function J(w,v){if(v.type===dn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===At||v.magFilter===Ns||v.magFilter===ji||v.magFilter===tn||v.minFilter===At||v.minFilter===Ns||v.minFilter===ji||v.minFilter===tn)&&ze("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(w,i.TEXTURE_WRAP_S,D[v.wrapS]),i.texParameteri(w,i.TEXTURE_WRAP_T,D[v.wrapT]),(w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY)&&i.texParameteri(w,i.TEXTURE_WRAP_R,D[v.wrapR]),i.texParameteri(w,i.TEXTURE_MAG_FILTER,j[v.magFilter]),i.texParameteri(w,i.TEXTURE_MIN_FILTER,j[v.minFilter]),v.compareFunction&&(i.texParameteri(w,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(w,i.TEXTURE_COMPARE_FUNC,k[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Tt||v.minFilter!==ji&&v.minFilter!==tn||v.type===dn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){let G=e.get("EXT_texture_filter_anisotropic");i.texParameterf(w,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function H(w,v){let G=!1;w.__webglInit===void 0&&(w.__webglInit=!0,v.addEventListener("dispose",L),F(v));let ue=v.source,se=d.get(ue);se===void 0&&(se={},d.set(ue,se));let ge=ee(v);if(ge!==w.__cacheKey){se[ge]===void 0&&(se[ge]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,G=!0),se[ge].usedTimes++;let Se=se[w.__cacheKey];Se!==void 0&&(se[w.__cacheKey].usedTimes--,Se.usedTimes===0&&W(v)),w.__cacheKey=ge,w.__webglTexture=se[ge].texture}return G}function $(w,v,G){return Math.floor(Math.floor(w/G)/v)}function ce(w,v,G,ue){let ge=w.updateRanges;if(ge.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,G,ue,v.data);else{ge.sort((R,ie)=>R.start-ie.start);let Se=0;for(let R=1;R<ge.length;R++){let ie=ge[Se],Q=ge[R],ve=ie.start+ie.count,pe=$(Q.start,v.width,4),_e=$(ie.start,v.width,4);Q.start<=ve+1&&pe===_e&&$(Q.start+Q.count-1,v.width,4)===pe?ie.count=Math.max(ie.count,Q.start+Q.count-ie.start):(++Se,ge[Se]=Q)}ge.length=Se+1;let te=t.getParameter(i.UNPACK_ROW_LENGTH),ne=t.getParameter(i.UNPACK_SKIP_PIXELS),xe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let R=0,ie=ge.length;R<ie;R++){let Q=ge[R],ve=Math.floor(Q.start/4),pe=Math.ceil(Q.count/4),_e=ve%v.width,Ge=Math.floor(ve/v.width),Qe=pe,fe=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,_e),t.pixelStorei(i.UNPACK_SKIP_ROWS,Ge),t.texSubImage2D(i.TEXTURE_2D,0,_e,Ge,Qe,fe,G,ue,v.data)}w.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,te),t.pixelStorei(i.UNPACK_SKIP_PIXELS,ne),t.pixelStorei(i.UNPACK_SKIP_ROWS,xe)}}function re(w,v,G){let ue=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(ue=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(ue=i.TEXTURE_3D);let se=H(w,v),ge=v.source;t.bindTexture(ue,w.__webglTexture,i.TEXTURE0+G);let Se=n.get(ge);if(ge.version!==Se.__version||se===!0){if(t.activeTexture(i.TEXTURE0+G),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let fe=tt.getPrimaries(tt.workingColorSpace),Ve=v.colorSpace===mi?null:tt.getPrimaries(v.colorSpace),$e=v.colorSpace===mi||fe===Ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e)}t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment);let ne=M(v.image,!1,s.maxTextureSize);ne=Ue(v,ne);let xe=r.convert(v.format,v.colorSpace),R=r.convert(v.type),ie=T(v.internalFormat,xe,R,v.normalized,v.colorSpace,v.isVideoTexture);J(ue,v);let Q,ve=v.mipmaps,pe=v.isVideoTexture!==!0,_e=Se.__version===void 0||se===!0,Ge=ge.dataReady,Qe=b(v,ne);if(v.isDepthTexture)ie=_(v.format===pi,v.type),_e&&(pe?t.texStorage2D(i.TEXTURE_2D,1,ie,ne.width,ne.height):t.texImage2D(i.TEXTURE_2D,0,ie,ne.width,ne.height,0,xe,R,null));else if(v.isDataTexture)if(ve.length>0){pe&&_e&&t.texStorage2D(i.TEXTURE_2D,Qe,ie,ve[0].width,ve[0].height);for(let fe=0,Ve=ve.length;fe<Ve;fe++)Q=ve[fe],pe?Ge&&t.texSubImage2D(i.TEXTURE_2D,fe,0,0,Q.width,Q.height,xe,R,Q.data):t.texImage2D(i.TEXTURE_2D,fe,ie,Q.width,Q.height,0,xe,R,Q.data);v.generateMipmaps=!1}else pe?(_e&&t.texStorage2D(i.TEXTURE_2D,Qe,ie,ne.width,ne.height),Ge&&ce(v,ne,xe,R)):t.texImage2D(i.TEXTURE_2D,0,ie,ne.width,ne.height,0,xe,R,ne.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){pe&&_e&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Qe,ie,ve[0].width,ve[0].height,ne.depth);for(let fe=0,Ve=ve.length;fe<Ve;fe++)if(Q=ve[fe],v.format!==yn)if(xe!==null)if(pe){if(Ge)if(v.layerUpdates.size>0){let $e=ic(Q.width,Q.height,v.format,v.type);for(let Te of v.layerUpdates){let mt=Q.data.subarray(Te*$e/Q.data.BYTES_PER_ELEMENT,(Te+1)*$e/Q.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,fe,0,0,Te,Q.width,Q.height,1,xe,mt)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,fe,0,0,0,Q.width,Q.height,ne.depth,xe,Q.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,fe,ie,Q.width,Q.height,ne.depth,0,Q.data,0,0);else ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else pe?Ge&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,fe,0,0,0,Q.width,Q.height,ne.depth,xe,R,Q.data):t.texImage3D(i.TEXTURE_2D_ARRAY,fe,ie,Q.width,Q.height,ne.depth,0,xe,R,Q.data);v.layerUpdates.size>0&&v.clearLayerUpdates()}else{pe&&_e&&t.texStorage2D(i.TEXTURE_2D,Qe,ie,ve[0].width,ve[0].height);for(let fe=0,Ve=ve.length;fe<Ve;fe++)Q=ve[fe],v.format!==yn?xe!==null?pe?Ge&&t.compressedTexSubImage2D(i.TEXTURE_2D,fe,0,0,Q.width,Q.height,xe,Q.data):t.compressedTexImage2D(i.TEXTURE_2D,fe,ie,Q.width,Q.height,0,Q.data):ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?Ge&&t.texSubImage2D(i.TEXTURE_2D,fe,0,0,Q.width,Q.height,xe,R,Q.data):t.texImage2D(i.TEXTURE_2D,fe,ie,Q.width,Q.height,0,xe,R,Q.data)}else if(v.isDataArrayTexture)if(pe){if(_e&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Qe,ie,ne.width,ne.height,ne.depth),Ge)if(v.layerUpdates.size>0){let fe=ic(ne.width,ne.height,v.format,v.type);for(let Ve of v.layerUpdates){let $e=ne.data.subarray(Ve*fe/ne.data.BYTES_PER_ELEMENT,(Ve+1)*fe/ne.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Ve,ne.width,ne.height,1,xe,R,$e)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ne.width,ne.height,ne.depth,xe,R,ne.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ie,ne.width,ne.height,ne.depth,0,xe,R,ne.data);else if(v.isData3DTexture)pe?(_e&&t.texStorage3D(i.TEXTURE_3D,Qe,ie,ne.width,ne.height,ne.depth),Ge&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ne.width,ne.height,ne.depth,xe,R,ne.data)):t.texImage3D(i.TEXTURE_3D,0,ie,ne.width,ne.height,ne.depth,0,xe,R,ne.data);else if(v.isFramebufferTexture){if(_e)if(pe)t.texStorage2D(i.TEXTURE_2D,Qe,ie,ne.width,ne.height);else{let fe=ne.width,Ve=ne.height;for(let $e=0;$e<Qe;$e++)t.texImage2D(i.TEXTURE_2D,$e,ie,fe,Ve,0,xe,R,null),fe>>=1,Ve>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in i){let fe=i.canvas;if(fe.hasAttribute("layoutsubtree")||fe.setAttribute("layoutsubtree","true"),ne.parentNode!==fe){fe.appendChild(ne),u.add(v),fe.onpaint=Ve=>{let $e=Ve.changedElements;for(let Te of u)$e.includes(Te.image)&&(Te.needsUpdate=!0)},fe.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,ne);else{let $e=i.RGBA,Te=i.RGBA,mt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,$e,Te,mt,ne)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(ve.length>0){if(pe&&_e){let fe=Oe(ve[0]);t.texStorage2D(i.TEXTURE_2D,Qe,ie,fe.width,fe.height)}for(let fe=0,Ve=ve.length;fe<Ve;fe++)Q=ve[fe],pe?Ge&&t.texSubImage2D(i.TEXTURE_2D,fe,0,0,xe,R,Q):t.texImage2D(i.TEXTURE_2D,fe,ie,xe,R,Q);v.generateMipmaps=!1}else if(pe){if(_e){let fe=Oe(ne);t.texStorage2D(i.TEXTURE_2D,Qe,ie,fe.width,fe.height)}Ge&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,xe,R,ne)}else t.texImage2D(i.TEXTURE_2D,0,ie,xe,R,ne);A(v)&&v.mipmapsAutoUpdate===!0&&S(ue),Se.__version=ge.version,v.onUpdate&&v.onUpdate(v)}w.__version=v.version}function he(w,v,G){if(v.image.length!==6)return;let ue=H(w,v),se=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,w.__webglTexture,i.TEXTURE0+G);let ge=n.get(se);if(se.version!==ge.__version||ue===!0){t.activeTexture(i.TEXTURE0+G);let Se=tt.getPrimaries(tt.workingColorSpace),te=v.colorSpace===mi?null:tt.getPrimaries(v.colorSpace),ne=v.colorSpace===mi||Se===te?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ne);let xe=v.isCompressedTexture||v.image[0].isCompressedTexture,R=v.image[0]&&v.image[0].isDataTexture,ie=[];for(let Te=0;Te<6;Te++)!xe&&!R?ie[Te]=M(v.image[Te],!0,s.maxCubemapSize):ie[Te]=R?v.image[Te].image:v.image[Te],ie[Te]=Ue(v,ie[Te]);let Q=ie[0],ve=r.convert(v.format,v.colorSpace),pe=r.convert(v.type),_e=T(v.internalFormat,ve,pe,v.normalized,v.colorSpace),Ge=v.isVideoTexture!==!0,Qe=ge.__version===void 0||ue===!0,fe=se.dataReady,Ve=b(v,Q);J(i.TEXTURE_CUBE_MAP,v);let $e;if(v.isDepthTexture){if(_e=_(v.format===pi,v.type),Qe)if(Ge)t.texStorage2D(i.TEXTURE_CUBE_MAP,1,_e,Q.width,Q.height);else for(let Te=0;Te<6;Te++)t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,_e,Q.width,Q.height,0,ve,pe,null)}else if(xe){Ge&&Qe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Ve,_e,Q.width,Q.height);for(let Te=0;Te<6;Te++){$e=ie[Te].mipmaps;for(let mt=0;mt<$e.length;mt++){let Nt=$e[mt];v.format!==yn?ve!==null?Ge?fe&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt,0,0,Nt.width,Nt.height,ve,Nt.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt,_e,Nt.width,Nt.height,0,Nt.data):ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ge?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt,0,0,Nt.width,Nt.height,ve,pe,Nt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt,_e,Nt.width,Nt.height,0,ve,pe,Nt.data)}}}else{if($e=v.mipmaps,Ge&&Qe){$e.length>0&&Ve++;let Te=Oe(ie[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ve,_e,Te.width,Te.height)}for(let Te=0;Te<6;Te++)if(R){Ge?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,ie[Te].width,ie[Te].height,ve,pe,ie[Te].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,_e,ie[Te].width,ie[Te].height,0,ve,pe,ie[Te].data);for(let mt=0;mt<$e.length;mt++){let _i=$e[mt].image[Te].image;Ge?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt+1,0,0,_i.width,_i.height,ve,pe,_i.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt+1,_e,_i.width,_i.height,0,ve,pe,_i.data)}}else{Ge?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,ve,pe,ie[Te]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,_e,ve,pe,ie[Te]);for(let mt=0;mt<$e.length;mt++){let Nt=$e[mt];Ge?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt+1,0,0,ve,pe,Nt.image[Te]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Te,mt+1,_e,ve,pe,Nt.image[Te])}}}A(v)&&v.mipmapsAutoUpdate===!0&&S(i.TEXTURE_CUBE_MAP),ge.__version=se.version,v.onUpdate&&v.onUpdate(v)}w.__version=v.version}function we(w,v,G,ue,se,ge){let Se=r.convert(G.format,G.colorSpace),te=r.convert(G.type),ne=T(G.internalFormat,Se,te,G.normalized,G.colorSpace),xe=n.get(v),R=n.get(G);if(R.__renderTarget=v,!xe.__hasExternalTextures){let ie=Math.max(1,v.width>>ge),Q=Math.max(1,v.height>>ge);se===i.TEXTURE_3D||se===i.TEXTURE_2D_ARRAY?t.texImage3D(se,ge,ne,ie,Q,v.depth,0,Se,te,null):t.texImage2D(se,ge,ne,ie,Q,0,Se,te,null)}t.bindFramebuffer(i.FRAMEBUFFER,w),me(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ue,se,R.__webglTexture,0,Xe(v)):(se===i.TEXTURE_2D||se>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&se<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,ue,se,R.__webglTexture,ge),t.bindFramebuffer(i.FRAMEBUFFER,null)}function de(w,v,G){if(i.bindRenderbuffer(i.RENDERBUFFER,w),v.depthBuffer){let ue=v.depthTexture,se=ue&&ue.isDepthTexture?ue.type:null,ge=_(v.stencilBuffer,se),Se=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;me(v)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xe(v),ge,v.width,v.height):G?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xe(v),ge,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,ge,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Se,i.RENDERBUFFER,w)}else{let ue=v.textures;for(let se=0;se<ue.length;se++){let ge=ue[se],Se=r.convert(ge.format,ge.colorSpace),te=r.convert(ge.type),ne=T(ge.internalFormat,Se,te,ge.normalized,ge.colorSpace);me(v)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xe(v),ne,v.width,v.height):G?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xe(v),ne,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,ne,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ye(w,v,G){let ue=v.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,w),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let se=n.get(v.depthTexture);se.__renderTarget=v;let ge=ue?v.depthTexture.image[0]:v.depthTexture.image;(!se.__webglTexture||ge.width!==v.width||ge.height!==v.height)&&(ge.width=v.width,ge.height=v.height,v.depthTexture.needsUpdate=!0),ue?I(v.depthTexture,0):ye(v.depthTexture,0);let Se=se.__webglTexture,te=Xe(v),ne=ue?i.TEXTURE_CUBE_MAP_POSITIVE_X+G:i.TEXTURE_2D,xe=v.depthTexture.format===pi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===si)me(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,xe,ne,Se,0,te):i.framebufferTexture2D(i.FRAMEBUFFER,xe,ne,Se,0);else if(v.depthTexture.format===pi)me(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,xe,ne,Se,0,te):i.framebufferTexture2D(i.FRAMEBUFFER,xe,ne,Se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function je(w){let v=n.get(w),G=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){let ue=w.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),ue){let se=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,ue.removeEventListener("dispose",se)};ue.addEventListener("dispose",se),v.__depthDisposeCallback=se}v.__boundDepthTexture=ue}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(G)for(let ue=0;ue<6;ue++)Ye(v.__webglFramebuffer[ue],w,ue);else w.texture.mipmaps.length>0?Ye(v.__webglFramebuffer[0],w,0):Ye(v.__webglFramebuffer,w,0);else if(G){v.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[ue]),v.__webglDepthbuffer[ue]===void 0)v.__webglDepthbuffer[ue]=i.createRenderbuffer(),de(v.__webglDepthbuffer[ue],w,!1);else{let se=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ge=v.__webglDepthbuffer[ue];i.bindRenderbuffer(i.RENDERBUFFER,ge),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,ge)}}else if(w.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),de(v.__webglDepthbuffer,w,!1);else{let se=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ge=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ge),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,ge)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function at(w,v,G){let ue=n.get(w);v!==void 0&&we(ue.__webglFramebuffer,w,w.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),G!==void 0&&je(w)}function ct(w){let v=w.texture,G=n.get(w),ue=n.get(v);w.addEventListener("dispose",B),F(w);let se=w.textures,ge=w.isWebGLCubeRenderTarget===!0,Se=se.length>1;if(Se||(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=v.version,o.memory.textures++),ge){G.__webglFramebuffer=[];for(let te=0;te<6;te++)if(v.mipmaps.length>0){G.__webglFramebuffer[te]=[];for(let ne=0;ne<v.mipmaps.length;ne++)G.__webglFramebuffer[te][ne]=i.createFramebuffer()}else G.__webglFramebuffer[te]=i.createFramebuffer()}else{if(v.mipmaps.length>0){G.__webglFramebuffer=[];for(let te=0;te<v.mipmaps.length;te++)G.__webglFramebuffer[te]=i.createFramebuffer()}else G.__webglFramebuffer=i.createFramebuffer();if(Se)for(let te=0,ne=se.length;te<ne;te++){let xe=n.get(se[te]);xe.__webglTexture===void 0&&(xe.__webglTexture=i.createTexture(),o.memory.textures++)}if(w.samples>0&&me(w)===!1){G.__webglMultisampledFramebuffer=i.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let te=0;te<se.length;te++){let ne=se[te];G.__webglColorRenderbuffer[te]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,G.__webglColorRenderbuffer[te]);let xe=r.convert(ne.format,ne.colorSpace),R=r.convert(ne.type),ie=T(ne.internalFormat,xe,R,ne.normalized,ne.colorSpace,w.isXRRenderTarget===!0),Q=Xe(w);i.renderbufferStorageMultisample(i.RENDERBUFFER,Q,ie,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+te,i.RENDERBUFFER,G.__webglColorRenderbuffer[te])}i.bindRenderbuffer(i.RENDERBUFFER,null),w.depthBuffer&&(G.__webglDepthRenderbuffer=i.createRenderbuffer(),de(G.__webglDepthRenderbuffer,w,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ge){t.bindTexture(i.TEXTURE_CUBE_MAP,ue.__webglTexture),J(i.TEXTURE_CUBE_MAP,v);for(let te=0;te<6;te++)if(v.mipmaps.length>0)for(let ne=0;ne<v.mipmaps.length;ne++)we(G.__webglFramebuffer[te][ne],w,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+te,ne);else we(G.__webglFramebuffer[te],w,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);A(v)?S(i.TEXTURE_CUBE_MAP):v.mipmaps.length>0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,v.mipmaps.length-1),t.unbindTexture()}else if(Se){for(let te=0,ne=se.length;te<ne;te++){let xe=se[te],R=n.get(xe),ie=i.TEXTURE_2D;(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(ie=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ie,R.__webglTexture),J(ie,xe),we(G.__webglFramebuffer,w,xe,i.COLOR_ATTACHMENT0+te,ie,0),A(xe)&&S(ie)}t.unbindTexture()}else{let te=i.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(te=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(te,ue.__webglTexture),J(te,v),v.mipmaps.length>0)for(let ne=0;ne<v.mipmaps.length;ne++)we(G.__webglFramebuffer[ne],w,v,i.COLOR_ATTACHMENT0,te,ne);else we(G.__webglFramebuffer,w,v,i.COLOR_ATTACHMENT0,te,0);A(v)?S(te):v.mipmaps.length>0&&i.texParameteri(te,i.TEXTURE_MAX_LEVEL,v.mipmaps.length-1),t.unbindTexture()}w.depthBuffer&&je(w)}function N(w){let v=w.textures;for(let G=0,ue=v.length;G<ue;G++){let se=v[G];if(A(se)&&se.mipmapsAutoUpdate===!0){let ge=E(w),Se=n.get(se).__webglTexture;t.bindTexture(ge,Se),S(ge),t.unbindTexture()}}}let Ee=[];function Pe(w){if(w.samples>0){if(me(w)===!1){let v=w.textures,G=w.width,ue=w.height,se=i.COLOR_BUFFER_BIT,ge=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Se=n.get(w),te=v.length>1;if(te)for(let xe=0;xe<v.length;xe++)t.bindFramebuffer(i.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Se.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Se.__webglMultisampledFramebuffer),w.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Se.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Se.__webglFramebuffer);for(let xe=0;xe<v.length;xe++){if(w.resolveDepthBuffer&&(w.depthBuffer&&(se|=i.DEPTH_BUFFER_BIT),w.stencilBuffer&&w.resolveStencilBuffer&&(se|=i.STENCIL_BUFFER_BIT)),te){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Se.__webglColorRenderbuffer[xe]);let R=n.get(v[xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,R,0)}i.blitFramebuffer(0,0,G,ue,0,0,G,ue,se,i.NEAREST),c===!0&&(Ee.length=0,Ee.push(i.COLOR_ATTACHMENT0+xe),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&Ee.push(ge),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Ee))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),te)for(let xe=0;xe<v.length;xe++){t.bindFramebuffer(i.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,Se.__webglColorRenderbuffer[xe]);let R=n.get(v[xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Se.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,R,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Se.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let v=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function Xe(w){return Math.min(s.maxSamples,w.samples)}function me(w){let v=n.get(w);return w.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function ht(w){let v=o.render.frame;h.get(w)!==v&&(h.set(w,v),w.update())}function Ue(w,v){let G=w.colorSpace,ue=w.format,se=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||G!==$t&&G!==mi&&(tt.getTransfer(G)===pt?(ue!==yn||se!==on)&&ze("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):qe("WebGLTextures: Unsupported texture color space:",G)),v}function Oe(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(l.width=w.displayWidth,l.height=w.displayHeight):(l.width=w.width,l.height=w.height),l}this.allocateTextureUnit=He,this.resetTextureUnits=oe,this.getTextureUnits=le,this.setTextureUnits=Ie,this.setTexture2D=ye,this.setTexture2DArray=Ce,this.setTexture3D=ke,this.setTextureCube=I,this.rebindTextures=at,this.setupRenderTarget=ct,this.updateRenderTargetMipmap=N,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=we,this.useMultisampledRTT=me,this.dispose=q}function B_(i,e){function t(n,s=mi){let r,o=tt.getTransfer(s);if(n===on)return i.UNSIGNED_BYTE;if(n===Yo)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Zo)return i.UNSIGNED_SHORT_5_5_5_1;if(n===kl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Gl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Bl)return i.BYTE;if(n===zl)return i.SHORT;if(n===Us)return i.UNSIGNED_SHORT;if(n===qo)return i.INT;if(n===Pn)return i.UNSIGNED_INT;if(n===dn)return i.FLOAT;if(n===Ln)return i.HALF_FLOAT;if(n===Vl)return i.ALPHA;if(n===Hl)return i.RGB;if(n===yn)return i.RGBA;if(n===si)return i.DEPTH_COMPONENT;if(n===pi)return i.DEPTH_STENCIL;if(n===Ko)return i.RED;if(n===Jo)return i.RED_INTEGER;if(n===Pi)return i.RG;if(n===jo)return i.RG_INTEGER;if(n===$o)return i.RGBA_INTEGER;if(n===Tr||n===Ar||n===wr||n===Er)if(o===pt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Tr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Tr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Qo||n===ea||n===ta||n===na)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Qo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ea)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ta)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===na)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ia||n===sa||n===ra||n===oa||n===aa||n===Rr||n===la)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ia||n===sa)return o===pt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ra)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===oa)return r.COMPRESSED_R11_EAC;if(n===aa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Rr)return r.COMPRESSED_RG11_EAC;if(n===la)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===ca||n===ha||n===ua||n===fa||n===da||n===pa||n===ma||n===ga||n===_a||n===xa||n===va||n===ya||n===Ma||n===Sa)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===ca)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ha)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ua)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===fa)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===da)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===pa)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ma)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ga)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_a)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===xa)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===va)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ya)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ma)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Sa)return o===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ba||n===Ta||n===Aa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ba)return o===pt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ta)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Aa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===wa||n===Ea||n===Cr||n===Ra)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===wa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ea)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Cr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ra)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===$i?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var z_=` | ||
| 4205 | void main() { | ||
| 4206 | |||
| 4207 | gl_Position = vec4( position, 1.0 ); | ||
| 4208 | |||
| 4209 | }`,k_=` | ||
| 4210 | uniform sampler2DArray depthColor; | ||
| 4211 | uniform float depthWidth; | ||
| 4212 | uniform float depthHeight; | ||
| 4213 | |||
| 4214 | void main() { | ||
| 4215 | |||
| 4216 | vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); | ||
| 4217 | |||
| 4218 | if ( coord.x >= 1.0 ) { | ||
| 4219 | |||
| 4220 | gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; | ||
| 4221 | |||
| 4222 | } else { | ||
| 4223 | |||
| 4224 | gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; | ||
| 4225 | |||
| 4226 | } | ||
| 4227 | |||
| 4228 | }`,_c=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new fr(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new zn({vertexShader:z_,fragmentShader:k_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new bt(new pr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},xc=class extends Rn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,u=null,f=null,d=null,g=null,x=typeof XRWebGLBinding<"u",m=new _c,p={},M=t.getContextAttributes(),A=null,S=null,E=[],T=[],_=new We,b=null,F=null,P=new Ot;P.viewport=new gt;let L=new Ot;L.viewport=new gt;let B=[P,L],K=new ko,C=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ye=E[ee];return ye===void 0&&(ye=new Ms,E[ee]=ye),ye.getTargetRaySpace()},this.getControllerGrip=function(ee){let ye=E[ee];return ye===void 0&&(ye=new Ms,E[ee]=ye),ye.getGripSpace()},this.getHand=function(ee){let ye=E[ee];return ye===void 0&&(ye=new Ms,E[ee]=ye),ye.getHandSpace()};function X(ee){let ye=T.indexOf(ee.inputSource);if(ye===-1)return;let Ce=E[ye];Ce!==void 0&&(Ce.update(ee.inputSource,ee.frame,l||o),Ce.dispatchEvent({type:ee.type,data:ee.inputSource}))}function W(){s.removeEventListener("select",X),s.removeEventListener("selectstart",X),s.removeEventListener("selectend",X),s.removeEventListener("squeeze",X),s.removeEventListener("squeezestart",X),s.removeEventListener("squeezeend",X),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",ae);for(let ee=0;ee<E.length;ee++){let ye=T[ee];ye!==null&&(T[ee]=null,E[ee].disconnect(ye))}C=null,q=null,m.reset();for(let ee in p)delete p[ee];if(e.setRenderTarget(A),d=null,f=null,u=null,s=null,S=null,He.stop(),n.isPresenting=!1,e.setPixelRatio(b),e.setSize(_.width,_.height,!1),F!==null){let ee=F.camera;ee.fov=F.fov,ee.zoom=F.zoom,ee.updateProjectionMatrix(),F=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){r=ee,n.isPresenting===!0&&ze("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){a=ee,n.isPresenting===!0&&ze("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(ee){l=ee},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,t)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(ee){if(s=ee,s!==null){if(A=e.getRenderTarget(),s.addEventListener("select",X),s.addEventListener("selectstart",X),s.addEventListener("selectend",X),s.addEventListener("squeeze",X),s.addEventListener("squeezestart",X),s.addEventListener("squeezeend",X),s.addEventListener("end",W),s.addEventListener("inputsourceschange",ae),M.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(_),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ce=null,ke=null,I=null;M.depth&&(I=M.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ce=M.stencil?pi:si,ke=M.stencil?$i:Pn);let D={colorFormat:t.RGBA8,depthFormat:I,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(D),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),S=new fn(f.textureWidth,f.textureHeight,{format:yn,type:on,depthTexture:new li(f.textureWidth,f.textureHeight,ke,void 0,void 0,void 0,void 0,void 0,void 0,Ce),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let Ce={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(s,t,Ce),s.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new fn(d.framebufferWidth,d.framebufferHeight,{format:yn,type:on,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await s.requestReferenceSpace(a),He.setContext(s),He.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ae(ee){for(let ye=0;ye<ee.removed.length;ye++){let Ce=ee.removed[ye],ke=T.indexOf(Ce);ke>=0&&(T[ke]=null,E[ke].disconnect(Ce))}for(let ye=0;ye<ee.added.length;ye++){let Ce=ee.added[ye],ke=T.indexOf(Ce);if(ke===-1){for(let D=0;D<E.length;D++)if(D>=T.length){T.push(Ce),ke=D;break}else if(T[D]===null){T[D]=Ce,ke=D;break}if(ke===-1)break}let I=E[ke];I&&I.connect(Ce)}}function Y(ee,ye){ye===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ye.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(s===null)return;let ye=ee.near,Ce=ee.far;m.texture!==null&&(m.depthNear>0&&(ye=m.depthNear),m.depthFar>0&&(Ce=m.depthFar)),K.near=L.near=P.near=ye,K.far=L.far=P.far=Ce,(C!==K.near||q!==K.far)&&(s.updateRenderState({depthNear:K.near,depthFar:K.far}),C=K.near,q=K.far),K.layers.mask=ee.layers.mask|6,P.layers.mask=K.layers.mask&-5,L.layers.mask=K.layers.mask&-3;let ke=ee.parent,I=K.cameras;Y(K,ke);for(let D=0;D<I.length;D++)Y(I[D],ke);K.projectionMatrix.copy(P.projectionMatrix),K.projectionMatrixInverse.copy(P.projectionMatrixInverse),F===null&&ee.isPerspectiveCamera&&(F={camera:ee,fov:ee.fov,zoom:ee.zoom}),oe(ee,K,ke)};function oe(ee,ye,Ce){Ce===null?ee.matrix.copy(ye.matrixWorld):(ee.matrix.copy(Ce.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ye.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ye.projectionMatrix),ee.projectionMatrixInverse.copy(ye.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=Hi*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return K},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(ee){c=ee,f!==null&&(f.fixedFoveation=ee),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=ee)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(K)},this.getCameraTexture=function(ee){return p[ee]};let le=null;function Ie(ee,ye){if(h=ye.getViewerPose(l||o),g=ye,h!==null){let Ce=h.views;d!==null&&(e.setRenderTargetFramebuffer(S,d.framebuffer),e.setRenderTarget(S));let ke=!1;Ce.length!==K.cameras.length&&(K.cameras.length=0,ke=!0);for(let k=0;k<Ce.length;k++){let J=Ce[k],H=null;if(d!==null)H=d.getViewport(J);else{let ce=u.getViewSubImage(f,J);H=ce.viewport,k===0&&(e.setRenderTargetTextures(S,ce.colorTexture,ce.depthStencilTexture),e.setRenderTarget(S))}let $=B[k];$===void 0&&($=new Ot,$.layers.enable(k),$.viewport=new gt,B[k]=$),$.matrix.fromArray(J.transform.matrix),$.matrix.decompose($.position,$.quaternion,$.scale),$.projectionMatrix.fromArray(J.projectionMatrix),$.projectionMatrixInverse.copy($.projectionMatrix).invert(),$.viewport.set(H.x,H.y,H.width,H.height),k===0&&(K.matrix.copy($.matrix),K.matrix.decompose(K.position,K.quaternion,K.scale)),ke===!0&&K.cameras.push($)}let I=s.enabledFeatures;if(I&&I.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();let k=u.getDepthInformation(Ce[0]);k&&k.isValid&&k.texture&&m.init(k,s.renderState)}if(I&&I.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let k=0;k<Ce.length;k++){let J=Ce[k].camera;if(J){let H=p[J];H||(H=new fr,p[J]=H);let $=u.getCameraImage(J);H.sourceTexture=$}}}}for(let Ce=0;Ce<E.length;Ce++){let ke=T[Ce],I=E[Ce];ke!==null&&I!==void 0&&I.update(ke,ye,l||o)}le&&le(ee,ye),ye.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ye}),g=null}let He=new xf;He.setAnimationLoop(Ie),this.setAnimationLoop=function(ee){le=ee},this.dispose=function(){}}},G_=new Ze,Rf=new Ke;Rf.set(-1,0,0,0,1,0,0,0,1);function V_(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,ec(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,M,A,S){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),f(m,p),p.isMeshPhysicalMaterial&&d(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,M,A):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===en&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===en&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let M=e.get(p),A=M.envMap,S=M.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(G_.makeRotationFromEuler(S)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,M,A){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*M,m.scale.value=A*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function f(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function d(m,p,M){m.ior.value=p.ior,p.diffuseRoughness>0&&(m.diffuseRoughness.value=p.diffuseRoughness,p.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=p.diffuseRoughnessMap,t(p.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===en&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=p.iridescenceThicknessMaximum,p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=M.texture,m.transmissionSamplerSize.value.set(M.width,M.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){let M=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(M.matrixWorld),m.nearDistance.value=M.shadow.camera.near,m.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function H_(i,e,t,n){let s={},r={};function o(M,A){let S=A.program;n.uniformBlockBinding(M,S,s[M.id])}function a(M,A){let S=s[M.id];S===void 0&&(g(M),S=c(M),s[M.id]=S,M.addEventListener("dispose",m));let E=A.program;n.updateUBOMapping(M,E);let T=e.render.frame;r[M.id]!==T&&(l(M),r[M.id]=T)}function c(M){let A=i.createBuffer(),S=M.__size,E=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,S,E),i.bindBuffer(i.UNIFORM_BUFFER,null),A}function l(M){let A=s[M.id],S=M.uniforms,E=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let T=0,_=S.length;T<_;T++){let b=S[T];if(Array.isArray(b))for(let F=0,P=b.length;F<P;F++)h(b[F],T,F,E);else h(b,T,0,E)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(M,A,S,E){if(f(M,A,S,E)===!0){let T=M.__offset,_=M.value;if(Array.isArray(_)){let b=0;for(let F=0;F<_.length;F++){let P=_[F],L=x(P,!0);u(P,M.__data,b),b+=L.storage/Float32Array.BYTES_PER_ELEMENT}}else u(_,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,T,M.__data)}}function u(M,A,S){typeof M=="number"||typeof M=="boolean"?A[S]=M:M.isMatrix3?(A[S]=M.elements[0],A[S+1]=M.elements[1],A[S+2]=M.elements[2],A[S+3]=0,A[S+4]=M.elements[3],A[S+5]=M.elements[4],A[S+6]=M.elements[5],A[S+7]=0,A[S+8]=M.elements[6],A[S+9]=M.elements[7],A[S+10]=M.elements[8],A[S+11]=0):ArrayBuffer.isView(M)?A.set(M.subarray(0,A.length-S),S):M.toArray(A,S)}function f(M,A,S,E){let T=M.value,_=A+"_"+S;if(Array.isArray(T)){E[_]===void 0&&(E[_]=[]);let b=E[_],F=!1;for(let P=0;P<T.length;P++)d(T[P],b,P)===!0&&(F=!0);return F}return d(T,E,_)}function d(M,A,S){if(A[S]===void 0)return typeof M=="number"||typeof M=="boolean"?A[S]=M:ArrayBuffer.isView(M)?A[S]=M.slice():A[S]=M.clone(),!0;{let E=A[S];if(typeof M=="number"||typeof M=="boolean"){if(E!==M)return A[S]=M,!0}else{if(ArrayBuffer.isView(M))return!0;if(E.equals(M)===!1)return E.copy(M),!0}}return!1}function g(M){let A=M.uniforms,S=0,E=16;for(let _=0,b=A.length;_<b;_++){let F=Array.isArray(A[_])?A[_]:[A[_]];for(let P=0,L=F.length;P<L;P++){let B=F[P],K=Array.isArray(B.value)?B.value:[B.value],C=Array.isArray(A[_])||Array.isArray(B.value),q=S;for(let W=0,ae=K.length;W<ae;W++){let Y=K[W],oe=x(Y,C),le=S%E,Ie=le%oe.boundary,He=le+Ie;S+=Ie,He!==0&&E-He<oe.storage&&(S+=E-He),W===0&&(q=S),S+=oe.storage}let X=B.type==="int"?Int32Array:B.type==="uint"?Uint32Array:Float32Array;B.__data=new X((S-q)/Float32Array.BYTES_PER_ELEMENT),B.__offset=q}}let T=S%E;return T>0&&(S+=E-T),M.__size=S,M.__cache={},this}function x(M,A){let S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=16,S.storage=48):M.isMatrix4?(S.boundary=16,S.storage=64):M.isTexture?ze("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):ze("WebGLRenderer: Unsupported uniform value type.",M),A===!0&&(S.boundary=16,S.storage=Math.ceil(S.storage/16)*16),S}function m(M){let A=M.target;A.removeEventListener("dispose",m),i.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function p(){for(let M in s)i.deleteBuffer(s[M]);s={},r={}}return{bind:o,update:a,dispose:p}}var W_=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]),Xn=null;function X_(){return Xn===null&&(Xn=new As(W_,16,16,Pi,Ln),Xn.name="DFG_LUT",Xn.minFilter=At,Xn.magFilter=At,Xn.wrapS=jt,Xn.wrapT=jt,Xn.generateMipmaps=!1,Xn.needsUpdate=!0),Xn}var vc=class{constructor(e={}){let{canvas:t=Vu(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:d=on}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let x=d,m=new Set([$o,jo,Jo]),p=new Set([on,Pn,Us,$i,Yo,Zo]),M=new Uint32Array(4),A=new Int32Array(4),S={textures:[],min:[],max:[],resolution:[]},E=null,T=null,_=[],b=[],F=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let P=this,L=!1,B=null,K=null,C=null,q=null;this._outputColorSpace=Mt;let X=0,W=0,ae=null,Y=-1,oe=null,le=new gt,Ie=new gt,He=null,ee=new Be(0),ye=0,Ce=t.width,ke=t.height,I=1,D=null,j=null,k=new gt(0,0,Ce,ke),J=new gt(0,0,Ce,ke),H=!1,$=new wi,ce=new wo,re=!1,he=!1,we=new Ze,de=new O,Ye=new gt,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},at=!1;function ct(){return ae===null?I:1}let N=n;function Ee(y,U){return t.getContext(y,U)}let Pe,Xe,me,ht,Ue,Oe,w,v,G,ue,se,ge,Se,te,ne,xe,R,ie,Q,ve,pe,_e,Ge;try{let y={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",Ve,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",Te,!1),N===null){let U="webgl2";if(N=Ee(U,y),N===null)throw Ee(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Qe()}catch(y){throw t.removeEventListener("webglcontextlost",Ve,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",Te,!1),qe("WebGLRenderer: "+y.message),y}function Qe(){Pe=new n0(N),Pe.init(),pe=new B_(N,Pe),Xe=new Xg(N,Pe,e,pe),me=new F_(N,Pe),Xe.reversedDepthBuffer&&f&&me.buffers.depth.setReversed(!0),K=N.createFramebuffer(),C=N.createFramebuffer(),q=N.createFramebuffer(),ht=new r0(N),Ue=new S_,Oe=new O_(N,Pe,me,Ue,Xe,pe,ht),w=new t0(P),v=new ap(N),_e=new Hg(N,v),G=new i0(N,v,ht,_e),ue=new a0(N,G,v,_e,ht),ie=new o0(N,Xe,Oe),ne=new qg(Ue),se=new M_(P,w,Pe,Xe,_e,ne),ge=new V_(P,Ue),Se=new T_,te=new I_(Pe),R=new Vg(P,w,me,ue,g,c),xe=new U_(P,ue,Xe),Ge=new H_(N,ht,Xe,me),Q=new Wg(N,Pe,ht),ve=new s0(N,Pe,ht),ht.programs=se.programs,P.capabilities=Xe,P.extensions=Pe,P.properties=Ue,P.renderLists=Se,P.shadowMap=xe,P.state=me,P.info=ht}x!==on&&(F=new c0(x,t.width,t.height,a,s,r));let fe=new xc(P,N);this.xr=fe,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let y=Pe.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Pe.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(y){y!==void 0&&(I=y,this.setSize(Ce,ke,!1))},this.getSize=function(y){return y.set(Ce,ke)},this.setSize=function(y,U,Z=!0){if(fe.isPresenting){ze("WebGLRenderer: Can't change size while VR device is presenting.");return}Ce=y,ke=U,t.width=Math.floor(y*I),t.height=Math.floor(U*I),Z===!0&&(t.style.width=y+"px",t.style.height=U+"px"),F!==null&&F.setSize(t.width,t.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(Ce*I,ke*I).floor()},this.setDrawingBufferSize=function(y,U,Z){Ce=y,ke=U,I=Z,t.width=Math.floor(y*Z),t.height=Math.floor(U*Z),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(x===on){qe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){ze("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}F.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(le)},this.getViewport=function(y){return y.copy(k)},this.setViewport=function(y,U,Z,z){y.isVector4?k.set(y.x,y.y,y.z,y.w):k.set(y,U,Z,z),me.viewport(le.copy(k).multiplyScalar(ct()).round())},this.getScissor=function(y){return y.copy(J)},this.setScissor=function(y,U,Z,z){y.isVector4?J.set(y.x,y.y,y.z,y.w):J.set(y,U,Z,z),me.scissor(Ie.copy(J).multiplyScalar(ct()).round())},this.getScissorTest=function(){return H},this.setScissorTest=function(y){me.setScissorTest(H=y)},this.setOpaqueSort=function(y){D=y},this.setTransparentSort=function(y){j=y},this.getClearColor=function(y){return y.copy(R.getClearColor())},this.setClearColor=function(){R.setClearColor(...arguments)},this.getClearAlpha=function(){return R.getClearAlpha()},this.setClearAlpha=function(){R.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,Z=!0){let z=0;if(y){let V=!1;if(ae!==null){let be=ae.texture.format;V=m.has(be)}if(V){let be=ae.texture.type,Le=p.has(be),Me=R.getClearColor(),Re=R.getClearAlpha(),Fe=Me.r,Je=Me.g,rt=Me.b;Le?(M[0]=Fe,M[1]=Je,M[2]=rt,M[3]=Re,N.clearBufferuiv(N.COLOR,0,M)):(A[0]=Fe,A[1]=Je,A[2]=rt,A[3]=Re,N.clearBufferiv(N.COLOR,0,A))}else z|=N.COLOR_BUFFER_BIT}U&&(z|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Z&&(z|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z!==0&&N.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),B=y},this.dispose=function(){t.removeEventListener("webglcontextlost",Ve,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",Te,!1),R.dispose(),Se.dispose(),te.dispose(),Oe.dispose(),Ue.dispose(),w.dispose(),ue.dispose(),G.dispose(),_e.dispose(),Ge.dispose(),se.dispose(),fe.dispose(),fe.removeEventListener("sessionstart",dh),fe.removeEventListener("sessionend",ph),Di.stop()};function Ve(y){y.preventDefault(),tr("WebGLRenderer: Context Lost."),L=!0}function $e(){tr("WebGLRenderer: Context Restored."),L=!1;let y=ht.autoReset,U=xe.enabled,Z=xe.autoUpdate,z=xe.needsUpdate,V=xe.type;Qe(),ht.autoReset=y,xe.enabled=U,xe.autoUpdate=Z,xe.needsUpdate=z,xe.type=V}function Te(y){qe("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function mt(y){let U=y.target;U.removeEventListener("dispose",mt),Nt(U)}function Nt(y){_i(y),Ue.remove(y)}function _i(y){let U=Ue.get(y).programs;U!==void 0&&(U.forEach(function(Z){se.releaseProgram(Z)}),y.isShaderMaterial&&se.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,Z,z,V,be){U===null&&(U=je);let Le=V.isMesh&&V.matrixWorld.determinantAffine()<0,Me=td(y,U,Z,z,V);me.setMaterial(z,Le);let Re=Z.index,Fe=1;if(z.wireframe===!0){if(Re=G.getWireframeAttribute(Z),Re===void 0)return;Fe=2}let Je=Z.drawRange,rt=Z.attributes.position,De=Je.start*Fe,ot=(Je.start+Je.count)*Fe;be!==null&&(De=Math.max(De,be.start*Fe),ot=Math.min(ot,(be.start+be.count)*Fe)),Re!==null?(De=Math.max(De,0),ot=Math.min(ot,Re.count)):rt!=null&&(De=Math.max(De,0),ot=Math.min(ot,rt.count));let Ct=ot-De;if(Ct<0||Ct===1/0)return;_e.setup(V,z,Me,Z,Re);let yt,xt=Q;if(Re!==null&&(yt=v.get(Re),xt=ve,xt.setIndex(yt)),V.isMesh)z.wireframe===!0?(me.setLineWidth(z.wireframeLinewidth*ct()),xt.setMode(N.LINES)):xt.setMode(N.TRIANGLES);else if(V.isLine){let Wt=z.linewidth;Wt===void 0&&(Wt=1),me.setLineWidth(Wt*ct()),V.isLineSegments?xt.setMode(N.LINES):V.isLineLoop?xt.setMode(N.LINE_LOOP):xt.setMode(N.LINE_STRIP)}else V.isPoints?xt.setMode(N.POINTS):V.isSprite&&xt.setMode(N.TRIANGLES);if(V.isBatchedMesh)if(Pe.get("WEBGL_multi_draw"))xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else{let Wt=V._multiDrawStarts,Ne=V._multiDrawCounts,Kt=V._multiDrawCount,ut=Re?v.get(Re).bytesPerElement:1,Ni=Ue.get(z).currentProgram.getUniforms();for(let Xt=0;Xt<Kt;Xt++)Ni.setValue(N,"_gl_DrawID",Xt),xt.render(Wt[Xt]/ut,Ne[Xt])}else if(V.isInstancedMesh)xt.renderInstances(De,Ct,V.count);else if(Z.isInstancedBufferGeometry){let Wt=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Ne=Math.min(Z.instanceCount,Wt);xt.renderInstances(De,Ct,Ne)}else xt.render(De,Ct)};function fh(y,U,Z,z){B!==null&&y.isNodeMaterial&&B.setObject(z,y),re===!0&&ne.setState(y,Z,!1),y.transparent===!0&&y.side===vn&&y.forceSinglePass===!1?(y.side=en,y.needsUpdate=!0,Vs(y,U,z),y.side=Vn,y.needsUpdate=!0,Vs(y,U,z),y.side=vn):Vs(y,U,z)}this.compile=function(y,U,Z=null){Z===null&&(Z=y),B!==null&&B.renderStart(y,U,Z),T=te.get(Z),T.init(U),b.push(T),Z.traverseVisible(function(V){V.isLight&&V.layers.test(U.layers)&&(T.pushLight(V),V.castShadow&&T.pushShadow(V))}),y!==Z&&y.traverseVisible(function(V){V.isLight&&V.layers.test(U.layers)&&(T.pushLight(V),V.castShadow&&T.pushShadow(V))}),T.setupLights(),B!==null&&B.updateLights(T.state.lightsArray),he=this.localClippingEnabled,re=ne.init(this.clippingPlanes,he),re===!0&&ne.setGlobalState(this.clippingPlanes,U),B!==null&&xe.render(T.state.shadowsArray,Z,U);let z=new Set;return y.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let be=V.material;if(be)if(Array.isArray(be))for(let Le=0;Le<be.length;Le++){let Me=be[Le];fh(Me,Z,U,V),z.add(Me)}else fh(be,Z,U,V),z.add(be)}),T=b.pop(),B!==null&&B.renderEnd(),z},this.compileAsync=function(y,U,Z=null){let z=this.compile(y,U,Z);return new Promise(V=>{function be(){if(z.forEach(function(Le){let Re=Ue.get(Le).currentProgram;(Re===void 0||Re.isReady())&&z.delete(Le)}),z.size===0){V(y);return}setTimeout(be,10)}Pe.get("KHR_parallel_shader_compile")!==null?be():setTimeout(be,10)})};let ka=null;function Qf(y){ka&&ka(y)}function dh(){Di.stop()}function ph(){Di.start()}let Di=new xf;Di.setAnimationLoop(Qf),typeof self<"u"&&Di.setContext(self),this.setAnimationLoop=function(y){ka=y,fe.setAnimationLoop(y),y===null?Di.stop():Di.start()},fe.addEventListener("sessionstart",dh),fe.addEventListener("sessionend",ph),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;B!==null&&B.renderStart(y,U);let Z=fe.enabled===!0&&fe.isPresenting===!0,z=F!==null&&(ae===null||Z)&&F.begin(P,ae);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),fe.enabled===!0&&fe.isPresenting===!0&&(F===null||F.isCompositing()===!1)&&(fe.cameraAutoUpdate===!0&&fe.updateCamera(U),U=fe.getCamera()),y.isScene===!0&&y.onBeforeRender(P,y,U,ae),T=te.get(y,b.length),T.init(U),T.state.textureUnits=Oe.getTextureUnits(),b.push(T),we.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),U.isArrayCamera?ce.setFromArrayCamera(U):$.setFromProjectionMatrix(we,_n,U.reversedDepth),he=this.localClippingEnabled,re=ne.init(this.clippingPlanes,he),E=Se.get(y,_.length),E.init(),_.push(E),this.info.render.frame++,fe.enabled===!0&&fe.isPresenting===!0){let Le=P.xr.getDepthSensingMesh();Le!==null&&Ga(Le,U,-1/0,P.sortObjects)}Ga(y,U,0,P.sortObjects),E.finish(),B!==null&&B.updateLights(T.state.lightsArray),P.sortObjects===!0&&E.sort(D,j),at=fe.enabled===!1||fe.isPresenting===!1||fe.hasDepthSensing()===!1,at&&R.addToRenderList(E,y),this.info.autoReset===!0&&this.info.reset(),re===!0&&ne.beginShadows();let V=T.state.shadowsArray;if(xe.render(V,y,U),re===!0&&ne.endShadows(),(z&&F.hasRenderPass())===!1){let Le=E.opaque,Me=E.transmissive;if(T.setupLights(),U.isArrayCamera){let Re=U.cameras;if(Me.length>0)for(let Fe=0,Je=Re.length;Fe<Je;Fe++){let rt=Re[Fe];gh(Le,Me,y,rt)}at&&R.render(y);for(let Fe=0,Je=Re.length;Fe<Je;Fe++){let rt=Re[Fe];mh(E,y,rt,rt.viewport)}}else Me.length>0&&gh(Le,Me,y,U),at&&R.render(y),mh(E,y,U)}ae!==null&&W===0&&(Oe.updateMultisampleRenderTarget(ae),Oe.updateRenderTargetMipmap(ae)),z&&F.end(P),y.isScene===!0&&y.onAfterRender(P,y,U),_e.resetDefaultState(),Y=-1,oe=null,b.pop(),b.length>0?(T=b[b.length-1],Oe.setTextureUnits(T.state.textureUnits),re===!0&&ne.setGlobalState(P.clippingPlanes,T.state.camera)):T=null,_.pop(),_.length>0?E=_[_.length-1]:E=null,B!==null&&B.renderEnd()};function Ga(y,U,Z,z){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)Z=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLight)T.pushLight(y),y.castShadow&&T.pushShadow(y);else if(y.isSprite){let Le=U.isArrayCamera?ce:$;if(!y.frustumCulled||y.intersectsFrustum(Le)){z&&Ye.setFromMatrixPosition(y.matrixWorld).applyMatrix4(we);let Me=ue.update(y),Re=y.material;Re.visible&&E.push(y,Me,Re,Z,Ye.z,null,U)}}else if(y.isMesh||y.isLine||y.isPoints){let Le=U.isArrayCamera?ce:$;if(!y.frustumCulled||y.intersectsFrustum(Le)){let Me=ue.update(y),Re=y.material;if(z&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ye.copy(y.boundingSphere.center)):(Me.boundingSphere===null&&Me.computeBoundingSphere(),Ye.copy(Me.boundingSphere.center)),Ye.applyMatrix4(y.matrixWorld).applyMatrix4(we)),Array.isArray(Re)){let Fe=Me.groups;for(let Je=0,rt=Fe.length;Je<rt;Je++){let De=Fe[Je],ot=Re[De.materialIndex];ot&&ot.visible&&E.push(y,Me,ot,Z,Ye.z,De,U)}}else Re.visible&&E.push(y,Me,Re,Z,Ye.z,null,U)}}}let be=y.children;for(let Le=0,Me=be.length;Le<Me;Le++)Ga(be[Le],U,Z,z)}function mh(y,U,Z,z){let{opaque:V,transmissive:be,transparent:Le}=y;T.setupLightsView(Z),re===!0&&ne.setGlobalState(P.clippingPlanes,Z),z&&me.viewport(le.copy(z)),V.length>0&&zr(V,U,Z),be.length>0&&zr(be,U,Z),Le.length>0&&zr(Le,U,Z),me.buffers.depth.setTest(!0),me.buffers.depth.setMask(!0),me.buffers.color.setMask(!0),me.setPolygonOffset(!1)}function gh(y,U,Z,z){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(T.state.transmissionRenderTarget[z.id]===void 0){let De=Pe.has("EXT_color_buffer_half_float")||Pe.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[z.id]=new fn(1,1,{generateMipmaps:!0,type:De?Ln:on,minFilter:tn,samples:Math.max(4,Xe.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:tt.workingColorSpace})}let be=T.state.transmissionRenderTarget[z.id],Le=z.viewport||le;be.setSize(Le.z*P.transmissionResolutionScale,Le.w*P.transmissionResolutionScale);let Me=P.getRenderTarget(),Re=P.getActiveCubeFace(),Fe=P.getActiveMipmapLevel();P.setRenderTarget(be),P.getClearColor(ee),ye=P.getClearAlpha(),ye<1&&P.setClearColor(16777215,.5),P.clear(),at&&R.render(Z);let Je=P.toneMapping;P.toneMapping=Hn;let rt=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),T.setupLightsView(z),re===!0&&ne.setGlobalState(P.clippingPlanes,z),zr(y,Z,z),Oe.updateMultisampleRenderTarget(be),Oe.updateRenderTargetMipmap(be),Pe.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let ot=0,Ct=U.length;ot<Ct;ot++){let yt=U[ot],{object:xt,geometry:Wt,material:Ne,group:Kt}=yt;if(Ne.side===vn&&xt.layers.test(z.layers)){let ut=Ne.side;Ne.side=en,Ne.needsUpdate=!0,_h(xt,Z,z,Wt,Ne,Kt),Ne.side=ut,Ne.needsUpdate=!0,De=!0}}De===!0&&(Oe.updateMultisampleRenderTarget(be),Oe.updateRenderTargetMipmap(be))}P.setRenderTarget(Me,Re,Fe),P.setClearColor(ee,ye),rt!==void 0&&(z.viewport=rt),P.toneMapping=Je}function zr(y,U,Z){let z=U.isScene===!0?U.overrideMaterial:null;for(let V=0,be=y.length;V<be;V++){let Le=y[V],{object:Me,geometry:Re,group:Fe}=Le,Je=Le.material;Je.allowOverride===!0&&z!==null&&(Je=z),Me.layers.test(Z.layers)&&_h(Me,U,Z,Re,Je,Fe)}}function _h(y,U,Z,z,V,be){B!==null&&V.isNodeMaterial&&B.setObject(y,V),y.onBeforeRender(P,U,Z,z,V,be),y.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),V.onBeforeRender(P,U,Z,z,y,be),V.transparent===!0&&V.side===vn&&V.forceSinglePass===!1?(V.side=en,V.needsUpdate=!0,P.renderBufferDirect(Z,U,z,V,y,be),V.side=Vn,V.needsUpdate=!0,P.renderBufferDirect(Z,U,z,V,y,be),V.side=vn):P.renderBufferDirect(Z,U,z,V,y,be),y.onAfterRender(P,U,Z,z,V,be)}function xh(y){let U=0;for(let Z of y)Z.texture!==null&&U++;return U}function Vs(y,U,Z){U.isScene!==!0&&(U=je);let z=Ue.get(y),V=T.state.lights,be=T.state.shadowsArray,Le=V.state.version,Me=se.getParameters(y,V.state,be,U,Z,T.state.lightProbeGridArray),Re=se.getProgramCacheKey(Me),Fe=z.programs;z.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,z.fog=U.fog;let Je=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;z.envMap=w.get(y.envMap||z.environment,Je),z.envMapRotation=z.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Fe===void 0&&(y.addEventListener("dispose",mt),Fe=new Map,z.programs=Fe,z.programVariants=new Map);let rt=Fe.get(Re);if(rt!==void 0){if(z.currentProgram===rt&&z.lightsStateVersion===Le)return yh(y,Me),rt}else Me.uniforms=se.getUniforms(y),B!==null&&y.isNodeMaterial&&B.build(y,Z,Me),y.onBeforeCompile(Me,P),rt=se.acquireProgram(Me,Re),Fe.set(Re,rt),z.uniforms=Me.uniforms;let De=z.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(De.clippingPlanes=ne.uniform),yh(y,Me),z.needsLights=id(y),z.lightsStateVersion=Le,z.needsLights&&(De.ambientLightColor.value=V.state.ambient,De.lightProbe.value=V.state.probe,De.sunLights.value=V.state.sun,De.sunLightShadows.value=V.state.sunShadow,De.directionalLights.value=V.state.directional,De.directionalLightShadows.value=V.state.directionalShadow,De.spotLights.value=V.state.spot,De.spotLightShadows.value=V.state.spotShadow,De.rectAreaLights.value=V.state.rectArea,De.ltc_1.value=V.state.rectAreaLTC1,De.ltc_2.value=V.state.rectAreaLTC2,De.pointLights.value=V.state.point,De.pointLightShadows.value=V.state.pointShadow,De.hemisphereLights.value=V.state.hemi,De.sunShadowMatrix.value=V.state.sunShadowMatrix,De.sunShadowCascade.value=V.state.sunShadowCascade,De.directionalShadowMatrix.value=V.state.directionalShadowMatrix,De.spotLightMatrix.value=V.state.spotLightMatrix,De.spotLightMap.value=V.state.spotLightMap,De.pointShadowMatrix.value=V.state.pointShadowMatrix),z.numLightProbeGrids=xh(T.state.lightProbeGridArray),z.currentProgram=rt,z.uniformsList=null,rt}function ed(y,U,Z,z,V){let be=Ue.get(y),Le=be.currentProgram.id+","+z+","+V,Me=be.programVariants.get(Le);return Me===void 0?(Me=Vs(y,U,Z),be.programVariants.set(Le,Me)):(be.currentProgram=Me,be.uniformsList=null,be.outputColorSpace=z,be.toneMapping=V),Me}function vh(y){if(y.uniformsList===null){let U=y.currentProgram.getUniforms();y.uniformsList=Bs.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function yh(y,U){let Z=Ue.get(y);Z.outputColorSpace=U.outputColorSpace,Z.batching=U.batching,Z.batchingColor=U.batchingColor,Z.instancing=U.instancing,Z.instancingColor=U.instancingColor,Z.instancingMorph=U.instancingMorph,Z.skinning=U.skinning,Z.morphTargets=U.morphTargets,Z.morphNormals=U.morphNormals,Z.morphColors=U.morphColors,Z.morphTargetsCount=U.morphTargetsCount,Z.numClippingPlanes=U.numClippingPlanes,Z.numIntersection=U.numClipIntersection,Z.vertexAlphas=U.vertexAlphas,Z.vertexTangents=U.vertexTangents,Z.toneMapping=U.toneMapping}function td(y,U,Z,z,V){U.isScene!==!0&&(U=je),Oe.resetTextureUnits();let be=U.fog,Le=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?U.environment:null,Me=ae===null?P.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:tt.workingColorSpace,Re=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Fe=w.get(z.envMap||Le,Re),Je=z.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,rt=!!Z.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),De=!!Z.morphAttributes.position,ot=!!Z.morphAttributes.normal,Ct=!!Z.morphAttributes.color,yt=Hn;z.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(yt=P.toneMapping);let xt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,Wt=xt!==void 0?xt.length:0,Ne=Ue.get(z),Kt=T.state.lights;if(re===!0&&(he===!0||y!==oe)){let Et=y===oe&&z.id===Y;ne.setState(z,y,Et)}let ut=!1,Ni=!1;z.version===Ne.__version?Ne.needsLights&&Ne.lightsStateVersion!==Kt.state.version||V.isBatchedMesh&&Ne.batching===!1||!V.isBatchedMesh&&Ne.batching===!0||V.isBatchedMesh&&Ne.batchingColor===!0&&V._colorsTexture===null||V.isBatchedMesh&&Ne.batchingColor===!1&&V._colorsTexture!==null||V.isInstancedMesh&&Ne.instancing===!1||!V.isInstancedMesh&&Ne.instancing===!0||V.isSkinnedMesh&&Ne.skinning===!1||!V.isSkinnedMesh&&Ne.skinning===!0||V.isInstancedMesh&&Ne.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&Ne.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&Ne.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&Ne.instancingMorph===!1&&V.morphTexture!==null||Ne.envMap!==Fe||z.fog===!0&&Ne.fog!==be||Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==ne.numPlanes||Ne.numIntersection!==ne.numIntersection)||Ne.vertexAlphas!==Je||Ne.vertexTangents!==rt||Ne.morphTargets!==De||Ne.morphNormals!==ot||Ne.morphColors!==Ct||Ne.morphTargetsCount!==Wt||Ne.numLightProbeGrids!==xh(T.state.lightProbeGridArray)?ut=!0:(Ne.outputColorSpace!==Me||Ne.toneMapping!==yt)&&(Ni=!0):(ut=!0,Ne.__version=z.version);let Xt=Ne.currentProgram;(ut===!0||Ni===!0)&&(Xt=Ni===!0?ed(z,U,V,Me,yt):Vs(z,U,V),B&&z.isNodeMaterial&&B.onUpdateProgram(z,Xt,Ne));let kr=!1,xi=!1,Ui=!1,lt=Xt.getUniforms(),Ht=Ne.uniforms;if(me.useProgram(Xt.program)&&(kr=!0,xi=!0,Ui=!0),z.id!==Y&&(Y=z.id,xi=!0),kr||oe!==y){me.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),lt.setValue(N,"projectionMatrix",y.projectionMatrix),lt.setValue(N,"viewMatrix",y.matrixWorldInverse);let Ut=lt.map.cameraPosition;Ut!==void 0&&Ut.setValue(N,de.setFromMatrixPosition(y.matrixWorld)),Xe.logarithmicDepthBuffer&<.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&<.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),oe!==y&&(oe=y,xi=!0,Ui=!0)}if(Ne.needsLights&&(Kt.state.sunShadowMap.length>0&<.setValue(N,"sunShadowMap",Kt.state.sunShadowMap,Oe),Kt.state.directionalShadowMap.length>0&<.setValue(N,"directionalShadowMap",Kt.state.directionalShadowMap,Oe),Kt.state.spotShadowMap.length>0&<.setValue(N,"spotShadowMap",Kt.state.spotShadowMap,Oe),Kt.state.pointShadowMap.length>0&<.setValue(N,"pointShadowMap",Kt.state.pointShadowMap,Oe)),V.isSkinnedMesh){lt.setOptional(N,V,"bindMatrix"),lt.setOptional(N,V,"bindMatrixInverse");let Et=V.skeleton;Et&&(Et.boneTexture===null&&Et.computeBoneTexture(),lt.setValue(N,"boneTexture",Et.boneTexture,Oe))}V.isBatchedMesh&&(lt.setOptional(N,V,"batchingTexture"),lt.setValue(N,"batchingTexture",V._matricesTexture,Oe),lt.setOptional(N,V,"batchingIdTexture"),lt.setValue(N,"batchingIdTexture",V._indirectTexture,Oe),lt.setOptional(N,V,"batchingColorTexture"),V._colorsTexture!==null&<.setValue(N,"batchingColorTexture",V._colorsTexture,Oe));let Tn=Z.morphAttributes;if((Tn.position!==void 0||Tn.normal!==void 0||Tn.color!==void 0)&&ie.update(V,Z,Xt),(xi||Ne.receiveShadow!==V.receiveShadow)&&(Ne.receiveShadow=V.receiveShadow,lt.setValue(N,"receiveShadow",V.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&U.environment!==null&&(Ht.envMapIntensity.value=U.environmentIntensity),Ht.dfgLUT!==void 0&&(Ht.dfgLUT.value=X_()),xi){if(lt.setValue(N,"toneMappingExposure",P.toneMappingExposure),Ne.needsLights&&nd(Ht,Ui),be&&z.fog===!0&&ge.refreshFogUniforms(Ht,be),ge.refreshMaterialUniforms(Ht,z,I,ke,T.state.transmissionRenderTarget[y.id]),Ne.needsLights&&Ne.numLightProbeGrids>0){let Et=S,Ut=0;for(let Kn of T.state.lightProbeGridArray)Kn.texture!==null&&(Et.textures[Ut]=Kn.texture,Et.min[Ut]=Kn.boundingBox.min,Et.max[Ut]=Kn.boundingBox.max,Et.resolution[Ut]=Kn.resolution,Ut++);for(let Kn in Et)Et[Kn].length=Ut;Ht.probesSH.value=Et.textures,Ht.probesMin.value=Et.min,Ht.probesMax.value=Et.max,Ht.probesResolution.value=Et.resolution}Bs.upload(N,vh(Ne),Ht,Oe)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Bs.upload(N,vh(Ne),Ht,Oe),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&<.setValue(N,"center",V.center),lt.setValue(N,"modelViewMatrix",V.modelViewMatrix),lt.setValue(N,"normalMatrix",V.normalMatrix),lt.setValue(N,"modelMatrix",V.matrixWorld),z.uniformsGroups!==void 0){let Et=z.uniformsGroups;for(let Ut=0,Kn=Et.length;Ut<Kn;Ut++){let Sh=Et[Ut];Ge.update(Sh,Xt),Ge.bind(Sh,Xt)}}return Xt}function nd(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.sunLights.needsUpdate=U,y.sunLightShadows.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function id(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return X},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return ae},this.setRenderTargetTextures=function(y,U,Z){let z=Ue.get(y);z.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),Ue.get(y.texture).__webglTexture=U,Ue.get(y.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:Z,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){let Z=Ue.get(y);Z.__webglFramebuffer=U,Z.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,Z=0){ae=y,X=U,W=Z;let z=null,V=!1,be=!1;if(y){let Me=Ue.get(y);if(Me.__useDefaultFramebuffer!==void 0){me.bindFramebuffer(N.FRAMEBUFFER,Me.__webglFramebuffer),le.copy(y.viewport),Ie.copy(y.scissor),He=y.scissorTest,me.viewport(le),me.scissor(Ie),me.setScissorTest(He),Y=-1;return}else if(Me.__webglFramebuffer===void 0)Oe.setupRenderTarget(y);else if(Me.__hasExternalTextures)Oe.rebindTextures(y,Ue.get(y.texture).__webglTexture,Ue.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let Je=y.depthTexture;if(Me.__boundDepthTexture!==Je){if(Je!==null&&Ue.has(Je)&&(y.width!==Je.image.width||y.height!==Je.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Oe.setupDepthRenderbuffer(y)}}let Re=y.texture;(Re.isData3DTexture||Re.isDataArrayTexture||Re.isCompressedArrayTexture)&&(be=!0);let Fe=Ue.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Fe[U])?z=Fe[U][Z]:z=Fe[U],V=!0):y.samples>0&&Oe.useMultisampledRTT(y)===!1?z=Ue.get(y).__webglMultisampledFramebuffer:Array.isArray(Fe)?z=Fe[Z]:z=Fe,le.copy(y.viewport),Ie.copy(y.scissor),He=y.scissorTest}else le.copy(k).multiplyScalar(I).floor(),Ie.copy(J).multiplyScalar(I).floor(),He=H;if(Z!==0&&(z=K),me.bindFramebuffer(N.FRAMEBUFFER,z)&&me.drawBuffers(y,z),me.viewport(le),me.scissor(Ie),me.setScissorTest(He),V){let Me=Ue.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,Me.__webglTexture,Z)}else if(be){let Me=U;for(let Re=0;Re<y.textures.length;Re++){let Fe=Ue.get(y.textures[Re]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Re,Fe.__webglTexture,Z,Me)}}else if(y!==null&&Z!==0){let Me=Ue.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Me.__webglTexture,Z)}Y=-1};function Mh(y){let U=Ue.get(y);return(U.__readFormat!==y.format||U.__readType!==y.type)&&(U.__readFormat=y.format,U.__readType=y.type,U.__formatReadable=Xe.textureFormatReadable(y.format),U.__typeReadable=Xe.textureTypeReadable(y.type)),U}this.readRenderTargetPixels=function(y,U,Z,z,V,be,Le,Me=0){if(!(y&&y.isWebGLRenderTarget)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Re=Ue.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Le!==void 0&&(Re=Re[Le],Array.isArray(Re)&&(Re=Re[0])),Re){me.bindFramebuffer(N.FRAMEBUFFER,Re);try{let Fe=y.textures[Me],Je=Fe.format,rt=Fe.type;y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+Me);let De=Mh(Fe);if(De.__formatReadable===!1){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-z&&Z>=0&&Z<=y.height-V&&N.readPixels(U,Z,z,V,pe.convert(Je),pe.convert(rt),be)}finally{let Fe=ae!==null?Ue.get(ae).__webglFramebuffer:null;me.bindFramebuffer(N.FRAMEBUFFER,Fe)}}},this.readRenderTargetPixelsAsync=async function(y,U,Z,z,V,be,Le,Me=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Re=Ue.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Le!==void 0&&(Re=Re[Le],Array.isArray(Re)&&(Re=Re[0])),Re)if(U>=0&&U<=y.width-z&&Z>=0&&Z<=y.height-V){me.bindFramebuffer(N.FRAMEBUFFER,Re);let Fe=y.textures[Me],Je=Fe.format,rt=Fe.type;y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+Me);let De=Mh(Fe);if(De.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ot=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,ot),N.bufferData(N.PIXEL_PACK_BUFFER,be.byteLength,N.STREAM_READ),N.readPixels(U,Z,z,V,pe.convert(Je),pe.convert(rt),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let Ct=ae!==null?Ue.get(ae).__webglFramebuffer:null;me.bindFramebuffer(N.FRAMEBUFFER,Ct);let yt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Wu(N,yt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,ot),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,be),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(ot),N.deleteSync(yt),be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,Z=0){let z=Math.pow(2,-Z),V=Math.floor(y.image.width*z),be=Math.floor(y.image.height*z),Le=U!==null?U.x:0,Me=U!==null?U.y:0;Oe.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,Z,0,0,Le,Me,V,be),me.unbindTexture()},this.copyTextureToTexture=function(y,U,Z=null,z=null,V=0,be=0){let Le,Me,Re,Fe,Je,rt,De,ot,Ct,yt=y.isCompressedTexture?y.mipmaps[be]:y.image;if(Z!==null)Le=Z.max.x-Z.min.x,Me=Z.max.y-Z.min.y,Re=Z.isBox3?Z.max.z-Z.min.z:1,Fe=Z.min.x,Je=Z.min.y,rt=Z.isBox3?Z.min.z:0;else{let lt=Math.pow(2,-V);Le=Math.floor(yt.width*lt),Me=Math.floor(yt.height*lt),y.isDataArrayTexture?Re=yt.depth:y.isData3DTexture?Re=Math.floor(yt.depth*lt):Re=1,Fe=0,Je=0,rt=0}z!==null?(De=z.x,ot=z.y,Ct=z.z):(De=0,ot=0,Ct=0);let xt=pe.convert(U.format),Wt=pe.convert(U.type),Ne;U.isData3DTexture?(Oe.setTexture3D(U,0),Ne=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Oe.setTexture2DArray(U,0),Ne=N.TEXTURE_2D_ARRAY):(Oe.setTexture2D(U,0),Ne=N.TEXTURE_2D),me.activeTexture(N.TEXTURE0),me.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),me.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),me.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);let Kt=me.getParameter(N.UNPACK_ROW_LENGTH),ut=me.getParameter(N.UNPACK_IMAGE_HEIGHT),Ni=me.getParameter(N.UNPACK_SKIP_PIXELS),Xt=me.getParameter(N.UNPACK_SKIP_ROWS),kr=me.getParameter(N.UNPACK_SKIP_IMAGES);me.pixelStorei(N.UNPACK_ROW_LENGTH,yt.width),me.pixelStorei(N.UNPACK_IMAGE_HEIGHT,yt.height),me.pixelStorei(N.UNPACK_SKIP_PIXELS,Fe),me.pixelStorei(N.UNPACK_SKIP_ROWS,Je),me.pixelStorei(N.UNPACK_SKIP_IMAGES,rt);let xi=y.isDataArrayTexture||y.isData3DTexture,Ui=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){let lt=Ue.get(y),Ht=Ue.get(U),Tn=Ue.get(lt.__renderTarget),Et=Ue.get(Ht.__renderTarget);me.bindFramebuffer(N.READ_FRAMEBUFFER,Tn.__webglFramebuffer),me.bindFramebuffer(N.DRAW_FRAMEBUFFER,Et.__webglFramebuffer);for(let Ut=0;Ut<Re;Ut++)xi&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ue.get(y).__webglTexture,V,rt+Ut),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ue.get(U).__webglTexture,be,Ct+Ut)),N.blitFramebuffer(Fe,Je,Fe+Le,Je+Me,De,ot,De+Le,ot+Me,N.DEPTH_BUFFER_BIT,N.NEAREST);me.bindFramebuffer(N.READ_FRAMEBUFFER,null),me.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(V!==0||y.isRenderTargetTexture||Ue.has(y)){let lt=Ue.get(y),Ht=Ue.get(U);me.bindFramebuffer(N.READ_FRAMEBUFFER,C),me.bindFramebuffer(N.DRAW_FRAMEBUFFER,q);for(let Tn=0;Tn<Re;Tn++)xi?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,lt.__webglTexture,V,rt+Tn):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,lt.__webglTexture,V),Ui?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ht.__webglTexture,be,Ct+Tn):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ht.__webglTexture,be),V!==0?N.blitFramebuffer(Fe,Je,Fe+Le,Je+Me,De,ot,De+Le,ot+Me,N.COLOR_BUFFER_BIT,N.NEAREST):Ui?N.copyTexSubImage3D(Ne,be,De,ot,Ct+Tn,Fe,Je,Le,Me):N.copyTexSubImage2D(Ne,be,De,ot,Fe,Je,Le,Me);me.bindFramebuffer(N.READ_FRAMEBUFFER,null),me.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else Ui?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(Ne,be,De,ot,Ct,Le,Me,Re,xt,Wt,yt.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(Ne,be,De,ot,Ct,Le,Me,Re,xt,yt.data):N.texSubImage3D(Ne,be,De,ot,Ct,Le,Me,Re,xt,Wt,yt):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,be,De,ot,Le,Me,xt,Wt,yt.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,be,De,ot,yt.width,yt.height,xt,yt.data):N.texSubImage2D(N.TEXTURE_2D,be,De,ot,Le,Me,xt,Wt,yt);me.pixelStorei(N.UNPACK_ROW_LENGTH,Kt),me.pixelStorei(N.UNPACK_IMAGE_HEIGHT,ut),me.pixelStorei(N.UNPACK_SKIP_PIXELS,Ni),me.pixelStorei(N.UNPACK_SKIP_ROWS,Xt),me.pixelStorei(N.UNPACK_SKIP_IMAGES,kr),be===0&&U.generateMipmaps===!0&&U.mipmapsAutoUpdate===!0&&N.generateMipmap(Ne),me.unbindTexture()},this.initRenderTarget=function(y){Ue.get(y).__webglFramebuffer===void 0&&Oe.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?Oe.setTextureCube(y,0):y.isData3DTexture?Oe.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Oe.setTexture2DArray(y,0):Oe.setTexture2D(y,0),me.unbindTexture()},this.resetState=function(){X=0,W=0,ae=null,me.reset(),_e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _n}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=tt._getDrawingBufferColorSpace(e),t.unpackColorSpace=tt._getUnpackColorSpace()}};var Cf={type:"change"},Sc={type:"start"},Pf={type:"end"},Ua=new ri,If=new hn,q_=Math.cos(70*Os.DEG2RAD),Dt=new O,an=2*Math.PI,ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},yc=1e-6,Mc=class extends Sr{constructor(e,t=null){super(e,t),this.state=ft.NONE,this.target=new O,this.cursor=new O,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:Ci.ROTATE,MIDDLE:Ci.DOLLY,RIGHT:Ci.PAN},this.touches={ONE:Ii.ROTATE,TWO:Ii.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 O,this._lastQuaternion=new zt,this._lastTargetPosition=new O,this._quat=new zt().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Is,this._sphericalDelta=new Is,this._scale=1,this._panOffset=new O,this._rotateStart=new We,this._rotateEnd=new We,this._rotateDelta=new We,this._panStart=new We,this._panEnd=new We,this._panDelta=new We,this._dollyStart=new We,this._dollyEnd=new We,this._dollyDelta=new We,this._dollyDirection=new O,this._mouse=new We,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Z_.bind(this),this._onPointerDown=Y_.bind(this),this._onPointerUp=K_.bind(this),this._onContextMenu=nx.bind(this),this._onMouseWheel=$_.bind(this),this._onKeyDown=Q_.bind(this),this._onTouchStart=ex.bind(this),this._onTouchMove=tx.bind(this),this._onMouseDown=J_.bind(this),this._onMouseMove=j_.bind(this),this._interceptControlDown=ix.bind(this),this._interceptControlUp=sx.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),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.ownerDocument.addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ft.NONE,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.ownerDocument.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Cf),this.update(),this.state=ft.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;Dt.copy(t).sub(this.target),Dt.applyQuaternion(this._quat),this._spherical.setFromVector3(Dt),this.autoRotate&&this.state===ft.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=an:n>Math.PI&&(n-=an),s<-Math.PI?s+=an:s>Math.PI&&(s-=an),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Dt.setFromSpherical(this._spherical),Dt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Dt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=Dt.length();o=this._clampDistance(a*this._scale);let c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let a=new O(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;let l=new O(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=Dt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Ua.origin.copy(this.object.position),Ua.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ua.direction))<q_?this.object.lookAt(this.target):(If.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ua.intersectPlane(If,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>yc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>yc||this._lastTargetPosition.distanceToSquared(this.target)>yc?(this.dispatchEvent(Cf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?an/60*this.autoRotateSpeed*e:an/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Dt.setFromMatrixColumn(t,0),Dt.multiplyScalar(-e),this._panOffset.add(Dt)}_panUp(e,t){this.screenSpacePanning===!0?Dt.setFromMatrixColumn(t,1):(Dt.setFromMatrixColumn(t,0),Dt.crossVectors(this.object.up,Dt)),Dt.multiplyScalar(e),this._panOffset.add(Dt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Dt.copy(s).sub(this.target);let r=Dt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*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(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientY),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.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.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.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(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new We,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function Y_(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Z_(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function K_(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Pf),this.state=ft.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function J_(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Ci.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=ft.DOLLY;break;case Ci.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ft.ROTATE}break;case Ci.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ft.PAN}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(Sc)}function j_(i){switch(this.state){case ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function $_(i){this.enabled===!1||this.enableZoom===!1||this.state!==ft.NONE||(i.preventDefault(),this.dispatchEvent(Sc),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Pf))}function Q_(i){this.enabled!==!1&&this._handleKeyDown(i)}function ex(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Ii.ROTATE:if(this.enableRotate===!1){this.state=ft.NONE;break}this._handleTouchStartRotate(i),this.state=ft.TOUCH_ROTATE;break;case Ii.PAN:if(this.enablePan===!1){this.state=ft.NONE;break}this._handleTouchStartPan(i),this.state=ft.TOUCH_PAN;break;default:this.state=ft.NONE}break;case 2:switch(this.touches.TWO){case Ii.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=ft.TOUCH_DOLLY_PAN;break;case Ii.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=ft.TOUCH_DOLLY_ROTATE;break;default:this.state=ft.NONE}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(Sc)}function tx(i){switch(this._trackPointer(i),this.state){case ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=ft.NONE}}function nx(i){this.enabled!==!1&&i.preventDefault()}function ix(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function sx(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var bc=class extends Vt{constructor(e){super(e)}load(e,t,n,s){let r=this,o=new xn(this.manager);o.setPriority(this.priority),o.setCache(this.cache),o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){s?s(c):console.error(c),r.manager.itemError(e)}},n,s)}parse(e){function t(l){let h=new DataView(l),u=32/8*3+32/8*3*3+16/8,f=h.getUint32(80,!0);if(80+32/8+f*u===h.byteLength)return!0;let g=[115,111,108,105,100];for(let x=0;x<5;x++)if(n(g,h,x))return!1;return!0}function n(l,h,u){for(let f=0,d=l.length;f<d;f++)if(l[f]!==h.getUint8(u+f))return!1;return!0}function s(l){let h=new DataView(l),u=h.getUint32(80,!0),f,d,g,x=!1,m,p,M,A,S;for(let L=0;L<=70;L++)h.getUint32(L,!1)==1129270351&&h.getUint8(L+4)==82&&h.getUint8(L+5)==61&&(x=!0,m=new Float32Array(u*3*3),p=h.getUint8(L+6)/255,M=h.getUint8(L+7)/255,A=h.getUint8(L+8)/255,S=h.getUint8(L+9)/255);let E=84,T=50,_=new _t,b=new Float32Array(u*3*3),F=new Float32Array(u*3*3),P=new Be;for(let L=0;L<u;L++){let B=E+L*T,K=h.getFloat32(B,!0),C=h.getFloat32(B+4,!0),q=h.getFloat32(B+8,!0);if(x){let X=h.getUint16(B+48,!0);(X&32768)===0?(f=(X&31)/31,d=(X>>5&31)/31,g=(X>>10&31)/31):(f=p,d=M,g=A)}for(let X=1;X<=3;X++){let W=B+X*12,ae=L*3*3+(X-1)*3;b[ae]=h.getFloat32(W,!0),b[ae+1]=h.getFloat32(W+4,!0),b[ae+2]=h.getFloat32(W+8,!0),F[ae]=K,F[ae+1]=C,F[ae+2]=q,x&&(P.setRGB(f,d,g,Mt),m[ae]=P.r,m[ae+1]=P.g,m[ae+2]=P.b)}}return _.setAttribute("position",new St(b,3)),_.setAttribute("normal",new St(F,3)),x&&(_.setAttribute("color",new St(m,3)),_.hasColors=!0,_.alpha=S),_}function r(l){let h=new _t,u=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g,d=/solid\s(.+)/,g=0,x=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+x+x+x,"g"),p=new RegExp("normal"+x+x+x,"g"),M=[],A=[],S=[],E=new O,T,_=0,b=0,F=0;for(;(T=u.exec(l))!==null;){b=F;let P=T[0],L=(T=d.exec(P))!==null?T[1]:"";for(S.push(L);(T=f.exec(P))!==null;){let C=0,q=0,X=T[0];for(;(T=p.exec(X))!==null;)E.x=parseFloat(T[1]),E.y=parseFloat(T[2]),E.z=parseFloat(T[3]),q++;for(;(T=m.exec(X))!==null;)M.push(parseFloat(T[1]),parseFloat(T[2]),parseFloat(T[3])),A.push(E.x,E.y,E.z),C++,F++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+g),C!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+g),g++}let B=b,K=F-b;h.userData.groupNames=S,h.addGroup(B,K,_),_++}return h.setAttribute("position",new st(M,3)),h.setAttribute("normal",new st(A,3)),h}function o(l){return typeof l!="string"?new TextDecoder().decode(l):l}function a(l){if(typeof l=="string"){let h=new Uint8Array(l.length);for(let u=0;u<l.length;u++)h[u]=l.charCodeAt(u)&255;return h.buffer||h}else return l}let c=a(e);return t(c)?s(c):r(o(e))}};var rx=/^[og]\s*(.+)?/,ox=/^mtllib /,ax=/^usemtl /,lx=/^usemap /,Fa=/\s+/,Lf=new O,Tc=new O,Df=new O,Nf=new O,Mn=new O,Oa=new Be;function cx(){let i={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(s,r){let o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);let a={index:this.materials.length,name:s||"",mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){let l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){let r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),s&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},n&&n.name&&typeof n.clone=="function"){let s=n.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let s=this.vertices,r=this.object.geometry.vertices;r.push(s[e+0],s[e+1],s[e+2]),r.push(s[t+0],s[t+1],s[t+2]),r.push(s[n+0],s[n+1],s[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let s=this.normals,r=this.object.geometry.normals;r.push(s[e+0],s[e+1],s[e+2]),r.push(s[t+0],s[t+1],s[t+2]),r.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){let s=this.vertices,r=this.object.geometry.normals;Lf.fromArray(s,e),Tc.fromArray(s,t),Df.fromArray(s,n),Mn.subVectors(Df,Tc),Nf.subVectors(Lf,Tc),Mn.cross(Nf),Mn.normalize(),r.push(Mn.x,Mn.y,Mn.z),r.push(Mn.x,Mn.y,Mn.z),r.push(Mn.x,Mn.y,Mn.z)},addColor:function(e,t,n){let s=this.colors,r=this.object.geometry.colors;s[e]!==void 0&&r.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&r.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&r.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){let s=this.uvs,r=this.object.geometry.uvs;r.push(s[e+0],s[e+1]),r.push(s[t+0],s[t+1]),r.push(s[n+0],s[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,s,r,o,a,c,l){let h=this.vertices.length,u=this.parseVertexIndex(e,h),f=this.parseVertexIndex(t,h),d=this.parseVertexIndex(n,h);if(this.addVertex(u,f,d),this.addColor(u,f,d),a!==void 0&&a!==""){let g=this.normals.length;u=this.parseNormalIndex(a,g),f=this.parseNormalIndex(c,g),d=this.parseNormalIndex(l,g),this.addNormal(u,f,d)}else this.addFaceNormal(u,f,d);if(s!==void 0&&s!==""){let g=this.uvs.length;u=this.parseUVIndex(s,g),f=this.parseUVIndex(r,g),d=this.parseUVIndex(o,g),this.addUV(u,f,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";let t=this.vertices.length;for(let n=0,s=e.length;n<s;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";let n=this.vertices.length,s=this.uvs.length;for(let r=0,o=e.length-1;r<o;r++)this.addVertexLine(this.parseVertexIndex(e[r],n)),this.addVertexLine(this.parseVertexIndex(e[r+1],n));for(let r=0,o=t.length-1;r<o;r++)this.addUVLine(this.parseUVIndex(t[r],s)),this.addUVLine(this.parseUVIndex(t[r+1],s))}};return i.startObject("",!1),i}var Ac=class extends Vt{constructor(e){super(e),this.materials=null}load(e,t,n,s){let r=this,o=new xn(this.manager);o.setPriority(this.priority),o.setCache(this.cache),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){s?s(c):console.error(c),r.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){let t=new cx;e.indexOf(`\r | ||
| 4229 | `)!==-1&&(e=e.replace(/\r\n/g,` | ||
| 4230 | `)),e.indexOf(`\\ | ||
| 4231 | `)!==-1&&(e=e.replace(/\\\n/g,""));let n=e.split(` | ||
| 4232 | `),s=[];for(let a=0,c=n.length;a<c;a++){let l=n[a].trimStart();if(l.length===0)continue;let h=l.charAt(0);if(h!=="#")if(h==="v"){let u=l.split(Fa);switch(u[0]){case"v":t.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])),u.length>=7?(Oa.setRGB(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6]),Mt),t.colors.push(Oa.r,Oa.g,Oa.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(h==="f"){let f=l.slice(1).trim().split(Fa),d=[];for(let x=0,m=f.length;x<m;x++){let p=f[x];if(p.length>0){let M=p.split("/");d.push(M)}}let g=d[0];for(let x=1,m=d.length-1;x<m;x++){let p=d[x],M=d[x+1];t.addFace(g[0],p[0],M[0],g[1],p[1],M[1],g[2],p[2],M[2])}}else if(h==="l"){let u=l.substring(1).trim().split(Fa),f=[],d=[];if(l.indexOf("/")===-1)f=u;else for(let g=0,x=u.length;g<x;g++){let m=u[g].split("/");m[0]!==""&&f.push(m[0]),m[1]!==""&&d.push(m[1])}t.addLineGeometry(f,d)}else if(h==="p"){let f=l.slice(1).trim().split(Fa);t.addPointGeometry(f)}else if((s=rx.exec(l))!==null){let u=(" "+s[0].slice(1).trim()).slice(1);t.startObject(u)}else if(ax.test(l))t.object.startMaterial(l.substring(7).trim(),t.materialLibraries);else if(ox.test(l))t.materialLibraries.push(l.substring(7).trim());else if(lx.test(l))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(h==="s"){if(s=l.split(" "),s.length>1){let f=s[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;let u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();let r=new Bt;if(r.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let a=0,c=t.objects.length;a<c;a++){let l=t.objects[a],h=l.geometry,u=l.materials,f=h.type==="Line",d=h.type==="Points",g=!1;if(h.vertices.length===0)continue;let x=new _t;x.setAttribute("position",new st(h.vertices,3)),h.normals.length>0&&x.setAttribute("normal",new st(h.normals,3)),h.colors.length>0&&(g=!0,x.setAttribute("color",new st(h.colors,3))),h.hasUVIndices===!0&&x.setAttribute("uv",new st(h.uvs,2));let m=[];for(let M=0,A=u.length;M<A;M++){let S=u[M],E=S.name+"_"+S.smooth+"_"+g,T=t.materials[E];if(this.materials!==null){if(T=this.materials.create(S.name),f&&T&&!(T instanceof Bn)){let _=new Bn;Gt.prototype.copy.call(_,T),_.color.copy(T.color),T=_}else if(d&&T&&!(T instanceof Cn)){let _=new Cn({size:10,sizeAttenuation:!1});Gt.prototype.copy.call(_,T),_.color.copy(T.color),_.map=T.map,T=_}}T===void 0&&(f?T=new Bn:d?T=new Cn({size:1,sizeAttenuation:!1}):T=new In,T.name=S.name,T.flatShading=!S.smooth,T.vertexColors=g,t.materials[E]=T),m.push(T)}let p;if(m.length>1){for(let M=0,A=u.length;M<A;M++){let S=u[M];x.addGroup(S.groupStart,S.groupCount,M)}f?p=new Ei(x,m):d?p=new ai(x,m):p=new bt(x,m)}else f?p=new Ei(x,m[0]):d?p=new ai(x,m[0]):p=new bt(x,m[0]);p.name=l.name,r.add(p)}else if(t.vertices.length>0){let a=new Cn({size:1,sizeAttenuation:!1}),c=new _t;c.setAttribute("position",new st(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new st(t.colors,3)),a.vertexColors=!0);let l=new ai(c,a);r.add(l)}return r}};function Ff(i,e=!1){let t=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),s=new Set(Object.keys(i[0].morphAttributes)),r={},o={},a=i[0].morphTargetsRelative,c=new _t;c.morphTargetsRelative=a;let l=0;for(let h=0;h<i.length;++h){let u=i[h],f=0,d=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let g in u.attributes){if(!n.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+g+'" attribute exists among all geometries, or in none of them.'),null;r[g]===void 0&&(r[g]=[]),r[g].push(u.attributes[g]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let g in u.morphAttributes){if(!s.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;if(u.morphAttributes[g].length!==i[0].morphAttributes[g].length)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have the same number of morph targets for the "'+g+'" morph attribute.'),null;o[g]===void 0&&(o[g]=[]),o[g].push(u.morphAttributes[g]),d++}if(d!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of morph attributes."),null;if(e){let g;if(t)g=u.index.count;else if(u.attributes.position!==void 0)g=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,g,h),l+=g}}if(t){let h=0,u=[];for(let f=0;f<i.length;++f){let d=i[f].index;for(let g=0;g<d.count;++g)u.push(d.getX(g)+h);h+=i[f].attributes.position.count}c.setIndex(u)}for(let h in r){let u=Uf(r[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;c.setAttribute(h,u)}for(let h in o){let u=o[h][0].length;if(u!==0){c.morphAttributes=c.morphAttributes||{},c.morphAttributes[h]=[];for(let f=0;f<u;++f){let d=[];for(let x=0;x<o[h].length;++x)d.push(o[h][x][f]);let g=Uf(d);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;c.morphAttributes[h].push(g)}}}return c}function Uf(i){let e,t,n,s=-1,r=0;for(let l=0;l<i.length;++l){let h=i[l];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*t}let o=new e(r),a=new St(o,t,n),c=0;for(let l=0;l<i.length;++l){let h=i[l];if(h.isInterleavedBufferAttribute){let u=c/t;for(let f=0,d=h.count;f<d;f++)for(let g=0;g<t;g++){let x=h.getComponent(f,g);a.setComponent(f+u,g,x)}}else o.set(h.array,c);c+=h.count*t}return s!==void 0&&(a.gpuType=s),a}function wc(i,e){if(e===Wl)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Fs||e===Ir){let t=i.getIndex();if(t===null){let r=[],o=i.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)r.push(a);i.setIndex(r),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,s=[];if(e===Fs)for(let r=1;r<=n;r++)s.push(t.getX(0)),s.push(t.getX(r)),s.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(s.push(t.getX(r)),s.push(t.getX(r+1)),s.push(t.getX(r+2))):(s.push(t.getX(r+2)),s.push(t.getX(r+1)),s.push(t.getX(r)));return s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}function Of(i){let e=new Map,t=new Map,n=i.clone();return Bf(i,n,function(s,r){e.set(r,s),t.set(s,r)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;let r=s,o=e.get(s),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(c){return t.get(c)}),r.bind(r.skeleton,r.bindMatrix)}),n}function Bf(i,e,t){t(i,e);for(let n=0;n<i.children.length;n++)Bf(i.children[n],e.children[n],t)}var Ic=class extends Vt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Nc(t)}),this.register(function(t){return new Uc(t)}),this.register(function(t){return new Fc(t)}),this.register(function(t){return new Xc(t)}),this.register(function(t){return new qc(t)}),this.register(function(t){return new Yc(t)}),this.register(function(t){return new Bc(t)}),this.register(function(t){return new zc(t)}),this.register(function(t){return new kc(t)}),this.register(function(t){return new Gc(t)}),this.register(function(t){return new Dc(t)}),this.register(function(t){return new Vc(t)}),this.register(function(t){return new Oc(t)}),this.register(function(t){return new Wc(t)}),this.register(function(t){return new Hc(t)}),this.register(function(t){return new Pc(t)}),this.register(function(t){return new Ba(t,it.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ba(t,it.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Zc(t)})}load(e,t,n,s){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=di.extractUrlBase(e);o=di.resolveURL(l,this.path)}else o=di.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new xn(this.manager);c.setPriority(this.priority),c.setCache(this.cache),c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r,o={},a={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Hf){try{o[it.KHR_BINARY_GLTF]=new Kc(e)}catch(u){s&&s(u);return}r=JSON.parse(o[it.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new nh(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let u=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(u){case it.KHR_MATERIALS_UNLIT:o[u]=new Lc;break;case it.KHR_DRACO_MESH_COMPRESSION:o[u]=new Jc(r,this.dracoLoader);break;case it.KHR_TEXTURE_TRANSFORM:o[u]=new jc;break;case it.KHR_MESH_QUANTIZATION:o[u]=new $c;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};function hx(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function Rt(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}var it={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_DIFFUSE_ROUGHNESS:"KHR_materials_diffuse_roughness",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"},Pc=class{constructor(e){this.parser=e,this.name=it.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,s=t.cache.get(n);if(s)return s;let r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],l,h=new Be(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],$t);let u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new Rs(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new yr(h),l.distance=u;break;case"spot":l=new vr(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),Yn(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}},Lc=class{constructor(){this.name=it.KHR_MATERIALS_UNLIT}getMaterialType(){return On}extendParams(e,t,n){let s=[];e.color=new Be(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],$t),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Mt))}return Promise.all(s)}},Dc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},Nc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new We(r,r)}return Promise.all(s)}},Uc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return t.diffuseRoughness=n.diffuseRoughnessFactor!==void 0?n.diffuseRoughnessFactor:0,n.diffuseRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"diffuseRoughnessMap",n.diffuseRoughnessTexture)),Promise.all(s)}},Fc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}},Oc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}},Bc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_SHEEN}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];if(t.sheenColor=new Be(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],$t)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Mt)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}},zc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}},kc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_VOLUME}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Be().setRGB(r[0],r[1],r[2],$t),Promise.all(s)}},Gc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_IOR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Vc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];return t.specularColor=new Be().setRGB(r[0],r[1],r[2],$t),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Mt)),Promise.all(s)}},Hc=class{constructor(e){this.parser=e,this.name=it.EXT_MATERIALS_BUMP}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}},Wc=class{constructor(e){this.parser=e,this.name=it.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?Qt:null}extendMaterialParams(e,t){let n=Rt(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}},Xc=class{constructor(e){this.parser=e,this.name=it.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;let r=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},qc=class{constructor(e){this.parser=e,this.name=it.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}},Yc=class{constructor(e){this.parser=e,this.name=it.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}},Ba=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let c=s.byteOffset||0,l=s.byteLength||0,h=s.count,u=s.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,s.mode,s.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,s.mode,s.filter),d})})}else return null}},Zc=class{constructor(e){this.name=it.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let l of s.primitives)if(l.mode!==Sn.TRIANGLES&&l.mode!==Sn.TRIANGLE_STRIP&&l.mode!==Sn.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(let g of u){let x=new Ze,m=new O,p=new zt,M=new O(1,1,1),A=new lr(g.geometry,g.material,f);for(let E=0;E<f;E++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,E),c.SCALE&&M.fromBufferAttribute(c.SCALE,E),A.setMatrixAt(E,x.compose(m,p,M));let S=null;for(let E in c)if(E==="_COLOR_0"){let T=c[E];A.instanceColor=new oi(T.array,T.itemSize,T.normalized)}else if(E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"){if(S===null){let _=A.geometry;S=new _t,S.name=_.name;for(let b in _.attributes)S.setAttribute(b,_.attributes[b]);for(let b in _.morphAttributes)S.morphAttributes[b]=_.morphAttributes[b];_.index!==null&&S.setIndex(_.index),S.morphTargetsRelative=_.morphTargetsRelative;for(let b of _.groups)S.addGroup(b.start,b.count,b.materialIndex);_.boundingBox!==null&&(S.boundingBox=_.boundingBox.clone()),_.boundingSphere!==null&&(S.boundingSphere=_.boundingSphere.clone()),S.drawRange.start=_.drawRange.start,S.drawRange.count=_.drawRange.count,S.userData=Object.assign({},_.userData),A.geometry=S}let T=c[E];S.setAttribute(E,new oi(T.array,T.itemSize,T.normalized))}wt.prototype.copy.call(A,g),this.parser.assignFinalMaterial(A),d.push(A)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}},Hf="glTF",Fr=12,zf={JSON:1313821514,BIN:5130562},Kc=class{constructor(e){this.name=it.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Fr),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Hf)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let s=this.header.length-Fr,r=new DataView(e,Fr),o=0;for(;o<s;){let a=r.getUint32(o,!0);o+=4;let c=r.getUint32(o,!0);if(o+=4,c===zf.JSON){let l=new Uint8Array(e,Fr+o,a);this.content=n.decode(l)}else if(c===zf.BIN){let l=Fr+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Jc=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=it.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let h in o){let u=eh[h]||h.toLowerCase();a[u]=o[h]}for(let h in e.attributes){let u=eh[h]||h.toLowerCase();if(o[h]!==void 0){let f=n.accessors[e.attributes[h]],d=ks[f.componentType];l[u]=d.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){s.decodeDracoFile(h,function(d){for(let g in d.attributes){let x=d.attributes[g],m=c[g];m!==void 0&&(x.normalized=m)}u(d)},a,l,$t,f)})})}},jc=class{constructor(){this.name=it.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let n=Math.cos(e.rotation),s=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*s,e.offset.x,-e.repeat.x*s,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},$c=class{constructor(){this.name=it.KHR_MESH_QUANTIZATION}},za=class extends Gn{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=s-t,u=(n-t)/h,f=u*u,d=f*u,g=e*l,x=g-l,m=-2*d+3*f,p=d-f,M=1-m,A=p-f+u;for(let S=0;S!==a;S++){let E=o[x+S+a],T=o[x+S+c]*h,_=o[g+S+a],b=o[g+S]*h;r[S]=M*E+A*T+m*_+p*b}return r}},ux=new zt,Qc=class extends za{interpolate_(e,t,n,s){let r=super.interpolate_(e,t,n,s);return ux.fromArray(r).normalize().toArray(r),r}},Sn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ks={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kf={9728:Tt,9729:At,9984:Xo,9985:Ns,9986:ji,9987:tn},Gf={33071:jt,33648:ii,10497:un},Ec={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eh={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"},Li={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},fx={CUBICSPLINE:void 0,LINEAR:Vi,STEP:Gi},Rc={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function dx(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new kn({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Vn})),i.DefaultMaterial}function es(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Yn(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function px(i,e,t){let n=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){let u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);let o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){let u=e[l];if(n){let f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;o.push(f)}if(s){let f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;a.push(f)}if(r){let f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let h=l[0],u=l[1],f=l[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=f),i.morphTargetsRelative=!0,i})}function mx(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function gx(i){let e,t=i.extensions&&i.extensions[it.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Cc(t.attributes):e=i.indices+":"+Cc(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+Cc(i.targets[n]);return e}function Cc(i){let e="",t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function th(i){switch(i){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.")}}function _x(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var xx=new Ze,nh=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hx,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 n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?(this.textureLoader=new Xi(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new Mr(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new xn(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType("arraybuffer"),(this.options.withCredentials||this.options.crossOrigin==="use-credentials")&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return es(r,a,s),Yn(a,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){let o=t[s].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){let o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let s=n.clone(),r=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,h]of o.children.entries())r(h,a.children[l])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let s=e(t[n]);if(s)return s}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let s=0;s<t.length;s++){let r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[it.KHR_BINARY_GLTF].body);let s=this.options;return new Promise(function(r,o){n.load(di.resolveURL(t.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){let t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){let o=Ec[s.type],a=ks[s.componentType],c=s.normalized===!0,l=new a(s.count*o);return Promise.resolve(new St(l,o,c))}let r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],c=Ec[s.type],l=ks[s.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=s.byteOffset||0,d=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,g=s.normalized===!0,x,m;if(d&&d!==u){let p=Math.floor(f/d),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+p+":"+s.count,A=t.cache.get(M);A||(x=new l(a,p*d,s.count*d/h),A=new Ss(x,d/h),t.cache.add(M,A)),m=new bs(A,c,f%d/h,g)}else a===null?x=new l(s.count*c):x=new l(a,f,s.count*c),m=new St(x,c,g);if(s.sparse!==void 0){let p=Ec.SCALAR,M=ks[s.sparse.indices.componentType],A=s.sparse.indices.byteOffset||0,S=s.sparse.values.byteOffset||0,E=new M(o[1],A,s.sparse.count*p),T=new l(o[2],S,s.sparse.count*c);a!==null&&(m=new St(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let _=0,b=E.length;_<b;_++){let F=E[_];if(m.setX(F,T[_*c]),c>=2&&m.setY(F,T[_*c+1]),c>=3&&m.setZ(F,T[_*c+2]),c>=4&&m.setW(F,T[_*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let s=this,r=this.json,o=r.textures[e],a=r.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let f=(r.samplers||{})[o.sampler]||{};return h.magFilter=kf[f.magFilter]||At,h.minFilter=kf[f.minFilter]||tn,h.wrapS=Gf[f.wrapS]||un,h.wrapT=Gf[f.wrapT]||un,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Tt&&h.minFilter!==At,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());let o=s.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1,h;if(t.isKTX2Loader===!0&&o.bufferView!==void 0)h=n.getDependency("bufferView",o.bufferView).then(function(f){return new Promise(function(d,g){t.parse(f,d,g)})});else{if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(f){l=!0;let d=new Blob([f],{type:o.mimeType});return c=a.createObjectURL(d),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");h=Promise.resolve(c).then(function(f){return new Promise(function(d,g){let x=d;t.isImageBitmapLoader===!0&&(x=function(m){let p=new kt(m);p.needsUpdate=!0,d(p)}),t.load(di.resolveURL(f,r.path),x,void 0,g)})})}let u=h.then(function(f){return l===!0&&a.revokeObjectURL(c),Yn(f,o),f.userData.mimeType=o.mimeType||_x(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[it.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[it.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=r.associations.get(o);o=r.extensions[it.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Cn,Gt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Bn,Gt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return kn}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],o,a={},c=r.extensions||{},l=[];if(c[it.KHR_MATERIALS_UNLIT]){let u=s[it.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new Be(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],$t),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,Mt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=vn);let h=r.alphaMode||Rc.OPAQUE;if(h===Rc.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Rc.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==On&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new We(1,1),r.normalTexture.scale!==void 0)){let u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==On&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==On){let u=r.emissiveFactor;a.emissive=new Be().setRGB(u[0],u[1],u[2],$t)}return r.emissiveTexture!==void 0&&o!==On&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Mt)),Promise.all(l).then(function(){let u=new o(a);return r.name&&(u.name=r.name),Yn(u,r),t.associations.set(u,{materials:e}),r.extensions&&es(s,u,r),u})}createUniqueName(e){let t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[it.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Vf(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],h=gx(l),u=s[h];if(u)o.push(u.promise);else{let f;l.extensions&&l.extensions[it.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=Vf(new _t,l,t),l.mode===Sn.TRIANGLE_STRIP?f=f.then(d=>wc(d,Ir)):l.mode===Sn.TRIANGLE_FAN&&(f=f.then(d=>wc(d,Fs))),s[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let h=o[c].material===void 0?dx(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(async function(c){let l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,g=h.length;d<g;d++){let x=h[d],m=o[d],p,M=l[d];if(m.mode===Sn.TRIANGLES||m.mode===Sn.TRIANGLE_STRIP||m.mode===Sn.TRIANGLE_FAN||m.mode===void 0){let A=r.isSkinnedMesh===!0,S=x.hasAttribute("skinIndex")&&x.hasAttribute("skinWeight");A&&S===!1&&console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled."),p=A&&S?new or(x,M):new bt(x,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights()}else if(m.mode===Sn.LINES)p=new Ei(x,M);else if(m.mode===Sn.LINE_STRIP)p=new Wi(x,M);else if(m.mode===Sn.LINE_LOOP)p=new cr(x,M);else if(m.mode===Sn.POINTS)p=new ai(x,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&mx(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Yn(p,r),m.extensions&&es(s,p,m),t.assignFinalMaterial(p),u.push(p)}for(let d=0,g=u.length;d<g;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&es(s,u[0],r),u[0];let f=new Bt;r.extensions&&es(s,f,r),t.associations.set(f,{meshes:e});for(let d=0,g=u.length;d<g;d++)f.add(u[d]);return f})}loadCamera(e){let t,n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Ot(Os.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new Yi(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Yn(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){let r=s.pop(),o=s,a=[],c=[];for(let l=0,h=o.length;l<h;l++){let u=o[l];if(u){a.push(u);let f=new Ze;r!==null&&f.fromArray(r.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new ar(a,c)})}loadAnimation(e){let t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];for(let u=0,f=s.channels.length;u<f;u++){let d=s.channels[u],g=s.samplers[d.sampler],x=d.target,m=x.node,p=s.parameters!==void 0?s.parameters[g.input]:g.input,M=s.parameters!==void 0?s.parameters[g.output]:g.output;x.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",M)),l.push(g),h.push(x))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){let f=u[0],d=u[1],g=u[2],x=u[3],m=u[4],p=[];for(let A=0,S=f.length;A<S;A++){let E=f[A],T=d[A],_=g[A],b=x[A],F=m[A];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();let P=n._createAnimationTracks(E,T,_,b,F);if(P)for(let L=0;L<P.length;L++)p.push(P[L])}let M=new _r(r,void 0,p);return Yn(M,s),M})}createNodeMesh(e){let t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=s.weights.length;c<l;c++)a.morphTargetInfluences[c]=s.weights[c]}),o})}loadNode(e){let t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=s.children||[];for(let l=0,h=a.length;l<h;l++)o.push(n.getDependency("node",a[l]));let c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){let h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(d){d.isSkinnedMesh&&d.bind(f,xx)});for(let d=0,g=u.length;d<g;d++)h.add(u[d]);if(h.userData.pivot!==void 0&&u.length>0){let d=h.userData.pivot,g=u[0];h.pivot=new O().fromArray(d),h.position.x-=d[0],h.position.y-=d[1],h.position.z-=d[2],g.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(r.isBone===!0?h=new Ts:l.length>1?h=new Bt:l.length===1?h=l[0]:h=new wt,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=o),Yn(h,r),r.extensions&&es(n,h,r),r.matrix!==void 0){let u=new Ze;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){let u=s.associations.get(h);s.associations.set(h,{...u})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new Bt;n.name&&(r.name=s.createUniqueName(n.name)),Yn(r,n),n.extensions&&es(t,r,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(s.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++){let f=c[h];f.parent!==null?r.add(Of(f)):r.add(f)}let l=h=>{let u=new Map;for(let[f,d]of s.associations)(f instanceof Gt||f instanceof kt)&&u.set(f,d);return h.traverse(f=>{let d=s.associations.get(f);d!=null&&u.set(f,d)}),u};return s.associations=l(r),r})}_createAnimationTracks(e,t,n,s,r){let o=[],a=e.name?e.name:e.uuid,c=[];function l(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}Li[r.path]===Li.weights?(l(e),e.isGroup&&e.children.forEach(l)):c.push(a);let h;switch(Li[r.path]){case Li.weights:h=hi;break;case Li.rotation:h=ui;break;case Li.translation:case Li.scale:h=Ri;break;default:n.itemSize===1?h=hi:h=Ri;break}let u=s.interpolation!==void 0?fx[s.interpolation]:Vi,f=this._getArrayFromAccessor(n);for(let d=0,g=c.length;d<g;d++){let x=new h(c[d]+"."+Li[r.path],t.array,f,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),o.push(x)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=th(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let s=this instanceof ui?Qc:za;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function vx(i,e,t){let n=e.attributes,s=new nn;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(s.set(new O(c[0],c[1],c[2]),new O(l[0],l[1],l[2])),a.normalized){let h=th(ks[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=e.targets;if(r!==void 0){let a=new O,c=new O;for(let l=0,h=r.length;l<h;l++){let u=r[l];if(u.POSITION!==void 0){let f=t.json.accessors[u.POSITION],d=f.min,g=f.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),f.normalized){let x=th(ks[f.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}i.boundingBox=s;let o=new sn;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=o}function Vf(i,e,t){let n=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){i.setAttribute(a,c)})}for(let o in n){let a=eh[o]||o.toLowerCase();a in i.attributes||s.push(r(n[o],a))}if(e.indices!==void 0&&!i.index){let o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});s.push(o)}return tt.workingColorSpace!==$t&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${tt.workingColorSpace}" not supported.`),Yn(i,e),vx(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?px(i,e.targets,t):i})}var mn=Uint8Array,Gs=Uint16Array,yx=Int32Array,Wf=new mn([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]),Xf=new mn([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]),Mx=new mn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qf=function(i,e){for(var t=new Gs(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var s=new yx(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return{b:t,r:s}},Yf=qf(Wf,2),Zf=Yf.b,Sx=Yf.r;Zf[28]=258,Sx[258]=28;var Kf=qf(Xf,0),bx=Kf.b,QM=Kf.r,oh=new Gs(32768);for(dt=0;dt<32768;++dt)gi=(dt&43690)>>1|(dt&21845)<<1,gi=(gi&52428)>>2|(gi&13107)<<2,gi=(gi&61680)>>4|(gi&3855)<<4,oh[dt]=((gi&65280)>>8|(gi&255)<<8)>>1;var gi,dt,Or=(function(i,e,t){for(var n=i.length,s=0,r=new Gs(e);s<n;++s)i[s]&&++r[i[s]-1];var o=new Gs(e);for(s=1;s<e;++s)o[s]=o[s-1]+r[s-1]<<1;var a;if(t){a=new Gs(1<<e);var c=15-e;for(s=0;s<n;++s)if(i[s])for(var l=s<<4|i[s],h=e-i[s],u=o[i[s]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)a[oh[u]>>c]=l}else for(a=new Gs(n),s=0;s<n;++s)i[s]&&(a[s]=oh[o[i[s]-1]++]>>15-i[s]);return a}),Br=new mn(288);for(dt=0;dt<144;++dt)Br[dt]=8;var dt;for(dt=144;dt<256;++dt)Br[dt]=9;var dt;for(dt=256;dt<280;++dt)Br[dt]=7;var dt;for(dt=280;dt<288;++dt)Br[dt]=8;var dt,Jf=new mn(32);for(dt=0;dt<32;++dt)Jf[dt]=5;var dt;var Tx=Or(Br,9,1);var Ax=Or(Jf,5,1),ih=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},Dn=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},sh=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},wx=function(i){return(i+7)/8|0},lh=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new mn(i.subarray(e,t))};var Ex=["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"],pn=function(i,e,t){var n=new Error(e||Ex[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,pn),!t)throw n;return n},Rx=function(i,e,t,n){var s=i.length,r=n?n.length:0;if(!s||e.f&&!e.l)return t||new mn(0);var o=!t,a=o||e.i!=2,c=e.i;o&&(t=new mn(s*3));var l=function(k){var J=t.length;if(k>J){var H=new mn(Math.max(J*2,k));H.set(t),t=H}},h=e.f||0,u=e.p||0,f=e.b||0,d=e.l,g=e.d,x=e.m,m=e.n,p=s*8;do{if(!d){h=Dn(i,u,1);var M=Dn(i,u+1,3);if(u+=3,M)if(M==1)d=Tx,g=Ax,x=9,m=5;else if(M==2){var T=Dn(i,u,31)+257,_=Dn(i,u+10,15)+4,b=T+Dn(i,u+5,31)+1;u+=14;for(var F=new mn(b),P=new mn(19),L=0;L<_;++L)P[Mx[L]]=Dn(i,u+L*3,7);u+=_*3;for(var B=ih(P),K=(1<<B)-1,C=Or(P,B,1),L=0;L<b;){var q=C[Dn(i,u,K)];u+=q&15;var A=q>>4;if(A<16)F[L++]=A;else{var X=0,W=0;for(A==16?(W=3+Dn(i,u,3),u+=2,X=F[L-1]):A==17?(W=3+Dn(i,u,7),u+=3):A==18&&(W=11+Dn(i,u,127),u+=7);W--;)F[L++]=X}}var ae=F.subarray(0,T),Y=F.subarray(T);x=ih(ae),m=ih(Y),d=Or(ae,x,1),g=Or(Y,m,1)}else pn(1);else{var A=wx(u)+4,S=i[A-4]|i[A-3]<<8,E=A+S;if(E>s){c&&pn(0);break}a&&l(f+S),t.set(i.subarray(A,E),f),e.b=f+=S,e.p=u=E*8,e.f=h;continue}if(u>p){c&&pn(0);break}}a&&l(f+131072);for(var oe=(1<<x)-1,le=(1<<m)-1,Ie=u;;Ie=u){var X=d[sh(i,u)&oe],He=X>>4;if(u+=X&15,u>p){c&&pn(0);break}if(X||pn(2),He<256)t[f++]=He;else if(He==256){Ie=u,d=null;break}else{var ee=He-254;if(He>264){var L=He-257,ye=Wf[L];ee=Dn(i,u,(1<<ye)-1)+Zf[L],u+=ye}var Ce=g[sh(i,u)&le],ke=Ce>>4;Ce||pn(3),u+=Ce&15;var Y=bx[ke];if(ke>3){var ye=Xf[ke];Y+=sh(i,u)&(1<<ye)-1,u+=ye}if(u>p){c&&pn(0);break}a&&l(f+131072);var I=f+ee;if(f<Y){var D=r-Y,j=Math.min(Y,I);for(D+f<0&&pn(3);f<j;++f)t[f]=n[D+f]}for(;f<I;++f)t[f]=t[f-Y]}}e.l=d,e.p=Ie,e.b=f,e.f=h,d&&(h=1,e.m=x,e.d=g,e.n=m)}while(!h);return f!=t.length&&o?lh(t,0,f):t.subarray(0,f)};var Cx=new mn(0);var Zn=function(i,e){return i[e]|i[e+1]<<8},bn=function(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24)>>>0},rh=function(i,e){return bn(i,e)+bn(i,e+4)*4294967296};function Ix(i,e){return Rx(i,{i:2},e&&e.out,e&&e.dictionary)}var ah=typeof TextDecoder<"u"&&new TextDecoder,Px=0;try{ah.decode(Cx,{stream:!0}),Px=1}catch{}var Lx=function(i){for(var e="",t=0;;){var n=i[t++],s=(n>127)+(n>223)+(n>239);if(t+s>i.length)return{s:e,r:lh(i,t-1)};s?s==3?(n=((n&15)<<18|(i[t++]&63)<<12|(i[t++]&63)<<6|i[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?e+=String.fromCharCode((n&31)<<6|i[t++]&63):e+=String.fromCharCode((n&15)<<12|(i[t++]&63)<<6|i[t++]&63):e+=String.fromCharCode(n)}};function Dx(i,e){if(e){for(var t="",n=0;n<i.length;n+=16384)t+=String.fromCharCode.apply(null,i.subarray(n,n+16384));return t}else{if(ah)return ah.decode(i);var s=Lx(i),r=s.s,t=s.r;return t.length&&pn(8),r}}var Nx=function(i,e){return e+30+Zn(i,e+26)+Zn(i,e+28)},Ux=function(i,e,t){var n=Zn(i,e+28),s=Zn(i,e+30),r=Dx(i.subarray(e+46,e+46+n),!(Zn(i,e+8)&2048)),o=e+46+n,a=Fx(i,o,s,t,bn(i,e+20),bn(i,e+24),bn(i,e+42)),c=a[0],l=a[1],h=a[2];return[Zn(i,e+10),c,l,r,o+s+Zn(i,e+32),h]},Fx=function(i,e,t,n,s,r,o){var a=s==4294967295,c=r==4294967295,l=o==4294967295,h=e+t,u=a+c+l;if(n&&u){for(;e+4<h;e+=4+Zn(i,e+2))if(Zn(i,e)==1)return[a?rh(i,e+4+8*c):s,c?rh(i,e+4):r,l?rh(i,e+4+8*(c+a)):o,1];n<2&&pn(13)}return[s,r,o,0]};function jf(i,e){for(var t={},n=i.length-22;bn(i,n)!=101010256;--n)(!n||i.length-n>65558)&&pn(13);var s=Zn(i,n+8);if(!s)return{};var r=bn(i,n+16),o=bn(i,n-20)==117853008;if(o){var a=bn(i,n-12);o=bn(i,a)==101075792,o&&(s=bn(i,a+32),r=bn(i,a+48))}for(var c=e&&e.filter,l=0;l<s;++l){var h=Ux(i,r,o),u=h[0],f=h[1],d=h[2],g=h[3],x=h[4],m=h[5],p=Nx(i,m);r=x,(!c||c({name:g,size:f,originalSize:d,compression:u}))&&(u?u==8?t[g]=Ix(i.subarray(p,p+f),{out:new mn(d)}):pn(14,"unknown compression type "+u):t[g]=lh(i,p,p+f))}return t}var ch=Mt,$f="http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02",hh="http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07",uh=class extends Vt{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,s){let r=this,o=new xn(r.manager);o.setPriority(r.priority),o.setCache(r.cache),o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){s?s(c):console.error(c),r.manager.itemError(e)}},n,s)}parse(e){let t=this,n=new Xi(this.manager);n.setPriority(this.priority),n.setCache(this.cache);function s(I){let D=null,j=null,k,J,H=[],$=[],ce,re={},he={},we={},de=new TextDecoder;try{D=jf(new Uint8Array(I))}catch(N){if(N instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}let Ye=null;for(j in D)j.match(/\_rels\/.rels$/)?k=j:j.match(/3D\/_rels\/.*\.model\.rels$/)?J=j:j.match(/^3D\/[^\/]*\.model$/)?Ye=j:j.match(/^3D\/.*\/[^\/]*\.model$/)?H.push(j):j.match(/^3D\/Textures?\/.*/)&&$.push(j);if(H.push(Ye),k===void 0)throw new Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let je=D[k],at=de.decode(je),ct=r(at);if(J){let N=D[J],Ee=de.decode(N);ce=r(Ee)}for(let N=0;N<H.length;N++){let Ee=H[N],Pe=D[Ee],Xe=de.decode(Pe),me=new DOMParser().parseFromString(Xe,"application/xml");me.documentElement.nodeName.toLowerCase()!=="model"&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",Ee);let ht=me.querySelector("model"),Ue={};for(let w=0;w<ht.attributes.length;w++){let v=ht.attributes[w];v.name.match(/^xmlns:(.+)$/)&&(Ue[v.value]=RegExp.$1)}let Oe=_(ht);Oe.xml=ht,0<Object.keys(Ue).length&&(Oe.extensions=Ue),re[Ee]=Oe}for(let N=0;N<$.length;N++){let Ee=$[N];we[Ee]=D[Ee].buffer}return{rels:ct,modelRels:ce,model:re,printTicket:he,texture:we}}function r(I){let D=[],k=new DOMParser().parseFromString(I,"application/xml").querySelectorAll("Relationship");for(let J=0;J<k.length;J++){let H=k[J],$={target:H.getAttribute("Target"),id:H.getAttribute("Id"),type:H.getAttribute("Type")};D.push($)}return D}function o(I){let D={};for(let j=0;j<I.length;j++){let k=I[j],J=k.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(J)&&(D[J]=k.textContent)}return D}function a(I){let D={id:I.getAttribute("id"),basematerials:[]},j=I.querySelectorAll("base");for(let k=0;k<j.length;k++){let J=j[k],H=g(J);H.index=k,D.basematerials.push(H)}return D}function c(I){return{id:I.getAttribute("id"),path:I.getAttribute("path"),contenttype:I.getAttribute("contenttype"),tilestyleu:I.getAttribute("tilestyleu"),tilestylev:I.getAttribute("tilestylev"),filter:I.getAttribute("filter")}}function l(I){let D={id:I.getAttribute("id"),texid:I.getAttribute("texid"),displaypropertiesid:I.getAttribute("displaypropertiesid")},j=I.querySelectorAll("tex2coord"),k=[];for(let J=0;J<j.length;J++){let H=j[J],$=H.getAttribute("u"),ce=H.getAttribute("v");k.push(parseFloat($),parseFloat(ce))}return D.uvs=new Float32Array(k),D}function h(I){let D={id:I.getAttribute("id"),displaypropertiesid:I.getAttribute("displaypropertiesid")},j=I.querySelectorAll("color"),k=[],J=new Be;for(let H=0;H<j.length;H++){let ce=j[H].getAttribute("color");J.setStyle(ce.substring(0,7),ch),k.push(J.r,J.g,J.b)}return D.colors=new Float32Array(k),D}function u(I){let D=I.children,j={};for(let k=0;k<D.length;k++){let J={type:D[k].nodeName.substring(2)};for(let H=0;H<D[k].attributes.length;H++){let $=D[k].attributes[H];$.specified&&(J[$.name]=$.value)}j[D[k].getAttribute("identifier")]=J}return j}function f(I){let D={id:I.getAttribute("id"),displayname:I.getAttribute("displayname")},j=I.children,k={};for(let J=0;J<j.length;J++){let H=j[J];if(H.nodeName==="i:in"||H.nodeName==="i:out")k[H.nodeName==="i:in"?"inputs":"outputs"]=u(H);else{let $=H.children,ce={op:H.nodeName.substring(2),identifier:H.getAttribute("identifier")};for(let re=0;re<$.length;re++)ce[$[re].nodeName.substring(2)]=u($[re]);k[ce.identifier]=ce}}return D.operations=k,D}function d(I){let D={id:I.getAttribute("id")},j=I.querySelectorAll("pbmetallic"),k=[];for(let J=0;J<j.length;J++){let H=j[J];k.push({name:H.getAttribute("name"),metallicness:parseFloat(H.getAttribute("metallicness")),roughness:parseFloat(H.getAttribute("roughness"))})}return D.data=k,D}function g(I){let D={};return D.name=I.getAttribute("name"),D.displaycolor=I.getAttribute("displaycolor"),D.displaypropertiesid=I.getAttribute("displaypropertiesid"),D}function x(I){let D={},j=[],k=I.querySelectorAll("vertices vertex");for(let re=0;re<k.length;re++){let he=k[re],we=he.getAttribute("x"),de=he.getAttribute("y"),Ye=he.getAttribute("z");j.push(parseFloat(we),parseFloat(de),parseFloat(Ye))}D.vertices=new Float32Array(j);let J=[],H=[],$=I.querySelectorAll("triangles triangle");for(let re=0;re<$.length;re++){let he=$[re],we=he.getAttribute("v1"),de=he.getAttribute("v2"),Ye=he.getAttribute("v3"),je=he.getAttribute("p1"),at=he.getAttribute("p2"),ct=he.getAttribute("p3"),N=he.getAttribute("pid"),Ee={};Ee.v1=parseInt(we,10),Ee.v2=parseInt(de,10),Ee.v3=parseInt(Ye,10),H.push(Ee.v1,Ee.v2,Ee.v3),je&&(Ee.p1=parseInt(je,10)),at&&(Ee.p2=parseInt(at,10)),ct&&(Ee.p3=parseInt(ct,10)),N&&(Ee.pid=N),0<Object.keys(Ee).length&&J.push(Ee)}D.triangleProperties=J,D.triangles=new Uint32Array(H);let ce=I.getElementsByTagNameNS($f,"beamlattice")[0];return ce!==void 0&&(D.beamlattice=m(ce)),D}function m(I){let D={radius:parseFloat(I.getAttribute("radius")),minLength:parseFloat(I.getAttribute("minlength")),cap:I.getAttribute("cap")||"sphere",ballMode:I.getAttributeNS(hh,"ballmode")||"none",ballRadius:parseFloat(I.getAttributeNS(hh,"ballradius")),beams:[],balls:[]},j=I.getAttribute("clippingmode")||I.getAttribute("clipping");j!==null&&j!=="none"&&console.warn("THREE.3MFLoader: Beam lattice clipping is not supported. The lattice is rendered unclipped.");let k=I.getElementsByTagNameNS($f,"beam");for(let H=0;H<k.length;H++){let $=k[H],ce={v1:parseInt($.getAttribute("v1"),10),v2:parseInt($.getAttribute("v2"),10)},re=$.getAttribute("r1"),he=$.getAttribute("r2");re!==null&&(ce.r1=parseFloat(re)),he!==null&&(ce.r2=parseFloat(he)),D.beams.push(ce)}let J=I.getElementsByTagNameNS(hh,"ball");for(let H=0;H<J.length;H++){let $=J[H],ce={vindex:parseInt($.getAttribute("vindex"),10)},re=$.getAttribute("r");re!==null&&(ce.r=parseFloat(re)),D.balls.push(ce)}return D}function p(I){let D=[],j=I.querySelectorAll("component");for(let k=0;k<j.length;k++){let J=j[k],H=M(J);D.push(H)}return D}function M(I){let D={};D.objectId=I.getAttribute("objectid");let j=I.getAttribute("transform");return j&&(D.transform=A(j)),D}function A(I){let D=[];I.split(" ").forEach(function(k){D.push(parseFloat(k))});let j=new Ze;return j.set(D[0],D[3],D[6],D[9],D[1],D[4],D[7],D[10],D[2],D[5],D[8],D[11],0,0,0,1),j}function S(I){let D={type:I.getAttribute("type")},j=I.getAttribute("id");j&&(D.id=j);let k=I.getAttribute("pid");k&&(D.pid=k);let J=I.getAttribute("pindex");J&&(D.pindex=J);let H=I.getAttribute("thumbnail");H&&(D.thumbnail=H);let $=I.getAttribute("partnumber");$&&(D.partnumber=$);let ce=I.getAttribute("name");ce&&(D.name=ce);let re=I.querySelector("mesh");re&&(D.mesh=x(re));let he=I.querySelector("components");return he&&(D.components=p(he)),D}function E(I){let D={};D.basematerials={};let j=I.querySelectorAll("basematerials");for(let he=0;he<j.length;he++){let we=j[he],de=a(we);D.basematerials[de.id]=de}D.texture2d={};let k=I.querySelectorAll("texture2d");for(let he=0;he<k.length;he++){let we=k[he],de=c(we);D.texture2d[de.id]=de}D.colorgroup={};let J=I.querySelectorAll("colorgroup");for(let he=0;he<J.length;he++){let we=J[he],de=h(we);D.colorgroup[de.id]=de}let H=I.querySelectorAll("implicitfunction");H.length>0&&(D.implicitfunction={});for(let he=0;he<H.length;he++){let we=H[he],de=f(we);D.implicitfunction[de.id]=de}D.pbmetallicdisplayproperties={};let $=I.querySelectorAll("pbmetallicdisplayproperties");for(let he=0;he<$.length;he++){let we=$[he],de=d(we);D.pbmetallicdisplayproperties[de.id]=de}D.texture2dgroup={};let ce=I.querySelectorAll("texture2dgroup");for(let he=0;he<ce.length;he++){let we=ce[he],de=l(we);D.texture2dgroup[de.id]=de}D.object={};let re=I.querySelectorAll("object");for(let he=0;he<re.length;he++){let we=re[he],de=S(we);D.object[de.id]=de}return D}function T(I){let D=[],j=I.querySelectorAll("item");for(let k=0;k<j.length;k++){let J=j[k],H={objectId:J.getAttribute("objectid")},$=J.getAttribute("transform");$&&(H.transform=A($)),D.push(H)}return D}function _(I){let D={unit:I.getAttribute("unit")||"millimeter"},j=I.querySelectorAll("metadata");j&&(D.metadata=o(j));let k=I.querySelector("resources");k&&(D.resources=E(k));let J=I.querySelector("build");return J&&(D.build=T(J)),D}function b(I,D,j,k){let J=I.texid,$=j.resources.texture2d[J];if($){let ce=k[$.path],re=$.contenttype,he=new Blob([ce],{type:re}),we=URL.createObjectURL(he),de=n.load(we,function(){URL.revokeObjectURL(we)});switch(de.colorSpace=ch,$.tilestyleu){case"wrap":de.wrapS=un;break;case"mirror":de.wrapS=ii;break;case"none":case"clamp":de.wrapS=jt;break;default:de.wrapS=un}switch($.tilestylev){case"wrap":de.wrapT=un;break;case"mirror":de.wrapT=ii;break;case"none":case"clamp":de.wrapT=jt;break;default:de.wrapT=un}switch($.filter){case"auto":de.magFilter=At,de.minFilter=tn;break;case"linear":de.magFilter=At,de.minFilter=At,de.generateMipmaps=!1;break;case"nearest":de.magFilter=Tt,de.minFilter=Tt,de.generateMipmaps=!1;break;default:de.magFilter=At,de.minFilter=tn}return de}else return null}function F(I,D,j,k,J,H,$){let ce=$.pindex,re={};for(let de=0,Ye=D.length;de<Ye;de++){let je=D[de],at=je.p1!==void 0?je.p1:ce;re[at]===void 0&&(re[at]=[]),re[at].push(je)}let he=Object.keys(re),we=[];for(let de=0,Ye=he.length;de<Ye;de++){let je=he[de],at=re[je],ct=I.basematerials[je],N=Y(ct,k,J,H,$,oe),Ee=new _t,Pe=[],Xe=j.vertices;for(let ht=0,Ue=at.length;ht<Ue;ht++){let Oe=at[ht];Pe.push(Xe[Oe.v1*3+0]),Pe.push(Xe[Oe.v1*3+1]),Pe.push(Xe[Oe.v1*3+2]),Pe.push(Xe[Oe.v2*3+0]),Pe.push(Xe[Oe.v2*3+1]),Pe.push(Xe[Oe.v2*3+2]),Pe.push(Xe[Oe.v3*3+0]),Pe.push(Xe[Oe.v3*3+1]),Pe.push(Xe[Oe.v3*3+2])}Ee.setAttribute("position",new st(Pe,3));let me=new bt(Ee,N);we.push(me)}return we}function P(I,D,j,k,J,H,$){let ce=new _t,re=[],he=[],we=j.vertices,de=I.uvs;for(let ct=0,N=D.length;ct<N;ct++){let Ee=D[ct];re.push(we[Ee.v1*3+0]),re.push(we[Ee.v1*3+1]),re.push(we[Ee.v1*3+2]),re.push(we[Ee.v2*3+0]),re.push(we[Ee.v2*3+1]),re.push(we[Ee.v2*3+2]),re.push(we[Ee.v3*3+0]),re.push(we[Ee.v3*3+1]),re.push(we[Ee.v3*3+2]),he.push(de[Ee.p1*2+0]),he.push(de[Ee.p1*2+1]),he.push(de[Ee.p2*2+0]),he.push(de[Ee.p2*2+1]),he.push(de[Ee.p3*2+0]),he.push(de[Ee.p3*2+1])}ce.setAttribute("position",new st(re,3)),ce.setAttribute("uv",new st(he,2));let Ye=Y(I,k,J,H,$,b),je=new In({map:Ye,flatShading:!0});return new bt(ce,je)}function L(I,D,j,k){let J=new _t,H=[],$=[],ce=j.vertices,re=I.colors;for(let de=0,Ye=D.length;de<Ye;de++){let je=D[de],at=je.v1,ct=je.v2,N=je.v3;H.push(ce[at*3+0]),H.push(ce[at*3+1]),H.push(ce[at*3+2]),H.push(ce[ct*3+0]),H.push(ce[ct*3+1]),H.push(ce[ct*3+2]),H.push(ce[N*3+0]),H.push(ce[N*3+1]),H.push(ce[N*3+2]);let Ee=je.p1!==void 0?je.p1:k.pindex,Pe=je.p2!==void 0?je.p2:Ee,Xe=je.p3!==void 0?je.p3:Ee;$.push(re[Ee*3+0]),$.push(re[Ee*3+1]),$.push(re[Ee*3+2]),$.push(re[Pe*3+0]),$.push(re[Pe*3+1]),$.push(re[Pe*3+2]),$.push(re[Xe*3+0]),$.push(re[Xe*3+1]),$.push(re[Xe*3+2])}J.setAttribute("position",new st(H,3)),J.setAttribute("color",new st($,3));let he=new In({vertexColors:!0,flatShading:!0});return new bt(J,he)}function B(I){let D=new _t;D.setIndex(new St(I.triangles,1)),D.setAttribute("position",new St(I.vertices,3));let j=new In({name:Vt.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new bt(D,j)}function K(I){let D=I.beamlattice,j=I.vertices,k=[],J=new O,H=new O,$=new O,ce=new O(0,1,0),re=new zt,he=new Ze,we=D.beams,de=D.cap!=="butt",Ye=new Map;for(let Ee=0;Ee<we.length;Ee++){let Pe=we[Ee];J.fromArray(j,Pe.v1*3),H.fromArray(j,Pe.v2*3);let Xe=J.distanceTo(H);if(Xe<D.minLength)continue;let me=Pe.r1!==void 0?Pe.r1:D.radius,ht=Pe.r2!==void 0?Pe.r2:me,Ue=new dr(ht,me,Xe,8,1,de);$.subVectors(H,J).divideScalar(Xe),re.setFromUnitVectors(ce,$),he.makeRotationFromQuaternion(re),he.setPosition(J.add(H).multiplyScalar(.5)),Ue.applyMatrix4(he),k.push(Ue),de&&(Ye.set(Pe.v1,Math.max(me,Ye.get(Pe.v1)||0)),Ye.set(Pe.v2,Math.max(ht,Ye.get(Pe.v2)||0))),D.ballMode==="all"&&(Ye.set(Pe.v1,Math.max(D.ballRadius,Ye.get(Pe.v1)||0)),Ye.set(Pe.v2,Math.max(D.ballRadius,Ye.get(Pe.v2)||0)))}let je=D.balls;for(let Ee=0;Ee<je.length;Ee++){let Pe=je[Ee],Xe=Pe.r!==void 0?Pe.r:D.ballRadius;Ye.set(Pe.vindex,Math.max(Xe,Ye.get(Pe.vindex)||0))}for(let[Ee,Pe]of Ye){let Xe=new mr(Pe,8,6);J.fromArray(j,Ee*3),Xe.translate(J.x,J.y,J.z),k.push(Xe)}let at=Ff(k),ct=new In({name:Vt.DEFAULT_MATERIAL_NAME,color:16777215});return new bt(at,ct)}function C(I,D,j,k,J,H){let $=Object.keys(I),ce=[];for(let re=0,he=$.length;re<he;re++){let we=$[re],de=I[we];switch(q(we,k)){case"material":let je=k.resources.basematerials[we],at=F(je,de,D,j,k,J,H);for(let Ee=0,Pe=at.length;Ee<Pe;Ee++)ce.push(at[Ee]);break;case"texture":let ct=k.resources.texture2dgroup[we];ce.push(P(ct,de,D,j,k,J,H));break;case"vertexColors":let N=k.resources.colorgroup[we];ce.push(L(N,de,D,H));break;case"default":ce.push(B(D));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(H.name)for(let re=0;re<ce.length;re++)ce[re].name=H.name;return ce}function q(I,D){return D.resources.texture2dgroup[I]!==void 0?"texture":D.resources.basematerials[I]!==void 0?"material":D.resources.colorgroup[I]!==void 0?"vertexColors":I==="default"?"default":void 0}function X(I,D){let j={},k=I.triangleProperties,J=D.pid;for(let H=0,$=k.length;H<$;H++){let ce=k[H],re=ce.pid!==void 0?ce.pid:J;re===void 0&&(re="default"),j[re]===void 0&&(j[re]=[]),j[re].push(ce)}return j}function W(I,D,j,k,J){let H=new Bt,$=X(I,J),ce=C($,I,D,j,k,J);if(I.beamlattice!==void 0){let re=K(I);J.name&&(re.name=J.name),ce.push(re)}for(let re=0,he=ce.length;re<he;re++)H.add(ce[re]);return H}function ae(I,D,j){if(!I)return;let k=[],J=Object.keys(I);for(let H=0;H<J.length;H++){let $=J[H];for(let ce=0;ce<t.availableExtensions.length;ce++){let re=t.availableExtensions[ce];re.ns===$&&k.push(re)}}for(let H=0;H<k.length;H++){let $=k[H];$.apply(j,I[$.ns],D)}}function Y(I,D,j,k,J,H){return I.build!==void 0||(I.build=H(I,D,j,k,J)),I.build}function oe(I,D,j){let k,J=I.displaypropertiesid,H=j.resources.pbmetallicdisplayproperties;if(J!==null&&H[J]!==void 0){let he=H[J].data[I.index];k=new kn({flatShading:!0,roughness:he.roughness,metalness:he.metallicness})}else k=new In({flatShading:!0});k.name=I.name;let $=I.displaycolor,ce=$.substring(0,7);return k.color.setStyle(ce,ch),$.length===9&&(k.opacity=parseInt($.charAt(7)+$.charAt(8),16)/255),k}function le(I,D,j,k){let J=new Bt;for(let H=0;H<I.length;H++){let $=I[H],ce=D[$.objectId];ce===void 0&&(Ie($.objectId,D,j,k),ce=D[$.objectId]);let re=ce.clone(),he=$.transform;he&&re.applyMatrix4(he),J.add(re)}return J}function Ie(I,D,j,k){let J=j.resources.object[I];if(J.mesh){let H=J.mesh,$=j.extensions,ce=j.xml;ae($,H,ce),D[J.id]=Y(H,D,j,k,J,W)}else{let H=J.components;D[J.id]=Y(H,D,j,k,J,le)}J.name&&(D[J.id].name=J.name),j.resources.implicitfunction&&console.warn("THREE.ThreeMFLoader: Implicit Functions are implemented in data-only.",j.resources.implicitfunction)}function He(I){let D=I.model,j=I.modelRels,k={},J=Object.keys(D),H={};if(j)for(let $=0,ce=j.length;$<ce;$++){let re=j[$],he=re.target.substring(1);I.texture[he]&&(H[re.target]=I.texture[he])}for(let $=0;$<J.length;$++){let ce=J[$],re=D[ce],he=Object.keys(re.resources.object);for(let we=0;we<he.length;we++){let de=he[we];Ie(de,k,re,H)}}return k}function ee(I){for(let D=0;D<I.length;D++){let j=I[D];if(j.target.split(".").pop().toLowerCase()==="model")return j}}function ye(I,D){let j=new Bt,k=ee(D.rels),J=D.model[k.target.substring(1)].build;for(let H=0;H<J.length;H++){let $=J[H],ce=I[$.objectId].clone(),re=$.transform;re&&ce.applyMatrix4(re),j.add(ce)}return j}let Ce=s(e),ke=He(Ce);return ye(ke,Ce)}addExtension(e){this.availableExtensions.push(e)}};export{nn as Box3,Rs as DirectionalLight,Ic as GLTFLoader,Bt as Group,zo as HemisphereLight,bt as Mesh,kn as MeshStandardMaterial,Ac as OBJLoader,Mc as OrbitControls,Ot as PerspectiveCamera,Mt as SRGBColorSpace,bc as STLLoader,Ao as Scene,uh as ThreeMFLoader,O as Vector3,vc as WebGLRenderer}; | ||
| 4233 | /** | ||
| 4234 | * @license | ||
| 4235 | * Copyright 2010-2026 Three.js Authors | ||
| 4236 | * SPDX-License-Identifier: MIT | ||
| 4237 | */ | ||
| 4238 | /*! | ||
| 4239 | fflate - fast JavaScript compression/decompression | ||
| 4240 | <https://101arrowz.github.io/fflate> | ||
| 4241 | Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE | ||
| 4242 | version 0.8.3 | ||
| 4243 | */ | ||