@mappedin/react-sdk 6.0.1-beta.2 → 6.0.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3799 +0,0 @@
1
- import{a as u,j as sh}from"./chunk-HGQSHE2E.js";sh();var No="162",gv={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};var df=0,rh=1,ff=2;var Nd=1,pf=2,ln=3,Cn=0,Pe=1,un=2,An=0,wi=1,ah=2,oh=3,ch=4,mf=5,Xn=100,gf=101,_f=102,lh=103,hh=104,xf=200,vf=201,yf=202,Mf=203,Oa=204,Fa=205,Sf=206,bf=207,Ef=208,wf=209,Af=210,Tf=211,Rf=212,Cf=213,Pf=214,If=0,Lf=1,Uf=2,Js=3,Df=4,Nf=5,Of=6,Ff=7,Oo=0,Bf=1,zf=2,Tn=0,kf=1,Vf=2,Hf=3,Gf=4,Wf=5,Xf=6,qf=7,uh="attached",Yf="detached",Od=300,Ci=301,Pi=302,Ba=303,za=304,kr=306,ka=1e3,Ye=1001,Va=1002,ge=1003,dh=1004;var Vi=1005;var Ce=1006,Zr=1007;var Yn=1008;var Rn=1009,Zf=1010,Jf=1011,Fo=1012,Fd=1013,En=1014,ke=1015,ns=1016,Bd=1017,zd=1018,Jn=1020,$f=1021,Oe=1023,Kf=1024,Qf=1025,$n=1026,Ii=1027,kd=1028,Vd=1029,jf=1030,Hd=1031,Gd=1033,Jr=33776,$r=33777,Kr=33778,Qr=33779,fh=35840,ph=35841,mh=35842,gh=35843,Wd=36196,_h=37492,xh=37496,vh=37808,yh=37809,Mh=37810,Sh=37811,bh=37812,Eh=37813,wh=37814,Ah=37815,Th=37816,Rh=37817,Ch=37818,Ph=37819,Ih=37820,Lh=37821,jr=36492,Uh=36494,Dh=36495,tp=36283,Nh=36284,Oh=36285,Fh=36286;var $s=2300,Ks=2301,ta=2302,Bh=2400,zh=2401,kh=2402,ep=2500;var _v=0,xv=1,vv=2,np=3200,ip=3201,Bo=0,sp=1,bn="",Ke="srgb",Dn="srgb-linear",zo="display-p3",Vr="display-p3-linear",Qs="linear",jt="srgb",js="rec709",tr="p3";var ei=7680;var Vh=519,rp=512,ap=513,op=514,Xd=515,cp=516,lp=517,hp=518,up=519,Ha=35044;var Hh="300 es",Ga=1035,dn=2e3,er=2001,Xo=class Xo{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let i=this._listeners[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,t);t.target=null}}};u(Xo,"EventDispatcher");var Pn=Xo,xe=["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"],Gh=1234567,Ai=Math.PI/180,Li=180/Math.PI;function Ve(){let s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(xe[s&255]+xe[s>>8&255]+xe[s>>16&255]+xe[s>>24&255]+"-"+xe[t&255]+xe[t>>8&255]+"-"+xe[t>>16&15|64]+xe[t>>24&255]+"-"+xe[e&63|128]+xe[e>>8&255]+"-"+xe[e>>16&255]+xe[e>>24&255]+xe[n&255]+xe[n>>8&255]+xe[n>>16&255]+xe[n>>24&255]).toLowerCase()}u(Ve,"generateUUID");function pe(s,t,e){return Math.max(t,Math.min(e,s))}u(pe,"clamp");function ko(s,t){return(s%t+t)%t}u(ko,"euclideanModulo");function dp(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}u(dp,"mapLinear");function fp(s,t,e){return s!==t?(e-s)/(t-s):0}u(fp,"inverseLerp");function $i(s,t,e){return(1-e)*s+e*t}u($i,"lerp");function pp(s,t,e,n){return $i(s,t,1-Math.exp(-e*n))}u(pp,"damp");function mp(s,t=1){return t-Math.abs(ko(s,t*2)-t)}u(mp,"pingpong");function gp(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}u(gp,"smoothstep");function _p(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}u(_p,"smootherstep");function xp(s,t){return s+Math.floor(Math.random()*(t-s+1))}u(xp,"randInt");function vp(s,t){return s+Math.random()*(t-s)}u(vp,"randFloat");function yp(s){return s*(.5-Math.random())}u(yp,"randFloatSpread");function Mp(s){s!==void 0&&(Gh=s);let t=Gh+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}u(Mp,"seededRandom");function Sp(s){return s*Ai}u(Sp,"degToRad");function bp(s){return s*Li}u(bp,"radToDeg");function Wa(s){return(s&s-1)===0&&s!==0}u(Wa,"isPowerOfTwo");function Ep(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}u(Ep,"ceilPowerOfTwo");function nr(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}u(nr,"floorPowerOfTwo");function wp(s,t,e,n,i){let r=Math.cos,o=Math.sin,a=r(e/2),c=o(e/2),l=r((t+n)/2),h=o((t+n)/2),d=r((t-n)/2),f=o((t-n)/2),g=r((n-t)/2),_=o((n-t)/2);switch(i){case"XYX":s.set(a*h,c*d,c*f,a*l);break;case"YZY":s.set(c*f,a*h,c*d,a*l);break;case"ZXZ":s.set(c*d,c*f,a*h,a*l);break;case"XZX":s.set(a*h,c*_,c*g,a*l);break;case"YXY":s.set(c*g,a*h,c*_,a*l);break;case"ZYZ":s.set(c*_,c*g,a*h,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}u(wp,"setQuaternionFromProperEuler");function Ze(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}u(Ze,"denormalize");function Zt(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}u(Zt,"normalize");var yv={DEG2RAD:Ai,RAD2DEG:Li,generateUUID:Ve,clamp:pe,euclideanModulo:ko,mapLinear:dp,inverseLerp:fp,lerp:$i,damp:pp,pingpong:mp,smoothstep:gp,smootherstep:_p,randInt:xp,randFloat:vp,randFloatSpread:yp,seededRandom:Mp,degToRad:Sp,radToDeg:bp,isPowerOfTwo:Wa,ceilPowerOfTwo:Ep,floorPowerOfTwo:nr,setQuaternionFromProperEuler:wp,normalize:Zt,denormalize:Ze},wr=class wr{constructor(t=0,e=0){wr.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*i+t.x,this.y=r*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};u(wr,"Vector2");var at=wr,Ar=class Ar{constructor(t,e,n,i,r,o,a,c,l){Ar.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l)}set(t,e,n,i,r,o,a,c,l){let h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,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(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],d=n[7],f=n[2],g=n[5],_=n[8],v=i[0],m=i[3],p=i[6],w=i[1],x=i[4],b=i[7],L=i[2],C=i[5],R=i[8];return r[0]=o*v+a*w+c*L,r[3]=o*m+a*x+c*C,r[6]=o*p+a*b+c*R,r[1]=l*v+h*w+d*L,r[4]=l*m+h*x+d*C,r[7]=l*p+h*b+d*R,r[2]=f*v+g*w+_*L,r[5]=f*m+g*x+_*C,r[8]=f*p+g*b+_*R,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8];return e*o*h-e*a*l-n*r*h+n*a*c+i*r*l-i*o*c}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],d=h*o-a*l,f=a*c-h*r,g=l*r-o*c,_=e*d+n*f+i*g;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/_;return t[0]=d*v,t[1]=(i*l-h*n)*v,t[2]=(a*n-i*o)*v,t[3]=f*v,t[4]=(h*e-i*c)*v,t[5]=(i*r-a*e)*v,t[6]=g*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*r)*v,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,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+t,-i*l,i*c,-i*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ea.makeScale(t,e)),this}rotate(t){return this.premultiply(ea.makeRotation(-t)),this}translate(t,e){return this.premultiply(ea.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};u(Ar,"Matrix3");var kt=Ar,ea=new kt;function qd(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}u(qd,"arrayNeedsUint32");function is(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}u(is,"createElementNS");function Ap(){let s=is("canvas");return s.style.display="block",s}u(Ap,"createCanvasElement");var Wh={};function Yd(s){s in Wh||(Wh[s]=!0,console.warn(s))}u(Yd,"warnOnce");var Xh=new kt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),qh=new kt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ps={[Dn]:{transfer:Qs,primaries:js,toReference:s=>s,fromReference:s=>s},[Ke]:{transfer:jt,primaries:js,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[Vr]:{transfer:Qs,primaries:tr,toReference:s=>s.applyMatrix3(qh),fromReference:s=>s.applyMatrix3(Xh)},[zo]:{transfer:jt,primaries:tr,toReference:s=>s.convertSRGBToLinear().applyMatrix3(qh),fromReference:s=>s.applyMatrix3(Xh).convertLinearToSRGB()}},Tp=new Set([Dn,Vr]),Jt={enabled:!0,_workingColorSpace:Dn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!Tp.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,t,e){if(this.enabled===!1||t===e||!t||!e)return s;let n=ps[t].toReference,i=ps[e].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,t){return this.convert(s,this._workingColorSpace,t)},toWorkingColorSpace:function(s,t){return this.convert(s,t,this._workingColorSpace)},getPrimaries:function(s){return ps[s].primaries},getTransfer:function(s){return s===bn?Qs:ps[s].transfer}};function Ti(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}u(Ti,"SRGBToLinear");function na(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}u(na,"LinearToSRGB");var ni,qo=class qo{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ni===void 0&&(ni=is("canvas")),ni.width=t.width,ni.height=t.height;let n=ni.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=ni}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=is("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=Ti(r[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ti(e[n]/255)*255):e[n]=Ti(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}};u(qo,"ImageUtils");var ir=qo,Rp=0,Yo=class Yo{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Rp++}),this.uuid=Ve(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(ia(i[o].image)):r.push(ia(i[o]))}else r=ia(i);n.url=r}return e||(t.images[this.uuid]=n),n}};u(Yo,"Source");var sr=Yo;function ia(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?ir.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}u(ia,"serializeImage");var Cp=0,bi=class bi extends Pn{constructor(t=bi.DEFAULT_IMAGE,e=bi.DEFAULT_MAPPING,n=Ye,i=Ye,r=Ce,o=Yn,a=Oe,c=Rn,l=bi.DEFAULT_ANISOTROPY,h=bn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Cp++}),this.uuid=Ve(),this.name="",this.source=new sr(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new at(0,0),this.repeat=new at(1,1),this.center=new at(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Od)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ka:t.x=t.x-Math.floor(t.x);break;case Ye:t.x=t.x<0?0:1;break;case Va:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ka:t.y=t.y-Math.floor(t.y);break;case Ye:t.y=t.y<0?0:1;break;case Va:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}};u(bi,"Texture");var be=bi;be.DEFAULT_IMAGE=null;be.DEFAULT_MAPPING=Od;be.DEFAULT_ANISOTROPY=1;var Tr=class Tr{constructor(t=0,e=0,n=0,i=1){Tr.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r,c=t.elements,l=c[0],h=c[4],d=c[8],f=c[1],g=c[5],_=c[9],v=c[2],m=c[6],p=c[10];if(Math.abs(h-f)<.01&&Math.abs(d-v)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+f)<.1&&Math.abs(d+v)<.1&&Math.abs(_+m)<.1&&Math.abs(l+g+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let x=(l+1)/2,b=(g+1)/2,L=(p+1)/2,C=(h+f)/4,R=(d+v)/4,D=(_+m)/4;return x>b&&x>L?x<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(x),i=C/n,r=R/n):b>L?b<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(b),n=C/i,r=D/i):L<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(L),n=R/r,i=D/r),this.set(n,i,r,e),this}let w=Math.sqrt((m-_)*(m-_)+(d-v)*(d-v)+(f-h)*(f-h));return Math.abs(w)<.001&&(w=1),this.x=(m-_)/w,this.y=(d-v)/w,this.z=(f-h)/w,this.w=Math.acos((l+g+p-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};u(Tr,"Vector4");var $t=Tr,Zo=class Zo extends Pn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new $t(0,0,t,e),this.scissorTest=!1,this.viewport=new $t(0,0,t,e);let i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ce,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},n);let r=new be(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,i=t.textures.length;n<i;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new sr(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};u(Zo,"RenderTarget");var Xa=Zo,Jo=class Jo extends Xa{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}};u(Jo,"WebGLRenderTarget");var fn=Jo,$o=class $o extends be{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ge,this.minFilter=ge,this.wrapR=Ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};u($o,"DataArrayTexture");var rr=$o;var Ko=class Ko extends be{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ge,this.minFilter=ge,this.wrapR=Ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};u(Ko,"Data3DTexture");var qa=Ko;var Qo=class Qo{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,o,a){let c=n[i+0],l=n[i+1],h=n[i+2],d=n[i+3],f=r[o+0],g=r[o+1],_=r[o+2],v=r[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d;return}if(a===1){t[e+0]=f,t[e+1]=g,t[e+2]=_,t[e+3]=v;return}if(d!==v||c!==f||l!==g||h!==_){let m=1-a,p=c*f+l*g+h*_+d*v,w=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){let L=Math.sqrt(x),C=Math.atan2(L,p*w);m=Math.sin(m*C)/L,a=Math.sin(a*C)/L}let b=a*w;if(c=c*m+f*b,l=l*m+g*b,h=h*m+_*b,d=d*m+v*b,m===1-a){let L=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=L,l*=L,h*=L,d*=L}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,i,r,o){let a=n[i],c=n[i+1],l=n[i+2],h=n[i+3],d=r[o],f=r[o+1],g=r[o+2],_=r[o+3];return t[e]=a*_+h*d+c*g-l*f,t[e+1]=c*_+h*f+l*d-a*g,t[e+2]=l*_+h*g+a*f-c*d,t[e+3]=h*_-a*d-c*f-l*g,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,i=t._y,r=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(i/2),d=a(r/2),f=c(n/2),g=c(i/2),_=c(r/2);switch(o){case"XYZ":this._x=f*h*d+l*g*_,this._y=l*g*d-f*h*_,this._z=l*h*_+f*g*d,this._w=l*h*d-f*g*_;break;case"YXZ":this._x=f*h*d+l*g*_,this._y=l*g*d-f*h*_,this._z=l*h*_-f*g*d,this._w=l*h*d+f*g*_;break;case"ZXY":this._x=f*h*d-l*g*_,this._y=l*g*d+f*h*_,this._z=l*h*_+f*g*d,this._w=l*h*d-f*g*_;break;case"ZYX":this._x=f*h*d-l*g*_,this._y=l*g*d+f*h*_,this._z=l*h*_-f*g*d,this._w=l*h*d+f*g*_;break;case"YZX":this._x=f*h*d+l*g*_,this._y=l*g*d+f*h*_,this._z=l*h*_-f*g*d,this._w=l*h*d-f*g*_;break;case"XZY":this._x=f*h*d-l*g*_,this._y=l*g*d-f*h*_,this._z=l*h*_+f*g*d,this._w=l*h*d+f*g*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],o=e[1],a=e[5],c=e[9],l=e[2],h=e[6],d=e[10],f=n+a+d;if(f>0){let g=.5/Math.sqrt(f+1);this._w=.25/g,this._x=(h-c)*g,this._y=(r-l)*g,this._z=(o-i)*g}else if(n>a&&n>d){let g=2*Math.sqrt(1+n-a-d);this._w=(h-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(r+l)/g}else if(a>d){let g=2*Math.sqrt(1+a-n-d);this._w=(r-l)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+h)/g}else{let g=2*Math.sqrt(1+d-n-a);this._w=(o-i)/g,this._x=(r+l)/g,this._y=(c+h)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(pe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,i=t._y,r=t._z,o=t._w,a=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+o*a+i*l-r*c,this._y=i*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-i*a,this._w=o*h-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,i=this._y,r=this._z,o=this._w,a=o*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;let c=1-a*a;if(c<=Number.EPSILON){let g=1-e;return this._w=g*o+e*this._w,this._x=g*n+e*this._x,this._y=g*i+e*this._y,this._z=g*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),h=Math.atan2(l,a),d=Math.sin((1-e)*h)/l,f=Math.sin(e*h)/l;return this._w=o*d+this._w*f,this._x=n*d+this._x*f,this._y=i*d+this._y*f,this._z=r*d+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};u(Qo,"Quaternion");var In=Qo,Rr=class Rr{constructor(t=0,e=0,n=0){Rr.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Yh.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Yh.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*i-a*n),h=2*(a*e-r*i),d=2*(r*n-o*e);return this.x=e+c*l+o*d-a*h,this.y=n+c*h+a*l-r*d,this.z=i+c*d+r*h-o*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,r=t.z,o=e.x,a=e.y,c=e.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return sa.copy(this).projectOnVector(t),this.sub(sa)}reflect(t){return this.sub(sa.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};u(Rr,"Vector3");var P=Rr,sa=new P,Yh=new In,jo=class jo{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(We.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(We.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=We.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,We):We.fromBufferAttribute(r,o),We.applyMatrix4(t.matrixWorld),this.expandByPoint(We);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ms.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ms.copy(n.boundingBox)),ms.applyMatrix4(t.matrixWorld),this.union(ms)}let i=t.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,We),We.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Hi),gs.subVectors(this.max,Hi),ii.subVectors(t.a,Hi),si.subVectors(t.b,Hi),ri.subVectors(t.c,Hi),pn.subVectors(si,ii),mn.subVectors(ri,si),Fn.subVectors(ii,ri);let e=[0,-pn.z,pn.y,0,-mn.z,mn.y,0,-Fn.z,Fn.y,pn.z,0,-pn.x,mn.z,0,-mn.x,Fn.z,0,-Fn.x,-pn.y,pn.x,0,-mn.y,mn.x,0,-Fn.y,Fn.x,0];return!ra(e,ii,si,ri,gs)||(e=[1,0,0,0,1,0,0,0,1],!ra(e,ii,si,ri,gs))?!1:(_s.crossVectors(pn,mn),e=[_s.x,_s.y,_s.z],ra(e,ii,si,ri,gs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,We).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(We).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(nn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),nn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),nn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),nn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),nn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),nn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),nn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),nn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(nn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};u(jo,"Box3");var Ie=jo,nn=[new P,new P,new P,new P,new P,new P,new P,new P],We=new P,ms=new Ie,ii=new P,si=new P,ri=new P,pn=new P,mn=new P,Fn=new P,Hi=new P,gs=new P,_s=new P,Bn=new P;function ra(s,t,e,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Bn.fromArray(s,r);let a=i.x*Math.abs(Bn.x)+i.y*Math.abs(Bn.y)+i.z*Math.abs(Bn.z),c=t.dot(Bn),l=e.dot(Bn),h=n.dot(Bn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}u(ra,"satForAxes");var Pp=new Ie,Gi=new P,aa=new P,tc=class tc{constructor(t=new P,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):Pp.setFromPoints(t).getCenter(n);let i=0;for(let r=0,o=t.length;r<o;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Gi.subVectors(t,this.center);let e=Gi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Gi,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(aa.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gi.copy(t.center).add(aa)),this.expandByPoint(Gi.copy(t.center).sub(aa))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}};u(tc,"Sphere");var Re=tc,sn=new P,oa=new P,xs=new P,gn=new P,ca=new P,vs=new P,la=new P,ec=class ec{constructor(t=new P,e=new P(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,sn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=sn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(sn.copy(this.origin).addScaledVector(this.direction,e),sn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){oa.copy(t).add(e).multiplyScalar(.5),xs.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(oa);let r=t.distanceTo(e)*.5,o=-this.direction.dot(xs),a=gn.dot(this.direction),c=-gn.dot(xs),l=gn.lengthSq(),h=Math.abs(1-o*o),d,f,g,_;if(h>0)if(d=o*c-a,f=o*a-c,_=r*h,d>=0)if(f>=-_)if(f<=_){let v=1/h;d*=v,f*=v,g=d*(d+o*f+2*a)+f*(o*d+f+2*c)+l}else f=r,d=Math.max(0,-(o*f+a)),g=-d*d+f*(f+2*c)+l;else f=-r,d=Math.max(0,-(o*f+a)),g=-d*d+f*(f+2*c)+l;else f<=-_?(d=Math.max(0,-(-o*r+a)),f=d>0?-r:Math.min(Math.max(-r,-c),r),g=-d*d+f*(f+2*c)+l):f<=_?(d=0,f=Math.min(Math.max(-r,-c),r),g=f*(f+2*c)+l):(d=Math.max(0,-(o*r+a)),f=d>0?r:Math.min(Math.max(-r,-c),r),g=-d*d+f*(f+2*c)+l);else f=o>0?-r:r,d=Math.max(0,-(o*f+a)),g=-d*d+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(oa).addScaledVector(xs,f),g}intersectSphere(t,e){sn.subVectors(t.center,this.origin);let n=sn.dot(this.direction),i=sn.dot(sn)-n*n,r=t.radius*t.radius;if(i>r)return null;let o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,o,a,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,i=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,i=(t.min.x-f.x)*l),h>=0?(r=(t.min.y-f.y)*h,o=(t.max.y-f.y)*h):(r=(t.max.y-f.y)*h,o=(t.min.y-f.y)*h),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),d>=0?(a=(t.min.z-f.z)*d,c=(t.max.z-f.z)*d):(a=(t.max.z-f.z)*d,c=(t.min.z-f.z)*d),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,sn)!==null}intersectTriangle(t,e,n,i,r){ca.subVectors(e,t),vs.subVectors(n,t),la.crossVectors(ca,vs);let o=this.direction.dot(la),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;gn.subVectors(this.origin,t);let c=a*this.direction.dot(vs.crossVectors(gn,vs));if(c<0)return null;let l=a*this.direction.dot(ca.cross(gn));if(l<0||c+l>o)return null;let h=-a*gn.dot(la);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}};u(ec,"Ray");var Kn=ec,es=class es{constructor(t,e,n,i,r,o,a,c,l,h,d,f,g,_,v,m){es.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l,h,d,f,g,_,v,m)}set(t,e,n,i,r,o,a,c,l,h,d,f,g,_,v,m){let p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=r,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=h,p[10]=d,p[14]=f,p[3]=g,p[7]=_,p[11]=v,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 es().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/ai.setFromMatrixColumn(t,0).length(),r=1/ai.setFromMatrixColumn(t,1).length(),o=1/ai.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let f=o*h,g=o*d,_=a*h,v=a*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=g+_*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=_+g*l,e[10]=o*c}else if(t.order==="YXZ"){let f=c*h,g=c*d,_=l*h,v=l*d;e[0]=f+v*a,e[4]=_*a-g,e[8]=o*l,e[1]=o*d,e[5]=o*h,e[9]=-a,e[2]=g*a-_,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){let f=c*h,g=c*d,_=l*h,v=l*d;e[0]=f-v*a,e[4]=-o*d,e[8]=_+g*a,e[1]=g+_*a,e[5]=o*h,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){let f=o*h,g=o*d,_=a*h,v=a*d;e[0]=c*h,e[4]=_*l-g,e[8]=f*l+v,e[1]=c*d,e[5]=v*l+f,e[9]=g*l-_,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){let f=o*c,g=o*l,_=a*c,v=a*l;e[0]=c*h,e[4]=v-f*d,e[8]=_*d+g,e[1]=d,e[5]=o*h,e[9]=-a*h,e[2]=-l*h,e[6]=g*d+_,e[10]=f-v*d}else if(t.order==="XZY"){let f=o*c,g=o*l,_=a*c,v=a*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=f*d+v,e[5]=o*h,e[9]=g*d-_,e[2]=_*d-g,e[6]=a*h,e[10]=v*d+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ip,t,Lp)}lookAt(t,e,n){let i=this.elements;return De.subVectors(t,e),De.lengthSq()===0&&(De.z=1),De.normalize(),_n.crossVectors(n,De),_n.lengthSq()===0&&(Math.abs(n.z)===1?De.x+=1e-4:De.z+=1e-4,De.normalize(),_n.crossVectors(n,De)),_n.normalize(),ys.crossVectors(De,_n),i[0]=_n.x,i[4]=ys.x,i[8]=De.x,i[1]=_n.y,i[5]=ys.y,i[9]=De.y,i[2]=_n.z,i[6]=ys.z,i[10]=De.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],d=n[5],f=n[9],g=n[13],_=n[2],v=n[6],m=n[10],p=n[14],w=n[3],x=n[7],b=n[11],L=n[15],C=i[0],R=i[4],D=i[8],X=i[12],M=i[1],A=i[5],Q=i[9],$=i[13],I=i[2],G=i[6],k=i[10],J=i[14],q=i[3],Y=i[7],it=i[11],nt=i[15];return r[0]=o*C+a*M+c*I+l*q,r[4]=o*R+a*A+c*G+l*Y,r[8]=o*D+a*Q+c*k+l*it,r[12]=o*X+a*$+c*J+l*nt,r[1]=h*C+d*M+f*I+g*q,r[5]=h*R+d*A+f*G+g*Y,r[9]=h*D+d*Q+f*k+g*it,r[13]=h*X+d*$+f*J+g*nt,r[2]=_*C+v*M+m*I+p*q,r[6]=_*R+v*A+m*G+p*Y,r[10]=_*D+v*Q+m*k+p*it,r[14]=_*X+v*$+m*J+p*nt,r[3]=w*C+x*M+b*I+L*q,r[7]=w*R+x*A+b*G+L*Y,r[11]=w*D+x*Q+b*k+L*it,r[15]=w*X+x*$+b*J+L*nt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],o=t[1],a=t[5],c=t[9],l=t[13],h=t[2],d=t[6],f=t[10],g=t[14],_=t[3],v=t[7],m=t[11],p=t[15];return _*(+r*c*d-i*l*d-r*a*f+n*l*f+i*a*g-n*c*g)+v*(+e*c*g-e*l*f+r*o*f-i*o*g+i*l*h-r*c*h)+m*(+e*l*d-e*a*g-r*o*d+n*o*g+r*a*h-n*l*h)+p*(-i*a*h-e*c*d+e*a*f+i*o*d-n*o*f+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],d=t[9],f=t[10],g=t[11],_=t[12],v=t[13],m=t[14],p=t[15],w=d*m*l-v*f*l+v*c*g-a*m*g-d*c*p+a*f*p,x=_*f*l-h*m*l-_*c*g+o*m*g+h*c*p-o*f*p,b=h*v*l-_*d*l+_*a*g-o*v*g-h*a*p+o*d*p,L=_*d*c-h*v*c-_*a*f+o*v*f+h*a*m-o*d*m,C=e*w+n*x+i*b+r*L;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/C;return t[0]=w*R,t[1]=(v*f*r-d*m*r-v*i*g+n*m*g+d*i*p-n*f*p)*R,t[2]=(a*m*r-v*c*r+v*i*l-n*m*l-a*i*p+n*c*p)*R,t[3]=(d*c*r-a*f*r-d*i*l+n*f*l+a*i*g-n*c*g)*R,t[4]=x*R,t[5]=(h*m*r-_*f*r+_*i*g-e*m*g-h*i*p+e*f*p)*R,t[6]=(_*c*r-o*m*r-_*i*l+e*m*l+o*i*p-e*c*p)*R,t[7]=(o*f*r-h*c*r+h*i*l-e*f*l-o*i*g+e*c*g)*R,t[8]=b*R,t[9]=(_*d*r-h*v*r-_*n*g+e*v*g+h*n*p-e*d*p)*R,t[10]=(o*v*r-_*a*r+_*n*l-e*v*l-o*n*p+e*a*p)*R,t[11]=(h*a*r-o*d*r-h*n*l+e*d*l+o*n*g-e*a*g)*R,t[12]=L*R,t[13]=(h*v*i-_*d*i+_*n*f-e*v*f-h*n*m+e*d*m)*R,t[14]=(_*a*i-o*v*i-_*n*c+e*v*c+o*n*m-e*a*m)*R,t[15]=(o*d*i-h*a*i+h*n*c-e*d*c-o*n*f+e*a*f)*R,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,o=t.x,a=t.y,c=t.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,h*a+n,h*c-i*o,0,l*c-i*a,h*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,o){return this.set(1,n,r,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,o=e._y,a=e._z,c=e._w,l=r+r,h=o+o,d=a+a,f=r*l,g=r*h,_=r*d,v=o*h,m=o*d,p=a*d,w=c*l,x=c*h,b=c*d,L=n.x,C=n.y,R=n.z;return i[0]=(1-(v+p))*L,i[1]=(g+b)*L,i[2]=(_-x)*L,i[3]=0,i[4]=(g-b)*C,i[5]=(1-(f+p))*C,i[6]=(m+w)*C,i[7]=0,i[8]=(_+x)*R,i[9]=(m-w)*R,i[10]=(1-(f+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=ai.set(i[0],i[1],i[2]).length(),o=ai.set(i[4],i[5],i[6]).length(),a=ai.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],Xe.copy(this);let l=1/r,h=1/o,d=1/a;return Xe.elements[0]*=l,Xe.elements[1]*=l,Xe.elements[2]*=l,Xe.elements[4]*=h,Xe.elements[5]*=h,Xe.elements[6]*=h,Xe.elements[8]*=d,Xe.elements[9]*=d,Xe.elements[10]*=d,e.setFromRotationMatrix(Xe),n.x=r,n.y=o,n.z=a,this}makePerspective(t,e,n,i,r,o,a=dn){let c=this.elements,l=2*r/(e-t),h=2*r/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i),g,_;if(a===dn)g=-(o+r)/(o-r),_=-2*o*r/(o-r);else if(a===er)g=-o/(o-r),_=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,o,a=dn){let c=this.elements,l=1/(e-t),h=1/(n-i),d=1/(o-r),f=(e+t)*l,g=(n+i)*h,_,v;if(a===dn)_=(o+r)*d,v=-2*d;else if(a===er)_=r*d,v=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-g,c[2]=0,c[6]=0,c[10]=v,c[14]=-_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};u(es,"Matrix4");var Ft=es,ai=new P,Xe=new Ft,Ip=new P(0,0,0),Lp=new P(1,1,1),_n=new P,ys=new P,De=new P,Zh=new Ft,Jh=new In,Cr=class Cr{constructor(t=0,e=0,n=0,i=Cr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],h=i[9],d=i[2],f=i[6],g=i[10];switch(e){case"XYZ":this._y=Math.asin(pe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-pe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(pe(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,g),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-pe(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,g),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(pe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,g));break;case"XZY":this._z=Math.asin(-pe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,g),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Zh.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Zh,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Jh.setFromEuler(this),this.setFromQuaternion(Jh,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};u(Cr,"Euler");var Je=Cr;Je.DEFAULT_ORDER="XYZ";var nc=class nc{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}};u(nc,"Layers");var ss=nc,Up=0,$h=new P,oi=new In,rn=new Ft,Ms=new P,Wi=new P,Dp=new P,Np=new In,Kh=new P(1,0,0),Qh=new P(0,1,0),jh=new P(0,0,1),Op={type:"added"},Fp={type:"removed"},ha={type:"childadded",child:null},ua={type:"childremoved",child:null},Ei=class Ei extends Pn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Up++}),this.uuid=Ve(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ei.DEFAULT_UP.clone();let t=new P,e=new Je,n=new In,i=new P(1,1,1);function r(){n.setFromEuler(e,!1)}u(r,"onRotationChange");function o(){e.setFromQuaternion(n,void 0,!1)}u(o,"onQuaternionChange"),e._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ft},normalMatrix:{value:new kt}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=Ei.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ei.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ss,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.multiply(oi),this}rotateOnWorldAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.premultiply(oi),this}rotateX(t){return this.rotateOnAxis(Kh,t)}rotateY(t){return this.rotateOnAxis(Qh,t)}rotateZ(t){return this.rotateOnAxis(jh,t)}translateOnAxis(t,e){return $h.copy(t).applyQuaternion(this.quaternion),this.position.add($h.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Kh,t)}translateY(t){return this.translateOnAxis(Qh,t)}translateZ(t){return this.translateOnAxis(jh,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(rn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ms.copy(t):Ms.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Wi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rn.lookAt(Wi,Ms,this.up):rn.lookAt(Ms,Wi,this.up),this.quaternion.setFromRotationMatrix(rn),i&&(rn.extractRotation(i.matrixWorld),oi.setFromRotationMatrix(rn),this.quaternion.premultiply(oi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Op),ha.child=t,this.dispatchEvent(ha),ha.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Fp),ua.child=t,this.dispatchEvent(ua),ua.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),rn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),rn.multiply(t.parent.matrixWorld)),t.applyMatrix4(rn),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wi,t,Dp),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wi,Np,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,i=e.length;n<i;n++){let r=e[n];(r.matrixWorldAutoUpdate===!0||t===!0)&&r.updateMatrixWorld(t)}}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let i=this.children;for(let r=0,o=i.length;r<o;r++){let a=i[r];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(u(r,"serialize"),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.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 d=c[l];r(t.shapes,d)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.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(t.materials,this.material[c]));i.material=a}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];i.animations.push(r(t.animations,c))}}if(e){let a=o(t.geometries),c=o(t.materials),l=o(t.textures),h=o(t.images),d=o(t.shapes),f=o(t.skeletons),g=o(t.animations),_=o(t.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),d.length>0&&(n.shapes=d),f.length>0&&(n.skeletons=f),g.length>0&&(n.animations=g),_.length>0&&(n.nodes=_)}return n.object=i,n;function o(a){let c=[];for(let l in a){let h=a[l];delete h.metadata,c.push(h)}return c}u(o,"extractFromCache")}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};u(Ei,"Object3D");var le=Ei;le.DEFAULT_UP=new P(0,1,0);le.DEFAULT_MATRIX_AUTO_UPDATE=!0;le.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var qe=new P,an=new P,da=new P,on=new P,ci=new P,li=new P,tu=new P,fa=new P,pa=new P,ma=new P,Mn=class Mn{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),qe.subVectors(t,e),i.cross(qe);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){qe.subVectors(i,e),an.subVectors(n,e),da.subVectors(t,e);let o=qe.dot(qe),a=qe.dot(an),c=qe.dot(da),l=an.dot(an),h=an.dot(da),d=o*l-a*a;if(d===0)return r.set(0,0,0),null;let f=1/d,g=(l*c-a*h)*f,_=(o*h-a*c)*f;return r.set(1-g-_,_,g)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,on)===null?!1:on.x>=0&&on.y>=0&&on.x+on.y<=1}static getInterpolation(t,e,n,i,r,o,a,c){return this.getBarycoord(t,e,n,i,on)===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,on.x),c.addScaledVector(o,on.y),c.addScaledVector(a,on.z),c)}static isFrontFacing(t,e,n,i){return qe.subVectors(n,e),an.subVectors(t,e),qe.cross(an).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return qe.subVectors(this.c,this.b),an.subVectors(this.a,this.b),qe.cross(an).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Mn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Mn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Mn.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Mn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Mn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,o,a;ci.subVectors(i,n),li.subVectors(r,n),fa.subVectors(t,n);let c=ci.dot(fa),l=li.dot(fa);if(c<=0&&l<=0)return e.copy(n);pa.subVectors(t,i);let h=ci.dot(pa),d=li.dot(pa);if(h>=0&&d<=h)return e.copy(i);let f=c*d-h*l;if(f<=0&&c>=0&&h<=0)return o=c/(c-h),e.copy(n).addScaledVector(ci,o);ma.subVectors(t,r);let g=ci.dot(ma),_=li.dot(ma);if(_>=0&&g<=_)return e.copy(r);let v=g*l-c*_;if(v<=0&&l>=0&&_<=0)return a=l/(l-_),e.copy(n).addScaledVector(li,a);let m=h*_-g*d;if(m<=0&&d-h>=0&&g-_>=0)return tu.subVectors(r,i),a=(d-h)/(d-h+(g-_)),e.copy(i).addScaledVector(tu,a);let p=1/(m+v+f);return o=v*p,a=f*p,e.copy(n).addScaledVector(ci,o).addScaledVector(li,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}};u(Mn,"Triangle");var Zn=Mn,Zd={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},xn={h:0,s:0,l:0},Ss={h:0,s:0,l:0};function ga(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}u(ga,"hue2rgb");var ic=class ic{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ke){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Jt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Jt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Jt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Jt.workingColorSpace){if(t=ko(t,1),e=pe(e,0,1),n=pe(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=ga(o,r,t+1/3),this.g=ga(o,r,t),this.b=ga(o,r,t-1/3)}return Jt.toWorkingColorSpace(this,i),this}setStyle(t,e=Ke){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}u(n,"handleAlpha");let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[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,e);if(o===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ke){let n=Zd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ti(t.r),this.g=Ti(t.g),this.b=Ti(t.b),this}copyLinearToSRGB(t){return this.r=na(t.r),this.g=na(t.g),this.b=na(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ke){return Jt.fromWorkingColorSpace(ve.copy(this),t),Math.round(pe(ve.r*255,0,255))*65536+Math.round(pe(ve.g*255,0,255))*256+Math.round(pe(ve.b*255,0,255))}getHexString(t=Ke){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Jt.workingColorSpace){Jt.fromWorkingColorSpace(ve.copy(this),e);let n=ve.r,i=ve.g,r=ve.b,o=Math.max(n,i,r),a=Math.min(n,i,r),c,l,h=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=h<=.5?d/(o+a):d/(2-o-a),o){case n:c=(i-r)/d+(i<r?6:0);break;case i:c=(r-n)/d+2;break;case r:c=(n-i)/d+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Jt.workingColorSpace){return Jt.fromWorkingColorSpace(ve.copy(this),e),t.r=ve.r,t.g=ve.g,t.b=ve.b,t}getStyle(t=Ke){Jt.fromWorkingColorSpace(ve.copy(this),t);let e=ve.r,n=ve.g,i=ve.b;return t!==Ke?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(xn),this.setHSL(xn.h+t,xn.s+e,xn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(xn),t.getHSL(Ss);let n=$i(xn.h,Ss.h,e),i=$i(xn.s,Ss.s,e),r=$i(xn.l,Ss.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};u(ic,"Color");var Vt=ic,ve=new Vt;Vt.NAMES=Zd;var Bp=0,sc=class sc extends Pn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bp++}),this.uuid=Ve(),this.name="",this.type="Material",this.blending=wi,this.side=Cn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Oa,this.blendDst=Fa,this.blendEquation=Xn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=Js,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Vh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ei,this.stencilZFail=ei,this.stencilZPass=ei,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==wi&&(n.blending=this.blending),this.side!==Cn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Oa&&(n.blendSrc=this.blendSrc),this.blendDst!==Fa&&(n.blendDst=this.blendDst),this.blendEquation!==Xn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Js&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Vh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ei&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ei&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ei&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(u(i,"extractFromCache"),e){let r=i(t.textures),o=i(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};u(sc,"Material");var je=sc,rc=class rc extends je{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(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 Je,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};u(rc,"MeshBasicMaterial");var ar=rc;var oe=new P,bs=new at,ac=class ac{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Ha,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ke,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Yd("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)bs.fromBufferAttribute(this,e),bs.applyMatrix3(t),this.setXY(e,bs.x,bs.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyMatrix3(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyMatrix4(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyNormalMatrix(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.transformDirection(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Zt(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ze(e,this.array)),e}setX(t,e){return this.normalized&&(e=Zt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ze(e,this.array)),e}setY(t,e){return this.normalized&&(e=Zt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ze(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Zt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ze(e,this.array)),e}setW(t,e){return this.normalized&&(e=Zt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array),i=Zt(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array),i=Zt(i,this.array),r=Zt(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Ha&&(t.usage=this.usage),t}};u(ac,"BufferAttribute");var Se=ac;var oc=class oc extends Se{constructor(t,e,n){super(new Uint16Array(t),e,n)}};u(oc,"Uint16BufferAttribute");var or=oc;var cc=class cc extends Se{constructor(t,e,n){super(new Uint32Array(t),e,n)}};u(cc,"Uint32BufferAttribute");var cr=cc;var lc=class lc extends Se{constructor(t,e,n){super(new Float32Array(t),e,n)}};u(lc,"Float32BufferAttribute");var ce=lc,zp=0,ze=new Ft,_a=new le,hi=new P,Ne=new Ie,Xi=new Ie,fe=new P,Pr=class Pr extends Pn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zp++}),this.uuid=Ve(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(qd(t)?cr:or)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new kt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return ze.makeRotationFromQuaternion(t),this.applyMatrix4(ze),this}rotateX(t){return ze.makeRotationX(t),this.applyMatrix4(ze),this}rotateY(t){return ze.makeRotationY(t),this.applyMatrix4(ze),this}rotateZ(t){return ze.makeRotationZ(t),this.applyMatrix4(ze),this}translate(t,e,n){return ze.makeTranslation(t,e,n),this.applyMatrix4(ze),this}scale(t,e,n){return ze.makeScale(t,e,n),this.applyMatrix4(ze),this}lookAt(t){return _a.lookAt(t),_a.updateMatrix(),this.applyMatrix4(_a.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hi).negate(),this.translate(hi.x,hi.y,hi.z),this}setFromPoints(t){let e=[];for(let n=0,i=t.length;n<i;n++){let r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new ce(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ie);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let r=e[n];Ne.setFromBufferAttribute(r),this.morphTargetsRelative?(fe.addVectors(this.boundingBox.min,Ne.min),this.boundingBox.expandByPoint(fe),fe.addVectors(this.boundingBox.max,Ne.max),this.boundingBox.expandByPoint(fe)):(this.boundingBox.expandByPoint(Ne.min),this.boundingBox.expandByPoint(Ne.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Re);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(t){let n=this.boundingSphere.center;if(Ne.setFromBufferAttribute(t),e)for(let r=0,o=e.length;r<o;r++){let a=e[r];Xi.setFromBufferAttribute(a),this.morphTargetsRelative?(fe.addVectors(Ne.min,Xi.min),Ne.expandByPoint(fe),fe.addVectors(Ne.max,Xi.max),Ne.expandByPoint(fe)):(Ne.expandByPoint(Xi.min),Ne.expandByPoint(Xi.max))}Ne.getCenter(n);let i=0;for(let r=0,o=t.count;r<o;r++)fe.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(fe));if(e)for(let r=0,o=e.length;r<o;r++){let a=e[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)fe.fromBufferAttribute(a,l),c&&(hi.fromBufferAttribute(t,l),fe.add(hi)),i=Math.max(i,n.distanceToSquared(fe))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Se(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let D=0;D<n.count;D++)a[D]=new P,c[D]=new P;let l=new P,h=new P,d=new P,f=new at,g=new at,_=new at,v=new P,m=new P;function p(D,X,M){l.fromBufferAttribute(n,D),h.fromBufferAttribute(n,X),d.fromBufferAttribute(n,M),f.fromBufferAttribute(r,D),g.fromBufferAttribute(r,X),_.fromBufferAttribute(r,M),h.sub(l),d.sub(l),g.sub(f),_.sub(f);let A=1/(g.x*_.y-_.x*g.y);isFinite(A)&&(v.copy(h).multiplyScalar(_.y).addScaledVector(d,-g.y).multiplyScalar(A),m.copy(d).multiplyScalar(g.x).addScaledVector(h,-_.x).multiplyScalar(A),a[D].add(v),a[X].add(v),a[M].add(v),c[D].add(m),c[X].add(m),c[M].add(m))}u(p,"handleTriangle");let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let D=0,X=w.length;D<X;++D){let M=w[D],A=M.start,Q=M.count;for(let $=A,I=A+Q;$<I;$+=3)p(t.getX($+0),t.getX($+1),t.getX($+2))}let x=new P,b=new P,L=new P,C=new P;function R(D){L.fromBufferAttribute(i,D),C.copy(L);let X=a[D];x.copy(X),x.sub(L.multiplyScalar(L.dot(X))).normalize(),b.crossVectors(C,X);let A=b.dot(c[D])<0?-1:1;o.setXYZW(D,x.x,x.y,x.z,A)}u(R,"handleVertex");for(let D=0,X=w.length;D<X;++D){let M=w[D],A=M.start,Q=M.count;for(let $=A,I=A+Q;$<I;$+=3)R(t.getX($+0)),R(t.getX($+1)),R(t.getX($+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Se(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,g=n.count;f<g;f++)n.setXYZ(f,0,0,0);let i=new P,r=new P,o=new P,a=new P,c=new P,l=new P,h=new P,d=new P;if(t)for(let f=0,g=t.count;f<g;f+=3){let _=t.getX(f+0),v=t.getX(f+1),m=t.getX(f+2);i.fromBufferAttribute(e,_),r.fromBufferAttribute(e,v),o.fromBufferAttribute(e,m),h.subVectors(o,r),d.subVectors(i,r),h.cross(d),a.fromBufferAttribute(n,_),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),a.add(h),c.add(h),l.add(h),n.setXYZ(_,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,g=e.count;f<g;f+=3)i.fromBufferAttribute(e,f+0),r.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),h.subVectors(o,r),d.subVectors(i,r),h.cross(d),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 t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)fe.fromBufferAttribute(t,e),fe.normalize(),t.setXYZ(e,fe.x,fe.y,fe.z)}toNonIndexed(){function t(a,c){let l=a.array,h=a.itemSize,d=a.normalized,f=new l.constructor(c.length*h),g=0,_=0;for(let v=0,m=c.length;v<m;v++){a.isInterleavedBufferAttribute?g=c[v]*a.data.stride+a.offset:g=c[v]*h;for(let p=0;p<h;p++)f[_++]=l[g++]}return new Se(f,h,d)}if(u(t,"convertBufferAttribute"),this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new Pr,n=this.index.array,i=this.attributes;for(let a in i){let c=i[a],l=t(c,n);e.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let h=0,d=l.length;h<d;h++){let f=l[h],g=t(f,n);c.push(g)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,f=l.length;d<f;d++){let g=l[d];h.push(g.toJSON(t.data))}h.length>0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let i=t.attributes;for(let l in i){let h=i[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],d=r[l];for(let f=0,g=d.length;f<g;f++)h.push(d[f].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let l=0,h=o.length;l<h;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};u(Pr,"BufferGeometry");var Le=Pr,eu=new Ft,zn=new Kn,Es=new Re,nu=new P,ui=new P,di=new P,fi=new P,xa=new P,ws=new P,As=new at,Ts=new at,Rs=new at,iu=new P,su=new P,ru=new P,Cs=new P,Ps=new P,hc=class hc extends le{constructor(t=new Le,e=new ar){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(r&&a){ws.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=a[c],d=r[c];h!==0&&(xa.fromBufferAttribute(d,t),o?ws.addScaledVector(xa,h):ws.addScaledVector(xa.sub(e),h))}e.add(ws)}return e}raycast(t,e){let n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Es.copy(n.boundingSphere),Es.applyMatrix4(r),zn.copy(t.ray).recast(t.near),!(Es.containsPoint(zn.origin)===!1&&(zn.intersectSphere(Es,nu)===null||zn.origin.distanceToSquared(nu)>(t.far-t.near)**2))&&(eu.copy(r).invert(),zn.copy(t.ray).applyMatrix4(eu),!(n.boundingBox!==null&&zn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,zn)))}_computeIntersections(t,e,n){let i,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,f=r.groups,g=r.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,v=f.length;_<v;_++){let m=f[_],p=o[m.materialIndex],w=Math.max(m.start,g.start),x=Math.min(a.count,Math.min(m.start+m.count,g.start+g.count));for(let b=w,L=x;b<L;b+=3){let C=a.getX(b),R=a.getX(b+1),D=a.getX(b+2);i=Is(this,p,t,n,l,h,d,C,R,D),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=m.materialIndex,e.push(i))}}else{let _=Math.max(0,g.start),v=Math.min(a.count,g.start+g.count);for(let m=_,p=v;m<p;m+=3){let w=a.getX(m),x=a.getX(m+1),b=a.getX(m+2);i=Is(this,o,t,n,l,h,d,w,x,b),i&&(i.faceIndex=Math.floor(m/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let _=0,v=f.length;_<v;_++){let m=f[_],p=o[m.materialIndex],w=Math.max(m.start,g.start),x=Math.min(c.count,Math.min(m.start+m.count,g.start+g.count));for(let b=w,L=x;b<L;b+=3){let C=b,R=b+1,D=b+2;i=Is(this,p,t,n,l,h,d,C,R,D),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=m.materialIndex,e.push(i))}}else{let _=Math.max(0,g.start),v=Math.min(c.count,g.start+g.count);for(let m=_,p=v;m<p;m+=3){let w=m,x=m+1,b=m+2;i=Is(this,o,t,n,l,h,d,w,x,b),i&&(i.faceIndex=Math.floor(m/3),e.push(i))}}}};u(hc,"Mesh");var Me=hc;function kp(s,t,e,n,i,r,o,a){let c;if(t.side===Pe?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,t.side===Cn,a),c===null)return null;Ps.copy(a),Ps.applyMatrix4(s.matrixWorld);let l=e.ray.origin.distanceTo(Ps);return l<e.near||l>e.far?null:{distance:l,point:Ps.clone(),object:s}}u(kp,"checkIntersection");function Is(s,t,e,n,i,r,o,a,c,l){s.getVertexPosition(a,ui),s.getVertexPosition(c,di),s.getVertexPosition(l,fi);let h=kp(s,t,e,n,ui,di,fi,Cs);if(h){i&&(As.fromBufferAttribute(i,a),Ts.fromBufferAttribute(i,c),Rs.fromBufferAttribute(i,l),h.uv=Zn.getInterpolation(Cs,ui,di,fi,As,Ts,Rs,new at)),r&&(As.fromBufferAttribute(r,a),Ts.fromBufferAttribute(r,c),Rs.fromBufferAttribute(r,l),h.uv1=Zn.getInterpolation(Cs,ui,di,fi,As,Ts,Rs,new at)),o&&(iu.fromBufferAttribute(o,a),su.fromBufferAttribute(o,c),ru.fromBufferAttribute(o,l),h.normal=Zn.getInterpolation(Cs,ui,di,fi,iu,su,ru,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new P,materialIndex:0};Zn.getNormal(ui,di,fi,d.normal),h.face=d}return h}u(Is,"checkGeometryIntersection");var Ir=class Ir extends Le{constructor(t=1,e=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};let a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],h=[],d=[],f=0,g=0;_("z","y","x",-1,-1,n,e,t,o,r,0),_("z","y","x",1,-1,n,e,-t,o,r,1),_("x","z","y",1,1,t,n,e,i,o,2),_("x","z","y",1,-1,t,n,-e,i,o,3),_("x","y","z",1,-1,t,e,n,i,r,4),_("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new ce(l,3)),this.setAttribute("normal",new ce(h,3)),this.setAttribute("uv",new ce(d,2));function _(v,m,p,w,x,b,L,C,R,D,X){let M=b/R,A=L/D,Q=b/2,$=L/2,I=C/2,G=R+1,k=D+1,J=0,q=0,Y=new P;for(let it=0;it<k;it++){let nt=it*A-$;for(let _t=0;_t<G;_t++){let It=_t*M-Q;Y[v]=It*w,Y[m]=nt*x,Y[p]=I,l.push(Y.x,Y.y,Y.z),Y[v]=0,Y[m]=0,Y[p]=C>0?1:-1,h.push(Y.x,Y.y,Y.z),d.push(_t/R),d.push(1-it/D),J+=1}}for(let it=0;it<D;it++)for(let nt=0;nt<R;nt++){let _t=f+nt+G*it,It=f+nt+G*(it+1),V=f+(nt+1)+G*(it+1),tt=f+(nt+1)+G*it;c.push(_t,It,tt),c.push(It,V,tt),q+=6}a.addGroup(g,q,X),g+=q,f+=J}u(_,"buildPlane")}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ir(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};u(Ir,"BoxGeometry");var rs=Ir;function Ui(s){let t={};for(let e in s){t[e]={};for(let n in s[e]){let i=s[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}u(Ui,"cloneUniforms");function Ae(s){let t={};for(let e=0;e<s.length;e++){let n=Ui(s[e]);for(let i in n)t[i]=n[i]}return t}u(Ae,"mergeUniforms");function Vp(s){let t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}u(Vp,"cloneUniformsGroups");function Jd(s){return s.getRenderTarget()===null?s.outputColorSpace:Jt.workingColorSpace}u(Jd,"getUnlitUniformColorSpace");var Hp={clone:Ui,merge:Ae},Gp=`void main() {
2
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,Wp=`void main() {
4
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`,uc=class uc extends je{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Gp,this.fragmentShader=Wp,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ui(t.uniforms),this.uniformsGroups=Vp(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let i in this.uniforms){let o=this.uniforms[i].value;o&&o.isTexture?e.uniforms[i]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[i]={type:"m4",value:o.toArray()}:e.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}};u(uc,"ShaderMaterial");var tn=uc,dc=class dc extends le{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=dn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};u(dc,"Camera");var lr=dc,vn=new P,au=new at,ou=new at,fc=class fc extends lr{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Li*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Ai*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Li*2*Math.atan(Math.tan(Ai*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vn.x,vn.y).multiplyScalar(-t/vn.z),vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vn.x,vn.y).multiplyScalar(-t/vn.z)}getViewSize(t,e){return this.getViewBounds(t,au,ou),e.subVectors(ou,au)}setViewOffset(t,e,n,i,r,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Ai*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,e-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}};u(fc,"PerspectiveCamera");var Te=fc,pi=-90,mi=1,pc=class pc extends le{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Te(pi,mi,t,e);i.layers=this.layers,this.add(i);let r=new Te(pi,mi,t,e);r.layers=this.layers,this.add(r);let o=new Te(pi,mi,t,e);o.layers=this.layers,this.add(o);let a=new Te(pi,mi,t,e);a.layers=this.layers,this.add(a);let c=new Te(pi,mi,t,e);c.layers=this.layers,this.add(c);let l=new Te(pi,mi,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,r,o,a,c]=e;for(let l of e)this.remove(l);if(t===dn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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(t===er)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,c,l,h]=this.children,d=t.getRenderTarget(),f=t.getActiveCubeFace(),g=t.getActiveMipmapLevel(),_=t.xr.enabled;t.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,o),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,c),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(d,f,g),t.xr.enabled=_,n.texture.needsPMREMUpdate=!0}};u(pc,"CubeCamera");var Ya=pc,mc=class mc extends be{constructor(t,e,n,i,r,o,a,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:Ci,super(t,e,n,i,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};u(mc,"CubeTexture");var hr=mc,gc=class gc extends fn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new hr(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Ce}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
-
7
- varying vec3 vWorldDirection;
8
-
9
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
-
11
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
-
13
- }
14
-
15
- void main() {
16
-
17
- vWorldDirection = transformDirection( position, modelMatrix );
18
-
19
- #include <begin_vertex>
20
- #include <project_vertex>
21
-
22
- }
23
- `,fragmentShader:`
24
-
25
- uniform sampler2D tEquirect;
26
-
27
- varying vec3 vWorldDirection;
28
-
29
- #include <common>
30
-
31
- void main() {
32
-
33
- vec3 direction = normalize( vWorldDirection );
34
-
35
- vec2 sampleUV = equirectUv( direction );
36
-
37
- gl_FragColor = texture2D( tEquirect, sampleUV );
38
-
39
- }
40
- `},i=new rs(5,5,5),r=new tn({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pe,blending:An});r.uniforms.tEquirect.value=e;let o=new Me(i,r),a=e.minFilter;return e.minFilter===Yn&&(e.minFilter=Ce),new Ya(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,i);t.setRenderTarget(r)}};u(gc,"WebGLCubeRenderTarget");var Za=gc,va=new P,Xp=new P,qp=new kt,_c=class _c{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=va.subVectors(n,e).cross(Xp.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(va),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||qp.getNormalMatrix(t),i=this.coplanarPoint(va).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}};u(_c,"Plane");var hn=_c,kn=new Re,Ls=new P,xc=class xc{constructor(t=new hn,e=new hn,n=new hn,i=new hn,r=new hn,o=new hn){this.planes=[t,e,n,i,r,o]}set(t,e,n,i,r,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=dn){let n=this.planes,i=t.elements,r=i[0],o=i[1],a=i[2],c=i[3],l=i[4],h=i[5],d=i[6],f=i[7],g=i[8],_=i[9],v=i[10],m=i[11],p=i[12],w=i[13],x=i[14],b=i[15];if(n[0].setComponents(c-r,f-l,m-g,b-p).normalize(),n[1].setComponents(c+r,f+l,m+g,b+p).normalize(),n[2].setComponents(c+o,f+h,m+_,b+w).normalize(),n[3].setComponents(c-o,f-h,m-_,b-w).normalize(),n[4].setComponents(c-a,f-d,m-v,b-x).normalize(),e===dn)n[5].setComponents(c+a,f+d,m+v,b+x).normalize();else if(e===er)n[5].setComponents(a,d,v,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),kn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),kn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(kn)}intersectsSprite(t){return kn.center.set(0,0,0),kn.radius=.7071067811865476,kn.applyMatrix4(t.matrixWorld),this.intersectsSphere(kn)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(Ls.x=i.normal.x>0?t.max.x:t.min.x,Ls.y=i.normal.y>0?t.max.y:t.min.y,Ls.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Ls)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};u(xc,"Frustum");var Di=xc;function $d(){let s=null,t=!1,e=null,n=null;function i(r,o){e(r,o),n=s.requestAnimationFrame(i)}return u(i,"onAnimationFrame"),{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}u($d,"WebGLAnimation");function Yp(s,t){let e=t.isWebGL2,n=new WeakMap;function i(l,h){let d=l.array,f=l.usage,g=d.byteLength,_=s.createBuffer();s.bindBuffer(h,_),s.bufferData(h,d,f),l.onUploadCallback();let v;if(d instanceof Float32Array)v=s.FLOAT;else if(d instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(e)v=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=s.UNSIGNED_SHORT;else if(d instanceof Int16Array)v=s.SHORT;else if(d instanceof Uint32Array)v=s.UNSIGNED_INT;else if(d instanceof Int32Array)v=s.INT;else if(d instanceof Int8Array)v=s.BYTE;else if(d instanceof Uint8Array)v=s.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)v=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:_,type:v,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version,size:g}}u(i,"createBuffer");function r(l,h,d){let f=h.array,g=h._updateRange,_=h.updateRanges;if(s.bindBuffer(d,l),g.count===-1&&_.length===0&&s.bufferSubData(d,0,f),_.length!==0){for(let v=0,m=_.length;v<m;v++){let p=_[v];e?s.bufferSubData(d,p.start*f.BYTES_PER_ELEMENT,f,p.start,p.count):s.bufferSubData(d,p.start*f.BYTES_PER_ELEMENT,f.subarray(p.start,p.start+p.count))}h.clearUpdateRanges()}g.count!==-1&&(e?s.bufferSubData(d,g.offset*f.BYTES_PER_ELEMENT,f,g.offset,g.count):s.bufferSubData(d,g.offset*f.BYTES_PER_ELEMENT,f.subarray(g.offset,g.offset+g.count)),g.count=-1),h.onUploadCallback()}u(r,"updateBuffer");function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}u(o,"get");function a(l){l.isInterleavedBufferAttribute&&(l=l.data);let h=n.get(l);h&&(s.deleteBuffer(h.buffer),n.delete(l))}u(a,"remove");function c(l,h){if(l.isGLBufferAttribute){let f=n.get(l);(!f||f.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);let d=n.get(l);if(d===void 0)n.set(l,i(l,h));else if(d.version<l.version){if(d.size!==l.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.");r(d.buffer,l,h),d.version=l.version}}return u(c,"update"),{get:o,remove:a,update:c}}u(Yp,"WebGLAttributes");var Lr=class Lr extends Le{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let r=t/2,o=e/2,a=Math.floor(n),c=Math.floor(i),l=a+1,h=c+1,d=t/a,f=e/c,g=[],_=[],v=[],m=[];for(let p=0;p<h;p++){let w=p*f-o;for(let x=0;x<l;x++){let b=x*d-r;_.push(b,-w,0),v.push(0,0,1),m.push(x/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let w=0;w<a;w++){let x=w+l*p,b=w+l*(p+1),L=w+1+l*(p+1),C=w+1+l*p;g.push(x,b,C),g.push(b,L,C)}this.setIndex(g),this.setAttribute("position",new ce(_,3)),this.setAttribute("normal",new ce(v,3)),this.setAttribute("uv",new ce(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Lr(t.width,t.height,t.widthSegments,t.heightSegments)}};u(Lr,"PlaneGeometry");var ur=Lr,Zp=`#ifdef USE_ALPHAHASH
41
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
- #endif`,Jp=`#ifdef USE_ALPHAHASH
43
- const float ALPHA_HASH_SCALE = 0.05;
44
- float hash2D( vec2 value ) {
45
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
- }
47
- float hash3D( vec3 value ) {
48
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
- }
50
- float getAlphaHashThreshold( vec3 position ) {
51
- float maxDeriv = max(
52
- length( dFdx( position.xyz ) ),
53
- length( dFdy( position.xyz ) )
54
- );
55
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
- vec2 pixScales = vec2(
57
- exp2( floor( log2( pixScale ) ) ),
58
- exp2( ceil( log2( pixScale ) ) )
59
- );
60
- vec2 alpha = vec2(
61
- hash3D( floor( pixScales.x * position.xyz ) ),
62
- hash3D( floor( pixScales.y * position.xyz ) )
63
- );
64
- float lerpFactor = fract( log2( pixScale ) );
65
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
- float a = min( lerpFactor, 1.0 - lerpFactor );
67
- vec3 cases = vec3(
68
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
- ( x - 0.5 * a ) / ( 1.0 - a ),
70
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
- );
72
- float threshold = ( x < ( 1.0 - a ) )
73
- ? ( ( x < a ) ? cases.x : cases.y )
74
- : cases.z;
75
- return clamp( threshold , 1.0e-6, 1.0 );
76
- }
77
- #endif`,$p=`#ifdef USE_ALPHAMAP
78
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
- #endif`,Kp=`#ifdef USE_ALPHAMAP
80
- uniform sampler2D alphaMap;
81
- #endif`,Qp=`#ifdef USE_ALPHATEST
82
- #ifdef ALPHA_TO_COVERAGE
83
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
- if ( diffuseColor.a == 0.0 ) discard;
85
- #else
86
- if ( diffuseColor.a < alphaTest ) discard;
87
- #endif
88
- #endif`,jp=`#ifdef USE_ALPHATEST
89
- uniform float alphaTest;
90
- #endif`,tm=`#ifdef USE_AOMAP
91
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
- reflectedLight.indirectDiffuse *= ambientOcclusion;
93
- #if defined( USE_CLEARCOAT )
94
- clearcoatSpecularIndirect *= ambientOcclusion;
95
- #endif
96
- #if defined( USE_SHEEN )
97
- sheenSpecularIndirect *= ambientOcclusion;
98
- #endif
99
- #if defined( USE_ENVMAP ) && defined( STANDARD )
100
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
- #endif
103
- #endif`,em=`#ifdef USE_AOMAP
104
- uniform sampler2D aoMap;
105
- uniform float aoMapIntensity;
106
- #endif`,nm=`#ifdef USE_BATCHING
107
- attribute float batchId;
108
- uniform highp sampler2D batchingTexture;
109
- mat4 getBatchingMatrix( const in float i ) {
110
- int size = textureSize( batchingTexture, 0 ).x;
111
- int j = int( i ) * 4;
112
- int x = j % size;
113
- int y = j / size;
114
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
115
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
116
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
117
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
118
- return mat4( v1, v2, v3, v4 );
119
- }
120
- #endif`,im=`#ifdef USE_BATCHING
121
- mat4 batchingMatrix = getBatchingMatrix( batchId );
122
- #endif`,sm=`vec3 transformed = vec3( position );
123
- #ifdef USE_ALPHAHASH
124
- vPosition = vec3( position );
125
- #endif`,rm=`vec3 objectNormal = vec3( normal );
126
- #ifdef USE_TANGENT
127
- vec3 objectTangent = vec3( tangent.xyz );
128
- #endif`,am=`float G_BlinnPhong_Implicit( ) {
129
- return 0.25;
130
- }
131
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
132
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
133
- }
134
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
135
- vec3 halfDir = normalize( lightDir + viewDir );
136
- float dotNH = saturate( dot( normal, halfDir ) );
137
- float dotVH = saturate( dot( viewDir, halfDir ) );
138
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
139
- float G = G_BlinnPhong_Implicit( );
140
- float D = D_BlinnPhong( shininess, dotNH );
141
- return F * ( G * D );
142
- } // validated`,om=`#ifdef USE_IRIDESCENCE
143
- const mat3 XYZ_TO_REC709 = mat3(
144
- 3.2404542, -0.9692660, 0.0556434,
145
- -1.5371385, 1.8760108, -0.2040259,
146
- -0.4985314, 0.0415560, 1.0572252
147
- );
148
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
149
- vec3 sqrtF0 = sqrt( fresnel0 );
150
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
151
- }
152
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
153
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
154
- }
155
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
156
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
157
- }
158
- vec3 evalSensitivity( float OPD, vec3 shift ) {
159
- float phase = 2.0 * PI * OPD * 1.0e-9;
160
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
161
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
162
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
163
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
164
- 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 ) );
165
- xyz /= 1.0685e-7;
166
- vec3 rgb = XYZ_TO_REC709 * xyz;
167
- return rgb;
168
- }
169
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
170
- vec3 I;
171
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
172
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
173
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
174
- if ( cosTheta2Sq < 0.0 ) {
175
- return vec3( 1.0 );
176
- }
177
- float cosTheta2 = sqrt( cosTheta2Sq );
178
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
179
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
180
- float T121 = 1.0 - R12;
181
- float phi12 = 0.0;
182
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
183
- float phi21 = PI - phi12;
184
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
185
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
186
- vec3 phi23 = vec3( 0.0 );
187
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
188
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
189
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
190
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
191
- vec3 phi = vec3( phi21 ) + phi23;
192
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
193
- vec3 r123 = sqrt( R123 );
194
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
195
- vec3 C0 = R12 + Rs;
196
- I = C0;
197
- vec3 Cm = Rs - T121;
198
- for ( int m = 1; m <= 2; ++ m ) {
199
- Cm *= r123;
200
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
201
- I += Cm * Sm;
202
- }
203
- return max( I, vec3( 0.0 ) );
204
- }
205
- #endif`,cm=`#ifdef USE_BUMPMAP
206
- uniform sampler2D bumpMap;
207
- uniform float bumpScale;
208
- vec2 dHdxy_fwd() {
209
- vec2 dSTdx = dFdx( vBumpMapUv );
210
- vec2 dSTdy = dFdy( vBumpMapUv );
211
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
212
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
213
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
214
- return vec2( dBx, dBy );
215
- }
216
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
217
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
218
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
219
- vec3 vN = surf_norm;
220
- vec3 R1 = cross( vSigmaY, vN );
221
- vec3 R2 = cross( vN, vSigmaX );
222
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
223
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
224
- return normalize( abs( fDet ) * surf_norm - vGrad );
225
- }
226
- #endif`,lm=`#if NUM_CLIPPING_PLANES > 0
227
- vec4 plane;
228
- #ifdef ALPHA_TO_COVERAGE
229
- float distanceToPlane, distanceGradient;
230
- float clipOpacity = 1.0;
231
- #pragma unroll_loop_start
232
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
233
- plane = clippingPlanes[ i ];
234
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
235
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
236
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
237
- if ( clipOpacity == 0.0 ) discard;
238
- }
239
- #pragma unroll_loop_end
240
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
241
- float unionClipOpacity = 1.0;
242
- #pragma unroll_loop_start
243
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
244
- plane = clippingPlanes[ i ];
245
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
246
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
247
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
248
- }
249
- #pragma unroll_loop_end
250
- clipOpacity *= 1.0 - unionClipOpacity;
251
- #endif
252
- diffuseColor.a *= clipOpacity;
253
- if ( diffuseColor.a == 0.0 ) discard;
254
- #else
255
- #pragma unroll_loop_start
256
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
257
- plane = clippingPlanes[ i ];
258
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
259
- }
260
- #pragma unroll_loop_end
261
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
262
- bool clipped = true;
263
- #pragma unroll_loop_start
264
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
265
- plane = clippingPlanes[ i ];
266
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
267
- }
268
- #pragma unroll_loop_end
269
- if ( clipped ) discard;
270
- #endif
271
- #endif
272
- #endif`,hm=`#if NUM_CLIPPING_PLANES > 0
273
- varying vec3 vClipPosition;
274
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
275
- #endif`,um=`#if NUM_CLIPPING_PLANES > 0
276
- varying vec3 vClipPosition;
277
- #endif`,dm=`#if NUM_CLIPPING_PLANES > 0
278
- vClipPosition = - mvPosition.xyz;
279
- #endif`,fm=`#if defined( USE_COLOR_ALPHA )
280
- diffuseColor *= vColor;
281
- #elif defined( USE_COLOR )
282
- diffuseColor.rgb *= vColor;
283
- #endif`,pm=`#if defined( USE_COLOR_ALPHA )
284
- varying vec4 vColor;
285
- #elif defined( USE_COLOR )
286
- varying vec3 vColor;
287
- #endif`,mm=`#if defined( USE_COLOR_ALPHA )
288
- varying vec4 vColor;
289
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
290
- varying vec3 vColor;
291
- #endif`,gm=`#if defined( USE_COLOR_ALPHA )
292
- vColor = vec4( 1.0 );
293
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
294
- vColor = vec3( 1.0 );
295
- #endif
296
- #ifdef USE_COLOR
297
- vColor *= color;
298
- #endif
299
- #ifdef USE_INSTANCING_COLOR
300
- vColor.xyz *= instanceColor.xyz;
301
- #endif`,_m=`#define PI 3.141592653589793
302
- #define PI2 6.283185307179586
303
- #define PI_HALF 1.5707963267948966
304
- #define RECIPROCAL_PI 0.3183098861837907
305
- #define RECIPROCAL_PI2 0.15915494309189535
306
- #define EPSILON 1e-6
307
- #ifndef saturate
308
- #define saturate( a ) clamp( a, 0.0, 1.0 )
309
- #endif
310
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
311
- float pow2( const in float x ) { return x*x; }
312
- vec3 pow2( const in vec3 x ) { return x*x; }
313
- float pow3( const in float x ) { return x*x*x; }
314
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
315
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
316
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
317
- highp float rand( const in vec2 uv ) {
318
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
319
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
320
- return fract( sin( sn ) * c );
321
- }
322
- #ifdef HIGH_PRECISION
323
- float precisionSafeLength( vec3 v ) { return length( v ); }
324
- #else
325
- float precisionSafeLength( vec3 v ) {
326
- float maxComponent = max3( abs( v ) );
327
- return length( v / maxComponent ) * maxComponent;
328
- }
329
- #endif
330
- struct IncidentLight {
331
- vec3 color;
332
- vec3 direction;
333
- bool visible;
334
- };
335
- struct ReflectedLight {
336
- vec3 directDiffuse;
337
- vec3 directSpecular;
338
- vec3 indirectDiffuse;
339
- vec3 indirectSpecular;
340
- };
341
- #ifdef USE_ALPHAHASH
342
- varying vec3 vPosition;
343
- #endif
344
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
345
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
346
- }
347
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
348
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
349
- }
350
- mat3 transposeMat3( const in mat3 m ) {
351
- mat3 tmp;
352
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
353
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
354
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
355
- return tmp;
356
- }
357
- float luminance( const in vec3 rgb ) {
358
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
359
- return dot( weights, rgb );
360
- }
361
- bool isPerspectiveMatrix( mat4 m ) {
362
- return m[ 2 ][ 3 ] == - 1.0;
363
- }
364
- vec2 equirectUv( in vec3 dir ) {
365
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
366
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
367
- return vec2( u, v );
368
- }
369
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
370
- return RECIPROCAL_PI * diffuseColor;
371
- }
372
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
373
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
374
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
375
- }
376
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
377
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
378
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
379
- } // validated`,xm=`#ifdef ENVMAP_TYPE_CUBE_UV
380
- #define cubeUV_minMipLevel 4.0
381
- #define cubeUV_minTileSize 16.0
382
- float getFace( vec3 direction ) {
383
- vec3 absDirection = abs( direction );
384
- float face = - 1.0;
385
- if ( absDirection.x > absDirection.z ) {
386
- if ( absDirection.x > absDirection.y )
387
- face = direction.x > 0.0 ? 0.0 : 3.0;
388
- else
389
- face = direction.y > 0.0 ? 1.0 : 4.0;
390
- } else {
391
- if ( absDirection.z > absDirection.y )
392
- face = direction.z > 0.0 ? 2.0 : 5.0;
393
- else
394
- face = direction.y > 0.0 ? 1.0 : 4.0;
395
- }
396
- return face;
397
- }
398
- vec2 getUV( vec3 direction, float face ) {
399
- vec2 uv;
400
- if ( face == 0.0 ) {
401
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
402
- } else if ( face == 1.0 ) {
403
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
404
- } else if ( face == 2.0 ) {
405
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
406
- } else if ( face == 3.0 ) {
407
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
408
- } else if ( face == 4.0 ) {
409
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
410
- } else {
411
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
412
- }
413
- return 0.5 * ( uv + 1.0 );
414
- }
415
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
416
- float face = getFace( direction );
417
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
418
- mipInt = max( mipInt, cubeUV_minMipLevel );
419
- float faceSize = exp2( mipInt );
420
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
421
- if ( face > 2.0 ) {
422
- uv.y += faceSize;
423
- face -= 3.0;
424
- }
425
- uv.x += face * faceSize;
426
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
427
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
428
- uv.x *= CUBEUV_TEXEL_WIDTH;
429
- uv.y *= CUBEUV_TEXEL_HEIGHT;
430
- #ifdef texture2DGradEXT
431
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
432
- #else
433
- return texture2D( envMap, uv ).rgb;
434
- #endif
435
- }
436
- #define cubeUV_r0 1.0
437
- #define cubeUV_m0 - 2.0
438
- #define cubeUV_r1 0.8
439
- #define cubeUV_m1 - 1.0
440
- #define cubeUV_r4 0.4
441
- #define cubeUV_m4 2.0
442
- #define cubeUV_r5 0.305
443
- #define cubeUV_m5 3.0
444
- #define cubeUV_r6 0.21
445
- #define cubeUV_m6 4.0
446
- float roughnessToMip( float roughness ) {
447
- float mip = 0.0;
448
- if ( roughness >= cubeUV_r1 ) {
449
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
450
- } else if ( roughness >= cubeUV_r4 ) {
451
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
452
- } else if ( roughness >= cubeUV_r5 ) {
453
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
454
- } else if ( roughness >= cubeUV_r6 ) {
455
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
456
- } else {
457
- mip = - 2.0 * log2( 1.16 * roughness ); }
458
- return mip;
459
- }
460
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
461
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
462
- float mipF = fract( mip );
463
- float mipInt = floor( mip );
464
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
465
- if ( mipF == 0.0 ) {
466
- return vec4( color0, 1.0 );
467
- } else {
468
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
469
- return vec4( mix( color0, color1, mipF ), 1.0 );
470
- }
471
- }
472
- #endif`,vm=`vec3 transformedNormal = objectNormal;
473
- #ifdef USE_TANGENT
474
- vec3 transformedTangent = objectTangent;
475
- #endif
476
- #ifdef USE_BATCHING
477
- mat3 bm = mat3( batchingMatrix );
478
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
479
- transformedNormal = bm * transformedNormal;
480
- #ifdef USE_TANGENT
481
- transformedTangent = bm * transformedTangent;
482
- #endif
483
- #endif
484
- #ifdef USE_INSTANCING
485
- mat3 im = mat3( instanceMatrix );
486
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
487
- transformedNormal = im * transformedNormal;
488
- #ifdef USE_TANGENT
489
- transformedTangent = im * transformedTangent;
490
- #endif
491
- #endif
492
- transformedNormal = normalMatrix * transformedNormal;
493
- #ifdef FLIP_SIDED
494
- transformedNormal = - transformedNormal;
495
- #endif
496
- #ifdef USE_TANGENT
497
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
498
- #ifdef FLIP_SIDED
499
- transformedTangent = - transformedTangent;
500
- #endif
501
- #endif`,ym=`#ifdef USE_DISPLACEMENTMAP
502
- uniform sampler2D displacementMap;
503
- uniform float displacementScale;
504
- uniform float displacementBias;
505
- #endif`,Mm=`#ifdef USE_DISPLACEMENTMAP
506
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
507
- #endif`,Sm=`#ifdef USE_EMISSIVEMAP
508
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
509
- totalEmissiveRadiance *= emissiveColor.rgb;
510
- #endif`,bm=`#ifdef USE_EMISSIVEMAP
511
- uniform sampler2D emissiveMap;
512
- #endif`,Em="gl_FragColor = linearToOutputTexel( gl_FragColor );",wm=`
513
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
514
- vec3( 0.8224621, 0.177538, 0.0 ),
515
- vec3( 0.0331941, 0.9668058, 0.0 ),
516
- vec3( 0.0170827, 0.0723974, 0.9105199 )
517
- );
518
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
519
- vec3( 1.2249401, - 0.2249404, 0.0 ),
520
- vec3( - 0.0420569, 1.0420571, 0.0 ),
521
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
522
- );
523
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
524
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
525
- }
526
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
527
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
528
- }
529
- vec4 LinearTransferOETF( in vec4 value ) {
530
- return value;
531
- }
532
- vec4 sRGBTransferOETF( in vec4 value ) {
533
- 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 );
534
- }
535
- vec4 LinearToLinear( in vec4 value ) {
536
- return value;
537
- }
538
- vec4 LinearTosRGB( in vec4 value ) {
539
- return sRGBTransferOETF( value );
540
- }`,Am=`#ifdef USE_ENVMAP
541
- #ifdef ENV_WORLDPOS
542
- vec3 cameraToFrag;
543
- if ( isOrthographic ) {
544
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
545
- } else {
546
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
547
- }
548
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
549
- #ifdef ENVMAP_MODE_REFLECTION
550
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
551
- #else
552
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
553
- #endif
554
- #else
555
- vec3 reflectVec = vReflect;
556
- #endif
557
- #ifdef ENVMAP_TYPE_CUBE
558
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
559
- #else
560
- vec4 envColor = vec4( 0.0 );
561
- #endif
562
- #ifdef ENVMAP_BLENDING_MULTIPLY
563
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
564
- #elif defined( ENVMAP_BLENDING_MIX )
565
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
566
- #elif defined( ENVMAP_BLENDING_ADD )
567
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
568
- #endif
569
- #endif`,Tm=`#ifdef USE_ENVMAP
570
- uniform float envMapIntensity;
571
- uniform float flipEnvMap;
572
- uniform mat3 envMapRotation;
573
- #ifdef ENVMAP_TYPE_CUBE
574
- uniform samplerCube envMap;
575
- #else
576
- uniform sampler2D envMap;
577
- #endif
578
-
579
- #endif`,Rm=`#ifdef USE_ENVMAP
580
- uniform float reflectivity;
581
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
582
- #define ENV_WORLDPOS
583
- #endif
584
- #ifdef ENV_WORLDPOS
585
- varying vec3 vWorldPosition;
586
- uniform float refractionRatio;
587
- #else
588
- varying vec3 vReflect;
589
- #endif
590
- #endif`,Cm=`#ifdef USE_ENVMAP
591
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
592
- #define ENV_WORLDPOS
593
- #endif
594
- #ifdef ENV_WORLDPOS
595
-
596
- varying vec3 vWorldPosition;
597
- #else
598
- varying vec3 vReflect;
599
- uniform float refractionRatio;
600
- #endif
601
- #endif`,Pm=`#ifdef USE_ENVMAP
602
- #ifdef ENV_WORLDPOS
603
- vWorldPosition = worldPosition.xyz;
604
- #else
605
- vec3 cameraToVertex;
606
- if ( isOrthographic ) {
607
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
608
- } else {
609
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
610
- }
611
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
612
- #ifdef ENVMAP_MODE_REFLECTION
613
- vReflect = reflect( cameraToVertex, worldNormal );
614
- #else
615
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
616
- #endif
617
- #endif
618
- #endif`,Im=`#ifdef USE_FOG
619
- vFogDepth = - mvPosition.z;
620
- #endif`,Lm=`#ifdef USE_FOG
621
- varying float vFogDepth;
622
- #endif`,Um=`#ifdef USE_FOG
623
- #ifdef FOG_EXP2
624
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
625
- #else
626
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
627
- #endif
628
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
629
- #endif`,Dm=`#ifdef USE_FOG
630
- uniform vec3 fogColor;
631
- varying float vFogDepth;
632
- #ifdef FOG_EXP2
633
- uniform float fogDensity;
634
- #else
635
- uniform float fogNear;
636
- uniform float fogFar;
637
- #endif
638
- #endif`,Nm=`#ifdef USE_GRADIENTMAP
639
- uniform sampler2D gradientMap;
640
- #endif
641
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
642
- float dotNL = dot( normal, lightDirection );
643
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
644
- #ifdef USE_GRADIENTMAP
645
- return vec3( texture2D( gradientMap, coord ).r );
646
- #else
647
- vec2 fw = fwidth( coord ) * 0.5;
648
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
649
- #endif
650
- }`,Om=`#ifdef USE_LIGHTMAP
651
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
652
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
653
- reflectedLight.indirectDiffuse += lightMapIrradiance;
654
- #endif`,Fm=`#ifdef USE_LIGHTMAP
655
- uniform sampler2D lightMap;
656
- uniform float lightMapIntensity;
657
- #endif`,Bm=`LambertMaterial material;
658
- material.diffuseColor = diffuseColor.rgb;
659
- material.specularStrength = specularStrength;`,zm=`varying vec3 vViewPosition;
660
- struct LambertMaterial {
661
- vec3 diffuseColor;
662
- float specularStrength;
663
- };
664
- 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 ) {
665
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
666
- vec3 irradiance = dotNL * directLight.color;
667
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
668
- }
669
- 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 ) {
670
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
671
- }
672
- #define RE_Direct RE_Direct_Lambert
673
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,km=`uniform bool receiveShadow;
674
- uniform vec3 ambientLightColor;
675
- #if defined( USE_LIGHT_PROBES )
676
- uniform vec3 lightProbe[ 9 ];
677
- #endif
678
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
679
- float x = normal.x, y = normal.y, z = normal.z;
680
- vec3 result = shCoefficients[ 0 ] * 0.886227;
681
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
682
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
683
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
684
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
685
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
686
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
687
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
688
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
689
- return result;
690
- }
691
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
692
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
693
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
694
- return irradiance;
695
- }
696
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
697
- vec3 irradiance = ambientLightColor;
698
- return irradiance;
699
- }
700
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
701
- #if defined ( LEGACY_LIGHTS )
702
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
703
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
704
- }
705
- return 1.0;
706
- #else
707
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
708
- if ( cutoffDistance > 0.0 ) {
709
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
710
- }
711
- return distanceFalloff;
712
- #endif
713
- }
714
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
715
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
716
- }
717
- #if NUM_DIR_LIGHTS > 0
718
- struct DirectionalLight {
719
- vec3 direction;
720
- vec3 color;
721
- };
722
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
723
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
724
- light.color = directionalLight.color;
725
- light.direction = directionalLight.direction;
726
- light.visible = true;
727
- }
728
- #endif
729
- #if NUM_POINT_LIGHTS > 0
730
- struct PointLight {
731
- vec3 position;
732
- vec3 color;
733
- float distance;
734
- float decay;
735
- };
736
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
737
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
738
- vec3 lVector = pointLight.position - geometryPosition;
739
- light.direction = normalize( lVector );
740
- float lightDistance = length( lVector );
741
- light.color = pointLight.color;
742
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
743
- light.visible = ( light.color != vec3( 0.0 ) );
744
- }
745
- #endif
746
- #if NUM_SPOT_LIGHTS > 0
747
- struct SpotLight {
748
- vec3 position;
749
- vec3 direction;
750
- vec3 color;
751
- float distance;
752
- float decay;
753
- float coneCos;
754
- float penumbraCos;
755
- };
756
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
757
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
758
- vec3 lVector = spotLight.position - geometryPosition;
759
- light.direction = normalize( lVector );
760
- float angleCos = dot( light.direction, spotLight.direction );
761
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
762
- if ( spotAttenuation > 0.0 ) {
763
- float lightDistance = length( lVector );
764
- light.color = spotLight.color * spotAttenuation;
765
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
766
- light.visible = ( light.color != vec3( 0.0 ) );
767
- } else {
768
- light.color = vec3( 0.0 );
769
- light.visible = false;
770
- }
771
- }
772
- #endif
773
- #if NUM_RECT_AREA_LIGHTS > 0
774
- struct RectAreaLight {
775
- vec3 color;
776
- vec3 position;
777
- vec3 halfWidth;
778
- vec3 halfHeight;
779
- };
780
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
781
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
782
- #endif
783
- #if NUM_HEMI_LIGHTS > 0
784
- struct HemisphereLight {
785
- vec3 direction;
786
- vec3 skyColor;
787
- vec3 groundColor;
788
- };
789
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
790
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
791
- float dotNL = dot( normal, hemiLight.direction );
792
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
793
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
794
- return irradiance;
795
- }
796
- #endif`,Vm=`#ifdef USE_ENVMAP
797
- vec3 getIBLIrradiance( const in vec3 normal ) {
798
- #ifdef ENVMAP_TYPE_CUBE_UV
799
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
800
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
801
- return PI * envMapColor.rgb * envMapIntensity;
802
- #else
803
- return vec3( 0.0 );
804
- #endif
805
- }
806
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
807
- #ifdef ENVMAP_TYPE_CUBE_UV
808
- vec3 reflectVec = reflect( - viewDir, normal );
809
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
810
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
811
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
812
- return envMapColor.rgb * envMapIntensity;
813
- #else
814
- return vec3( 0.0 );
815
- #endif
816
- }
817
- #ifdef USE_ANISOTROPY
818
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
819
- #ifdef ENVMAP_TYPE_CUBE_UV
820
- vec3 bentNormal = cross( bitangent, viewDir );
821
- bentNormal = normalize( cross( bentNormal, bitangent ) );
822
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
823
- return getIBLRadiance( viewDir, bentNormal, roughness );
824
- #else
825
- return vec3( 0.0 );
826
- #endif
827
- }
828
- #endif
829
- #endif`,Hm=`ToonMaterial material;
830
- material.diffuseColor = diffuseColor.rgb;`,Gm=`varying vec3 vViewPosition;
831
- struct ToonMaterial {
832
- vec3 diffuseColor;
833
- };
834
- 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 ) {
835
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
836
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
837
- }
838
- 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 ) {
839
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
840
- }
841
- #define RE_Direct RE_Direct_Toon
842
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Wm=`BlinnPhongMaterial material;
843
- material.diffuseColor = diffuseColor.rgb;
844
- material.specularColor = specular;
845
- material.specularShininess = shininess;
846
- material.specularStrength = specularStrength;`,Xm=`varying vec3 vViewPosition;
847
- struct BlinnPhongMaterial {
848
- vec3 diffuseColor;
849
- vec3 specularColor;
850
- float specularShininess;
851
- float specularStrength;
852
- };
853
- 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 ) {
854
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
855
- vec3 irradiance = dotNL * directLight.color;
856
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
857
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
858
- }
859
- 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 ) {
860
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
861
- }
862
- #define RE_Direct RE_Direct_BlinnPhong
863
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qm=`PhysicalMaterial material;
864
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
865
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
866
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
867
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
868
- material.roughness = min( material.roughness, 1.0 );
869
- #ifdef IOR
870
- material.ior = ior;
871
- #ifdef USE_SPECULAR
872
- float specularIntensityFactor = specularIntensity;
873
- vec3 specularColorFactor = specularColor;
874
- #ifdef USE_SPECULAR_COLORMAP
875
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
876
- #endif
877
- #ifdef USE_SPECULAR_INTENSITYMAP
878
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
879
- #endif
880
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
881
- #else
882
- float specularIntensityFactor = 1.0;
883
- vec3 specularColorFactor = vec3( 1.0 );
884
- material.specularF90 = 1.0;
885
- #endif
886
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
887
- #else
888
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
889
- material.specularF90 = 1.0;
890
- #endif
891
- #ifdef USE_CLEARCOAT
892
- material.clearcoat = clearcoat;
893
- material.clearcoatRoughness = clearcoatRoughness;
894
- material.clearcoatF0 = vec3( 0.04 );
895
- material.clearcoatF90 = 1.0;
896
- #ifdef USE_CLEARCOATMAP
897
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
898
- #endif
899
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
900
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
901
- #endif
902
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
903
- material.clearcoatRoughness += geometryRoughness;
904
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
905
- #endif
906
- #ifdef USE_IRIDESCENCE
907
- material.iridescence = iridescence;
908
- material.iridescenceIOR = iridescenceIOR;
909
- #ifdef USE_IRIDESCENCEMAP
910
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
911
- #endif
912
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
913
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
914
- #else
915
- material.iridescenceThickness = iridescenceThicknessMaximum;
916
- #endif
917
- #endif
918
- #ifdef USE_SHEEN
919
- material.sheenColor = sheenColor;
920
- #ifdef USE_SHEEN_COLORMAP
921
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
922
- #endif
923
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
924
- #ifdef USE_SHEEN_ROUGHNESSMAP
925
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
926
- #endif
927
- #endif
928
- #ifdef USE_ANISOTROPY
929
- #ifdef USE_ANISOTROPYMAP
930
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
931
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
932
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
933
- #else
934
- vec2 anisotropyV = anisotropyVector;
935
- #endif
936
- material.anisotropy = length( anisotropyV );
937
- if( material.anisotropy == 0.0 ) {
938
- anisotropyV = vec2( 1.0, 0.0 );
939
- } else {
940
- anisotropyV /= material.anisotropy;
941
- material.anisotropy = saturate( material.anisotropy );
942
- }
943
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
944
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
945
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
946
- #endif`,Ym=`struct PhysicalMaterial {
947
- vec3 diffuseColor;
948
- float roughness;
949
- vec3 specularColor;
950
- float specularF90;
951
- #ifdef USE_CLEARCOAT
952
- float clearcoat;
953
- float clearcoatRoughness;
954
- vec3 clearcoatF0;
955
- float clearcoatF90;
956
- #endif
957
- #ifdef USE_IRIDESCENCE
958
- float iridescence;
959
- float iridescenceIOR;
960
- float iridescenceThickness;
961
- vec3 iridescenceFresnel;
962
- vec3 iridescenceF0;
963
- #endif
964
- #ifdef USE_SHEEN
965
- vec3 sheenColor;
966
- float sheenRoughness;
967
- #endif
968
- #ifdef IOR
969
- float ior;
970
- #endif
971
- #ifdef USE_TRANSMISSION
972
- float transmission;
973
- float transmissionAlpha;
974
- float thickness;
975
- float attenuationDistance;
976
- vec3 attenuationColor;
977
- #endif
978
- #ifdef USE_ANISOTROPY
979
- float anisotropy;
980
- float alphaT;
981
- vec3 anisotropyT;
982
- vec3 anisotropyB;
983
- #endif
984
- };
985
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
986
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
987
- vec3 sheenSpecularDirect = vec3( 0.0 );
988
- vec3 sheenSpecularIndirect = vec3(0.0 );
989
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
990
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
991
- float x2 = x * x;
992
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
993
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
994
- }
995
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
996
- float a2 = pow2( alpha );
997
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
998
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
999
- return 0.5 / max( gv + gl, EPSILON );
1000
- }
1001
- float D_GGX( const in float alpha, const in float dotNH ) {
1002
- float a2 = pow2( alpha );
1003
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1004
- return RECIPROCAL_PI * a2 / pow2( denom );
1005
- }
1006
- #ifdef USE_ANISOTROPY
1007
- 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 ) {
1008
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1009
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1010
- float v = 0.5 / ( gv + gl );
1011
- return saturate(v);
1012
- }
1013
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1014
- float a2 = alphaT * alphaB;
1015
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1016
- highp float v2 = dot( v, v );
1017
- float w2 = a2 / v2;
1018
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
1019
- }
1020
- #endif
1021
- #ifdef USE_CLEARCOAT
1022
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1023
- vec3 f0 = material.clearcoatF0;
1024
- float f90 = material.clearcoatF90;
1025
- float roughness = material.clearcoatRoughness;
1026
- float alpha = pow2( roughness );
1027
- vec3 halfDir = normalize( lightDir + viewDir );
1028
- float dotNL = saturate( dot( normal, lightDir ) );
1029
- float dotNV = saturate( dot( normal, viewDir ) );
1030
- float dotNH = saturate( dot( normal, halfDir ) );
1031
- float dotVH = saturate( dot( viewDir, halfDir ) );
1032
- vec3 F = F_Schlick( f0, f90, dotVH );
1033
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1034
- float D = D_GGX( alpha, dotNH );
1035
- return F * ( V * D );
1036
- }
1037
- #endif
1038
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1039
- vec3 f0 = material.specularColor;
1040
- float f90 = material.specularF90;
1041
- float roughness = material.roughness;
1042
- float alpha = pow2( roughness );
1043
- vec3 halfDir = normalize( lightDir + viewDir );
1044
- float dotNL = saturate( dot( normal, lightDir ) );
1045
- float dotNV = saturate( dot( normal, viewDir ) );
1046
- float dotNH = saturate( dot( normal, halfDir ) );
1047
- float dotVH = saturate( dot( viewDir, halfDir ) );
1048
- vec3 F = F_Schlick( f0, f90, dotVH );
1049
- #ifdef USE_IRIDESCENCE
1050
- F = mix( F, material.iridescenceFresnel, material.iridescence );
1051
- #endif
1052
- #ifdef USE_ANISOTROPY
1053
- float dotTL = dot( material.anisotropyT, lightDir );
1054
- float dotTV = dot( material.anisotropyT, viewDir );
1055
- float dotTH = dot( material.anisotropyT, halfDir );
1056
- float dotBL = dot( material.anisotropyB, lightDir );
1057
- float dotBV = dot( material.anisotropyB, viewDir );
1058
- float dotBH = dot( material.anisotropyB, halfDir );
1059
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1060
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1061
- #else
1062
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1063
- float D = D_GGX( alpha, dotNH );
1064
- #endif
1065
- return F * ( V * D );
1066
- }
1067
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1068
- const float LUT_SIZE = 64.0;
1069
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1070
- const float LUT_BIAS = 0.5 / LUT_SIZE;
1071
- float dotNV = saturate( dot( N, V ) );
1072
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1073
- uv = uv * LUT_SCALE + LUT_BIAS;
1074
- return uv;
1075
- }
1076
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1077
- float l = length( f );
1078
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1079
- }
1080
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1081
- float x = dot( v1, v2 );
1082
- float y = abs( x );
1083
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1084
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
1085
- float v = a / b;
1086
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1087
- return cross( v1, v2 ) * theta_sintheta;
1088
- }
1089
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1090
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1091
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1092
- vec3 lightNormal = cross( v1, v2 );
1093
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1094
- vec3 T1, T2;
1095
- T1 = normalize( V - N * dot( V, N ) );
1096
- T2 = - cross( N, T1 );
1097
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1098
- vec3 coords[ 4 ];
1099
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1100
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1101
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1102
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1103
- coords[ 0 ] = normalize( coords[ 0 ] );
1104
- coords[ 1 ] = normalize( coords[ 1 ] );
1105
- coords[ 2 ] = normalize( coords[ 2 ] );
1106
- coords[ 3 ] = normalize( coords[ 3 ] );
1107
- vec3 vectorFormFactor = vec3( 0.0 );
1108
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1109
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1110
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1111
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1112
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1113
- return vec3( result );
1114
- }
1115
- #if defined( USE_SHEEN )
1116
- float D_Charlie( float roughness, float dotNH ) {
1117
- float alpha = pow2( roughness );
1118
- float invAlpha = 1.0 / alpha;
1119
- float cos2h = dotNH * dotNH;
1120
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
1121
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1122
- }
1123
- float V_Neubelt( float dotNV, float dotNL ) {
1124
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1125
- }
1126
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1127
- vec3 halfDir = normalize( lightDir + viewDir );
1128
- float dotNL = saturate( dot( normal, lightDir ) );
1129
- float dotNV = saturate( dot( normal, viewDir ) );
1130
- float dotNH = saturate( dot( normal, halfDir ) );
1131
- float D = D_Charlie( sheenRoughness, dotNH );
1132
- float V = V_Neubelt( dotNV, dotNL );
1133
- return sheenColor * ( D * V );
1134
- }
1135
- #endif
1136
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1137
- float dotNV = saturate( dot( normal, viewDir ) );
1138
- float r2 = roughness * roughness;
1139
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1140
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1141
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1142
- return saturate( DG * RECIPROCAL_PI );
1143
- }
1144
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1145
- float dotNV = saturate( dot( normal, viewDir ) );
1146
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1147
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1148
- vec4 r = roughness * c0 + c1;
1149
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1150
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1151
- return fab;
1152
- }
1153
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1154
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1155
- return specularColor * fab.x + specularF90 * fab.y;
1156
- }
1157
- #ifdef USE_IRIDESCENCE
1158
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1159
- #else
1160
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1161
- #endif
1162
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1163
- #ifdef USE_IRIDESCENCE
1164
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1165
- #else
1166
- vec3 Fr = specularColor;
1167
- #endif
1168
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1169
- float Ess = fab.x + fab.y;
1170
- float Ems = 1.0 - Ess;
1171
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1172
- singleScatter += FssEss;
1173
- multiScatter += Fms * Ems;
1174
- }
1175
- #if NUM_RECT_AREA_LIGHTS > 0
1176
- 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 ) {
1177
- vec3 normal = geometryNormal;
1178
- vec3 viewDir = geometryViewDir;
1179
- vec3 position = geometryPosition;
1180
- vec3 lightPos = rectAreaLight.position;
1181
- vec3 halfWidth = rectAreaLight.halfWidth;
1182
- vec3 halfHeight = rectAreaLight.halfHeight;
1183
- vec3 lightColor = rectAreaLight.color;
1184
- float roughness = material.roughness;
1185
- vec3 rectCoords[ 4 ];
1186
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1187
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1188
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1189
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
1190
- vec4 t1 = texture2D( ltc_1, uv );
1191
- vec4 t2 = texture2D( ltc_2, uv );
1192
- mat3 mInv = mat3(
1193
- vec3( t1.x, 0, t1.y ),
1194
- vec3( 0, 1, 0 ),
1195
- vec3( t1.z, 0, t1.w )
1196
- );
1197
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1198
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1199
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1200
- }
1201
- #endif
1202
- 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 ) {
1203
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1204
- vec3 irradiance = dotNL * directLight.color;
1205
- #ifdef USE_CLEARCOAT
1206
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1207
- vec3 ccIrradiance = dotNLcc * directLight.color;
1208
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1209
- #endif
1210
- #ifdef USE_SHEEN
1211
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1212
- #endif
1213
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1214
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1215
- }
1216
- 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 ) {
1217
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1218
- }
1219
- 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) {
1220
- #ifdef USE_CLEARCOAT
1221
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1222
- #endif
1223
- #ifdef USE_SHEEN
1224
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1225
- #endif
1226
- vec3 singleScattering = vec3( 0.0 );
1227
- vec3 multiScattering = vec3( 0.0 );
1228
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1229
- #ifdef USE_IRIDESCENCE
1230
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1231
- #else
1232
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1233
- #endif
1234
- vec3 totalScattering = singleScattering + multiScattering;
1235
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1236
- reflectedLight.indirectSpecular += radiance * singleScattering;
1237
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1238
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1239
- }
1240
- #define RE_Direct RE_Direct_Physical
1241
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1242
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1243
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1244
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1245
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1246
- }`,Zm=`
1247
- vec3 geometryPosition = - vViewPosition;
1248
- vec3 geometryNormal = normal;
1249
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1250
- vec3 geometryClearcoatNormal = vec3( 0.0 );
1251
- #ifdef USE_CLEARCOAT
1252
- geometryClearcoatNormal = clearcoatNormal;
1253
- #endif
1254
- #ifdef USE_IRIDESCENCE
1255
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
1256
- if ( material.iridescenceThickness == 0.0 ) {
1257
- material.iridescence = 0.0;
1258
- } else {
1259
- material.iridescence = saturate( material.iridescence );
1260
- }
1261
- if ( material.iridescence > 0.0 ) {
1262
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1263
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1264
- }
1265
- #endif
1266
- IncidentLight directLight;
1267
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1268
- PointLight pointLight;
1269
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1270
- PointLightShadow pointLightShadow;
1271
- #endif
1272
- #pragma unroll_loop_start
1273
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1274
- pointLight = pointLights[ i ];
1275
- getPointLightInfo( pointLight, geometryPosition, directLight );
1276
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1277
- pointLightShadow = pointLightShadows[ i ];
1278
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1279
- #endif
1280
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1281
- }
1282
- #pragma unroll_loop_end
1283
- #endif
1284
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1285
- SpotLight spotLight;
1286
- vec4 spotColor;
1287
- vec3 spotLightCoord;
1288
- bool inSpotLightMap;
1289
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1290
- SpotLightShadow spotLightShadow;
1291
- #endif
1292
- #pragma unroll_loop_start
1293
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1294
- spotLight = spotLights[ i ];
1295
- getSpotLightInfo( spotLight, geometryPosition, directLight );
1296
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1297
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1298
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1299
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1300
- #else
1301
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1302
- #endif
1303
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1304
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1305
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1306
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1307
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1308
- #endif
1309
- #undef SPOT_LIGHT_MAP_INDEX
1310
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1311
- spotLightShadow = spotLightShadows[ i ];
1312
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1313
- #endif
1314
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1315
- }
1316
- #pragma unroll_loop_end
1317
- #endif
1318
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1319
- DirectionalLight directionalLight;
1320
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1321
- DirectionalLightShadow directionalLightShadow;
1322
- #endif
1323
- #pragma unroll_loop_start
1324
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1325
- directionalLight = directionalLights[ i ];
1326
- getDirectionalLightInfo( directionalLight, directLight );
1327
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1328
- directionalLightShadow = directionalLightShadows[ i ];
1329
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1330
- #endif
1331
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1332
- }
1333
- #pragma unroll_loop_end
1334
- #endif
1335
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1336
- RectAreaLight rectAreaLight;
1337
- #pragma unroll_loop_start
1338
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1339
- rectAreaLight = rectAreaLights[ i ];
1340
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1341
- }
1342
- #pragma unroll_loop_end
1343
- #endif
1344
- #if defined( RE_IndirectDiffuse )
1345
- vec3 iblIrradiance = vec3( 0.0 );
1346
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1347
- #if defined( USE_LIGHT_PROBES )
1348
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1349
- #endif
1350
- #if ( NUM_HEMI_LIGHTS > 0 )
1351
- #pragma unroll_loop_start
1352
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1353
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1354
- }
1355
- #pragma unroll_loop_end
1356
- #endif
1357
- #endif
1358
- #if defined( RE_IndirectSpecular )
1359
- vec3 radiance = vec3( 0.0 );
1360
- vec3 clearcoatRadiance = vec3( 0.0 );
1361
- #endif`,Jm=`#if defined( RE_IndirectDiffuse )
1362
- #ifdef USE_LIGHTMAP
1363
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1364
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1365
- irradiance += lightMapIrradiance;
1366
- #endif
1367
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1368
- iblIrradiance += getIBLIrradiance( geometryNormal );
1369
- #endif
1370
- #endif
1371
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1372
- #ifdef USE_ANISOTROPY
1373
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1374
- #else
1375
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1376
- #endif
1377
- #ifdef USE_CLEARCOAT
1378
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1379
- #endif
1380
- #endif`,$m=`#if defined( RE_IndirectDiffuse )
1381
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1382
- #endif
1383
- #if defined( RE_IndirectSpecular )
1384
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1385
- #endif`,Km=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1386
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1387
- #endif`,Qm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1388
- uniform float logDepthBufFC;
1389
- varying float vFragDepth;
1390
- varying float vIsPerspective;
1391
- #endif`,jm=`#ifdef USE_LOGDEPTHBUF
1392
- #ifdef USE_LOGDEPTHBUF_EXT
1393
- varying float vFragDepth;
1394
- varying float vIsPerspective;
1395
- #else
1396
- uniform float logDepthBufFC;
1397
- #endif
1398
- #endif`,tg=`#ifdef USE_LOGDEPTHBUF
1399
- #ifdef USE_LOGDEPTHBUF_EXT
1400
- vFragDepth = 1.0 + gl_Position.w;
1401
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1402
- #else
1403
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
1404
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
1405
- gl_Position.z *= gl_Position.w;
1406
- }
1407
- #endif
1408
- #endif`,eg=`#ifdef USE_MAP
1409
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1410
- #ifdef DECODE_VIDEO_TEXTURE
1411
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
1412
-
1413
- #endif
1414
- diffuseColor *= sampledDiffuseColor;
1415
- #endif`,ng=`#ifdef USE_MAP
1416
- uniform sampler2D map;
1417
- #endif`,ig=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1418
- #if defined( USE_POINTS_UV )
1419
- vec2 uv = vUv;
1420
- #else
1421
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1422
- #endif
1423
- #endif
1424
- #ifdef USE_MAP
1425
- diffuseColor *= texture2D( map, uv );
1426
- #endif
1427
- #ifdef USE_ALPHAMAP
1428
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
1429
- #endif`,sg=`#if defined( USE_POINTS_UV )
1430
- varying vec2 vUv;
1431
- #else
1432
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1433
- uniform mat3 uvTransform;
1434
- #endif
1435
- #endif
1436
- #ifdef USE_MAP
1437
- uniform sampler2D map;
1438
- #endif
1439
- #ifdef USE_ALPHAMAP
1440
- uniform sampler2D alphaMap;
1441
- #endif`,rg=`float metalnessFactor = metalness;
1442
- #ifdef USE_METALNESSMAP
1443
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1444
- metalnessFactor *= texelMetalness.b;
1445
- #endif`,ag=`#ifdef USE_METALNESSMAP
1446
- uniform sampler2D metalnessMap;
1447
- #endif`,og=`#ifdef USE_INSTANCING_MORPH
1448
- float morphTargetInfluences[MORPHTARGETS_COUNT];
1449
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1450
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1451
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1452
- }
1453
- #endif`,cg=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1454
- vColor *= morphTargetBaseInfluence;
1455
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
- #if defined( USE_COLOR_ALPHA )
1457
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1458
- #elif defined( USE_COLOR )
1459
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1460
- #endif
1461
- }
1462
- #endif`,lg=`#ifdef USE_MORPHNORMALS
1463
- objectNormal *= morphTargetBaseInfluence;
1464
- #ifdef MORPHTARGETS_TEXTURE
1465
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1466
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1467
- }
1468
- #else
1469
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
1470
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
1471
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
1472
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
1473
- #endif
1474
- #endif`,hg=`#ifdef USE_MORPHTARGETS
1475
- #ifndef USE_INSTANCING_MORPH
1476
- uniform float morphTargetBaseInfluence;
1477
- #endif
1478
- #ifdef MORPHTARGETS_TEXTURE
1479
- #ifndef USE_INSTANCING_MORPH
1480
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1481
- #endif
1482
- uniform sampler2DArray morphTargetsTexture;
1483
- uniform ivec2 morphTargetsTextureSize;
1484
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1485
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1486
- int y = texelIndex / morphTargetsTextureSize.x;
1487
- int x = texelIndex - y * morphTargetsTextureSize.x;
1488
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1489
- return texelFetch( morphTargetsTexture, morphUV, 0 );
1490
- }
1491
- #else
1492
- #ifndef USE_MORPHNORMALS
1493
- uniform float morphTargetInfluences[ 8 ];
1494
- #else
1495
- uniform float morphTargetInfluences[ 4 ];
1496
- #endif
1497
- #endif
1498
- #endif`,ug=`#ifdef USE_MORPHTARGETS
1499
- transformed *= morphTargetBaseInfluence;
1500
- #ifdef MORPHTARGETS_TEXTURE
1501
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1502
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1503
- }
1504
- #else
1505
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
1506
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
1507
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
1508
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
1509
- #ifndef USE_MORPHNORMALS
1510
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
1511
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
1512
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
1513
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
1514
- #endif
1515
- #endif
1516
- #endif`,dg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1517
- #ifdef FLAT_SHADED
1518
- vec3 fdx = dFdx( vViewPosition );
1519
- vec3 fdy = dFdy( vViewPosition );
1520
- vec3 normal = normalize( cross( fdx, fdy ) );
1521
- #else
1522
- vec3 normal = normalize( vNormal );
1523
- #ifdef DOUBLE_SIDED
1524
- normal *= faceDirection;
1525
- #endif
1526
- #endif
1527
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1528
- #ifdef USE_TANGENT
1529
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1530
- #else
1531
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
1532
- #if defined( USE_NORMALMAP )
1533
- vNormalMapUv
1534
- #elif defined( USE_CLEARCOAT_NORMALMAP )
1535
- vClearcoatNormalMapUv
1536
- #else
1537
- vUv
1538
- #endif
1539
- );
1540
- #endif
1541
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1542
- tbn[0] *= faceDirection;
1543
- tbn[1] *= faceDirection;
1544
- #endif
1545
- #endif
1546
- #ifdef USE_CLEARCOAT_NORMALMAP
1547
- #ifdef USE_TANGENT
1548
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1549
- #else
1550
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1551
- #endif
1552
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1553
- tbn2[0] *= faceDirection;
1554
- tbn2[1] *= faceDirection;
1555
- #endif
1556
- #endif
1557
- vec3 nonPerturbedNormal = normal;`,fg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1558
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1559
- #ifdef FLIP_SIDED
1560
- normal = - normal;
1561
- #endif
1562
- #ifdef DOUBLE_SIDED
1563
- normal = normal * faceDirection;
1564
- #endif
1565
- normal = normalize( normalMatrix * normal );
1566
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
1567
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1568
- mapN.xy *= normalScale;
1569
- normal = normalize( tbn * mapN );
1570
- #elif defined( USE_BUMPMAP )
1571
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1572
- #endif`,pg=`#ifndef FLAT_SHADED
1573
- varying vec3 vNormal;
1574
- #ifdef USE_TANGENT
1575
- varying vec3 vTangent;
1576
- varying vec3 vBitangent;
1577
- #endif
1578
- #endif`,mg=`#ifndef FLAT_SHADED
1579
- varying vec3 vNormal;
1580
- #ifdef USE_TANGENT
1581
- varying vec3 vTangent;
1582
- varying vec3 vBitangent;
1583
- #endif
1584
- #endif`,gg=`#ifndef FLAT_SHADED
1585
- vNormal = normalize( transformedNormal );
1586
- #ifdef USE_TANGENT
1587
- vTangent = normalize( transformedTangent );
1588
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1589
- #endif
1590
- #endif`,_g=`#ifdef USE_NORMALMAP
1591
- uniform sampler2D normalMap;
1592
- uniform vec2 normalScale;
1593
- #endif
1594
- #ifdef USE_NORMALMAP_OBJECTSPACE
1595
- uniform mat3 normalMatrix;
1596
- #endif
1597
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1598
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1599
- vec3 q0 = dFdx( eye_pos.xyz );
1600
- vec3 q1 = dFdy( eye_pos.xyz );
1601
- vec2 st0 = dFdx( uv.st );
1602
- vec2 st1 = dFdy( uv.st );
1603
- vec3 N = surf_norm;
1604
- vec3 q1perp = cross( q1, N );
1605
- vec3 q0perp = cross( N, q0 );
1606
- vec3 T = q1perp * st0.x + q0perp * st1.x;
1607
- vec3 B = q1perp * st0.y + q0perp * st1.y;
1608
- float det = max( dot( T, T ), dot( B, B ) );
1609
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1610
- return mat3( T * scale, B * scale, N );
1611
- }
1612
- #endif`,xg=`#ifdef USE_CLEARCOAT
1613
- vec3 clearcoatNormal = nonPerturbedNormal;
1614
- #endif`,vg=`#ifdef USE_CLEARCOAT_NORMALMAP
1615
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1616
- clearcoatMapN.xy *= clearcoatNormalScale;
1617
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1618
- #endif`,yg=`#ifdef USE_CLEARCOATMAP
1619
- uniform sampler2D clearcoatMap;
1620
- #endif
1621
- #ifdef USE_CLEARCOAT_NORMALMAP
1622
- uniform sampler2D clearcoatNormalMap;
1623
- uniform vec2 clearcoatNormalScale;
1624
- #endif
1625
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1626
- uniform sampler2D clearcoatRoughnessMap;
1627
- #endif`,Mg=`#ifdef USE_IRIDESCENCEMAP
1628
- uniform sampler2D iridescenceMap;
1629
- #endif
1630
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
1631
- uniform sampler2D iridescenceThicknessMap;
1632
- #endif`,Sg=`#ifdef OPAQUE
1633
- diffuseColor.a = 1.0;
1634
- #endif
1635
- #ifdef USE_TRANSMISSION
1636
- diffuseColor.a *= material.transmissionAlpha;
1637
- #endif
1638
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bg=`vec3 packNormalToRGB( const in vec3 normal ) {
1639
- return normalize( normal ) * 0.5 + 0.5;
1640
- }
1641
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
1642
- return 2.0 * rgb.xyz - 1.0;
1643
- }
1644
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
1645
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
1646
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
1647
- const float ShiftRight8 = 1. / 256.;
1648
- vec4 packDepthToRGBA( const in float v ) {
1649
- vec4 r = vec4( fract( v * PackFactors ), v );
1650
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
1651
- }
1652
- float unpackRGBAToDepth( const in vec4 v ) {
1653
- return dot( v, UnpackFactors );
1654
- }
1655
- vec2 packDepthToRG( in highp float v ) {
1656
- return packDepthToRGBA( v ).yx;
1657
- }
1658
- float unpackRGToDepth( const in highp vec2 v ) {
1659
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
1660
- }
1661
- vec4 pack2HalfToRGBA( vec2 v ) {
1662
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1663
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1664
- }
1665
- vec2 unpackRGBATo2Half( vec4 v ) {
1666
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1667
- }
1668
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1669
- return ( viewZ + near ) / ( near - far );
1670
- }
1671
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1672
- return depth * ( near - far ) - near;
1673
- }
1674
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1675
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1676
- }
1677
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1678
- return ( near * far ) / ( ( far - near ) * depth - far );
1679
- }`,Eg=`#ifdef PREMULTIPLIED_ALPHA
1680
- gl_FragColor.rgb *= gl_FragColor.a;
1681
- #endif`,wg=`vec4 mvPosition = vec4( transformed, 1.0 );
1682
- #ifdef USE_BATCHING
1683
- mvPosition = batchingMatrix * mvPosition;
1684
- #endif
1685
- #ifdef USE_INSTANCING
1686
- mvPosition = instanceMatrix * mvPosition;
1687
- #endif
1688
- mvPosition = modelViewMatrix * mvPosition;
1689
- gl_Position = projectionMatrix * mvPosition;`,Ag=`#ifdef DITHERING
1690
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1691
- #endif`,Tg=`#ifdef DITHERING
1692
- vec3 dithering( vec3 color ) {
1693
- float grid_position = rand( gl_FragCoord.xy );
1694
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1695
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1696
- return color + dither_shift_RGB;
1697
- }
1698
- #endif`,Rg=`float roughnessFactor = roughness;
1699
- #ifdef USE_ROUGHNESSMAP
1700
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1701
- roughnessFactor *= texelRoughness.g;
1702
- #endif`,Cg=`#ifdef USE_ROUGHNESSMAP
1703
- uniform sampler2D roughnessMap;
1704
- #endif`,Pg=`#if NUM_SPOT_LIGHT_COORDS > 0
1705
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1706
- #endif
1707
- #if NUM_SPOT_LIGHT_MAPS > 0
1708
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1709
- #endif
1710
- #ifdef USE_SHADOWMAP
1711
- #if NUM_DIR_LIGHT_SHADOWS > 0
1712
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1713
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1714
- struct DirectionalLightShadow {
1715
- float shadowBias;
1716
- float shadowNormalBias;
1717
- float shadowRadius;
1718
- vec2 shadowMapSize;
1719
- };
1720
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1721
- #endif
1722
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1723
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1724
- struct SpotLightShadow {
1725
- float shadowBias;
1726
- float shadowNormalBias;
1727
- float shadowRadius;
1728
- vec2 shadowMapSize;
1729
- };
1730
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1731
- #endif
1732
- #if NUM_POINT_LIGHT_SHADOWS > 0
1733
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1734
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1735
- struct PointLightShadow {
1736
- float shadowBias;
1737
- float shadowNormalBias;
1738
- float shadowRadius;
1739
- vec2 shadowMapSize;
1740
- float shadowCameraNear;
1741
- float shadowCameraFar;
1742
- };
1743
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1744
- #endif
1745
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1746
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1747
- }
1748
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1749
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
1750
- }
1751
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1752
- float occlusion = 1.0;
1753
- vec2 distribution = texture2DDistribution( shadow, uv );
1754
- float hard_shadow = step( compare , distribution.x );
1755
- if (hard_shadow != 1.0 ) {
1756
- float distance = compare - distribution.x ;
1757
- float variance = max( 0.00000, distribution.y * distribution.y );
1758
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1759
- }
1760
- return occlusion;
1761
- }
1762
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1763
- float shadow = 1.0;
1764
- shadowCoord.xyz /= shadowCoord.w;
1765
- shadowCoord.z += shadowBias;
1766
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1767
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1768
- if ( frustumTest ) {
1769
- #if defined( SHADOWMAP_TYPE_PCF )
1770
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1771
- float dx0 = - texelSize.x * shadowRadius;
1772
- float dy0 = - texelSize.y * shadowRadius;
1773
- float dx1 = + texelSize.x * shadowRadius;
1774
- float dy1 = + texelSize.y * shadowRadius;
1775
- float dx2 = dx0 / 2.0;
1776
- float dy2 = dy0 / 2.0;
1777
- float dx3 = dx1 / 2.0;
1778
- float dy3 = dy1 / 2.0;
1779
- shadow = (
1780
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1781
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1782
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1783
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1784
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1785
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1786
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1787
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1788
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1789
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1790
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1791
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1792
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1793
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1794
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1795
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1796
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1797
- ) * ( 1.0 / 17.0 );
1798
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1799
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1800
- float dx = texelSize.x;
1801
- float dy = texelSize.y;
1802
- vec2 uv = shadowCoord.xy;
1803
- vec2 f = fract( uv * shadowMapSize + 0.5 );
1804
- uv -= f * texelSize;
1805
- shadow = (
1806
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1807
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1808
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1809
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1810
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1811
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1812
- f.x ) +
1813
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1814
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1815
- f.x ) +
1816
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1817
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1818
- f.y ) +
1819
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1820
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1821
- f.y ) +
1822
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1823
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1824
- f.x ),
1825
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1826
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1827
- f.x ),
1828
- f.y )
1829
- ) * ( 1.0 / 9.0 );
1830
- #elif defined( SHADOWMAP_TYPE_VSM )
1831
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1832
- #else
1833
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1834
- #endif
1835
- }
1836
- return shadow;
1837
- }
1838
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
1839
- vec3 absV = abs( v );
1840
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1841
- absV *= scaleToCube;
1842
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1843
- vec2 planar = v.xy;
1844
- float almostATexel = 1.5 * texelSizeY;
1845
- float almostOne = 1.0 - almostATexel;
1846
- if ( absV.z >= almostOne ) {
1847
- if ( v.z > 0.0 )
1848
- planar.x = 4.0 - v.x;
1849
- } else if ( absV.x >= almostOne ) {
1850
- float signX = sign( v.x );
1851
- planar.x = v.z * signX + 2.0 * signX;
1852
- } else if ( absV.y >= almostOne ) {
1853
- float signY = sign( v.y );
1854
- planar.x = v.x + 2.0 * signY + 2.0;
1855
- planar.y = v.z * signY - 2.0;
1856
- }
1857
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1858
- }
1859
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1860
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1861
- vec3 lightToPosition = shadowCoord.xyz;
1862
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1863
- vec3 bd3D = normalize( lightToPosition );
1864
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1865
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1866
- return (
1867
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1868
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1869
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1870
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1871
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1872
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1873
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1874
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1875
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1876
- ) * ( 1.0 / 9.0 );
1877
- #else
1878
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1879
- #endif
1880
- }
1881
- #endif`,Ig=`#if NUM_SPOT_LIGHT_COORDS > 0
1882
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1883
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1884
- #endif
1885
- #ifdef USE_SHADOWMAP
1886
- #if NUM_DIR_LIGHT_SHADOWS > 0
1887
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1888
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1889
- struct DirectionalLightShadow {
1890
- float shadowBias;
1891
- float shadowNormalBias;
1892
- float shadowRadius;
1893
- vec2 shadowMapSize;
1894
- };
1895
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1896
- #endif
1897
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1898
- struct SpotLightShadow {
1899
- float shadowBias;
1900
- float shadowNormalBias;
1901
- float shadowRadius;
1902
- vec2 shadowMapSize;
1903
- };
1904
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1905
- #endif
1906
- #if NUM_POINT_LIGHT_SHADOWS > 0
1907
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1908
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1909
- struct PointLightShadow {
1910
- float shadowBias;
1911
- float shadowNormalBias;
1912
- float shadowRadius;
1913
- vec2 shadowMapSize;
1914
- float shadowCameraNear;
1915
- float shadowCameraFar;
1916
- };
1917
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1918
- #endif
1919
- #endif`,Lg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1920
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1921
- vec4 shadowWorldPosition;
1922
- #endif
1923
- #if defined( USE_SHADOWMAP )
1924
- #if NUM_DIR_LIGHT_SHADOWS > 0
1925
- #pragma unroll_loop_start
1926
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1927
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1928
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1929
- }
1930
- #pragma unroll_loop_end
1931
- #endif
1932
- #if NUM_POINT_LIGHT_SHADOWS > 0
1933
- #pragma unroll_loop_start
1934
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1935
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1936
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1937
- }
1938
- #pragma unroll_loop_end
1939
- #endif
1940
- #endif
1941
- #if NUM_SPOT_LIGHT_COORDS > 0
1942
- #pragma unroll_loop_start
1943
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1944
- shadowWorldPosition = worldPosition;
1945
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1946
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1947
- #endif
1948
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1949
- }
1950
- #pragma unroll_loop_end
1951
- #endif`,Ug=`float getShadowMask() {
1952
- float shadow = 1.0;
1953
- #ifdef USE_SHADOWMAP
1954
- #if NUM_DIR_LIGHT_SHADOWS > 0
1955
- DirectionalLightShadow directionalLight;
1956
- #pragma unroll_loop_start
1957
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1958
- directionalLight = directionalLightShadows[ i ];
1959
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1960
- }
1961
- #pragma unroll_loop_end
1962
- #endif
1963
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1964
- SpotLightShadow spotLight;
1965
- #pragma unroll_loop_start
1966
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1967
- spotLight = spotLightShadows[ i ];
1968
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1969
- }
1970
- #pragma unroll_loop_end
1971
- #endif
1972
- #if NUM_POINT_LIGHT_SHADOWS > 0
1973
- PointLightShadow pointLight;
1974
- #pragma unroll_loop_start
1975
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1976
- pointLight = pointLightShadows[ i ];
1977
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1978
- }
1979
- #pragma unroll_loop_end
1980
- #endif
1981
- #endif
1982
- return shadow;
1983
- }`,Dg=`#ifdef USE_SKINNING
1984
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
1985
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
1986
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1987
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
1988
- #endif`,Ng=`#ifdef USE_SKINNING
1989
- uniform mat4 bindMatrix;
1990
- uniform mat4 bindMatrixInverse;
1991
- uniform highp sampler2D boneTexture;
1992
- mat4 getBoneMatrix( const in float i ) {
1993
- int size = textureSize( boneTexture, 0 ).x;
1994
- int j = int( i ) * 4;
1995
- int x = j % size;
1996
- int y = j / size;
1997
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1998
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1999
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2000
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2001
- return mat4( v1, v2, v3, v4 );
2002
- }
2003
- #endif`,Og=`#ifdef USE_SKINNING
2004
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2005
- vec4 skinned = vec4( 0.0 );
2006
- skinned += boneMatX * skinVertex * skinWeight.x;
2007
- skinned += boneMatY * skinVertex * skinWeight.y;
2008
- skinned += boneMatZ * skinVertex * skinWeight.z;
2009
- skinned += boneMatW * skinVertex * skinWeight.w;
2010
- transformed = ( bindMatrixInverse * skinned ).xyz;
2011
- #endif`,Fg=`#ifdef USE_SKINNING
2012
- mat4 skinMatrix = mat4( 0.0 );
2013
- skinMatrix += skinWeight.x * boneMatX;
2014
- skinMatrix += skinWeight.y * boneMatY;
2015
- skinMatrix += skinWeight.z * boneMatZ;
2016
- skinMatrix += skinWeight.w * boneMatW;
2017
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2018
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2019
- #ifdef USE_TANGENT
2020
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2021
- #endif
2022
- #endif`,Bg=`float specularStrength;
2023
- #ifdef USE_SPECULARMAP
2024
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2025
- specularStrength = texelSpecular.r;
2026
- #else
2027
- specularStrength = 1.0;
2028
- #endif`,zg=`#ifdef USE_SPECULARMAP
2029
- uniform sampler2D specularMap;
2030
- #endif`,kg=`#if defined( TONE_MAPPING )
2031
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2032
- #endif`,Vg=`#ifndef saturate
2033
- #define saturate( a ) clamp( a, 0.0, 1.0 )
2034
- #endif
2035
- uniform float toneMappingExposure;
2036
- vec3 LinearToneMapping( vec3 color ) {
2037
- return saturate( toneMappingExposure * color );
2038
- }
2039
- vec3 ReinhardToneMapping( vec3 color ) {
2040
- color *= toneMappingExposure;
2041
- return saturate( color / ( vec3( 1.0 ) + color ) );
2042
- }
2043
- vec3 OptimizedCineonToneMapping( vec3 color ) {
2044
- color *= toneMappingExposure;
2045
- color = max( vec3( 0.0 ), color - 0.004 );
2046
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2047
- }
2048
- vec3 RRTAndODTFit( vec3 v ) {
2049
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2050
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2051
- return a / b;
2052
- }
2053
- vec3 ACESFilmicToneMapping( vec3 color ) {
2054
- const mat3 ACESInputMat = mat3(
2055
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2056
- vec3( 0.04823, 0.01566, 0.83777 )
2057
- );
2058
- const mat3 ACESOutputMat = mat3(
2059
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2060
- vec3( -0.07367, -0.00605, 1.07602 )
2061
- );
2062
- color *= toneMappingExposure / 0.6;
2063
- color = ACESInputMat * color;
2064
- color = RRTAndODTFit( color );
2065
- color = ACESOutputMat * color;
2066
- return saturate( color );
2067
- }
2068
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2069
- vec3( 1.6605, - 0.1246, - 0.0182 ),
2070
- vec3( - 0.5876, 1.1329, - 0.1006 ),
2071
- vec3( - 0.0728, - 0.0083, 1.1187 )
2072
- );
2073
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2074
- vec3( 0.6274, 0.0691, 0.0164 ),
2075
- vec3( 0.3293, 0.9195, 0.0880 ),
2076
- vec3( 0.0433, 0.0113, 0.8956 )
2077
- );
2078
- vec3 agxDefaultContrastApprox( vec3 x ) {
2079
- vec3 x2 = x * x;
2080
- vec3 x4 = x2 * x2;
2081
- return + 15.5 * x4 * x2
2082
- - 40.14 * x4 * x
2083
- + 31.96 * x4
2084
- - 6.868 * x2 * x
2085
- + 0.4298 * x2
2086
- + 0.1191 * x
2087
- - 0.00232;
2088
- }
2089
- vec3 AgXToneMapping( vec3 color ) {
2090
- const mat3 AgXInsetMatrix = mat3(
2091
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2092
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2093
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2094
- );
2095
- const mat3 AgXOutsetMatrix = mat3(
2096
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2097
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2098
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2099
- );
2100
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2101
- color *= toneMappingExposure;
2102
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2103
- color = AgXInsetMatrix * color;
2104
- color = max( color, 1e-10 ); color = log2( color );
2105
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2106
- color = clamp( color, 0.0, 1.0 );
2107
- color = agxDefaultContrastApprox( color );
2108
- color = AgXOutsetMatrix * color;
2109
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2110
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2111
- color = clamp( color, 0.0, 1.0 );
2112
- return color;
2113
- }
2114
- vec3 NeutralToneMapping( vec3 color ) {
2115
- float startCompression = 0.8 - 0.04;
2116
- float desaturation = 0.15;
2117
- color *= toneMappingExposure;
2118
- float x = min(color.r, min(color.g, color.b));
2119
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2120
- color -= offset;
2121
- float peak = max(color.r, max(color.g, color.b));
2122
- if (peak < startCompression) return color;
2123
- float d = 1. - startCompression;
2124
- float newPeak = 1. - d * d / (peak + d - startCompression);
2125
- color *= newPeak / peak;
2126
- float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
2127
- return mix(color, vec3(1, 1, 1), g);
2128
- }
2129
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Hg=`#ifdef USE_TRANSMISSION
2130
- material.transmission = transmission;
2131
- material.transmissionAlpha = 1.0;
2132
- material.thickness = thickness;
2133
- material.attenuationDistance = attenuationDistance;
2134
- material.attenuationColor = attenuationColor;
2135
- #ifdef USE_TRANSMISSIONMAP
2136
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2137
- #endif
2138
- #ifdef USE_THICKNESSMAP
2139
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2140
- #endif
2141
- vec3 pos = vWorldPosition;
2142
- vec3 v = normalize( cameraPosition - pos );
2143
- vec3 n = inverseTransformDirection( normal, viewMatrix );
2144
- vec4 transmitted = getIBLVolumeRefraction(
2145
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2146
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
2147
- material.attenuationColor, material.attenuationDistance );
2148
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2149
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2150
- #endif`,Gg=`#ifdef USE_TRANSMISSION
2151
- uniform float transmission;
2152
- uniform float thickness;
2153
- uniform float attenuationDistance;
2154
- uniform vec3 attenuationColor;
2155
- #ifdef USE_TRANSMISSIONMAP
2156
- uniform sampler2D transmissionMap;
2157
- #endif
2158
- #ifdef USE_THICKNESSMAP
2159
- uniform sampler2D thicknessMap;
2160
- #endif
2161
- uniform vec2 transmissionSamplerSize;
2162
- uniform sampler2D transmissionSamplerMap;
2163
- uniform mat4 modelMatrix;
2164
- uniform mat4 projectionMatrix;
2165
- varying vec3 vWorldPosition;
2166
- float w0( float a ) {
2167
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2168
- }
2169
- float w1( float a ) {
2170
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2171
- }
2172
- float w2( float a ){
2173
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2174
- }
2175
- float w3( float a ) {
2176
- return ( 1.0 / 6.0 ) * ( a * a * a );
2177
- }
2178
- float g0( float a ) {
2179
- return w0( a ) + w1( a );
2180
- }
2181
- float g1( float a ) {
2182
- return w2( a ) + w3( a );
2183
- }
2184
- float h0( float a ) {
2185
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2186
- }
2187
- float h1( float a ) {
2188
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2189
- }
2190
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2191
- uv = uv * texelSize.zw + 0.5;
2192
- vec2 iuv = floor( uv );
2193
- vec2 fuv = fract( uv );
2194
- float g0x = g0( fuv.x );
2195
- float g1x = g1( fuv.x );
2196
- float h0x = h0( fuv.x );
2197
- float h1x = h1( fuv.x );
2198
- float h0y = h0( fuv.y );
2199
- float h1y = h1( fuv.y );
2200
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2201
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2202
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2203
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2204
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2205
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2206
- }
2207
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2208
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2209
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2210
- vec2 fLodSizeInv = 1.0 / fLodSize;
2211
- vec2 cLodSizeInv = 1.0 / cLodSize;
2212
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2213
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2214
- return mix( fSample, cSample, fract( lod ) );
2215
- }
2216
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2217
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2218
- vec3 modelScale;
2219
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2220
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2221
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2222
- return normalize( refractionVector ) * thickness * modelScale;
2223
- }
2224
- float applyIorToRoughness( const in float roughness, const in float ior ) {
2225
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2226
- }
2227
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2228
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2229
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2230
- }
2231
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2232
- if ( isinf( attenuationDistance ) ) {
2233
- return vec3( 1.0 );
2234
- } else {
2235
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2236
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2237
- }
2238
- }
2239
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2240
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2241
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
2242
- const in vec3 attenuationColor, const in float attenuationDistance ) {
2243
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2244
- vec3 refractedRayExit = position + transmissionRay;
2245
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2246
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2247
- refractionCoords += 1.0;
2248
- refractionCoords /= 2.0;
2249
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2250
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2251
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2252
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2253
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2254
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2255
- }
2256
- #endif`,Wg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2257
- varying vec2 vUv;
2258
- #endif
2259
- #ifdef USE_MAP
2260
- varying vec2 vMapUv;
2261
- #endif
2262
- #ifdef USE_ALPHAMAP
2263
- varying vec2 vAlphaMapUv;
2264
- #endif
2265
- #ifdef USE_LIGHTMAP
2266
- varying vec2 vLightMapUv;
2267
- #endif
2268
- #ifdef USE_AOMAP
2269
- varying vec2 vAoMapUv;
2270
- #endif
2271
- #ifdef USE_BUMPMAP
2272
- varying vec2 vBumpMapUv;
2273
- #endif
2274
- #ifdef USE_NORMALMAP
2275
- varying vec2 vNormalMapUv;
2276
- #endif
2277
- #ifdef USE_EMISSIVEMAP
2278
- varying vec2 vEmissiveMapUv;
2279
- #endif
2280
- #ifdef USE_METALNESSMAP
2281
- varying vec2 vMetalnessMapUv;
2282
- #endif
2283
- #ifdef USE_ROUGHNESSMAP
2284
- varying vec2 vRoughnessMapUv;
2285
- #endif
2286
- #ifdef USE_ANISOTROPYMAP
2287
- varying vec2 vAnisotropyMapUv;
2288
- #endif
2289
- #ifdef USE_CLEARCOATMAP
2290
- varying vec2 vClearcoatMapUv;
2291
- #endif
2292
- #ifdef USE_CLEARCOAT_NORMALMAP
2293
- varying vec2 vClearcoatNormalMapUv;
2294
- #endif
2295
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2296
- varying vec2 vClearcoatRoughnessMapUv;
2297
- #endif
2298
- #ifdef USE_IRIDESCENCEMAP
2299
- varying vec2 vIridescenceMapUv;
2300
- #endif
2301
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2302
- varying vec2 vIridescenceThicknessMapUv;
2303
- #endif
2304
- #ifdef USE_SHEEN_COLORMAP
2305
- varying vec2 vSheenColorMapUv;
2306
- #endif
2307
- #ifdef USE_SHEEN_ROUGHNESSMAP
2308
- varying vec2 vSheenRoughnessMapUv;
2309
- #endif
2310
- #ifdef USE_SPECULARMAP
2311
- varying vec2 vSpecularMapUv;
2312
- #endif
2313
- #ifdef USE_SPECULAR_COLORMAP
2314
- varying vec2 vSpecularColorMapUv;
2315
- #endif
2316
- #ifdef USE_SPECULAR_INTENSITYMAP
2317
- varying vec2 vSpecularIntensityMapUv;
2318
- #endif
2319
- #ifdef USE_TRANSMISSIONMAP
2320
- uniform mat3 transmissionMapTransform;
2321
- varying vec2 vTransmissionMapUv;
2322
- #endif
2323
- #ifdef USE_THICKNESSMAP
2324
- uniform mat3 thicknessMapTransform;
2325
- varying vec2 vThicknessMapUv;
2326
- #endif`,Xg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2327
- varying vec2 vUv;
2328
- #endif
2329
- #ifdef USE_MAP
2330
- uniform mat3 mapTransform;
2331
- varying vec2 vMapUv;
2332
- #endif
2333
- #ifdef USE_ALPHAMAP
2334
- uniform mat3 alphaMapTransform;
2335
- varying vec2 vAlphaMapUv;
2336
- #endif
2337
- #ifdef USE_LIGHTMAP
2338
- uniform mat3 lightMapTransform;
2339
- varying vec2 vLightMapUv;
2340
- #endif
2341
- #ifdef USE_AOMAP
2342
- uniform mat3 aoMapTransform;
2343
- varying vec2 vAoMapUv;
2344
- #endif
2345
- #ifdef USE_BUMPMAP
2346
- uniform mat3 bumpMapTransform;
2347
- varying vec2 vBumpMapUv;
2348
- #endif
2349
- #ifdef USE_NORMALMAP
2350
- uniform mat3 normalMapTransform;
2351
- varying vec2 vNormalMapUv;
2352
- #endif
2353
- #ifdef USE_DISPLACEMENTMAP
2354
- uniform mat3 displacementMapTransform;
2355
- varying vec2 vDisplacementMapUv;
2356
- #endif
2357
- #ifdef USE_EMISSIVEMAP
2358
- uniform mat3 emissiveMapTransform;
2359
- varying vec2 vEmissiveMapUv;
2360
- #endif
2361
- #ifdef USE_METALNESSMAP
2362
- uniform mat3 metalnessMapTransform;
2363
- varying vec2 vMetalnessMapUv;
2364
- #endif
2365
- #ifdef USE_ROUGHNESSMAP
2366
- uniform mat3 roughnessMapTransform;
2367
- varying vec2 vRoughnessMapUv;
2368
- #endif
2369
- #ifdef USE_ANISOTROPYMAP
2370
- uniform mat3 anisotropyMapTransform;
2371
- varying vec2 vAnisotropyMapUv;
2372
- #endif
2373
- #ifdef USE_CLEARCOATMAP
2374
- uniform mat3 clearcoatMapTransform;
2375
- varying vec2 vClearcoatMapUv;
2376
- #endif
2377
- #ifdef USE_CLEARCOAT_NORMALMAP
2378
- uniform mat3 clearcoatNormalMapTransform;
2379
- varying vec2 vClearcoatNormalMapUv;
2380
- #endif
2381
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2382
- uniform mat3 clearcoatRoughnessMapTransform;
2383
- varying vec2 vClearcoatRoughnessMapUv;
2384
- #endif
2385
- #ifdef USE_SHEEN_COLORMAP
2386
- uniform mat3 sheenColorMapTransform;
2387
- varying vec2 vSheenColorMapUv;
2388
- #endif
2389
- #ifdef USE_SHEEN_ROUGHNESSMAP
2390
- uniform mat3 sheenRoughnessMapTransform;
2391
- varying vec2 vSheenRoughnessMapUv;
2392
- #endif
2393
- #ifdef USE_IRIDESCENCEMAP
2394
- uniform mat3 iridescenceMapTransform;
2395
- varying vec2 vIridescenceMapUv;
2396
- #endif
2397
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2398
- uniform mat3 iridescenceThicknessMapTransform;
2399
- varying vec2 vIridescenceThicknessMapUv;
2400
- #endif
2401
- #ifdef USE_SPECULARMAP
2402
- uniform mat3 specularMapTransform;
2403
- varying vec2 vSpecularMapUv;
2404
- #endif
2405
- #ifdef USE_SPECULAR_COLORMAP
2406
- uniform mat3 specularColorMapTransform;
2407
- varying vec2 vSpecularColorMapUv;
2408
- #endif
2409
- #ifdef USE_SPECULAR_INTENSITYMAP
2410
- uniform mat3 specularIntensityMapTransform;
2411
- varying vec2 vSpecularIntensityMapUv;
2412
- #endif
2413
- #ifdef USE_TRANSMISSIONMAP
2414
- uniform mat3 transmissionMapTransform;
2415
- varying vec2 vTransmissionMapUv;
2416
- #endif
2417
- #ifdef USE_THICKNESSMAP
2418
- uniform mat3 thicknessMapTransform;
2419
- varying vec2 vThicknessMapUv;
2420
- #endif`,qg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2421
- vUv = vec3( uv, 1 ).xy;
2422
- #endif
2423
- #ifdef USE_MAP
2424
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2425
- #endif
2426
- #ifdef USE_ALPHAMAP
2427
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2428
- #endif
2429
- #ifdef USE_LIGHTMAP
2430
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2431
- #endif
2432
- #ifdef USE_AOMAP
2433
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2434
- #endif
2435
- #ifdef USE_BUMPMAP
2436
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2437
- #endif
2438
- #ifdef USE_NORMALMAP
2439
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2440
- #endif
2441
- #ifdef USE_DISPLACEMENTMAP
2442
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2443
- #endif
2444
- #ifdef USE_EMISSIVEMAP
2445
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2446
- #endif
2447
- #ifdef USE_METALNESSMAP
2448
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2449
- #endif
2450
- #ifdef USE_ROUGHNESSMAP
2451
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2452
- #endif
2453
- #ifdef USE_ANISOTROPYMAP
2454
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2455
- #endif
2456
- #ifdef USE_CLEARCOATMAP
2457
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2458
- #endif
2459
- #ifdef USE_CLEARCOAT_NORMALMAP
2460
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2461
- #endif
2462
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2463
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2464
- #endif
2465
- #ifdef USE_IRIDESCENCEMAP
2466
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2467
- #endif
2468
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2469
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2470
- #endif
2471
- #ifdef USE_SHEEN_COLORMAP
2472
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2473
- #endif
2474
- #ifdef USE_SHEEN_ROUGHNESSMAP
2475
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2476
- #endif
2477
- #ifdef USE_SPECULARMAP
2478
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2479
- #endif
2480
- #ifdef USE_SPECULAR_COLORMAP
2481
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2482
- #endif
2483
- #ifdef USE_SPECULAR_INTENSITYMAP
2484
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2485
- #endif
2486
- #ifdef USE_TRANSMISSIONMAP
2487
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2488
- #endif
2489
- #ifdef USE_THICKNESSMAP
2490
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2491
- #endif`,Yg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2492
- vec4 worldPosition = vec4( transformed, 1.0 );
2493
- #ifdef USE_BATCHING
2494
- worldPosition = batchingMatrix * worldPosition;
2495
- #endif
2496
- #ifdef USE_INSTANCING
2497
- worldPosition = instanceMatrix * worldPosition;
2498
- #endif
2499
- worldPosition = modelMatrix * worldPosition;
2500
- #endif`,Zg=`varying vec2 vUv;
2501
- uniform mat3 uvTransform;
2502
- void main() {
2503
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2504
- gl_Position = vec4( position.xy, 1.0, 1.0 );
2505
- }`,Jg=`uniform sampler2D t2D;
2506
- uniform float backgroundIntensity;
2507
- varying vec2 vUv;
2508
- void main() {
2509
- vec4 texColor = texture2D( t2D, vUv );
2510
- #ifdef DECODE_VIDEO_TEXTURE
2511
- 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 );
2512
- #endif
2513
- texColor.rgb *= backgroundIntensity;
2514
- gl_FragColor = texColor;
2515
- #include <tonemapping_fragment>
2516
- #include <colorspace_fragment>
2517
- }`,$g=`varying vec3 vWorldDirection;
2518
- #include <common>
2519
- void main() {
2520
- vWorldDirection = transformDirection( position, modelMatrix );
2521
- #include <begin_vertex>
2522
- #include <project_vertex>
2523
- gl_Position.z = gl_Position.w;
2524
- }`,Kg=`#ifdef ENVMAP_TYPE_CUBE
2525
- uniform samplerCube envMap;
2526
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2527
- uniform sampler2D envMap;
2528
- #endif
2529
- uniform float flipEnvMap;
2530
- uniform float backgroundBlurriness;
2531
- uniform float backgroundIntensity;
2532
- uniform mat3 backgroundRotation;
2533
- varying vec3 vWorldDirection;
2534
- #include <cube_uv_reflection_fragment>
2535
- void main() {
2536
- #ifdef ENVMAP_TYPE_CUBE
2537
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2538
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2539
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2540
- #else
2541
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2542
- #endif
2543
- texColor.rgb *= backgroundIntensity;
2544
- gl_FragColor = texColor;
2545
- #include <tonemapping_fragment>
2546
- #include <colorspace_fragment>
2547
- }`,Qg=`varying vec3 vWorldDirection;
2548
- #include <common>
2549
- void main() {
2550
- vWorldDirection = transformDirection( position, modelMatrix );
2551
- #include <begin_vertex>
2552
- #include <project_vertex>
2553
- gl_Position.z = gl_Position.w;
2554
- }`,jg=`uniform samplerCube tCube;
2555
- uniform float tFlip;
2556
- uniform float opacity;
2557
- varying vec3 vWorldDirection;
2558
- void main() {
2559
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2560
- gl_FragColor = texColor;
2561
- gl_FragColor.a *= opacity;
2562
- #include <tonemapping_fragment>
2563
- #include <colorspace_fragment>
2564
- }`,t_=`#include <common>
2565
- #include <batching_pars_vertex>
2566
- #include <uv_pars_vertex>
2567
- #include <displacementmap_pars_vertex>
2568
- #include <morphtarget_pars_vertex>
2569
- #include <skinning_pars_vertex>
2570
- #include <logdepthbuf_pars_vertex>
2571
- #include <clipping_planes_pars_vertex>
2572
- varying vec2 vHighPrecisionZW;
2573
- void main() {
2574
- #include <uv_vertex>
2575
- #include <batching_vertex>
2576
- #include <skinbase_vertex>
2577
- #include <morphinstance_vertex>
2578
- #ifdef USE_DISPLACEMENTMAP
2579
- #include <beginnormal_vertex>
2580
- #include <morphnormal_vertex>
2581
- #include <skinnormal_vertex>
2582
- #endif
2583
- #include <begin_vertex>
2584
- #include <morphtarget_vertex>
2585
- #include <skinning_vertex>
2586
- #include <displacementmap_vertex>
2587
- #include <project_vertex>
2588
- #include <logdepthbuf_vertex>
2589
- #include <clipping_planes_vertex>
2590
- vHighPrecisionZW = gl_Position.zw;
2591
- }`,e_=`#if DEPTH_PACKING == 3200
2592
- uniform float opacity;
2593
- #endif
2594
- #include <common>
2595
- #include <packing>
2596
- #include <uv_pars_fragment>
2597
- #include <map_pars_fragment>
2598
- #include <alphamap_pars_fragment>
2599
- #include <alphatest_pars_fragment>
2600
- #include <alphahash_pars_fragment>
2601
- #include <logdepthbuf_pars_fragment>
2602
- #include <clipping_planes_pars_fragment>
2603
- varying vec2 vHighPrecisionZW;
2604
- void main() {
2605
- vec4 diffuseColor = vec4( 1.0 );
2606
- #include <clipping_planes_fragment>
2607
- #if DEPTH_PACKING == 3200
2608
- diffuseColor.a = opacity;
2609
- #endif
2610
- #include <map_fragment>
2611
- #include <alphamap_fragment>
2612
- #include <alphatest_fragment>
2613
- #include <alphahash_fragment>
2614
- #include <logdepthbuf_fragment>
2615
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2616
- #if DEPTH_PACKING == 3200
2617
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2618
- #elif DEPTH_PACKING == 3201
2619
- gl_FragColor = packDepthToRGBA( fragCoordZ );
2620
- #endif
2621
- }`,n_=`#define DISTANCE
2622
- varying vec3 vWorldPosition;
2623
- #include <common>
2624
- #include <batching_pars_vertex>
2625
- #include <uv_pars_vertex>
2626
- #include <displacementmap_pars_vertex>
2627
- #include <morphtarget_pars_vertex>
2628
- #include <skinning_pars_vertex>
2629
- #include <clipping_planes_pars_vertex>
2630
- void main() {
2631
- #include <uv_vertex>
2632
- #include <batching_vertex>
2633
- #include <skinbase_vertex>
2634
- #include <morphinstance_vertex>
2635
- #ifdef USE_DISPLACEMENTMAP
2636
- #include <beginnormal_vertex>
2637
- #include <morphnormal_vertex>
2638
- #include <skinnormal_vertex>
2639
- #endif
2640
- #include <begin_vertex>
2641
- #include <morphtarget_vertex>
2642
- #include <skinning_vertex>
2643
- #include <displacementmap_vertex>
2644
- #include <project_vertex>
2645
- #include <worldpos_vertex>
2646
- #include <clipping_planes_vertex>
2647
- vWorldPosition = worldPosition.xyz;
2648
- }`,i_=`#define DISTANCE
2649
- uniform vec3 referencePosition;
2650
- uniform float nearDistance;
2651
- uniform float farDistance;
2652
- varying vec3 vWorldPosition;
2653
- #include <common>
2654
- #include <packing>
2655
- #include <uv_pars_fragment>
2656
- #include <map_pars_fragment>
2657
- #include <alphamap_pars_fragment>
2658
- #include <alphatest_pars_fragment>
2659
- #include <alphahash_pars_fragment>
2660
- #include <clipping_planes_pars_fragment>
2661
- void main () {
2662
- vec4 diffuseColor = vec4( 1.0 );
2663
- #include <clipping_planes_fragment>
2664
- #include <map_fragment>
2665
- #include <alphamap_fragment>
2666
- #include <alphatest_fragment>
2667
- #include <alphahash_fragment>
2668
- float dist = length( vWorldPosition - referencePosition );
2669
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2670
- dist = saturate( dist );
2671
- gl_FragColor = packDepthToRGBA( dist );
2672
- }`,s_=`varying vec3 vWorldDirection;
2673
- #include <common>
2674
- void main() {
2675
- vWorldDirection = transformDirection( position, modelMatrix );
2676
- #include <begin_vertex>
2677
- #include <project_vertex>
2678
- }`,r_=`uniform sampler2D tEquirect;
2679
- varying vec3 vWorldDirection;
2680
- #include <common>
2681
- void main() {
2682
- vec3 direction = normalize( vWorldDirection );
2683
- vec2 sampleUV = equirectUv( direction );
2684
- gl_FragColor = texture2D( tEquirect, sampleUV );
2685
- #include <tonemapping_fragment>
2686
- #include <colorspace_fragment>
2687
- }`,a_=`uniform float scale;
2688
- attribute float lineDistance;
2689
- varying float vLineDistance;
2690
- #include <common>
2691
- #include <uv_pars_vertex>
2692
- #include <color_pars_vertex>
2693
- #include <fog_pars_vertex>
2694
- #include <morphtarget_pars_vertex>
2695
- #include <logdepthbuf_pars_vertex>
2696
- #include <clipping_planes_pars_vertex>
2697
- void main() {
2698
- vLineDistance = scale * lineDistance;
2699
- #include <uv_vertex>
2700
- #include <color_vertex>
2701
- #include <morphinstance_vertex>
2702
- #include <morphcolor_vertex>
2703
- #include <begin_vertex>
2704
- #include <morphtarget_vertex>
2705
- #include <project_vertex>
2706
- #include <logdepthbuf_vertex>
2707
- #include <clipping_planes_vertex>
2708
- #include <fog_vertex>
2709
- }`,o_=`uniform vec3 diffuse;
2710
- uniform float opacity;
2711
- uniform float dashSize;
2712
- uniform float totalSize;
2713
- varying float vLineDistance;
2714
- #include <common>
2715
- #include <color_pars_fragment>
2716
- #include <uv_pars_fragment>
2717
- #include <map_pars_fragment>
2718
- #include <fog_pars_fragment>
2719
- #include <logdepthbuf_pars_fragment>
2720
- #include <clipping_planes_pars_fragment>
2721
- void main() {
2722
- vec4 diffuseColor = vec4( diffuse, opacity );
2723
- #include <clipping_planes_fragment>
2724
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
2725
- discard;
2726
- }
2727
- vec3 outgoingLight = vec3( 0.0 );
2728
- #include <logdepthbuf_fragment>
2729
- #include <map_fragment>
2730
- #include <color_fragment>
2731
- outgoingLight = diffuseColor.rgb;
2732
- #include <opaque_fragment>
2733
- #include <tonemapping_fragment>
2734
- #include <colorspace_fragment>
2735
- #include <fog_fragment>
2736
- #include <premultiplied_alpha_fragment>
2737
- }`,c_=`#include <common>
2738
- #include <batching_pars_vertex>
2739
- #include <uv_pars_vertex>
2740
- #include <envmap_pars_vertex>
2741
- #include <color_pars_vertex>
2742
- #include <fog_pars_vertex>
2743
- #include <morphtarget_pars_vertex>
2744
- #include <skinning_pars_vertex>
2745
- #include <logdepthbuf_pars_vertex>
2746
- #include <clipping_planes_pars_vertex>
2747
- void main() {
2748
- #include <uv_vertex>
2749
- #include <color_vertex>
2750
- #include <morphinstance_vertex>
2751
- #include <morphcolor_vertex>
2752
- #include <batching_vertex>
2753
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2754
- #include <beginnormal_vertex>
2755
- #include <morphnormal_vertex>
2756
- #include <skinbase_vertex>
2757
- #include <skinnormal_vertex>
2758
- #include <defaultnormal_vertex>
2759
- #endif
2760
- #include <begin_vertex>
2761
- #include <morphtarget_vertex>
2762
- #include <skinning_vertex>
2763
- #include <project_vertex>
2764
- #include <logdepthbuf_vertex>
2765
- #include <clipping_planes_vertex>
2766
- #include <worldpos_vertex>
2767
- #include <envmap_vertex>
2768
- #include <fog_vertex>
2769
- }`,l_=`uniform vec3 diffuse;
2770
- uniform float opacity;
2771
- #ifndef FLAT_SHADED
2772
- varying vec3 vNormal;
2773
- #endif
2774
- #include <common>
2775
- #include <dithering_pars_fragment>
2776
- #include <color_pars_fragment>
2777
- #include <uv_pars_fragment>
2778
- #include <map_pars_fragment>
2779
- #include <alphamap_pars_fragment>
2780
- #include <alphatest_pars_fragment>
2781
- #include <alphahash_pars_fragment>
2782
- #include <aomap_pars_fragment>
2783
- #include <lightmap_pars_fragment>
2784
- #include <envmap_common_pars_fragment>
2785
- #include <envmap_pars_fragment>
2786
- #include <fog_pars_fragment>
2787
- #include <specularmap_pars_fragment>
2788
- #include <logdepthbuf_pars_fragment>
2789
- #include <clipping_planes_pars_fragment>
2790
- void main() {
2791
- vec4 diffuseColor = vec4( diffuse, opacity );
2792
- #include <clipping_planes_fragment>
2793
- #include <logdepthbuf_fragment>
2794
- #include <map_fragment>
2795
- #include <color_fragment>
2796
- #include <alphamap_fragment>
2797
- #include <alphatest_fragment>
2798
- #include <alphahash_fragment>
2799
- #include <specularmap_fragment>
2800
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2801
- #ifdef USE_LIGHTMAP
2802
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2803
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2804
- #else
2805
- reflectedLight.indirectDiffuse += vec3( 1.0 );
2806
- #endif
2807
- #include <aomap_fragment>
2808
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2809
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
2810
- #include <envmap_fragment>
2811
- #include <opaque_fragment>
2812
- #include <tonemapping_fragment>
2813
- #include <colorspace_fragment>
2814
- #include <fog_fragment>
2815
- #include <premultiplied_alpha_fragment>
2816
- #include <dithering_fragment>
2817
- }`,h_=`#define LAMBERT
2818
- varying vec3 vViewPosition;
2819
- #include <common>
2820
- #include <batching_pars_vertex>
2821
- #include <uv_pars_vertex>
2822
- #include <displacementmap_pars_vertex>
2823
- #include <envmap_pars_vertex>
2824
- #include <color_pars_vertex>
2825
- #include <fog_pars_vertex>
2826
- #include <normal_pars_vertex>
2827
- #include <morphtarget_pars_vertex>
2828
- #include <skinning_pars_vertex>
2829
- #include <shadowmap_pars_vertex>
2830
- #include <logdepthbuf_pars_vertex>
2831
- #include <clipping_planes_pars_vertex>
2832
- void main() {
2833
- #include <uv_vertex>
2834
- #include <color_vertex>
2835
- #include <morphinstance_vertex>
2836
- #include <morphcolor_vertex>
2837
- #include <batching_vertex>
2838
- #include <beginnormal_vertex>
2839
- #include <morphnormal_vertex>
2840
- #include <skinbase_vertex>
2841
- #include <skinnormal_vertex>
2842
- #include <defaultnormal_vertex>
2843
- #include <normal_vertex>
2844
- #include <begin_vertex>
2845
- #include <morphtarget_vertex>
2846
- #include <skinning_vertex>
2847
- #include <displacementmap_vertex>
2848
- #include <project_vertex>
2849
- #include <logdepthbuf_vertex>
2850
- #include <clipping_planes_vertex>
2851
- vViewPosition = - mvPosition.xyz;
2852
- #include <worldpos_vertex>
2853
- #include <envmap_vertex>
2854
- #include <shadowmap_vertex>
2855
- #include <fog_vertex>
2856
- }`,u_=`#define LAMBERT
2857
- uniform vec3 diffuse;
2858
- uniform vec3 emissive;
2859
- uniform float opacity;
2860
- #include <common>
2861
- #include <packing>
2862
- #include <dithering_pars_fragment>
2863
- #include <color_pars_fragment>
2864
- #include <uv_pars_fragment>
2865
- #include <map_pars_fragment>
2866
- #include <alphamap_pars_fragment>
2867
- #include <alphatest_pars_fragment>
2868
- #include <alphahash_pars_fragment>
2869
- #include <aomap_pars_fragment>
2870
- #include <lightmap_pars_fragment>
2871
- #include <emissivemap_pars_fragment>
2872
- #include <envmap_common_pars_fragment>
2873
- #include <envmap_pars_fragment>
2874
- #include <fog_pars_fragment>
2875
- #include <bsdfs>
2876
- #include <lights_pars_begin>
2877
- #include <normal_pars_fragment>
2878
- #include <lights_lambert_pars_fragment>
2879
- #include <shadowmap_pars_fragment>
2880
- #include <bumpmap_pars_fragment>
2881
- #include <normalmap_pars_fragment>
2882
- #include <specularmap_pars_fragment>
2883
- #include <logdepthbuf_pars_fragment>
2884
- #include <clipping_planes_pars_fragment>
2885
- void main() {
2886
- vec4 diffuseColor = vec4( diffuse, opacity );
2887
- #include <clipping_planes_fragment>
2888
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2889
- vec3 totalEmissiveRadiance = emissive;
2890
- #include <logdepthbuf_fragment>
2891
- #include <map_fragment>
2892
- #include <color_fragment>
2893
- #include <alphamap_fragment>
2894
- #include <alphatest_fragment>
2895
- #include <alphahash_fragment>
2896
- #include <specularmap_fragment>
2897
- #include <normal_fragment_begin>
2898
- #include <normal_fragment_maps>
2899
- #include <emissivemap_fragment>
2900
- #include <lights_lambert_fragment>
2901
- #include <lights_fragment_begin>
2902
- #include <lights_fragment_maps>
2903
- #include <lights_fragment_end>
2904
- #include <aomap_fragment>
2905
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2906
- #include <envmap_fragment>
2907
- #include <opaque_fragment>
2908
- #include <tonemapping_fragment>
2909
- #include <colorspace_fragment>
2910
- #include <fog_fragment>
2911
- #include <premultiplied_alpha_fragment>
2912
- #include <dithering_fragment>
2913
- }`,d_=`#define MATCAP
2914
- varying vec3 vViewPosition;
2915
- #include <common>
2916
- #include <batching_pars_vertex>
2917
- #include <uv_pars_vertex>
2918
- #include <color_pars_vertex>
2919
- #include <displacementmap_pars_vertex>
2920
- #include <fog_pars_vertex>
2921
- #include <normal_pars_vertex>
2922
- #include <morphtarget_pars_vertex>
2923
- #include <skinning_pars_vertex>
2924
- #include <logdepthbuf_pars_vertex>
2925
- #include <clipping_planes_pars_vertex>
2926
- void main() {
2927
- #include <uv_vertex>
2928
- #include <color_vertex>
2929
- #include <morphinstance_vertex>
2930
- #include <morphcolor_vertex>
2931
- #include <batching_vertex>
2932
- #include <beginnormal_vertex>
2933
- #include <morphnormal_vertex>
2934
- #include <skinbase_vertex>
2935
- #include <skinnormal_vertex>
2936
- #include <defaultnormal_vertex>
2937
- #include <normal_vertex>
2938
- #include <begin_vertex>
2939
- #include <morphtarget_vertex>
2940
- #include <skinning_vertex>
2941
- #include <displacementmap_vertex>
2942
- #include <project_vertex>
2943
- #include <logdepthbuf_vertex>
2944
- #include <clipping_planes_vertex>
2945
- #include <fog_vertex>
2946
- vViewPosition = - mvPosition.xyz;
2947
- }`,f_=`#define MATCAP
2948
- uniform vec3 diffuse;
2949
- uniform float opacity;
2950
- uniform sampler2D matcap;
2951
- varying vec3 vViewPosition;
2952
- #include <common>
2953
- #include <dithering_pars_fragment>
2954
- #include <color_pars_fragment>
2955
- #include <uv_pars_fragment>
2956
- #include <map_pars_fragment>
2957
- #include <alphamap_pars_fragment>
2958
- #include <alphatest_pars_fragment>
2959
- #include <alphahash_pars_fragment>
2960
- #include <fog_pars_fragment>
2961
- #include <normal_pars_fragment>
2962
- #include <bumpmap_pars_fragment>
2963
- #include <normalmap_pars_fragment>
2964
- #include <logdepthbuf_pars_fragment>
2965
- #include <clipping_planes_pars_fragment>
2966
- void main() {
2967
- vec4 diffuseColor = vec4( diffuse, opacity );
2968
- #include <clipping_planes_fragment>
2969
- #include <logdepthbuf_fragment>
2970
- #include <map_fragment>
2971
- #include <color_fragment>
2972
- #include <alphamap_fragment>
2973
- #include <alphatest_fragment>
2974
- #include <alphahash_fragment>
2975
- #include <normal_fragment_begin>
2976
- #include <normal_fragment_maps>
2977
- vec3 viewDir = normalize( vViewPosition );
2978
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
2979
- vec3 y = cross( viewDir, x );
2980
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
2981
- #ifdef USE_MATCAP
2982
- vec4 matcapColor = texture2D( matcap, uv );
2983
- #else
2984
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
2985
- #endif
2986
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
2987
- #include <opaque_fragment>
2988
- #include <tonemapping_fragment>
2989
- #include <colorspace_fragment>
2990
- #include <fog_fragment>
2991
- #include <premultiplied_alpha_fragment>
2992
- #include <dithering_fragment>
2993
- }`,p_=`#define NORMAL
2994
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
2995
- varying vec3 vViewPosition;
2996
- #endif
2997
- #include <common>
2998
- #include <batching_pars_vertex>
2999
- #include <uv_pars_vertex>
3000
- #include <displacementmap_pars_vertex>
3001
- #include <normal_pars_vertex>
3002
- #include <morphtarget_pars_vertex>
3003
- #include <skinning_pars_vertex>
3004
- #include <logdepthbuf_pars_vertex>
3005
- #include <clipping_planes_pars_vertex>
3006
- void main() {
3007
- #include <uv_vertex>
3008
- #include <batching_vertex>
3009
- #include <beginnormal_vertex>
3010
- #include <morphinstance_vertex>
3011
- #include <morphnormal_vertex>
3012
- #include <skinbase_vertex>
3013
- #include <skinnormal_vertex>
3014
- #include <defaultnormal_vertex>
3015
- #include <normal_vertex>
3016
- #include <begin_vertex>
3017
- #include <morphtarget_vertex>
3018
- #include <skinning_vertex>
3019
- #include <displacementmap_vertex>
3020
- #include <project_vertex>
3021
- #include <logdepthbuf_vertex>
3022
- #include <clipping_planes_vertex>
3023
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3024
- vViewPosition = - mvPosition.xyz;
3025
- #endif
3026
- }`,m_=`#define NORMAL
3027
- uniform float opacity;
3028
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3029
- varying vec3 vViewPosition;
3030
- #endif
3031
- #include <packing>
3032
- #include <uv_pars_fragment>
3033
- #include <normal_pars_fragment>
3034
- #include <bumpmap_pars_fragment>
3035
- #include <normalmap_pars_fragment>
3036
- #include <logdepthbuf_pars_fragment>
3037
- #include <clipping_planes_pars_fragment>
3038
- void main() {
3039
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3040
- #include <clipping_planes_fragment>
3041
- #include <logdepthbuf_fragment>
3042
- #include <normal_fragment_begin>
3043
- #include <normal_fragment_maps>
3044
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3045
- #ifdef OPAQUE
3046
- gl_FragColor.a = 1.0;
3047
- #endif
3048
- }`,g_=`#define PHONG
3049
- varying vec3 vViewPosition;
3050
- #include <common>
3051
- #include <batching_pars_vertex>
3052
- #include <uv_pars_vertex>
3053
- #include <displacementmap_pars_vertex>
3054
- #include <envmap_pars_vertex>
3055
- #include <color_pars_vertex>
3056
- #include <fog_pars_vertex>
3057
- #include <normal_pars_vertex>
3058
- #include <morphtarget_pars_vertex>
3059
- #include <skinning_pars_vertex>
3060
- #include <shadowmap_pars_vertex>
3061
- #include <logdepthbuf_pars_vertex>
3062
- #include <clipping_planes_pars_vertex>
3063
- void main() {
3064
- #include <uv_vertex>
3065
- #include <color_vertex>
3066
- #include <morphcolor_vertex>
3067
- #include <batching_vertex>
3068
- #include <beginnormal_vertex>
3069
- #include <morphinstance_vertex>
3070
- #include <morphnormal_vertex>
3071
- #include <skinbase_vertex>
3072
- #include <skinnormal_vertex>
3073
- #include <defaultnormal_vertex>
3074
- #include <normal_vertex>
3075
- #include <begin_vertex>
3076
- #include <morphtarget_vertex>
3077
- #include <skinning_vertex>
3078
- #include <displacementmap_vertex>
3079
- #include <project_vertex>
3080
- #include <logdepthbuf_vertex>
3081
- #include <clipping_planes_vertex>
3082
- vViewPosition = - mvPosition.xyz;
3083
- #include <worldpos_vertex>
3084
- #include <envmap_vertex>
3085
- #include <shadowmap_vertex>
3086
- #include <fog_vertex>
3087
- }`,__=`#define PHONG
3088
- uniform vec3 diffuse;
3089
- uniform vec3 emissive;
3090
- uniform vec3 specular;
3091
- uniform float shininess;
3092
- uniform float opacity;
3093
- #include <common>
3094
- #include <packing>
3095
- #include <dithering_pars_fragment>
3096
- #include <color_pars_fragment>
3097
- #include <uv_pars_fragment>
3098
- #include <map_pars_fragment>
3099
- #include <alphamap_pars_fragment>
3100
- #include <alphatest_pars_fragment>
3101
- #include <alphahash_pars_fragment>
3102
- #include <aomap_pars_fragment>
3103
- #include <lightmap_pars_fragment>
3104
- #include <emissivemap_pars_fragment>
3105
- #include <envmap_common_pars_fragment>
3106
- #include <envmap_pars_fragment>
3107
- #include <fog_pars_fragment>
3108
- #include <bsdfs>
3109
- #include <lights_pars_begin>
3110
- #include <normal_pars_fragment>
3111
- #include <lights_phong_pars_fragment>
3112
- #include <shadowmap_pars_fragment>
3113
- #include <bumpmap_pars_fragment>
3114
- #include <normalmap_pars_fragment>
3115
- #include <specularmap_pars_fragment>
3116
- #include <logdepthbuf_pars_fragment>
3117
- #include <clipping_planes_pars_fragment>
3118
- void main() {
3119
- vec4 diffuseColor = vec4( diffuse, opacity );
3120
- #include <clipping_planes_fragment>
3121
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3122
- vec3 totalEmissiveRadiance = emissive;
3123
- #include <logdepthbuf_fragment>
3124
- #include <map_fragment>
3125
- #include <color_fragment>
3126
- #include <alphamap_fragment>
3127
- #include <alphatest_fragment>
3128
- #include <alphahash_fragment>
3129
- #include <specularmap_fragment>
3130
- #include <normal_fragment_begin>
3131
- #include <normal_fragment_maps>
3132
- #include <emissivemap_fragment>
3133
- #include <lights_phong_fragment>
3134
- #include <lights_fragment_begin>
3135
- #include <lights_fragment_maps>
3136
- #include <lights_fragment_end>
3137
- #include <aomap_fragment>
3138
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3139
- #include <envmap_fragment>
3140
- #include <opaque_fragment>
3141
- #include <tonemapping_fragment>
3142
- #include <colorspace_fragment>
3143
- #include <fog_fragment>
3144
- #include <premultiplied_alpha_fragment>
3145
- #include <dithering_fragment>
3146
- }`,x_=`#define STANDARD
3147
- varying vec3 vViewPosition;
3148
- #ifdef USE_TRANSMISSION
3149
- varying vec3 vWorldPosition;
3150
- #endif
3151
- #include <common>
3152
- #include <batching_pars_vertex>
3153
- #include <uv_pars_vertex>
3154
- #include <displacementmap_pars_vertex>
3155
- #include <color_pars_vertex>
3156
- #include <fog_pars_vertex>
3157
- #include <normal_pars_vertex>
3158
- #include <morphtarget_pars_vertex>
3159
- #include <skinning_pars_vertex>
3160
- #include <shadowmap_pars_vertex>
3161
- #include <logdepthbuf_pars_vertex>
3162
- #include <clipping_planes_pars_vertex>
3163
- void main() {
3164
- #include <uv_vertex>
3165
- #include <color_vertex>
3166
- #include <morphinstance_vertex>
3167
- #include <morphcolor_vertex>
3168
- #include <batching_vertex>
3169
- #include <beginnormal_vertex>
3170
- #include <morphnormal_vertex>
3171
- #include <skinbase_vertex>
3172
- #include <skinnormal_vertex>
3173
- #include <defaultnormal_vertex>
3174
- #include <normal_vertex>
3175
- #include <begin_vertex>
3176
- #include <morphtarget_vertex>
3177
- #include <skinning_vertex>
3178
- #include <displacementmap_vertex>
3179
- #include <project_vertex>
3180
- #include <logdepthbuf_vertex>
3181
- #include <clipping_planes_vertex>
3182
- vViewPosition = - mvPosition.xyz;
3183
- #include <worldpos_vertex>
3184
- #include <shadowmap_vertex>
3185
- #include <fog_vertex>
3186
- #ifdef USE_TRANSMISSION
3187
- vWorldPosition = worldPosition.xyz;
3188
- #endif
3189
- }`,v_=`#define STANDARD
3190
- #ifdef PHYSICAL
3191
- #define IOR
3192
- #define USE_SPECULAR
3193
- #endif
3194
- uniform vec3 diffuse;
3195
- uniform vec3 emissive;
3196
- uniform float roughness;
3197
- uniform float metalness;
3198
- uniform float opacity;
3199
- #ifdef IOR
3200
- uniform float ior;
3201
- #endif
3202
- #ifdef USE_SPECULAR
3203
- uniform float specularIntensity;
3204
- uniform vec3 specularColor;
3205
- #ifdef USE_SPECULAR_COLORMAP
3206
- uniform sampler2D specularColorMap;
3207
- #endif
3208
- #ifdef USE_SPECULAR_INTENSITYMAP
3209
- uniform sampler2D specularIntensityMap;
3210
- #endif
3211
- #endif
3212
- #ifdef USE_CLEARCOAT
3213
- uniform float clearcoat;
3214
- uniform float clearcoatRoughness;
3215
- #endif
3216
- #ifdef USE_IRIDESCENCE
3217
- uniform float iridescence;
3218
- uniform float iridescenceIOR;
3219
- uniform float iridescenceThicknessMinimum;
3220
- uniform float iridescenceThicknessMaximum;
3221
- #endif
3222
- #ifdef USE_SHEEN
3223
- uniform vec3 sheenColor;
3224
- uniform float sheenRoughness;
3225
- #ifdef USE_SHEEN_COLORMAP
3226
- uniform sampler2D sheenColorMap;
3227
- #endif
3228
- #ifdef USE_SHEEN_ROUGHNESSMAP
3229
- uniform sampler2D sheenRoughnessMap;
3230
- #endif
3231
- #endif
3232
- #ifdef USE_ANISOTROPY
3233
- uniform vec2 anisotropyVector;
3234
- #ifdef USE_ANISOTROPYMAP
3235
- uniform sampler2D anisotropyMap;
3236
- #endif
3237
- #endif
3238
- varying vec3 vViewPosition;
3239
- #include <common>
3240
- #include <packing>
3241
- #include <dithering_pars_fragment>
3242
- #include <color_pars_fragment>
3243
- #include <uv_pars_fragment>
3244
- #include <map_pars_fragment>
3245
- #include <alphamap_pars_fragment>
3246
- #include <alphatest_pars_fragment>
3247
- #include <alphahash_pars_fragment>
3248
- #include <aomap_pars_fragment>
3249
- #include <lightmap_pars_fragment>
3250
- #include <emissivemap_pars_fragment>
3251
- #include <iridescence_fragment>
3252
- #include <cube_uv_reflection_fragment>
3253
- #include <envmap_common_pars_fragment>
3254
- #include <envmap_physical_pars_fragment>
3255
- #include <fog_pars_fragment>
3256
- #include <lights_pars_begin>
3257
- #include <normal_pars_fragment>
3258
- #include <lights_physical_pars_fragment>
3259
- #include <transmission_pars_fragment>
3260
- #include <shadowmap_pars_fragment>
3261
- #include <bumpmap_pars_fragment>
3262
- #include <normalmap_pars_fragment>
3263
- #include <clearcoat_pars_fragment>
3264
- #include <iridescence_pars_fragment>
3265
- #include <roughnessmap_pars_fragment>
3266
- #include <metalnessmap_pars_fragment>
3267
- #include <logdepthbuf_pars_fragment>
3268
- #include <clipping_planes_pars_fragment>
3269
- void main() {
3270
- vec4 diffuseColor = vec4( diffuse, opacity );
3271
- #include <clipping_planes_fragment>
3272
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3273
- vec3 totalEmissiveRadiance = emissive;
3274
- #include <logdepthbuf_fragment>
3275
- #include <map_fragment>
3276
- #include <color_fragment>
3277
- #include <alphamap_fragment>
3278
- #include <alphatest_fragment>
3279
- #include <alphahash_fragment>
3280
- #include <roughnessmap_fragment>
3281
- #include <metalnessmap_fragment>
3282
- #include <normal_fragment_begin>
3283
- #include <normal_fragment_maps>
3284
- #include <clearcoat_normal_fragment_begin>
3285
- #include <clearcoat_normal_fragment_maps>
3286
- #include <emissivemap_fragment>
3287
- #include <lights_physical_fragment>
3288
- #include <lights_fragment_begin>
3289
- #include <lights_fragment_maps>
3290
- #include <lights_fragment_end>
3291
- #include <aomap_fragment>
3292
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3293
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3294
- #include <transmission_fragment>
3295
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3296
- #ifdef USE_SHEEN
3297
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3298
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3299
- #endif
3300
- #ifdef USE_CLEARCOAT
3301
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3302
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3303
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3304
- #endif
3305
- #include <opaque_fragment>
3306
- #include <tonemapping_fragment>
3307
- #include <colorspace_fragment>
3308
- #include <fog_fragment>
3309
- #include <premultiplied_alpha_fragment>
3310
- #include <dithering_fragment>
3311
- }`,y_=`#define TOON
3312
- varying vec3 vViewPosition;
3313
- #include <common>
3314
- #include <batching_pars_vertex>
3315
- #include <uv_pars_vertex>
3316
- #include <displacementmap_pars_vertex>
3317
- #include <color_pars_vertex>
3318
- #include <fog_pars_vertex>
3319
- #include <normal_pars_vertex>
3320
- #include <morphtarget_pars_vertex>
3321
- #include <skinning_pars_vertex>
3322
- #include <shadowmap_pars_vertex>
3323
- #include <logdepthbuf_pars_vertex>
3324
- #include <clipping_planes_pars_vertex>
3325
- void main() {
3326
- #include <uv_vertex>
3327
- #include <color_vertex>
3328
- #include <morphinstance_vertex>
3329
- #include <morphcolor_vertex>
3330
- #include <batching_vertex>
3331
- #include <beginnormal_vertex>
3332
- #include <morphnormal_vertex>
3333
- #include <skinbase_vertex>
3334
- #include <skinnormal_vertex>
3335
- #include <defaultnormal_vertex>
3336
- #include <normal_vertex>
3337
- #include <begin_vertex>
3338
- #include <morphtarget_vertex>
3339
- #include <skinning_vertex>
3340
- #include <displacementmap_vertex>
3341
- #include <project_vertex>
3342
- #include <logdepthbuf_vertex>
3343
- #include <clipping_planes_vertex>
3344
- vViewPosition = - mvPosition.xyz;
3345
- #include <worldpos_vertex>
3346
- #include <shadowmap_vertex>
3347
- #include <fog_vertex>
3348
- }`,M_=`#define TOON
3349
- uniform vec3 diffuse;
3350
- uniform vec3 emissive;
3351
- uniform float opacity;
3352
- #include <common>
3353
- #include <packing>
3354
- #include <dithering_pars_fragment>
3355
- #include <color_pars_fragment>
3356
- #include <uv_pars_fragment>
3357
- #include <map_pars_fragment>
3358
- #include <alphamap_pars_fragment>
3359
- #include <alphatest_pars_fragment>
3360
- #include <alphahash_pars_fragment>
3361
- #include <aomap_pars_fragment>
3362
- #include <lightmap_pars_fragment>
3363
- #include <emissivemap_pars_fragment>
3364
- #include <gradientmap_pars_fragment>
3365
- #include <fog_pars_fragment>
3366
- #include <bsdfs>
3367
- #include <lights_pars_begin>
3368
- #include <normal_pars_fragment>
3369
- #include <lights_toon_pars_fragment>
3370
- #include <shadowmap_pars_fragment>
3371
- #include <bumpmap_pars_fragment>
3372
- #include <normalmap_pars_fragment>
3373
- #include <logdepthbuf_pars_fragment>
3374
- #include <clipping_planes_pars_fragment>
3375
- void main() {
3376
- vec4 diffuseColor = vec4( diffuse, opacity );
3377
- #include <clipping_planes_fragment>
3378
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3379
- vec3 totalEmissiveRadiance = emissive;
3380
- #include <logdepthbuf_fragment>
3381
- #include <map_fragment>
3382
- #include <color_fragment>
3383
- #include <alphamap_fragment>
3384
- #include <alphatest_fragment>
3385
- #include <alphahash_fragment>
3386
- #include <normal_fragment_begin>
3387
- #include <normal_fragment_maps>
3388
- #include <emissivemap_fragment>
3389
- #include <lights_toon_fragment>
3390
- #include <lights_fragment_begin>
3391
- #include <lights_fragment_maps>
3392
- #include <lights_fragment_end>
3393
- #include <aomap_fragment>
3394
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3395
- #include <opaque_fragment>
3396
- #include <tonemapping_fragment>
3397
- #include <colorspace_fragment>
3398
- #include <fog_fragment>
3399
- #include <premultiplied_alpha_fragment>
3400
- #include <dithering_fragment>
3401
- }`,S_=`uniform float size;
3402
- uniform float scale;
3403
- #include <common>
3404
- #include <color_pars_vertex>
3405
- #include <fog_pars_vertex>
3406
- #include <morphtarget_pars_vertex>
3407
- #include <logdepthbuf_pars_vertex>
3408
- #include <clipping_planes_pars_vertex>
3409
- #ifdef USE_POINTS_UV
3410
- varying vec2 vUv;
3411
- uniform mat3 uvTransform;
3412
- #endif
3413
- void main() {
3414
- #ifdef USE_POINTS_UV
3415
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3416
- #endif
3417
- #include <color_vertex>
3418
- #include <morphinstance_vertex>
3419
- #include <morphcolor_vertex>
3420
- #include <begin_vertex>
3421
- #include <morphtarget_vertex>
3422
- #include <project_vertex>
3423
- gl_PointSize = size;
3424
- #ifdef USE_SIZEATTENUATION
3425
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3426
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3427
- #endif
3428
- #include <logdepthbuf_vertex>
3429
- #include <clipping_planes_vertex>
3430
- #include <worldpos_vertex>
3431
- #include <fog_vertex>
3432
- }`,b_=`uniform vec3 diffuse;
3433
- uniform float opacity;
3434
- #include <common>
3435
- #include <color_pars_fragment>
3436
- #include <map_particle_pars_fragment>
3437
- #include <alphatest_pars_fragment>
3438
- #include <alphahash_pars_fragment>
3439
- #include <fog_pars_fragment>
3440
- #include <logdepthbuf_pars_fragment>
3441
- #include <clipping_planes_pars_fragment>
3442
- void main() {
3443
- vec4 diffuseColor = vec4( diffuse, opacity );
3444
- #include <clipping_planes_fragment>
3445
- vec3 outgoingLight = vec3( 0.0 );
3446
- #include <logdepthbuf_fragment>
3447
- #include <map_particle_fragment>
3448
- #include <color_fragment>
3449
- #include <alphatest_fragment>
3450
- #include <alphahash_fragment>
3451
- outgoingLight = diffuseColor.rgb;
3452
- #include <opaque_fragment>
3453
- #include <tonemapping_fragment>
3454
- #include <colorspace_fragment>
3455
- #include <fog_fragment>
3456
- #include <premultiplied_alpha_fragment>
3457
- }`,E_=`#include <common>
3458
- #include <batching_pars_vertex>
3459
- #include <fog_pars_vertex>
3460
- #include <morphtarget_pars_vertex>
3461
- #include <skinning_pars_vertex>
3462
- #include <logdepthbuf_pars_vertex>
3463
- #include <shadowmap_pars_vertex>
3464
- void main() {
3465
- #include <batching_vertex>
3466
- #include <beginnormal_vertex>
3467
- #include <morphinstance_vertex>
3468
- #include <morphnormal_vertex>
3469
- #include <skinbase_vertex>
3470
- #include <skinnormal_vertex>
3471
- #include <defaultnormal_vertex>
3472
- #include <begin_vertex>
3473
- #include <morphtarget_vertex>
3474
- #include <skinning_vertex>
3475
- #include <project_vertex>
3476
- #include <logdepthbuf_vertex>
3477
- #include <worldpos_vertex>
3478
- #include <shadowmap_vertex>
3479
- #include <fog_vertex>
3480
- }`,w_=`uniform vec3 color;
3481
- uniform float opacity;
3482
- #include <common>
3483
- #include <packing>
3484
- #include <fog_pars_fragment>
3485
- #include <bsdfs>
3486
- #include <lights_pars_begin>
3487
- #include <logdepthbuf_pars_fragment>
3488
- #include <shadowmap_pars_fragment>
3489
- #include <shadowmask_pars_fragment>
3490
- void main() {
3491
- #include <logdepthbuf_fragment>
3492
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3493
- #include <tonemapping_fragment>
3494
- #include <colorspace_fragment>
3495
- #include <fog_fragment>
3496
- }`,A_=`uniform float rotation;
3497
- uniform vec2 center;
3498
- #include <common>
3499
- #include <uv_pars_vertex>
3500
- #include <fog_pars_vertex>
3501
- #include <logdepthbuf_pars_vertex>
3502
- #include <clipping_planes_pars_vertex>
3503
- void main() {
3504
- #include <uv_vertex>
3505
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3506
- vec2 scale;
3507
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
3508
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
3509
- #ifndef USE_SIZEATTENUATION
3510
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3511
- if ( isPerspective ) scale *= - mvPosition.z;
3512
- #endif
3513
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3514
- vec2 rotatedPosition;
3515
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3516
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3517
- mvPosition.xy += rotatedPosition;
3518
- gl_Position = projectionMatrix * mvPosition;
3519
- #include <logdepthbuf_vertex>
3520
- #include <clipping_planes_vertex>
3521
- #include <fog_vertex>
3522
- }`,T_=`uniform vec3 diffuse;
3523
- uniform float opacity;
3524
- #include <common>
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 <fog_pars_fragment>
3531
- #include <logdepthbuf_pars_fragment>
3532
- #include <clipping_planes_pars_fragment>
3533
- void main() {
3534
- vec4 diffuseColor = vec4( diffuse, opacity );
3535
- #include <clipping_planes_fragment>
3536
- vec3 outgoingLight = vec3( 0.0 );
3537
- #include <logdepthbuf_fragment>
3538
- #include <map_fragment>
3539
- #include <alphamap_fragment>
3540
- #include <alphatest_fragment>
3541
- #include <alphahash_fragment>
3542
- outgoingLight = diffuseColor.rgb;
3543
- #include <opaque_fragment>
3544
- #include <tonemapping_fragment>
3545
- #include <colorspace_fragment>
3546
- #include <fog_fragment>
3547
- }`,zt={alphahash_fragment:Zp,alphahash_pars_fragment:Jp,alphamap_fragment:$p,alphamap_pars_fragment:Kp,alphatest_fragment:Qp,alphatest_pars_fragment:jp,aomap_fragment:tm,aomap_pars_fragment:em,batching_pars_vertex:nm,batching_vertex:im,begin_vertex:sm,beginnormal_vertex:rm,bsdfs:am,iridescence_fragment:om,bumpmap_pars_fragment:cm,clipping_planes_fragment:lm,clipping_planes_pars_fragment:hm,clipping_planes_pars_vertex:um,clipping_planes_vertex:dm,color_fragment:fm,color_pars_fragment:pm,color_pars_vertex:mm,color_vertex:gm,common:_m,cube_uv_reflection_fragment:xm,defaultnormal_vertex:vm,displacementmap_pars_vertex:ym,displacementmap_vertex:Mm,emissivemap_fragment:Sm,emissivemap_pars_fragment:bm,colorspace_fragment:Em,colorspace_pars_fragment:wm,envmap_fragment:Am,envmap_common_pars_fragment:Tm,envmap_pars_fragment:Rm,envmap_pars_vertex:Cm,envmap_physical_pars_fragment:Vm,envmap_vertex:Pm,fog_vertex:Im,fog_pars_vertex:Lm,fog_fragment:Um,fog_pars_fragment:Dm,gradientmap_pars_fragment:Nm,lightmap_fragment:Om,lightmap_pars_fragment:Fm,lights_lambert_fragment:Bm,lights_lambert_pars_fragment:zm,lights_pars_begin:km,lights_toon_fragment:Hm,lights_toon_pars_fragment:Gm,lights_phong_fragment:Wm,lights_phong_pars_fragment:Xm,lights_physical_fragment:qm,lights_physical_pars_fragment:Ym,lights_fragment_begin:Zm,lights_fragment_maps:Jm,lights_fragment_end:$m,logdepthbuf_fragment:Km,logdepthbuf_pars_fragment:Qm,logdepthbuf_pars_vertex:jm,logdepthbuf_vertex:tg,map_fragment:eg,map_pars_fragment:ng,map_particle_fragment:ig,map_particle_pars_fragment:sg,metalnessmap_fragment:rg,metalnessmap_pars_fragment:ag,morphinstance_vertex:og,morphcolor_vertex:cg,morphnormal_vertex:lg,morphtarget_pars_vertex:hg,morphtarget_vertex:ug,normal_fragment_begin:dg,normal_fragment_maps:fg,normal_pars_fragment:pg,normal_pars_vertex:mg,normal_vertex:gg,normalmap_pars_fragment:_g,clearcoat_normal_fragment_begin:xg,clearcoat_normal_fragment_maps:vg,clearcoat_pars_fragment:yg,iridescence_pars_fragment:Mg,opaque_fragment:Sg,packing:bg,premultiplied_alpha_fragment:Eg,project_vertex:wg,dithering_fragment:Ag,dithering_pars_fragment:Tg,roughnessmap_fragment:Rg,roughnessmap_pars_fragment:Cg,shadowmap_pars_fragment:Pg,shadowmap_pars_vertex:Ig,shadowmap_vertex:Lg,shadowmask_pars_fragment:Ug,skinbase_vertex:Dg,skinning_pars_vertex:Ng,skinning_vertex:Og,skinnormal_vertex:Fg,specularmap_fragment:Bg,specularmap_pars_fragment:zg,tonemapping_fragment:kg,tonemapping_pars_fragment:Vg,transmission_fragment:Hg,transmission_pars_fragment:Gg,uv_pars_fragment:Wg,uv_pars_vertex:Xg,uv_vertex:qg,worldpos_vertex:Yg,background_vert:Zg,background_frag:Jg,backgroundCube_vert:$g,backgroundCube_frag:Kg,cube_vert:Qg,cube_frag:jg,depth_vert:t_,depth_frag:e_,distanceRGBA_vert:n_,distanceRGBA_frag:i_,equirect_vert:s_,equirect_frag:r_,linedashed_vert:a_,linedashed_frag:o_,meshbasic_vert:c_,meshbasic_frag:l_,meshlambert_vert:h_,meshlambert_frag:u_,meshmatcap_vert:d_,meshmatcap_frag:f_,meshnormal_vert:p_,meshnormal_frag:m_,meshphong_vert:g_,meshphong_frag:__,meshphysical_vert:x_,meshphysical_frag:v_,meshtoon_vert:y_,meshtoon_frag:M_,points_vert:S_,points_frag:b_,shadow_vert:E_,shadow_frag:w_,sprite_vert:A_,sprite_frag:T_},ht={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new kt}},envmap:{envMap:{value:null},envMapRotation:{value:new kt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new kt},normalScale:{value:new at(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0},uvTransform:{value:new kt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new at(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}}},Qe={basic:{uniforms:Ae([ht.common,ht.specularmap,ht.envmap,ht.aomap,ht.lightmap,ht.fog]),vertexShader:zt.meshbasic_vert,fragmentShader:zt.meshbasic_frag},lambert:{uniforms:Ae([ht.common,ht.specularmap,ht.envmap,ht.aomap,ht.lightmap,ht.emissivemap,ht.bumpmap,ht.normalmap,ht.displacementmap,ht.fog,ht.lights,{emissive:{value:new Vt(0)}}]),vertexShader:zt.meshlambert_vert,fragmentShader:zt.meshlambert_frag},phong:{uniforms:Ae([ht.common,ht.specularmap,ht.envmap,ht.aomap,ht.lightmap,ht.emissivemap,ht.bumpmap,ht.normalmap,ht.displacementmap,ht.fog,ht.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30}}]),vertexShader:zt.meshphong_vert,fragmentShader:zt.meshphong_frag},standard:{uniforms:Ae([ht.common,ht.envmap,ht.aomap,ht.lightmap,ht.emissivemap,ht.bumpmap,ht.normalmap,ht.displacementmap,ht.roughnessmap,ht.metalnessmap,ht.fog,ht.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag},toon:{uniforms:Ae([ht.common,ht.aomap,ht.lightmap,ht.emissivemap,ht.bumpmap,ht.normalmap,ht.displacementmap,ht.gradientmap,ht.fog,ht.lights,{emissive:{value:new Vt(0)}}]),vertexShader:zt.meshtoon_vert,fragmentShader:zt.meshtoon_frag},matcap:{uniforms:Ae([ht.common,ht.bumpmap,ht.normalmap,ht.displacementmap,ht.fog,{matcap:{value:null}}]),vertexShader:zt.meshmatcap_vert,fragmentShader:zt.meshmatcap_frag},points:{uniforms:Ae([ht.points,ht.fog]),vertexShader:zt.points_vert,fragmentShader:zt.points_frag},dashed:{uniforms:Ae([ht.common,ht.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zt.linedashed_vert,fragmentShader:zt.linedashed_frag},depth:{uniforms:Ae([ht.common,ht.displacementmap]),vertexShader:zt.depth_vert,fragmentShader:zt.depth_frag},normal:{uniforms:Ae([ht.common,ht.bumpmap,ht.normalmap,ht.displacementmap,{opacity:{value:1}}]),vertexShader:zt.meshnormal_vert,fragmentShader:zt.meshnormal_frag},sprite:{uniforms:Ae([ht.sprite,ht.fog]),vertexShader:zt.sprite_vert,fragmentShader:zt.sprite_frag},background:{uniforms:{uvTransform:{value:new kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zt.background_vert,fragmentShader:zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new kt}},vertexShader:zt.backgroundCube_vert,fragmentShader:zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zt.cube_vert,fragmentShader:zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zt.equirect_vert,fragmentShader:zt.equirect_frag},distanceRGBA:{uniforms:Ae([ht.common,ht.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zt.distanceRGBA_vert,fragmentShader:zt.distanceRGBA_frag},shadow:{uniforms:Ae([ht.lights,ht.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:zt.shadow_vert,fragmentShader:zt.shadow_frag}};Qe.physical={uniforms:Ae([Qe.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new kt},clearcoatNormalScale:{value:new at(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new kt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new kt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new kt},transmissionSamplerSize:{value:new at},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new kt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new kt},anisotropyVector:{value:new at},anisotropyMap:{value:null},anisotropyMapTransform:{value:new kt}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag};var Us={r:0,b:0,g:0},Vn=new Je,R_=new Ft;function C_(s,t,e,n,i,r,o){let a=new Vt(0),c=r===!0?0:1,l,h,d=null,f=0,g=null;function _(m,p){let w=!1,x=p.isScene===!0?p.background:null;x&&x.isTexture&&(x=(p.backgroundBlurriness>0?e:t).get(x)),x===null?v(a,c):x&&x.isColor&&(v(x,1),w=!0);let b=s.xr.getEnvironmentBlendMode();b==="additive"?n.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||w)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),x&&(x.isCubeTexture||x.mapping===kr)?(h===void 0&&(h=new Me(new rs(1,1,1),new tn({name:"BackgroundCubeMaterial",uniforms:Ui(Qe.backgroundCube.uniforms),vertexShader:Qe.backgroundCube.vertexShader,fragmentShader:Qe.backgroundCube.fragmentShader,side:Pe,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(L,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),Vn.copy(p.backgroundRotation),Vn.x*=-1,Vn.y*=-1,Vn.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Vn.y*=-1,Vn.z*=-1),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(R_.makeRotationFromEuler(Vn)),h.material.toneMapped=Jt.getTransfer(x.colorSpace)!==jt,(d!==x||f!==x.version||g!==s.toneMapping)&&(h.material.needsUpdate=!0,d=x,f=x.version,g=s.toneMapping),h.layers.enableAll(),m.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new Me(new ur(2,2),new tn({name:"BackgroundMaterial",uniforms:Ui(Qe.background.uniforms),vertexShader:Qe.background.vertexShader,fragmentShader:Qe.background.fragmentShader,side:Cn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=Jt.getTransfer(x.colorSpace)!==jt,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(d!==x||f!==x.version||g!==s.toneMapping)&&(l.material.needsUpdate=!0,d=x,f=x.version,g=s.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null))}u(_,"render");function v(m,p){m.getRGB(Us,Jd(s)),n.buffers.color.setClear(Us.r,Us.g,Us.b,p,o)}return u(v,"setClear"),{getClearColor:function(){return a},setClearColor:function(m,p=1){a.set(m),c=p,v(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(m){c=m,v(a,c)},render:_}}u(C_,"WebGLBackground");function P_(s,t,e,n){let i=s.getParameter(s.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:t.get("OES_vertex_array_object"),o=n.isWebGL2||r!==null,a={},c=m(null),l=c,h=!1;function d(I,G,k,J,q){let Y=!1;if(o){let it=v(J,k,G);l!==it&&(l=it,g(l.object)),Y=p(I,J,k,q),Y&&w(I,J,k,q)}else{let it=G.wireframe===!0;(l.geometry!==J.id||l.program!==k.id||l.wireframe!==it)&&(l.geometry=J.id,l.program=k.id,l.wireframe=it,Y=!0)}q!==null&&e.update(q,s.ELEMENT_ARRAY_BUFFER),(Y||h)&&(h=!1,D(I,G,k,J),q!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}u(d,"setup");function f(){return n.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}u(f,"createVertexArrayObject");function g(I){return n.isWebGL2?s.bindVertexArray(I):r.bindVertexArrayOES(I)}u(g,"bindVertexArrayObject");function _(I){return n.isWebGL2?s.deleteVertexArray(I):r.deleteVertexArrayOES(I)}u(_,"deleteVertexArrayObject");function v(I,G,k){let J=k.wireframe===!0,q=a[I.id];q===void 0&&(q={},a[I.id]=q);let Y=q[G.id];Y===void 0&&(Y={},q[G.id]=Y);let it=Y[J];return it===void 0&&(it=m(f()),Y[J]=it),it}u(v,"getBindingState");function m(I){let G=[],k=[],J=[];for(let q=0;q<i;q++)G[q]=0,k[q]=0,J[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:k,attributeDivisors:J,object:I,attributes:{},index:null}}u(m,"createBindingState");function p(I,G,k,J){let q=l.attributes,Y=G.attributes,it=0,nt=k.getAttributes();for(let _t in nt)if(nt[_t].location>=0){let V=q[_t],tt=Y[_t];if(tt===void 0&&(_t==="instanceMatrix"&&I.instanceMatrix&&(tt=I.instanceMatrix),_t==="instanceColor"&&I.instanceColor&&(tt=I.instanceColor)),V===void 0||V.attribute!==tt||tt&&V.data!==tt.data)return!0;it++}return l.attributesNum!==it||l.index!==J}u(p,"needsUpdate");function w(I,G,k,J){let q={},Y=G.attributes,it=0,nt=k.getAttributes();for(let _t in nt)if(nt[_t].location>=0){let V=Y[_t];V===void 0&&(_t==="instanceMatrix"&&I.instanceMatrix&&(V=I.instanceMatrix),_t==="instanceColor"&&I.instanceColor&&(V=I.instanceColor));let tt={};tt.attribute=V,V&&V.data&&(tt.data=V.data),q[_t]=tt,it++}l.attributes=q,l.attributesNum=it,l.index=J}u(w,"saveCache");function x(){let I=l.newAttributes;for(let G=0,k=I.length;G<k;G++)I[G]=0}u(x,"initAttributes");function b(I){L(I,0)}u(b,"enableAttribute");function L(I,G){let k=l.newAttributes,J=l.enabledAttributes,q=l.attributeDivisors;k[I]=1,J[I]===0&&(s.enableVertexAttribArray(I),J[I]=1),q[I]!==G&&((n.isWebGL2?s:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](I,G),q[I]=G)}u(L,"enableAttributeAndDivisor");function C(){let I=l.newAttributes,G=l.enabledAttributes;for(let k=0,J=G.length;k<J;k++)G[k]!==I[k]&&(s.disableVertexAttribArray(k),G[k]=0)}u(C,"disableUnusedAttributes");function R(I,G,k,J,q,Y,it){it===!0?s.vertexAttribIPointer(I,G,k,q,Y):s.vertexAttribPointer(I,G,k,J,q,Y)}u(R,"vertexAttribPointer");function D(I,G,k,J){if(n.isWebGL2===!1&&(I.isInstancedMesh||J.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;x();let q=J.attributes,Y=k.getAttributes(),it=G.defaultAttributeValues;for(let nt in Y){let _t=Y[nt];if(_t.location>=0){let It=q[nt];if(It===void 0&&(nt==="instanceMatrix"&&I.instanceMatrix&&(It=I.instanceMatrix),nt==="instanceColor"&&I.instanceColor&&(It=I.instanceColor)),It!==void 0){let V=It.normalized,tt=It.itemSize,mt=e.get(It);if(mt===void 0)continue;let wt=mt.buffer,Mt=mt.type,vt=mt.bytesPerElement,Ht=n.isWebGL2===!0&&(Mt===s.INT||Mt===s.UNSIGNED_INT||It.gpuType===Fd);if(It.isInterleavedBufferAttribute){let At=It.data,T=At.stride,ot=It.offset;if(At.isInstancedInterleavedBuffer){for(let Z=0;Z<_t.locationSize;Z++)L(_t.location+Z,At.meshPerAttribute);I.isInstancedMesh!==!0&&J._maxInstanceCount===void 0&&(J._maxInstanceCount=At.meshPerAttribute*At.count)}else for(let Z=0;Z<_t.locationSize;Z++)b(_t.location+Z);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let Z=0;Z<_t.locationSize;Z++)R(_t.location+Z,tt/_t.locationSize,Mt,V,T*vt,(ot+tt/_t.locationSize*Z)*vt,Ht)}else{if(It.isInstancedBufferAttribute){for(let At=0;At<_t.locationSize;At++)L(_t.location+At,It.meshPerAttribute);I.isInstancedMesh!==!0&&J._maxInstanceCount===void 0&&(J._maxInstanceCount=It.meshPerAttribute*It.count)}else for(let At=0;At<_t.locationSize;At++)b(_t.location+At);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let At=0;At<_t.locationSize;At++)R(_t.location+At,tt/_t.locationSize,Mt,V,tt*vt,tt/_t.locationSize*At*vt,Ht)}}else if(it!==void 0){let V=it[nt];if(V!==void 0)switch(V.length){case 2:s.vertexAttrib2fv(_t.location,V);break;case 3:s.vertexAttrib3fv(_t.location,V);break;case 4:s.vertexAttrib4fv(_t.location,V);break;default:s.vertexAttrib1fv(_t.location,V)}}}}C()}u(D,"setupVertexAttributes");function X(){Q();for(let I in a){let G=a[I];for(let k in G){let J=G[k];for(let q in J)_(J[q].object),delete J[q];delete G[k]}delete a[I]}}u(X,"dispose");function M(I){if(a[I.id]===void 0)return;let G=a[I.id];for(let k in G){let J=G[k];for(let q in J)_(J[q].object),delete J[q];delete G[k]}delete a[I.id]}u(M,"releaseStatesOfGeometry");function A(I){for(let G in a){let k=a[G];if(k[I.id]===void 0)continue;let J=k[I.id];for(let q in J)_(J[q].object),delete J[q];delete k[I.id]}}u(A,"releaseStatesOfProgram");function Q(){$(),h=!0,l!==c&&(l=c,g(l.object))}u(Q,"reset");function $(){c.geometry=null,c.program=null,c.wireframe=!1}return u($,"resetDefaultState"),{setup:d,reset:Q,resetDefaultState:$,dispose:X,releaseStatesOfGeometry:M,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:b,disableUnusedAttributes:C}}u(P_,"WebGLBindingStates");function I_(s,t,e,n){let i=n.isWebGL2,r;function o(h){r=h}u(o,"setMode");function a(h,d){s.drawArrays(r,h,d),e.update(d,r,1)}u(a,"render");function c(h,d,f){if(f===0)return;let g,_;if(i)g=s,_="drawArraysInstanced";else if(g=t.get("ANGLE_instanced_arrays"),_="drawArraysInstancedANGLE",g===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[_](r,h,d,f),e.update(d,r,f)}u(c,"renderInstances");function l(h,d,f){if(f===0)return;let g=t.get("WEBGL_multi_draw");if(g===null)for(let _=0;_<f;_++)this.render(h[_],d[_]);else{g.multiDrawArraysWEBGL(r,h,0,d,0,f);let _=0;for(let v=0;v<f;v++)_+=d[v];e.update(_,r,1)}}u(l,"renderMultiDraw"),this.setMode=o,this.render=a,this.renderInstances=c,this.renderMultiDraw=l}u(I_,"WebGLBufferRenderer");function L_(s,t,e){let n;function i(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");n=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}u(i,"getMaxAnisotropy");function r(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}u(r,"getMaxPrecision");let o=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext",a=e.precision!==void 0?e.precision:"highp",c=r(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);let l=o||t.has("WEBGL_draw_buffers"),h=e.logarithmicDepthBuffer===!0,d=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_TEXTURE_SIZE),_=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),v=s.getParameter(s.MAX_VERTEX_ATTRIBS),m=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),p=s.getParameter(s.MAX_VARYING_VECTORS),w=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),x=f>0,b=o||t.has("OES_texture_float"),L=x&&b,C=o?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:f,maxTextureSize:g,maxCubemapSize:_,maxAttributes:v,maxVertexUniforms:m,maxVaryings:p,maxFragmentUniforms:w,vertexTextures:x,floatFragmentTextures:b,floatVertexTextures:L,maxSamples:C}}u(L_,"WebGLCapabilities");function U_(s){let t=this,e=null,n=0,i=!1,r=!1,o=new hn,a=new kt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let g=d.length!==0||f||n!==0||i;return i=f,n=d.length,g},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,f){e=h(d,f,0)},this.setState=function(d,f,g){let _=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,p=s.get(d);if(!i||_===null||_.length===0||r&&!m)r?h(null):l();else{let w=r?0:n,x=w*4,b=p.clippingState||null;c.value=b,b=h(_,f,x,g);for(let L=0;L!==x;++L)b[L]=e[L];p.clippingState=b,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}u(l,"resetGlobalState");function h(d,f,g,_){let v=d!==null?d.length:0,m=null;if(v!==0){if(m=c.value,_!==!0||m===null){let p=g+v*4,w=f.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<p)&&(m=new Float32Array(p));for(let x=0,b=g;x!==v;++x,b+=4)o.copy(d[x]).applyMatrix4(w,a),o.normal.toArray(m,b),m[b+3]=o.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}u(h,"projectPlanes")}u(U_,"WebGLClipping");function D_(s){let t=new WeakMap;function e(o,a){return a===Ba?o.mapping=Ci:a===za&&(o.mapping=Pi),o}u(e,"mapTextureMapping");function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Ba||a===za)if(t.has(o)){let c=t.get(o).texture;return e(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Za(c.height);return l.fromEquirectangularTexture(s,o),t.set(o,l),o.addEventListener("dispose",i),e(l.texture,o.mapping)}else return null}}return o}u(n,"get");function i(o){let a=o.target;a.removeEventListener("dispose",i);let c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}u(i,"onTextureDispose");function r(){t=new WeakMap}return u(r,"dispose"),{get:n,dispose:r}}u(D_,"WebGLCubeMaps");var vc=class vc extends lr{constructor(t=-1,e=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,o=n+t,a=i+e,c=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,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.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}};u(vc,"OrthographicCamera");var dr=vc,vi=4,cu=[.125,.215,.35,.446,.526,.582],qn=20,ya=new dr,lu=new Vt,Ma=null,Sa=0,ba=0,Wn=(1+Math.sqrt(5))/2,gi=1/Wn,hu=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Wn,gi),new P(0,Wn,-gi),new P(gi,0,Wn),new P(-gi,0,Wn),new P(Wn,gi,0),new P(-Wn,gi,0)],yc=class yc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){Ma=this._renderer.getRenderTarget(),Sa=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=fu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=du(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Ma,Sa,ba),t.scissorTest=!1,Ds(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ci||t.mapping===Pi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ma=this._renderer.getRenderTarget(),Sa=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel();let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ce,minFilter:Ce,generateMipmaps:!1,type:ns,format:Oe,colorSpace:Dn,depthBuffer:!1},i=uu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=uu(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=N_(r)),this._blurMaterial=O_(r,t,e)}return i}_compileMaterial(t){let e=new Me(this._lodPlanes[0],t);this._renderer.compile(e,ya)}_sceneToCubeUV(t,e,n,i){let a=new Te(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(lu),h.toneMapping=Tn,h.autoClear=!1;let g=new ar({name:"PMREM.Background",side:Pe,depthWrite:!1,depthTest:!1}),_=new Me(new rs,g),v=!1,m=t.background;m?m.isColor&&(g.color.copy(m),t.background=null,v=!0):(g.color.copy(lu),v=!0);for(let p=0;p<6;p++){let w=p%3;w===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):w===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));let x=this._cubeSize;Ds(i,w*x,p>2?x:0,x,x),h.setRenderTarget(i),v&&h.render(_,a),h.render(t,a)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=f,h.autoClear=d,t.background=m}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===Ci||t.mapping===Pi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=fu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=du());let r=i?this._cubemapMaterial:this._equirectMaterial,o=new Me(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=t;let c=this._cubeSize;Ds(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,ya)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let r=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=hu[(i-1)%hu.length];this._blur(t,i-1,i,r,o)}e.autoClear=n}_blur(t,e,n,i,r){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",r),this._halfBlur(o,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,d=new Me(this._lodPlanes[i],l),f=l.uniforms,g=this._sizeLods[n]-1,_=isFinite(r)?Math.PI/(2*g):2*Math.PI/(2*qn-1),v=r/_,m=isFinite(r)?1+Math.floor(h*v):qn;m>qn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${qn}`);let p=[],w=0;for(let R=0;R<qn;++R){let D=R/v,X=Math.exp(-D*D/2);p.push(X),R===0?w+=X:R<m&&(w+=2*X)}for(let R=0;R<p.length;R++)p[R]=p[R]/w;f.envMap.value=t.texture,f.samples.value=m,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:x}=this;f.dTheta.value=_,f.mipInt.value=x-n;let b=this._sizeLods[i],L=3*b*(i>x-vi?i-x+vi:0),C=4*(this._cubeSize-b);Ds(e,L,C,3*b,2*b),c.setRenderTarget(e),c.render(d,ya)}};u(yc,"PMREMGenerator");var fr=yc;function N_(s){let t=[],e=[],n=[],i=s,r=s-vi+1+cu.length;for(let o=0;o<r;o++){let a=Math.pow(2,i);e.push(a);let c=1/a;o>s-vi?c=cu[o-s+vi-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),h=-l,d=1+l,f=[h,h,d,h,d,d,h,h,d,d,h,d],g=6,_=6,v=3,m=2,p=1,w=new Float32Array(v*_*g),x=new Float32Array(m*_*g),b=new Float32Array(p*_*g);for(let C=0;C<g;C++){let R=C%3*2/3-1,D=C>2?0:-1,X=[R,D,0,R+2/3,D,0,R+2/3,D+1,0,R,D,0,R+2/3,D+1,0,R,D+1,0];w.set(X,v*_*C),x.set(f,m*_*C);let M=[C,C,C,C,C,C];b.set(M,p*_*C)}let L=new Le;L.setAttribute("position",new Se(w,v)),L.setAttribute("uv",new Se(x,m)),L.setAttribute("faceIndex",new Se(b,p)),t.push(L),i>vi&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}u(N_,"_createPlanes");function uu(s,t,e){let n=new fn(s,t,e);return n.texture.mapping=kr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}u(uu,"_createRenderTarget");function Ds(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}u(Ds,"_setViewport");function O_(s,t,e){let n=new Float32Array(qn),i=new P(0,1,0);return new tn({name:"SphericalGaussianBlur",defines:{n:qn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Vo(),fragmentShader:`
3548
-
3549
- precision mediump float;
3550
- precision mediump int;
3551
-
3552
- varying vec3 vOutputDirection;
3553
-
3554
- uniform sampler2D envMap;
3555
- uniform int samples;
3556
- uniform float weights[ n ];
3557
- uniform bool latitudinal;
3558
- uniform float dTheta;
3559
- uniform float mipInt;
3560
- uniform vec3 poleAxis;
3561
-
3562
- #define ENVMAP_TYPE_CUBE_UV
3563
- #include <cube_uv_reflection_fragment>
3564
-
3565
- vec3 getSample( float theta, vec3 axis ) {
3566
-
3567
- float cosTheta = cos( theta );
3568
- // Rodrigues' axis-angle rotation
3569
- vec3 sampleDirection = vOutputDirection * cosTheta
3570
- + cross( axis, vOutputDirection ) * sin( theta )
3571
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3572
-
3573
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
3574
-
3575
- }
3576
-
3577
- void main() {
3578
-
3579
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3580
-
3581
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3582
-
3583
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3584
-
3585
- }
3586
-
3587
- axis = normalize( axis );
3588
-
3589
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3590
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3591
-
3592
- for ( int i = 1; i < n; i++ ) {
3593
-
3594
- if ( i >= samples ) {
3595
-
3596
- break;
3597
-
3598
- }
3599
-
3600
- float theta = dTheta * float( i );
3601
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3602
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3603
-
3604
- }
3605
-
3606
- }
3607
- `,blending:An,depthTest:!1,depthWrite:!1})}u(O_,"_getBlurShader");function du(){return new tn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Vo(),fragmentShader:`
3608
-
3609
- precision mediump float;
3610
- precision mediump int;
3611
-
3612
- varying vec3 vOutputDirection;
3613
-
3614
- uniform sampler2D envMap;
3615
-
3616
- #include <common>
3617
-
3618
- void main() {
3619
-
3620
- vec3 outputDirection = normalize( vOutputDirection );
3621
- vec2 uv = equirectUv( outputDirection );
3622
-
3623
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3624
-
3625
- }
3626
- `,blending:An,depthTest:!1,depthWrite:!1})}u(du,"_getEquirectMaterial");function fu(){return new tn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Vo(),fragmentShader:`
3627
-
3628
- precision mediump float;
3629
- precision mediump int;
3630
-
3631
- uniform float flipEnvMap;
3632
-
3633
- varying vec3 vOutputDirection;
3634
-
3635
- uniform samplerCube envMap;
3636
-
3637
- void main() {
3638
-
3639
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3640
-
3641
- }
3642
- `,blending:An,depthTest:!1,depthWrite:!1})}u(fu,"_getCubemapMaterial");function Vo(){return`
3643
-
3644
- precision mediump float;
3645
- precision mediump int;
3646
-
3647
- attribute float faceIndex;
3648
-
3649
- varying vec3 vOutputDirection;
3650
-
3651
- // RH coordinate system; PMREM face-indexing convention
3652
- vec3 getDirection( vec2 uv, float face ) {
3653
-
3654
- uv = 2.0 * uv - 1.0;
3655
-
3656
- vec3 direction = vec3( uv, 1.0 );
3657
-
3658
- if ( face == 0.0 ) {
3659
-
3660
- direction = direction.zyx; // ( 1, v, u ) pos x
3661
-
3662
- } else if ( face == 1.0 ) {
3663
-
3664
- direction = direction.xzy;
3665
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3666
-
3667
- } else if ( face == 2.0 ) {
3668
-
3669
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
3670
-
3671
- } else if ( face == 3.0 ) {
3672
-
3673
- direction = direction.zyx;
3674
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
3675
-
3676
- } else if ( face == 4.0 ) {
3677
-
3678
- direction = direction.xzy;
3679
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
3680
-
3681
- } else if ( face == 5.0 ) {
3682
-
3683
- direction.z *= -1.0; // ( u, v, -1 ) neg z
3684
-
3685
- }
3686
-
3687
- return direction;
3688
-
3689
- }
3690
-
3691
- void main() {
3692
-
3693
- vOutputDirection = getDirection( uv, faceIndex );
3694
- gl_Position = vec4( position, 1.0 );
3695
-
3696
- }
3697
- `}u(Vo,"_getCommonVertexShader");function F_(s){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===Ba||c===za,h=c===Ci||c===Pi;if(l||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=t.get(a);return e===null&&(e=new fr(s)),d=l?e.fromEquirectangular(a,d):e.fromCubemap(a,d),t.set(a,d),d.texture}else{if(t.has(a))return t.get(a).texture;{let d=a.image;if(l&&d&&d.height>0||h&&d&&i(d)){e===null&&(e=new fr(s));let f=l?e.fromEquirectangular(a):e.fromCubemap(a);return t.set(a,f),a.addEventListener("dispose",r),f.texture}else return null}}}return a}u(n,"get");function i(a){let c=0,l=6;for(let h=0;h<l;h++)a[h]!==void 0&&c++;return c===l}u(i,"isCubeTextureComplete");function r(a){let c=a.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}u(r,"onTextureDispose");function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return u(o,"dispose"),{get:n,dispose:o}}u(F_,"WebGLCubeUVMaps");function B_(s){let t={};function e(n){if(t[n]!==void 0)return t[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return t[n]=i,i}return u(e,"getExtension"),{has:function(n){return e(n)!==null},init:function(n){n.isWebGL2?(e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance")):(e("WEBGL_depth_texture"),e("OES_texture_float"),e("OES_texture_half_float"),e("OES_texture_half_float_linear"),e("OES_standard_derivatives"),e("OES_element_index_uint"),e("OES_vertex_array_object"),e("ANGLE_instanced_arrays")),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture")},get:function(n){let i=e(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}u(B_,"WebGLExtensions");function z_(s,t,e,n){let i={},r=new WeakMap;function o(d){let f=d.target;f.index!==null&&t.remove(f.index);for(let _ in f.attributes)t.remove(f.attributes[_]);for(let _ in f.morphAttributes){let v=f.morphAttributes[_];for(let m=0,p=v.length;m<p;m++)t.remove(v[m])}f.removeEventListener("dispose",o),delete i[f.id];let g=r.get(f);g&&(t.remove(g),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}u(o,"onGeometryDispose");function a(d,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,e.memory.geometries++),f}u(a,"get");function c(d){let f=d.attributes;for(let _ in f)t.update(f[_],s.ARRAY_BUFFER);let g=d.morphAttributes;for(let _ in g){let v=g[_];for(let m=0,p=v.length;m<p;m++)t.update(v[m],s.ARRAY_BUFFER)}}u(c,"update");function l(d){let f=[],g=d.index,_=d.attributes.position,v=0;if(g!==null){let w=g.array;v=g.version;for(let x=0,b=w.length;x<b;x+=3){let L=w[x+0],C=w[x+1],R=w[x+2];f.push(L,C,C,R,R,L)}}else if(_!==void 0){let w=_.array;v=_.version;for(let x=0,b=w.length/3-1;x<b;x+=3){let L=x+0,C=x+1,R=x+2;f.push(L,C,C,R,R,L)}}else return;let m=new(qd(f)?cr:or)(f,1);m.version=v;let p=r.get(d);p&&t.remove(p),r.set(d,m)}u(l,"updateWireframeAttribute");function h(d){let f=r.get(d);if(f){let g=d.index;g!==null&&f.version<g.version&&l(d)}else l(d);return r.get(d)}return u(h,"getWireframeAttribute"),{get:a,update:c,getWireframeAttribute:h}}u(z_,"WebGLGeometries");function k_(s,t,e,n){let i=n.isWebGL2,r;function o(g){r=g}u(o,"setMode");let a,c;function l(g){a=g.type,c=g.bytesPerElement}u(l,"setIndex");function h(g,_){s.drawElements(r,_,a,g*c),e.update(_,r,1)}u(h,"render");function d(g,_,v){if(v===0)return;let m,p;if(i)m=s,p="drawElementsInstanced";else if(m=t.get("ANGLE_instanced_arrays"),p="drawElementsInstancedANGLE",m===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[p](r,_,a,g*c,v),e.update(_,r,v)}u(d,"renderInstances");function f(g,_,v){if(v===0)return;let m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<v;p++)this.render(g[p]/c,_[p]);else{m.multiDrawElementsWEBGL(r,_,0,a,g,0,v);let p=0;for(let w=0;w<v;w++)p+=_[w];e.update(p,r,1)}}u(f,"renderMultiDraw"),this.setMode=o,this.setIndex=l,this.render=h,this.renderInstances=d,this.renderMultiDraw=f}u(k_,"WebGLIndexedBufferRenderer");function V_(s){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(e.calls++,o){case s.TRIANGLES:e.triangles+=a*(r/3);break;case s.LINES:e.lines+=a*(r/2);break;case s.LINE_STRIP:e.lines+=a*(r-1);break;case s.LINE_LOOP:e.lines+=a*r;break;case s.POINTS:e.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}u(n,"update");function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return u(i,"reset"),{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}u(V_,"WebGLInfo");function H_(s,t){return s[0]-t[0]}u(H_,"numericalSort");function G_(s,t){return Math.abs(t[1])-Math.abs(s[1])}u(G_,"absNumericalSort");function W_(s,t,e){let n={},i=new Float32Array(8),r=new WeakMap,o=new $t,a=[];for(let l=0;l<8;l++)a[l]=[l,0];function c(l,h,d){let f=l.morphTargetInfluences;if(t.isWebGL2===!0){let g=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,_=g!==void 0?g.length:0,v=r.get(h);if(v===void 0||v.count!==_){let Q=function(){M.dispose(),r.delete(h),h.removeEventListener("dispose",Q)};u(Q,"disposeTexture"),v!==void 0&&v.texture.dispose();let m=h.morphAttributes.position!==void 0,p=h.morphAttributes.normal!==void 0,w=h.morphAttributes.color!==void 0,x=h.morphAttributes.position||[],b=h.morphAttributes.normal||[],L=h.morphAttributes.color||[],C=0;m===!0&&(C=1),p===!0&&(C=2),w===!0&&(C=3);let R=h.attributes.position.count*C,D=1;R>t.maxTextureSize&&(D=Math.ceil(R/t.maxTextureSize),R=t.maxTextureSize);let X=new Float32Array(R*D*4*_),M=new rr(X,R,D,_);M.type=ke,M.needsUpdate=!0;let A=C*4;for(let $=0;$<_;$++){let I=x[$],G=b[$],k=L[$],J=R*D*4*$;for(let q=0;q<I.count;q++){let Y=q*A;m===!0&&(o.fromBufferAttribute(I,q),X[J+Y+0]=o.x,X[J+Y+1]=o.y,X[J+Y+2]=o.z,X[J+Y+3]=0),p===!0&&(o.fromBufferAttribute(G,q),X[J+Y+4]=o.x,X[J+Y+5]=o.y,X[J+Y+6]=o.z,X[J+Y+7]=0),w===!0&&(o.fromBufferAttribute(k,q),X[J+Y+8]=o.x,X[J+Y+9]=o.y,X[J+Y+10]=o.z,X[J+Y+11]=k.itemSize===4?o.w:1)}}v={count:_,texture:M,size:new at(R,D)},r.set(h,v),h.addEventListener("dispose",Q)}if(l.isInstancedMesh===!0&&l.morphTexture!==null)d.getUniforms().setValue(s,"morphTexture",l.morphTexture,e);else{let m=0;for(let w=0;w<f.length;w++)m+=f[w];let p=h.morphTargetsRelative?1:1-m;d.getUniforms().setValue(s,"morphTargetBaseInfluence",p),d.getUniforms().setValue(s,"morphTargetInfluences",f)}d.getUniforms().setValue(s,"morphTargetsTexture",v.texture,e),d.getUniforms().setValue(s,"morphTargetsTextureSize",v.size)}else{let g=f===void 0?0:f.length,_=n[h.id];if(_===void 0||_.length!==g){_=[];for(let x=0;x<g;x++)_[x]=[x,0];n[h.id]=_}for(let x=0;x<g;x++){let b=_[x];b[0]=x,b[1]=f[x]}_.sort(G_);for(let x=0;x<8;x++)x<g&&_[x][1]?(a[x][0]=_[x][0],a[x][1]=_[x][1]):(a[x][0]=Number.MAX_SAFE_INTEGER,a[x][1]=0);a.sort(H_);let v=h.morphAttributes.position,m=h.morphAttributes.normal,p=0;for(let x=0;x<8;x++){let b=a[x],L=b[0],C=b[1];L!==Number.MAX_SAFE_INTEGER&&C?(v&&h.getAttribute("morphTarget"+x)!==v[L]&&h.setAttribute("morphTarget"+x,v[L]),m&&h.getAttribute("morphNormal"+x)!==m[L]&&h.setAttribute("morphNormal"+x,m[L]),i[x]=C,p+=C):(v&&h.hasAttribute("morphTarget"+x)===!0&&h.deleteAttribute("morphTarget"+x),m&&h.hasAttribute("morphNormal"+x)===!0&&h.deleteAttribute("morphNormal"+x),i[x]=0)}let w=h.morphTargetsRelative?1:1-p;d.getUniforms().setValue(s,"morphTargetBaseInfluence",w),d.getUniforms().setValue(s,"morphTargetInfluences",i)}}return u(c,"update"),{update:c}}u(W_,"WebGLMorphtargets");function X_(s,t,e,n){let i=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,d=t.get(c,h);if(i.get(d)!==l&&(t.update(d),i.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(e.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){let f=c.skeleton;i.get(f)!==l&&(f.update(),i.set(f,l))}return d}u(r,"update");function o(){i=new WeakMap}u(o,"dispose");function a(c){let l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return u(a,"onInstancedMeshDispose"),{update:r,dispose:o}}u(X_,"WebGLObjects");var Mc=class Mc extends be{constructor(t,e,n,i,r,o,a,c,l,h){if(h=h!==void 0?h:$n,h!==$n&&h!==Ii)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===$n&&(n=En),n===void 0&&h===Ii&&(n=Jn),super(null,i,r,o,a,c,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:ge,this.minFilter=c!==void 0?c:ge,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}};u(Mc,"DepthTexture");var pr=Mc,Kd=new be,Qd=new pr(1,1);Qd.compareFunction=Xd;var jd=new rr,tf=new qa,ef=new hr,pu=[],mu=[],gu=new Float32Array(16),_u=new Float32Array(9),xu=new Float32Array(4);function zi(s,t,e){let n=s[0];if(n<=0||n>0)return s;let i=t*e,r=pu[i];if(r===void 0&&(r=new Float32Array(i),pu[i]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,s[o].toArray(r,a)}return r}u(zi,"flatten");function he(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}u(he,"arraysEqual");function ue(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}u(ue,"copyArray");function Hr(s,t){let e=mu[t];e===void 0&&(e=new Int32Array(t),mu[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}u(Hr,"allocTexUnits");function q_(s,t){let e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}u(q_,"setValueV1f");function Y_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;s.uniform2fv(this.addr,t),ue(e,t)}}u(Y_,"setValueV2f");function Z_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(he(e,t))return;s.uniform3fv(this.addr,t),ue(e,t)}}u(Z_,"setValueV3f");function J_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;s.uniform4fv(this.addr,t),ue(e,t)}}u(J_,"setValueV4f");function $_(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;xu.set(n),s.uniformMatrix2fv(this.addr,!1,xu),ue(e,n)}}u($_,"setValueM2");function K_(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;_u.set(n),s.uniformMatrix3fv(this.addr,!1,_u),ue(e,n)}}u(K_,"setValueM3");function Q_(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;gu.set(n),s.uniformMatrix4fv(this.addr,!1,gu),ue(e,n)}}u(Q_,"setValueM4");function j_(s,t){let e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}u(j_,"setValueV1i");function t0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;s.uniform2iv(this.addr,t),ue(e,t)}}u(t0,"setValueV2i");function e0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(he(e,t))return;s.uniform3iv(this.addr,t),ue(e,t)}}u(e0,"setValueV3i");function n0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;s.uniform4iv(this.addr,t),ue(e,t)}}u(n0,"setValueV4i");function i0(s,t){let e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}u(i0,"setValueV1ui");function s0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;s.uniform2uiv(this.addr,t),ue(e,t)}}u(s0,"setValueV2ui");function r0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(he(e,t))return;s.uniform3uiv(this.addr,t),ue(e,t)}}u(r0,"setValueV3ui");function a0(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;s.uniform4uiv(this.addr,t),ue(e,t)}}u(a0,"setValueV4ui");function o0(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r=this.type===s.SAMPLER_2D_SHADOW?Qd:Kd;e.setTexture2D(t||r,i)}u(o0,"setValueT1");function c0(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||tf,i)}u(c0,"setValueT3D1");function l0(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||ef,i)}u(l0,"setValueT6");function h0(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||jd,i)}u(h0,"setValueT2DArray1");function u0(s){switch(s){case 5126:return q_;case 35664:return Y_;case 35665:return Z_;case 35666:return J_;case 35674:return $_;case 35675:return K_;case 35676:return Q_;case 5124:case 35670:return j_;case 35667:case 35671:return t0;case 35668:case 35672:return e0;case 35669:case 35673:return n0;case 5125:return i0;case 36294:return s0;case 36295:return r0;case 36296:return a0;case 35678:case 36198:case 36298:case 36306:case 35682:return o0;case 35679:case 36299:case 36307:return c0;case 35680:case 36300:case 36308:case 36293:return l0;case 36289:case 36303:case 36311:case 36292:return h0}}u(u0,"getSingularSetter");function d0(s,t){s.uniform1fv(this.addr,t)}u(d0,"setValueV1fArray");function f0(s,t){let e=zi(t,this.size,2);s.uniform2fv(this.addr,e)}u(f0,"setValueV2fArray");function p0(s,t){let e=zi(t,this.size,3);s.uniform3fv(this.addr,e)}u(p0,"setValueV3fArray");function m0(s,t){let e=zi(t,this.size,4);s.uniform4fv(this.addr,e)}u(m0,"setValueV4fArray");function g0(s,t){let e=zi(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}u(g0,"setValueM2Array");function _0(s,t){let e=zi(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}u(_0,"setValueM3Array");function x0(s,t){let e=zi(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}u(x0,"setValueM4Array");function v0(s,t){s.uniform1iv(this.addr,t)}u(v0,"setValueV1iArray");function y0(s,t){s.uniform2iv(this.addr,t)}u(y0,"setValueV2iArray");function M0(s,t){s.uniform3iv(this.addr,t)}u(M0,"setValueV3iArray");function S0(s,t){s.uniform4iv(this.addr,t)}u(S0,"setValueV4iArray");function b0(s,t){s.uniform1uiv(this.addr,t)}u(b0,"setValueV1uiArray");function E0(s,t){s.uniform2uiv(this.addr,t)}u(E0,"setValueV2uiArray");function w0(s,t){s.uniform3uiv(this.addr,t)}u(w0,"setValueV3uiArray");function A0(s,t){s.uniform4uiv(this.addr,t)}u(A0,"setValueV4uiArray");function T0(s,t,e){let n=this.cache,i=t.length,r=Hr(e,i);he(n,r)||(s.uniform1iv(this.addr,r),ue(n,r));for(let o=0;o!==i;++o)e.setTexture2D(t[o]||Kd,r[o])}u(T0,"setValueT1Array");function R0(s,t,e){let n=this.cache,i=t.length,r=Hr(e,i);he(n,r)||(s.uniform1iv(this.addr,r),ue(n,r));for(let o=0;o!==i;++o)e.setTexture3D(t[o]||tf,r[o])}u(R0,"setValueT3DArray");function C0(s,t,e){let n=this.cache,i=t.length,r=Hr(e,i);he(n,r)||(s.uniform1iv(this.addr,r),ue(n,r));for(let o=0;o!==i;++o)e.setTextureCube(t[o]||ef,r[o])}u(C0,"setValueT6Array");function P0(s,t,e){let n=this.cache,i=t.length,r=Hr(e,i);he(n,r)||(s.uniform1iv(this.addr,r),ue(n,r));for(let o=0;o!==i;++o)e.setTexture2DArray(t[o]||jd,r[o])}u(P0,"setValueT2DArrayArray");function I0(s){switch(s){case 5126:return d0;case 35664:return f0;case 35665:return p0;case 35666:return m0;case 35674:return g0;case 35675:return _0;case 35676:return x0;case 5124:case 35670:return v0;case 35667:case 35671:return y0;case 35668:case 35672:return M0;case 35669:case 35673:return S0;case 5125:return b0;case 36294:return E0;case 36295:return w0;case 36296:return A0;case 35678:case 36198:case 36298:case 36306:case 35682:return T0;case 35679:case 36299:case 36307:return R0;case 35680:case 36300:case 36308:case 36293:return C0;case 36289:case 36303:case 36311:case 36292:return P0}}u(I0,"getPureArraySetter");var Sc=class Sc{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=u0(e.type)}};u(Sc,"SingleUniform");var Ja=Sc,bc=class bc{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=I0(e.type)}};u(bc,"PureArrayUniform");var $a=bc,Ec=class Ec{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let r=0,o=i.length;r!==o;++r){let a=i[r];a.setValue(t,e[a.id],n)}}};u(Ec,"StructuredUniform");var Ka=Ec,Ea=/(\w+)(\])?(\[|\.)?/g;function vu(s,t){s.seq.push(t),s.map[t.id]=t}u(vu,"addUniform");function L0(s,t,e){let n=s.name,i=n.length;for(Ea.lastIndex=0;;){let r=Ea.exec(n),o=Ea.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){vu(e,l===void 0?new Ja(a,s,t):new $a(a,s,t));break}else{let d=e.map[a];d===void 0&&(d=new Ka(a),vu(e,d)),e=d}}}u(L0,"parseUniform");var wc=class wc{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let r=t.getActiveUniform(e,i),o=t.getUniformLocation(e,r.name);L0(r,o,this)}}setValue(t,e,n,i){let r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,o=e.length;r!==o;++r){let a=e[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,r=t.length;i!==r;++i){let o=t[i];o.id in e&&n.push(o)}return n}};u(wc,"WebGLUniforms");var Ri=wc;function yu(s,t,e){let n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}u(yu,"WebGLShader");var U0=37297,D0=0;function N0(s,t){let e=s.split(`
3698
- `),n=[],i=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let o=i;o<r;o++){let a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
3699
- `)}u(N0,"handleSource");function O0(s){let t=Jt.getPrimaries(Jt.workingColorSpace),e=Jt.getPrimaries(s),n;switch(t===e?n="":t===tr&&e===js?n="LinearDisplayP3ToLinearSRGB":t===js&&e===tr&&(n="LinearSRGBToLinearDisplayP3"),s){case Dn:case Vr:return[n,"LinearTransferOETF"];case Ke:case zo:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[n,"LinearTransferOETF"]}}u(O0,"getEncodingComponents");function Mu(s,t,e){let n=s.getShaderParameter(t,s.COMPILE_STATUS),i=s.getShaderInfoLog(t).trim();if(n&&i==="")return"";let r=/ERROR: 0:(\d+)/.exec(i);if(r){let o=parseInt(r[1]);return e.toUpperCase()+`
3700
-
3701
- `+i+`
3702
-
3703
- `+N0(s.getShaderSource(t),o)}else return i}u(Mu,"getShaderErrors");function F0(s,t){let e=O0(t);return`vec4 ${s}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}u(F0,"getTexelEncodingFunction");function B0(s,t){let e;switch(t){case kf:e="Linear";break;case Vf:e="Reinhard";break;case Hf:e="OptimizedCineon";break;case Gf:e="ACESFilmic";break;case Xf:e="AgX";break;case qf:e="Neutral";break;case Wf:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}u(B0,"getToneMappingFunction");function z0(s){return[s.extensionDerivatives||s.envMapCubeUVHeight||s.bumpMap||s.normalMapTangentSpace||s.clearcoatNormalMap||s.flatShading||s.alphaToCoverage||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(yi).join(`
3704
- `)}u(z0,"generateExtensions");function k0(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(yi).join(`
3705
- `)}u(k0,"generateVertexExtensions");function V0(s){let t=[];for(let e in s){let n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3706
- `)}u(V0,"generateDefines");function H0(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let r=s.getActiveAttrib(t,i),o=r.name,a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),e[o]={type:r.type,location:s.getAttribLocation(t,o),locationSize:a}}return e}u(H0,"fetchAttributeLocations");function yi(s){return s!==""}u(yi,"filterEmptyLine");function Su(s,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}u(Su,"replaceLightNums");function bu(s,t){return s.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}u(bu,"replaceClippingPlaneNums");var G0=/^[ \t]*#include +<([\w\d./]+)>/gm;function Qa(s){return s.replace(G0,X0)}u(Qa,"resolveIncludes");var W0=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function X0(s,t){let e=zt[t];if(e===void 0){let n=W0.get(t);if(n!==void 0)e=zt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Qa(e)}u(X0,"includeReplacer");var q0=/#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 Eu(s){return s.replace(q0,Y0)}u(Eu,"unrollLoops");function Y0(s,t,e,n){let i="";for(let r=parseInt(t);r<parseInt(e);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}u(Y0,"loopReplacer");function wu(s){let t=`precision ${s.precision} float;
3707
- precision ${s.precision} int;
3708
- precision ${s.precision} sampler2D;
3709
- precision ${s.precision} samplerCube;
3710
- `;return s.isWebGL2&&(t+=`precision ${s.precision} sampler3D;
3711
- precision ${s.precision} sampler2DArray;
3712
- precision ${s.precision} sampler2DShadow;
3713
- precision ${s.precision} samplerCubeShadow;
3714
- precision ${s.precision} sampler2DArrayShadow;
3715
- precision ${s.precision} isampler2D;
3716
- precision ${s.precision} isampler3D;
3717
- precision ${s.precision} isamplerCube;
3718
- precision ${s.precision} isampler2DArray;
3719
- precision ${s.precision} usampler2D;
3720
- precision ${s.precision} usampler3D;
3721
- precision ${s.precision} usamplerCube;
3722
- precision ${s.precision} usampler2DArray;
3723
- `),s.precision==="highp"?t+=`
3724
- #define HIGH_PRECISION`:s.precision==="mediump"?t+=`
3725
- #define MEDIUM_PRECISION`:s.precision==="lowp"&&(t+=`
3726
- #define LOW_PRECISION`),t}u(wu,"generatePrecision");function Z0(s){let t="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===Nd?t="SHADOWMAP_TYPE_PCF":s.shadowMapType===pf?t="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===ln&&(t="SHADOWMAP_TYPE_VSM"),t}u(Z0,"generateShadowMapTypeDefine");function J0(s){let t="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Ci:case Pi:t="ENVMAP_TYPE_CUBE";break;case kr:t="ENVMAP_TYPE_CUBE_UV";break}return t}u(J0,"generateEnvMapTypeDefine");function $0(s){let t="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Pi:t="ENVMAP_MODE_REFRACTION";break}return t}u($0,"generateEnvMapModeDefine");function K0(s){let t="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Oo:t="ENVMAP_BLENDING_MULTIPLY";break;case Bf:t="ENVMAP_BLENDING_MIX";break;case zf:t="ENVMAP_BLENDING_ADD";break}return t}u(K0,"generateEnvMapBlendingDefine");function Q0(s){let t=s.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}u(Q0,"generateCubeUVSize");function j0(s,t,e,n){let i=s.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,c=Z0(e),l=J0(e),h=$0(e),d=K0(e),f=Q0(e),g=e.isWebGL2?"":z0(e),_=k0(e),v=V0(r),m=i.createProgram(),p,w,x=e.glslVersion?"#version "+e.glslVersion+`
3727
- `:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v].filter(yi).join(`
3728
- `),p.length>0&&(p+=`
3729
- `),w=[g,"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v].filter(yi).join(`
3730
- `),w.length>0&&(w+=`
3731
- `)):(p=[wu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3732
- `].filter(yi).join(`
3733
- `),w=[g,wu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Tn?"#define TONE_MAPPING":"",e.toneMapping!==Tn?zt.tonemapping_pars_fragment:"",e.toneMapping!==Tn?B0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",zt.colorspace_pars_fragment,F0("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3734
- `].filter(yi).join(`
3735
- `)),o=Qa(o),o=Su(o,e),o=bu(o,e),a=Qa(a),a=Su(a,e),a=bu(a,e),o=Eu(o),a=Eu(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(x=`#version 300 es
3736
- `,p=[_,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
3737
- `)+`
3738
- `+p,w=["precision mediump sampler2DArray;","#define varying in",e.glslVersion===Hh?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Hh?"":"#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(`
3739
- `)+`
3740
- `+w);let b=x+p+o,L=x+w+a,C=yu(i,i.VERTEX_SHADER,b),R=yu(i,i.FRAGMENT_SHADER,L);i.attachShader(m,C),i.attachShader(m,R),e.index0AttributeName!==void 0?i.bindAttribLocation(m,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m);function D(Q){if(s.debug.checkShaderErrors){let $=i.getProgramInfoLog(m).trim(),I=i.getShaderInfoLog(C).trim(),G=i.getShaderInfoLog(R).trim(),k=!0,J=!0;if(i.getProgramParameter(m,i.LINK_STATUS)===!1)if(k=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,m,C,R);else{let q=Mu(i,C,"vertex"),Y=Mu(i,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,i.VALIDATE_STATUS)+`
3741
-
3742
- Material Name: `+Q.name+`
3743
- Material Type: `+Q.type+`
3744
-
3745
- Program Info Log: `+$+`
3746
- `+q+`
3747
- `+Y)}else $!==""?console.warn("THREE.WebGLProgram: Program Info Log:",$):(I===""||G==="")&&(J=!1);J&&(Q.diagnostics={runnable:k,programLog:$,vertexShader:{log:I,prefix:p},fragmentShader:{log:G,prefix:w}})}i.deleteShader(C),i.deleteShader(R),X=new Ri(i,m),M=H0(i,m)}u(D,"onFirstUse");let X;this.getUniforms=function(){return X===void 0&&D(this),X};let M;this.getAttributes=function(){return M===void 0&&D(this),M};let A=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=i.getProgramParameter(m,U0)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=D0++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=C,this.fragmentShader=R,this}u(j0,"WebGLProgram");var tx=0,Ac=class Ac{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new to(t),e.set(t,n)),n}};u(Ac,"WebGLShaderCache");var ja=Ac,Tc=class Tc{constructor(t){this.id=tx++,this.code=t,this.usedTimes=0}};u(Tc,"WebGLShaderStage");var to=Tc;function ex(s,t,e,n,i,r,o){let a=new ss,c=new ja,l=new Set,h=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures,_=i.precision,v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(M){return l.add(M),M===0?"uv":`uv${M}`}u(m,"getChannel");function p(M,A,Q,$,I){let G=$.fog,k=I.geometry,J=M.isMeshStandardMaterial?$.environment:null,q=(M.isMeshStandardMaterial?e:t).get(M.envMap||J),Y=q&&q.mapping===kr?q.image.height:null,it=v[M.type];M.precision!==null&&(_=i.getMaxPrecision(M.precision),_!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",_,"instead."));let nt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,_t=nt!==void 0?nt.length:0,It=0;k.morphAttributes.position!==void 0&&(It=1),k.morphAttributes.normal!==void 0&&(It=2),k.morphAttributes.color!==void 0&&(It=3);let V,tt,mt,wt;if(it){let Kt=Qe[it];V=Kt.vertexShader,tt=Kt.fragmentShader}else V=M.vertexShader,tt=M.fragmentShader,c.update(M),mt=c.getVertexShaderID(M),wt=c.getFragmentShaderID(M);let Mt=s.getRenderTarget(),vt=I.isInstancedMesh===!0,Ht=I.isBatchedMesh===!0,At=!!M.map,T=!!M.matcap,ot=!!q,Z=!!M.aoMap,st=!!M.lightMap,K=!!M.bumpMap,xt=!!M.normalMap,pt=!!M.displacementMap,yt=!!M.emissiveMap,Wt=!!M.metalnessMap,E=!!M.roughnessMap,y=M.anisotropy>0,H=M.clearcoat>0,W=M.iridescence>0,et=M.sheen>0,j=M.transmission>0,Lt=y&&!!M.anisotropyMap,Rt=H&&!!M.clearcoatMap,lt=H&&!!M.clearcoatNormalMap,ut=H&&!!M.clearcoatRoughnessMap,Ut=W&&!!M.iridescenceMap,rt=W&&!!M.iridescenceThicknessMap,ae=et&&!!M.sheenColorMap,Xt=et&&!!M.sheenRoughnessMap,Tt=!!M.specularMap,St=!!M.specularColorMap,bt=!!M.specularIntensityMap,Yt=j&&!!M.transmissionMap,Nt=j&&!!M.thicknessMap,te=!!M.gradientMap,U=!!M.alphaMap,dt=M.alphaTest>0,F=!!M.alphaHash,ct=!!M.extensions,ft=Tn;M.toneMapped&&(Mt===null||Mt.isXRRenderTarget===!0)&&(ft=s.toneMapping);let qt={isWebGL2:d,shaderID:it,shaderType:M.type,shaderName:M.name,vertexShader:V,fragmentShader:tt,defines:M.defines,customVertexShaderID:mt,customFragmentShaderID:wt,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:_,batching:Ht,instancing:vt,instancingColor:vt&&I.instanceColor!==null,instancingMorph:vt&&I.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:Mt===null?s.outputColorSpace:Mt.isXRRenderTarget===!0?Mt.texture.colorSpace:Dn,alphaToCoverage:!!M.alphaToCoverage,map:At,matcap:T,envMap:ot,envMapMode:ot&&q.mapping,envMapCubeUVHeight:Y,aoMap:Z,lightMap:st,bumpMap:K,normalMap:xt,displacementMap:g&&pt,emissiveMap:yt,normalMapObjectSpace:xt&&M.normalMapType===sp,normalMapTangentSpace:xt&&M.normalMapType===Bo,metalnessMap:Wt,roughnessMap:E,anisotropy:y,anisotropyMap:Lt,clearcoat:H,clearcoatMap:Rt,clearcoatNormalMap:lt,clearcoatRoughnessMap:ut,iridescence:W,iridescenceMap:Ut,iridescenceThicknessMap:rt,sheen:et,sheenColorMap:ae,sheenRoughnessMap:Xt,specularMap:Tt,specularColorMap:St,specularIntensityMap:bt,transmission:j,transmissionMap:Yt,thicknessMap:Nt,gradientMap:te,opaque:M.transparent===!1&&M.blending===wi&&M.alphaToCoverage===!1,alphaMap:U,alphaTest:dt,alphaHash:F,combine:M.combine,mapUv:At&&m(M.map.channel),aoMapUv:Z&&m(M.aoMap.channel),lightMapUv:st&&m(M.lightMap.channel),bumpMapUv:K&&m(M.bumpMap.channel),normalMapUv:xt&&m(M.normalMap.channel),displacementMapUv:pt&&m(M.displacementMap.channel),emissiveMapUv:yt&&m(M.emissiveMap.channel),metalnessMapUv:Wt&&m(M.metalnessMap.channel),roughnessMapUv:E&&m(M.roughnessMap.channel),anisotropyMapUv:Lt&&m(M.anisotropyMap.channel),clearcoatMapUv:Rt&&m(M.clearcoatMap.channel),clearcoatNormalMapUv:lt&&m(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ut&&m(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Ut&&m(M.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&m(M.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(M.sheenColorMap.channel),sheenRoughnessMapUv:Xt&&m(M.sheenRoughnessMap.channel),specularMapUv:Tt&&m(M.specularMap.channel),specularColorMapUv:St&&m(M.specularColorMap.channel),specularIntensityMapUv:bt&&m(M.specularIntensityMap.channel),transmissionMapUv:Yt&&m(M.transmissionMap.channel),thicknessMapUv:Nt&&m(M.thicknessMap.channel),alphaMapUv:U&&m(M.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(xt||y),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!k.attributes.uv&&(At||U),fog:!!G,useFog:M.fog===!0,fogExp2:!!G&&G.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:I.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:_t,morphTextureStride:It,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&Q.length>0,shadowMapType:s.shadowMap.type,toneMapping:ft,useLegacyLights:s._useLegacyLights,decodeVideoTexture:At&&M.map.isVideoTexture===!0&&Jt.getTransfer(M.map.colorSpace)===jt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===un,flipSided:M.side===Pe,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:ct&&M.extensions.derivatives===!0,extensionFragDepth:ct&&M.extensions.fragDepth===!0,extensionDrawBuffers:ct&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:ct&&M.extensions.shaderTextureLOD===!0,extensionClipCullDistance:ct&&M.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:ct&&M.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionFragDepth:d||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return qt.vertexUv1s=l.has(1),qt.vertexUv2s=l.has(2),qt.vertexUv3s=l.has(3),l.clear(),qt}u(p,"getParameters");function w(M){let A=[];if(M.shaderID?A.push(M.shaderID):(A.push(M.customVertexShaderID),A.push(M.customFragmentShaderID)),M.defines!==void 0)for(let Q in M.defines)A.push(Q),A.push(M.defines[Q]);return M.isRawShaderMaterial===!1&&(x(A,M),b(A,M),A.push(s.outputColorSpace)),A.push(M.customProgramCacheKey),A.join()}u(w,"getProgramCacheKey");function x(M,A){M.push(A.precision),M.push(A.outputColorSpace),M.push(A.envMapMode),M.push(A.envMapCubeUVHeight),M.push(A.mapUv),M.push(A.alphaMapUv),M.push(A.lightMapUv),M.push(A.aoMapUv),M.push(A.bumpMapUv),M.push(A.normalMapUv),M.push(A.displacementMapUv),M.push(A.emissiveMapUv),M.push(A.metalnessMapUv),M.push(A.roughnessMapUv),M.push(A.anisotropyMapUv),M.push(A.clearcoatMapUv),M.push(A.clearcoatNormalMapUv),M.push(A.clearcoatRoughnessMapUv),M.push(A.iridescenceMapUv),M.push(A.iridescenceThicknessMapUv),M.push(A.sheenColorMapUv),M.push(A.sheenRoughnessMapUv),M.push(A.specularMapUv),M.push(A.specularColorMapUv),M.push(A.specularIntensityMapUv),M.push(A.transmissionMapUv),M.push(A.thicknessMapUv),M.push(A.combine),M.push(A.fogExp2),M.push(A.sizeAttenuation),M.push(A.morphTargetsCount),M.push(A.morphAttributeCount),M.push(A.numDirLights),M.push(A.numPointLights),M.push(A.numSpotLights),M.push(A.numSpotLightMaps),M.push(A.numHemiLights),M.push(A.numRectAreaLights),M.push(A.numDirLightShadows),M.push(A.numPointLightShadows),M.push(A.numSpotLightShadows),M.push(A.numSpotLightShadowsWithMaps),M.push(A.numLightProbes),M.push(A.shadowMapType),M.push(A.toneMapping),M.push(A.numClippingPlanes),M.push(A.numClipIntersection),M.push(A.depthPacking)}u(x,"getProgramCacheKeyParameters");function b(M,A){a.disableAll(),A.isWebGL2&&a.enable(0),A.supportsVertexTextures&&a.enable(1),A.instancing&&a.enable(2),A.instancingColor&&a.enable(3),A.instancingMorph&&a.enable(4),A.matcap&&a.enable(5),A.envMap&&a.enable(6),A.normalMapObjectSpace&&a.enable(7),A.normalMapTangentSpace&&a.enable(8),A.clearcoat&&a.enable(9),A.iridescence&&a.enable(10),A.alphaTest&&a.enable(11),A.vertexColors&&a.enable(12),A.vertexAlphas&&a.enable(13),A.vertexUv1s&&a.enable(14),A.vertexUv2s&&a.enable(15),A.vertexUv3s&&a.enable(16),A.vertexTangents&&a.enable(17),A.anisotropy&&a.enable(18),A.alphaHash&&a.enable(19),A.batching&&a.enable(20),M.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.skinning&&a.enable(4),A.morphTargets&&a.enable(5),A.morphNormals&&a.enable(6),A.morphColors&&a.enable(7),A.premultipliedAlpha&&a.enable(8),A.shadowMapEnabled&&a.enable(9),A.useLegacyLights&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.alphaToCoverage&&a.enable(20),M.push(a.mask)}u(b,"getProgramCacheKeyBooleans");function L(M){let A=v[M.type],Q;if(A){let $=Qe[A];Q=Hp.clone($.uniforms)}else Q=M.uniforms;return Q}u(L,"getUniforms");function C(M,A){let Q;for(let $=0,I=h.length;$<I;$++){let G=h[$];if(G.cacheKey===A){Q=G,++Q.usedTimes;break}}return Q===void 0&&(Q=new j0(s,A,M,r),h.push(Q)),Q}u(C,"acquireProgram");function R(M){if(--M.usedTimes===0){let A=h.indexOf(M);h[A]=h[h.length-1],h.pop(),M.destroy()}}u(R,"releaseProgram");function D(M){c.remove(M)}u(D,"releaseShaderCache");function X(){c.dispose()}return u(X,"dispose"),{getParameters:p,getProgramCacheKey:w,getUniforms:L,acquireProgram:C,releaseProgram:R,releaseShaderCache:D,programs:h,dispose:X}}u(ex,"WebGLPrograms");function nx(){let s=new WeakMap;function t(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}u(t,"get");function e(r){s.delete(r)}u(e,"remove");function n(r,o,a){s.get(r)[o]=a}u(n,"update");function i(){s=new WeakMap}return u(i,"dispose"),{get:t,remove:e,update:n,dispose:i}}u(nx,"WebGLProperties");function ix(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.z!==t.z?s.z-t.z:s.id-t.id}u(ix,"painterSortStable");function Au(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}u(Au,"reversePainterSortStable");function Tu(){let s=[],t=0,e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}u(r,"init");function o(d,f,g,_,v,m){let p=s[t];return p===void 0?(p={id:d.id,object:d,geometry:f,material:g,groupOrder:_,renderOrder:d.renderOrder,z:v,group:m},s[t]=p):(p.id=d.id,p.object=d,p.geometry=f,p.material=g,p.groupOrder=_,p.renderOrder=d.renderOrder,p.z=v,p.group=m),t++,p}u(o,"getNextRenderItem");function a(d,f,g,_,v,m){let p=o(d,f,g,_,v,m);g.transmission>0?n.push(p):g.transparent===!0?i.push(p):e.push(p)}u(a,"push");function c(d,f,g,_,v,m){let p=o(d,f,g,_,v,m);g.transmission>0?n.unshift(p):g.transparent===!0?i.unshift(p):e.unshift(p)}u(c,"unshift");function l(d,f){e.length>1&&e.sort(d||ix),n.length>1&&n.sort(f||Au),i.length>1&&i.sort(f||Au)}u(l,"sort");function h(){for(let d=t,f=s.length;d<f;d++){let g=s[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return u(h,"finish"),{opaque:e,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:h,sort:l}}u(Tu,"WebGLRenderList");function sx(){let s=new WeakMap;function t(n,i){let r=s.get(n),o;return r===void 0?(o=new Tu,s.set(n,[o])):i>=r.length?(o=new Tu,r.push(o)):o=r[i],o}u(t,"get");function e(){s=new WeakMap}return u(e,"dispose"),{get:t,dispose:e}}u(sx,"WebGLRenderLists");function rx(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new Vt};break;case"SpotLight":e={position:new P,direction:new P,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new P,halfWidth:new P,halfHeight:new P};break}return s[t.id]=e,e}}}u(rx,"UniformsCache");function ax(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}u(ax,"ShadowUniformsCache");var ox=0;function cx(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}u(cx,"shadowCastingAndTexturingLightsFirst");function lx(s,t){let e=new rx,n=ax(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)i.probe.push(new P);let r=new P,o=new Ft,a=new Ft;function c(h,d){let f=0,g=0,_=0;for(let Q=0;Q<9;Q++)i.probe[Q].set(0,0,0);let v=0,m=0,p=0,w=0,x=0,b=0,L=0,C=0,R=0,D=0,X=0;h.sort(cx);let M=d===!0?Math.PI:1;for(let Q=0,$=h.length;Q<$;Q++){let I=h[Q],G=I.color,k=I.intensity,J=I.distance,q=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)f+=G.r*k*M,g+=G.g*k*M,_+=G.b*k*M;else if(I.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(I.sh.coefficients[Y],k);X++}else if(I.isDirectionalLight){let Y=e.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity*M),I.castShadow){let it=I.shadow,nt=n.get(I);nt.shadowBias=it.bias,nt.shadowNormalBias=it.normalBias,nt.shadowRadius=it.radius,nt.shadowMapSize=it.mapSize,i.directionalShadow[v]=nt,i.directionalShadowMap[v]=q,i.directionalShadowMatrix[v]=I.shadow.matrix,b++}i.directional[v]=Y,v++}else if(I.isSpotLight){let Y=e.get(I);Y.position.setFromMatrixPosition(I.matrixWorld),Y.color.copy(G).multiplyScalar(k*M),Y.distance=J,Y.coneCos=Math.cos(I.angle),Y.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),Y.decay=I.decay,i.spot[p]=Y;let it=I.shadow;if(I.map&&(i.spotLightMap[R]=I.map,R++,it.updateMatrices(I),I.castShadow&&D++),i.spotLightMatrix[p]=it.matrix,I.castShadow){let nt=n.get(I);nt.shadowBias=it.bias,nt.shadowNormalBias=it.normalBias,nt.shadowRadius=it.radius,nt.shadowMapSize=it.mapSize,i.spotShadow[p]=nt,i.spotShadowMap[p]=q,C++}p++}else if(I.isRectAreaLight){let Y=e.get(I);Y.color.copy(G).multiplyScalar(k),Y.halfWidth.set(I.width*.5,0,0),Y.halfHeight.set(0,I.height*.5,0),i.rectArea[w]=Y,w++}else if(I.isPointLight){let Y=e.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity*M),Y.distance=I.distance,Y.decay=I.decay,I.castShadow){let it=I.shadow,nt=n.get(I);nt.shadowBias=it.bias,nt.shadowNormalBias=it.normalBias,nt.shadowRadius=it.radius,nt.shadowMapSize=it.mapSize,nt.shadowCameraNear=it.camera.near,nt.shadowCameraFar=it.camera.far,i.pointShadow[m]=nt,i.pointShadowMap[m]=q,i.pointShadowMatrix[m]=I.shadow.matrix,L++}i.point[m]=Y,m++}else if(I.isHemisphereLight){let Y=e.get(I);Y.skyColor.copy(I.color).multiplyScalar(k*M),Y.groundColor.copy(I.groundColor).multiplyScalar(k*M),i.hemi[x]=Y,x++}}w>0&&(t.isWebGL2?s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ht.LTC_FLOAT_1,i.rectAreaLTC2=ht.LTC_FLOAT_2):(i.rectAreaLTC1=ht.LTC_HALF_1,i.rectAreaLTC2=ht.LTC_HALF_2):s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ht.LTC_FLOAT_1,i.rectAreaLTC2=ht.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ht.LTC_HALF_1,i.rectAreaLTC2=ht.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=g,i.ambient[2]=_;let A=i.hash;(A.directionalLength!==v||A.pointLength!==m||A.spotLength!==p||A.rectAreaLength!==w||A.hemiLength!==x||A.numDirectionalShadows!==b||A.numPointShadows!==L||A.numSpotShadows!==C||A.numSpotMaps!==R||A.numLightProbes!==X)&&(i.directional.length=v,i.spot.length=p,i.rectArea.length=w,i.point.length=m,i.hemi.length=x,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=L,i.pointShadowMap.length=L,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=L,i.spotLightMatrix.length=C+R-D,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=X,A.directionalLength=v,A.pointLength=m,A.spotLength=p,A.rectAreaLength=w,A.hemiLength=x,A.numDirectionalShadows=b,A.numPointShadows=L,A.numSpotShadows=C,A.numSpotMaps=R,A.numLightProbes=X,i.version=ox++)}u(c,"setup");function l(h,d){let f=0,g=0,_=0,v=0,m=0,p=d.matrixWorldInverse;for(let w=0,x=h.length;w<x;w++){let b=h[w];if(b.isDirectionalLight){let L=i.directional[f];L.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),L.direction.sub(r),L.direction.transformDirection(p),f++}else if(b.isSpotLight){let L=i.spot[_];L.position.setFromMatrixPosition(b.matrixWorld),L.position.applyMatrix4(p),L.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),L.direction.sub(r),L.direction.transformDirection(p),_++}else if(b.isRectAreaLight){let L=i.rectArea[v];L.position.setFromMatrixPosition(b.matrixWorld),L.position.applyMatrix4(p),a.identity(),o.copy(b.matrixWorld),o.premultiply(p),a.extractRotation(o),L.halfWidth.set(b.width*.5,0,0),L.halfHeight.set(0,b.height*.5,0),L.halfWidth.applyMatrix4(a),L.halfHeight.applyMatrix4(a),v++}else if(b.isPointLight){let L=i.point[g];L.position.setFromMatrixPosition(b.matrixWorld),L.position.applyMatrix4(p),g++}else if(b.isHemisphereLight){let L=i.hemi[m];L.direction.setFromMatrixPosition(b.matrixWorld),L.direction.transformDirection(p),m++}}}return u(l,"setupView"),{setup:c,setupView:l,state:i}}u(lx,"WebGLLights");function Ru(s,t){let e=new lx(s,t),n=[],i=[];function r(){n.length=0,i.length=0}u(r,"init");function o(d){n.push(d)}u(o,"pushLight");function a(d){i.push(d)}u(a,"pushShadow");function c(d){e.setup(n,d)}u(c,"setupLights");function l(d){e.setupView(n,d)}return u(l,"setupLightsView"),{init:r,state:{lightsArray:n,shadowsArray:i,lights:e},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}u(Ru,"WebGLRenderState");function hx(s,t){let e=new WeakMap;function n(r,o=0){let a=e.get(r),c;return a===void 0?(c=new Ru(s,t),e.set(r,[c])):o>=a.length?(c=new Ru(s,t),a.push(c)):c=a[o],c}u(n,"get");function i(){e=new WeakMap}return u(i,"dispose"),{get:n,dispose:i}}u(hx,"WebGLRenderStates");var Rc=class Rc extends je{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=np,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}};u(Rc,"MeshDepthMaterial");var eo=Rc,Cc=class Cc extends je{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};u(Cc,"MeshDistanceMaterial");var no=Cc,ux=`void main() {
3748
- gl_Position = vec4( position, 1.0 );
3749
- }`,dx=`uniform sampler2D shadow_pass;
3750
- uniform vec2 resolution;
3751
- uniform float radius;
3752
- #include <packing>
3753
- void main() {
3754
- const float samples = float( VSM_SAMPLES );
3755
- float mean = 0.0;
3756
- float squared_mean = 0.0;
3757
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3758
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3759
- for ( float i = 0.0; i < samples; i ++ ) {
3760
- float uvOffset = uvStart + i * uvStride;
3761
- #ifdef HORIZONTAL_PASS
3762
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3763
- mean += distribution.x;
3764
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3765
- #else
3766
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3767
- mean += depth;
3768
- squared_mean += depth * depth;
3769
- #endif
3770
- }
3771
- mean = mean / samples;
3772
- squared_mean = squared_mean / samples;
3773
- float std_dev = sqrt( squared_mean - mean * mean );
3774
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3775
- }`;function fx(s,t,e){let n=new Di,i=new at,r=new at,o=new $t,a=new eo({depthPacking:ip}),c=new no,l={},h=e.maxTextureSize,d={[Cn]:Pe,[Pe]:Cn,[un]:un},f=new tn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new at},radius:{value:4}},vertexShader:ux,fragmentShader:dx}),g=f.clone();g.defines.HORIZONTAL_PASS=1;let _=new Le;_.setAttribute("position",new Se(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Me(_,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nd;let p=this.type;this.render=function(C,R,D){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||C.length===0)return;let X=s.getRenderTarget(),M=s.getActiveCubeFace(),A=s.getActiveMipmapLevel(),Q=s.state;Q.setBlending(An),Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);let $=p!==ln&&this.type===ln,I=p===ln&&this.type!==ln;for(let G=0,k=C.length;G<k;G++){let J=C[G],q=J.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",J,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;i.copy(q.mapSize);let Y=q.getFrameExtents();if(i.multiply(Y),r.copy(q.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,q.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,q.mapSize.y=r.y)),q.map===null||$===!0||I===!0){let nt=this.type!==ln?{minFilter:ge,magFilter:ge}:{};q.map!==null&&q.map.dispose(),q.map=new fn(i.x,i.y,nt),q.map.texture.name=J.name+".shadowMap",q.camera.updateProjectionMatrix()}s.setRenderTarget(q.map),s.clear();let it=q.getViewportCount();for(let nt=0;nt<it;nt++){let _t=q.getViewport(nt);o.set(r.x*_t.x,r.y*_t.y,r.x*_t.z,r.y*_t.w),Q.viewport(o),q.updateMatrices(J,nt),n=q.getFrustum(),b(R,D,q.camera,J,this.type)}q.isPointLightShadow!==!0&&this.type===ln&&w(q,D),q.needsUpdate=!1}p=this.type,m.needsUpdate=!1,s.setRenderTarget(X,M,A)};function w(C,R){let D=t.update(v);f.defines.VSM_SAMPLES!==C.blurSamples&&(f.defines.VSM_SAMPLES=C.blurSamples,g.defines.VSM_SAMPLES=C.blurSamples,f.needsUpdate=!0,g.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new fn(i.x,i.y)),f.uniforms.shadow_pass.value=C.map.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,s.setRenderTarget(C.mapPass),s.clear(),s.renderBufferDirect(R,null,D,f,v,null),g.uniforms.shadow_pass.value=C.mapPass.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,s.setRenderTarget(C.map),s.clear(),s.renderBufferDirect(R,null,D,g,v,null)}u(w,"VSMPass");function x(C,R,D,X){let M=null,A=D.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(A!==void 0)M=A;else if(M=D.isPointLight===!0?c:a,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let Q=M.uuid,$=R.uuid,I=l[Q];I===void 0&&(I={},l[Q]=I);let G=I[$];G===void 0&&(G=M.clone(),I[$]=G,R.addEventListener("dispose",L)),M=G}if(M.visible=R.visible,M.wireframe=R.wireframe,X===ln?M.side=R.shadowSide!==null?R.shadowSide:R.side:M.side=R.shadowSide!==null?R.shadowSide:d[R.side],M.alphaMap=R.alphaMap,M.alphaTest=R.alphaTest,M.map=R.map,M.clipShadows=R.clipShadows,M.clippingPlanes=R.clippingPlanes,M.clipIntersection=R.clipIntersection,M.displacementMap=R.displacementMap,M.displacementScale=R.displacementScale,M.displacementBias=R.displacementBias,M.wireframeLinewidth=R.wireframeLinewidth,M.linewidth=R.linewidth,D.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let Q=s.properties.get(M);Q.light=D}return M}u(x,"getDepthMaterial");function b(C,R,D,X,M){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&M===ln)&&(!C.frustumCulled||n.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,C.matrixWorld);let $=t.update(C),I=C.material;if(Array.isArray(I)){let G=$.groups;for(let k=0,J=G.length;k<J;k++){let q=G[k],Y=I[q.materialIndex];if(Y&&Y.visible){let it=x(C,Y,X,M);C.onBeforeShadow(s,C,R,D,$,it,q),s.renderBufferDirect(D,null,$,it,C,q),C.onAfterShadow(s,C,R,D,$,it,q)}}}else if(I.visible){let G=x(C,I,X,M);C.onBeforeShadow(s,C,R,D,$,G,null),s.renderBufferDirect(D,null,$,G,C,null),C.onAfterShadow(s,C,R,D,$,G,null)}}let Q=C.children;for(let $=0,I=Q.length;$<I;$++)b(Q[$],R,D,X,M)}u(b,"renderObject");function L(C){C.target.removeEventListener("dispose",L);for(let D in l){let X=l[D],M=C.target.uuid;M in X&&(X[M].dispose(),delete X[M])}}u(L,"onMaterialDispose")}u(fx,"WebGLShadowMap");function px(s,t,e){let n=e.isWebGL2;function i(){let U=!1,dt=new $t,F=null,ct=new $t(0,0,0,0);return{setMask:function(ft){F!==ft&&!U&&(s.colorMask(ft,ft,ft,ft),F=ft)},setLocked:function(ft){U=ft},setClear:function(ft,qt,Kt,me,Fe){Fe===!0&&(ft*=me,qt*=me,Kt*=me),dt.set(ft,qt,Kt,me),ct.equals(dt)===!1&&(s.clearColor(ft,qt,Kt,me),ct.copy(dt))},reset:function(){U=!1,F=null,ct.set(-1,0,0,0)}}}u(i,"ColorBuffer");function r(){let U=!1,dt=null,F=null,ct=null;return{setTest:function(ft){ft?vt(s.DEPTH_TEST):Ht(s.DEPTH_TEST)},setMask:function(ft){dt!==ft&&!U&&(s.depthMask(ft),dt=ft)},setFunc:function(ft){if(F!==ft){switch(ft){case If:s.depthFunc(s.NEVER);break;case Lf:s.depthFunc(s.ALWAYS);break;case Uf:s.depthFunc(s.LESS);break;case Js:s.depthFunc(s.LEQUAL);break;case Df:s.depthFunc(s.EQUAL);break;case Nf:s.depthFunc(s.GEQUAL);break;case Of:s.depthFunc(s.GREATER);break;case Ff:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}F=ft}},setLocked:function(ft){U=ft},setClear:function(ft){ct!==ft&&(s.clearDepth(ft),ct=ft)},reset:function(){U=!1,dt=null,F=null,ct=null}}}u(r,"DepthBuffer");function o(){let U=!1,dt=null,F=null,ct=null,ft=null,qt=null,Kt=null,me=null,Fe=null;return{setTest:function(Qt){U||(Qt?vt(s.STENCIL_TEST):Ht(s.STENCIL_TEST))},setMask:function(Qt){dt!==Qt&&!U&&(s.stencilMask(Qt),dt=Qt)},setFunc:function(Qt,Ee,$e){(F!==Qt||ct!==Ee||ft!==$e)&&(s.stencilFunc(Qt,Ee,$e),F=Qt,ct=Ee,ft=$e)},setOp:function(Qt,Ee,$e){(qt!==Qt||Kt!==Ee||me!==$e)&&(s.stencilOp(Qt,Ee,$e),qt=Qt,Kt=Ee,me=$e)},setLocked:function(Qt){U=Qt},setClear:function(Qt){Fe!==Qt&&(s.clearStencil(Qt),Fe=Qt)},reset:function(){U=!1,dt=null,F=null,ct=null,ft=null,qt=null,Kt=null,me=null,Fe=null}}}u(o,"StencilBuffer");let a=new i,c=new r,l=new o,h=new WeakMap,d=new WeakMap,f={},g={},_=new WeakMap,v=[],m=null,p=!1,w=null,x=null,b=null,L=null,C=null,R=null,D=null,X=new Vt(0,0,0),M=0,A=!1,Q=null,$=null,I=null,G=null,k=null,J=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),q=!1,Y=0,it=s.getParameter(s.VERSION);it.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(it)[1]),q=Y>=1):it.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(it)[1]),q=Y>=2);let nt=null,_t={},It=s.getParameter(s.SCISSOR_BOX),V=s.getParameter(s.VIEWPORT),tt=new $t().fromArray(It),mt=new $t().fromArray(V);function wt(U,dt,F,ct){let ft=new Uint8Array(4),qt=s.createTexture();s.bindTexture(U,qt),s.texParameteri(U,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(U,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Kt=0;Kt<F;Kt++)n&&(U===s.TEXTURE_3D||U===s.TEXTURE_2D_ARRAY)?s.texImage3D(dt,0,s.RGBA,1,1,ct,0,s.RGBA,s.UNSIGNED_BYTE,ft):s.texImage2D(dt+Kt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ft);return qt}u(wt,"createTexture");let Mt={};Mt[s.TEXTURE_2D]=wt(s.TEXTURE_2D,s.TEXTURE_2D,1),Mt[s.TEXTURE_CUBE_MAP]=wt(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(Mt[s.TEXTURE_2D_ARRAY]=wt(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),Mt[s.TEXTURE_3D]=wt(s.TEXTURE_3D,s.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),vt(s.DEPTH_TEST),c.setFunc(Js),pt(!1),yt(rh),vt(s.CULL_FACE),K(An);function vt(U){f[U]!==!0&&(s.enable(U),f[U]=!0)}u(vt,"enable");function Ht(U){f[U]!==!1&&(s.disable(U),f[U]=!1)}u(Ht,"disable");function At(U,dt){return g[U]!==dt?(s.bindFramebuffer(U,dt),g[U]=dt,n&&(U===s.DRAW_FRAMEBUFFER&&(g[s.FRAMEBUFFER]=dt),U===s.FRAMEBUFFER&&(g[s.DRAW_FRAMEBUFFER]=dt)),!0):!1}u(At,"bindFramebuffer");function T(U,dt){let F=v,ct=!1;if(U){F=_.get(dt),F===void 0&&(F=[],_.set(dt,F));let ft=U.textures;if(F.length!==ft.length||F[0]!==s.COLOR_ATTACHMENT0){for(let qt=0,Kt=ft.length;qt<Kt;qt++)F[qt]=s.COLOR_ATTACHMENT0+qt;F.length=ft.length,ct=!0}}else F[0]!==s.BACK&&(F[0]=s.BACK,ct=!0);if(ct)if(e.isWebGL2)s.drawBuffers(F);else if(t.has("WEBGL_draw_buffers")===!0)t.get("WEBGL_draw_buffers").drawBuffersWEBGL(F);else throw new Error("THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension")}u(T,"drawBuffers");function ot(U){return m!==U?(s.useProgram(U),m=U,!0):!1}u(ot,"useProgram");let Z={[Xn]:s.FUNC_ADD,[gf]:s.FUNC_SUBTRACT,[_f]:s.FUNC_REVERSE_SUBTRACT};if(n)Z[lh]=s.MIN,Z[hh]=s.MAX;else{let U=t.get("EXT_blend_minmax");U!==null&&(Z[lh]=U.MIN_EXT,Z[hh]=U.MAX_EXT)}let st={[xf]:s.ZERO,[vf]:s.ONE,[yf]:s.SRC_COLOR,[Oa]:s.SRC_ALPHA,[Af]:s.SRC_ALPHA_SATURATE,[Ef]:s.DST_COLOR,[Sf]:s.DST_ALPHA,[Mf]:s.ONE_MINUS_SRC_COLOR,[Fa]:s.ONE_MINUS_SRC_ALPHA,[wf]:s.ONE_MINUS_DST_COLOR,[bf]:s.ONE_MINUS_DST_ALPHA,[Tf]:s.CONSTANT_COLOR,[Rf]:s.ONE_MINUS_CONSTANT_COLOR,[Cf]:s.CONSTANT_ALPHA,[Pf]:s.ONE_MINUS_CONSTANT_ALPHA};function K(U,dt,F,ct,ft,qt,Kt,me,Fe,Qt){if(U===An){p===!0&&(Ht(s.BLEND),p=!1);return}if(p===!1&&(vt(s.BLEND),p=!0),U!==mf){if(U!==w||Qt!==A){if((x!==Xn||C!==Xn)&&(s.blendEquation(s.FUNC_ADD),x=Xn,C=Xn),Qt)switch(U){case wi:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ah:s.blendFunc(s.ONE,s.ONE);break;case oh:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case ch:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case wi:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ah:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case oh:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case ch:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}b=null,L=null,R=null,D=null,X.set(0,0,0),M=0,w=U,A=Qt}return}ft=ft||dt,qt=qt||F,Kt=Kt||ct,(dt!==x||ft!==C)&&(s.blendEquationSeparate(Z[dt],Z[ft]),x=dt,C=ft),(F!==b||ct!==L||qt!==R||Kt!==D)&&(s.blendFuncSeparate(st[F],st[ct],st[qt],st[Kt]),b=F,L=ct,R=qt,D=Kt),(me.equals(X)===!1||Fe!==M)&&(s.blendColor(me.r,me.g,me.b,Fe),X.copy(me),M=Fe),w=U,A=!1}u(K,"setBlending");function xt(U,dt){U.side===un?Ht(s.CULL_FACE):vt(s.CULL_FACE);let F=U.side===Pe;dt&&(F=!F),pt(F),U.blending===wi&&U.transparent===!1?K(An):K(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),c.setFunc(U.depthFunc),c.setTest(U.depthTest),c.setMask(U.depthWrite),a.setMask(U.colorWrite);let ct=U.stencilWrite;l.setTest(ct),ct&&(l.setMask(U.stencilWriteMask),l.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),l.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),E(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?vt(s.SAMPLE_ALPHA_TO_COVERAGE):Ht(s.SAMPLE_ALPHA_TO_COVERAGE)}u(xt,"setMaterial");function pt(U){Q!==U&&(U?s.frontFace(s.CW):s.frontFace(s.CCW),Q=U)}u(pt,"setFlipSided");function yt(U){U!==df?(vt(s.CULL_FACE),U!==$&&(U===rh?s.cullFace(s.BACK):U===ff?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Ht(s.CULL_FACE),$=U}u(yt,"setCullFace");function Wt(U){U!==I&&(q&&s.lineWidth(U),I=U)}u(Wt,"setLineWidth");function E(U,dt,F){U?(vt(s.POLYGON_OFFSET_FILL),(G!==dt||k!==F)&&(s.polygonOffset(dt,F),G=dt,k=F)):Ht(s.POLYGON_OFFSET_FILL)}u(E,"setPolygonOffset");function y(U){U?vt(s.SCISSOR_TEST):Ht(s.SCISSOR_TEST)}u(y,"setScissorTest");function H(U){U===void 0&&(U=s.TEXTURE0+J-1),nt!==U&&(s.activeTexture(U),nt=U)}u(H,"activeTexture");function W(U,dt,F){F===void 0&&(nt===null?F=s.TEXTURE0+J-1:F=nt);let ct=_t[F];ct===void 0&&(ct={type:void 0,texture:void 0},_t[F]=ct),(ct.type!==U||ct.texture!==dt)&&(nt!==F&&(s.activeTexture(F),nt=F),s.bindTexture(U,dt||Mt[U]),ct.type=U,ct.texture=dt)}u(W,"bindTexture");function et(){let U=_t[nt];U!==void 0&&U.type!==void 0&&(s.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}u(et,"unbindTexture");function j(){try{s.compressedTexImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(j,"compressedTexImage2D");function Lt(){try{s.compressedTexImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(Lt,"compressedTexImage3D");function Rt(){try{s.texSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(Rt,"texSubImage2D");function lt(){try{s.texSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(lt,"texSubImage3D");function ut(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(ut,"compressedTexSubImage2D");function Ut(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(Ut,"compressedTexSubImage3D");function rt(){try{s.texStorage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(rt,"texStorage2D");function ae(){try{s.texStorage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(ae,"texStorage3D");function Xt(){try{s.texImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(Xt,"texImage2D");function Tt(){try{s.texImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}u(Tt,"texImage3D");function St(U){tt.equals(U)===!1&&(s.scissor(U.x,U.y,U.z,U.w),tt.copy(U))}u(St,"scissor");function bt(U){mt.equals(U)===!1&&(s.viewport(U.x,U.y,U.z,U.w),mt.copy(U))}u(bt,"viewport");function Yt(U,dt){let F=d.get(dt);F===void 0&&(F=new WeakMap,d.set(dt,F));let ct=F.get(U);ct===void 0&&(ct=s.getUniformBlockIndex(dt,U.name),F.set(U,ct))}u(Yt,"updateUBOMapping");function Nt(U,dt){let ct=d.get(dt).get(U);h.get(dt)!==ct&&(s.uniformBlockBinding(dt,ct,U.__bindingPointIndex),h.set(dt,ct))}u(Nt,"uniformBlockBinding");function te(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),n===!0&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null)),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),f={},nt=null,_t={},g={},_=new WeakMap,v=[],m=null,p=!1,w=null,x=null,b=null,L=null,C=null,R=null,D=null,X=new Vt(0,0,0),M=0,A=!1,Q=null,$=null,I=null,G=null,k=null,tt.set(0,0,s.canvas.width,s.canvas.height),mt.set(0,0,s.canvas.width,s.canvas.height),a.reset(),c.reset(),l.reset()}return u(te,"reset"),{buffers:{color:a,depth:c,stencil:l},enable:vt,disable:Ht,bindFramebuffer:At,drawBuffers:T,useProgram:ot,setBlending:K,setMaterial:xt,setFlipSided:pt,setCullFace:yt,setLineWidth:Wt,setPolygonOffset:E,setScissorTest:y,activeTexture:H,bindTexture:W,unbindTexture:et,compressedTexImage2D:j,compressedTexImage3D:Lt,texImage2D:Xt,texImage3D:Tt,updateUBOMapping:Yt,uniformBlockBinding:Nt,texStorage2D:rt,texStorage3D:ae,texSubImage2D:Rt,texSubImage3D:lt,compressedTexSubImage2D:ut,compressedTexSubImage3D:Ut,scissor:St,viewport:bt,reset:te}}u(px,"WebGLState");function mx(s,t,e,n,i,r,o){let a=i.isWebGL2,c=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new at,d=new WeakMap,f,g=new WeakMap,_=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(E,y){return _?new OffscreenCanvas(E,y):is("canvas")}u(v,"createCanvas");function m(E,y,H,W){let et=1,j=Wt(E);if((j.width>W||j.height>W)&&(et=W/Math.max(j.width,j.height)),et<1||y===!0)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let Lt=y?nr:Math.floor,Rt=Lt(et*j.width),lt=Lt(et*j.height);f===void 0&&(f=v(Rt,lt));let ut=H?v(Rt,lt):f;return ut.width=Rt,ut.height=lt,ut.getContext("2d").drawImage(E,0,0,Rt,lt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+Rt+"x"+lt+")."),ut}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),E;return E}u(m,"resizeImage");function p(E){let y=Wt(E);return Wa(y.width)&&Wa(y.height)}u(p,"isPowerOfTwo$1");function w(E){return a?!1:E.wrapS!==Ye||E.wrapT!==Ye||E.minFilter!==ge&&E.minFilter!==Ce}u(w,"textureNeedsPowerOfTwo");function x(E,y){return E.generateMipmaps&&y&&E.minFilter!==ge&&E.minFilter!==Ce}u(x,"textureNeedsGenerateMipmaps");function b(E){s.generateMipmap(E)}u(b,"generateMipmap");function L(E,y,H,W,et=!1){if(a===!1)return y;if(E!==null){if(s[E]!==void 0)return s[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let j=y;if(y===s.RED&&(H===s.FLOAT&&(j=s.R32F),H===s.HALF_FLOAT&&(j=s.R16F),H===s.UNSIGNED_BYTE&&(j=s.R8)),y===s.RED_INTEGER&&(H===s.UNSIGNED_BYTE&&(j=s.R8UI),H===s.UNSIGNED_SHORT&&(j=s.R16UI),H===s.UNSIGNED_INT&&(j=s.R32UI),H===s.BYTE&&(j=s.R8I),H===s.SHORT&&(j=s.R16I),H===s.INT&&(j=s.R32I)),y===s.RG&&(H===s.FLOAT&&(j=s.RG32F),H===s.HALF_FLOAT&&(j=s.RG16F),H===s.UNSIGNED_BYTE&&(j=s.RG8)),y===s.RG_INTEGER&&(H===s.UNSIGNED_BYTE&&(j=s.RG8UI),H===s.UNSIGNED_SHORT&&(j=s.RG16UI),H===s.UNSIGNED_INT&&(j=s.RG32UI),H===s.BYTE&&(j=s.RG8I),H===s.SHORT&&(j=s.RG16I),H===s.INT&&(j=s.RG32I)),y===s.RGBA){let Lt=et?Qs:Jt.getTransfer(W);H===s.FLOAT&&(j=s.RGBA32F),H===s.HALF_FLOAT&&(j=s.RGBA16F),H===s.UNSIGNED_BYTE&&(j=Lt===jt?s.SRGB8_ALPHA8:s.RGBA8),H===s.UNSIGNED_SHORT_4_4_4_4&&(j=s.RGBA4),H===s.UNSIGNED_SHORT_5_5_5_1&&(j=s.RGB5_A1)}return(j===s.R16F||j===s.R32F||j===s.RG16F||j===s.RG32F||j===s.RGBA16F||j===s.RGBA32F)&&t.get("EXT_color_buffer_float"),j}u(L,"getInternalFormat");function C(E,y,H){return x(E,H)===!0||E.isFramebufferTexture&&E.minFilter!==ge&&E.minFilter!==Ce?Math.log2(Math.max(y.width,y.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?y.mipmaps.length:1}u(C,"getMipLevels");function R(E){return E===ge||E===dh||E===Vi?s.NEAREST:s.LINEAR}u(R,"filterFallback");function D(E){let y=E.target;y.removeEventListener("dispose",D),M(y),y.isVideoTexture&&d.delete(y)}u(D,"onTextureDispose");function X(E){let y=E.target;y.removeEventListener("dispose",X),Q(y)}u(X,"onRenderTargetDispose");function M(E){let y=n.get(E);if(y.__webglInit===void 0)return;let H=E.source,W=g.get(H);if(W){let et=W[y.__cacheKey];et.usedTimes--,et.usedTimes===0&&A(E),Object.keys(W).length===0&&g.delete(H)}n.remove(E)}u(M,"deallocateTexture");function A(E){let y=n.get(E);s.deleteTexture(y.__webglTexture);let H=E.source,W=g.get(H);delete W[y.__cacheKey],o.memory.textures--}u(A,"deleteTexture");function Q(E){let y=n.get(E);if(E.depthTexture&&E.depthTexture.dispose(),E.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let et=0;et<y.__webglFramebuffer[W].length;et++)s.deleteFramebuffer(y.__webglFramebuffer[W][et]);else s.deleteFramebuffer(y.__webglFramebuffer[W]);y.__webglDepthbuffer&&s.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)s.deleteFramebuffer(y.__webglFramebuffer[W]);else s.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&s.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&s.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let W=0;W<y.__webglColorRenderbuffer.length;W++)y.__webglColorRenderbuffer[W]&&s.deleteRenderbuffer(y.__webglColorRenderbuffer[W]);y.__webglDepthRenderbuffer&&s.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let H=E.textures;for(let W=0,et=H.length;W<et;W++){let j=n.get(H[W]);j.__webglTexture&&(s.deleteTexture(j.__webglTexture),o.memory.textures--),n.remove(H[W])}n.remove(E)}u(Q,"deallocateRenderTarget");let $=0;function I(){$=0}u(I,"resetTextureUnits");function G(){let E=$;return E>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+i.maxTextures),$+=1,E}u(G,"allocateTextureUnit");function k(E){let y=[];return y.push(E.wrapS),y.push(E.wrapT),y.push(E.wrapR||0),y.push(E.magFilter),y.push(E.minFilter),y.push(E.anisotropy),y.push(E.internalFormat),y.push(E.format),y.push(E.type),y.push(E.generateMipmaps),y.push(E.premultiplyAlpha),y.push(E.flipY),y.push(E.unpackAlignment),y.push(E.colorSpace),y.join()}u(k,"getTextureCacheKey");function J(E,y){let H=n.get(E);if(E.isVideoTexture&&pt(E),E.isRenderTargetTexture===!1&&E.version>0&&H.__version!==E.version){let W=E.image;if(W===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{mt(H,E,y);return}}e.bindTexture(s.TEXTURE_2D,H.__webglTexture,s.TEXTURE0+y)}u(J,"setTexture2D");function q(E,y){let H=n.get(E);if(E.version>0&&H.__version!==E.version){mt(H,E,y);return}e.bindTexture(s.TEXTURE_2D_ARRAY,H.__webglTexture,s.TEXTURE0+y)}u(q,"setTexture2DArray");function Y(E,y){let H=n.get(E);if(E.version>0&&H.__version!==E.version){mt(H,E,y);return}e.bindTexture(s.TEXTURE_3D,H.__webglTexture,s.TEXTURE0+y)}u(Y,"setTexture3D");function it(E,y){let H=n.get(E);if(E.version>0&&H.__version!==E.version){wt(H,E,y);return}e.bindTexture(s.TEXTURE_CUBE_MAP,H.__webglTexture,s.TEXTURE0+y)}u(it,"setTextureCube");let nt={[ka]:s.REPEAT,[Ye]:s.CLAMP_TO_EDGE,[Va]:s.MIRRORED_REPEAT},_t={[ge]:s.NEAREST,[dh]:s.NEAREST_MIPMAP_NEAREST,[Vi]:s.NEAREST_MIPMAP_LINEAR,[Ce]:s.LINEAR,[Zr]:s.LINEAR_MIPMAP_NEAREST,[Yn]:s.LINEAR_MIPMAP_LINEAR},It={[rp]:s.NEVER,[up]:s.ALWAYS,[ap]:s.LESS,[Xd]:s.LEQUAL,[op]:s.EQUAL,[hp]:s.GEQUAL,[cp]:s.GREATER,[lp]:s.NOTEQUAL};function V(E,y,H){if(y.type===ke&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Ce||y.magFilter===Zr||y.magFilter===Vi||y.magFilter===Yn||y.minFilter===Ce||y.minFilter===Zr||y.minFilter===Vi||y.minFilter===Yn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),H?(s.texParameteri(E,s.TEXTURE_WRAP_S,nt[y.wrapS]),s.texParameteri(E,s.TEXTURE_WRAP_T,nt[y.wrapT]),(E===s.TEXTURE_3D||E===s.TEXTURE_2D_ARRAY)&&s.texParameteri(E,s.TEXTURE_WRAP_R,nt[y.wrapR]),s.texParameteri(E,s.TEXTURE_MAG_FILTER,_t[y.magFilter]),s.texParameteri(E,s.TEXTURE_MIN_FILTER,_t[y.minFilter])):(s.texParameteri(E,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(E,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(E===s.TEXTURE_3D||E===s.TEXTURE_2D_ARRAY)&&s.texParameteri(E,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(y.wrapS!==Ye||y.wrapT!==Ye)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(E,s.TEXTURE_MAG_FILTER,R(y.magFilter)),s.texParameteri(E,s.TEXTURE_MIN_FILTER,R(y.minFilter)),y.minFilter!==ge&&y.minFilter!==Ce&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),y.compareFunction&&(s.texParameteri(E,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(E,s.TEXTURE_COMPARE_FUNC,It[y.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===ge||y.minFilter!==Vi&&y.minFilter!==Yn||y.type===ke&&t.has("OES_texture_float_linear")===!1||a===!1&&y.type===ns&&t.has("OES_texture_half_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let W=t.get("EXT_texture_filter_anisotropic");s.texParameterf(E,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,i.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}u(V,"setTextureParameters");function tt(E,y){let H=!1;E.__webglInit===void 0&&(E.__webglInit=!0,y.addEventListener("dispose",D));let W=y.source,et=g.get(W);et===void 0&&(et={},g.set(W,et));let j=k(y);if(j!==E.__cacheKey){et[j]===void 0&&(et[j]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,H=!0),et[j].usedTimes++;let Lt=et[E.__cacheKey];Lt!==void 0&&(et[E.__cacheKey].usedTimes--,Lt.usedTimes===0&&A(y)),E.__cacheKey=j,E.__webglTexture=et[j].texture}return H}u(tt,"initTexture");function mt(E,y,H){let W=s.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(W=s.TEXTURE_2D_ARRAY),y.isData3DTexture&&(W=s.TEXTURE_3D);let et=tt(E,y),j=y.source;e.bindTexture(W,E.__webglTexture,s.TEXTURE0+H);let Lt=n.get(j);if(j.version!==Lt.__version||et===!0){e.activeTexture(s.TEXTURE0+H);let Rt=Jt.getPrimaries(Jt.workingColorSpace),lt=y.colorSpace===bn?null:Jt.getPrimaries(y.colorSpace),ut=y.colorSpace===bn||Rt===lt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,y.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,y.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);let Ut=w(y)&&p(y.image)===!1,rt=m(y.image,Ut,!1,i.maxTextureSize);rt=yt(y,rt);let ae=p(rt)||a,Xt=r.convert(y.format,y.colorSpace),Tt=r.convert(y.type),St=L(y.internalFormat,Xt,Tt,y.colorSpace,y.isVideoTexture);V(W,y,ae);let bt,Yt=y.mipmaps,Nt=a&&y.isVideoTexture!==!0&&St!==Wd,te=Lt.__version===void 0||et===!0,U=j.dataReady,dt=C(y,rt,ae);if(y.isDepthTexture)St=s.DEPTH_COMPONENT,a?y.type===ke?St=s.DEPTH_COMPONENT32F:y.type===En?St=s.DEPTH_COMPONENT24:y.type===Jn?St=s.DEPTH24_STENCIL8:St=s.DEPTH_COMPONENT16:y.type===ke&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),y.format===$n&&St===s.DEPTH_COMPONENT&&y.type!==Fo&&y.type!==En&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),y.type=En,Tt=r.convert(y.type)),y.format===Ii&&St===s.DEPTH_COMPONENT&&(St=s.DEPTH_STENCIL,y.type!==Jn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),y.type=Jn,Tt=r.convert(y.type))),te&&(Nt?e.texStorage2D(s.TEXTURE_2D,1,St,rt.width,rt.height):e.texImage2D(s.TEXTURE_2D,0,St,rt.width,rt.height,0,Xt,Tt,null));else if(y.isDataTexture)if(Yt.length>0&&ae){Nt&&te&&e.texStorage2D(s.TEXTURE_2D,dt,St,Yt[0].width,Yt[0].height);for(let F=0,ct=Yt.length;F<ct;F++)bt=Yt[F],Nt?U&&e.texSubImage2D(s.TEXTURE_2D,F,0,0,bt.width,bt.height,Xt,Tt,bt.data):e.texImage2D(s.TEXTURE_2D,F,St,bt.width,bt.height,0,Xt,Tt,bt.data);y.generateMipmaps=!1}else Nt?(te&&e.texStorage2D(s.TEXTURE_2D,dt,St,rt.width,rt.height),U&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,rt.width,rt.height,Xt,Tt,rt.data)):e.texImage2D(s.TEXTURE_2D,0,St,rt.width,rt.height,0,Xt,Tt,rt.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Nt&&te&&e.texStorage3D(s.TEXTURE_2D_ARRAY,dt,St,Yt[0].width,Yt[0].height,rt.depth);for(let F=0,ct=Yt.length;F<ct;F++)bt=Yt[F],y.format!==Oe?Xt!==null?Nt?U&&e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,F,0,0,0,bt.width,bt.height,rt.depth,Xt,bt.data,0,0):e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,F,St,bt.width,bt.height,rt.depth,0,bt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?U&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,F,0,0,0,bt.width,bt.height,rt.depth,Xt,Tt,bt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,F,St,bt.width,bt.height,rt.depth,0,Xt,Tt,bt.data)}else{Nt&&te&&e.texStorage2D(s.TEXTURE_2D,dt,St,Yt[0].width,Yt[0].height);for(let F=0,ct=Yt.length;F<ct;F++)bt=Yt[F],y.format!==Oe?Xt!==null?Nt?U&&e.compressedTexSubImage2D(s.TEXTURE_2D,F,0,0,bt.width,bt.height,Xt,bt.data):e.compressedTexImage2D(s.TEXTURE_2D,F,St,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?U&&e.texSubImage2D(s.TEXTURE_2D,F,0,0,bt.width,bt.height,Xt,Tt,bt.data):e.texImage2D(s.TEXTURE_2D,F,St,bt.width,bt.height,0,Xt,Tt,bt.data)}else if(y.isDataArrayTexture)Nt?(te&&e.texStorage3D(s.TEXTURE_2D_ARRAY,dt,St,rt.width,rt.height,rt.depth),U&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,Xt,Tt,rt.data)):e.texImage3D(s.TEXTURE_2D_ARRAY,0,St,rt.width,rt.height,rt.depth,0,Xt,Tt,rt.data);else if(y.isData3DTexture)Nt?(te&&e.texStorage3D(s.TEXTURE_3D,dt,St,rt.width,rt.height,rt.depth),U&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,Xt,Tt,rt.data)):e.texImage3D(s.TEXTURE_3D,0,St,rt.width,rt.height,rt.depth,0,Xt,Tt,rt.data);else if(y.isFramebufferTexture){if(te)if(Nt)e.texStorage2D(s.TEXTURE_2D,dt,St,rt.width,rt.height);else{let F=rt.width,ct=rt.height;for(let ft=0;ft<dt;ft++)e.texImage2D(s.TEXTURE_2D,ft,St,F,ct,0,Xt,Tt,null),F>>=1,ct>>=1}}else if(Yt.length>0&&ae){if(Nt&&te){let F=Wt(Yt[0]);e.texStorage2D(s.TEXTURE_2D,dt,St,F.width,F.height)}for(let F=0,ct=Yt.length;F<ct;F++)bt=Yt[F],Nt?U&&e.texSubImage2D(s.TEXTURE_2D,F,0,0,Xt,Tt,bt):e.texImage2D(s.TEXTURE_2D,F,St,Xt,Tt,bt);y.generateMipmaps=!1}else if(Nt){if(te){let F=Wt(rt);e.texStorage2D(s.TEXTURE_2D,dt,St,F.width,F.height)}U&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,Xt,Tt,rt)}else e.texImage2D(s.TEXTURE_2D,0,St,Xt,Tt,rt);x(y,ae)&&b(W),Lt.__version=j.version,y.onUpdate&&y.onUpdate(y)}E.__version=y.version}u(mt,"uploadTexture");function wt(E,y,H){if(y.image.length!==6)return;let W=tt(E,y),et=y.source;e.bindTexture(s.TEXTURE_CUBE_MAP,E.__webglTexture,s.TEXTURE0+H);let j=n.get(et);if(et.version!==j.__version||W===!0){e.activeTexture(s.TEXTURE0+H);let Lt=Jt.getPrimaries(Jt.workingColorSpace),Rt=y.colorSpace===bn?null:Jt.getPrimaries(y.colorSpace),lt=y.colorSpace===bn||Lt===Rt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,y.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,y.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt);let ut=y.isCompressedTexture||y.image[0].isCompressedTexture,Ut=y.image[0]&&y.image[0].isDataTexture,rt=[];for(let F=0;F<6;F++)!ut&&!Ut?rt[F]=m(y.image[F],!1,!0,i.maxCubemapSize):rt[F]=Ut?y.image[F].image:y.image[F],rt[F]=yt(y,rt[F]);let ae=rt[0],Xt=p(ae)||a,Tt=r.convert(y.format,y.colorSpace),St=r.convert(y.type),bt=L(y.internalFormat,Tt,St,y.colorSpace),Yt=a&&y.isVideoTexture!==!0,Nt=j.__version===void 0||W===!0,te=et.dataReady,U=C(y,ae,Xt);V(s.TEXTURE_CUBE_MAP,y,Xt);let dt;if(ut){Yt&&Nt&&e.texStorage2D(s.TEXTURE_CUBE_MAP,U,bt,ae.width,ae.height);for(let F=0;F<6;F++){dt=rt[F].mipmaps;for(let ct=0;ct<dt.length;ct++){let ft=dt[ct];y.format!==Oe?Tt!==null?Yt?te&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct,0,0,ft.width,ft.height,Tt,ft.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct,bt,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Yt?te&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct,0,0,ft.width,ft.height,Tt,St,ft.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct,bt,ft.width,ft.height,0,Tt,St,ft.data)}}}else{if(dt=y.mipmaps,Yt&&Nt){dt.length>0&&U++;let F=Wt(rt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,U,bt,F.width,F.height)}for(let F=0;F<6;F++)if(Ut){Yt?te&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,0,0,rt[F].width,rt[F].height,Tt,St,rt[F].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,bt,rt[F].width,rt[F].height,0,Tt,St,rt[F].data);for(let ct=0;ct<dt.length;ct++){let qt=dt[ct].image[F].image;Yt?te&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct+1,0,0,qt.width,qt.height,Tt,St,qt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct+1,bt,qt.width,qt.height,0,Tt,St,qt.data)}}else{Yt?te&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,0,0,Tt,St,rt[F]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,bt,Tt,St,rt[F]);for(let ct=0;ct<dt.length;ct++){let ft=dt[ct];Yt?te&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct+1,0,0,Tt,St,ft.image[F]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+F,ct+1,bt,Tt,St,ft.image[F])}}}x(y,Xt)&&b(s.TEXTURE_CUBE_MAP),j.__version=et.version,y.onUpdate&&y.onUpdate(y)}E.__version=y.version}u(wt,"uploadCubeTexture");function Mt(E,y,H,W,et,j){let Lt=r.convert(H.format,H.colorSpace),Rt=r.convert(H.type),lt=L(H.internalFormat,Lt,Rt,H.colorSpace);if(!n.get(y).__hasExternalTextures){let Ut=Math.max(1,y.width>>j),rt=Math.max(1,y.height>>j);et===s.TEXTURE_3D||et===s.TEXTURE_2D_ARRAY?e.texImage3D(et,j,lt,Ut,rt,y.depth,0,Lt,Rt,null):e.texImage2D(et,j,lt,Ut,rt,0,Lt,Rt,null)}e.bindFramebuffer(s.FRAMEBUFFER,E),xt(y)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,W,et,n.get(H).__webglTexture,0,K(y)):(et===s.TEXTURE_2D||et>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&et<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,W,et,n.get(H).__webglTexture,j),e.bindFramebuffer(s.FRAMEBUFFER,null)}u(Mt,"setupFrameBufferTexture");function vt(E,y,H){if(s.bindRenderbuffer(s.RENDERBUFFER,E),y.depthBuffer&&!y.stencilBuffer){let W=a===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(H||xt(y)){let et=y.depthTexture;et&&et.isDepthTexture&&(et.type===ke?W=s.DEPTH_COMPONENT32F:et.type===En&&(W=s.DEPTH_COMPONENT24));let j=K(y);xt(y)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,j,W,y.width,y.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,j,W,y.width,y.height)}else s.renderbufferStorage(s.RENDERBUFFER,W,y.width,y.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,E)}else if(y.depthBuffer&&y.stencilBuffer){let W=K(y);H&&xt(y)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,W,s.DEPTH24_STENCIL8,y.width,y.height):xt(y)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,W,s.DEPTH24_STENCIL8,y.width,y.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,y.width,y.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,E)}else{let W=y.textures;for(let et=0;et<W.length;et++){let j=W[et],Lt=r.convert(j.format,j.colorSpace),Rt=r.convert(j.type),lt=L(j.internalFormat,Lt,Rt,j.colorSpace),ut=K(y);H&&xt(y)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,ut,lt,y.width,y.height):xt(y)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ut,lt,y.width,y.height):s.renderbufferStorage(s.RENDERBUFFER,lt,y.width,y.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}u(vt,"setupRenderBufferStorage");function Ht(E,y){if(y&&y.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(s.FRAMEBUFFER,E),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(y.depthTexture).__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),J(y.depthTexture,0);let W=n.get(y.depthTexture).__webglTexture,et=K(y);if(y.depthTexture.format===$n)xt(y)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,W,0,et):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,W,0);else if(y.depthTexture.format===Ii)xt(y)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,W,0,et):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,W,0);else throw new Error("Unknown depthTexture format")}u(Ht,"setupDepthTexture");function At(E){let y=n.get(E),H=E.isWebGLCubeRenderTarget===!0;if(E.depthTexture&&!y.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");Ht(y.__webglFramebuffer,E)}else if(H){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)e.bindFramebuffer(s.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]=s.createRenderbuffer(),vt(y.__webglDepthbuffer[W],E,!1)}else e.bindFramebuffer(s.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer=s.createRenderbuffer(),vt(y.__webglDepthbuffer,E,!1);e.bindFramebuffer(s.FRAMEBUFFER,null)}u(At,"setupDepthRenderbuffer");function T(E,y,H){let W=n.get(E);y!==void 0&&Mt(W.__webglFramebuffer,E,E.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),H!==void 0&&At(E)}u(T,"rebindTextures");function ot(E){let y=E.texture,H=n.get(E),W=n.get(y);E.addEventListener("dispose",X);let et=E.textures,j=E.isWebGLCubeRenderTarget===!0,Lt=et.length>1,Rt=p(E)||a;if(Lt||(W.__webglTexture===void 0&&(W.__webglTexture=s.createTexture()),W.__version=y.version,o.memory.textures++),j){H.__webglFramebuffer=[];for(let lt=0;lt<6;lt++)if(a&&y.mipmaps&&y.mipmaps.length>0){H.__webglFramebuffer[lt]=[];for(let ut=0;ut<y.mipmaps.length;ut++)H.__webglFramebuffer[lt][ut]=s.createFramebuffer()}else H.__webglFramebuffer[lt]=s.createFramebuffer()}else{if(a&&y.mipmaps&&y.mipmaps.length>0){H.__webglFramebuffer=[];for(let lt=0;lt<y.mipmaps.length;lt++)H.__webglFramebuffer[lt]=s.createFramebuffer()}else H.__webglFramebuffer=s.createFramebuffer();if(Lt)if(i.drawBuffers)for(let lt=0,ut=et.length;lt<ut;lt++){let Ut=n.get(et[lt]);Ut.__webglTexture===void 0&&(Ut.__webglTexture=s.createTexture(),o.memory.textures++)}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&E.samples>0&&xt(E)===!1){H.__webglMultisampledFramebuffer=s.createFramebuffer(),H.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let lt=0;lt<et.length;lt++){let ut=et[lt];H.__webglColorRenderbuffer[lt]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,H.__webglColorRenderbuffer[lt]);let Ut=r.convert(ut.format,ut.colorSpace),rt=r.convert(ut.type),ae=L(ut.internalFormat,Ut,rt,ut.colorSpace,E.isXRRenderTarget===!0),Xt=K(E);s.renderbufferStorageMultisample(s.RENDERBUFFER,Xt,ae,E.width,E.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+lt,s.RENDERBUFFER,H.__webglColorRenderbuffer[lt])}s.bindRenderbuffer(s.RENDERBUFFER,null),E.depthBuffer&&(H.__webglDepthRenderbuffer=s.createRenderbuffer(),vt(H.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(j){e.bindTexture(s.TEXTURE_CUBE_MAP,W.__webglTexture),V(s.TEXTURE_CUBE_MAP,y,Rt);for(let lt=0;lt<6;lt++)if(a&&y.mipmaps&&y.mipmaps.length>0)for(let ut=0;ut<y.mipmaps.length;ut++)Mt(H.__webglFramebuffer[lt][ut],E,y,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+lt,ut);else Mt(H.__webglFramebuffer[lt],E,y,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0);x(y,Rt)&&b(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Lt){for(let lt=0,ut=et.length;lt<ut;lt++){let Ut=et[lt],rt=n.get(Ut);e.bindTexture(s.TEXTURE_2D,rt.__webglTexture),V(s.TEXTURE_2D,Ut,Rt),Mt(H.__webglFramebuffer,E,Ut,s.COLOR_ATTACHMENT0+lt,s.TEXTURE_2D,0),x(Ut,Rt)&&b(s.TEXTURE_2D)}e.unbindTexture()}else{let lt=s.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(a?lt=E.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(lt,W.__webglTexture),V(lt,y,Rt),a&&y.mipmaps&&y.mipmaps.length>0)for(let ut=0;ut<y.mipmaps.length;ut++)Mt(H.__webglFramebuffer[ut],E,y,s.COLOR_ATTACHMENT0,lt,ut);else Mt(H.__webglFramebuffer,E,y,s.COLOR_ATTACHMENT0,lt,0);x(y,Rt)&&b(lt),e.unbindTexture()}E.depthBuffer&&At(E)}u(ot,"setupRenderTarget");function Z(E){let y=p(E)||a,H=E.textures;for(let W=0,et=H.length;W<et;W++){let j=H[W];if(x(j,y)){let Lt=E.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,Rt=n.get(j).__webglTexture;e.bindTexture(Lt,Rt),b(Lt),e.unbindTexture()}}}u(Z,"updateRenderTargetMipmap");function st(E){if(a&&E.samples>0&&xt(E)===!1){let y=E.textures,H=E.width,W=E.height,et=s.COLOR_BUFFER_BIT,j=[],Lt=E.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Rt=n.get(E),lt=y.length>1;if(lt)for(let ut=0;ut<y.length;ut++)e.bindFramebuffer(s.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ut,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,Rt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ut,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,Rt.__webglFramebuffer);for(let ut=0;ut<y.length;ut++){j.push(s.COLOR_ATTACHMENT0+ut),E.depthBuffer&&j.push(Lt);let Ut=Rt.__ignoreDepthValues!==void 0?Rt.__ignoreDepthValues:!1;if(Ut===!1&&(E.depthBuffer&&(et|=s.DEPTH_BUFFER_BIT),E.stencilBuffer&&(et|=s.STENCIL_BUFFER_BIT)),lt&&s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Rt.__webglColorRenderbuffer[ut]),Ut===!0&&(s.invalidateFramebuffer(s.READ_FRAMEBUFFER,[Lt]),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[Lt])),lt){let rt=n.get(y[ut]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,rt,0)}s.blitFramebuffer(0,0,H,W,0,0,H,W,et,s.NEAREST),l&&s.invalidateFramebuffer(s.READ_FRAMEBUFFER,j)}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),lt)for(let ut=0;ut<y.length;ut++){e.bindFramebuffer(s.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ut,s.RENDERBUFFER,Rt.__webglColorRenderbuffer[ut]);let Ut=n.get(y[ut]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,Rt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ut,s.TEXTURE_2D,Ut,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,Rt.__webglMultisampledFramebuffer)}}u(st,"updateMultisampleRenderTarget");function K(E){return Math.min(i.maxSamples,E.samples)}u(K,"getRenderTargetSamples");function xt(E){let y=n.get(E);return a&&E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}u(xt,"useMultisampledRTT");function pt(E){let y=o.render.frame;d.get(E)!==y&&(d.set(E,y),E.update())}u(pt,"updateVideoTexture");function yt(E,y){let H=E.colorSpace,W=E.format,et=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||E.format===Ga||H!==Dn&&H!==bn&&(Jt.getTransfer(H)===jt?a===!1?t.has("EXT_sRGB")===!0&&W===Oe?(E.format=Ga,E.minFilter=Ce,E.generateMipmaps=!1):y=ir.sRGBToLinear(y):(W!==Oe||et!==Rn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),y}u(yt,"verifyColorSpace");function Wt(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(h.width=E.naturalWidth||E.width,h.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(h.width=E.displayWidth,h.height=E.displayHeight):(h.width=E.width,h.height=E.height),h}u(Wt,"getDimensions"),this.allocateTextureUnit=G,this.resetTextureUnits=I,this.setTexture2D=J,this.setTexture2DArray=q,this.setTexture3D=Y,this.setTextureCube=it,this.rebindTextures=T,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=Z,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=Mt,this.useMultisampledRTT=xt}u(mx,"WebGLTextures");function gx(s,t,e){let n=e.isWebGL2;function i(r,o=bn){let a,c=Jt.getTransfer(o);if(r===Rn)return s.UNSIGNED_BYTE;if(r===Bd)return s.UNSIGNED_SHORT_4_4_4_4;if(r===zd)return s.UNSIGNED_SHORT_5_5_5_1;if(r===Zf)return s.BYTE;if(r===Jf)return s.SHORT;if(r===Fo)return s.UNSIGNED_SHORT;if(r===Fd)return s.INT;if(r===En)return s.UNSIGNED_INT;if(r===ke)return s.FLOAT;if(r===ns)return n?s.HALF_FLOAT:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(r===$f)return s.ALPHA;if(r===Oe)return s.RGBA;if(r===Kf)return s.LUMINANCE;if(r===Qf)return s.LUMINANCE_ALPHA;if(r===$n)return s.DEPTH_COMPONENT;if(r===Ii)return s.DEPTH_STENCIL;if(r===Ga)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(r===kd)return s.RED;if(r===Vd)return s.RED_INTEGER;if(r===jf)return s.RG;if(r===Hd)return s.RG_INTEGER;if(r===Gd)return s.RGBA_INTEGER;if(r===Jr||r===$r||r===Kr||r===Qr)if(c===jt)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===Jr)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===$r)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Kr)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Qr)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===Jr)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===$r)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Kr)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Qr)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===fh||r===ph||r===mh||r===gh)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===fh)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===ph)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===mh)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===gh)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Wd)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===_h||r===xh)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(r===_h)return c===jt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===xh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===vh||r===yh||r===Mh||r===Sh||r===bh||r===Eh||r===wh||r===Ah||r===Th||r===Rh||r===Ch||r===Ph||r===Ih||r===Lh)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(r===vh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===yh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Mh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Sh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===bh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Eh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===wh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Ah)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Th)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Rh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Ch)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Ph)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Ih)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Lh)return c===jt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===jr||r===Uh||r===Dh)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(r===jr)return c===jt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Uh)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Dh)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===tp||r===Nh||r===Oh||r===Fh)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(r===jr)return a.COMPRESSED_RED_RGTC1_EXT;if(r===Nh)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Oh)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Fh)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Jn?n?s.UNSIGNED_INT_24_8:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):s[r]!==void 0?s[r]:null}return u(i,"convert"),{convert:i}}u(gx,"WebGLUtils");var Pc=class Pc extends Te{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}};u(Pc,"ArrayCamera");var io=Pc,Ic=class Ic extends le{constructor(){super(),this.isGroup=!0,this.type="Group"}};u(Ic,"Group");var Mi=Ic,_x={type:"move"},Lc=class Lc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Mi,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 Mi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Mi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(let v of t.hand.values()){let m=e.getJointPose(v,n),p=this._getHandJoint(l,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],f=h.position.distanceTo(d.position),g=.02,_=.005;l.inputState.pinching&&f>g+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=g-_&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(_x)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Mi;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}};u(Lc,"WebXRController");var Ki=Lc,xx=`
3776
- void main() {
3777
-
3778
- gl_Position = vec4( position, 1.0 );
3779
-
3780
- }`,vx=`
3781
- uniform sampler2DArray depthColor;
3782
- uniform float depthWidth;
3783
- uniform float depthHeight;
3784
-
3785
- void main() {
3786
-
3787
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3788
-
3789
- if ( coord.x >= 1.0 ) {
3790
-
3791
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3792
-
3793
- } else {
3794
-
3795
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3796
-
3797
- }
3798
-
3799
- }`,Uc=class Uc{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let i=new be,r=t.properties.get(i);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}render(t,e){if(this.texture!==null){if(this.mesh===null){let n=e.cameras[0].viewport,i=new tn({extensions:{fragDepth:!0},vertexShader:xx,fragmentShader:vx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Me(new ur(20,20),i)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}};u(Uc,"WebXRDepthSensing");var so=Uc,Dc=class Dc extends Pn{constructor(t,e){super();let n=this,i=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,d=null,f=null,g=null,_=null,v=new so,m=e.getContextAttributes(),p=null,w=null,x=[],b=[],L=new at,C=null,R=new Te;R.layers.enable(1),R.viewport=new $t;let D=new Te;D.layers.enable(2),D.viewport=new $t;let X=[R,D],M=new io;M.layers.enable(1),M.layers.enable(2);let A=null,Q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let tt=x[V];return tt===void 0&&(tt=new Ki,x[V]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(V){let tt=x[V];return tt===void 0&&(tt=new Ki,x[V]=tt),tt.getGripSpace()},this.getHand=function(V){let tt=x[V];return tt===void 0&&(tt=new Ki,x[V]=tt),tt.getHandSpace()};function $(V){let tt=b.indexOf(V.inputSource);if(tt===-1)return;let mt=x[tt];mt!==void 0&&(mt.update(V.inputSource,V.frame,l||o),mt.dispatchEvent({type:V.type,data:V.inputSource}))}u($,"onSessionEvent");function I(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",G);for(let V=0;V<x.length;V++){let tt=b[V];tt!==null&&(b[V]=null,x[V].disconnect(tt))}A=null,Q=null,v.reset(),t.setRenderTarget(p),g=null,f=null,d=null,i=null,w=null,It.stop(),n.isPresenting=!1,t.setPixelRatio(C),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}u(I,"onSessionEnd"),this.setFramebufferScaleFactor=function(V){r=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(V){a=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(V){l=V},this.getBaseLayer=function(){return f!==null?f:g},this.getBinding=function(){return d},this.getFrame=function(){return _},this.getSession=function(){return i},this.setSession=async function(V){if(i=V,i!==null){if(p=t.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",I),i.addEventListener("inputsourceschange",G),m.xrCompatible!==!0&&await e.makeXRCompatible(),C=t.getPixelRatio(),t.getSize(L),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let tt={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};g=new XRWebGLLayer(i,e,tt),i.updateRenderState({baseLayer:g}),t.setPixelRatio(1),t.setSize(g.framebufferWidth,g.framebufferHeight,!1),w=new fn(g.framebufferWidth,g.framebufferHeight,{format:Oe,type:Rn,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let tt=null,mt=null,wt=null;m.depth&&(wt=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,tt=m.stencil?Ii:$n,mt=m.stencil?Jn:En);let Mt={colorFormat:e.RGBA8,depthFormat:wt,scaleFactor:r};d=new XRWebGLBinding(i,e),f=d.createProjectionLayer(Mt),i.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),w=new fn(f.textureWidth,f.textureHeight,{format:Oe,type:Rn,depthTexture:new pr(f.textureWidth,f.textureHeight,mt,void 0,void 0,void 0,void 0,void 0,void 0,tt),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0});let vt=t.properties.get(w);vt.__ignoreDepthValues=f.ignoreDepthValues}w.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),It.setContext(i),It.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function G(V){for(let tt=0;tt<V.removed.length;tt++){let mt=V.removed[tt],wt=b.indexOf(mt);wt>=0&&(b[wt]=null,x[wt].disconnect(mt))}for(let tt=0;tt<V.added.length;tt++){let mt=V.added[tt],wt=b.indexOf(mt);if(wt===-1){for(let vt=0;vt<x.length;vt++)if(vt>=b.length){b.push(mt),wt=vt;break}else if(b[vt]===null){b[vt]=mt,wt=vt;break}if(wt===-1)break}let Mt=x[wt];Mt&&Mt.connect(mt)}}u(G,"onInputSourcesChange");let k=new P,J=new P;function q(V,tt,mt){k.setFromMatrixPosition(tt.matrixWorld),J.setFromMatrixPosition(mt.matrixWorld);let wt=k.distanceTo(J),Mt=tt.projectionMatrix.elements,vt=mt.projectionMatrix.elements,Ht=Mt[14]/(Mt[10]-1),At=Mt[14]/(Mt[10]+1),T=(Mt[9]+1)/Mt[5],ot=(Mt[9]-1)/Mt[5],Z=(Mt[8]-1)/Mt[0],st=(vt[8]+1)/vt[0],K=Ht*Z,xt=Ht*st,pt=wt/(-Z+st),yt=pt*-Z;tt.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(yt),V.translateZ(pt),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert();let Wt=Ht+pt,E=At+pt,y=K-yt,H=xt+(wt-yt),W=T*At/E*Wt,et=ot*At/E*Wt;V.projectionMatrix.makePerspective(y,H,W,et,Wt,E),V.projectionMatrixInverse.copy(V.projectionMatrix).invert()}u(q,"setProjectionFromUnion");function Y(V,tt){tt===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(tt.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}u(Y,"updateCamera"),this.updateCamera=function(V){if(i===null)return;v.texture!==null&&(V.near=v.depthNear,V.far=v.depthFar),M.near=D.near=R.near=V.near,M.far=D.far=R.far=V.far,(A!==M.near||Q!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),A=M.near,Q=M.far,R.near=A,R.far=Q,D.near=A,D.far=Q,R.updateProjectionMatrix(),D.updateProjectionMatrix(),V.updateProjectionMatrix());let tt=V.parent,mt=M.cameras;Y(M,tt);for(let wt=0;wt<mt.length;wt++)Y(mt[wt],tt);mt.length===2?q(M,R,D):M.projectionMatrix.copy(R.projectionMatrix),it(V,M,tt)};function it(V,tt,mt){mt===null?V.matrix.copy(tt.matrixWorld):(V.matrix.copy(mt.matrixWorld),V.matrix.invert(),V.matrix.multiply(tt.matrixWorld)),V.matrix.decompose(V.position,V.quaternion,V.scale),V.updateMatrixWorld(!0),V.projectionMatrix.copy(tt.projectionMatrix),V.projectionMatrixInverse.copy(tt.projectionMatrixInverse),V.isPerspectiveCamera&&(V.fov=Li*2*Math.atan(1/V.projectionMatrix.elements[5]),V.zoom=1)}u(it,"updateUserCamera"),this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&g===null))return c},this.setFoveation=function(V){c=V,f!==null&&(f.fixedFoveation=V),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=V)},this.hasDepthSensing=function(){return v.texture!==null};let nt=null;function _t(V,tt){if(h=tt.getViewerPose(l||o),_=tt,h!==null){let mt=h.views;g!==null&&(t.setRenderTargetFramebuffer(w,g.framebuffer),t.setRenderTarget(w));let wt=!1;mt.length!==M.cameras.length&&(M.cameras.length=0,wt=!0);for(let vt=0;vt<mt.length;vt++){let Ht=mt[vt],At=null;if(g!==null)At=g.getViewport(Ht);else{let ot=d.getViewSubImage(f,Ht);At=ot.viewport,vt===0&&(t.setRenderTargetTextures(w,ot.colorTexture,f.ignoreDepthValues?void 0:ot.depthStencilTexture),t.setRenderTarget(w))}let T=X[vt];T===void 0&&(T=new Te,T.layers.enable(vt),T.viewport=new $t,X[vt]=T),T.matrix.fromArray(Ht.transform.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale),T.projectionMatrix.fromArray(Ht.projectionMatrix),T.projectionMatrixInverse.copy(T.projectionMatrix).invert(),T.viewport.set(At.x,At.y,At.width,At.height),vt===0&&(M.matrix.copy(T.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),wt===!0&&M.cameras.push(T)}let Mt=i.enabledFeatures;if(Mt&&Mt.includes("depth-sensing")){let vt=d.getDepthInformation(mt[0]);vt&&vt.isValid&&vt.texture&&v.init(t,vt,i.renderState)}}for(let mt=0;mt<x.length;mt++){let wt=b[mt],Mt=x[mt];wt!==null&&Mt!==void 0&&Mt.update(wt,tt,l||o)}v.render(t,M),nt&&nt(V,tt),tt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:tt}),_=null}u(_t,"onAnimationFrame");let It=new $d;It.setAnimationLoop(_t),this.setAnimationLoop=function(V){nt=V},this.dispose=function(){}}};u(Dc,"WebXRManager");var ro=Dc,Hn=new Je,yx=new Ft;function Mx(s,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}u(e,"refreshTransformUniform");function n(m,p){p.color.getRGB(m.fogColor.value,Jd(s)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}u(n,"refreshFogUniforms");function i(m,p,w,x,b){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),d(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p)):p.isMeshStandardMaterial?(r(m,p),f(m,p),p.isMeshPhysicalMaterial&&g(m,p,b)):p.isMeshMatcapMaterial?(r(m,p),_(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),v(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,w,x):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}u(i,"refreshMaterialUniforms");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,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Pe&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Pe&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let w=t.get(p),x=w.envMap,b=w.envMapRotation;if(x&&(m.envMap.value=x,Hn.copy(b),Hn.x*=-1,Hn.y*=-1,Hn.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Hn.y*=-1,Hn.z*=-1),m.envMapRotation.value.setFromMatrix4(yx.makeRotationFromEuler(Hn)),m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap){m.lightMap.value=p.lightMap;let L=s._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=p.lightMapIntensity*L,e(p.lightMap,m.lightMapTransform)}p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}u(r,"refreshUniformsCommon");function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}u(o,"refreshUniformsLine");function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}u(a,"refreshUniformsDash");function c(m,p,w,x){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=x*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}u(c,"refreshUniformsPoints");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,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}u(l,"refreshUniformsSprites");function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}u(h,"refreshUniformsPhong");function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}u(d,"refreshUniformsToon");function f(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),t.get(p).envMap&&(m.envMapIntensity.value=p.envMapIntensity)}u(f,"refreshUniformsStandard");function g(m,p,w){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Pe&&m.clearcoatNormalScale.value.negate())),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(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,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}u(g,"refreshUniformsPhysical");function _(m,p){p.matcap&&(m.matcap.value=p.matcap)}u(_,"refreshUniformsMatcap");function v(m,p){let w=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return u(v,"refreshUniformsDistance"),{refreshFogUniforms:n,refreshMaterialUniforms:i}}u(Mx,"WebGLMaterials");function Sx(s,t,e,n){let i={},r={},o=[],a=e.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(w,x){let b=x.program;n.uniformBlockBinding(w,b)}u(c,"bind");function l(w,x){let b=i[w.id];b===void 0&&(_(w),b=h(w),i[w.id]=b,w.addEventListener("dispose",m));let L=x.program;n.updateUBOMapping(w,L);let C=t.render.frame;r[w.id]!==C&&(f(w),r[w.id]=C)}u(l,"update");function h(w){let x=d();w.__bindingPointIndex=x;let b=s.createBuffer(),L=w.__size,C=w.usage;return s.bindBuffer(s.UNIFORM_BUFFER,b),s.bufferData(s.UNIFORM_BUFFER,L,C),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,x,b),b}u(h,"createBuffer");function d(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}u(d,"allocateBindingPointIndex");function f(w){let x=i[w.id],b=w.uniforms,L=w.__cache;s.bindBuffer(s.UNIFORM_BUFFER,x);for(let C=0,R=b.length;C<R;C++){let D=Array.isArray(b[C])?b[C]:[b[C]];for(let X=0,M=D.length;X<M;X++){let A=D[X];if(g(A,C,X,L)===!0){let Q=A.__offset,$=Array.isArray(A.value)?A.value:[A.value],I=0;for(let G=0;G<$.length;G++){let k=$[G],J=v(k);typeof k=="number"||typeof k=="boolean"?(A.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,Q+I,A.__data)):k.isMatrix3?(A.__data[0]=k.elements[0],A.__data[1]=k.elements[1],A.__data[2]=k.elements[2],A.__data[3]=0,A.__data[4]=k.elements[3],A.__data[5]=k.elements[4],A.__data[6]=k.elements[5],A.__data[7]=0,A.__data[8]=k.elements[6],A.__data[9]=k.elements[7],A.__data[10]=k.elements[8],A.__data[11]=0):(k.toArray(A.__data,I),I+=J.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,Q,A.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}u(f,"updateBufferData");function g(w,x,b,L){let C=w.value,R=x+"_"+b;if(L[R]===void 0)return typeof C=="number"||typeof C=="boolean"?L[R]=C:L[R]=C.clone(),!0;{let D=L[R];if(typeof C=="number"||typeof C=="boolean"){if(D!==C)return L[R]=C,!0}else if(D.equals(C)===!1)return D.copy(C),!0}return!1}u(g,"hasUniformChanged");function _(w){let x=w.uniforms,b=0,L=16;for(let R=0,D=x.length;R<D;R++){let X=Array.isArray(x[R])?x[R]:[x[R]];for(let M=0,A=X.length;M<A;M++){let Q=X[M],$=Array.isArray(Q.value)?Q.value:[Q.value];for(let I=0,G=$.length;I<G;I++){let k=$[I],J=v(k),q=b%L;q!==0&&L-q<J.boundary&&(b+=L-q),Q.__data=new Float32Array(J.storage/Float32Array.BYTES_PER_ELEMENT),Q.__offset=b,b+=J.storage}}}let C=b%L;return C>0&&(b+=L-C),w.__size=b,w.__cache={},this}u(_,"prepareUniformsGroup");function v(w){let x={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(x.boundary=4,x.storage=4):w.isVector2?(x.boundary=8,x.storage=8):w.isVector3||w.isColor?(x.boundary=16,x.storage=12):w.isVector4?(x.boundary=16,x.storage=16):w.isMatrix3?(x.boundary=48,x.storage=48):w.isMatrix4?(x.boundary=64,x.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),x}u(v,"getUniformSize");function m(w){let x=w.target;x.removeEventListener("dispose",m);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),s.deleteBuffer(i[x.id]),delete i[x.id],delete r[x.id]}u(m,"onUniformsGroupsDispose");function p(){for(let w in i)s.deleteBuffer(i[w]);o=[],i={},r={}}return u(p,"dispose"),{bind:c,update:l,dispose:p}}u(Sx,"WebGLUniformsGroups");var Nc=class Nc{constructor(t={}){let{canvas:e=Ap(),context:n=null,depth:i=!0,stencil:r=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=t;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=o;let g=new Uint32Array(4),_=new Int32Array(4),v=null,m=null,p=[],w=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ke,this._useLegacyLights=!1,this.toneMapping=Tn,this.toneMappingExposure=1;let x=this,b=!1,L=0,C=0,R=null,D=-1,X=null,M=new $t,A=new $t,Q=null,$=new Vt(0),I=0,G=e.width,k=e.height,J=1,q=null,Y=null,it=new $t(0,0,G,k),nt=new $t(0,0,G,k),_t=!1,It=new Di,V=!1,tt=!1,mt=null,wt=new Ft,Mt=new at,vt=new P,Ht={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function At(){return R===null?J:1}u(At,"getTargetPixelRatio");let T=n;function ot(S,N){for(let B=0;B<S.length;B++){let z=S[B],O=e.getContext(z,N);if(O!==null)return O}return null}u(ot,"getContext");try{let S={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${No}`),e.addEventListener("webglcontextlost",te,!1),e.addEventListener("webglcontextrestored",U,!1),e.addEventListener("webglcontextcreationerror",dt,!1),T===null){let N=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&N.shift(),T=ot(N,S),T===null)throw ot(N)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&T instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),T.getShaderPrecisionFormat===void 0&&(T.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(S){throw console.error("THREE.WebGLRenderer: "+S.message),S}let Z,st,K,xt,pt,yt,Wt,E,y,H,W,et,j,Lt,Rt,lt,ut,Ut,rt,ae,Xt,Tt,St,bt;function Yt(){Z=new B_(T),st=new L_(T,Z,t),Z.init(st),Tt=new gx(T,Z,st),K=new px(T,Z,st),xt=new V_(T),pt=new nx,yt=new mx(T,Z,K,pt,st,Tt,xt),Wt=new D_(x),E=new F_(x),y=new Yp(T,st),St=new P_(T,Z,y,st),H=new z_(T,y,xt,St),W=new X_(T,H,y,xt),rt=new W_(T,st,yt),lt=new U_(pt),et=new ex(x,Wt,E,Z,st,St,lt),j=new Mx(x,pt),Lt=new sx,Rt=new hx(Z,st),Ut=new C_(x,Wt,E,K,W,f,c),ut=new fx(x,W,st),bt=new Sx(T,xt,st,K),ae=new I_(T,Z,xt,st),Xt=new k_(T,Z,xt,st),xt.programs=et.programs,x.capabilities=st,x.extensions=Z,x.properties=pt,x.renderLists=Lt,x.shadowMap=ut,x.state=K,x.info=xt}u(Yt,"initGLContext"),Yt();let Nt=new ro(x,T);this.xr=Nt,this.getContext=function(){return T},this.getContextAttributes=function(){return T.getContextAttributes()},this.forceContextLoss=function(){let S=Z.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){let S=Z.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(S){S!==void 0&&(J=S,this.setSize(G,k,!1))},this.getSize=function(S){return S.set(G,k)},this.setSize=function(S,N,B=!0){if(Nt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=S,k=N,e.width=Math.floor(S*J),e.height=Math.floor(N*J),B===!0&&(e.style.width=S+"px",e.style.height=N+"px"),this.setViewport(0,0,S,N)},this.getDrawingBufferSize=function(S){return S.set(G*J,k*J).floor()},this.setDrawingBufferSize=function(S,N,B){G=S,k=N,J=B,e.width=Math.floor(S*B),e.height=Math.floor(N*B),this.setViewport(0,0,S,N)},this.getCurrentViewport=function(S){return S.copy(M)},this.getViewport=function(S){return S.copy(it)},this.setViewport=function(S,N,B,z){S.isVector4?it.set(S.x,S.y,S.z,S.w):it.set(S,N,B,z),K.viewport(M.copy(it).multiplyScalar(J).round())},this.getScissor=function(S){return S.copy(nt)},this.setScissor=function(S,N,B,z){S.isVector4?nt.set(S.x,S.y,S.z,S.w):nt.set(S,N,B,z),K.scissor(A.copy(nt).multiplyScalar(J).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(S){K.setScissorTest(_t=S)},this.setOpaqueSort=function(S){q=S},this.setTransparentSort=function(S){Y=S},this.getClearColor=function(S){return S.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(S=!0,N=!0,B=!0){let z=0;if(S){let O=!1;if(R!==null){let gt=R.texture.format;O=gt===Gd||gt===Hd||gt===Vd}if(O){let gt=R.texture.type,Et=gt===Rn||gt===En||gt===Fo||gt===Jn||gt===Bd||gt===zd,Ct=Ut.getClearColor(),Pt=Ut.getClearAlpha(),Gt=Ct.r,Dt=Ct.g,Ot=Ct.b;Et?(g[0]=Gt,g[1]=Dt,g[2]=Ot,g[3]=Pt,T.clearBufferuiv(T.COLOR,0,g)):(_[0]=Gt,_[1]=Dt,_[2]=Ot,_[3]=Pt,T.clearBufferiv(T.COLOR,0,_))}else z|=T.COLOR_BUFFER_BIT}N&&(z|=T.DEPTH_BUFFER_BIT),B&&(z|=T.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),T.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",te,!1),e.removeEventListener("webglcontextrestored",U,!1),e.removeEventListener("webglcontextcreationerror",dt,!1),Lt.dispose(),Rt.dispose(),pt.dispose(),Wt.dispose(),E.dispose(),W.dispose(),St.dispose(),bt.dispose(),et.dispose(),Nt.dispose(),Nt.removeEventListener("sessionstart",Fe),Nt.removeEventListener("sessionend",Qt),mt&&(mt.dispose(),mt=null),Ee.stop()};function te(S){S.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}u(te,"onContextLost");function U(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let S=xt.autoReset,N=ut.enabled,B=ut.autoUpdate,z=ut.needsUpdate,O=ut.type;Yt(),xt.autoReset=S,ut.enabled=N,ut.autoUpdate=B,ut.needsUpdate=z,ut.type=O}u(U,"onContextRestore");function dt(S){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}u(dt,"onContextCreationError");function F(S){let N=S.target;N.removeEventListener("dispose",F),ct(N)}u(F,"onMaterialDispose");function ct(S){ft(S),pt.remove(S)}u(ct,"deallocateMaterial");function ft(S){let N=pt.get(S).programs;N!==void 0&&(N.forEach(function(B){et.releaseProgram(B)}),S.isShaderMaterial&&et.releaseShaderCache(S))}u(ft,"releaseMaterialProgramReferences"),this.renderBufferDirect=function(S,N,B,z,O,gt){N===null&&(N=Ht);let Et=O.isMesh&&O.matrixWorld.determinant()<0,Ct=cf(S,N,B,z,O);K.setMaterial(z,Et);let Pt=B.index,Gt=1;if(z.wireframe===!0){if(Pt=H.getWireframeAttribute(B),Pt===void 0)return;Gt=2}let Dt=B.drawRange,Ot=B.attributes.position,re=Dt.start*Gt,Ue=(Dt.start+Dt.count)*Gt;gt!==null&&(re=Math.max(re,gt.start*Gt),Ue=Math.min(Ue,(gt.start+gt.count)*Gt)),Pt!==null?(re=Math.max(re,0),Ue=Math.min(Ue,Pt.count)):Ot!=null&&(re=Math.max(re,0),Ue=Math.min(Ue,Ot.count));let de=Ue-re;if(de<0||de===1/0)return;St.setup(O,z,Ct,B,Pt);let en,ie=ae;if(Pt!==null&&(en=y.get(Pt),ie=Xt,ie.setIndex(en)),O.isMesh)z.wireframe===!0?(K.setLineWidth(z.wireframeLinewidth*At()),ie.setMode(T.LINES)):ie.setMode(T.TRIANGLES);else if(O.isLine){let Bt=z.linewidth;Bt===void 0&&(Bt=1),K.setLineWidth(Bt*At()),O.isLineSegments?ie.setMode(T.LINES):O.isLineLoop?ie.setMode(T.LINE_LOOP):ie.setMode(T.LINE_STRIP)}else O.isPoints?ie.setMode(T.POINTS):O.isSprite&&ie.setMode(T.TRIANGLES);if(O.isBatchedMesh)ie.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else if(O.isInstancedMesh)ie.renderInstances(re,de,O.count);else if(B.isInstancedBufferGeometry){let Bt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,Wr=Math.min(B.instanceCount,Bt);ie.renderInstances(re,de,Wr)}else ie.render(re,de)};function qt(S,N,B){S.transparent===!0&&S.side===un&&S.forceSinglePass===!1?(S.side=Pe,S.needsUpdate=!0,fs(S,N,B),S.side=Cn,S.needsUpdate=!0,fs(S,N,B),S.side=un):fs(S,N,B)}u(qt,"prepareMaterial"),this.compile=function(S,N,B=null){B===null&&(B=S),m=Rt.get(B),m.init(),w.push(m),B.traverseVisible(function(O){O.isLight&&O.layers.test(N.layers)&&(m.pushLight(O),O.castShadow&&m.pushShadow(O))}),S!==B&&S.traverseVisible(function(O){O.isLight&&O.layers.test(N.layers)&&(m.pushLight(O),O.castShadow&&m.pushShadow(O))}),m.setupLights(x._useLegacyLights);let z=new Set;return S.traverse(function(O){let gt=O.material;if(gt)if(Array.isArray(gt))for(let Et=0;Et<gt.length;Et++){let Ct=gt[Et];qt(Ct,B,O),z.add(Ct)}else qt(gt,B,O),z.add(gt)}),w.pop(),m=null,z},this.compileAsync=function(S,N,B=null){let z=this.compile(S,N,B);return new Promise(O=>{function gt(){if(z.forEach(function(Et){pt.get(Et).currentProgram.isReady()&&z.delete(Et)}),z.size===0){O(S);return}setTimeout(gt,10)}u(gt,"checkMaterialsReady"),Z.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Kt=null;function me(S){Kt&&Kt(S)}u(me,"onAnimationFrame");function Fe(){Ee.stop()}u(Fe,"onXRSessionStart");function Qt(){Ee.start()}u(Qt,"onXRSessionEnd");let Ee=new $d;Ee.setAnimationLoop(me),typeof self<"u"&&Ee.setContext(self),this.setAnimationLoop=function(S){Kt=S,Nt.setAnimationLoop(S),S===null?Ee.stop():Ee.start()},Nt.addEventListener("sessionstart",Fe),Nt.addEventListener("sessionend",Qt),this.render=function(S,N){if(N!==void 0&&N.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),Nt.enabled===!0&&Nt.isPresenting===!0&&(Nt.cameraAutoUpdate===!0&&Nt.updateCamera(N),N=Nt.getCamera()),S.isScene===!0&&S.onBeforeRender(x,S,N,R),m=Rt.get(S,w.length),m.init(),w.push(m),wt.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),It.setFromProjectionMatrix(wt),tt=this.localClippingEnabled,V=lt.init(this.clippingPlanes,tt),v=Lt.get(S,p.length),v.init(),p.push(v),$e(S,N,0,x.sortObjects),v.finish(),x.sortObjects===!0&&v.sort(q,Y),this.info.render.frame++,V===!0&&lt.beginShadows();let B=m.state.shadowsArray;if(ut.render(B,S,N),V===!0&&lt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Nt.enabled===!1||Nt.isPresenting===!1||Nt.hasDepthSensing()===!1)&&Ut.render(v,S),m.setupLights(x._useLegacyLights),N.isArrayCamera){let z=N.cameras;for(let O=0,gt=z.length;O<gt;O++){let Et=z[O];Ql(v,S,Et,Et.viewport)}}else Ql(v,S,N);R!==null&&(yt.updateMultisampleRenderTarget(R),yt.updateRenderTargetMipmap(R)),S.isScene===!0&&S.onAfterRender(x,S,N),St.resetDefaultState(),D=-1,X=null,w.pop(),w.length>0?m=w[w.length-1]:m=null,p.pop(),p.length>0?v=p[p.length-1]:v=null};function $e(S,N,B,z){if(S.visible===!1)return;if(S.layers.test(N.layers)){if(S.isGroup)B=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(N);else if(S.isLight)m.pushLight(S),S.castShadow&&m.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||It.intersectsSprite(S)){z&&vt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(wt);let Et=W.update(S),Ct=S.material;Ct.visible&&v.push(S,Et,Ct,B,vt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||It.intersectsObject(S))){let Et=W.update(S),Ct=S.material;if(z&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),vt.copy(S.boundingSphere.center)):(Et.boundingSphere===null&&Et.computeBoundingSphere(),vt.copy(Et.boundingSphere.center)),vt.applyMatrix4(S.matrixWorld).applyMatrix4(wt)),Array.isArray(Ct)){let Pt=Et.groups;for(let Gt=0,Dt=Pt.length;Gt<Dt;Gt++){let Ot=Pt[Gt],re=Ct[Ot.materialIndex];re&&re.visible&&v.push(S,Et,re,B,vt.z,Ot)}}else Ct.visible&&v.push(S,Et,Ct,B,vt.z,null)}}let gt=S.children;for(let Et=0,Ct=gt.length;Et<Ct;Et++)$e(gt[Et],N,B,z)}u($e,"projectObject");function Ql(S,N,B,z){let O=S.opaque,gt=S.transmissive,Et=S.transparent;m.setupLightsView(B),V===!0&&lt.setGlobalState(x.clippingPlanes,B),gt.length>0&&of(O,gt,N,B),z&&K.viewport(M.copy(z)),O.length>0&&ds(O,N,B),gt.length>0&&ds(gt,N,B),Et.length>0&&ds(Et,N,B),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}u(Ql,"renderScene");function of(S,N,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;let gt=st.isWebGL2;mt===null&&(mt=new fn(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?ns:Rn,minFilter:Yn,samples:gt?4:0})),x.getDrawingBufferSize(Mt),gt?mt.setSize(Mt.x,Mt.y):mt.setSize(nr(Mt.x),nr(Mt.y));let Et=x.getRenderTarget();x.setRenderTarget(mt),x.getClearColor($),I=x.getClearAlpha(),I<1&&x.setClearColor(16777215,.5),x.clear();let Ct=x.toneMapping;x.toneMapping=Tn,ds(S,B,z),yt.updateMultisampleRenderTarget(mt),yt.updateRenderTargetMipmap(mt);let Pt=!1;for(let Gt=0,Dt=N.length;Gt<Dt;Gt++){let Ot=N[Gt],re=Ot.object,Ue=Ot.geometry,de=Ot.material,en=Ot.group;if(de.side===un&&re.layers.test(z.layers)){let ie=de.side;de.side=Pe,de.needsUpdate=!0,jl(re,B,z,Ue,de,en),de.side=ie,de.needsUpdate=!0,Pt=!0}}Pt===!0&&(yt.updateMultisampleRenderTarget(mt),yt.updateRenderTargetMipmap(mt)),x.setRenderTarget(Et),x.setClearColor($,I),x.toneMapping=Ct}u(of,"renderTransmissionPass");function ds(S,N,B){let z=N.isScene===!0?N.overrideMaterial:null;for(let O=0,gt=S.length;O<gt;O++){let Et=S[O],Ct=Et.object,Pt=Et.geometry,Gt=z===null?Et.material:z,Dt=Et.group;Ct.layers.test(B.layers)&&jl(Ct,N,B,Pt,Gt,Dt)}}u(ds,"renderObjects");function jl(S,N,B,z,O,gt){S.onBeforeRender(x,N,B,z,O,gt),S.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),O.onBeforeRender(x,N,B,z,S,gt),O.transparent===!0&&O.side===un&&O.forceSinglePass===!1?(O.side=Pe,O.needsUpdate=!0,x.renderBufferDirect(B,N,z,O,S,gt),O.side=Cn,O.needsUpdate=!0,x.renderBufferDirect(B,N,z,O,S,gt),O.side=un):x.renderBufferDirect(B,N,z,O,S,gt),S.onAfterRender(x,N,B,z,O,gt)}u(jl,"renderObject");function fs(S,N,B){N.isScene!==!0&&(N=Ht);let z=pt.get(S),O=m.state.lights,gt=m.state.shadowsArray,Et=O.state.version,Ct=et.getParameters(S,O.state,gt,N,B),Pt=et.getProgramCacheKey(Ct),Gt=z.programs;z.environment=S.isMeshStandardMaterial?N.environment:null,z.fog=N.fog,z.envMap=(S.isMeshStandardMaterial?E:Wt).get(S.envMap||z.environment),z.envMapRotation=z.environment!==null&&S.envMap===null?N.environmentRotation:S.envMapRotation,Gt===void 0&&(S.addEventListener("dispose",F),Gt=new Map,z.programs=Gt);let Dt=Gt.get(Pt);if(Dt!==void 0){if(z.currentProgram===Dt&&z.lightsStateVersion===Et)return eh(S,Ct),Dt}else Ct.uniforms=et.getUniforms(S),S.onBuild(B,Ct,x),S.onBeforeCompile(Ct,x),Dt=et.acquireProgram(Ct,Pt),Gt.set(Pt,Dt),z.uniforms=Ct.uniforms;let Ot=z.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Ot.clippingPlanes=lt.uniform),eh(S,Ct),z.needsLights=hf(S),z.lightsStateVersion=Et,z.needsLights&&(Ot.ambientLightColor.value=O.state.ambient,Ot.lightProbe.value=O.state.probe,Ot.directionalLights.value=O.state.directional,Ot.directionalLightShadows.value=O.state.directionalShadow,Ot.spotLights.value=O.state.spot,Ot.spotLightShadows.value=O.state.spotShadow,Ot.rectAreaLights.value=O.state.rectArea,Ot.ltc_1.value=O.state.rectAreaLTC1,Ot.ltc_2.value=O.state.rectAreaLTC2,Ot.pointLights.value=O.state.point,Ot.pointLightShadows.value=O.state.pointShadow,Ot.hemisphereLights.value=O.state.hemi,Ot.directionalShadowMap.value=O.state.directionalShadowMap,Ot.directionalShadowMatrix.value=O.state.directionalShadowMatrix,Ot.spotShadowMap.value=O.state.spotShadowMap,Ot.spotLightMatrix.value=O.state.spotLightMatrix,Ot.spotLightMap.value=O.state.spotLightMap,Ot.pointShadowMap.value=O.state.pointShadowMap,Ot.pointShadowMatrix.value=O.state.pointShadowMatrix),z.currentProgram=Dt,z.uniformsList=null,Dt}u(fs,"getProgram");function th(S){if(S.uniformsList===null){let N=S.currentProgram.getUniforms();S.uniformsList=Ri.seqWithValue(N.seq,S.uniforms)}return S.uniformsList}u(th,"getUniformList");function eh(S,N){let B=pt.get(S);B.outputColorSpace=N.outputColorSpace,B.batching=N.batching,B.instancing=N.instancing,B.instancingColor=N.instancingColor,B.instancingMorph=N.instancingMorph,B.skinning=N.skinning,B.morphTargets=N.morphTargets,B.morphNormals=N.morphNormals,B.morphColors=N.morphColors,B.morphTargetsCount=N.morphTargetsCount,B.numClippingPlanes=N.numClippingPlanes,B.numIntersection=N.numClipIntersection,B.vertexAlphas=N.vertexAlphas,B.vertexTangents=N.vertexTangents,B.toneMapping=N.toneMapping}u(eh,"updateCommonMaterialProperties");function cf(S,N,B,z,O){N.isScene!==!0&&(N=Ht),yt.resetTextureUnits();let gt=N.fog,Et=z.isMeshStandardMaterial?N.environment:null,Ct=R===null?x.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Dn,Pt=(z.isMeshStandardMaterial?E:Wt).get(z.envMap||Et),Gt=z.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Dt=!!B.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Ot=!!B.morphAttributes.position,re=!!B.morphAttributes.normal,Ue=!!B.morphAttributes.color,de=Tn;z.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(de=x.toneMapping);let en=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ie=en!==void 0?en.length:0,Bt=pt.get(z),Wr=m.state.lights;if(V===!0&&(tt===!0||S!==X)){let Be=S===X&&z.id===D;lt.setState(z,S,Be)}let ee=!1;z.version===Bt.__version?(Bt.needsLights&&Bt.lightsStateVersion!==Wr.state.version||Bt.outputColorSpace!==Ct||O.isBatchedMesh&&Bt.batching===!1||!O.isBatchedMesh&&Bt.batching===!0||O.isInstancedMesh&&Bt.instancing===!1||!O.isInstancedMesh&&Bt.instancing===!0||O.isSkinnedMesh&&Bt.skinning===!1||!O.isSkinnedMesh&&Bt.skinning===!0||O.isInstancedMesh&&Bt.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Bt.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Bt.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Bt.instancingMorph===!1&&O.morphTexture!==null||Bt.envMap!==Pt||z.fog===!0&&Bt.fog!==gt||Bt.numClippingPlanes!==void 0&&(Bt.numClippingPlanes!==lt.numPlanes||Bt.numIntersection!==lt.numIntersection)||Bt.vertexAlphas!==Gt||Bt.vertexTangents!==Dt||Bt.morphTargets!==Ot||Bt.morphNormals!==re||Bt.morphColors!==Ue||Bt.toneMapping!==de||st.isWebGL2===!0&&Bt.morphTargetsCount!==ie)&&(ee=!0):(ee=!0,Bt.__version=z.version);let Nn=Bt.currentProgram;ee===!0&&(Nn=fs(z,N,O));let nh=!1,ki=!1,Xr=!1,_e=Nn.getUniforms(),On=Bt.uniforms;if(K.useProgram(Nn.program)&&(nh=!0,ki=!0,Xr=!0),z.id!==D&&(D=z.id,ki=!0),nh||X!==S){_e.setValue(T,"projectionMatrix",S.projectionMatrix),_e.setValue(T,"viewMatrix",S.matrixWorldInverse);let Be=_e.map.cameraPosition;Be!==void 0&&Be.setValue(T,vt.setFromMatrixPosition(S.matrixWorld)),st.logarithmicDepthBuffer&&_e.setValue(T,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&_e.setValue(T,"isOrthographic",S.isOrthographicCamera===!0),X!==S&&(X=S,ki=!0,Xr=!0)}if(O.isSkinnedMesh){_e.setOptional(T,O,"bindMatrix"),_e.setOptional(T,O,"bindMatrixInverse");let Be=O.skeleton;Be&&(st.floatVertexTextures?(Be.boneTexture===null&&Be.computeBoneTexture(),_e.setValue(T,"boneTexture",Be.boneTexture,yt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}O.isBatchedMesh&&(_e.setOptional(T,O,"batchingTexture"),_e.setValue(T,"batchingTexture",O._matricesTexture,yt));let qr=B.morphAttributes;if((qr.position!==void 0||qr.normal!==void 0||qr.color!==void 0&&st.isWebGL2===!0)&&rt.update(O,B,Nn),(ki||Bt.receiveShadow!==O.receiveShadow)&&(Bt.receiveShadow=O.receiveShadow,_e.setValue(T,"receiveShadow",O.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(On.envMap.value=Pt,On.flipEnvMap.value=Pt.isCubeTexture&&Pt.isRenderTargetTexture===!1?-1:1),ki&&(_e.setValue(T,"toneMappingExposure",x.toneMappingExposure),Bt.needsLights&&lf(On,Xr),gt&&z.fog===!0&&j.refreshFogUniforms(On,gt),j.refreshMaterialUniforms(On,z,J,k,mt),Ri.upload(T,th(Bt),On,yt)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Ri.upload(T,th(Bt),On,yt),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&_e.setValue(T,"center",O.center),_e.setValue(T,"modelViewMatrix",O.modelViewMatrix),_e.setValue(T,"normalMatrix",O.normalMatrix),_e.setValue(T,"modelMatrix",O.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let Be=z.uniformsGroups;for(let Yr=0,uf=Be.length;Yr<uf;Yr++)if(st.isWebGL2){let ih=Be[Yr];bt.update(ih,Nn),bt.bind(ih,Nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Nn}u(cf,"setProgram");function lf(S,N){S.ambientLightColor.needsUpdate=N,S.lightProbe.needsUpdate=N,S.directionalLights.needsUpdate=N,S.directionalLightShadows.needsUpdate=N,S.pointLights.needsUpdate=N,S.pointLightShadows.needsUpdate=N,S.spotLights.needsUpdate=N,S.spotLightShadows.needsUpdate=N,S.rectAreaLights.needsUpdate=N,S.hemisphereLights.needsUpdate=N}u(lf,"markUniformsLightsNeedsUpdate");function hf(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}u(hf,"materialNeedsLights"),this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(S,N,B){pt.get(S.texture).__webglTexture=N,pt.get(S.depthTexture).__webglTexture=B;let z=pt.get(S);z.__hasExternalTextures=!0,z.__autoAllocateDepthBuffer=B===void 0,z.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(S,N){let B=pt.get(S);B.__webglFramebuffer=N,B.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(S,N=0,B=0){R=S,L=N,C=B;let z=!0,O=null,gt=!1,Et=!1;if(S){let Pt=pt.get(S);Pt.__useDefaultFramebuffer!==void 0?(K.bindFramebuffer(T.FRAMEBUFFER,null),z=!1):Pt.__webglFramebuffer===void 0?yt.setupRenderTarget(S):Pt.__hasExternalTextures&&yt.rebindTextures(S,pt.get(S.texture).__webglTexture,pt.get(S.depthTexture).__webglTexture);let Gt=S.texture;(Gt.isData3DTexture||Gt.isDataArrayTexture||Gt.isCompressedArrayTexture)&&(Et=!0);let Dt=pt.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Dt[N])?O=Dt[N][B]:O=Dt[N],gt=!0):st.isWebGL2&&S.samples>0&&yt.useMultisampledRTT(S)===!1?O=pt.get(S).__webglMultisampledFramebuffer:Array.isArray(Dt)?O=Dt[B]:O=Dt,M.copy(S.viewport),A.copy(S.scissor),Q=S.scissorTest}else M.copy(it).multiplyScalar(J).floor(),A.copy(nt).multiplyScalar(J).floor(),Q=_t;if(K.bindFramebuffer(T.FRAMEBUFFER,O)&&st.drawBuffers&&z&&K.drawBuffers(S,O),K.viewport(M),K.scissor(A),K.setScissorTest(Q),gt){let Pt=pt.get(S.texture);T.framebufferTexture2D(T.FRAMEBUFFER,T.COLOR_ATTACHMENT0,T.TEXTURE_CUBE_MAP_POSITIVE_X+N,Pt.__webglTexture,B)}else if(Et){let Pt=pt.get(S.texture),Gt=N||0;T.framebufferTextureLayer(T.FRAMEBUFFER,T.COLOR_ATTACHMENT0,Pt.__webglTexture,B||0,Gt)}D=-1},this.readRenderTargetPixels=function(S,N,B,z,O,gt,Et){if(!(S&&S.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ct=pt.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&Et!==void 0&&(Ct=Ct[Et]),Ct){K.bindFramebuffer(T.FRAMEBUFFER,Ct);try{let Pt=S.texture,Gt=Pt.format,Dt=Pt.type;if(Gt!==Oe&&Tt.convert(Gt)!==T.getParameter(T.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Ot=Dt===ns&&(Z.has("EXT_color_buffer_half_float")||st.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Dt!==Rn&&Tt.convert(Dt)!==T.getParameter(T.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Dt===ke&&(st.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Ot){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=S.width-z&&B>=0&&B<=S.height-O&&T.readPixels(N,B,z,O,Tt.convert(Gt),Tt.convert(Dt),gt)}finally{let Pt=R!==null?pt.get(R).__webglFramebuffer:null;K.bindFramebuffer(T.FRAMEBUFFER,Pt)}}},this.copyFramebufferToTexture=function(S,N,B=0){let z=Math.pow(2,-B),O=Math.floor(N.image.width*z),gt=Math.floor(N.image.height*z);yt.setTexture2D(N,0),T.copyTexSubImage2D(T.TEXTURE_2D,B,0,0,S.x,S.y,O,gt),K.unbindTexture()},this.copyTextureToTexture=function(S,N,B,z=0){let O=N.image.width,gt=N.image.height,Et=Tt.convert(B.format),Ct=Tt.convert(B.type);yt.setTexture2D(B,0),T.pixelStorei(T.UNPACK_FLIP_Y_WEBGL,B.flipY),T.pixelStorei(T.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),T.pixelStorei(T.UNPACK_ALIGNMENT,B.unpackAlignment),N.isDataTexture?T.texSubImage2D(T.TEXTURE_2D,z,S.x,S.y,O,gt,Et,Ct,N.image.data):N.isCompressedTexture?T.compressedTexSubImage2D(T.TEXTURE_2D,z,S.x,S.y,N.mipmaps[0].width,N.mipmaps[0].height,Et,N.mipmaps[0].data):T.texSubImage2D(T.TEXTURE_2D,z,S.x,S.y,Et,Ct,N.image),z===0&&B.generateMipmaps&&T.generateMipmap(T.TEXTURE_2D),K.unbindTexture()},this.copyTextureToTexture3D=function(S,N,B,z,O=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let gt=Math.round(S.max.x-S.min.x),Et=Math.round(S.max.y-S.min.y),Ct=S.max.z-S.min.z+1,Pt=Tt.convert(z.format),Gt=Tt.convert(z.type),Dt;if(z.isData3DTexture)yt.setTexture3D(z,0),Dt=T.TEXTURE_3D;else if(z.isDataArrayTexture||z.isCompressedArrayTexture)yt.setTexture2DArray(z,0),Dt=T.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}T.pixelStorei(T.UNPACK_FLIP_Y_WEBGL,z.flipY),T.pixelStorei(T.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),T.pixelStorei(T.UNPACK_ALIGNMENT,z.unpackAlignment);let Ot=T.getParameter(T.UNPACK_ROW_LENGTH),re=T.getParameter(T.UNPACK_IMAGE_HEIGHT),Ue=T.getParameter(T.UNPACK_SKIP_PIXELS),de=T.getParameter(T.UNPACK_SKIP_ROWS),en=T.getParameter(T.UNPACK_SKIP_IMAGES),ie=B.isCompressedTexture?B.mipmaps[O]:B.image;T.pixelStorei(T.UNPACK_ROW_LENGTH,ie.width),T.pixelStorei(T.UNPACK_IMAGE_HEIGHT,ie.height),T.pixelStorei(T.UNPACK_SKIP_PIXELS,S.min.x),T.pixelStorei(T.UNPACK_SKIP_ROWS,S.min.y),T.pixelStorei(T.UNPACK_SKIP_IMAGES,S.min.z),B.isDataTexture||B.isData3DTexture?T.texSubImage3D(Dt,O,N.x,N.y,N.z,gt,Et,Ct,Pt,Gt,ie.data):z.isCompressedArrayTexture?T.compressedTexSubImage3D(Dt,O,N.x,N.y,N.z,gt,Et,Ct,Pt,ie.data):T.texSubImage3D(Dt,O,N.x,N.y,N.z,gt,Et,Ct,Pt,Gt,ie),T.pixelStorei(T.UNPACK_ROW_LENGTH,Ot),T.pixelStorei(T.UNPACK_IMAGE_HEIGHT,re),T.pixelStorei(T.UNPACK_SKIP_PIXELS,Ue),T.pixelStorei(T.UNPACK_SKIP_ROWS,de),T.pixelStorei(T.UNPACK_SKIP_IMAGES,en),O===0&&z.generateMipmaps&&T.generateMipmap(Dt),K.unbindTexture()},this.initTexture=function(S){S.isCubeTexture?yt.setTextureCube(S,0):S.isData3DTexture?yt.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?yt.setTexture2DArray(S,0):yt.setTexture2D(S,0),K.unbindTexture()},this.resetState=function(){L=0,C=0,R=null,K.reset(),St.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return dn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===zo?"display-p3":"srgb",e.unpackColorSpace=Jt.workingColorSpace===Vr?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}};u(Nc,"WebGLRenderer");var ao=Nc,Oc=class Oc extends ao{};u(Oc,"WebGL1Renderer");var oo=Oc;oo.prototype.isWebGL1Renderer=!0;var Fc=class Fc extends le{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 Je,this.environmentRotation=new Je,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentRotation=this.environmentRotation.toArray(),e}};u(Fc,"Scene");var Cu=Fc,Bc=class Bc{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Ha,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ve()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Yd("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ve()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ve()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};u(Bc,"InterleavedBuffer");var Pu=Bc,we=new P,Ur=class Ur{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)we.fromBufferAttribute(this,e),we.applyMatrix4(t),this.setXYZ(e,we.x,we.y,we.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.applyNormalMatrix(t),this.setXYZ(e,we.x,we.y,we.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.transformDirection(t),this.setXYZ(e,we.x,we.y,we.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Zt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Zt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ze(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ze(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ze(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ze(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array),i=Zt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zt(e,this.array),n=Zt(n,this.array),i=Zt(i,this.array),r=Zt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new Se(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ur(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};u(Ur,"InterleavedBufferAttribute");var Iu=Ur;var Lu=new P,Uu=new $t,Du=new $t,bx=new P,Nu=new Ft,Ns=new P,wa=new Re,Ou=new Ft,Aa=new Kn,zc=class zc extends Me{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=uh,this.bindMatrix=new Ft,this.bindMatrixInverse=new Ft,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ie),this.boundingBox.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Ns),this.boundingBox.expandByPoint(Ns)}computeBoundingSphere(){let t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Re),this.boundingSphere.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Ns),this.boundingSphere.expandByPoint(Ns)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){let n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),wa.copy(this.boundingSphere),wa.applyMatrix4(i),t.ray.intersectsSphere(wa)!==!1&&(Ou.copy(i).invert(),Aa.copy(t.ray).applyMatrix4(Ou),!(this.boundingBox!==null&&Aa.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Aa)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let t=new $t,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);let r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===uh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Yf?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){let n=this.skeleton,i=this.geometry;Uu.fromBufferAttribute(i.attributes.skinIndex,t),Du.fromBufferAttribute(i.attributes.skinWeight,t),Lu.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let o=Du.getComponent(r);if(o!==0){let a=Uu.getComponent(r);Nu.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),e.addScaledVector(bx.copy(Lu).applyMatrix4(Nu),o)}}return e.applyMatrix4(this.bindMatrixInverse)}};u(zc,"SkinnedMesh");var Fu=zc,kc=class kc extends le{constructor(){super(),this.isBone=!0,this.type="Bone"}};u(kc,"Bone");var co=kc,Vc=class Vc extends be{constructor(t=null,e=1,n=1,i,r,o,a,c,l=ge,h=ge,d,f){super(null,o,a,c,l,h,i,r,d,f),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};u(Vc,"DataTexture");var as=Vc,Bu=new Ft,Ex=new Ft,Dr=class Dr{constructor(t=[],e=[]){this.uuid=Ve(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ft)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new Ft;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];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 t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=t.length;r<o;r++){let a=t[r]?t[r].matrixWorld:Ex;Bu.multiplyMatrices(a,e[r]),Bu.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Dr(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new as(e,t,t,Oe,ke);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){let r=t.bones[n],o=e[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new co),this.bones.push(o),this.boneInverses.push(new Ft().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){let o=e[i];t.bones.push(o.uuid);let a=n[i];t.boneInverses.push(a.toArray())}return t}};u(Dr,"Skeleton");var zu=Dr,Hc=class Hc extends Se{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};u(Hc,"InstancedBufferAttribute");var mr=Hc,_i=new Ft,ku=new Ft,Os=[],Vu=new Ie,wx=new Ft,qi=new Me,Yi=new Re,Gc=class Gc extends Me{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new mr(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,wx)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Ie),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,_i),Vu.copy(t.boundingBox).applyMatrix4(_i),this.boundingBox.union(Vu)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Re),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,_i),Yi.copy(t.boundingSphere).applyMatrix4(_i),this.boundingSphere.union(Yi)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=t*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(t,e){let n=this.matrixWorld,i=this.count;if(qi.geometry=this.geometry,qi.material=this.material,qi.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yi.copy(this.boundingSphere),Yi.applyMatrix4(n),t.ray.intersectsSphere(Yi)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,_i),ku.multiplyMatrices(n,_i),qi.matrixWorld=ku,qi.raycast(t,Os);for(let o=0,a=Os.length;o<a;o++){let c=Os[o];c.instanceId=r,c.object=this,e.push(c)}Os.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new mr(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new as(new Float32Array(i*this.count),i,this.count,kd,ke));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=i*t;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};u(Gc,"InstancedMesh");var Hu=Gc;function Ax(s,t){return s.z-t.z}u(Ax,"sortOpaque");function Tx(s,t){return t.z-s.z}u(Tx,"sortTransparent");var Wc=class Wc{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e){let n=this.pool,i=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1});let r=n[this.index];i.push(r),this.index++,r.start=t.start,r.count=t.count,r.z=e}reset(){this.list.length=0,this.index=0}};u(Wc,"MultiDrawRenderList");var lo=Wc,xi="batchId",yn=new Ft,Gu=new Ft,Rx=new Ft,Wu=new Ft,Ta=new Di,Fs=new Ie,Gn=new Re,Zi=new P,Ra=new lo,ye=new Me,Bs=[];function Cx(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)t.setComponent(r+e,o,s.getComponent(r,o))}else t.array.set(s.array,e*n);t.needsUpdate=!0}u(Cx,"copyAttributeData");var Xc=class Xc extends Me{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,n=e*2,i){super(new Le,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let t=Math.sqrt(this._maxGeometryCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4),n=new as(e,t,t,Oe,ke);this._matricesTexture=n}_initializeGeometry(t){let e=this.geometry,n=this._maxVertexCount,i=this._maxGeometryCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in t.attributes){let c=t.getAttribute(a),{array:l,itemSize:h,normalized:d}=c,f=new l.constructor(n*h),g=new c.constructor(f,h,d);g.setUsage(c.usage),e.setAttribute(a,g)}if(t.getIndex()!==null){let a=n>65536?new Uint32Array(r):new Uint16Array(r);e.setIndex(new Se(a,1))}let o=i>65536?new Uint32Array(n):new Uint16Array(n);e.setAttribute(xi,new Se(o,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(xi))throw new Error(`BatchedMesh: Geometry cannot use attribute "${xi}"`);let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(n===xi)continue;if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ie);let t=this._geometryCount,e=this.boundingBox,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)n[i]!==!1&&(this.getMatrixAt(i,yn),this.getBoundingBoxAt(i,Fs).applyMatrix4(yn),e.union(Fs))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Re);let t=this._geometryCount,e=this.boundingSphere,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)n[i]!==!1&&(this.getMatrixAt(i,yn),this.getBoundingSphereAt(i,Gn).applyMatrix4(yn),e.union(Gn))}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},r=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),e===-1?i.vertexCount=t.getAttribute("position").count:i.vertexCount=e,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;let l=t.getIndex(),h=l!==null;if(h&&(n===-1?i.indexCount=l.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,f=this._active,g=this._matricesTexture,_=this._matricesTexture.image.data;d.push(!0),f.push(!0);let v=this._geometryCount;this._geometryCount++,Rx.toArray(_,v*16),g.needsUpdate=!0,o.push(i),a.push({start:h?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Ie,sphereInitialized:!1,sphere:new Re});let m=this.geometry.getAttribute(xi);for(let p=0;p<i.vertexCount;p++)m.setX(i.vertexStart+p,v);return m.needsUpdate=!0,this.setGeometryAt(v,t),v}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=e.getIndex(),a=this._reservedRanges[t];if(i&&o.count>a.indexCount||e.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let g in n.attributes){if(g===xi)continue;let _=e.getAttribute(g),v=n.getAttribute(g);Cx(_,v,c);let m=_.itemSize;for(let p=_.count,w=l;p<w;p++){let x=c+p;for(let b=0;b<m;b++)v.setComponent(x,b,0)}v.needsUpdate=!0}if(i){let g=a.indexStart;for(let _=0;_<o.count;_++)r.setX(g+_,c+o.getX(_));for(let _=o.count,v=a.indexCount;_<v;_++)r.setX(g+_,c);r.needsUpdate=!0}let h=this._bounds[t];e.boundingBox!==null?(h.box.copy(e.boundingBox),h.boxInitialized=!0):h.boxInitialized=!1,e.boundingSphere!==null?(h.sphere.copy(e.boundingSphere),h.sphereInitialized=!0):h.sphereInitialized=!1;let d=this._drawRanges[t],f=e.getAttribute("position");return d.count=i?o.count:f.count,this._visibilityChanged=!0,t}deleteGeometry(t){let e=this._active;return t>=e.length||e[t]===!1?this:(e[t]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(t,e){if(this._active[t]===!1)return null;let i=this._bounds[t],r=i.box,o=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[t];for(let h=l.start,d=l.start+l.count;h<d;h++){let f=h;a&&(f=a.getX(f)),r.expandByPoint(Zi.fromBufferAttribute(c,f))}i.boxInitialized=!0}return e.copy(r),e}getBoundingSphereAt(t,e){if(this._active[t]===!1)return null;let i=this._bounds[t],r=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(t,Fs),Fs.getCenter(r.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[t],h=0;for(let d=l.start,f=l.start+l.count;d<f;d++){let g=d;a&&(g=a.getX(g)),Zi.fromBufferAttribute(c,g),h=Math.max(h,r.center.distanceToSquared(Zi))}r.radius=Math.sqrt(h),i.sphereInitialized=!0}return e.copy(r),e}setMatrixAt(t,e){let n=this._active,i=this._matricesTexture,r=this._matricesTexture.image.data,o=this._geometryCount;return t>=o||n[t]===!1?this:(e.toArray(r,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){let n=this._active,i=this._matricesTexture.image.data,r=this._geometryCount;return t>=r||n[t]===!1?null:e.fromArray(i,t*16)}setVisibleAt(t,e){let n=this._visibility,i=this._active,r=this._geometryCount;return t>=r||i[t]===!1||n[t]===e?this:(n[t]=e,this._visibilityChanged=!0,this)}getVisibleAt(t){let e=this._visibility,n=this._active,i=this._geometryCount;return t>=i||n[t]===!1?!1:e[t]}raycast(t,e){let n=this._visibility,i=this._active,r=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;ye.material=this.material,ye.geometry.index=c.index,ye.geometry.attributes=c.attributes,ye.geometry.boundingBox===null&&(ye.geometry.boundingBox=new Ie),ye.geometry.boundingSphere===null&&(ye.geometry.boundingSphere=new Re);for(let l=0;l<o;l++){if(!n[l]||!i[l])continue;let h=r[l];ye.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(l,ye.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,ye.geometry.boundingBox),this.getBoundingSphereAt(l,ye.geometry.boundingSphere),ye.raycast(t,Bs);for(let d=0,f=Bs.length;d<f;d++){let g=Bs[d];g.object=this,g.batchId=l,e.push(g)}Bs.length=0}ye.material=null,ye.geometry.index=null,ye.geometry.attributes={},ye.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map(e=>({...e})),this._reservedRanges=t._reservedRanges.map(e=>({...e})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._active,l=this._visibility,h=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(Wu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Ta.setFromProjectionMatrix(Wu,t.coordinateSystem));let _=0;if(this.sortObjects){Gu.copy(this.matrixWorld).invert(),Zi.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Gu);for(let p=0,w=l.length;p<w;p++)if(l[p]&&c[p]){this.getMatrixAt(p,yn),this.getBoundingSphereAt(p,Gn).applyMatrix4(yn);let x=!1;if(g&&(x=!Ta.intersectsSphere(Gn)),!x){let b=Zi.distanceTo(Gn.center);Ra.push(f[p],b)}}let v=Ra.list,m=this.customSort;m===null?v.sort(r.transparent?Tx:Ax):m.call(this,v,n);for(let p=0,w=v.length;p<w;p++){let x=v[p];h[_]=x.start*a,d[_]=x.count,_++}Ra.reset()}else for(let v=0,m=l.length;v<m;v++)if(l[v]&&c[v]){let p=!1;if(g&&(this.getMatrixAt(v,yn),this.getBoundingSphereAt(v,Gn).applyMatrix4(yn),p=!Ta.intersectsSphere(Gn)),!p){let w=f[v];h[_]=w.start*a,d[_]=w.count,_++}}this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,o){this.onBeforeRender(t,null,i,r,o)}};u(Xc,"BatchedMesh");var Xu=Xc,qc=class qc extends je{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}};u(qc,"LineBasicMaterial");var ho=qc,qu=new P,Yu=new P,Zu=new Ft,Ca=new Kn,zs=new Re,Yc=class Yc extends le{constructor(t=new Le,e=new ho){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)qu.fromBufferAttribute(e,i-1),Yu.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=qu.distanceTo(Yu);t.setAttribute("lineDistance",new ce(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zs.copy(n.boundingSphere),zs.applyMatrix4(i),zs.radius+=r,t.ray.intersectsSphere(zs)===!1)return;Zu.copy(i).invert(),Ca.copy(t.ray).applyMatrix4(Zu);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new P,h=new P,d=new P,f=new P,g=this.isLineSegments?2:1,_=n.index,m=n.attributes.position;if(_!==null){let p=Math.max(0,o.start),w=Math.min(_.count,o.start+o.count);for(let x=p,b=w-1;x<b;x+=g){let L=_.getX(x),C=_.getX(x+1);if(l.fromBufferAttribute(m,L),h.fromBufferAttribute(m,C),Ca.distanceSqToSegment(l,h,f,d)>c)continue;f.applyMatrix4(this.matrixWorld);let D=t.ray.origin.distanceTo(f);D<t.near||D>t.far||e.push({distance:D,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let p=Math.max(0,o.start),w=Math.min(m.count,o.start+o.count);for(let x=p,b=w-1;x<b;x+=g){if(l.fromBufferAttribute(m,x),h.fromBufferAttribute(m,x+1),Ca.distanceSqToSegment(l,h,f,d)>c)continue;f.applyMatrix4(this.matrixWorld);let C=t.ray.origin.distanceTo(f);C<t.near||C>t.far||e.push({distance:C,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};u(Yc,"Line");var gr=Yc,Ju=new P,$u=new P,Zc=class Zc extends gr{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)Ju.fromBufferAttribute(e,i),$u.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Ju.distanceTo($u);t.setAttribute("lineDistance",new ce(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};u(Zc,"LineSegments");var Ku=Zc,Jc=class Jc extends gr{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}};u(Jc,"LineLoop");var Qu=Jc,$c=class $c extends je{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Vt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}};u($c,"PointsMaterial");var uo=$c,ju=new Ft,fo=new Kn,ks=new Re,Vs=new P,Kc=class Kc extends le{constructor(t=new Le,e=new uo){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ks.copy(n.boundingSphere),ks.applyMatrix4(i),ks.radius+=r,t.ray.intersectsSphere(ks)===!1)return;ju.copy(i).invert(),fo.copy(t.ray).applyMatrix4(ju);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,o.start),g=Math.min(l.count,o.start+o.count);for(let _=f,v=g;_<v;_++){let m=l.getX(_);Vs.fromBufferAttribute(d,m),ed(Vs,m,c,i,t,e,this)}}else{let f=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let _=f,v=g;_<v;_++)Vs.fromBufferAttribute(d,_),ed(Vs,_,c,i,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};u(Kc,"Points");var td=Kc;function ed(s,t,e,n,i,r,o){let a=fo.distanceSqToPoint(s);if(a<e){let c=new P;fo.closestPointToPoint(s,c),c.applyMatrix4(n);let l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,object:o})}}u(ed,"testPoint");var Qc=class Qc extends be{constructor(t,e,n,i,r,o,a,c,l,h,d,f){super(null,o,a,c,l,h,i,r,d,f),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}};u(Qc,"CompressedTexture");var nd=Qc;var jc=class jc extends be{constructor(t,e,n,i,r,o,a,c,l){super(t,e,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}};u(jc,"CanvasTexture");var id=jc,tl=class tl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,r=n.length,o;e?o=e:o=t*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);let h=n[i],f=n[i+1]-h,g=(o-h)/f;return(i+g)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let o=this.getPoint(i),a=this.getPoint(r),c=e||(o.isVector2?new at:new P);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new P,i=[],r=[],o=[],a=new P,c=new Ft;for(let g=0;g<=t;g++){let _=g/t;i[g]=this.getTangentAt(_,new P)}r[0]=new P,o[0]=new P;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),d=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),d<=l&&(l=d,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let g=1;g<=t;g++){if(r[g]=r[g-1].clone(),o[g]=o[g-1].clone(),a.crossVectors(i[g-1],i[g]),a.length()>Number.EPSILON){a.normalize();let _=Math.acos(pe(i[g-1].dot(i[g]),-1,1));r[g].applyMatrix4(c.makeRotationAxis(a,_))}o[g].crossVectors(i[g],r[g])}if(e===!0){let g=Math.acos(pe(r[0].dot(r[t]),-1,1));g/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(g=-g);for(let _=1;_<=t;_++)r[_].applyMatrix4(c.makeRotationAxis(i[_],g*_)),o[_].crossVectors(i[_],r[_])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}};u(tl,"Curve");var He=tl,el=class el extends He{constructor(t=0,e=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new at){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);let a=this.aStartAngle+t*r,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),f=c-this.aX,g=l-this.aY;c=f*h-g*d+this.aX,l=f*d+g*h+this.aY}return n.set(c,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}};u(el,"EllipseCurve");var os=el,nl=class nl extends os{constructor(t,e,n,i,r,o){super(t,e,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}};u(nl,"ArcCurve");var po=nl;function Ho(){let s=0,t=0,e=0,n=0;function i(r,o,a,c){s=r,t=a,e=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return u(i,"init"),{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,h,d){let f=(o-r)/l-(a-r)/(l+h)+(a-o)/h,g=(a-o)/h-(c-o)/(h+d)+(c-a)/d;f*=h,g*=h,i(o,a,f,g)},calc:function(r){let o=r*r,a=o*r;return s+t*r+e*o+n*a}}}u(Ho,"CubicPoly");var Hs=new P,Pa=new Ho,Ia=new Ho,La=new Ho,il=class il extends He{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new P){let n=e,i=this.points,r=i.length,o=(r-(this.closed?0:1))*t,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,h;this.closed||a>0?l=i[(a-1)%r]:(Hs.subVectors(i[0],i[1]).add(i[0]),l=Hs);let d=i[a%r],f=i[(a+1)%r];if(this.closed||a+2<r?h=i[(a+2)%r]:(Hs.subVectors(i[r-1],i[r-2]).add(i[r-1]),h=Hs),this.curveType==="centripetal"||this.curveType==="chordal"){let g=this.curveType==="chordal"?.5:.25,_=Math.pow(l.distanceToSquared(d),g),v=Math.pow(d.distanceToSquared(f),g),m=Math.pow(f.distanceToSquared(h),g);v<1e-4&&(v=1),_<1e-4&&(_=v),m<1e-4&&(m=v),Pa.initNonuniformCatmullRom(l.x,d.x,f.x,h.x,_,v,m),Ia.initNonuniformCatmullRom(l.y,d.y,f.y,h.y,_,v,m),La.initNonuniformCatmullRom(l.z,d.z,f.z,h.z,_,v,m)}else this.curveType==="catmullrom"&&(Pa.initCatmullRom(l.x,d.x,f.x,h.x,this.tension),Ia.initCatmullRom(l.y,d.y,f.y,h.y,this.tension),La.initCatmullRom(l.z,d.z,f.z,h.z,this.tension));return n.set(Pa.calc(c),Ia.calc(c),La.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new P().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};u(il,"CatmullRomCurve3");var mo=il;function sd(s,t,e,n,i){let r=(n-t)*.5,o=(i-e)*.5,a=s*s,c=s*a;return(2*e-2*n+r+o)*c+(-3*e+3*n-2*r-o)*a+r*s+e}u(sd,"CatmullRom");function Px(s,t){let e=1-s;return e*e*t}u(Px,"QuadraticBezierP0");function Ix(s,t){return 2*(1-s)*s*t}u(Ix,"QuadraticBezierP1");function Lx(s,t){return s*s*t}u(Lx,"QuadraticBezierP2");function Qi(s,t,e,n){return Px(s,t)+Ix(s,e)+Lx(s,n)}u(Qi,"QuadraticBezier");function Ux(s,t){let e=1-s;return e*e*e*t}u(Ux,"CubicBezierP0");function Dx(s,t){let e=1-s;return 3*e*e*s*t}u(Dx,"CubicBezierP1");function Nx(s,t){return 3*(1-s)*s*s*t}u(Nx,"CubicBezierP2");function Ox(s,t){return s*s*s*t}u(Ox,"CubicBezierP3");function ji(s,t,e,n,i){return Ux(s,t)+Dx(s,e)+Nx(s,n)+Ox(s,i)}u(ji,"CubicBezier");var sl=class sl extends He{constructor(t=new at,e=new at,n=new at,i=new at){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new at){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(ji(t,i.x,r.x,o.x,a.x),ji(t,i.y,r.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}};u(sl,"CubicBezierCurve");var _r=sl,rl=class rl extends He{constructor(t=new P,e=new P,n=new P,i=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new P){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(ji(t,i.x,r.x,o.x,a.x),ji(t,i.y,r.y,o.y,a.y),ji(t,i.z,r.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}};u(rl,"CubicBezierCurve3");var go=rl,al=class al extends He{constructor(t=new at,e=new at){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new at){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new at){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};u(al,"LineCurve");var xr=al,ol=class ol extends He{constructor(t=new P,e=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new P){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new P){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};u(ol,"LineCurve3");var _o=ol,cl=class cl extends He{constructor(t=new at,e=new at,n=new at){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new at){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(Qi(t,i.x,r.x,o.x),Qi(t,i.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};u(cl,"QuadraticBezierCurve");var vr=cl,ll=class ll extends He{constructor(t=new P,e=new P,n=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new P){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(Qi(t,i.x,r.x,o.x),Qi(t,i.y,r.y,o.y),Qi(t,i.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}};u(ll,"QuadraticBezierCurve3");var yr=ll,hl=class hl extends He{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new at){let n=e,i=this.points,r=(i.length-1)*t,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],h=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(sd(a,c.x,l.x,h.x,d.x),sd(a,c.y,l.y,h.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new at().fromArray(i))}return this}};u(hl,"SplineCurve");var Mr=hl,Sr=Object.freeze({__proto__:null,ArcCurve:po,CatmullRomCurve3:mo,CubicBezierCurve:_r,CubicBezierCurve3:go,EllipseCurve:os,LineCurve:xr,LineCurve3:_o,QuadraticBezierCurve:vr,QuadraticBezierCurve3:yr,SplineCurve:Mr}),ul=class ul extends He{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Sr[n](e,t))}return this}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,r=this.curves;i<r.length;i++){let o=r[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){let h=c[l];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new Sr[i.type]().fromJSON(i))}return this}};u(ul,"CurvePath");var xo=ul,dl=class dl extends xo{constructor(t){super(),this.type="Path",this.currentPoint=new at,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new xr(this.currentPoint.clone(),new at(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let r=new vr(this.currentPoint.clone(),new at(t,e),new at(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,o){let a=new _r(this.currentPoint.clone(),new at(t,e),new at(n,i),new at(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Mr(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,i,r,o),this}absarc(t,e,n,i,r,o){return this.absellipse(t,e,n,n,i,r,o),this}ellipse(t,e,n,i,r,o,a,c){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,n,i,r,o,a,c),this}absellipse(t,e,n,i,r,o,a,c){let l=new os(t,e,n,i,r,o,a,c);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}};u(dl,"Path");var br=dl;var Nr=class Nr extends Le{constructor(t=1,e=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};let l=this;i=Math.floor(i),r=Math.floor(r);let h=[],d=[],f=[],g=[],_=0,v=[],m=n/2,p=0;w(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ce(d,3)),this.setAttribute("normal",new ce(f,3)),this.setAttribute("uv",new ce(g,2));function w(){let b=new P,L=new P,C=0,R=(e-t)/n;for(let D=0;D<=r;D++){let X=[],M=D/r,A=M*(e-t)+t;for(let Q=0;Q<=i;Q++){let $=Q/i,I=$*c+a,G=Math.sin(I),k=Math.cos(I);L.x=A*G,L.y=-M*n+m,L.z=A*k,d.push(L.x,L.y,L.z),b.set(G,R,k).normalize(),f.push(b.x,b.y,b.z),g.push($,1-M),X.push(_++)}v.push(X)}for(let D=0;D<i;D++)for(let X=0;X<r;X++){let M=v[X][D],A=v[X+1][D],Q=v[X+1][D+1],$=v[X][D+1];h.push(M,A,$),h.push(A,Q,$),C+=6}l.addGroup(p,C,0),p+=C}u(w,"generateTorso");function x(b){let L=_,C=new at,R=new P,D=0,X=b===!0?t:e,M=b===!0?1:-1;for(let Q=1;Q<=i;Q++)d.push(0,m*M,0),f.push(0,M,0),g.push(.5,.5),_++;let A=_;for(let Q=0;Q<=i;Q++){let I=Q/i*c+a,G=Math.cos(I),k=Math.sin(I);R.x=X*k,R.y=m*M,R.z=X*G,d.push(R.x,R.y,R.z),f.push(0,M,0),C.x=G*.5+.5,C.y=k*.5*M+.5,g.push(C.x,C.y),_++}for(let Q=0;Q<i;Q++){let $=L+Q,I=A+Q;b===!0?h.push(I,I+1,$):h.push(I+1,I,$),D+=3}l.addGroup(p,D,b===!0?1:2),p+=D}u(x,"generateCap")}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Nr(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}};u(Nr,"CylinderGeometry");var rd=Nr;var Gs=new P,Ws=new P,Ua=new P,Xs=new Zn,fl=class fl extends Le{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){let i=Math.pow(10,4),r=Math.cos(Ai*e),o=t.getIndex(),a=t.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],h=["a","b","c"],d=new Array(3),f={},g=[];for(let _=0;_<c;_+=3){o?(l[0]=o.getX(_),l[1]=o.getX(_+1),l[2]=o.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:v,b:m,c:p}=Xs;if(v.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Xs.getNormal(Ua),d[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,d[1]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,d[2]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let w=0;w<3;w++){let x=(w+1)%3,b=d[w],L=d[x],C=Xs[h[w]],R=Xs[h[x]],D=`${b}_${L}`,X=`${L}_${b}`;X in f&&f[X]?(Ua.dot(f[X].normal)<=r&&(g.push(C.x,C.y,C.z),g.push(R.x,R.y,R.z)),f[X]=null):D in f||(f[D]={index0:l[w],index1:l[x],normal:Ua.clone()})}}for(let _ in f)if(f[_]){let{index0:v,index1:m}=f[_];Gs.fromBufferAttribute(a,v),Ws.fromBufferAttribute(a,m),g.push(Gs.x,Gs.y,Gs.z),g.push(Ws.x,Ws.y,Ws.z)}this.setAttribute("position",new ce(g,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}};u(fl,"EdgesGeometry");var ad=fl,pl=class pl extends br{constructor(t){super(t),this.uuid=Ve(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new br().fromJSON(i))}return this}};u(pl,"Shape");var vo=pl,Fx={triangulate:function(s,t,e=2){let n=t&&t.length,i=n?t[0]*e:s.length,r=nf(s,0,i,e,!0),o=[];if(!r||r.next===r.prev)return o;let a,c,l,h,d,f,g;if(n&&(r=Hx(s,t,r,e)),s.length>80*e){a=l=s[0],c=h=s[1];for(let _=e;_<i;_+=e)d=s[_],f=s[_+1],d<a&&(a=d),f<c&&(c=f),d>l&&(l=d),f>h&&(h=f);g=Math.max(l-a,h-c),g=g!==0?32767/g:0}return cs(r,o,e,a,c,g,0),o}};function nf(s,t,e,n,i){let r,o;if(i===jx(s,t,e,n)>0)for(r=t;r<e;r+=n)o=od(r,s[r],s[r+1],o);else for(r=e-n;r>=t;r-=n)o=od(r,s[r],s[r+1],o);return o&&Gr(o,o.next)&&(hs(o),o=o.next),o}u(nf,"linkedList");function Qn(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Gr(e,e.next)||se(e.prev,e,e.next)===0)){if(hs(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}u(Qn,"filterPoints");function cs(s,t,e,n,i,r,o){if(!s)return;!o&&r&&Yx(s,n,i,r);let a=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?zx(s,n,i,r):Bx(s)){t.push(c.i/e|0),t.push(s.i/e|0),t.push(l.i/e|0),hs(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=kx(Qn(s),t,e),cs(s,t,e,n,i,r,2)):o===2&&Vx(s,t,e,n,i,r):cs(Qn(s),t,e,n,i,r,1);break}}}u(cs,"earcutLinked");function Bx(s){let t=s.prev,e=s,n=s.next;if(se(t,e,n)>=0)return!1;let i=t.x,r=e.x,o=n.x,a=t.y,c=e.y,l=n.y,h=i<r?i<o?i:o:r<o?r:o,d=a<c?a<l?a:l:c<l?c:l,f=i>r?i>o?i:o:r>o?r:o,g=a>c?a>l?a:l:c>l?c:l,_=n.next;for(;_!==t;){if(_.x>=h&&_.x<=f&&_.y>=d&&_.y<=g&&Si(i,a,r,c,o,l,_.x,_.y)&&se(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}u(Bx,"isEar");function zx(s,t,e,n){let i=s.prev,r=s,o=s.next;if(se(i,r,o)>=0)return!1;let a=i.x,c=r.x,l=o.x,h=i.y,d=r.y,f=o.y,g=a<c?a<l?a:l:c<l?c:l,_=h<d?h<f?h:f:d<f?d:f,v=a>c?a>l?a:l:c>l?c:l,m=h>d?h>f?h:f:d>f?d:f,p=yo(g,_,t,e,n),w=yo(v,m,t,e,n),x=s.prevZ,b=s.nextZ;for(;x&&x.z>=p&&b&&b.z<=w;){if(x.x>=g&&x.x<=v&&x.y>=_&&x.y<=m&&x!==i&&x!==o&&Si(a,h,c,d,l,f,x.x,x.y)&&se(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=g&&b.x<=v&&b.y>=_&&b.y<=m&&b!==i&&b!==o&&Si(a,h,c,d,l,f,b.x,b.y)&&se(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=p;){if(x.x>=g&&x.x<=v&&x.y>=_&&x.y<=m&&x!==i&&x!==o&&Si(a,h,c,d,l,f,x.x,x.y)&&se(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=w;){if(b.x>=g&&b.x<=v&&b.y>=_&&b.y<=m&&b!==i&&b!==o&&Si(a,h,c,d,l,f,b.x,b.y)&&se(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}u(zx,"isEarHashed");function kx(s,t,e){let n=s;do{let i=n.prev,r=n.next.next;!Gr(i,r)&&sf(i,n,n.next,r)&&ls(i,r)&&ls(r,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(r.i/e|0),hs(n),hs(n.next),n=s=r),n=n.next}while(n!==s);return Qn(n)}u(kx,"cureLocalIntersections");function Vx(s,t,e,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&$x(o,a)){let c=rf(o,a);o=Qn(o,o.next),c=Qn(c,c.next),cs(o,t,e,n,i,r,0),cs(c,t,e,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}u(Vx,"splitEarcut");function Hx(s,t,e,n){let i=[],r,o,a,c,l;for(r=0,o=t.length;r<o;r++)a=t[r]*n,c=r<o-1?t[r+1]*n:s.length,l=nf(s,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(Jx(l));for(i.sort(Gx),r=0;r<i.length;r++)e=Wx(i[r],e);return e}u(Hx,"eliminateHoles");function Gx(s,t){return s.x-t.x}u(Gx,"compareX");function Wx(s,t){let e=Xx(s,t);if(!e)return t;let n=rf(e,s);return Qn(n,n.next),Qn(e,e.next)}u(Wx,"eliminateHole");function Xx(s,t){let e=t,n=-1/0,i,r=s.x,o=s.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let f=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=r&&f>n&&(n=f,i=e.x<e.next.x?e:e.next,f===r))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,c=i.x,l=i.y,h=1/0,d;e=i;do r>=e.x&&e.x>=c&&r!==e.x&&Si(o<l?r:n,o,c,l,o<l?n:r,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(r-e.x),ls(e,s)&&(d<h||d===h&&(e.x>i.x||e.x===i.x&&qx(i,e)))&&(i=e,h=d)),e=e.next;while(e!==a);return i}u(Xx,"findHoleBridge");function qx(s,t){return se(s.prev,s,t.prev)<0&&se(t.next,s,s.next)<0}u(qx,"sectorContainsSector");function Yx(s,t,e,n){let i=s;do i.z===0&&(i.z=yo(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Zx(i)}u(Yx,"indexCurve");function Zx(s){let t,e,n,i,r,o,a,c,l=1;do{for(e=s,s=null,r=null,o=0;e;){for(o++,n=e,a=0,t=0;t<l&&(a++,n=n.nextZ,!!n);t++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;e=n}r.nextZ=null,l*=2}while(o>1);return s}u(Zx,"sortLinked");function yo(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}u(yo,"zOrder");function Jx(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}u(Jx,"getLeftmost");function Si(s,t,e,n,i,r,o,a){return(i-o)*(t-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(i-o)*(n-a)}u(Si,"pointInTriangle");function $x(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Kx(s,t)&&(ls(s,t)&&ls(t,s)&&Qx(s,t)&&(se(s.prev,s,t.prev)||se(s,t.prev,t))||Gr(s,t)&&se(s.prev,s,s.next)>0&&se(t.prev,t,t.next)>0)}u($x,"isValidDiagonal");function se(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}u(se,"area");function Gr(s,t){return s.x===t.x&&s.y===t.y}u(Gr,"equals");function sf(s,t,e,n){let i=Ys(se(s,t,e)),r=Ys(se(s,t,n)),o=Ys(se(e,n,s)),a=Ys(se(e,n,t));return!!(i!==r&&o!==a||i===0&&qs(s,e,t)||r===0&&qs(s,n,t)||o===0&&qs(e,s,n)||a===0&&qs(e,t,n))}u(sf,"intersects");function qs(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}u(qs,"onSegment");function Ys(s){return s>0?1:s<0?-1:0}u(Ys,"sign");function Kx(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&sf(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}u(Kx,"intersectsPolygon");function ls(s,t){return se(s.prev,s,s.next)<0?se(s,t,s.next)>=0&&se(s,s.prev,t)>=0:se(s,t,s.prev)<0||se(s,s.next,t)<0}u(ls,"locallyInside");function Qx(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}u(Qx,"middleInside");function rf(s,t){let e=new Mo(s.i,s.x,s.y),n=new Mo(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}u(rf,"splitPolygon");function od(s,t,e,n){let i=new Mo(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}u(od,"insertNode");function hs(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}u(hs,"removeNode");function Mo(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}u(Mo,"Node");function jx(s,t,e,n){let i=0;for(let r=t,o=e-n;r<e;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}u(jx,"signedArea");var Or=class Or{static area(t){let e=t.length,n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return n*.5}static isClockWise(t){return Or.area(t)<0}static triangulateShape(t,e){let n=[],i=[],r=[];cd(t),ld(n,t);let o=t.length;e.forEach(cd);for(let c=0;c<e.length;c++)i.push(o),o+=e[c].length,ld(n,e[c]);let a=Fx.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}};u(Or,"ShapeUtils");var ts=Or;function cd(s){let t=s.length;t>2&&s[t-1].equals(s[0])&&s.pop()}u(cd,"removeDupEndPts");function ld(s,t){for(let e=0;e<t.length;e++)s.push(t[e].x),s.push(t[e].y)}u(ld,"addContour");var Fr=class Fr extends Le{constructor(t=new vo([new at(.5,.5),new at(-.5,.5),new at(-.5,-.5),new at(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let n=this,i=[],r=[];for(let a=0,c=t.length;a<c;a++){let l=t[a];o(l)}this.setAttribute("position",new ce(i,3)),this.setAttribute("uv",new ce(r,2)),this.computeVertexNormals();function o(a){let c=[],l=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,d=e.depth!==void 0?e.depth:1,f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,g=e.bevelThickness!==void 0?e.bevelThickness:.2,_=e.bevelSize!==void 0?e.bevelSize:g-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,m=e.bevelSegments!==void 0?e.bevelSegments:3,p=e.extrudePath,w=e.UVGenerator!==void 0?e.UVGenerator:tv,x,b=!1,L,C,R,D;p&&(x=p.getSpacedPoints(h),b=!0,f=!1,L=p.computeFrenetFrames(h,!1),C=new P,R=new P,D=new P),f||(m=0,g=0,_=0,v=0);let X=a.extractPoints(l),M=X.shape,A=X.holes;if(!ts.isClockWise(M)){M=M.reverse();for(let T=0,ot=A.length;T<ot;T++){let Z=A[T];ts.isClockWise(Z)&&(A[T]=Z.reverse())}}let $=ts.triangulateShape(M,A),I=M;for(let T=0,ot=A.length;T<ot;T++){let Z=A[T];M=M.concat(Z)}function G(T,ot,Z){return ot||console.error("THREE.ExtrudeGeometry: vec does not exist"),T.clone().addScaledVector(ot,Z)}u(G,"scalePt2");let k=M.length,J=$.length;function q(T,ot,Z){let st,K,xt,pt=T.x-ot.x,yt=T.y-ot.y,Wt=Z.x-T.x,E=Z.y-T.y,y=pt*pt+yt*yt,H=pt*E-yt*Wt;if(Math.abs(H)>Number.EPSILON){let W=Math.sqrt(y),et=Math.sqrt(Wt*Wt+E*E),j=ot.x-yt/W,Lt=ot.y+pt/W,Rt=Z.x-E/et,lt=Z.y+Wt/et,ut=((Rt-j)*E-(lt-Lt)*Wt)/(pt*E-yt*Wt);st=j+pt*ut-T.x,K=Lt+yt*ut-T.y;let Ut=st*st+K*K;if(Ut<=2)return new at(st,K);xt=Math.sqrt(Ut/2)}else{let W=!1;pt>Number.EPSILON?Wt>Number.EPSILON&&(W=!0):pt<-Number.EPSILON?Wt<-Number.EPSILON&&(W=!0):Math.sign(yt)===Math.sign(E)&&(W=!0),W?(st=-yt,K=pt,xt=Math.sqrt(y)):(st=pt,K=yt,xt=Math.sqrt(y/2))}return new at(st/xt,K/xt)}u(q,"getBevelVec");let Y=[];for(let T=0,ot=I.length,Z=ot-1,st=T+1;T<ot;T++,Z++,st++)Z===ot&&(Z=0),st===ot&&(st=0),Y[T]=q(I[T],I[Z],I[st]);let it=[],nt,_t=Y.concat();for(let T=0,ot=A.length;T<ot;T++){let Z=A[T];nt=[];for(let st=0,K=Z.length,xt=K-1,pt=st+1;st<K;st++,xt++,pt++)xt===K&&(xt=0),pt===K&&(pt=0),nt[st]=q(Z[st],Z[xt],Z[pt]);it.push(nt),_t=_t.concat(nt)}for(let T=0;T<m;T++){let ot=T/m,Z=g*Math.cos(ot*Math.PI/2),st=_*Math.sin(ot*Math.PI/2)+v;for(let K=0,xt=I.length;K<xt;K++){let pt=G(I[K],Y[K],st);wt(pt.x,pt.y,-Z)}for(let K=0,xt=A.length;K<xt;K++){let pt=A[K];nt=it[K];for(let yt=0,Wt=pt.length;yt<Wt;yt++){let E=G(pt[yt],nt[yt],st);wt(E.x,E.y,-Z)}}}let It=_+v;for(let T=0;T<k;T++){let ot=f?G(M[T],_t[T],It):M[T];b?(R.copy(L.normals[0]).multiplyScalar(ot.x),C.copy(L.binormals[0]).multiplyScalar(ot.y),D.copy(x[0]).add(R).add(C),wt(D.x,D.y,D.z)):wt(ot.x,ot.y,0)}for(let T=1;T<=h;T++)for(let ot=0;ot<k;ot++){let Z=f?G(M[ot],_t[ot],It):M[ot];b?(R.copy(L.normals[T]).multiplyScalar(Z.x),C.copy(L.binormals[T]).multiplyScalar(Z.y),D.copy(x[T]).add(R).add(C),wt(D.x,D.y,D.z)):wt(Z.x,Z.y,d/h*T)}for(let T=m-1;T>=0;T--){let ot=T/m,Z=g*Math.cos(ot*Math.PI/2),st=_*Math.sin(ot*Math.PI/2)+v;for(let K=0,xt=I.length;K<xt;K++){let pt=G(I[K],Y[K],st);wt(pt.x,pt.y,d+Z)}for(let K=0,xt=A.length;K<xt;K++){let pt=A[K];nt=it[K];for(let yt=0,Wt=pt.length;yt<Wt;yt++){let E=G(pt[yt],nt[yt],st);b?wt(E.x,E.y+x[h-1].y,x[h-1].x+Z):wt(E.x,E.y,d+Z)}}}V(),tt();function V(){let T=i.length/3;if(f){let ot=0,Z=k*ot;for(let st=0;st<J;st++){let K=$[st];Mt(K[2]+Z,K[1]+Z,K[0]+Z)}ot=h+m*2,Z=k*ot;for(let st=0;st<J;st++){let K=$[st];Mt(K[0]+Z,K[1]+Z,K[2]+Z)}}else{for(let ot=0;ot<J;ot++){let Z=$[ot];Mt(Z[2],Z[1],Z[0])}for(let ot=0;ot<J;ot++){let Z=$[ot];Mt(Z[0]+k*h,Z[1]+k*h,Z[2]+k*h)}}n.addGroup(T,i.length/3-T,0)}u(V,"buildLidFaces");function tt(){let T=i.length/3,ot=0;mt(I,ot),ot+=I.length;for(let Z=0,st=A.length;Z<st;Z++){let K=A[Z];mt(K,ot),ot+=K.length}n.addGroup(T,i.length/3-T,1)}u(tt,"buildSideFaces");function mt(T,ot){let Z=T.length;for(;--Z>=0;){let st=Z,K=Z-1;K<0&&(K=T.length-1);for(let xt=0,pt=h+m*2;xt<pt;xt++){let yt=k*xt,Wt=k*(xt+1),E=ot+st+yt,y=ot+K+yt,H=ot+K+Wt,W=ot+st+Wt;vt(E,y,H,W)}}}u(mt,"sidewalls");function wt(T,ot,Z){c.push(T),c.push(ot),c.push(Z)}u(wt,"v");function Mt(T,ot,Z){Ht(T),Ht(ot),Ht(Z);let st=i.length/3,K=w.generateTopUV(n,i,st-3,st-2,st-1);At(K[0]),At(K[1]),At(K[2])}u(Mt,"f3");function vt(T,ot,Z,st){Ht(T),Ht(ot),Ht(st),Ht(ot),Ht(Z),Ht(st);let K=i.length/3,xt=w.generateSideWallUV(n,i,K-6,K-3,K-2,K-1);At(xt[0]),At(xt[1]),At(xt[3]),At(xt[1]),At(xt[2]),At(xt[3])}u(vt,"f4");function Ht(T){i.push(c[T*3+0]),i.push(c[T*3+1]),i.push(c[T*3+2])}u(Ht,"addVertex");function At(T){r.push(T.x),r.push(T.y)}u(At,"addUV")}u(o,"addShape")}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return ev(e,n,t)}static fromJSON(t,e){let n=[];for(let r=0,o=t.shapes.length;r<o;r++){let a=e[t.shapes[r]];n.push(a)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new Sr[i.type]().fromJSON(i)),new Fr(n,t.options)}};u(Fr,"ExtrudeGeometry");var hd=Fr,tv={generateTopUV:function(s,t,e,n,i){let r=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[i*3],h=t[i*3+1];return[new at(r,o),new at(a,c),new at(l,h)]},generateSideWallUV:function(s,t,e,n,i,r){let o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],h=t[n*3+1],d=t[n*3+2],f=t[i*3],g=t[i*3+1],_=t[i*3+2],v=t[r*3],m=t[r*3+1],p=t[r*3+2];return Math.abs(a-h)<Math.abs(o-l)?[new at(o,1-c),new at(l,1-d),new at(f,1-_),new at(v,1-p)]:[new at(a,1-c),new at(h,1-d),new at(g,1-_),new at(m,1-p)]}};function ev(s,t,e){if(e.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){let r=s[n];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}u(ev,"toJSON$1");var Br=class Br extends Le{constructor(t=new yr(new P(-1,-1,0),new P(-1,1,0),new P(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};let o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new P,c=new P,l=new at,h=new P,d=[],f=[],g=[],_=[];v(),this.setIndex(_),this.setAttribute("position",new ce(d,3)),this.setAttribute("normal",new ce(f,3)),this.setAttribute("uv",new ce(g,2));function v(){for(let x=0;x<e;x++)m(x);m(r===!1?e:0),w(),p()}u(v,"generateBufferData");function m(x){h=t.getPointAt(x/e,h);let b=o.normals[x],L=o.binormals[x];for(let C=0;C<=i;C++){let R=C/i*Math.PI*2,D=Math.sin(R),X=-Math.cos(R);c.x=X*b.x+D*L.x,c.y=X*b.y+D*L.y,c.z=X*b.z+D*L.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=h.x+n*c.x,a.y=h.y+n*c.y,a.z=h.z+n*c.z,d.push(a.x,a.y,a.z)}}u(m,"generateSegment");function p(){for(let x=1;x<=e;x++)for(let b=1;b<=i;b++){let L=(i+1)*(x-1)+(b-1),C=(i+1)*x+(b-1),R=(i+1)*x+b,D=(i+1)*(x-1)+b;_.push(L,C,D),_.push(C,R,D)}}u(p,"generateIndices");function w(){for(let x=0;x<=e;x++)for(let b=0;b<=i;b++)l.x=x/e,l.y=b/i,g.push(l.x,l.y)}u(w,"generateUVs")}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Br(new Sr[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}};u(Br,"TubeGeometry");var ud=Br;var ml=class ml extends je{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Vt(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 Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bo,this.normalScale=new at(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 Je,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}};u(ml,"MeshStandardMaterial");var So=ml,gl=class gl extends So{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new at(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return pe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Vt(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 Vt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Vt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}};u(gl,"MeshPhysicalMaterial");var dd=gl;var _l=class _l extends je{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bo,this.normalScale=new at(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}};u(_l,"MeshLambertMaterial");var fd=_l;function Zs(s,t,e){return!s||!e&&s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}u(Zs,"convertArray");function nv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}u(nv,"isTypedArray");function iv(s){function t(i,r){return s[i]-s[r]}u(t,"compareTime");let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}u(iv,"getKeyframeOrder");function pd(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){let a=e[r]*t;for(let c=0;c!==t;++c)i[o++]=s[a+c]}return i}u(pd,"sortedArray");function af(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(t.push(r.time),e.push.apply(e,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(t.push(r.time),o.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(t.push(r.time),e.push(o)),r=s[i++];while(r!==void 0)}u(af,"flattenJSON");var xl=class xl{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=e[++n],t<i)break t}o=e.length;break e}if(!(t>=r)){let a=e[1];t<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(i=r,r=e[--n-1],t>=r)break t}o=n,n=0;break e}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let o=0;o!==i;++o)e[o]=n[r+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}};u(xl,"Interpolant");var Ni=xl,vl=class vl extends Ni{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Bh,endingEnd:Bh}}intervalChanged_(t,e,n){let i=this.parameterPositions,r=t-2,o=t+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case zh:r=t,a=2*e-n;break;case kh:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case zh:o=t,c=2*n-e;break;case kh:o=1,c=n+i[1]-i[0];break;default:o=t-1,c=e}let l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,h=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,g=this._weightNext,_=(n-e)/(i-e),v=_*_,m=v*_,p=-f*m+2*f*v-f*_,w=(1+f)*m+(-1.5-2*f)*v+(-.5+f)*_+1,x=(-1-g)*m+(1.5+g)*v+.5*_,b=g*m-g*v;for(let L=0;L!==a;++L)r[L]=p*o[h+L]+w*o[l+L]+x*o[c+L]+b*o[d+L];return r}};u(vl,"CubicInterpolant");var bo=vl,yl=class yl extends Ni{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,h=(n-e)/(i-e),d=1-h;for(let f=0;f!==a;++f)r[f]=o[l+f]*d+o[c+f]*h;return r}};u(yl,"LinearInterpolant");var Eo=yl,Ml=class Ml extends Ni{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}};u(Ml,"DiscreteInterpolant");var wo=Ml,Sl=class Sl{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Zs(e,this.TimeBufferType),this.values=Zs(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Zs(t.times,Array),values:Zs(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new wo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Eo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new bo(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case $s:e=this.InterpolantFactoryMethodDiscrete;break;case Ks:e=this.InterpolantFactoryMethodLinear;break;case ta:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return $s;case this.InterpolantFactoryMethodLinear:return Ks;case this.InterpolantFactoryMethodSmooth:return ta}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,r=0,o=i-1;for(;r!==i&&n[r]<t;)++r;for(;o!==-1&&n[o]>e;)--o;if(++o,r!==0||o!==i){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 t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),t=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),t=!1;break}o=c}if(i!==void 0&&nv(i))for(let a=0,c=i.length;a!==c;++a){let l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===ta,r=t.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=t[a],h=t[a+1];if(l!==h&&(a!==1||l!==t[0]))if(i)c=!0;else{let d=a*n,f=d-n,g=d+n;for(let _=0;_!==n;++_){let v=e[d+_];if(v!==e[f+_]||v!==e[g+_]){c=!0;break}}}if(c){if(a!==o){t[o]=t[a];let d=a*n,f=o*n;for(let g=0;g!==n;++g)e[f+g]=e[d+g]}++o}}if(r>0){t[o]=t[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)e[c+l]=e[a+l];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};u(Sl,"KeyframeTrack");var Ge=Sl;Ge.prototype.TimeBufferType=Float32Array;Ge.prototype.ValueBufferType=Float32Array;Ge.prototype.DefaultInterpolation=Ks;var bl=class bl extends Ge{};u(bl,"BooleanKeyframeTrack");var Ln=bl;Ln.prototype.ValueTypeName="bool";Ln.prototype.ValueBufferType=Array;Ln.prototype.DefaultInterpolation=$s;Ln.prototype.InterpolantFactoryMethodLinear=void 0;Ln.prototype.InterpolantFactoryMethodSmooth=void 0;var El=class El extends Ge{};u(El,"ColorKeyframeTrack");var Er=El;Er.prototype.ValueTypeName="color";var wl=class wl extends Ge{};u(wl,"NumberKeyframeTrack");var Oi=wl;Oi.prototype.ValueTypeName="number";var Al=class Al extends Ni{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-e)/(i-e),l=t*a;for(let h=l+a;l!==h;l+=4)In.slerpFlat(r,0,o,l-a,o,l,c);return r}};u(Al,"QuaternionLinearInterpolant");var Ao=Al,Tl=class Tl extends Ge{InterpolantFactoryMethodLinear(t){return new Ao(this.times,this.values,this.getValueSize(),t)}};u(Tl,"QuaternionKeyframeTrack");var jn=Tl;jn.prototype.ValueTypeName="quaternion";jn.prototype.DefaultInterpolation=Ks;jn.prototype.InterpolantFactoryMethodSmooth=void 0;var Rl=class Rl extends Ge{};u(Rl,"StringKeyframeTrack");var Un=Rl;Un.prototype.ValueTypeName="string";Un.prototype.ValueBufferType=Array;Un.prototype.DefaultInterpolation=$s;Un.prototype.InterpolantFactoryMethodLinear=void 0;Un.prototype.InterpolantFactoryMethodSmooth=void 0;var Cl=class Cl extends Ge{};u(Cl,"VectorKeyframeTrack");var Fi=Cl;Fi.prototype.ValueTypeName="vector";var Pl=class Pl{constructor(t,e=-1,n,i=ep){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Ve(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(rv(n[o]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,o=n.length;r!==o;++r)e.push(Ge.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.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=iv(c);c=pd(c,1,h),l=pd(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new Oi(".morphTargetInfluences["+e[a].name+"]",c,l).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=t.length;a<c;a++){let l=t[a],h=l.name.match(r);if(h&&h.length>1){let d=h[1],f=i[d];f||(i[d]=f=[]),f.push(l)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=u(function(d,f,g,_,v){if(g.length!==0){let m=[],p=[];af(g,m,p,_),m.length!==0&&v.push(new d(f,m,p))}},"addNonemptyTrack"),i=[],r=t.name||"default",o=t.fps||30,a=t.blendMode,c=t.length||-1,l=t.hierarchy||[];for(let d=0;d<l.length;d++){let f=l[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let g={},_;for(_=0;_<f.length;_++)if(f[_].morphTargets)for(let v=0;v<f[_].morphTargets.length;v++)g[f[_].morphTargets[v]]=-1;for(let v in g){let m=[],p=[];for(let w=0;w!==f[_].morphTargets.length;++w){let x=f[_];m.push(x.time),p.push(x.morphTarget===v?1:0)}i.push(new Oi(".morphTargetInfluence["+v+"]",m,p))}c=g.length*o}else{let g=".bones["+e[d].name+"]";n(Fi,g+".position",f,"pos",i),n(jn,g+".quaternion",f,"rot",i),n(Fi,g+".scale",f,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,i=t.length;n!==i;++n){let r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};u(Pl,"AnimationClip");var md=Pl;function sv(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Oi;case"vector":case"vector2":case"vector3":case"vector4":return Fi;case"color":return Er;case"quaternion":return jn;case"bool":case"boolean":return Ln;case"string":return Un}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}u(sv,"getTrackTypeForValueTypeName");function rv(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=sv(s.type);if(s.times===void 0){let e=[],n=[];af(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}u(rv,"parseKeyframeTrack");var wn={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(this.files[s]=t)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}},Il=class Il{constructor(t,e,n){let i=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){a++,r===!1&&i.onStart!==void 0&&i.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,f=l.length;d<f;d+=2){let g=l[d],_=l[d+1];if(g.global&&(g.lastIndex=0),g.test(h))return _}return null}}};u(Il,"LoadingManager");var To=Il,av=new To,Ll=class Ll{constructor(t){this.manager=t!==void 0?t:av,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};u(Ll,"Loader");var ti=Ll;ti.DEFAULT_MATERIAL_NAME="__DEFAULT";var cn={},Ul=class Ul extends Error{constructor(t,e){super(t),this.response=e}};u(Ul,"HttpError");var Ro=Ul,Dl=class Dl extends ti{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=wn.get(t);if(r!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(cn[t]!==void 0){cn[t].push({onLoad:e,onProgress:n,onError:i});return}cn[t]=[],cn[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=cn[t],d=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),g=f?parseInt(f):0,_=g!==0,v=0,m=new ReadableStream({start(p){w();function w(){d.read().then(({done:x,value:b})=>{if(x)p.close();else{v+=b.byteLength;let L=new ProgressEvent("progress",{lengthComputable:_,loaded:v,total:g});for(let C=0,R=h.length;C<R;C++){let D=h[C];D.onProgress&&D.onProgress(L)}p.enqueue(b),w()}})}u(w,"readData")}});return new Response(m)}else throw new Ro(`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===void 0)return l.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),f=d&&d[1]?d[1].toLowerCase():void 0,g=new TextDecoder(f);return l.arrayBuffer().then(_=>g.decode(_))}}}).then(l=>{wn.add(t,l);let h=cn[t];delete cn[t];for(let d=0,f=h.length;d<f;d++){let g=h[d];g.onLoad&&g.onLoad(l)}}).catch(l=>{let h=cn[t];if(h===void 0)throw this.manager.itemError(t),l;delete cn[t];for(let d=0,f=h.length;d<f;d++){let g=h[d];g.onError&&g.onError(l)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};u(Dl,"FileLoader");var gd=Dl;var Nl=class Nl extends ti{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=wn.get(t);if(o!==void 0)return r.manager.itemStart(t),setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0),o;let a=is("img");function c(){h(),wn.add(t,this),e&&e(this),r.manager.itemEnd(t)}u(c,"onImageLoad");function l(d){h(),i&&i(d),r.manager.itemError(t),r.manager.itemEnd(t)}u(l,"onImageError");function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return u(h,"removeEventListeners"),a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a}};u(Nl,"ImageLoader");var Co=Nl;var Ol=class Ol extends ti{constructor(t){super(t)}load(t,e,n,i){let r=new be,o=new Co(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){r.image=a,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}};u(Ol,"TextureLoader");var _d=Ol,Fl=class Fl extends le{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Vt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}};u(Fl,"Light");var Bi=Fl;var Da=new Ft,xd=new P,vd=new P,Bl=class Bl{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new at(512,512),this.map=null,this.mapPass=null,this.matrix=new Ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Di,this._frameExtents=new at(1,1),this._viewportCount=1,this._viewports=[new $t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;xd.setFromMatrixPosition(t.matrixWorld),e.position.copy(xd),vd.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(vd),e.updateMatrixWorld(),Da.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Da),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Da)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}};u(Bl,"LightShadow");var us=Bl,zl=class zl extends us{constructor(){super(new Te(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=Li*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}};u(zl,"SpotLightShadow");var Po=zl,kl=class kl extends Bi{constructor(t,e,n=0,i=Math.PI/3,r=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(le.DEFAULT_UP),this.updateMatrix(),this.target=new le,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new Po}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};u(kl,"SpotLight");var yd=kl,Md=new Ft,Ji=new P,Na=new P,Vl=class Vl extends us{constructor(){super(new Te(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new at(4,2),this._viewportCount=6,this._viewports=[new $t(2,1,1,1),new $t(0,1,1,1),new $t(3,1,1,1),new $t(1,1,1,1),new $t(3,0,1,1),new $t(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Ji.setFromMatrixPosition(t.matrixWorld),n.position.copy(Ji),Na.copy(n.position),Na.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Na),n.updateMatrixWorld(),i.makeTranslation(-Ji.x,-Ji.y,-Ji.z),Md.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Md)}};u(Vl,"PointLightShadow");var Io=Vl,Hl=class Hl extends Bi{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Io}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}};u(Hl,"PointLight");var Sd=Hl,Gl=class Gl extends us{constructor(){super(new dr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}};u(Gl,"DirectionalLightShadow");var Lo=Gl,Wl=class Wl extends Bi{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(le.DEFAULT_UP),this.updateMatrix(),this.target=new le,this.shadow=new Lo}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};u(Wl,"DirectionalLight");var bd=Wl,Xl=class Xl extends Bi{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}};u(Xl,"AmbientLight");var Ed=Xl;var ql=class ql{static decodeText(t){if(typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(t){let e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}};u(ql,"LoaderUtils");var wd=ql;var Yl=class Yl extends ti{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=wn.get(t);if(o!==void 0){if(r.manager.itemStart(t),o.then){o.then(l=>{e&&e(l),r.manager.itemEnd(t)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(t,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return wn.add(t,l),e&&e(l),r.manager.itemEnd(t),l}).catch(function(l){i&&i(l),wn.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)});wn.add(t,c),r.manager.itemStart(t)}};u(Yl,"ImageBitmapLoader");var Ad=Yl;var Zl=class Zl{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Rd(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=Rd();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};u(Zl,"Clock");var Td=Zl;function Rd(){return(typeof performance>"u"?Date:performance).now()}u(Rd,"now");var Go="\\[\\]\\.:\\/",ov=new RegExp("["+Go+"]","g"),Wo="[^"+Go+"]",cv="[^"+Go.replace("\\.","")+"]",lv=/((?:WC+[\/:])*)/.source.replace("WC",Wo),hv=/(WCOD+)?/.source.replace("WCOD",cv),uv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Wo),dv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Wo),fv=new RegExp("^"+lv+hv+uv+dv+"$"),pv=["material","materials","bones","map"],Jl=class Jl{constructor(t,e,n){let i=n||ne.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}};u(Jl,"Composite");var Uo=Jl,Sn=class Sn{constructor(t,e,n){this.path=e,this.parsedPath=n||Sn.parseTrackName(e),this.node=Sn.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Sn.Composite(t,e,n):new Sn(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ov,"")}static parseTrackName(t){let e=fv.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);pv.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=u(function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===e||a.uuid===e)return a;let c=n(a.children);if(c)return c}return null},"searchNodeSubtree"),i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=Sn.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let o=t[i];if(o===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=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=i;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}};u(Sn,"PropertyBinding");var ne=Sn;ne.Composite=Uo;ne.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ne.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ne.prototype.GetterByBindingType=[ne.prototype._getValue_direct,ne.prototype._getValue_array,ne.prototype._getValue_arrayElement,ne.prototype._getValue_toArray];ne.prototype.SetterByBindingTypeAndVersioning=[[ne.prototype._setValue_direct,ne.prototype._setValue_direct_setNeedsUpdate,ne.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ne.prototype._setValue_array,ne.prototype._setValue_array_setNeedsUpdate,ne.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ne.prototype._setValue_arrayElement,ne.prototype._setValue_arrayElement_setNeedsUpdate,ne.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ne.prototype._setValue_fromArray,ne.prototype._setValue_fromArray_setNeedsUpdate,ne.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Mv=new Float32Array(1);var zr=class zr{constructor(t){this.value=t}clone(){return new zr(this.value.clone===void 0?this.value:this.value.clone())}};u(zr,"Uniform");var Cd=zr;var Pd=new Ft,$l=class $l{constructor(t,e,n=0,i=1/0){this.ray=new Kn(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new ss,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Pd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Pd),this}intersectObject(t,e=!0,n=[]){return Do(t,this,n,e),n.sort(Ld),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Do(t[i],this,n,e);return n.sort(Ld),n}};u($l,"Raycaster");var Id=$l;function Ld(s,t){return s.distance-t.distance}u(Ld,"ascSort");function Do(s,t,e,n){if(s.layers.test(t.layers)&&s.raycast(t,e),n===!0){let i=s.children;for(let r=0,o=i.length;r<o;r++)Do(i[r],t,e,!0)}}u(Do,"intersect");var Ud=new at,Kl=class Kl{constructor(t=new at(1/0,1/0),e=new at(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Ud.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ud).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};u(Kl,"Box2");var Dd=Kl;typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:No}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=No);export{gv as a,Cn as b,un as c,ka as d,Ye as e,Va as f,ge as g,dh as h,Vi as i,Ce as j,Zr as k,Yn as l,ke as m,Oe as n,$s as o,Ks as p,_v as q,xv as r,vv as s,bn as t,Ke as u,Dn as v,yv as w,at as x,Jt as y,sr as z,be as A,$t as B,In as C,P as D,Ie as E,Re as F,Ft as G,Je as H,le as I,Vt as J,je as K,ar as L,Se as M,Le as N,Me as O,rs as P,tn as Q,lr as R,Te as S,Di as T,ur as U,dr as V,Mi as W,ao as X,oo as Y,Cu as Z,Pu as _,Iu as $,Fu as aa,co as ba,as as ca,zu as da,mr as ea,Hu as fa,Xu as ga,ho as ha,gr as ia,Ku as ja,Qu as ka,uo as la,td as ma,nd as na,id as oa,mo as pa,br as qa,rd as ra,ad as sa,vo as ta,hd as ua,ud as va,So as wa,dd as xa,fd as ya,Ni as za,Oi as Aa,jn as Ba,Fi as Ca,md as Da,ti as Ea,gd as Fa,_d as Ga,yd as Ha,Sd as Ia,bd as Ja,Ed as Ka,wd as La,Ad as Ma,Td as Na,ne as Oa,Cd as Pa,Id as Qa,Dd as Ra};