logseq-graph-living-atlas 0.1.0

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.
Files changed (41) hide show
  1. package/.env.example +29 -0
  2. package/CHANGELOG.md +38 -0
  3. package/CODE_OF_CONDUCT.md +33 -0
  4. package/CONTRIBUTING.md +116 -0
  5. package/GOVERNANCE.md +40 -0
  6. package/LICENSE +21 -0
  7. package/MAINTAINERS.md +34 -0
  8. package/README.md +370 -0
  9. package/ROADMAP.md +38 -0
  10. package/SECURITY.md +43 -0
  11. package/SUPPORT.md +31 -0
  12. package/dist/assets/AtlasCanvas-p-Pb_C3p.js +172 -0
  13. package/dist/assets/index-Cb0dgkF5.css +1 -0
  14. package/dist/assets/index-D-LUf-q7.js +12 -0
  15. package/dist/assets/three-DQCgX68K.js +3947 -0
  16. package/dist/index.html +13 -0
  17. package/docs/ADAPTERS.md +48 -0
  18. package/docs/API.md +145 -0
  19. package/docs/ARCHITECTURE.md +93 -0
  20. package/docs/CONCEPTS.md +62 -0
  21. package/docs/MCP.md +74 -0
  22. package/docs/RELEASE.md +65 -0
  23. package/docs/REPO_GUIDE.md +92 -0
  24. package/docs/TROUBLESHOOTING.md +138 -0
  25. package/docs/assets/living-atlas-demo.png +0 -0
  26. package/docs/assets/living-atlas-pathfinder.png +0 -0
  27. package/docs/assets/living-atlas-radar.png +0 -0
  28. package/docs/assets/living-atlas-source-detail.png +0 -0
  29. package/package.json +102 -0
  30. package/server/brain-service.mjs +201 -0
  31. package/server/contracts.mjs +346 -0
  32. package/server/fixture/create-fixture-graph.mjs +115 -0
  33. package/server/graph/pathfinding.mjs +155 -0
  34. package/server/graph/quality.mjs +11 -0
  35. package/server/graph/utils.mjs +25 -0
  36. package/server/graph-index.mjs +920 -0
  37. package/server/logseq/parser.mjs +121 -0
  38. package/server/logseq/source-adapter.mjs +147 -0
  39. package/server/redaction.mjs +89 -0
  40. package/server/service.mjs +777 -0
  41. package/server/source-adapter-contract.d.ts +46 -0
@@ -0,0 +1,3947 @@
1
+ const Sp={ROTATE:0,DOLLY:1,PAN:2},bp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Xo=0,na=1,qo=2,oo=1,Yo=2,Qt=3,gn=0,yt=1,en=2,rn=0,jn=1,ia=2,ra=3,sa=4,Ko=5,Cn=100,Zo=101,$o=102,jo=103,Jo=104,Qo=200,ec=201,tc=202,nc=203,Zr=204,$r=205,ic=206,rc=207,sc=208,ac=209,oc=210,cc=211,lc=212,uc=213,fc=214,jr=0,Jr=1,Qr=2,Qn=3,es=4,ts=5,ns=6,is=7,co=0,hc=1,dc=2,_n=0,pc=1,mc=2,xc=3,_c=4,gc=5,vc=6,Mc=7,lo=300,ei=301,ti=302,rs=303,ss=304,hr=306,as=1e3,tn=1001,os=1002,Ct=1003,Sc=1004,Di=1005,It=1006,gr=1007,Dn=1008,Xt=1009,uo=1010,fo=1011,vi=1012,Bs=1013,Ln=1014,nn=1015,ri=1016,zs=1017,Vs=1018,Mi=1020,ho=35902,po=35899,mo=1021,xo=1022,Vt=1023,Si=1026,bi=1027,_o=1028,Gs=1029,Hs=1030,ks=1031,Ws=1033,nr=33776,ir=33777,rr=33778,sr=33779,cs=35840,ls=35841,us=35842,fs=35843,hs=36196,ds=37492,ps=37496,ms=37808,xs=37809,_s=37810,gs=37811,vs=37812,Ms=37813,Ss=37814,bs=37815,Es=37816,ys=37817,Ts=37818,As=37819,Rs=37820,ws=37821,Cs=36492,Ps=36494,Ds=36495,Ls=36283,Us=36284,Is=36285,Ns=36286,bc=3200,Ec=3201,yc=0,Tc=1,mn="",Lt="srgb",ni="srgb-linear",or="linear",Ze="srgb",Fn=7680,aa=519,Ac=512,Rc=513,wc=514,go=515,Cc=516,Pc=517,Dc=518,Lc=519,oa=35044,ca="300 es",kt=2e3,cr=2001;function vo(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function lr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Uc(){const i=lr("canvas");return i.style.display="block",i}const la={};function ua(...i){const e="THREE."+i.shift();console.log(e,...i)}function Ce(...i){const e="THREE."+i.shift();console.warn(e,...i)}function lt(...i){const e="THREE."+i.shift();console.error(e,...i)}function Ei(...i){const e=i.join(" ");e in la||(la[e]=!0,Ce(...i))}function Ic(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}class In{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const mt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let fa=1234567;const _i=Math.PI/180,yi=180/Math.PI;function si(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(mt[i&255]+mt[i>>8&255]+mt[i>>16&255]+mt[i>>24&255]+"-"+mt[e&255]+mt[e>>8&255]+"-"+mt[e>>16&15|64]+mt[e>>24&255]+"-"+mt[t&63|128]+mt[t>>8&255]+"-"+mt[t>>16&255]+mt[t>>24&255]+mt[n&255]+mt[n>>8&255]+mt[n>>16&255]+mt[n>>24&255]).toLowerCase()}function Ne(i,e,t){return Math.max(e,Math.min(t,i))}function Xs(i,e){return(i%e+e)%e}function Nc(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Fc(i,e,t){return i!==e?(t-i)/(e-i):0}function gi(i,e,t){return(1-t)*i+t*e}function Oc(i,e,t,n){return gi(i,e,1-Math.exp(-t*n))}function Bc(i,e=1){return e-Math.abs(Xs(i,e*2)-e)}function zc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Vc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Gc(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Hc(i,e){return i+Math.random()*(e-i)}function kc(i){return i*(.5-Math.random())}function Wc(i){i!==void 0&&(fa=i);let e=fa+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Xc(i){return i*_i}function qc(i){return i*yi}function Yc(i){return(i&i-1)===0&&i!==0}function Kc(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Zc(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function $c(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),f=a((e+n)/2),h=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),g=a((n-e)/2);switch(r){case"XYX":i.set(o*f,l*h,l*d,o*c);break;case"YZY":i.set(l*d,o*f,l*h,o*c);break;case"ZXZ":i.set(l*h,l*d,o*f,o*c);break;case"XZX":i.set(o*f,l*g,l*p,o*c);break;case"YXY":i.set(l*p,o*f,l*g,o*c);break;case"ZYZ":i.set(l*g,l*p,o*f,o*c);break;default:Ce("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function $n(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function vt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Ep={DEG2RAD:_i,RAD2DEG:yi,generateUUID:si,clamp:Ne,euclideanModulo:Xs,mapLinear:Nc,inverseLerp:Fc,lerp:gi,damp:Oc,pingpong:Bc,smoothstep:zc,smootherstep:Vc,randInt:Gc,randFloat:Hc,randFloatSpread:kc,seededRandom:Wc,degToRad:Xc,radToDeg:qc,isPowerOfTwo:Yc,ceilPowerOfTwo:Kc,floorPowerOfTwo:Zc,setQuaternionFromProperEuler:$c,normalize:vt,denormalize:$n};class Xe{constructor(e=0,t=0){Xe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ne(this.x,e.x,t.x),this.y=Ne(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ne(this.x,e,t),this.y=Ne(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ne(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ne(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ti{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],f=n[r+2],h=n[r+3],d=s[a+0],p=s[a+1],g=s[a+2],v=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=f,e[t+3]=h;return}if(o>=1){e[t+0]=d,e[t+1]=p,e[t+2]=g,e[t+3]=v;return}if(h!==v||l!==d||c!==p||f!==g){let m=l*d+c*p+f*g+h*v;m<0&&(d=-d,p=-p,g=-g,v=-v,m=-m);let u=1-o;if(m<.9995){const T=Math.acos(m),E=Math.sin(T);u=Math.sin(u*T)/E,o=Math.sin(o*T)/E,l=l*u+d*o,c=c*u+p*o,f=f*u+g*o,h=h*u+v*o}else{l=l*u+d*o,c=c*u+p*o,f=f*u+g*o,h=h*u+v*o;const T=1/Math.sqrt(l*l+c*c+f*f+h*h);l*=T,c*=T,f*=T,h*=T}}e[t]=l,e[t+1]=c,e[t+2]=f,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],f=n[r+3],h=s[a],d=s[a+1],p=s[a+2],g=s[a+3];return e[t]=o*g+f*h+l*p-c*d,e[t+1]=l*g+f*d+c*h-o*p,e[t+2]=c*g+f*p+o*d-l*h,e[t+3]=f*g-o*h-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),f=o(r/2),h=o(s/2),d=l(n/2),p=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=d*f*h+c*p*g,this._y=c*p*h-d*f*g,this._z=c*f*g+d*p*h,this._w=c*f*h-d*p*g;break;case"YXZ":this._x=d*f*h+c*p*g,this._y=c*p*h-d*f*g,this._z=c*f*g-d*p*h,this._w=c*f*h+d*p*g;break;case"ZXY":this._x=d*f*h-c*p*g,this._y=c*p*h+d*f*g,this._z=c*f*g+d*p*h,this._w=c*f*h-d*p*g;break;case"ZYX":this._x=d*f*h-c*p*g,this._y=c*p*h+d*f*g,this._z=c*f*g-d*p*h,this._w=c*f*h+d*p*g;break;case"YZX":this._x=d*f*h+c*p*g,this._y=c*p*h+d*f*g,this._z=c*f*g-d*p*h,this._w=c*f*h-d*p*g;break;case"XZY":this._x=d*f*h-c*p*g,this._y=c*p*h-d*f*g,this._z=c*f*g+d*p*h,this._w=c*f*h+d*p*g;break;default:Ce("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],f=t[6],h=t[10],d=n+o+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(f-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(n>o&&n>h){const p=2*Math.sqrt(1+n-o-h);this._w=(f-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-n-h);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+f)/p}else{const p=2*Math.sqrt(1+h-n-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+f)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ne(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,f=t._w;return this._x=n*f+a*o+r*c-s*l,this._y=r*f+a*l+s*o-n*c,this._z=s*f+a*c+n*l-r*o,this._w=a*f-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),f=Math.sin(c);l=Math.sin(l*c)/f,t=Math.sin(t*c)/f,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,n=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ha.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ha.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),f=2*(o*t-s*r),h=2*(s*n-a*t);return this.x=t+l*c+a*h-o*f,this.y=n+l*f+o*c-s*h,this.z=r+l*h+s*f-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ne(this.x,e.x,t.x),this.y=Ne(this.y,e.y,t.y),this.z=Ne(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ne(this.x,e,t),this.y=Ne(this.y,e,t),this.z=Ne(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ne(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return vr.copy(this).projectOnVector(e),this.sub(vr)}reflect(e){return this.sub(vr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ne(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vr=new N,ha=new Ti;class Ue{constructor(e,t,n,r,s,a,o,l,c){Ue.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const f=this.elements;return f[0]=e,f[1]=r,f[2]=o,f[3]=t,f[4]=s,f[5]=l,f[6]=n,f[7]=a,f[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],f=n[4],h=n[7],d=n[2],p=n[5],g=n[8],v=r[0],m=r[3],u=r[6],T=r[1],E=r[4],w=r[7],D=r[2],y=r[5],P=r[8];return s[0]=a*v+o*T+l*D,s[3]=a*m+o*E+l*y,s[6]=a*u+o*w+l*P,s[1]=c*v+f*T+h*D,s[4]=c*m+f*E+h*y,s[7]=c*u+f*w+h*P,s[2]=d*v+p*T+g*D,s[5]=d*m+p*E+g*y,s[8]=d*u+p*w+g*P,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8];return t*a*f-t*o*c-n*s*f+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],h=f*a-o*c,d=o*l-f*s,p=c*s-a*l,g=t*h+n*d+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=h*v,e[1]=(r*c-f*n)*v,e[2]=(o*n-r*a)*v,e[3]=d*v,e[4]=(f*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Mr.makeScale(e,t)),this}rotate(e){return this.premultiply(Mr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Mr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Mr=new Ue,da=new Ue().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pa=new Ue().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jc(){const i={enabled:!0,workingColorSpace:ni,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ze&&(r.r=sn(r.r),r.g=sn(r.g),r.b=sn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ze&&(r.r=Jn(r.r),r.g=Jn(r.g),r.b=Jn(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===mn?or:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Ei("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Ei("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[ni]:{primaries:e,whitePoint:n,transfer:or,toXYZ:da,fromXYZ:pa,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Lt},outputColorSpaceConfig:{drawingBufferColorSpace:Lt}},[Lt]:{primaries:e,whitePoint:n,transfer:Ze,toXYZ:da,fromXYZ:pa,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Lt}}}),i}const ke=jc();function sn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Jn(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let On;class Jc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{On===void 0&&(On=lr("canvas")),On.width=e.width,On.height=e.height;const r=On.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=On}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=lr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=sn(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(sn(t[n]/255)*255):t[n]=sn(t[n]);return{data:t,width:e.width,height:e.height}}else return Ce("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Qc=0;class qs{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Qc++}),this.uuid=si(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Sr(r[a].image)):s.push(Sr(r[a]))}else s=Sr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Sr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Jc.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ce("Texture: Unable to serialize Texture."),{})}let el=0;const br=new N;class St extends In{constructor(e=St.DEFAULT_IMAGE,t=St.DEFAULT_MAPPING,n=tn,r=tn,s=It,a=Dn,o=Vt,l=Xt,c=St.DEFAULT_ANISOTROPY,f=mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:el++}),this.uuid=si(),this.name="",this.source=new qs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Xe(0,0),this.repeat=new Xe(1,1),this.center=new Xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ue,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(br).x}get height(){return this.source.getSize(br).y}get depth(){return this.source.getSize(br).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ce(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ce(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,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),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==lo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case as:e.x=e.x-Math.floor(e.x);break;case tn:e.x=e.x<0?0:1;break;case os:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case as:e.y=e.y-Math.floor(e.y);break;case tn:e.y=e.y<0?0:1;break;case os:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}St.DEFAULT_IMAGE=null;St.DEFAULT_MAPPING=lo;St.DEFAULT_ANISOTROPY=1;class $e{constructor(e=0,t=0,n=0,r=1){$e.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const l=e.elements,c=l[0],f=l[4],h=l[8],d=l[1],p=l[5],g=l[9],v=l[2],m=l[6],u=l[10];if(Math.abs(f-d)<.01&&Math.abs(h-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(f+d)<.1&&Math.abs(h+v)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,w=(p+1)/2,D=(u+1)/2,y=(f+d)/4,P=(h+v)/4,z=(g+m)/4;return E>w&&E>D?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=y/n,s=P/n):w>D?w<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),n=y/r,s=z/r):D<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(D),n=P/s,r=z/s),this.set(n,r,s,t),this}let T=Math.sqrt((m-g)*(m-g)+(h-v)*(h-v)+(d-f)*(d-f));return Math.abs(T)<.001&&(T=1),this.x=(m-g)/T,this.y=(h-v)/T,this.z=(d-f)/T,this.w=Math.acos((c+p+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ne(this.x,e.x,t.x),this.y=Ne(this.y,e.y,t.y),this.z=Ne(this.z,e.z,t.z),this.w=Ne(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ne(this.x,e,t),this.y=Ne(this.y,e,t),this.z=Ne(this.z,e,t),this.w=Ne(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ne(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tl extends In{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new $e(0,0,e,t),this.scissorTest=!1,this.viewport=new $e(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new St(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:It,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new qs(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Un extends tl{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Mo extends St{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class nl extends St{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ai{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ft.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ft.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ft.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ft):Ft.fromBufferAttribute(s,a),Ft.applyMatrix4(e.matrixWorld),this.expandByPoint(Ft);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Li.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Li.copy(n.boundingBox)),Li.applyMatrix4(e.matrixWorld),this.union(Li)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ft),Ft.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(li),Ui.subVectors(this.max,li),Bn.subVectors(e.a,li),zn.subVectors(e.b,li),Vn.subVectors(e.c,li),ln.subVectors(zn,Bn),un.subVectors(Vn,zn),bn.subVectors(Bn,Vn);let t=[0,-ln.z,ln.y,0,-un.z,un.y,0,-bn.z,bn.y,ln.z,0,-ln.x,un.z,0,-un.x,bn.z,0,-bn.x,-ln.y,ln.x,0,-un.y,un.x,0,-bn.y,bn.x,0];return!Er(t,Bn,zn,Vn,Ui)||(t=[1,0,0,0,1,0,0,0,1],!Er(t,Bn,zn,Vn,Ui))?!1:(Ii.crossVectors(ln,un),t=[Ii.x,Ii.y,Ii.z],Er(t,Bn,zn,Vn,Ui))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ft).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ft).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Yt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yt),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Yt=[new N,new N,new N,new N,new N,new N,new N,new N],Ft=new N,Li=new Ai,Bn=new N,zn=new N,Vn=new N,ln=new N,un=new N,bn=new N,li=new N,Ui=new N,Ii=new N,En=new N;function Er(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){En.fromArray(i,s);const o=r.x*Math.abs(En.x)+r.y*Math.abs(En.y)+r.z*Math.abs(En.z),l=e.dot(En),c=t.dot(En),f=n.dot(En);if(Math.max(-Math.max(l,c,f),Math.min(l,c,f))>o)return!1}return!0}const il=new Ai,ui=new N,yr=new N;class Ri{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):il.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ui.subVectors(e,this.center);const t=ui.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(ui,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(yr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ui.copy(e.center).add(yr)),this.expandByPoint(ui.copy(e.center).sub(yr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Kt=new N,Tr=new N,Ni=new N,fn=new N,Ar=new N,Fi=new N,Rr=new N;class Ys{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Kt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Kt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kt.copy(this.origin).addScaledVector(this.direction,t),Kt.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Tr.copy(e).add(t).multiplyScalar(.5),Ni.copy(t).sub(e).normalize(),fn.copy(this.origin).sub(Tr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Ni),o=fn.dot(this.direction),l=-fn.dot(Ni),c=fn.lengthSq(),f=Math.abs(1-a*a);let h,d,p,g;if(f>0)if(h=a*l-o,d=a*o-l,g=s*f,h>=0)if(d>=-g)if(d<=g){const v=1/f;h*=v,d*=v,p=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-a*s+o)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(a*s+o)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=a>0?-s:s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Tr).addScaledVector(Ni,d),p}intersectSphere(e,t){Kt.subVectors(e.center,this.origin);const n=Kt.dot(this.direction),r=Kt.dot(Kt)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,f=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),f>=0?(s=(e.min.y-d.y)*f,a=(e.max.y-d.y)*f):(s=(e.max.y-d.y)*f,a=(e.min.y-d.y)*f),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Kt)!==null}intersectTriangle(e,t,n,r,s){Ar.subVectors(t,e),Fi.subVectors(n,e),Rr.crossVectors(Ar,Fi);let a=this.direction.dot(Rr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fn.subVectors(this.origin,e);const l=o*this.direction.dot(Fi.crossVectors(fn,Fi));if(l<0)return null;const c=o*this.direction.dot(Ar.cross(fn));if(c<0||l+c>a)return null;const f=-o*fn.dot(Rr);return f<0?null:this.at(f/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class it{constructor(e,t,n,r,s,a,o,l,c,f,h,d,p,g,v,m){it.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,f,h,d,p,g,v,m)}set(e,t,n,r,s,a,o,l,c,f,h,d,p,g,v,m){const u=this.elements;return u[0]=e,u[4]=t,u[8]=n,u[12]=r,u[1]=s,u[5]=a,u[9]=o,u[13]=l,u[2]=c,u[6]=f,u[10]=h,u[14]=d,u[3]=p,u[7]=g,u[11]=v,u[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 it().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Gn.setFromMatrixColumn(e,0).length(),s=1/Gn.setFromMatrixColumn(e,1).length(),a=1/Gn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),f=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=a*f,p=a*h,g=o*f,v=o*h;t[0]=l*f,t[4]=-l*h,t[8]=c,t[1]=p+g*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=g+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*f,p=l*h,g=c*f,v=c*h;t[0]=d+v*o,t[4]=g*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*f,t[9]=-o,t[2]=p*o-g,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*f,p=l*h,g=c*f,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*f,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*f,p=a*h,g=o*f,v=o*h;t[0]=l*f,t[4]=g*c-p,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=p*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,g=o*l,v=o*c;t[0]=l*f,t[4]=v-d*h,t[8]=g*h+p,t[1]=h,t[5]=a*f,t[9]=-o*f,t[2]=-c*f,t[6]=p*h+g,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,p=a*c,g=o*l,v=o*c;t[0]=l*f,t[4]=-h,t[8]=c*f,t[1]=d*h+v,t[5]=a*f,t[9]=p*h-g,t[2]=g*h-p,t[6]=o*f,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(rl,e,sl)}lookAt(e,t,n){const r=this.elements;return Rt.subVectors(e,t),Rt.lengthSq()===0&&(Rt.z=1),Rt.normalize(),hn.crossVectors(n,Rt),hn.lengthSq()===0&&(Math.abs(n.z)===1?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),hn.crossVectors(n,Rt)),hn.normalize(),Oi.crossVectors(Rt,hn),r[0]=hn.x,r[4]=Oi.x,r[8]=Rt.x,r[1]=hn.y,r[5]=Oi.y,r[9]=Rt.y,r[2]=hn.z,r[6]=Oi.z,r[10]=Rt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],f=n[1],h=n[5],d=n[9],p=n[13],g=n[2],v=n[6],m=n[10],u=n[14],T=n[3],E=n[7],w=n[11],D=n[15],y=r[0],P=r[4],z=r[8],S=r[12],M=r[1],C=r[5],B=r[9],G=r[13],k=r[2],K=r[6],q=r[10],ne=r[14],H=r[3],te=r[7],se=r[11],Se=r[15];return s[0]=a*y+o*M+l*k+c*H,s[4]=a*P+o*C+l*K+c*te,s[8]=a*z+o*B+l*q+c*se,s[12]=a*S+o*G+l*ne+c*Se,s[1]=f*y+h*M+d*k+p*H,s[5]=f*P+h*C+d*K+p*te,s[9]=f*z+h*B+d*q+p*se,s[13]=f*S+h*G+d*ne+p*Se,s[2]=g*y+v*M+m*k+u*H,s[6]=g*P+v*C+m*K+u*te,s[10]=g*z+v*B+m*q+u*se,s[14]=g*S+v*G+m*ne+u*Se,s[3]=T*y+E*M+w*k+D*H,s[7]=T*P+E*C+w*K+D*te,s[11]=T*z+E*B+w*q+D*se,s[15]=T*S+E*G+w*ne+D*Se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],f=e[2],h=e[6],d=e[10],p=e[14],g=e[3],v=e[7],m=e[11],u=e[15];return g*(+s*l*h-r*c*h-s*o*d+n*c*d+r*o*p-n*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*f-s*l*f)+m*(+t*c*h-t*o*p-s*a*h+n*a*p+s*o*f-n*c*f)+u*(-r*o*f-t*l*h+t*o*d+r*a*h-n*a*d+n*l*f)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],u=e[15],T=h*m*c-v*d*c+v*l*p-o*m*p-h*l*u+o*d*u,E=g*d*c-f*m*c-g*l*p+a*m*p+f*l*u-a*d*u,w=f*v*c-g*h*c+g*o*p-a*v*p-f*o*u+a*h*u,D=g*h*l-f*v*l-g*o*d+a*v*d+f*o*m-a*h*m,y=t*T+n*E+r*w+s*D;if(y===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/y;return e[0]=T*P,e[1]=(v*d*s-h*m*s-v*r*p+n*m*p+h*r*u-n*d*u)*P,e[2]=(o*m*s-v*l*s+v*r*c-n*m*c-o*r*u+n*l*u)*P,e[3]=(h*l*s-o*d*s-h*r*c+n*d*c+o*r*p-n*l*p)*P,e[4]=E*P,e[5]=(f*m*s-g*d*s+g*r*p-t*m*p-f*r*u+t*d*u)*P,e[6]=(g*l*s-a*m*s-g*r*c+t*m*c+a*r*u-t*l*u)*P,e[7]=(a*d*s-f*l*s+f*r*c-t*d*c-a*r*p+t*l*p)*P,e[8]=w*P,e[9]=(g*h*s-f*v*s-g*n*p+t*v*p+f*n*u-t*h*u)*P,e[10]=(a*v*s-g*o*s+g*n*c-t*v*c-a*n*u+t*o*u)*P,e[11]=(f*o*s-a*h*s-f*n*c+t*h*c+a*n*p-t*o*p)*P,e[12]=D*P,e[13]=(f*v*r-g*h*r+g*n*d-t*v*d-f*n*m+t*h*m)*P,e[14]=(g*o*r-a*v*r-g*n*l+t*v*l+a*n*m-t*o*m)*P,e[15]=(a*h*r-f*o*r+f*n*l-t*h*l-a*n*d+t*o*d)*P,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,f=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,f*o+n,f*l-r*a,0,c*l-r*o,f*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,f=a+a,h=o+o,d=s*c,p=s*f,g=s*h,v=a*f,m=a*h,u=o*h,T=l*c,E=l*f,w=l*h,D=n.x,y=n.y,P=n.z;return r[0]=(1-(v+u))*D,r[1]=(p+w)*D,r[2]=(g-E)*D,r[3]=0,r[4]=(p-w)*y,r[5]=(1-(d+u))*y,r[6]=(m+T)*y,r[7]=0,r[8]=(g+E)*P,r[9]=(m-T)*P,r[10]=(1-(d+v))*P,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=Gn.set(r[0],r[1],r[2]).length();const a=Gn.set(r[4],r[5],r[6]).length(),o=Gn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Ot.copy(this);const c=1/s,f=1/a,h=1/o;return Ot.elements[0]*=c,Ot.elements[1]*=c,Ot.elements[2]*=c,Ot.elements[4]*=f,Ot.elements[5]*=f,Ot.elements[6]*=f,Ot.elements[8]*=h,Ot.elements[9]*=h,Ot.elements[10]*=h,t.setFromRotationMatrix(Ot),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=kt,l=!1){const c=this.elements,f=2*s/(t-e),h=2*s/(n-r),d=(t+e)/(t-e),p=(n+r)/(n-r);let g,v;if(l)g=s/(a-s),v=a*s/(a-s);else if(o===kt)g=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===cr)g=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=f,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=kt,l=!1){const c=this.elements,f=2/(t-e),h=2/(n-r),d=-(t+e)/(t-e),p=-(n+r)/(n-r);let g,v;if(l)g=1/(a-s),v=a/(a-s);else if(o===kt)g=-2/(a-s),v=-(a+s)/(a-s);else if(o===cr)g=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=f,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Gn=new N,Ot=new it,rl=new N(0,0,0),sl=new N(1,1,1),hn=new N,Oi=new N,Rt=new N,ma=new it,xa=new Ti;class on{constructor(e=0,t=0,n=0,r=on.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],f=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Ne(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ne(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ne(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ne(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Ne(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-f,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ne(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-f,p),this._y=0);break;default:Ce("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ma.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ma,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xa.setFromEuler(this),this.setFromQuaternion(xa,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}on.DEFAULT_ORDER="XYZ";class So{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let al=0;const _a=new N,Hn=new Ti,Zt=new it,Bi=new N,fi=new N,ol=new N,cl=new Ti,ga=new N(1,0,0),va=new N(0,1,0),Ma=new N(0,0,1),Sa={type:"added"},ll={type:"removed"},kn={type:"childadded",child:null},wr={type:"childremoved",child:null};class _t extends In{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:al++}),this.uuid=si(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new N,t=new on,n=new Ti,r=new N(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new it},normalMatrix:{value:new Ue}}),this.matrix=new it,this.matrixWorld=new it,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new So,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Hn.setFromAxisAngle(e,t),this.quaternion.multiply(Hn),this}rotateOnWorldAxis(e,t){return Hn.setFromAxisAngle(e,t),this.quaternion.premultiply(Hn),this}rotateX(e){return this.rotateOnAxis(ga,e)}rotateY(e){return this.rotateOnAxis(va,e)}rotateZ(e){return this.rotateOnAxis(Ma,e)}translateOnAxis(e,t){return _a.copy(e).applyQuaternion(this.quaternion),this.position.add(_a.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ga,e)}translateY(e){return this.translateOnAxis(va,e)}translateZ(e){return this.translateOnAxis(Ma,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Bi.copy(e):Bi.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),fi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zt.lookAt(fi,Bi,this.up):Zt.lookAt(Bi,fi,this.up),this.quaternion.setFromRotationMatrix(Zt),r&&(Zt.extractRotation(r.matrixWorld),Hn.setFromRotationMatrix(Zt),this.quaternion.premultiply(Hn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(lt("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Sa),kn.child=e,this.dispatchEvent(kn),kn.child=null):lt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ll),wr.child=e,this.dispatchEvent(wr),wr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Zt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Sa),kn.child=e,this.dispatchEvent(kn),kn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fi,e,ol),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fi,cl,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,f=l.length;c<f;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),f=a(e.images),h=a(e.shapes),d=a(e.skeletons),p=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),f.length>0&&(n.images=f),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=r,n;function a(o){const l=[];for(const c in o){const f=o[c];delete f.metadata,l.push(f)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}_t.DEFAULT_UP=new N(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Bt=new N,$t=new N,Cr=new N,jt=new N,Wn=new N,Xn=new N,ba=new N,Pr=new N,Dr=new N,Lr=new N,Ur=new $e,Ir=new $e,Nr=new $e;class zt{constructor(e=new N,t=new N,n=new N){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Bt.subVectors(e,t),r.cross(Bt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Bt.subVectors(r,t),$t.subVectors(n,t),Cr.subVectors(e,t);const a=Bt.dot(Bt),o=Bt.dot($t),l=Bt.dot(Cr),c=$t.dot($t),f=$t.dot(Cr),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-o*f)*d,g=(a*f-o*l)*d;return s.set(1-p-g,g,p)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,jt)===null?!1:jt.x>=0&&jt.y>=0&&jt.x+jt.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,jt)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,jt.x),l.addScaledVector(a,jt.y),l.addScaledVector(o,jt.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return Ur.setScalar(0),Ir.setScalar(0),Nr.setScalar(0),Ur.fromBufferAttribute(e,t),Ir.fromBufferAttribute(e,n),Nr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Ur,s.x),a.addScaledVector(Ir,s.y),a.addScaledVector(Nr,s.z),a}static isFrontFacing(e,t,n,r){return Bt.subVectors(n,t),$t.subVectors(e,t),Bt.cross($t).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Bt.subVectors(this.c,this.b),$t.subVectors(this.a,this.b),Bt.cross($t).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return zt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return zt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Wn.subVectors(r,n),Xn.subVectors(s,n),Pr.subVectors(e,n);const l=Wn.dot(Pr),c=Xn.dot(Pr);if(l<=0&&c<=0)return t.copy(n);Dr.subVectors(e,r);const f=Wn.dot(Dr),h=Xn.dot(Dr);if(f>=0&&h<=f)return t.copy(r);const d=l*h-f*c;if(d<=0&&l>=0&&f<=0)return a=l/(l-f),t.copy(n).addScaledVector(Wn,a);Lr.subVectors(e,s);const p=Wn.dot(Lr),g=Xn.dot(Lr);if(g>=0&&p<=g)return t.copy(s);const v=p*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(Xn,o);const m=f*g-p*h;if(m<=0&&h-f>=0&&p-g>=0)return ba.subVectors(s,r),o=(h-f)/(h-f+(p-g)),t.copy(r).addScaledVector(ba,o);const u=1/(m+v+d);return a=v*u,o=d*u,t.copy(n).addScaledVector(Wn,a).addScaledVector(Xn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const bo={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},dn={h:0,s:0,l:0},zi={h:0,s:0,l:0};function Fr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class We{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,ke.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ke.workingColorSpace){if(e=Xs(e,1),t=Ne(t,0,1),n=Ne(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Fr(a,s,e+1/3),this.g=Fr(a,s,e),this.b=Fr(a,s,e-1/3)}return ke.colorSpaceToWorking(this,r),this}setStyle(e,t=Lt){function n(s){s!==void 0&&parseFloat(s)<1&&Ce("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ce("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Ce("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Lt){const n=bo[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ce("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=sn(e.r),this.g=sn(e.g),this.b=sn(e.b),this}copyLinearToSRGB(e){return this.r=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Lt){return ke.workingToColorSpace(xt.copy(this),e),Math.round(Ne(xt.r*255,0,255))*65536+Math.round(Ne(xt.g*255,0,255))*256+Math.round(Ne(xt.b*255,0,255))}getHexString(e=Lt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ke.workingColorSpace){ke.workingToColorSpace(xt.copy(this),t);const n=xt.r,r=xt.g,s=xt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const f=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=f<=.5?h/(a+o):h/(2-a-o),a){case n:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-n)/h+2;break;case s:l=(n-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=f,e}getRGB(e,t=ke.workingColorSpace){return ke.workingToColorSpace(xt.copy(this),t),e.r=xt.r,e.g=xt.g,e.b=xt.b,e}getStyle(e=Lt){ke.workingToColorSpace(xt.copy(this),e);const t=xt.r,n=xt.g,r=xt.b;return e!==Lt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(dn),this.setHSL(dn.h+e,dn.s+t,dn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(dn),e.getHSL(zi);const n=gi(dn.h,zi.h,t),r=gi(dn.s,zi.s,t),s=gi(dn.l,zi.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xt=new We;We.NAMES=bo;let ul=0;class ai extends In{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ul++}),this.uuid=si(),this.name="",this.type="Material",this.blending=jn,this.side=gn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Zr,this.blendDst=$r,this.blendEquation=Cn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=Qn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=aa,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Fn,this.stencilZFail=Fn,this.stencilZPass=Fn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ce(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ce(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&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!==jn&&(n.blending=this.blending),this.side!==gn&&(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!==Zr&&(n.blendSrc=this.blendSrc),this.blendDst!==$r&&(n.blendDst=this.blendDst),this.blendEquation!==Cn&&(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!==Qn&&(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!==aa&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Fn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Fn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Fn&&(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 r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Eo extends ai{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 on,this.combine=co,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ut=new N,Vi=new Xe;let fl=0;class Wt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:fl++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=oa,this.updateRanges=[],this.gpuType=nn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Vi.fromBufferAttribute(this,t),Vi.applyMatrix3(e),this.setXY(t,Vi.x,Vi.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix3(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix4(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyNormalMatrix(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.transformDirection(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=$n(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=vt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$n(t,this.array)),t}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$n(t,this.array)),t}setY(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=$n(t,this.array)),t}setZ(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=$n(t,this.array)),t}setW(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),n=vt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),n=vt(n,this.array),r=vt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),n=vt(n,this.array),r=vt(r,this.array),s=vt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==oa&&(e.usage=this.usage),e}}class yo extends Wt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class To extends Wt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class an extends Wt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let hl=0;const Dt=new it,Or=new _t,qn=new N,wt=new Ai,hi=new Ai,dt=new N;class qt extends In{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:hl++}),this.uuid=si(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(vo(e)?To:yo)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ue().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Dt.makeRotationFromQuaternion(e),this.applyMatrix4(Dt),this}rotateX(e){return Dt.makeRotationX(e),this.applyMatrix4(Dt),this}rotateY(e){return Dt.makeRotationY(e),this.applyMatrix4(Dt),this}rotateZ(e){return Dt.makeRotationZ(e),this.applyMatrix4(Dt),this}translate(e,t,n){return Dt.makeTranslation(e,t,n),this.applyMatrix4(Dt),this}scale(e,t,n){return Dt.makeScale(e,t,n),this.applyMatrix4(Dt),this}lookAt(e){return Or.lookAt(e),Or.updateMatrix(),this.applyMatrix4(Or.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qn).negate(),this.translate(qn.x,qn.y,qn.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new an(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Ce("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){lt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];wt.setFromBufferAttribute(s),this.morphTargetsRelative?(dt.addVectors(this.boundingBox.min,wt.min),this.boundingBox.expandByPoint(dt),dt.addVectors(this.boundingBox.max,wt.max),this.boundingBox.expandByPoint(dt)):(this.boundingBox.expandByPoint(wt.min),this.boundingBox.expandByPoint(wt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&lt('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 Ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){lt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const n=this.boundingSphere.center;if(wt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];hi.setFromBufferAttribute(o),this.morphTargetsRelative?(dt.addVectors(wt.min,hi.min),wt.expandByPoint(dt),dt.addVectors(wt.max,hi.max),wt.expandByPoint(dt)):(wt.expandByPoint(hi.min),wt.expandByPoint(hi.max))}wt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)dt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(dt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,f=o.count;c<f;c++)dt.fromBufferAttribute(o,c),l&&(qn.fromBufferAttribute(e,c),dt.add(qn)),r=Math.max(r,n.distanceToSquared(dt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&lt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){lt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Wt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let z=0;z<n.count;z++)o[z]=new N,l[z]=new N;const c=new N,f=new N,h=new N,d=new Xe,p=new Xe,g=new Xe,v=new N,m=new N;function u(z,S,M){c.fromBufferAttribute(n,z),f.fromBufferAttribute(n,S),h.fromBufferAttribute(n,M),d.fromBufferAttribute(s,z),p.fromBufferAttribute(s,S),g.fromBufferAttribute(s,M),f.sub(c),h.sub(c),p.sub(d),g.sub(d);const C=1/(p.x*g.y-g.x*p.y);isFinite(C)&&(v.copy(f).multiplyScalar(g.y).addScaledVector(h,-p.y).multiplyScalar(C),m.copy(h).multiplyScalar(p.x).addScaledVector(f,-g.x).multiplyScalar(C),o[z].add(v),o[S].add(v),o[M].add(v),l[z].add(m),l[S].add(m),l[M].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let z=0,S=T.length;z<S;++z){const M=T[z],C=M.start,B=M.count;for(let G=C,k=C+B;G<k;G+=3)u(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const E=new N,w=new N,D=new N,y=new N;function P(z){D.fromBufferAttribute(r,z),y.copy(D);const S=o[z];E.copy(S),E.sub(D.multiplyScalar(D.dot(S))).normalize(),w.crossVectors(y,S);const C=w.dot(l[z])<0?-1:1;a.setXYZW(z,E.x,E.y,E.z,C)}for(let z=0,S=T.length;z<S;++z){const M=T[z],C=M.start,B=M.count;for(let G=C,k=C+B;G<k;G+=3)P(e.getX(G+0)),P(e.getX(G+1)),P(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Wt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,f=new N,h=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const g=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),f.subVectors(a,s),h.subVectors(r,s),f.cross(h),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,m),o.add(f),l.add(f),c.add(f),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),f.subVectors(a,s),h.subVectors(r,s),f.cross(h),n.setXYZ(d+0,f.x,f.y,f.z),n.setXYZ(d+1,f.x,f.y,f.z),n.setXYZ(d+2,f.x,f.y,f.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)dt.fromBufferAttribute(e,t),dt.normalize(),e.setXYZ(t,dt.x,dt.y,dt.z)}toNonIndexed(){function e(o,l){const c=o.array,f=o.itemSize,h=o.normalized,d=new c.constructor(l.length*f);let p=0,g=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*f;for(let u=0;u<f;u++)d[g++]=c[p++]}return new Wt(d,f,h)}if(this.index===null)return Ce("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new qt,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let f=0,h=c.length;f<h;f++){const d=c[f],p=e(d,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],f=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];f.push(p.toJSON(e.data))}f.length>0&&(r[l]=f,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const c in r){const f=r[c];this.setAttribute(c,f.clone(t))}const s=e.morphAttributes;for(const c in s){const f=[],h=s[c];for(let d=0,p=h.length;d<p;d++)f.push(h[d].clone(t));this.morphAttributes[c]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,f=a.length;c<f;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ea=new it,yn=new Ys,Gi=new Ri,ya=new N,Hi=new N,ki=new N,Wi=new N,Br=new N,Xi=new N,Ta=new N,qi=new N;class vn extends _t{constructor(e=new qt,t=new Eo){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Xi.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const f=o[l],h=s[l];f!==0&&(Br.fromBufferAttribute(h,e),a?Xi.addScaledVector(Br,f):Xi.addScaledVector(Br.sub(t),f))}t.add(Xi)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Gi.copy(n.boundingSphere),Gi.applyMatrix4(s),yn.copy(e.ray).recast(e.near),!(Gi.containsPoint(yn.origin)===!1&&(yn.intersectSphere(Gi,ya)===null||yn.origin.distanceToSquared(ya)>(e.far-e.near)**2))&&(Ea.copy(s).invert(),yn.copy(e.ray).applyMatrix4(Ea),!(n.boundingBox!==null&&yn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,yn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,f=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const m=d[g],u=a[m.materialIndex],T=Math.max(m.start,p.start),E=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let w=T,D=E;w<D;w+=3){const y=o.getX(w),P=o.getX(w+1),z=o.getX(w+2);r=Yi(this,u,e,n,c,f,h,y,P,z),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let m=g,u=v;m<u;m+=3){const T=o.getX(m),E=o.getX(m+1),w=o.getX(m+2);r=Yi(this,a,e,n,c,f,h,T,E,w),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const m=d[g],u=a[m.materialIndex],T=Math.max(m.start,p.start),E=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let w=T,D=E;w<D;w+=3){const y=w,P=w+1,z=w+2;r=Yi(this,u,e,n,c,f,h,y,P,z),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let m=g,u=v;m<u;m+=3){const T=m,E=m+1,w=m+2;r=Yi(this,a,e,n,c,f,h,T,E,w),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function dl(i,e,t,n,r,s,a,o){let l;if(e.side===yt?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===gn,o),l===null)return null;qi.copy(o),qi.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(qi);return c<t.near||c>t.far?null:{distance:c,point:qi.clone(),object:i}}function Yi(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,Hi),i.getVertexPosition(l,ki),i.getVertexPosition(c,Wi);const f=dl(i,e,t,n,Hi,ki,Wi,Ta);if(f){const h=new N;zt.getBarycoord(Ta,Hi,ki,Wi,h),r&&(f.uv=zt.getInterpolatedAttribute(r,o,l,c,h,new Xe)),s&&(f.uv1=zt.getInterpolatedAttribute(s,o,l,c,h,new Xe)),a&&(f.normal=zt.getInterpolatedAttribute(a,o,l,c,h,new N),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};zt.getNormal(Hi,ki,Wi,d.normal),f.face=d,f.barycoord=h}return f}class wi extends qt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],f=[],h=[];let d=0,p=0;g("z","y","x",-1,-1,n,t,e,a,s,0),g("z","y","x",1,-1,n,t,-e,a,s,1),g("x","z","y",1,1,e,n,t,r,a,2),g("x","z","y",1,-1,e,n,-t,r,a,3),g("x","y","z",1,-1,e,t,n,r,s,4),g("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new an(c,3)),this.setAttribute("normal",new an(f,3)),this.setAttribute("uv",new an(h,2));function g(v,m,u,T,E,w,D,y,P,z,S){const M=w/P,C=D/z,B=w/2,G=D/2,k=y/2,K=P+1,q=z+1;let ne=0,H=0;const te=new N;for(let se=0;se<q;se++){const Se=se*C-G;for(let Ge=0;Ge<K;Ge++){const qe=Ge*M-B;te[v]=qe*T,te[m]=Se*E,te[u]=k,c.push(te.x,te.y,te.z),te[v]=0,te[m]=0,te[u]=y>0?1:-1,f.push(te.x,te.y,te.z),h.push(Ge/P),h.push(1-se/z),ne+=1}}for(let se=0;se<z;se++)for(let Se=0;Se<P;Se++){const Ge=d+Se+K*se,qe=d+Se+K*(se+1),Je=d+(Se+1)+K*(se+1),Qe=d+(Se+1)+K*se;l.push(Ge,qe,Qe),l.push(qe,Je,Qe),H+=6}o.addGroup(p,H,S),p+=H,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ii(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ce("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Mt(i){const e={};for(let t=0;t<i.length;t++){const n=ii(i[t]);for(const r in n)e[r]=n[r]}return e}function pl(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Ao(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ke.workingColorSpace}const ml={clone:ii,merge:Mt};var xl=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,_l=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`;class cn extends ai{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xl,this.fragmentShader=_l,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ii(e.uniforms),this.uniformsGroups=pl(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ro extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new it,this.projectionMatrix=new it,this.projectionMatrixInverse=new it,this.coordinateSystem=kt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const pn=new N,Aa=new Xe,Ra=new Xe;class Ut extends Ro{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=yi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(_i*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return yi*2*Math.atan(Math.tan(_i*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){pn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(pn.x,pn.y).multiplyScalar(-e/pn.z),pn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(pn.x,pn.y).multiplyScalar(-e/pn.z)}getViewSize(e,t){return this.getViewBounds(e,Aa,Ra),t.subVectors(Ra,Aa)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(_i*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Yn=-90,Kn=1;class gl extends _t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ut(Yn,Kn,e,t);r.layers=this.layers,this.add(r);const s=new Ut(Yn,Kn,e,t);s.layers=this.layers,this.add(s);const a=new Ut(Yn,Kn,e,t);a.layers=this.layers,this.add(a);const o=new Ut(Yn,Kn,e,t);o.layers=this.layers,this.add(o);const l=new Ut(Yn,Kn,e,t);l.layers=this.layers,this.add(l);const c=new Ut(Yn,Kn,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===kt)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===cr)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,f]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,r),e.render(t,f),e.setRenderTarget(h,d,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class wo extends St{constructor(e=[],t=ei,n,r,s,a,o,l,c,f){super(e,t,n,r,s,a,o,l,c,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class vl extends Un{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new wo(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const 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
+ `},r=new wi(5,5,5),s=new cn({name:"CubemapFromEquirect",uniforms:ii(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:yt,blending:rn});s.uniforms.tEquirect.value=t;const a=new vn(r,s),o=t.minFilter;return t.minFilter===Dn&&(t.minFilter=It),new gl(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Ki extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ml={type:"move"};class zr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ki,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 Ki,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ki,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),u=this._getHandJoint(c,v);m!==null&&(u.matrix.fromArray(m.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=m.radius),u.visible=m!==null}const f=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=f.position.distanceTo(h.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ml)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ki;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Co{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new We(e),this.density=t}clone(){return new Co(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class yp extends _t{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 on,this.environmentIntensity=1,this.environmentRotation=new on,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sl extends St{constructor(e=null,t=1,n=1,r,s,a,o,l,c=Ct,f=Ct,h,d){super(null,a,o,l,c,f,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Vr=new N,bl=new N,El=new Ue;class wn{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Vr.subVectors(n,t).cross(bl.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Vr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||El.getNormalMatrix(e),r=this.coplanarPoint(Vr).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Tn=new Ri,yl=new Xe(.5,.5),Zi=new N;class Ks{constructor(e=new wn,t=new wn,n=new wn,r=new wn,s=new wn,a=new wn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=kt,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],f=s[4],h=s[5],d=s[6],p=s[7],g=s[8],v=s[9],m=s[10],u=s[11],T=s[12],E=s[13],w=s[14],D=s[15];if(r[0].setComponents(c-a,p-f,u-g,D-T).normalize(),r[1].setComponents(c+a,p+f,u+g,D+T).normalize(),r[2].setComponents(c+o,p+h,u+v,D+E).normalize(),r[3].setComponents(c-o,p-h,u-v,D-E).normalize(),n)r[4].setComponents(l,d,m,w).normalize(),r[5].setComponents(c-l,p-d,u-m,D-w).normalize();else if(r[4].setComponents(c-l,p-d,u-m,D-w).normalize(),t===kt)r[5].setComponents(c+l,p+d,u+m,D+w).normalize();else if(t===cr)r[5].setComponents(l,d,m,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Tn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Tn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Tn)}intersectsSprite(e){Tn.center.set(0,0,0);const t=yl.distanceTo(e.center);return Tn.radius=.7071067811865476+t,Tn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Tn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Zi.x=r.normal.x>0?e.max.x:e.min.x,Zi.y=r.normal.y>0?e.max.y:e.min.y,Zi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Zi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Tl extends ai{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const ur=new N,fr=new N,wa=new it,di=new Ys,$i=new Ri,Gr=new N,Ca=new N;class Al extends _t{constructor(e=new qt,t=new Tl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)ur.fromBufferAttribute(t,r-1),fr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=ur.distanceTo(fr);e.setAttribute("lineDistance",new an(n,1))}else Ce("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),$i.copy(n.boundingSphere),$i.applyMatrix4(r),$i.radius+=s,e.ray.intersectsSphere($i)===!1)return;wa.copy(r).invert(),di.copy(e.ray).applyMatrix4(wa);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,f=n.index,d=n.attributes.position;if(f!==null){const p=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let v=p,m=g-1;v<m;v+=c){const u=f.getX(v),T=f.getX(v+1),E=ji(this,e,di,l,u,T,v);E&&t.push(E)}if(this.isLineLoop){const v=f.getX(g-1),m=f.getX(p),u=ji(this,e,di,l,v,m,g-1);u&&t.push(u)}}else{const p=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let v=p,m=g-1;v<m;v+=c){const u=ji(this,e,di,l,v,v+1,v);u&&t.push(u)}if(this.isLineLoop){const v=ji(this,e,di,l,g-1,p,g-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function ji(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(ur.fromBufferAttribute(o,r),fr.fromBufferAttribute(o,s),t.distanceSqToSegment(ur,fr,Gr,Ca)>n)return;Gr.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Gr);if(!(c<e.near||c>e.far))return{distance:c,point:Ca.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Pa=new N,Da=new N;class Tp extends Al{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)Pa.fromBufferAttribute(t,r),Da.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Pa.distanceTo(Da);e.setAttribute("lineDistance",new an(n,1))}else Ce("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Rl extends ai{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new We(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const La=new it,Fs=new Ys,Ji=new Ri,Qi=new N;class Ap extends _t{constructor(e=new qt,t=new Rl){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ji.copy(n.boundingSphere),Ji.applyMatrix4(r),Ji.radius+=s,e.ray.intersectsSphere(Ji)===!1)return;La.copy(r).invert(),Fs.copy(e.ray).applyMatrix4(La);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let g=d,v=p;g<v;g++){const m=c.getX(g);Qi.fromBufferAttribute(h,m),Ua(Qi,m,l,r,e,t,this)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let g=d,v=p;g<v;g++)Qi.fromBufferAttribute(h,g),Ua(Qi,g,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Ua(i,e,t,n,r,s,a){const o=Fs.distanceSqToPoint(i);if(o<t){const l=new N;Fs.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Po extends St{constructor(e,t,n=Ln,r,s,a,o=Ct,l=Ct,c,f=Si,h=1){if(f!==Si&&f!==bi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,r,s,a,o,l,f,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Do extends St{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dr extends qt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,f=l+1,h=e/o,d=t/l,p=[],g=[],v=[],m=[];for(let u=0;u<f;u++){const T=u*d-a;for(let E=0;E<c;E++){const w=E*h-s;g.push(w,-T,0),v.push(0,0,1),m.push(E/o),m.push(1-u/l)}}for(let u=0;u<l;u++)for(let T=0;T<o;T++){const E=T+c*u,w=T+c*(u+1),D=T+1+c*(u+1),y=T+1+c*u;p.push(E,w,y),p.push(w,D,y)}this.setIndex(p),this.setAttribute("position",new an(g,3)),this.setAttribute("normal",new an(v,3)),this.setAttribute("uv",new an(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dr(e.width,e.height,e.widthSegments,e.heightSegments)}}class wl extends ai{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Cl extends ai{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Lo extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new We(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Hr=new it,Ia=new N,Na=new N;class Pl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Xe(512,512),this.mapType=Xt,this.map=null,this.mapPass=null,this.matrix=new it,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ks,this._frameExtents=new Xe(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Ia.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ia),Na.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Na),t.updateMatrixWorld(),Hr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hr,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Hr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Fa=new it,pi=new N,kr=new N;class Dl extends Pl{constructor(){super(new Ut(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Xe(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),pi.setFromMatrixPosition(e.matrixWorld),n.position.copy(pi),kr.copy(n.position),kr.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(kr),n.updateMatrixWorld(),r.makeTranslation(-pi.x,-pi.y,-pi.z),Fa.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fa,n.coordinateSystem,n.reversedDepth)}}class Rp extends Lo{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Dl}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Ll extends Ro{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=f*this.view.offsetY,l=o-f*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class wp extends Lo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ul extends Ut{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Cp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}class Pp{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ne(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ne(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Dp extends In{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ce("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Oa(i,e,t,n){const r=Il(n);switch(t){case mo:return i*e;case _o:return i*e/r.components*r.byteLength;case Gs:return i*e/r.components*r.byteLength;case Hs:return i*e*2/r.components*r.byteLength;case ks:return i*e*2/r.components*r.byteLength;case xo:return i*e*3/r.components*r.byteLength;case Vt:return i*e*4/r.components*r.byteLength;case Ws:return i*e*4/r.components*r.byteLength;case nr:case ir:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case rr:case sr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ls:case fs:return Math.max(i,16)*Math.max(e,8)/4;case cs:case us:return Math.max(i,8)*Math.max(e,8)/2;case hs:case ds:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ps:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ms:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case xs:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case _s:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case gs:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case vs:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ms:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ss:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case bs:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Es:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ys:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Ts:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case As:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Rs:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ws:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Cs:case Ps:case Ds:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Ls:case Us:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Is:case Ns:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Il(i){switch(i){case Xt:case uo:return{byteLength:1,components:1};case vi:case fo:case ri:return{byteLength:2,components:1};case zs:case Vs:return{byteLength:2,components:4};case Ln:case Bs:case nn:return{byteLength:4,components:1};case ho:case po:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"181"}}));typeof window<"u"&&(window.__THREE__?Ce("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="181");function Uo(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Nl(i){const e=new WeakMap;function t(o,l){const c=o.array,f=o.usage,h=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,f),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function n(o,l,c){const f=l.array,h=l.updateRanges;if(i.bindBuffer(c,o),h.length===0)i.bufferSubData(c,0,f);else{h.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<h.length;p++){const g=h[d],v=h[p];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++d,h[d]=v)}h.length=d+1;for(let p=0,g=h.length;p<g;p++){const v=h[p];i.bufferSubData(c,v.start*f.BYTES_PER_ELEMENT,f,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const f=e.get(o);(!f||f.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var Fl=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,Ol=`#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`,Bl=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,zl=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,Vl=`#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`,Gl=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,Hl=`#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`,kl=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,Wl=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,Xl=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,ql=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,Yl=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,Kl=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,Zl=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ 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 ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,$l=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,jl=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,Jl=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,Ql=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,eu=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,tu=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,nu=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,iu=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,ru=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,su=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ bool isPerspectiveMatrix( mat4 m ) {
375
+ return m[ 2 ][ 3 ] == - 1.0;
376
+ }
377
+ vec2 equirectUv( in vec3 dir ) {
378
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
379
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
380
+ return vec2( u, v );
381
+ }
382
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
383
+ return RECIPROCAL_PI * diffuseColor;
384
+ }
385
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
386
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
387
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
388
+ }
389
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
390
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
391
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
392
+ } // validated`,au=`#ifdef ENVMAP_TYPE_CUBE_UV
393
+ #define cubeUV_minMipLevel 4.0
394
+ #define cubeUV_minTileSize 16.0
395
+ float getFace( vec3 direction ) {
396
+ vec3 absDirection = abs( direction );
397
+ float face = - 1.0;
398
+ if ( absDirection.x > absDirection.z ) {
399
+ if ( absDirection.x > absDirection.y )
400
+ face = direction.x > 0.0 ? 0.0 : 3.0;
401
+ else
402
+ face = direction.y > 0.0 ? 1.0 : 4.0;
403
+ } else {
404
+ if ( absDirection.z > absDirection.y )
405
+ face = direction.z > 0.0 ? 2.0 : 5.0;
406
+ else
407
+ face = direction.y > 0.0 ? 1.0 : 4.0;
408
+ }
409
+ return face;
410
+ }
411
+ vec2 getUV( vec3 direction, float face ) {
412
+ vec2 uv;
413
+ if ( face == 0.0 ) {
414
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
415
+ } else if ( face == 1.0 ) {
416
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
417
+ } else if ( face == 2.0 ) {
418
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
419
+ } else if ( face == 3.0 ) {
420
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
421
+ } else if ( face == 4.0 ) {
422
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
423
+ } else {
424
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
425
+ }
426
+ return 0.5 * ( uv + 1.0 );
427
+ }
428
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
429
+ float face = getFace( direction );
430
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
431
+ mipInt = max( mipInt, cubeUV_minMipLevel );
432
+ float faceSize = exp2( mipInt );
433
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
434
+ if ( face > 2.0 ) {
435
+ uv.y += faceSize;
436
+ face -= 3.0;
437
+ }
438
+ uv.x += face * faceSize;
439
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
440
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
441
+ uv.x *= CUBEUV_TEXEL_WIDTH;
442
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
443
+ #ifdef texture2DGradEXT
444
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
445
+ #else
446
+ return texture2D( envMap, uv ).rgb;
447
+ #endif
448
+ }
449
+ #define cubeUV_r0 1.0
450
+ #define cubeUV_m0 - 2.0
451
+ #define cubeUV_r1 0.8
452
+ #define cubeUV_m1 - 1.0
453
+ #define cubeUV_r4 0.4
454
+ #define cubeUV_m4 2.0
455
+ #define cubeUV_r5 0.305
456
+ #define cubeUV_m5 3.0
457
+ #define cubeUV_r6 0.21
458
+ #define cubeUV_m6 4.0
459
+ float roughnessToMip( float roughness ) {
460
+ float mip = 0.0;
461
+ if ( roughness >= cubeUV_r1 ) {
462
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
463
+ } else if ( roughness >= cubeUV_r4 ) {
464
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
465
+ } else if ( roughness >= cubeUV_r5 ) {
466
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
467
+ } else if ( roughness >= cubeUV_r6 ) {
468
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
469
+ } else {
470
+ mip = - 2.0 * log2( 1.16 * roughness ); }
471
+ return mip;
472
+ }
473
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
474
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
475
+ float mipF = fract( mip );
476
+ float mipInt = floor( mip );
477
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
478
+ if ( mipF == 0.0 ) {
479
+ return vec4( color0, 1.0 );
480
+ } else {
481
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
482
+ return vec4( mix( color0, color1, mipF ), 1.0 );
483
+ }
484
+ }
485
+ #endif`,ou=`vec3 transformedNormal = objectNormal;
486
+ #ifdef USE_TANGENT
487
+ vec3 transformedTangent = objectTangent;
488
+ #endif
489
+ #ifdef USE_BATCHING
490
+ mat3 bm = mat3( batchingMatrix );
491
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
492
+ transformedNormal = bm * transformedNormal;
493
+ #ifdef USE_TANGENT
494
+ transformedTangent = bm * transformedTangent;
495
+ #endif
496
+ #endif
497
+ #ifdef USE_INSTANCING
498
+ mat3 im = mat3( instanceMatrix );
499
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
500
+ transformedNormal = im * transformedNormal;
501
+ #ifdef USE_TANGENT
502
+ transformedTangent = im * transformedTangent;
503
+ #endif
504
+ #endif
505
+ transformedNormal = normalMatrix * transformedNormal;
506
+ #ifdef FLIP_SIDED
507
+ transformedNormal = - transformedNormal;
508
+ #endif
509
+ #ifdef USE_TANGENT
510
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
511
+ #ifdef FLIP_SIDED
512
+ transformedTangent = - transformedTangent;
513
+ #endif
514
+ #endif`,cu=`#ifdef USE_DISPLACEMENTMAP
515
+ uniform sampler2D displacementMap;
516
+ uniform float displacementScale;
517
+ uniform float displacementBias;
518
+ #endif`,lu=`#ifdef USE_DISPLACEMENTMAP
519
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
520
+ #endif`,uu=`#ifdef USE_EMISSIVEMAP
521
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
522
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
523
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
524
+ #endif
525
+ totalEmissiveRadiance *= emissiveColor.rgb;
526
+ #endif`,fu=`#ifdef USE_EMISSIVEMAP
527
+ uniform sampler2D emissiveMap;
528
+ #endif`,hu="gl_FragColor = linearToOutputTexel( gl_FragColor );",du=`vec4 LinearTransferOETF( in vec4 value ) {
529
+ return value;
530
+ }
531
+ vec4 sRGBTransferEOTF( in vec4 value ) {
532
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
533
+ }
534
+ vec4 sRGBTransferOETF( in vec4 value ) {
535
+ 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 );
536
+ }`,pu=`#ifdef USE_ENVMAP
537
+ #ifdef ENV_WORLDPOS
538
+ vec3 cameraToFrag;
539
+ if ( isOrthographic ) {
540
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
541
+ } else {
542
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
543
+ }
544
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
545
+ #ifdef ENVMAP_MODE_REFLECTION
546
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
547
+ #else
548
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
549
+ #endif
550
+ #else
551
+ vec3 reflectVec = vReflect;
552
+ #endif
553
+ #ifdef ENVMAP_TYPE_CUBE
554
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
555
+ #else
556
+ vec4 envColor = vec4( 0.0 );
557
+ #endif
558
+ #ifdef ENVMAP_BLENDING_MULTIPLY
559
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
560
+ #elif defined( ENVMAP_BLENDING_MIX )
561
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
562
+ #elif defined( ENVMAP_BLENDING_ADD )
563
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
564
+ #endif
565
+ #endif`,mu=`#ifdef USE_ENVMAP
566
+ uniform float envMapIntensity;
567
+ uniform float flipEnvMap;
568
+ uniform mat3 envMapRotation;
569
+ #ifdef ENVMAP_TYPE_CUBE
570
+ uniform samplerCube envMap;
571
+ #else
572
+ uniform sampler2D envMap;
573
+ #endif
574
+ #endif`,xu=`#ifdef USE_ENVMAP
575
+ uniform float reflectivity;
576
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
577
+ #define ENV_WORLDPOS
578
+ #endif
579
+ #ifdef ENV_WORLDPOS
580
+ varying vec3 vWorldPosition;
581
+ uniform float refractionRatio;
582
+ #else
583
+ varying vec3 vReflect;
584
+ #endif
585
+ #endif`,_u=`#ifdef USE_ENVMAP
586
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
587
+ #define ENV_WORLDPOS
588
+ #endif
589
+ #ifdef ENV_WORLDPOS
590
+
591
+ varying vec3 vWorldPosition;
592
+ #else
593
+ varying vec3 vReflect;
594
+ uniform float refractionRatio;
595
+ #endif
596
+ #endif`,gu=`#ifdef USE_ENVMAP
597
+ #ifdef ENV_WORLDPOS
598
+ vWorldPosition = worldPosition.xyz;
599
+ #else
600
+ vec3 cameraToVertex;
601
+ if ( isOrthographic ) {
602
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
603
+ } else {
604
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
605
+ }
606
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
607
+ #ifdef ENVMAP_MODE_REFLECTION
608
+ vReflect = reflect( cameraToVertex, worldNormal );
609
+ #else
610
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
611
+ #endif
612
+ #endif
613
+ #endif`,vu=`#ifdef USE_FOG
614
+ vFogDepth = - mvPosition.z;
615
+ #endif`,Mu=`#ifdef USE_FOG
616
+ varying float vFogDepth;
617
+ #endif`,Su=`#ifdef USE_FOG
618
+ #ifdef FOG_EXP2
619
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
620
+ #else
621
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
622
+ #endif
623
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
624
+ #endif`,bu=`#ifdef USE_FOG
625
+ uniform vec3 fogColor;
626
+ varying float vFogDepth;
627
+ #ifdef FOG_EXP2
628
+ uniform float fogDensity;
629
+ #else
630
+ uniform float fogNear;
631
+ uniform float fogFar;
632
+ #endif
633
+ #endif`,Eu=`#ifdef USE_GRADIENTMAP
634
+ uniform sampler2D gradientMap;
635
+ #endif
636
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
637
+ float dotNL = dot( normal, lightDirection );
638
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
639
+ #ifdef USE_GRADIENTMAP
640
+ return vec3( texture2D( gradientMap, coord ).r );
641
+ #else
642
+ vec2 fw = fwidth( coord ) * 0.5;
643
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
644
+ #endif
645
+ }`,yu=`#ifdef USE_LIGHTMAP
646
+ uniform sampler2D lightMap;
647
+ uniform float lightMapIntensity;
648
+ #endif`,Tu=`LambertMaterial material;
649
+ material.diffuseColor = diffuseColor.rgb;
650
+ material.specularStrength = specularStrength;`,Au=`varying vec3 vViewPosition;
651
+ struct LambertMaterial {
652
+ vec3 diffuseColor;
653
+ float specularStrength;
654
+ };
655
+ 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 ) {
656
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
657
+ vec3 irradiance = dotNL * directLight.color;
658
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
659
+ }
660
+ 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 ) {
661
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
662
+ }
663
+ #define RE_Direct RE_Direct_Lambert
664
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ru=`uniform bool receiveShadow;
665
+ uniform vec3 ambientLightColor;
666
+ #if defined( USE_LIGHT_PROBES )
667
+ uniform vec3 lightProbe[ 9 ];
668
+ #endif
669
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
670
+ float x = normal.x, y = normal.y, z = normal.z;
671
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
672
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
673
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
674
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
675
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
676
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
677
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
678
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
679
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
680
+ return result;
681
+ }
682
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
683
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
684
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
685
+ return irradiance;
686
+ }
687
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
688
+ vec3 irradiance = ambientLightColor;
689
+ return irradiance;
690
+ }
691
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
692
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
693
+ if ( cutoffDistance > 0.0 ) {
694
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
695
+ }
696
+ return distanceFalloff;
697
+ }
698
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
699
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
700
+ }
701
+ #if NUM_DIR_LIGHTS > 0
702
+ struct DirectionalLight {
703
+ vec3 direction;
704
+ vec3 color;
705
+ };
706
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
707
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
708
+ light.color = directionalLight.color;
709
+ light.direction = directionalLight.direction;
710
+ light.visible = true;
711
+ }
712
+ #endif
713
+ #if NUM_POINT_LIGHTS > 0
714
+ struct PointLight {
715
+ vec3 position;
716
+ vec3 color;
717
+ float distance;
718
+ float decay;
719
+ };
720
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
721
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
722
+ vec3 lVector = pointLight.position - geometryPosition;
723
+ light.direction = normalize( lVector );
724
+ float lightDistance = length( lVector );
725
+ light.color = pointLight.color;
726
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
727
+ light.visible = ( light.color != vec3( 0.0 ) );
728
+ }
729
+ #endif
730
+ #if NUM_SPOT_LIGHTS > 0
731
+ struct SpotLight {
732
+ vec3 position;
733
+ vec3 direction;
734
+ vec3 color;
735
+ float distance;
736
+ float decay;
737
+ float coneCos;
738
+ float penumbraCos;
739
+ };
740
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
741
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
742
+ vec3 lVector = spotLight.position - geometryPosition;
743
+ light.direction = normalize( lVector );
744
+ float angleCos = dot( light.direction, spotLight.direction );
745
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
746
+ if ( spotAttenuation > 0.0 ) {
747
+ float lightDistance = length( lVector );
748
+ light.color = spotLight.color * spotAttenuation;
749
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
750
+ light.visible = ( light.color != vec3( 0.0 ) );
751
+ } else {
752
+ light.color = vec3( 0.0 );
753
+ light.visible = false;
754
+ }
755
+ }
756
+ #endif
757
+ #if NUM_RECT_AREA_LIGHTS > 0
758
+ struct RectAreaLight {
759
+ vec3 color;
760
+ vec3 position;
761
+ vec3 halfWidth;
762
+ vec3 halfHeight;
763
+ };
764
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
765
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
766
+ #endif
767
+ #if NUM_HEMI_LIGHTS > 0
768
+ struct HemisphereLight {
769
+ vec3 direction;
770
+ vec3 skyColor;
771
+ vec3 groundColor;
772
+ };
773
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
774
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
775
+ float dotNL = dot( normal, hemiLight.direction );
776
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
777
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
778
+ return irradiance;
779
+ }
780
+ #endif`,wu=`#ifdef USE_ENVMAP
781
+ vec3 getIBLIrradiance( const in vec3 normal ) {
782
+ #ifdef ENVMAP_TYPE_CUBE_UV
783
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
784
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
785
+ return PI * envMapColor.rgb * envMapIntensity;
786
+ #else
787
+ return vec3( 0.0 );
788
+ #endif
789
+ }
790
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
791
+ #ifdef ENVMAP_TYPE_CUBE_UV
792
+ vec3 reflectVec = reflect( - viewDir, normal );
793
+ reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
794
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
795
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
796
+ return envMapColor.rgb * envMapIntensity;
797
+ #else
798
+ return vec3( 0.0 );
799
+ #endif
800
+ }
801
+ #ifdef USE_ANISOTROPY
802
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
803
+ #ifdef ENVMAP_TYPE_CUBE_UV
804
+ vec3 bentNormal = cross( bitangent, viewDir );
805
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
806
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
807
+ return getIBLRadiance( viewDir, bentNormal, roughness );
808
+ #else
809
+ return vec3( 0.0 );
810
+ #endif
811
+ }
812
+ #endif
813
+ #endif`,Cu=`ToonMaterial material;
814
+ material.diffuseColor = diffuseColor.rgb;`,Pu=`varying vec3 vViewPosition;
815
+ struct ToonMaterial {
816
+ vec3 diffuseColor;
817
+ };
818
+ 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 ) {
819
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
820
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
821
+ }
822
+ 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 ) {
823
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
824
+ }
825
+ #define RE_Direct RE_Direct_Toon
826
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Du=`BlinnPhongMaterial material;
827
+ material.diffuseColor = diffuseColor.rgb;
828
+ material.specularColor = specular;
829
+ material.specularShininess = shininess;
830
+ material.specularStrength = specularStrength;`,Lu=`varying vec3 vViewPosition;
831
+ struct BlinnPhongMaterial {
832
+ vec3 diffuseColor;
833
+ vec3 specularColor;
834
+ float specularShininess;
835
+ float specularStrength;
836
+ };
837
+ 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 ) {
838
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
839
+ vec3 irradiance = dotNL * directLight.color;
840
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
841
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
842
+ }
843
+ 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 ) {
844
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
845
+ }
846
+ #define RE_Direct RE_Direct_BlinnPhong
847
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Uu=`PhysicalMaterial material;
848
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
849
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
850
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
851
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
852
+ material.roughness = min( material.roughness, 1.0 );
853
+ #ifdef IOR
854
+ material.ior = ior;
855
+ #ifdef USE_SPECULAR
856
+ float specularIntensityFactor = specularIntensity;
857
+ vec3 specularColorFactor = specularColor;
858
+ #ifdef USE_SPECULAR_COLORMAP
859
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
860
+ #endif
861
+ #ifdef USE_SPECULAR_INTENSITYMAP
862
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
863
+ #endif
864
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
865
+ #else
866
+ float specularIntensityFactor = 1.0;
867
+ vec3 specularColorFactor = vec3( 1.0 );
868
+ material.specularF90 = 1.0;
869
+ #endif
870
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
871
+ #else
872
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
873
+ material.specularF90 = 1.0;
874
+ #endif
875
+ #ifdef USE_CLEARCOAT
876
+ material.clearcoat = clearcoat;
877
+ material.clearcoatRoughness = clearcoatRoughness;
878
+ material.clearcoatF0 = vec3( 0.04 );
879
+ material.clearcoatF90 = 1.0;
880
+ #ifdef USE_CLEARCOATMAP
881
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
882
+ #endif
883
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
884
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
885
+ #endif
886
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
887
+ material.clearcoatRoughness += geometryRoughness;
888
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
889
+ #endif
890
+ #ifdef USE_DISPERSION
891
+ material.dispersion = dispersion;
892
+ #endif
893
+ #ifdef USE_IRIDESCENCE
894
+ material.iridescence = iridescence;
895
+ material.iridescenceIOR = iridescenceIOR;
896
+ #ifdef USE_IRIDESCENCEMAP
897
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
898
+ #endif
899
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
900
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
901
+ #else
902
+ material.iridescenceThickness = iridescenceThicknessMaximum;
903
+ #endif
904
+ #endif
905
+ #ifdef USE_SHEEN
906
+ material.sheenColor = sheenColor;
907
+ #ifdef USE_SHEEN_COLORMAP
908
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
909
+ #endif
910
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
911
+ #ifdef USE_SHEEN_ROUGHNESSMAP
912
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
913
+ #endif
914
+ #endif
915
+ #ifdef USE_ANISOTROPY
916
+ #ifdef USE_ANISOTROPYMAP
917
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
918
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
919
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
920
+ #else
921
+ vec2 anisotropyV = anisotropyVector;
922
+ #endif
923
+ material.anisotropy = length( anisotropyV );
924
+ if( material.anisotropy == 0.0 ) {
925
+ anisotropyV = vec2( 1.0, 0.0 );
926
+ } else {
927
+ anisotropyV /= material.anisotropy;
928
+ material.anisotropy = saturate( material.anisotropy );
929
+ }
930
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
931
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
932
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
933
+ #endif`,Iu=`uniform sampler2D dfgLUT;
934
+ struct PhysicalMaterial {
935
+ vec3 diffuseColor;
936
+ float roughness;
937
+ vec3 specularColor;
938
+ float specularF90;
939
+ float dispersion;
940
+ #ifdef USE_CLEARCOAT
941
+ float clearcoat;
942
+ float clearcoatRoughness;
943
+ vec3 clearcoatF0;
944
+ float clearcoatF90;
945
+ #endif
946
+ #ifdef USE_IRIDESCENCE
947
+ float iridescence;
948
+ float iridescenceIOR;
949
+ float iridescenceThickness;
950
+ vec3 iridescenceFresnel;
951
+ vec3 iridescenceF0;
952
+ #endif
953
+ #ifdef USE_SHEEN
954
+ vec3 sheenColor;
955
+ float sheenRoughness;
956
+ #endif
957
+ #ifdef IOR
958
+ float ior;
959
+ #endif
960
+ #ifdef USE_TRANSMISSION
961
+ float transmission;
962
+ float transmissionAlpha;
963
+ float thickness;
964
+ float attenuationDistance;
965
+ vec3 attenuationColor;
966
+ #endif
967
+ #ifdef USE_ANISOTROPY
968
+ float anisotropy;
969
+ float alphaT;
970
+ vec3 anisotropyT;
971
+ vec3 anisotropyB;
972
+ #endif
973
+ };
974
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
975
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
976
+ vec3 sheenSpecularDirect = vec3( 0.0 );
977
+ vec3 sheenSpecularIndirect = vec3(0.0 );
978
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
979
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
980
+ float x2 = x * x;
981
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
982
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
983
+ }
984
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
985
+ float a2 = pow2( alpha );
986
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
987
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
988
+ return 0.5 / max( gv + gl, EPSILON );
989
+ }
990
+ float D_GGX( const in float alpha, const in float dotNH ) {
991
+ float a2 = pow2( alpha );
992
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
993
+ return RECIPROCAL_PI * a2 / pow2( denom );
994
+ }
995
+ #ifdef USE_ANISOTROPY
996
+ 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 ) {
997
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
998
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
999
+ float v = 0.5 / ( gv + gl );
1000
+ return saturate(v);
1001
+ }
1002
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1003
+ float a2 = alphaT * alphaB;
1004
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1005
+ highp float v2 = dot( v, v );
1006
+ float w2 = a2 / v2;
1007
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1008
+ }
1009
+ #endif
1010
+ #ifdef USE_CLEARCOAT
1011
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1012
+ vec3 f0 = material.clearcoatF0;
1013
+ float f90 = material.clearcoatF90;
1014
+ float roughness = material.clearcoatRoughness;
1015
+ float alpha = pow2( roughness );
1016
+ vec3 halfDir = normalize( lightDir + viewDir );
1017
+ float dotNL = saturate( dot( normal, lightDir ) );
1018
+ float dotNV = saturate( dot( normal, viewDir ) );
1019
+ float dotNH = saturate( dot( normal, halfDir ) );
1020
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1021
+ vec3 F = F_Schlick( f0, f90, dotVH );
1022
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1023
+ float D = D_GGX( alpha, dotNH );
1024
+ return F * ( V * D );
1025
+ }
1026
+ #endif
1027
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1028
+ vec3 f0 = material.specularColor;
1029
+ float f90 = material.specularF90;
1030
+ float roughness = material.roughness;
1031
+ float alpha = pow2( roughness );
1032
+ vec3 halfDir = normalize( lightDir + viewDir );
1033
+ float dotNL = saturate( dot( normal, lightDir ) );
1034
+ float dotNV = saturate( dot( normal, viewDir ) );
1035
+ float dotNH = saturate( dot( normal, halfDir ) );
1036
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1037
+ vec3 F = F_Schlick( f0, f90, dotVH );
1038
+ #ifdef USE_IRIDESCENCE
1039
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1040
+ #endif
1041
+ #ifdef USE_ANISOTROPY
1042
+ float dotTL = dot( material.anisotropyT, lightDir );
1043
+ float dotTV = dot( material.anisotropyT, viewDir );
1044
+ float dotTH = dot( material.anisotropyT, halfDir );
1045
+ float dotBL = dot( material.anisotropyB, lightDir );
1046
+ float dotBV = dot( material.anisotropyB, viewDir );
1047
+ float dotBH = dot( material.anisotropyB, halfDir );
1048
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1049
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1050
+ #else
1051
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1052
+ float D = D_GGX( alpha, dotNH );
1053
+ #endif
1054
+ return F * ( V * D );
1055
+ }
1056
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1057
+ const float LUT_SIZE = 64.0;
1058
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1059
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1060
+ float dotNV = saturate( dot( N, V ) );
1061
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1062
+ uv = uv * LUT_SCALE + LUT_BIAS;
1063
+ return uv;
1064
+ }
1065
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1066
+ float l = length( f );
1067
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1068
+ }
1069
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1070
+ float x = dot( v1, v2 );
1071
+ float y = abs( x );
1072
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1073
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1074
+ float v = a / b;
1075
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1076
+ return cross( v1, v2 ) * theta_sintheta;
1077
+ }
1078
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1079
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1080
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1081
+ vec3 lightNormal = cross( v1, v2 );
1082
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1083
+ vec3 T1, T2;
1084
+ T1 = normalize( V - N * dot( V, N ) );
1085
+ T2 = - cross( N, T1 );
1086
+ mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
1087
+ vec3 coords[ 4 ];
1088
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1089
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1090
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1091
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1092
+ coords[ 0 ] = normalize( coords[ 0 ] );
1093
+ coords[ 1 ] = normalize( coords[ 1 ] );
1094
+ coords[ 2 ] = normalize( coords[ 2 ] );
1095
+ coords[ 3 ] = normalize( coords[ 3 ] );
1096
+ vec3 vectorFormFactor = vec3( 0.0 );
1097
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1098
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1099
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1100
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1101
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1102
+ return vec3( result );
1103
+ }
1104
+ #if defined( USE_SHEEN )
1105
+ float D_Charlie( float roughness, float dotNH ) {
1106
+ float alpha = pow2( roughness );
1107
+ float invAlpha = 1.0 / alpha;
1108
+ float cos2h = dotNH * dotNH;
1109
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1110
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1111
+ }
1112
+ float V_Neubelt( float dotNV, float dotNL ) {
1113
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1114
+ }
1115
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1116
+ vec3 halfDir = normalize( lightDir + viewDir );
1117
+ float dotNL = saturate( dot( normal, lightDir ) );
1118
+ float dotNV = saturate( dot( normal, viewDir ) );
1119
+ float dotNH = saturate( dot( normal, halfDir ) );
1120
+ float D = D_Charlie( sheenRoughness, dotNH );
1121
+ float V = V_Neubelt( dotNV, dotNL );
1122
+ return sheenColor * ( D * V );
1123
+ }
1124
+ #endif
1125
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1126
+ float dotNV = saturate( dot( normal, viewDir ) );
1127
+ float r2 = roughness * roughness;
1128
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1129
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1130
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1131
+ return saturate( DG * RECIPROCAL_PI );
1132
+ }
1133
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1134
+ float dotNV = saturate( dot( normal, viewDir ) );
1135
+ vec2 uv = vec2( roughness, dotNV );
1136
+ return texture2D( dfgLUT, uv ).rg;
1137
+ }
1138
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1139
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1140
+ return specularColor * fab.x + specularF90 * fab.y;
1141
+ }
1142
+ #ifdef USE_IRIDESCENCE
1143
+ 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 ) {
1144
+ #else
1145
+ 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 ) {
1146
+ #endif
1147
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1148
+ #ifdef USE_IRIDESCENCE
1149
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1150
+ #else
1151
+ vec3 Fr = specularColor;
1152
+ #endif
1153
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1154
+ float Ess = fab.x + fab.y;
1155
+ float Ems = 1.0 - Ess;
1156
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1157
+ singleScatter += FssEss;
1158
+ multiScatter += Fms * Ems;
1159
+ }
1160
+ vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1161
+ vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
1162
+ float dotNL = saturate( dot( normal, lightDir ) );
1163
+ float dotNV = saturate( dot( normal, viewDir ) );
1164
+ vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
1165
+ vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
1166
+ vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
1167
+ vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
1168
+ float Ess_V = dfgV.x + dfgV.y;
1169
+ float Ess_L = dfgL.x + dfgL.y;
1170
+ float Ems_V = 1.0 - Ess_V;
1171
+ float Ems_L = 1.0 - Ess_L;
1172
+ vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
1173
+ vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
1174
+ float compensationFactor = Ems_V * Ems_L;
1175
+ vec3 multiScatter = Fms * compensationFactor;
1176
+ return singleScatter + multiScatter;
1177
+ }
1178
+ #if NUM_RECT_AREA_LIGHTS > 0
1179
+ 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 ) {
1180
+ vec3 normal = geometryNormal;
1181
+ vec3 viewDir = geometryViewDir;
1182
+ vec3 position = geometryPosition;
1183
+ vec3 lightPos = rectAreaLight.position;
1184
+ vec3 halfWidth = rectAreaLight.halfWidth;
1185
+ vec3 halfHeight = rectAreaLight.halfHeight;
1186
+ vec3 lightColor = rectAreaLight.color;
1187
+ float roughness = material.roughness;
1188
+ vec3 rectCoords[ 4 ];
1189
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1190
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1191
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1192
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1193
+ vec4 t1 = texture2D( ltc_1, uv );
1194
+ vec4 t2 = texture2D( ltc_2, uv );
1195
+ mat3 mInv = mat3(
1196
+ vec3( t1.x, 0, t1.y ),
1197
+ vec3( 0, 1, 0 ),
1198
+ vec3( t1.z, 0, t1.w )
1199
+ );
1200
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1201
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1202
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1203
+ }
1204
+ #endif
1205
+ 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 ) {
1206
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1207
+ vec3 irradiance = dotNL * directLight.color;
1208
+ #ifdef USE_CLEARCOAT
1209
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1210
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1211
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1212
+ #endif
1213
+ #ifdef USE_SHEEN
1214
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1215
+ #endif
1216
+ reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
1217
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1218
+ }
1219
+ 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 ) {
1220
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1221
+ }
1222
+ 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) {
1223
+ #ifdef USE_CLEARCOAT
1224
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1225
+ #endif
1226
+ #ifdef USE_SHEEN
1227
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1228
+ #endif
1229
+ vec3 singleScattering = vec3( 0.0 );
1230
+ vec3 multiScattering = vec3( 0.0 );
1231
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1232
+ #ifdef USE_IRIDESCENCE
1233
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1234
+ #else
1235
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1236
+ #endif
1237
+ vec3 totalScattering = singleScattering + multiScattering;
1238
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1239
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1240
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1241
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1242
+ }
1243
+ #define RE_Direct RE_Direct_Physical
1244
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1245
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1246
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1247
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1248
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1249
+ }`,Nu=`
1250
+ vec3 geometryPosition = - vViewPosition;
1251
+ vec3 geometryNormal = normal;
1252
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1253
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1254
+ #ifdef USE_CLEARCOAT
1255
+ geometryClearcoatNormal = clearcoatNormal;
1256
+ #endif
1257
+ #ifdef USE_IRIDESCENCE
1258
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1259
+ if ( material.iridescenceThickness == 0.0 ) {
1260
+ material.iridescence = 0.0;
1261
+ } else {
1262
+ material.iridescence = saturate( material.iridescence );
1263
+ }
1264
+ if ( material.iridescence > 0.0 ) {
1265
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1266
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1267
+ }
1268
+ #endif
1269
+ IncidentLight directLight;
1270
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1271
+ PointLight pointLight;
1272
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1273
+ PointLightShadow pointLightShadow;
1274
+ #endif
1275
+ #pragma unroll_loop_start
1276
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1277
+ pointLight = pointLights[ i ];
1278
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1279
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1280
+ pointLightShadow = pointLightShadows[ i ];
1281
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1282
+ #endif
1283
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1284
+ }
1285
+ #pragma unroll_loop_end
1286
+ #endif
1287
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1288
+ SpotLight spotLight;
1289
+ vec4 spotColor;
1290
+ vec3 spotLightCoord;
1291
+ bool inSpotLightMap;
1292
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1293
+ SpotLightShadow spotLightShadow;
1294
+ #endif
1295
+ #pragma unroll_loop_start
1296
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1297
+ spotLight = spotLights[ i ];
1298
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1299
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1300
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1301
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1302
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1303
+ #else
1304
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1305
+ #endif
1306
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1307
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1308
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1309
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1310
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1311
+ #endif
1312
+ #undef SPOT_LIGHT_MAP_INDEX
1313
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1314
+ spotLightShadow = spotLightShadows[ i ];
1315
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1316
+ #endif
1317
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1318
+ }
1319
+ #pragma unroll_loop_end
1320
+ #endif
1321
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1322
+ DirectionalLight directionalLight;
1323
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1324
+ DirectionalLightShadow directionalLightShadow;
1325
+ #endif
1326
+ #pragma unroll_loop_start
1327
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1328
+ directionalLight = directionalLights[ i ];
1329
+ getDirectionalLightInfo( directionalLight, directLight );
1330
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1331
+ directionalLightShadow = directionalLightShadows[ i ];
1332
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1333
+ #endif
1334
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1335
+ }
1336
+ #pragma unroll_loop_end
1337
+ #endif
1338
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1339
+ RectAreaLight rectAreaLight;
1340
+ #pragma unroll_loop_start
1341
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1342
+ rectAreaLight = rectAreaLights[ i ];
1343
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1344
+ }
1345
+ #pragma unroll_loop_end
1346
+ #endif
1347
+ #if defined( RE_IndirectDiffuse )
1348
+ vec3 iblIrradiance = vec3( 0.0 );
1349
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1350
+ #if defined( USE_LIGHT_PROBES )
1351
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1352
+ #endif
1353
+ #if ( NUM_HEMI_LIGHTS > 0 )
1354
+ #pragma unroll_loop_start
1355
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1356
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1357
+ }
1358
+ #pragma unroll_loop_end
1359
+ #endif
1360
+ #endif
1361
+ #if defined( RE_IndirectSpecular )
1362
+ vec3 radiance = vec3( 0.0 );
1363
+ vec3 clearcoatRadiance = vec3( 0.0 );
1364
+ #endif`,Fu=`#if defined( RE_IndirectDiffuse )
1365
+ #ifdef USE_LIGHTMAP
1366
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1367
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1368
+ irradiance += lightMapIrradiance;
1369
+ #endif
1370
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1371
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1372
+ #endif
1373
+ #endif
1374
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1375
+ #ifdef USE_ANISOTROPY
1376
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1377
+ #else
1378
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1379
+ #endif
1380
+ #ifdef USE_CLEARCOAT
1381
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1382
+ #endif
1383
+ #endif`,Ou=`#if defined( RE_IndirectDiffuse )
1384
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1385
+ #endif
1386
+ #if defined( RE_IndirectSpecular )
1387
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1388
+ #endif`,Bu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1389
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1390
+ #endif`,zu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1391
+ uniform float logDepthBufFC;
1392
+ varying float vFragDepth;
1393
+ varying float vIsPerspective;
1394
+ #endif`,Vu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1395
+ varying float vFragDepth;
1396
+ varying float vIsPerspective;
1397
+ #endif`,Gu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1398
+ vFragDepth = 1.0 + gl_Position.w;
1399
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1400
+ #endif`,Hu=`#ifdef USE_MAP
1401
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1402
+ #ifdef DECODE_VIDEO_TEXTURE
1403
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1404
+ #endif
1405
+ diffuseColor *= sampledDiffuseColor;
1406
+ #endif`,ku=`#ifdef USE_MAP
1407
+ uniform sampler2D map;
1408
+ #endif`,Wu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1409
+ #if defined( USE_POINTS_UV )
1410
+ vec2 uv = vUv;
1411
+ #else
1412
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1413
+ #endif
1414
+ #endif
1415
+ #ifdef USE_MAP
1416
+ diffuseColor *= texture2D( map, uv );
1417
+ #endif
1418
+ #ifdef USE_ALPHAMAP
1419
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1420
+ #endif`,Xu=`#if defined( USE_POINTS_UV )
1421
+ varying vec2 vUv;
1422
+ #else
1423
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1424
+ uniform mat3 uvTransform;
1425
+ #endif
1426
+ #endif
1427
+ #ifdef USE_MAP
1428
+ uniform sampler2D map;
1429
+ #endif
1430
+ #ifdef USE_ALPHAMAP
1431
+ uniform sampler2D alphaMap;
1432
+ #endif`,qu=`float metalnessFactor = metalness;
1433
+ #ifdef USE_METALNESSMAP
1434
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1435
+ metalnessFactor *= texelMetalness.b;
1436
+ #endif`,Yu=`#ifdef USE_METALNESSMAP
1437
+ uniform sampler2D metalnessMap;
1438
+ #endif`,Ku=`#ifdef USE_INSTANCING_MORPH
1439
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1440
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1441
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1442
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1443
+ }
1444
+ #endif`,Zu=`#if defined( USE_MORPHCOLORS )
1445
+ vColor *= morphTargetBaseInfluence;
1446
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1447
+ #if defined( USE_COLOR_ALPHA )
1448
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1449
+ #elif defined( USE_COLOR )
1450
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1451
+ #endif
1452
+ }
1453
+ #endif`,$u=`#ifdef USE_MORPHNORMALS
1454
+ objectNormal *= morphTargetBaseInfluence;
1455
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1457
+ }
1458
+ #endif`,ju=`#ifdef USE_MORPHTARGETS
1459
+ #ifndef USE_INSTANCING_MORPH
1460
+ uniform float morphTargetBaseInfluence;
1461
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1462
+ #endif
1463
+ uniform sampler2DArray morphTargetsTexture;
1464
+ uniform ivec2 morphTargetsTextureSize;
1465
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1466
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1467
+ int y = texelIndex / morphTargetsTextureSize.x;
1468
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1469
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1470
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1471
+ }
1472
+ #endif`,Ju=`#ifdef USE_MORPHTARGETS
1473
+ transformed *= morphTargetBaseInfluence;
1474
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1475
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1476
+ }
1477
+ #endif`,Qu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1478
+ #ifdef FLAT_SHADED
1479
+ vec3 fdx = dFdx( vViewPosition );
1480
+ vec3 fdy = dFdy( vViewPosition );
1481
+ vec3 normal = normalize( cross( fdx, fdy ) );
1482
+ #else
1483
+ vec3 normal = normalize( vNormal );
1484
+ #ifdef DOUBLE_SIDED
1485
+ normal *= faceDirection;
1486
+ #endif
1487
+ #endif
1488
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1489
+ #ifdef USE_TANGENT
1490
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1491
+ #else
1492
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1493
+ #if defined( USE_NORMALMAP )
1494
+ vNormalMapUv
1495
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1496
+ vClearcoatNormalMapUv
1497
+ #else
1498
+ vUv
1499
+ #endif
1500
+ );
1501
+ #endif
1502
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1503
+ tbn[0] *= faceDirection;
1504
+ tbn[1] *= faceDirection;
1505
+ #endif
1506
+ #endif
1507
+ #ifdef USE_CLEARCOAT_NORMALMAP
1508
+ #ifdef USE_TANGENT
1509
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1510
+ #else
1511
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1512
+ #endif
1513
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1514
+ tbn2[0] *= faceDirection;
1515
+ tbn2[1] *= faceDirection;
1516
+ #endif
1517
+ #endif
1518
+ vec3 nonPerturbedNormal = normal;`,ef=`#ifdef USE_NORMALMAP_OBJECTSPACE
1519
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1520
+ #ifdef FLIP_SIDED
1521
+ normal = - normal;
1522
+ #endif
1523
+ #ifdef DOUBLE_SIDED
1524
+ normal = normal * faceDirection;
1525
+ #endif
1526
+ normal = normalize( normalMatrix * normal );
1527
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1528
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1529
+ mapN.xy *= normalScale;
1530
+ normal = normalize( tbn * mapN );
1531
+ #elif defined( USE_BUMPMAP )
1532
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1533
+ #endif`,tf=`#ifndef FLAT_SHADED
1534
+ varying vec3 vNormal;
1535
+ #ifdef USE_TANGENT
1536
+ varying vec3 vTangent;
1537
+ varying vec3 vBitangent;
1538
+ #endif
1539
+ #endif`,nf=`#ifndef FLAT_SHADED
1540
+ varying vec3 vNormal;
1541
+ #ifdef USE_TANGENT
1542
+ varying vec3 vTangent;
1543
+ varying vec3 vBitangent;
1544
+ #endif
1545
+ #endif`,rf=`#ifndef FLAT_SHADED
1546
+ vNormal = normalize( transformedNormal );
1547
+ #ifdef USE_TANGENT
1548
+ vTangent = normalize( transformedTangent );
1549
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1550
+ #endif
1551
+ #endif`,sf=`#ifdef USE_NORMALMAP
1552
+ uniform sampler2D normalMap;
1553
+ uniform vec2 normalScale;
1554
+ #endif
1555
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1556
+ uniform mat3 normalMatrix;
1557
+ #endif
1558
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1559
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1560
+ vec3 q0 = dFdx( eye_pos.xyz );
1561
+ vec3 q1 = dFdy( eye_pos.xyz );
1562
+ vec2 st0 = dFdx( uv.st );
1563
+ vec2 st1 = dFdy( uv.st );
1564
+ vec3 N = surf_norm;
1565
+ vec3 q1perp = cross( q1, N );
1566
+ vec3 q0perp = cross( N, q0 );
1567
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1568
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1569
+ float det = max( dot( T, T ), dot( B, B ) );
1570
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1571
+ return mat3( T * scale, B * scale, N );
1572
+ }
1573
+ #endif`,af=`#ifdef USE_CLEARCOAT
1574
+ vec3 clearcoatNormal = nonPerturbedNormal;
1575
+ #endif`,of=`#ifdef USE_CLEARCOAT_NORMALMAP
1576
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1577
+ clearcoatMapN.xy *= clearcoatNormalScale;
1578
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1579
+ #endif`,cf=`#ifdef USE_CLEARCOATMAP
1580
+ uniform sampler2D clearcoatMap;
1581
+ #endif
1582
+ #ifdef USE_CLEARCOAT_NORMALMAP
1583
+ uniform sampler2D clearcoatNormalMap;
1584
+ uniform vec2 clearcoatNormalScale;
1585
+ #endif
1586
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1587
+ uniform sampler2D clearcoatRoughnessMap;
1588
+ #endif`,lf=`#ifdef USE_IRIDESCENCEMAP
1589
+ uniform sampler2D iridescenceMap;
1590
+ #endif
1591
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1592
+ uniform sampler2D iridescenceThicknessMap;
1593
+ #endif`,uf=`#ifdef OPAQUE
1594
+ diffuseColor.a = 1.0;
1595
+ #endif
1596
+ #ifdef USE_TRANSMISSION
1597
+ diffuseColor.a *= material.transmissionAlpha;
1598
+ #endif
1599
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ff=`vec3 packNormalToRGB( const in vec3 normal ) {
1600
+ return normalize( normal ) * 0.5 + 0.5;
1601
+ }
1602
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1603
+ return 2.0 * rgb.xyz - 1.0;
1604
+ }
1605
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1606
+ const float Inv255 = 1. / 255.;
1607
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1608
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1609
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1610
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1611
+ vec4 packDepthToRGBA( const in float v ) {
1612
+ if( v <= 0.0 )
1613
+ return vec4( 0., 0., 0., 0. );
1614
+ if( v >= 1.0 )
1615
+ return vec4( 1., 1., 1., 1. );
1616
+ float vuf;
1617
+ float af = modf( v * PackFactors.a, vuf );
1618
+ float bf = modf( vuf * ShiftRight8, vuf );
1619
+ float gf = modf( vuf * ShiftRight8, vuf );
1620
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1621
+ }
1622
+ vec3 packDepthToRGB( const in float v ) {
1623
+ if( v <= 0.0 )
1624
+ return vec3( 0., 0., 0. );
1625
+ if( v >= 1.0 )
1626
+ return vec3( 1., 1., 1. );
1627
+ float vuf;
1628
+ float bf = modf( v * PackFactors.b, vuf );
1629
+ float gf = modf( vuf * ShiftRight8, vuf );
1630
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1631
+ }
1632
+ vec2 packDepthToRG( const in float v ) {
1633
+ if( v <= 0.0 )
1634
+ return vec2( 0., 0. );
1635
+ if( v >= 1.0 )
1636
+ return vec2( 1., 1. );
1637
+ float vuf;
1638
+ float gf = modf( v * 256., vuf );
1639
+ return vec2( vuf * Inv255, gf );
1640
+ }
1641
+ float unpackRGBAToDepth( const in vec4 v ) {
1642
+ return dot( v, UnpackFactors4 );
1643
+ }
1644
+ float unpackRGBToDepth( const in vec3 v ) {
1645
+ return dot( v, UnpackFactors3 );
1646
+ }
1647
+ float unpackRGToDepth( const in vec2 v ) {
1648
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1649
+ }
1650
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1651
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1652
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1653
+ }
1654
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1655
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1656
+ }
1657
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1658
+ return ( viewZ + near ) / ( near - far );
1659
+ }
1660
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1661
+ return depth * ( near - far ) - near;
1662
+ }
1663
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1664
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1665
+ }
1666
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1667
+ return ( near * far ) / ( ( far - near ) * depth - far );
1668
+ }`,hf=`#ifdef PREMULTIPLIED_ALPHA
1669
+ gl_FragColor.rgb *= gl_FragColor.a;
1670
+ #endif`,df=`vec4 mvPosition = vec4( transformed, 1.0 );
1671
+ #ifdef USE_BATCHING
1672
+ mvPosition = batchingMatrix * mvPosition;
1673
+ #endif
1674
+ #ifdef USE_INSTANCING
1675
+ mvPosition = instanceMatrix * mvPosition;
1676
+ #endif
1677
+ mvPosition = modelViewMatrix * mvPosition;
1678
+ gl_Position = projectionMatrix * mvPosition;`,pf=`#ifdef DITHERING
1679
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1680
+ #endif`,mf=`#ifdef DITHERING
1681
+ vec3 dithering( vec3 color ) {
1682
+ float grid_position = rand( gl_FragCoord.xy );
1683
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1684
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1685
+ return color + dither_shift_RGB;
1686
+ }
1687
+ #endif`,xf=`float roughnessFactor = roughness;
1688
+ #ifdef USE_ROUGHNESSMAP
1689
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1690
+ roughnessFactor *= texelRoughness.g;
1691
+ #endif`,_f=`#ifdef USE_ROUGHNESSMAP
1692
+ uniform sampler2D roughnessMap;
1693
+ #endif`,gf=`#if NUM_SPOT_LIGHT_COORDS > 0
1694
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1695
+ #endif
1696
+ #if NUM_SPOT_LIGHT_MAPS > 0
1697
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1698
+ #endif
1699
+ #ifdef USE_SHADOWMAP
1700
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1701
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1702
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1703
+ struct DirectionalLightShadow {
1704
+ float shadowIntensity;
1705
+ float shadowBias;
1706
+ float shadowNormalBias;
1707
+ float shadowRadius;
1708
+ vec2 shadowMapSize;
1709
+ };
1710
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1711
+ #endif
1712
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1713
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1714
+ struct SpotLightShadow {
1715
+ float shadowIntensity;
1716
+ float shadowBias;
1717
+ float shadowNormalBias;
1718
+ float shadowRadius;
1719
+ vec2 shadowMapSize;
1720
+ };
1721
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1722
+ #endif
1723
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1724
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1725
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1726
+ struct PointLightShadow {
1727
+ float shadowIntensity;
1728
+ float shadowBias;
1729
+ float shadowNormalBias;
1730
+ float shadowRadius;
1731
+ vec2 shadowMapSize;
1732
+ float shadowCameraNear;
1733
+ float shadowCameraFar;
1734
+ };
1735
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1736
+ #endif
1737
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1738
+ float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
1739
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1740
+ return step( depth, compare );
1741
+ #else
1742
+ return step( compare, depth );
1743
+ #endif
1744
+ }
1745
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1746
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1747
+ }
1748
+ float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
1749
+ float occlusion = 1.0;
1750
+ vec2 distribution = texture2DDistribution( shadow, uv );
1751
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1752
+ float hard_shadow = step( distribution.x, compare );
1753
+ #else
1754
+ float hard_shadow = step( compare, distribution.x );
1755
+ #endif
1756
+ if ( hard_shadow != 1.0 ) {
1757
+ float distance = compare - distribution.x;
1758
+ float variance = max( 0.00000, distribution.y * distribution.y );
1759
+ 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 );
1760
+ }
1761
+ return occlusion;
1762
+ }
1763
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1764
+ float shadow = 1.0;
1765
+ shadowCoord.xyz /= shadowCoord.w;
1766
+ shadowCoord.z += shadowBias;
1767
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1768
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1769
+ if ( frustumTest ) {
1770
+ #if defined( SHADOWMAP_TYPE_PCF )
1771
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1772
+ float dx0 = - texelSize.x * shadowRadius;
1773
+ float dy0 = - texelSize.y * shadowRadius;
1774
+ float dx1 = + texelSize.x * shadowRadius;
1775
+ float dy1 = + texelSize.y * shadowRadius;
1776
+ float dx2 = dx0 / 2.0;
1777
+ float dy2 = dy0 / 2.0;
1778
+ float dx3 = dx1 / 2.0;
1779
+ float dy3 = dy1 / 2.0;
1780
+ shadow = (
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1782
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1783
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1784
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1785
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1786
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1787
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1788
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1789
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1790
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1791
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1794
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1795
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1796
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1797
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1798
+ ) * ( 1.0 / 17.0 );
1799
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1800
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1801
+ float dx = texelSize.x;
1802
+ float dy = texelSize.y;
1803
+ vec2 uv = shadowCoord.xy;
1804
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1805
+ uv -= f * texelSize;
1806
+ shadow = (
1807
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1808
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1809
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1810
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1811
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1812
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1813
+ f.x ) +
1814
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1815
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1816
+ f.x ) +
1817
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1818
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1819
+ f.y ) +
1820
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1821
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1822
+ f.y ) +
1823
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1824
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1825
+ f.x ),
1826
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1827
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1828
+ f.x ),
1829
+ f.y )
1830
+ ) * ( 1.0 / 9.0 );
1831
+ #elif defined( SHADOWMAP_TYPE_VSM )
1832
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1833
+ #else
1834
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1835
+ #endif
1836
+ }
1837
+ return mix( 1.0, shadow, shadowIntensity );
1838
+ }
1839
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1840
+ vec3 absV = abs( v );
1841
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1842
+ absV *= scaleToCube;
1843
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1844
+ vec2 planar = v.xy;
1845
+ float almostATexel = 1.5 * texelSizeY;
1846
+ float almostOne = 1.0 - almostATexel;
1847
+ if ( absV.z >= almostOne ) {
1848
+ if ( v.z > 0.0 )
1849
+ planar.x = 4.0 - v.x;
1850
+ } else if ( absV.x >= almostOne ) {
1851
+ float signX = sign( v.x );
1852
+ planar.x = v.z * signX + 2.0 * signX;
1853
+ } else if ( absV.y >= almostOne ) {
1854
+ float signY = sign( v.y );
1855
+ planar.x = v.x + 2.0 * signY + 2.0;
1856
+ planar.y = v.z * signY - 2.0;
1857
+ }
1858
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1859
+ }
1860
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1861
+ float shadow = 1.0;
1862
+ vec3 lightToPosition = shadowCoord.xyz;
1863
+
1864
+ float lightToPositionLength = length( lightToPosition );
1865
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1866
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1867
+ vec3 bd3D = normalize( lightToPosition );
1868
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1869
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1870
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1871
+ shadow = (
1872
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1873
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1874
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1875
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1876
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1877
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1878
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1879
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1880
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1881
+ ) * ( 1.0 / 9.0 );
1882
+ #else
1883
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1884
+ #endif
1885
+ }
1886
+ return mix( 1.0, shadow, shadowIntensity );
1887
+ }
1888
+ #endif`,vf=`#if NUM_SPOT_LIGHT_COORDS > 0
1889
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1890
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1891
+ #endif
1892
+ #ifdef USE_SHADOWMAP
1893
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1894
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1895
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1896
+ struct DirectionalLightShadow {
1897
+ float shadowIntensity;
1898
+ float shadowBias;
1899
+ float shadowNormalBias;
1900
+ float shadowRadius;
1901
+ vec2 shadowMapSize;
1902
+ };
1903
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1904
+ #endif
1905
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1906
+ struct SpotLightShadow {
1907
+ float shadowIntensity;
1908
+ float shadowBias;
1909
+ float shadowNormalBias;
1910
+ float shadowRadius;
1911
+ vec2 shadowMapSize;
1912
+ };
1913
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1914
+ #endif
1915
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1916
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1917
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1918
+ struct PointLightShadow {
1919
+ float shadowIntensity;
1920
+ float shadowBias;
1921
+ float shadowNormalBias;
1922
+ float shadowRadius;
1923
+ vec2 shadowMapSize;
1924
+ float shadowCameraNear;
1925
+ float shadowCameraFar;
1926
+ };
1927
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1928
+ #endif
1929
+ #endif`,Mf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1930
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1931
+ vec4 shadowWorldPosition;
1932
+ #endif
1933
+ #if defined( USE_SHADOWMAP )
1934
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1935
+ #pragma unroll_loop_start
1936
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1937
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1938
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1939
+ }
1940
+ #pragma unroll_loop_end
1941
+ #endif
1942
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1943
+ #pragma unroll_loop_start
1944
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1945
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1946
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1947
+ }
1948
+ #pragma unroll_loop_end
1949
+ #endif
1950
+ #endif
1951
+ #if NUM_SPOT_LIGHT_COORDS > 0
1952
+ #pragma unroll_loop_start
1953
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1954
+ shadowWorldPosition = worldPosition;
1955
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1956
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1957
+ #endif
1958
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1959
+ }
1960
+ #pragma unroll_loop_end
1961
+ #endif`,Sf=`float getShadowMask() {
1962
+ float shadow = 1.0;
1963
+ #ifdef USE_SHADOWMAP
1964
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1965
+ DirectionalLightShadow directionalLight;
1966
+ #pragma unroll_loop_start
1967
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1968
+ directionalLight = directionalLightShadows[ i ];
1969
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1970
+ }
1971
+ #pragma unroll_loop_end
1972
+ #endif
1973
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1974
+ SpotLightShadow spotLight;
1975
+ #pragma unroll_loop_start
1976
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1977
+ spotLight = spotLightShadows[ i ];
1978
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1979
+ }
1980
+ #pragma unroll_loop_end
1981
+ #endif
1982
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1983
+ PointLightShadow pointLight;
1984
+ #pragma unroll_loop_start
1985
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1986
+ pointLight = pointLightShadows[ i ];
1987
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1988
+ }
1989
+ #pragma unroll_loop_end
1990
+ #endif
1991
+ #endif
1992
+ return shadow;
1993
+ }`,bf=`#ifdef USE_SKINNING
1994
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1995
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1996
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1997
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1998
+ #endif`,Ef=`#ifdef USE_SKINNING
1999
+ uniform mat4 bindMatrix;
2000
+ uniform mat4 bindMatrixInverse;
2001
+ uniform highp sampler2D boneTexture;
2002
+ mat4 getBoneMatrix( const in float i ) {
2003
+ int size = textureSize( boneTexture, 0 ).x;
2004
+ int j = int( i ) * 4;
2005
+ int x = j % size;
2006
+ int y = j / size;
2007
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2008
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2009
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2010
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2011
+ return mat4( v1, v2, v3, v4 );
2012
+ }
2013
+ #endif`,yf=`#ifdef USE_SKINNING
2014
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2015
+ vec4 skinned = vec4( 0.0 );
2016
+ skinned += boneMatX * skinVertex * skinWeight.x;
2017
+ skinned += boneMatY * skinVertex * skinWeight.y;
2018
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2019
+ skinned += boneMatW * skinVertex * skinWeight.w;
2020
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2021
+ #endif`,Tf=`#ifdef USE_SKINNING
2022
+ mat4 skinMatrix = mat4( 0.0 );
2023
+ skinMatrix += skinWeight.x * boneMatX;
2024
+ skinMatrix += skinWeight.y * boneMatY;
2025
+ skinMatrix += skinWeight.z * boneMatZ;
2026
+ skinMatrix += skinWeight.w * boneMatW;
2027
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2028
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2029
+ #ifdef USE_TANGENT
2030
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2031
+ #endif
2032
+ #endif`,Af=`float specularStrength;
2033
+ #ifdef USE_SPECULARMAP
2034
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2035
+ specularStrength = texelSpecular.r;
2036
+ #else
2037
+ specularStrength = 1.0;
2038
+ #endif`,Rf=`#ifdef USE_SPECULARMAP
2039
+ uniform sampler2D specularMap;
2040
+ #endif`,wf=`#if defined( TONE_MAPPING )
2041
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2042
+ #endif`,Cf=`#ifndef saturate
2043
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2044
+ #endif
2045
+ uniform float toneMappingExposure;
2046
+ vec3 LinearToneMapping( vec3 color ) {
2047
+ return saturate( toneMappingExposure * color );
2048
+ }
2049
+ vec3 ReinhardToneMapping( vec3 color ) {
2050
+ color *= toneMappingExposure;
2051
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2052
+ }
2053
+ vec3 CineonToneMapping( vec3 color ) {
2054
+ color *= toneMappingExposure;
2055
+ color = max( vec3( 0.0 ), color - 0.004 );
2056
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2057
+ }
2058
+ vec3 RRTAndODTFit( vec3 v ) {
2059
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2060
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2061
+ return a / b;
2062
+ }
2063
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2064
+ const mat3 ACESInputMat = mat3(
2065
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2066
+ vec3( 0.04823, 0.01566, 0.83777 )
2067
+ );
2068
+ const mat3 ACESOutputMat = mat3(
2069
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2070
+ vec3( -0.07367, -0.00605, 1.07602 )
2071
+ );
2072
+ color *= toneMappingExposure / 0.6;
2073
+ color = ACESInputMat * color;
2074
+ color = RRTAndODTFit( color );
2075
+ color = ACESOutputMat * color;
2076
+ return saturate( color );
2077
+ }
2078
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2079
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2080
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2081
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2082
+ );
2083
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2084
+ vec3( 0.6274, 0.0691, 0.0164 ),
2085
+ vec3( 0.3293, 0.9195, 0.0880 ),
2086
+ vec3( 0.0433, 0.0113, 0.8956 )
2087
+ );
2088
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2089
+ vec3 x2 = x * x;
2090
+ vec3 x4 = x2 * x2;
2091
+ return + 15.5 * x4 * x2
2092
+ - 40.14 * x4 * x
2093
+ + 31.96 * x4
2094
+ - 6.868 * x2 * x
2095
+ + 0.4298 * x2
2096
+ + 0.1191 * x
2097
+ - 0.00232;
2098
+ }
2099
+ vec3 AgXToneMapping( vec3 color ) {
2100
+ const mat3 AgXInsetMatrix = mat3(
2101
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2102
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2103
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2104
+ );
2105
+ const mat3 AgXOutsetMatrix = mat3(
2106
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2107
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2108
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2109
+ );
2110
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2111
+ color *= toneMappingExposure;
2112
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2113
+ color = AgXInsetMatrix * color;
2114
+ color = max( color, 1e-10 ); color = log2( color );
2115
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2116
+ color = clamp( color, 0.0, 1.0 );
2117
+ color = agxDefaultContrastApprox( color );
2118
+ color = AgXOutsetMatrix * color;
2119
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2120
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2121
+ color = clamp( color, 0.0, 1.0 );
2122
+ return color;
2123
+ }
2124
+ vec3 NeutralToneMapping( vec3 color ) {
2125
+ const float StartCompression = 0.8 - 0.04;
2126
+ const float Desaturation = 0.15;
2127
+ color *= toneMappingExposure;
2128
+ float x = min( color.r, min( color.g, color.b ) );
2129
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2130
+ color -= offset;
2131
+ float peak = max( color.r, max( color.g, color.b ) );
2132
+ if ( peak < StartCompression ) return color;
2133
+ float d = 1. - StartCompression;
2134
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2135
+ color *= newPeak / peak;
2136
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2137
+ return mix( color, vec3( newPeak ), g );
2138
+ }
2139
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Pf=`#ifdef USE_TRANSMISSION
2140
+ material.transmission = transmission;
2141
+ material.transmissionAlpha = 1.0;
2142
+ material.thickness = thickness;
2143
+ material.attenuationDistance = attenuationDistance;
2144
+ material.attenuationColor = attenuationColor;
2145
+ #ifdef USE_TRANSMISSIONMAP
2146
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2147
+ #endif
2148
+ #ifdef USE_THICKNESSMAP
2149
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2150
+ #endif
2151
+ vec3 pos = vWorldPosition;
2152
+ vec3 v = normalize( cameraPosition - pos );
2153
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2154
+ vec4 transmitted = getIBLVolumeRefraction(
2155
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2156
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2157
+ material.attenuationColor, material.attenuationDistance );
2158
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2159
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2160
+ #endif`,Df=`#ifdef USE_TRANSMISSION
2161
+ uniform float transmission;
2162
+ uniform float thickness;
2163
+ uniform float attenuationDistance;
2164
+ uniform vec3 attenuationColor;
2165
+ #ifdef USE_TRANSMISSIONMAP
2166
+ uniform sampler2D transmissionMap;
2167
+ #endif
2168
+ #ifdef USE_THICKNESSMAP
2169
+ uniform sampler2D thicknessMap;
2170
+ #endif
2171
+ uniform vec2 transmissionSamplerSize;
2172
+ uniform sampler2D transmissionSamplerMap;
2173
+ uniform mat4 modelMatrix;
2174
+ uniform mat4 projectionMatrix;
2175
+ varying vec3 vWorldPosition;
2176
+ float w0( float a ) {
2177
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2178
+ }
2179
+ float w1( float a ) {
2180
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2181
+ }
2182
+ float w2( float a ){
2183
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2184
+ }
2185
+ float w3( float a ) {
2186
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2187
+ }
2188
+ float g0( float a ) {
2189
+ return w0( a ) + w1( a );
2190
+ }
2191
+ float g1( float a ) {
2192
+ return w2( a ) + w3( a );
2193
+ }
2194
+ float h0( float a ) {
2195
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2196
+ }
2197
+ float h1( float a ) {
2198
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2199
+ }
2200
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2201
+ uv = uv * texelSize.zw + 0.5;
2202
+ vec2 iuv = floor( uv );
2203
+ vec2 fuv = fract( uv );
2204
+ float g0x = g0( fuv.x );
2205
+ float g1x = g1( fuv.x );
2206
+ float h0x = h0( fuv.x );
2207
+ float h1x = h1( fuv.x );
2208
+ float h0y = h0( fuv.y );
2209
+ float h1y = h1( fuv.y );
2210
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2211
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2212
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2213
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2214
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2215
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2216
+ }
2217
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2218
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2219
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2220
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2221
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2222
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2223
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2224
+ return mix( fSample, cSample, fract( lod ) );
2225
+ }
2226
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2227
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2228
+ vec3 modelScale;
2229
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2230
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2231
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2232
+ return normalize( refractionVector ) * thickness * modelScale;
2233
+ }
2234
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2235
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2236
+ }
2237
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2238
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2239
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2240
+ }
2241
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2242
+ if ( isinf( attenuationDistance ) ) {
2243
+ return vec3( 1.0 );
2244
+ } else {
2245
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2246
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2247
+ }
2248
+ }
2249
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2250
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2251
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2252
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2253
+ vec4 transmittedLight;
2254
+ vec3 transmittance;
2255
+ #ifdef USE_DISPERSION
2256
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2257
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2258
+ for ( int i = 0; i < 3; i ++ ) {
2259
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2260
+ vec3 refractedRayExit = position + transmissionRay;
2261
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2262
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2263
+ refractionCoords += 1.0;
2264
+ refractionCoords /= 2.0;
2265
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2266
+ transmittedLight[ i ] = transmissionSample[ i ];
2267
+ transmittedLight.a += transmissionSample.a;
2268
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2269
+ }
2270
+ transmittedLight.a /= 3.0;
2271
+ #else
2272
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2273
+ vec3 refractedRayExit = position + transmissionRay;
2274
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2275
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2276
+ refractionCoords += 1.0;
2277
+ refractionCoords /= 2.0;
2278
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2279
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2280
+ #endif
2281
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2282
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2283
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2284
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2285
+ }
2286
+ #endif`,Lf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2287
+ varying vec2 vUv;
2288
+ #endif
2289
+ #ifdef USE_MAP
2290
+ varying vec2 vMapUv;
2291
+ #endif
2292
+ #ifdef USE_ALPHAMAP
2293
+ varying vec2 vAlphaMapUv;
2294
+ #endif
2295
+ #ifdef USE_LIGHTMAP
2296
+ varying vec2 vLightMapUv;
2297
+ #endif
2298
+ #ifdef USE_AOMAP
2299
+ varying vec2 vAoMapUv;
2300
+ #endif
2301
+ #ifdef USE_BUMPMAP
2302
+ varying vec2 vBumpMapUv;
2303
+ #endif
2304
+ #ifdef USE_NORMALMAP
2305
+ varying vec2 vNormalMapUv;
2306
+ #endif
2307
+ #ifdef USE_EMISSIVEMAP
2308
+ varying vec2 vEmissiveMapUv;
2309
+ #endif
2310
+ #ifdef USE_METALNESSMAP
2311
+ varying vec2 vMetalnessMapUv;
2312
+ #endif
2313
+ #ifdef USE_ROUGHNESSMAP
2314
+ varying vec2 vRoughnessMapUv;
2315
+ #endif
2316
+ #ifdef USE_ANISOTROPYMAP
2317
+ varying vec2 vAnisotropyMapUv;
2318
+ #endif
2319
+ #ifdef USE_CLEARCOATMAP
2320
+ varying vec2 vClearcoatMapUv;
2321
+ #endif
2322
+ #ifdef USE_CLEARCOAT_NORMALMAP
2323
+ varying vec2 vClearcoatNormalMapUv;
2324
+ #endif
2325
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2326
+ varying vec2 vClearcoatRoughnessMapUv;
2327
+ #endif
2328
+ #ifdef USE_IRIDESCENCEMAP
2329
+ varying vec2 vIridescenceMapUv;
2330
+ #endif
2331
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2332
+ varying vec2 vIridescenceThicknessMapUv;
2333
+ #endif
2334
+ #ifdef USE_SHEEN_COLORMAP
2335
+ varying vec2 vSheenColorMapUv;
2336
+ #endif
2337
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2338
+ varying vec2 vSheenRoughnessMapUv;
2339
+ #endif
2340
+ #ifdef USE_SPECULARMAP
2341
+ varying vec2 vSpecularMapUv;
2342
+ #endif
2343
+ #ifdef USE_SPECULAR_COLORMAP
2344
+ varying vec2 vSpecularColorMapUv;
2345
+ #endif
2346
+ #ifdef USE_SPECULAR_INTENSITYMAP
2347
+ varying vec2 vSpecularIntensityMapUv;
2348
+ #endif
2349
+ #ifdef USE_TRANSMISSIONMAP
2350
+ uniform mat3 transmissionMapTransform;
2351
+ varying vec2 vTransmissionMapUv;
2352
+ #endif
2353
+ #ifdef USE_THICKNESSMAP
2354
+ uniform mat3 thicknessMapTransform;
2355
+ varying vec2 vThicknessMapUv;
2356
+ #endif`,Uf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2357
+ varying vec2 vUv;
2358
+ #endif
2359
+ #ifdef USE_MAP
2360
+ uniform mat3 mapTransform;
2361
+ varying vec2 vMapUv;
2362
+ #endif
2363
+ #ifdef USE_ALPHAMAP
2364
+ uniform mat3 alphaMapTransform;
2365
+ varying vec2 vAlphaMapUv;
2366
+ #endif
2367
+ #ifdef USE_LIGHTMAP
2368
+ uniform mat3 lightMapTransform;
2369
+ varying vec2 vLightMapUv;
2370
+ #endif
2371
+ #ifdef USE_AOMAP
2372
+ uniform mat3 aoMapTransform;
2373
+ varying vec2 vAoMapUv;
2374
+ #endif
2375
+ #ifdef USE_BUMPMAP
2376
+ uniform mat3 bumpMapTransform;
2377
+ varying vec2 vBumpMapUv;
2378
+ #endif
2379
+ #ifdef USE_NORMALMAP
2380
+ uniform mat3 normalMapTransform;
2381
+ varying vec2 vNormalMapUv;
2382
+ #endif
2383
+ #ifdef USE_DISPLACEMENTMAP
2384
+ uniform mat3 displacementMapTransform;
2385
+ varying vec2 vDisplacementMapUv;
2386
+ #endif
2387
+ #ifdef USE_EMISSIVEMAP
2388
+ uniform mat3 emissiveMapTransform;
2389
+ varying vec2 vEmissiveMapUv;
2390
+ #endif
2391
+ #ifdef USE_METALNESSMAP
2392
+ uniform mat3 metalnessMapTransform;
2393
+ varying vec2 vMetalnessMapUv;
2394
+ #endif
2395
+ #ifdef USE_ROUGHNESSMAP
2396
+ uniform mat3 roughnessMapTransform;
2397
+ varying vec2 vRoughnessMapUv;
2398
+ #endif
2399
+ #ifdef USE_ANISOTROPYMAP
2400
+ uniform mat3 anisotropyMapTransform;
2401
+ varying vec2 vAnisotropyMapUv;
2402
+ #endif
2403
+ #ifdef USE_CLEARCOATMAP
2404
+ uniform mat3 clearcoatMapTransform;
2405
+ varying vec2 vClearcoatMapUv;
2406
+ #endif
2407
+ #ifdef USE_CLEARCOAT_NORMALMAP
2408
+ uniform mat3 clearcoatNormalMapTransform;
2409
+ varying vec2 vClearcoatNormalMapUv;
2410
+ #endif
2411
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2412
+ uniform mat3 clearcoatRoughnessMapTransform;
2413
+ varying vec2 vClearcoatRoughnessMapUv;
2414
+ #endif
2415
+ #ifdef USE_SHEEN_COLORMAP
2416
+ uniform mat3 sheenColorMapTransform;
2417
+ varying vec2 vSheenColorMapUv;
2418
+ #endif
2419
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2420
+ uniform mat3 sheenRoughnessMapTransform;
2421
+ varying vec2 vSheenRoughnessMapUv;
2422
+ #endif
2423
+ #ifdef USE_IRIDESCENCEMAP
2424
+ uniform mat3 iridescenceMapTransform;
2425
+ varying vec2 vIridescenceMapUv;
2426
+ #endif
2427
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2428
+ uniform mat3 iridescenceThicknessMapTransform;
2429
+ varying vec2 vIridescenceThicknessMapUv;
2430
+ #endif
2431
+ #ifdef USE_SPECULARMAP
2432
+ uniform mat3 specularMapTransform;
2433
+ varying vec2 vSpecularMapUv;
2434
+ #endif
2435
+ #ifdef USE_SPECULAR_COLORMAP
2436
+ uniform mat3 specularColorMapTransform;
2437
+ varying vec2 vSpecularColorMapUv;
2438
+ #endif
2439
+ #ifdef USE_SPECULAR_INTENSITYMAP
2440
+ uniform mat3 specularIntensityMapTransform;
2441
+ varying vec2 vSpecularIntensityMapUv;
2442
+ #endif
2443
+ #ifdef USE_TRANSMISSIONMAP
2444
+ uniform mat3 transmissionMapTransform;
2445
+ varying vec2 vTransmissionMapUv;
2446
+ #endif
2447
+ #ifdef USE_THICKNESSMAP
2448
+ uniform mat3 thicknessMapTransform;
2449
+ varying vec2 vThicknessMapUv;
2450
+ #endif`,If=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2451
+ vUv = vec3( uv, 1 ).xy;
2452
+ #endif
2453
+ #ifdef USE_MAP
2454
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2455
+ #endif
2456
+ #ifdef USE_ALPHAMAP
2457
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2458
+ #endif
2459
+ #ifdef USE_LIGHTMAP
2460
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2461
+ #endif
2462
+ #ifdef USE_AOMAP
2463
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2464
+ #endif
2465
+ #ifdef USE_BUMPMAP
2466
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2467
+ #endif
2468
+ #ifdef USE_NORMALMAP
2469
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2470
+ #endif
2471
+ #ifdef USE_DISPLACEMENTMAP
2472
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2473
+ #endif
2474
+ #ifdef USE_EMISSIVEMAP
2475
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2476
+ #endif
2477
+ #ifdef USE_METALNESSMAP
2478
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2479
+ #endif
2480
+ #ifdef USE_ROUGHNESSMAP
2481
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2482
+ #endif
2483
+ #ifdef USE_ANISOTROPYMAP
2484
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2485
+ #endif
2486
+ #ifdef USE_CLEARCOATMAP
2487
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2488
+ #endif
2489
+ #ifdef USE_CLEARCOAT_NORMALMAP
2490
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2491
+ #endif
2492
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2493
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2494
+ #endif
2495
+ #ifdef USE_IRIDESCENCEMAP
2496
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2497
+ #endif
2498
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2499
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2500
+ #endif
2501
+ #ifdef USE_SHEEN_COLORMAP
2502
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2503
+ #endif
2504
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2505
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2506
+ #endif
2507
+ #ifdef USE_SPECULARMAP
2508
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2509
+ #endif
2510
+ #ifdef USE_SPECULAR_COLORMAP
2511
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2512
+ #endif
2513
+ #ifdef USE_SPECULAR_INTENSITYMAP
2514
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2515
+ #endif
2516
+ #ifdef USE_TRANSMISSIONMAP
2517
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2518
+ #endif
2519
+ #ifdef USE_THICKNESSMAP
2520
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2521
+ #endif`,Nf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2522
+ vec4 worldPosition = vec4( transformed, 1.0 );
2523
+ #ifdef USE_BATCHING
2524
+ worldPosition = batchingMatrix * worldPosition;
2525
+ #endif
2526
+ #ifdef USE_INSTANCING
2527
+ worldPosition = instanceMatrix * worldPosition;
2528
+ #endif
2529
+ worldPosition = modelMatrix * worldPosition;
2530
+ #endif`;const Ff=`varying vec2 vUv;
2531
+ uniform mat3 uvTransform;
2532
+ void main() {
2533
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2534
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2535
+ }`,Of=`uniform sampler2D t2D;
2536
+ uniform float backgroundIntensity;
2537
+ varying vec2 vUv;
2538
+ void main() {
2539
+ vec4 texColor = texture2D( t2D, vUv );
2540
+ #ifdef DECODE_VIDEO_TEXTURE
2541
+ 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 );
2542
+ #endif
2543
+ texColor.rgb *= backgroundIntensity;
2544
+ gl_FragColor = texColor;
2545
+ #include <tonemapping_fragment>
2546
+ #include <colorspace_fragment>
2547
+ }`,Bf=`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
+ }`,zf=`#ifdef ENVMAP_TYPE_CUBE
2555
+ uniform samplerCube envMap;
2556
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2557
+ uniform sampler2D envMap;
2558
+ #endif
2559
+ uniform float flipEnvMap;
2560
+ uniform float backgroundBlurriness;
2561
+ uniform float backgroundIntensity;
2562
+ uniform mat3 backgroundRotation;
2563
+ varying vec3 vWorldDirection;
2564
+ #include <cube_uv_reflection_fragment>
2565
+ void main() {
2566
+ #ifdef ENVMAP_TYPE_CUBE
2567
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2568
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2569
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2570
+ #else
2571
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2572
+ #endif
2573
+ texColor.rgb *= backgroundIntensity;
2574
+ gl_FragColor = texColor;
2575
+ #include <tonemapping_fragment>
2576
+ #include <colorspace_fragment>
2577
+ }`,Vf=`varying vec3 vWorldDirection;
2578
+ #include <common>
2579
+ void main() {
2580
+ vWorldDirection = transformDirection( position, modelMatrix );
2581
+ #include <begin_vertex>
2582
+ #include <project_vertex>
2583
+ gl_Position.z = gl_Position.w;
2584
+ }`,Gf=`uniform samplerCube tCube;
2585
+ uniform float tFlip;
2586
+ uniform float opacity;
2587
+ varying vec3 vWorldDirection;
2588
+ void main() {
2589
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2590
+ gl_FragColor = texColor;
2591
+ gl_FragColor.a *= opacity;
2592
+ #include <tonemapping_fragment>
2593
+ #include <colorspace_fragment>
2594
+ }`,Hf=`#include <common>
2595
+ #include <batching_pars_vertex>
2596
+ #include <uv_pars_vertex>
2597
+ #include <displacementmap_pars_vertex>
2598
+ #include <morphtarget_pars_vertex>
2599
+ #include <skinning_pars_vertex>
2600
+ #include <logdepthbuf_pars_vertex>
2601
+ #include <clipping_planes_pars_vertex>
2602
+ varying vec2 vHighPrecisionZW;
2603
+ void main() {
2604
+ #include <uv_vertex>
2605
+ #include <batching_vertex>
2606
+ #include <skinbase_vertex>
2607
+ #include <morphinstance_vertex>
2608
+ #ifdef USE_DISPLACEMENTMAP
2609
+ #include <beginnormal_vertex>
2610
+ #include <morphnormal_vertex>
2611
+ #include <skinnormal_vertex>
2612
+ #endif
2613
+ #include <begin_vertex>
2614
+ #include <morphtarget_vertex>
2615
+ #include <skinning_vertex>
2616
+ #include <displacementmap_vertex>
2617
+ #include <project_vertex>
2618
+ #include <logdepthbuf_vertex>
2619
+ #include <clipping_planes_vertex>
2620
+ vHighPrecisionZW = gl_Position.zw;
2621
+ }`,kf=`#if DEPTH_PACKING == 3200
2622
+ uniform float opacity;
2623
+ #endif
2624
+ #include <common>
2625
+ #include <packing>
2626
+ #include <uv_pars_fragment>
2627
+ #include <map_pars_fragment>
2628
+ #include <alphamap_pars_fragment>
2629
+ #include <alphatest_pars_fragment>
2630
+ #include <alphahash_pars_fragment>
2631
+ #include <logdepthbuf_pars_fragment>
2632
+ #include <clipping_planes_pars_fragment>
2633
+ varying vec2 vHighPrecisionZW;
2634
+ void main() {
2635
+ vec4 diffuseColor = vec4( 1.0 );
2636
+ #include <clipping_planes_fragment>
2637
+ #if DEPTH_PACKING == 3200
2638
+ diffuseColor.a = opacity;
2639
+ #endif
2640
+ #include <map_fragment>
2641
+ #include <alphamap_fragment>
2642
+ #include <alphatest_fragment>
2643
+ #include <alphahash_fragment>
2644
+ #include <logdepthbuf_fragment>
2645
+ #ifdef USE_REVERSED_DEPTH_BUFFER
2646
+ float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
2647
+ #else
2648
+ float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
2649
+ #endif
2650
+ #if DEPTH_PACKING == 3200
2651
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2652
+ #elif DEPTH_PACKING == 3201
2653
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2654
+ #elif DEPTH_PACKING == 3202
2655
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2656
+ #elif DEPTH_PACKING == 3203
2657
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2658
+ #endif
2659
+ }`,Wf=`#define DISTANCE
2660
+ varying vec3 vWorldPosition;
2661
+ #include <common>
2662
+ #include <batching_pars_vertex>
2663
+ #include <uv_pars_vertex>
2664
+ #include <displacementmap_pars_vertex>
2665
+ #include <morphtarget_pars_vertex>
2666
+ #include <skinning_pars_vertex>
2667
+ #include <clipping_planes_pars_vertex>
2668
+ void main() {
2669
+ #include <uv_vertex>
2670
+ #include <batching_vertex>
2671
+ #include <skinbase_vertex>
2672
+ #include <morphinstance_vertex>
2673
+ #ifdef USE_DISPLACEMENTMAP
2674
+ #include <beginnormal_vertex>
2675
+ #include <morphnormal_vertex>
2676
+ #include <skinnormal_vertex>
2677
+ #endif
2678
+ #include <begin_vertex>
2679
+ #include <morphtarget_vertex>
2680
+ #include <skinning_vertex>
2681
+ #include <displacementmap_vertex>
2682
+ #include <project_vertex>
2683
+ #include <worldpos_vertex>
2684
+ #include <clipping_planes_vertex>
2685
+ vWorldPosition = worldPosition.xyz;
2686
+ }`,Xf=`#define DISTANCE
2687
+ uniform vec3 referencePosition;
2688
+ uniform float nearDistance;
2689
+ uniform float farDistance;
2690
+ varying vec3 vWorldPosition;
2691
+ #include <common>
2692
+ #include <packing>
2693
+ #include <uv_pars_fragment>
2694
+ #include <map_pars_fragment>
2695
+ #include <alphamap_pars_fragment>
2696
+ #include <alphatest_pars_fragment>
2697
+ #include <alphahash_pars_fragment>
2698
+ #include <clipping_planes_pars_fragment>
2699
+ void main () {
2700
+ vec4 diffuseColor = vec4( 1.0 );
2701
+ #include <clipping_planes_fragment>
2702
+ #include <map_fragment>
2703
+ #include <alphamap_fragment>
2704
+ #include <alphatest_fragment>
2705
+ #include <alphahash_fragment>
2706
+ float dist = length( vWorldPosition - referencePosition );
2707
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2708
+ dist = saturate( dist );
2709
+ gl_FragColor = packDepthToRGBA( dist );
2710
+ }`,qf=`varying vec3 vWorldDirection;
2711
+ #include <common>
2712
+ void main() {
2713
+ vWorldDirection = transformDirection( position, modelMatrix );
2714
+ #include <begin_vertex>
2715
+ #include <project_vertex>
2716
+ }`,Yf=`uniform sampler2D tEquirect;
2717
+ varying vec3 vWorldDirection;
2718
+ #include <common>
2719
+ void main() {
2720
+ vec3 direction = normalize( vWorldDirection );
2721
+ vec2 sampleUV = equirectUv( direction );
2722
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2723
+ #include <tonemapping_fragment>
2724
+ #include <colorspace_fragment>
2725
+ }`,Kf=`uniform float scale;
2726
+ attribute float lineDistance;
2727
+ varying float vLineDistance;
2728
+ #include <common>
2729
+ #include <uv_pars_vertex>
2730
+ #include <color_pars_vertex>
2731
+ #include <fog_pars_vertex>
2732
+ #include <morphtarget_pars_vertex>
2733
+ #include <logdepthbuf_pars_vertex>
2734
+ #include <clipping_planes_pars_vertex>
2735
+ void main() {
2736
+ vLineDistance = scale * lineDistance;
2737
+ #include <uv_vertex>
2738
+ #include <color_vertex>
2739
+ #include <morphinstance_vertex>
2740
+ #include <morphcolor_vertex>
2741
+ #include <begin_vertex>
2742
+ #include <morphtarget_vertex>
2743
+ #include <project_vertex>
2744
+ #include <logdepthbuf_vertex>
2745
+ #include <clipping_planes_vertex>
2746
+ #include <fog_vertex>
2747
+ }`,Zf=`uniform vec3 diffuse;
2748
+ uniform float opacity;
2749
+ uniform float dashSize;
2750
+ uniform float totalSize;
2751
+ varying float vLineDistance;
2752
+ #include <common>
2753
+ #include <color_pars_fragment>
2754
+ #include <uv_pars_fragment>
2755
+ #include <map_pars_fragment>
2756
+ #include <fog_pars_fragment>
2757
+ #include <logdepthbuf_pars_fragment>
2758
+ #include <clipping_planes_pars_fragment>
2759
+ void main() {
2760
+ vec4 diffuseColor = vec4( diffuse, opacity );
2761
+ #include <clipping_planes_fragment>
2762
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2763
+ discard;
2764
+ }
2765
+ vec3 outgoingLight = vec3( 0.0 );
2766
+ #include <logdepthbuf_fragment>
2767
+ #include <map_fragment>
2768
+ #include <color_fragment>
2769
+ outgoingLight = diffuseColor.rgb;
2770
+ #include <opaque_fragment>
2771
+ #include <tonemapping_fragment>
2772
+ #include <colorspace_fragment>
2773
+ #include <fog_fragment>
2774
+ #include <premultiplied_alpha_fragment>
2775
+ }`,$f=`#include <common>
2776
+ #include <batching_pars_vertex>
2777
+ #include <uv_pars_vertex>
2778
+ #include <envmap_pars_vertex>
2779
+ #include <color_pars_vertex>
2780
+ #include <fog_pars_vertex>
2781
+ #include <morphtarget_pars_vertex>
2782
+ #include <skinning_pars_vertex>
2783
+ #include <logdepthbuf_pars_vertex>
2784
+ #include <clipping_planes_pars_vertex>
2785
+ void main() {
2786
+ #include <uv_vertex>
2787
+ #include <color_vertex>
2788
+ #include <morphinstance_vertex>
2789
+ #include <morphcolor_vertex>
2790
+ #include <batching_vertex>
2791
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2792
+ #include <beginnormal_vertex>
2793
+ #include <morphnormal_vertex>
2794
+ #include <skinbase_vertex>
2795
+ #include <skinnormal_vertex>
2796
+ #include <defaultnormal_vertex>
2797
+ #endif
2798
+ #include <begin_vertex>
2799
+ #include <morphtarget_vertex>
2800
+ #include <skinning_vertex>
2801
+ #include <project_vertex>
2802
+ #include <logdepthbuf_vertex>
2803
+ #include <clipping_planes_vertex>
2804
+ #include <worldpos_vertex>
2805
+ #include <envmap_vertex>
2806
+ #include <fog_vertex>
2807
+ }`,jf=`uniform vec3 diffuse;
2808
+ uniform float opacity;
2809
+ #ifndef FLAT_SHADED
2810
+ varying vec3 vNormal;
2811
+ #endif
2812
+ #include <common>
2813
+ #include <dithering_pars_fragment>
2814
+ #include <color_pars_fragment>
2815
+ #include <uv_pars_fragment>
2816
+ #include <map_pars_fragment>
2817
+ #include <alphamap_pars_fragment>
2818
+ #include <alphatest_pars_fragment>
2819
+ #include <alphahash_pars_fragment>
2820
+ #include <aomap_pars_fragment>
2821
+ #include <lightmap_pars_fragment>
2822
+ #include <envmap_common_pars_fragment>
2823
+ #include <envmap_pars_fragment>
2824
+ #include <fog_pars_fragment>
2825
+ #include <specularmap_pars_fragment>
2826
+ #include <logdepthbuf_pars_fragment>
2827
+ #include <clipping_planes_pars_fragment>
2828
+ void main() {
2829
+ vec4 diffuseColor = vec4( diffuse, opacity );
2830
+ #include <clipping_planes_fragment>
2831
+ #include <logdepthbuf_fragment>
2832
+ #include <map_fragment>
2833
+ #include <color_fragment>
2834
+ #include <alphamap_fragment>
2835
+ #include <alphatest_fragment>
2836
+ #include <alphahash_fragment>
2837
+ #include <specularmap_fragment>
2838
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2839
+ #ifdef USE_LIGHTMAP
2840
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2841
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2842
+ #else
2843
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2844
+ #endif
2845
+ #include <aomap_fragment>
2846
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2847
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2848
+ #include <envmap_fragment>
2849
+ #include <opaque_fragment>
2850
+ #include <tonemapping_fragment>
2851
+ #include <colorspace_fragment>
2852
+ #include <fog_fragment>
2853
+ #include <premultiplied_alpha_fragment>
2854
+ #include <dithering_fragment>
2855
+ }`,Jf=`#define LAMBERT
2856
+ varying vec3 vViewPosition;
2857
+ #include <common>
2858
+ #include <batching_pars_vertex>
2859
+ #include <uv_pars_vertex>
2860
+ #include <displacementmap_pars_vertex>
2861
+ #include <envmap_pars_vertex>
2862
+ #include <color_pars_vertex>
2863
+ #include <fog_pars_vertex>
2864
+ #include <normal_pars_vertex>
2865
+ #include <morphtarget_pars_vertex>
2866
+ #include <skinning_pars_vertex>
2867
+ #include <shadowmap_pars_vertex>
2868
+ #include <logdepthbuf_pars_vertex>
2869
+ #include <clipping_planes_pars_vertex>
2870
+ void main() {
2871
+ #include <uv_vertex>
2872
+ #include <color_vertex>
2873
+ #include <morphinstance_vertex>
2874
+ #include <morphcolor_vertex>
2875
+ #include <batching_vertex>
2876
+ #include <beginnormal_vertex>
2877
+ #include <morphnormal_vertex>
2878
+ #include <skinbase_vertex>
2879
+ #include <skinnormal_vertex>
2880
+ #include <defaultnormal_vertex>
2881
+ #include <normal_vertex>
2882
+ #include <begin_vertex>
2883
+ #include <morphtarget_vertex>
2884
+ #include <skinning_vertex>
2885
+ #include <displacementmap_vertex>
2886
+ #include <project_vertex>
2887
+ #include <logdepthbuf_vertex>
2888
+ #include <clipping_planes_vertex>
2889
+ vViewPosition = - mvPosition.xyz;
2890
+ #include <worldpos_vertex>
2891
+ #include <envmap_vertex>
2892
+ #include <shadowmap_vertex>
2893
+ #include <fog_vertex>
2894
+ }`,Qf=`#define LAMBERT
2895
+ uniform vec3 diffuse;
2896
+ uniform vec3 emissive;
2897
+ uniform float opacity;
2898
+ #include <common>
2899
+ #include <packing>
2900
+ #include <dithering_pars_fragment>
2901
+ #include <color_pars_fragment>
2902
+ #include <uv_pars_fragment>
2903
+ #include <map_pars_fragment>
2904
+ #include <alphamap_pars_fragment>
2905
+ #include <alphatest_pars_fragment>
2906
+ #include <alphahash_pars_fragment>
2907
+ #include <aomap_pars_fragment>
2908
+ #include <lightmap_pars_fragment>
2909
+ #include <emissivemap_pars_fragment>
2910
+ #include <envmap_common_pars_fragment>
2911
+ #include <envmap_pars_fragment>
2912
+ #include <fog_pars_fragment>
2913
+ #include <bsdfs>
2914
+ #include <lights_pars_begin>
2915
+ #include <normal_pars_fragment>
2916
+ #include <lights_lambert_pars_fragment>
2917
+ #include <shadowmap_pars_fragment>
2918
+ #include <bumpmap_pars_fragment>
2919
+ #include <normalmap_pars_fragment>
2920
+ #include <specularmap_pars_fragment>
2921
+ #include <logdepthbuf_pars_fragment>
2922
+ #include <clipping_planes_pars_fragment>
2923
+ void main() {
2924
+ vec4 diffuseColor = vec4( diffuse, opacity );
2925
+ #include <clipping_planes_fragment>
2926
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2927
+ vec3 totalEmissiveRadiance = emissive;
2928
+ #include <logdepthbuf_fragment>
2929
+ #include <map_fragment>
2930
+ #include <color_fragment>
2931
+ #include <alphamap_fragment>
2932
+ #include <alphatest_fragment>
2933
+ #include <alphahash_fragment>
2934
+ #include <specularmap_fragment>
2935
+ #include <normal_fragment_begin>
2936
+ #include <normal_fragment_maps>
2937
+ #include <emissivemap_fragment>
2938
+ #include <lights_lambert_fragment>
2939
+ #include <lights_fragment_begin>
2940
+ #include <lights_fragment_maps>
2941
+ #include <lights_fragment_end>
2942
+ #include <aomap_fragment>
2943
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2944
+ #include <envmap_fragment>
2945
+ #include <opaque_fragment>
2946
+ #include <tonemapping_fragment>
2947
+ #include <colorspace_fragment>
2948
+ #include <fog_fragment>
2949
+ #include <premultiplied_alpha_fragment>
2950
+ #include <dithering_fragment>
2951
+ }`,eh=`#define MATCAP
2952
+ varying vec3 vViewPosition;
2953
+ #include <common>
2954
+ #include <batching_pars_vertex>
2955
+ #include <uv_pars_vertex>
2956
+ #include <color_pars_vertex>
2957
+ #include <displacementmap_pars_vertex>
2958
+ #include <fog_pars_vertex>
2959
+ #include <normal_pars_vertex>
2960
+ #include <morphtarget_pars_vertex>
2961
+ #include <skinning_pars_vertex>
2962
+ #include <logdepthbuf_pars_vertex>
2963
+ #include <clipping_planes_pars_vertex>
2964
+ void main() {
2965
+ #include <uv_vertex>
2966
+ #include <color_vertex>
2967
+ #include <morphinstance_vertex>
2968
+ #include <morphcolor_vertex>
2969
+ #include <batching_vertex>
2970
+ #include <beginnormal_vertex>
2971
+ #include <morphnormal_vertex>
2972
+ #include <skinbase_vertex>
2973
+ #include <skinnormal_vertex>
2974
+ #include <defaultnormal_vertex>
2975
+ #include <normal_vertex>
2976
+ #include <begin_vertex>
2977
+ #include <morphtarget_vertex>
2978
+ #include <skinning_vertex>
2979
+ #include <displacementmap_vertex>
2980
+ #include <project_vertex>
2981
+ #include <logdepthbuf_vertex>
2982
+ #include <clipping_planes_vertex>
2983
+ #include <fog_vertex>
2984
+ vViewPosition = - mvPosition.xyz;
2985
+ }`,th=`#define MATCAP
2986
+ uniform vec3 diffuse;
2987
+ uniform float opacity;
2988
+ uniform sampler2D matcap;
2989
+ varying vec3 vViewPosition;
2990
+ #include <common>
2991
+ #include <dithering_pars_fragment>
2992
+ #include <color_pars_fragment>
2993
+ #include <uv_pars_fragment>
2994
+ #include <map_pars_fragment>
2995
+ #include <alphamap_pars_fragment>
2996
+ #include <alphatest_pars_fragment>
2997
+ #include <alphahash_pars_fragment>
2998
+ #include <fog_pars_fragment>
2999
+ #include <normal_pars_fragment>
3000
+ #include <bumpmap_pars_fragment>
3001
+ #include <normalmap_pars_fragment>
3002
+ #include <logdepthbuf_pars_fragment>
3003
+ #include <clipping_planes_pars_fragment>
3004
+ void main() {
3005
+ vec4 diffuseColor = vec4( diffuse, opacity );
3006
+ #include <clipping_planes_fragment>
3007
+ #include <logdepthbuf_fragment>
3008
+ #include <map_fragment>
3009
+ #include <color_fragment>
3010
+ #include <alphamap_fragment>
3011
+ #include <alphatest_fragment>
3012
+ #include <alphahash_fragment>
3013
+ #include <normal_fragment_begin>
3014
+ #include <normal_fragment_maps>
3015
+ vec3 viewDir = normalize( vViewPosition );
3016
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3017
+ vec3 y = cross( viewDir, x );
3018
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3019
+ #ifdef USE_MATCAP
3020
+ vec4 matcapColor = texture2D( matcap, uv );
3021
+ #else
3022
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3023
+ #endif
3024
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3025
+ #include <opaque_fragment>
3026
+ #include <tonemapping_fragment>
3027
+ #include <colorspace_fragment>
3028
+ #include <fog_fragment>
3029
+ #include <premultiplied_alpha_fragment>
3030
+ #include <dithering_fragment>
3031
+ }`,nh=`#define NORMAL
3032
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3033
+ varying vec3 vViewPosition;
3034
+ #endif
3035
+ #include <common>
3036
+ #include <batching_pars_vertex>
3037
+ #include <uv_pars_vertex>
3038
+ #include <displacementmap_pars_vertex>
3039
+ #include <normal_pars_vertex>
3040
+ #include <morphtarget_pars_vertex>
3041
+ #include <skinning_pars_vertex>
3042
+ #include <logdepthbuf_pars_vertex>
3043
+ #include <clipping_planes_pars_vertex>
3044
+ void main() {
3045
+ #include <uv_vertex>
3046
+ #include <batching_vertex>
3047
+ #include <beginnormal_vertex>
3048
+ #include <morphinstance_vertex>
3049
+ #include <morphnormal_vertex>
3050
+ #include <skinbase_vertex>
3051
+ #include <skinnormal_vertex>
3052
+ #include <defaultnormal_vertex>
3053
+ #include <normal_vertex>
3054
+ #include <begin_vertex>
3055
+ #include <morphtarget_vertex>
3056
+ #include <skinning_vertex>
3057
+ #include <displacementmap_vertex>
3058
+ #include <project_vertex>
3059
+ #include <logdepthbuf_vertex>
3060
+ #include <clipping_planes_vertex>
3061
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3062
+ vViewPosition = - mvPosition.xyz;
3063
+ #endif
3064
+ }`,ih=`#define NORMAL
3065
+ uniform float opacity;
3066
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3067
+ varying vec3 vViewPosition;
3068
+ #endif
3069
+ #include <packing>
3070
+ #include <uv_pars_fragment>
3071
+ #include <normal_pars_fragment>
3072
+ #include <bumpmap_pars_fragment>
3073
+ #include <normalmap_pars_fragment>
3074
+ #include <logdepthbuf_pars_fragment>
3075
+ #include <clipping_planes_pars_fragment>
3076
+ void main() {
3077
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3078
+ #include <clipping_planes_fragment>
3079
+ #include <logdepthbuf_fragment>
3080
+ #include <normal_fragment_begin>
3081
+ #include <normal_fragment_maps>
3082
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3083
+ #ifdef OPAQUE
3084
+ gl_FragColor.a = 1.0;
3085
+ #endif
3086
+ }`,rh=`#define PHONG
3087
+ varying vec3 vViewPosition;
3088
+ #include <common>
3089
+ #include <batching_pars_vertex>
3090
+ #include <uv_pars_vertex>
3091
+ #include <displacementmap_pars_vertex>
3092
+ #include <envmap_pars_vertex>
3093
+ #include <color_pars_vertex>
3094
+ #include <fog_pars_vertex>
3095
+ #include <normal_pars_vertex>
3096
+ #include <morphtarget_pars_vertex>
3097
+ #include <skinning_pars_vertex>
3098
+ #include <shadowmap_pars_vertex>
3099
+ #include <logdepthbuf_pars_vertex>
3100
+ #include <clipping_planes_pars_vertex>
3101
+ void main() {
3102
+ #include <uv_vertex>
3103
+ #include <color_vertex>
3104
+ #include <morphcolor_vertex>
3105
+ #include <batching_vertex>
3106
+ #include <beginnormal_vertex>
3107
+ #include <morphinstance_vertex>
3108
+ #include <morphnormal_vertex>
3109
+ #include <skinbase_vertex>
3110
+ #include <skinnormal_vertex>
3111
+ #include <defaultnormal_vertex>
3112
+ #include <normal_vertex>
3113
+ #include <begin_vertex>
3114
+ #include <morphtarget_vertex>
3115
+ #include <skinning_vertex>
3116
+ #include <displacementmap_vertex>
3117
+ #include <project_vertex>
3118
+ #include <logdepthbuf_vertex>
3119
+ #include <clipping_planes_vertex>
3120
+ vViewPosition = - mvPosition.xyz;
3121
+ #include <worldpos_vertex>
3122
+ #include <envmap_vertex>
3123
+ #include <shadowmap_vertex>
3124
+ #include <fog_vertex>
3125
+ }`,sh=`#define PHONG
3126
+ uniform vec3 diffuse;
3127
+ uniform vec3 emissive;
3128
+ uniform vec3 specular;
3129
+ uniform float shininess;
3130
+ uniform float opacity;
3131
+ #include <common>
3132
+ #include <packing>
3133
+ #include <dithering_pars_fragment>
3134
+ #include <color_pars_fragment>
3135
+ #include <uv_pars_fragment>
3136
+ #include <map_pars_fragment>
3137
+ #include <alphamap_pars_fragment>
3138
+ #include <alphatest_pars_fragment>
3139
+ #include <alphahash_pars_fragment>
3140
+ #include <aomap_pars_fragment>
3141
+ #include <lightmap_pars_fragment>
3142
+ #include <emissivemap_pars_fragment>
3143
+ #include <envmap_common_pars_fragment>
3144
+ #include <envmap_pars_fragment>
3145
+ #include <fog_pars_fragment>
3146
+ #include <bsdfs>
3147
+ #include <lights_pars_begin>
3148
+ #include <normal_pars_fragment>
3149
+ #include <lights_phong_pars_fragment>
3150
+ #include <shadowmap_pars_fragment>
3151
+ #include <bumpmap_pars_fragment>
3152
+ #include <normalmap_pars_fragment>
3153
+ #include <specularmap_pars_fragment>
3154
+ #include <logdepthbuf_pars_fragment>
3155
+ #include <clipping_planes_pars_fragment>
3156
+ void main() {
3157
+ vec4 diffuseColor = vec4( diffuse, opacity );
3158
+ #include <clipping_planes_fragment>
3159
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3160
+ vec3 totalEmissiveRadiance = emissive;
3161
+ #include <logdepthbuf_fragment>
3162
+ #include <map_fragment>
3163
+ #include <color_fragment>
3164
+ #include <alphamap_fragment>
3165
+ #include <alphatest_fragment>
3166
+ #include <alphahash_fragment>
3167
+ #include <specularmap_fragment>
3168
+ #include <normal_fragment_begin>
3169
+ #include <normal_fragment_maps>
3170
+ #include <emissivemap_fragment>
3171
+ #include <lights_phong_fragment>
3172
+ #include <lights_fragment_begin>
3173
+ #include <lights_fragment_maps>
3174
+ #include <lights_fragment_end>
3175
+ #include <aomap_fragment>
3176
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3177
+ #include <envmap_fragment>
3178
+ #include <opaque_fragment>
3179
+ #include <tonemapping_fragment>
3180
+ #include <colorspace_fragment>
3181
+ #include <fog_fragment>
3182
+ #include <premultiplied_alpha_fragment>
3183
+ #include <dithering_fragment>
3184
+ }`,ah=`#define STANDARD
3185
+ varying vec3 vViewPosition;
3186
+ #ifdef USE_TRANSMISSION
3187
+ varying vec3 vWorldPosition;
3188
+ #endif
3189
+ #include <common>
3190
+ #include <batching_pars_vertex>
3191
+ #include <uv_pars_vertex>
3192
+ #include <displacementmap_pars_vertex>
3193
+ #include <color_pars_vertex>
3194
+ #include <fog_pars_vertex>
3195
+ #include <normal_pars_vertex>
3196
+ #include <morphtarget_pars_vertex>
3197
+ #include <skinning_pars_vertex>
3198
+ #include <shadowmap_pars_vertex>
3199
+ #include <logdepthbuf_pars_vertex>
3200
+ #include <clipping_planes_pars_vertex>
3201
+ void main() {
3202
+ #include <uv_vertex>
3203
+ #include <color_vertex>
3204
+ #include <morphinstance_vertex>
3205
+ #include <morphcolor_vertex>
3206
+ #include <batching_vertex>
3207
+ #include <beginnormal_vertex>
3208
+ #include <morphnormal_vertex>
3209
+ #include <skinbase_vertex>
3210
+ #include <skinnormal_vertex>
3211
+ #include <defaultnormal_vertex>
3212
+ #include <normal_vertex>
3213
+ #include <begin_vertex>
3214
+ #include <morphtarget_vertex>
3215
+ #include <skinning_vertex>
3216
+ #include <displacementmap_vertex>
3217
+ #include <project_vertex>
3218
+ #include <logdepthbuf_vertex>
3219
+ #include <clipping_planes_vertex>
3220
+ vViewPosition = - mvPosition.xyz;
3221
+ #include <worldpos_vertex>
3222
+ #include <shadowmap_vertex>
3223
+ #include <fog_vertex>
3224
+ #ifdef USE_TRANSMISSION
3225
+ vWorldPosition = worldPosition.xyz;
3226
+ #endif
3227
+ }`,oh=`#define STANDARD
3228
+ #ifdef PHYSICAL
3229
+ #define IOR
3230
+ #define USE_SPECULAR
3231
+ #endif
3232
+ uniform vec3 diffuse;
3233
+ uniform vec3 emissive;
3234
+ uniform float roughness;
3235
+ uniform float metalness;
3236
+ uniform float opacity;
3237
+ #ifdef IOR
3238
+ uniform float ior;
3239
+ #endif
3240
+ #ifdef USE_SPECULAR
3241
+ uniform float specularIntensity;
3242
+ uniform vec3 specularColor;
3243
+ #ifdef USE_SPECULAR_COLORMAP
3244
+ uniform sampler2D specularColorMap;
3245
+ #endif
3246
+ #ifdef USE_SPECULAR_INTENSITYMAP
3247
+ uniform sampler2D specularIntensityMap;
3248
+ #endif
3249
+ #endif
3250
+ #ifdef USE_CLEARCOAT
3251
+ uniform float clearcoat;
3252
+ uniform float clearcoatRoughness;
3253
+ #endif
3254
+ #ifdef USE_DISPERSION
3255
+ uniform float dispersion;
3256
+ #endif
3257
+ #ifdef USE_IRIDESCENCE
3258
+ uniform float iridescence;
3259
+ uniform float iridescenceIOR;
3260
+ uniform float iridescenceThicknessMinimum;
3261
+ uniform float iridescenceThicknessMaximum;
3262
+ #endif
3263
+ #ifdef USE_SHEEN
3264
+ uniform vec3 sheenColor;
3265
+ uniform float sheenRoughness;
3266
+ #ifdef USE_SHEEN_COLORMAP
3267
+ uniform sampler2D sheenColorMap;
3268
+ #endif
3269
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3270
+ uniform sampler2D sheenRoughnessMap;
3271
+ #endif
3272
+ #endif
3273
+ #ifdef USE_ANISOTROPY
3274
+ uniform vec2 anisotropyVector;
3275
+ #ifdef USE_ANISOTROPYMAP
3276
+ uniform sampler2D anisotropyMap;
3277
+ #endif
3278
+ #endif
3279
+ varying vec3 vViewPosition;
3280
+ #include <common>
3281
+ #include <packing>
3282
+ #include <dithering_pars_fragment>
3283
+ #include <color_pars_fragment>
3284
+ #include <uv_pars_fragment>
3285
+ #include <map_pars_fragment>
3286
+ #include <alphamap_pars_fragment>
3287
+ #include <alphatest_pars_fragment>
3288
+ #include <alphahash_pars_fragment>
3289
+ #include <aomap_pars_fragment>
3290
+ #include <lightmap_pars_fragment>
3291
+ #include <emissivemap_pars_fragment>
3292
+ #include <iridescence_fragment>
3293
+ #include <cube_uv_reflection_fragment>
3294
+ #include <envmap_common_pars_fragment>
3295
+ #include <envmap_physical_pars_fragment>
3296
+ #include <fog_pars_fragment>
3297
+ #include <lights_pars_begin>
3298
+ #include <normal_pars_fragment>
3299
+ #include <lights_physical_pars_fragment>
3300
+ #include <transmission_pars_fragment>
3301
+ #include <shadowmap_pars_fragment>
3302
+ #include <bumpmap_pars_fragment>
3303
+ #include <normalmap_pars_fragment>
3304
+ #include <clearcoat_pars_fragment>
3305
+ #include <iridescence_pars_fragment>
3306
+ #include <roughnessmap_pars_fragment>
3307
+ #include <metalnessmap_pars_fragment>
3308
+ #include <logdepthbuf_pars_fragment>
3309
+ #include <clipping_planes_pars_fragment>
3310
+ void main() {
3311
+ vec4 diffuseColor = vec4( diffuse, opacity );
3312
+ #include <clipping_planes_fragment>
3313
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3314
+ vec3 totalEmissiveRadiance = emissive;
3315
+ #include <logdepthbuf_fragment>
3316
+ #include <map_fragment>
3317
+ #include <color_fragment>
3318
+ #include <alphamap_fragment>
3319
+ #include <alphatest_fragment>
3320
+ #include <alphahash_fragment>
3321
+ #include <roughnessmap_fragment>
3322
+ #include <metalnessmap_fragment>
3323
+ #include <normal_fragment_begin>
3324
+ #include <normal_fragment_maps>
3325
+ #include <clearcoat_normal_fragment_begin>
3326
+ #include <clearcoat_normal_fragment_maps>
3327
+ #include <emissivemap_fragment>
3328
+ #include <lights_physical_fragment>
3329
+ #include <lights_fragment_begin>
3330
+ #include <lights_fragment_maps>
3331
+ #include <lights_fragment_end>
3332
+ #include <aomap_fragment>
3333
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3334
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3335
+ #include <transmission_fragment>
3336
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3337
+ #ifdef USE_SHEEN
3338
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3339
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3340
+ #endif
3341
+ #ifdef USE_CLEARCOAT
3342
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3343
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3344
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3345
+ #endif
3346
+ #include <opaque_fragment>
3347
+ #include <tonemapping_fragment>
3348
+ #include <colorspace_fragment>
3349
+ #include <fog_fragment>
3350
+ #include <premultiplied_alpha_fragment>
3351
+ #include <dithering_fragment>
3352
+ }`,ch=`#define TOON
3353
+ varying vec3 vViewPosition;
3354
+ #include <common>
3355
+ #include <batching_pars_vertex>
3356
+ #include <uv_pars_vertex>
3357
+ #include <displacementmap_pars_vertex>
3358
+ #include <color_pars_vertex>
3359
+ #include <fog_pars_vertex>
3360
+ #include <normal_pars_vertex>
3361
+ #include <morphtarget_pars_vertex>
3362
+ #include <skinning_pars_vertex>
3363
+ #include <shadowmap_pars_vertex>
3364
+ #include <logdepthbuf_pars_vertex>
3365
+ #include <clipping_planes_pars_vertex>
3366
+ void main() {
3367
+ #include <uv_vertex>
3368
+ #include <color_vertex>
3369
+ #include <morphinstance_vertex>
3370
+ #include <morphcolor_vertex>
3371
+ #include <batching_vertex>
3372
+ #include <beginnormal_vertex>
3373
+ #include <morphnormal_vertex>
3374
+ #include <skinbase_vertex>
3375
+ #include <skinnormal_vertex>
3376
+ #include <defaultnormal_vertex>
3377
+ #include <normal_vertex>
3378
+ #include <begin_vertex>
3379
+ #include <morphtarget_vertex>
3380
+ #include <skinning_vertex>
3381
+ #include <displacementmap_vertex>
3382
+ #include <project_vertex>
3383
+ #include <logdepthbuf_vertex>
3384
+ #include <clipping_planes_vertex>
3385
+ vViewPosition = - mvPosition.xyz;
3386
+ #include <worldpos_vertex>
3387
+ #include <shadowmap_vertex>
3388
+ #include <fog_vertex>
3389
+ }`,lh=`#define TOON
3390
+ uniform vec3 diffuse;
3391
+ uniform vec3 emissive;
3392
+ uniform float opacity;
3393
+ #include <common>
3394
+ #include <packing>
3395
+ #include <dithering_pars_fragment>
3396
+ #include <color_pars_fragment>
3397
+ #include <uv_pars_fragment>
3398
+ #include <map_pars_fragment>
3399
+ #include <alphamap_pars_fragment>
3400
+ #include <alphatest_pars_fragment>
3401
+ #include <alphahash_pars_fragment>
3402
+ #include <aomap_pars_fragment>
3403
+ #include <lightmap_pars_fragment>
3404
+ #include <emissivemap_pars_fragment>
3405
+ #include <gradientmap_pars_fragment>
3406
+ #include <fog_pars_fragment>
3407
+ #include <bsdfs>
3408
+ #include <lights_pars_begin>
3409
+ #include <normal_pars_fragment>
3410
+ #include <lights_toon_pars_fragment>
3411
+ #include <shadowmap_pars_fragment>
3412
+ #include <bumpmap_pars_fragment>
3413
+ #include <normalmap_pars_fragment>
3414
+ #include <logdepthbuf_pars_fragment>
3415
+ #include <clipping_planes_pars_fragment>
3416
+ void main() {
3417
+ vec4 diffuseColor = vec4( diffuse, opacity );
3418
+ #include <clipping_planes_fragment>
3419
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3420
+ vec3 totalEmissiveRadiance = emissive;
3421
+ #include <logdepthbuf_fragment>
3422
+ #include <map_fragment>
3423
+ #include <color_fragment>
3424
+ #include <alphamap_fragment>
3425
+ #include <alphatest_fragment>
3426
+ #include <alphahash_fragment>
3427
+ #include <normal_fragment_begin>
3428
+ #include <normal_fragment_maps>
3429
+ #include <emissivemap_fragment>
3430
+ #include <lights_toon_fragment>
3431
+ #include <lights_fragment_begin>
3432
+ #include <lights_fragment_maps>
3433
+ #include <lights_fragment_end>
3434
+ #include <aomap_fragment>
3435
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3436
+ #include <opaque_fragment>
3437
+ #include <tonemapping_fragment>
3438
+ #include <colorspace_fragment>
3439
+ #include <fog_fragment>
3440
+ #include <premultiplied_alpha_fragment>
3441
+ #include <dithering_fragment>
3442
+ }`,uh=`uniform float size;
3443
+ uniform float scale;
3444
+ #include <common>
3445
+ #include <color_pars_vertex>
3446
+ #include <fog_pars_vertex>
3447
+ #include <morphtarget_pars_vertex>
3448
+ #include <logdepthbuf_pars_vertex>
3449
+ #include <clipping_planes_pars_vertex>
3450
+ #ifdef USE_POINTS_UV
3451
+ varying vec2 vUv;
3452
+ uniform mat3 uvTransform;
3453
+ #endif
3454
+ void main() {
3455
+ #ifdef USE_POINTS_UV
3456
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3457
+ #endif
3458
+ #include <color_vertex>
3459
+ #include <morphinstance_vertex>
3460
+ #include <morphcolor_vertex>
3461
+ #include <begin_vertex>
3462
+ #include <morphtarget_vertex>
3463
+ #include <project_vertex>
3464
+ gl_PointSize = size;
3465
+ #ifdef USE_SIZEATTENUATION
3466
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3467
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3468
+ #endif
3469
+ #include <logdepthbuf_vertex>
3470
+ #include <clipping_planes_vertex>
3471
+ #include <worldpos_vertex>
3472
+ #include <fog_vertex>
3473
+ }`,fh=`uniform vec3 diffuse;
3474
+ uniform float opacity;
3475
+ #include <common>
3476
+ #include <color_pars_fragment>
3477
+ #include <map_particle_pars_fragment>
3478
+ #include <alphatest_pars_fragment>
3479
+ #include <alphahash_pars_fragment>
3480
+ #include <fog_pars_fragment>
3481
+ #include <logdepthbuf_pars_fragment>
3482
+ #include <clipping_planes_pars_fragment>
3483
+ void main() {
3484
+ vec4 diffuseColor = vec4( diffuse, opacity );
3485
+ #include <clipping_planes_fragment>
3486
+ vec3 outgoingLight = vec3( 0.0 );
3487
+ #include <logdepthbuf_fragment>
3488
+ #include <map_particle_fragment>
3489
+ #include <color_fragment>
3490
+ #include <alphatest_fragment>
3491
+ #include <alphahash_fragment>
3492
+ outgoingLight = diffuseColor.rgb;
3493
+ #include <opaque_fragment>
3494
+ #include <tonemapping_fragment>
3495
+ #include <colorspace_fragment>
3496
+ #include <fog_fragment>
3497
+ #include <premultiplied_alpha_fragment>
3498
+ }`,hh=`#include <common>
3499
+ #include <batching_pars_vertex>
3500
+ #include <fog_pars_vertex>
3501
+ #include <morphtarget_pars_vertex>
3502
+ #include <skinning_pars_vertex>
3503
+ #include <logdepthbuf_pars_vertex>
3504
+ #include <shadowmap_pars_vertex>
3505
+ void main() {
3506
+ #include <batching_vertex>
3507
+ #include <beginnormal_vertex>
3508
+ #include <morphinstance_vertex>
3509
+ #include <morphnormal_vertex>
3510
+ #include <skinbase_vertex>
3511
+ #include <skinnormal_vertex>
3512
+ #include <defaultnormal_vertex>
3513
+ #include <begin_vertex>
3514
+ #include <morphtarget_vertex>
3515
+ #include <skinning_vertex>
3516
+ #include <project_vertex>
3517
+ #include <logdepthbuf_vertex>
3518
+ #include <worldpos_vertex>
3519
+ #include <shadowmap_vertex>
3520
+ #include <fog_vertex>
3521
+ }`,dh=`uniform vec3 color;
3522
+ uniform float opacity;
3523
+ #include <common>
3524
+ #include <packing>
3525
+ #include <fog_pars_fragment>
3526
+ #include <bsdfs>
3527
+ #include <lights_pars_begin>
3528
+ #include <logdepthbuf_pars_fragment>
3529
+ #include <shadowmap_pars_fragment>
3530
+ #include <shadowmask_pars_fragment>
3531
+ void main() {
3532
+ #include <logdepthbuf_fragment>
3533
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3534
+ #include <tonemapping_fragment>
3535
+ #include <colorspace_fragment>
3536
+ #include <fog_fragment>
3537
+ }`,ph=`uniform float rotation;
3538
+ uniform vec2 center;
3539
+ #include <common>
3540
+ #include <uv_pars_vertex>
3541
+ #include <fog_pars_vertex>
3542
+ #include <logdepthbuf_pars_vertex>
3543
+ #include <clipping_planes_pars_vertex>
3544
+ void main() {
3545
+ #include <uv_vertex>
3546
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3547
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3548
+ #ifndef USE_SIZEATTENUATION
3549
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3550
+ if ( isPerspective ) scale *= - mvPosition.z;
3551
+ #endif
3552
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3553
+ vec2 rotatedPosition;
3554
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3555
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3556
+ mvPosition.xy += rotatedPosition;
3557
+ gl_Position = projectionMatrix * mvPosition;
3558
+ #include <logdepthbuf_vertex>
3559
+ #include <clipping_planes_vertex>
3560
+ #include <fog_vertex>
3561
+ }`,mh=`uniform vec3 diffuse;
3562
+ uniform float opacity;
3563
+ #include <common>
3564
+ #include <uv_pars_fragment>
3565
+ #include <map_pars_fragment>
3566
+ #include <alphamap_pars_fragment>
3567
+ #include <alphatest_pars_fragment>
3568
+ #include <alphahash_pars_fragment>
3569
+ #include <fog_pars_fragment>
3570
+ #include <logdepthbuf_pars_fragment>
3571
+ #include <clipping_planes_pars_fragment>
3572
+ void main() {
3573
+ vec4 diffuseColor = vec4( diffuse, opacity );
3574
+ #include <clipping_planes_fragment>
3575
+ vec3 outgoingLight = vec3( 0.0 );
3576
+ #include <logdepthbuf_fragment>
3577
+ #include <map_fragment>
3578
+ #include <alphamap_fragment>
3579
+ #include <alphatest_fragment>
3580
+ #include <alphahash_fragment>
3581
+ outgoingLight = diffuseColor.rgb;
3582
+ #include <opaque_fragment>
3583
+ #include <tonemapping_fragment>
3584
+ #include <colorspace_fragment>
3585
+ #include <fog_fragment>
3586
+ }`,Ie={alphahash_fragment:Fl,alphahash_pars_fragment:Ol,alphamap_fragment:Bl,alphamap_pars_fragment:zl,alphatest_fragment:Vl,alphatest_pars_fragment:Gl,aomap_fragment:Hl,aomap_pars_fragment:kl,batching_pars_vertex:Wl,batching_vertex:Xl,begin_vertex:ql,beginnormal_vertex:Yl,bsdfs:Kl,iridescence_fragment:Zl,bumpmap_pars_fragment:$l,clipping_planes_fragment:jl,clipping_planes_pars_fragment:Jl,clipping_planes_pars_vertex:Ql,clipping_planes_vertex:eu,color_fragment:tu,color_pars_fragment:nu,color_pars_vertex:iu,color_vertex:ru,common:su,cube_uv_reflection_fragment:au,defaultnormal_vertex:ou,displacementmap_pars_vertex:cu,displacementmap_vertex:lu,emissivemap_fragment:uu,emissivemap_pars_fragment:fu,colorspace_fragment:hu,colorspace_pars_fragment:du,envmap_fragment:pu,envmap_common_pars_fragment:mu,envmap_pars_fragment:xu,envmap_pars_vertex:_u,envmap_physical_pars_fragment:wu,envmap_vertex:gu,fog_vertex:vu,fog_pars_vertex:Mu,fog_fragment:Su,fog_pars_fragment:bu,gradientmap_pars_fragment:Eu,lightmap_pars_fragment:yu,lights_lambert_fragment:Tu,lights_lambert_pars_fragment:Au,lights_pars_begin:Ru,lights_toon_fragment:Cu,lights_toon_pars_fragment:Pu,lights_phong_fragment:Du,lights_phong_pars_fragment:Lu,lights_physical_fragment:Uu,lights_physical_pars_fragment:Iu,lights_fragment_begin:Nu,lights_fragment_maps:Fu,lights_fragment_end:Ou,logdepthbuf_fragment:Bu,logdepthbuf_pars_fragment:zu,logdepthbuf_pars_vertex:Vu,logdepthbuf_vertex:Gu,map_fragment:Hu,map_pars_fragment:ku,map_particle_fragment:Wu,map_particle_pars_fragment:Xu,metalnessmap_fragment:qu,metalnessmap_pars_fragment:Yu,morphinstance_vertex:Ku,morphcolor_vertex:Zu,morphnormal_vertex:$u,morphtarget_pars_vertex:ju,morphtarget_vertex:Ju,normal_fragment_begin:Qu,normal_fragment_maps:ef,normal_pars_fragment:tf,normal_pars_vertex:nf,normal_vertex:rf,normalmap_pars_fragment:sf,clearcoat_normal_fragment_begin:af,clearcoat_normal_fragment_maps:of,clearcoat_pars_fragment:cf,iridescence_pars_fragment:lf,opaque_fragment:uf,packing:ff,premultiplied_alpha_fragment:hf,project_vertex:df,dithering_fragment:pf,dithering_pars_fragment:mf,roughnessmap_fragment:xf,roughnessmap_pars_fragment:_f,shadowmap_pars_fragment:gf,shadowmap_pars_vertex:vf,shadowmap_vertex:Mf,shadowmask_pars_fragment:Sf,skinbase_vertex:bf,skinning_pars_vertex:Ef,skinning_vertex:yf,skinnormal_vertex:Tf,specularmap_fragment:Af,specularmap_pars_fragment:Rf,tonemapping_fragment:wf,tonemapping_pars_fragment:Cf,transmission_fragment:Pf,transmission_pars_fragment:Df,uv_pars_fragment:Lf,uv_pars_vertex:Uf,uv_vertex:If,worldpos_vertex:Nf,background_vert:Ff,background_frag:Of,backgroundCube_vert:Bf,backgroundCube_frag:zf,cube_vert:Vf,cube_frag:Gf,depth_vert:Hf,depth_frag:kf,distanceRGBA_vert:Wf,distanceRGBA_frag:Xf,equirect_vert:qf,equirect_frag:Yf,linedashed_vert:Kf,linedashed_frag:Zf,meshbasic_vert:$f,meshbasic_frag:jf,meshlambert_vert:Jf,meshlambert_frag:Qf,meshmatcap_vert:eh,meshmatcap_frag:th,meshnormal_vert:nh,meshnormal_frag:ih,meshphong_vert:rh,meshphong_frag:sh,meshphysical_vert:ah,meshphysical_frag:oh,meshtoon_vert:ch,meshtoon_frag:lh,points_vert:uh,points_frag:fh,shadow_vert:hh,shadow_frag:dh,sprite_vert:ph,sprite_frag:mh},ae={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ue}},envmap:{envMap:{value:null},envMapRotation:{value:new Ue},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ue}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ue}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ue},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ue},normalScale:{value:new Xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ue},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ue}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ue}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ue}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0},uvTransform:{value:new Ue}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new Xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}}},Ht={basic:{uniforms:Mt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.fog]),vertexShader:Ie.meshbasic_vert,fragmentShader:Ie.meshbasic_frag},lambert:{uniforms:Mt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,ae.lights,{emissive:{value:new We(0)}}]),vertexShader:Ie.meshlambert_vert,fragmentShader:Ie.meshlambert_frag},phong:{uniforms:Mt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,ae.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30}}]),vertexShader:Ie.meshphong_vert,fragmentShader:Ie.meshphong_frag},standard:{uniforms:Mt([ae.common,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.roughnessmap,ae.metalnessmap,ae.fog,ae.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag},toon:{uniforms:Mt([ae.common,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.gradientmap,ae.fog,ae.lights,{emissive:{value:new We(0)}}]),vertexShader:Ie.meshtoon_vert,fragmentShader:Ie.meshtoon_frag},matcap:{uniforms:Mt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,{matcap:{value:null}}]),vertexShader:Ie.meshmatcap_vert,fragmentShader:Ie.meshmatcap_frag},points:{uniforms:Mt([ae.points,ae.fog]),vertexShader:Ie.points_vert,fragmentShader:Ie.points_frag},dashed:{uniforms:Mt([ae.common,ae.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ie.linedashed_vert,fragmentShader:Ie.linedashed_frag},depth:{uniforms:Mt([ae.common,ae.displacementmap]),vertexShader:Ie.depth_vert,fragmentShader:Ie.depth_frag},normal:{uniforms:Mt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,{opacity:{value:1}}]),vertexShader:Ie.meshnormal_vert,fragmentShader:Ie.meshnormal_frag},sprite:{uniforms:Mt([ae.sprite,ae.fog]),vertexShader:Ie.sprite_vert,fragmentShader:Ie.sprite_frag},background:{uniforms:{uvTransform:{value:new Ue},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ie.background_vert,fragmentShader:Ie.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ue}},vertexShader:Ie.backgroundCube_vert,fragmentShader:Ie.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ie.cube_vert,fragmentShader:Ie.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ie.equirect_vert,fragmentShader:Ie.equirect_frag},distanceRGBA:{uniforms:Mt([ae.common,ae.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ie.distanceRGBA_vert,fragmentShader:Ie.distanceRGBA_frag},shadow:{uniforms:Mt([ae.lights,ae.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:Ie.shadow_vert,fragmentShader:Ie.shadow_frag}};Ht.physical={uniforms:Mt([Ht.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ue},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ue},clearcoatNormalScale:{value:new Xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ue},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ue},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ue},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ue},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ue},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ue},transmissionSamplerSize:{value:new Xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ue},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ue},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ue},anisotropyVector:{value:new Xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ue}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag};const er={r:0,b:0,g:0},An=new on,xh=new it;function _h(i,e,t,n,r,s,a){const o=new We(0);let l=s===!0?0:1,c,f,h=null,d=0,p=null;function g(E){let w=E.isScene===!0?E.background:null;return w&&w.isTexture&&(w=(E.backgroundBlurriness>0?t:e).get(w)),w}function v(E){let w=!1;const D=g(E);D===null?u(o,l):D&&D.isColor&&(u(D,1),w=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?n.buffers.color.setClear(0,0,0,1,a):y==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||w)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(E,w){const D=g(w);D&&(D.isCubeTexture||D.mapping===hr)?(f===void 0&&(f=new vn(new wi(1,1,1),new cn({name:"BackgroundCubeMaterial",uniforms:ii(Ht.backgroundCube.uniforms),vertexShader:Ht.backgroundCube.vertexShader,fragmentShader:Ht.backgroundCube.fragmentShader,side:yt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(y,P,z){this.matrixWorld.copyPosition(z.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(f)),An.copy(w.backgroundRotation),An.x*=-1,An.y*=-1,An.z*=-1,D.isCubeTexture&&D.isRenderTargetTexture===!1&&(An.y*=-1,An.z*=-1),f.material.uniforms.envMap.value=D,f.material.uniforms.flipEnvMap.value=D.isCubeTexture&&D.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,f.material.uniforms.backgroundRotation.value.setFromMatrix4(xh.makeRotationFromEuler(An)),f.material.toneMapped=ke.getTransfer(D.colorSpace)!==Ze,(h!==D||d!==D.version||p!==i.toneMapping)&&(f.material.needsUpdate=!0,h=D,d=D.version,p=i.toneMapping),f.layers.enableAll(),E.unshift(f,f.geometry,f.material,0,0,null)):D&&D.isTexture&&(c===void 0&&(c=new vn(new dr(2,2),new cn({name:"BackgroundMaterial",uniforms:ii(Ht.background.uniforms),vertexShader:Ht.background.vertexShader,fragmentShader:Ht.background.fragmentShader,side:gn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=D,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=ke.getTransfer(D.colorSpace)!==Ze,D.matrixAutoUpdate===!0&&D.updateMatrix(),c.material.uniforms.uvTransform.value.copy(D.matrix),(h!==D||d!==D.version||p!==i.toneMapping)&&(c.material.needsUpdate=!0,h=D,d=D.version,p=i.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function u(E,w){E.getRGB(er,Ao(i)),n.buffers.color.setClear(er.r,er.g,er.b,w,a)}function T(){f!==void 0&&(f.geometry.dispose(),f.material.dispose(),f=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(E,w=1){o.set(E),l=w,u(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,u(o,l)},render:v,addToRenderList:m,dispose:T}}function gh(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(M,C,B,G,k){let K=!1;const q=h(G,B,C);s!==q&&(s=q,c(s.object)),K=p(M,G,B,k),K&&g(M,G,B,k),k!==null&&e.update(k,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,w(M,C,B,G),k!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(k).buffer))}function l(){return i.createVertexArray()}function c(M){return i.bindVertexArray(M)}function f(M){return i.deleteVertexArray(M)}function h(M,C,B){const G=B.wireframe===!0;let k=n[M.id];k===void 0&&(k={},n[M.id]=k);let K=k[C.id];K===void 0&&(K={},k[C.id]=K);let q=K[G];return q===void 0&&(q=d(l()),K[G]=q),q}function d(M){const C=[],B=[],G=[];for(let k=0;k<t;k++)C[k]=0,B[k]=0,G[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:C,enabledAttributes:B,attributeDivisors:G,object:M,attributes:{},index:null}}function p(M,C,B,G){const k=s.attributes,K=C.attributes;let q=0;const ne=B.getAttributes();for(const H in ne)if(ne[H].location>=0){const se=k[H];let Se=K[H];if(Se===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(Se=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(Se=M.instanceColor)),se===void 0||se.attribute!==Se||Se&&se.data!==Se.data)return!0;q++}return s.attributesNum!==q||s.index!==G}function g(M,C,B,G){const k={},K=C.attributes;let q=0;const ne=B.getAttributes();for(const H in ne)if(ne[H].location>=0){let se=K[H];se===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(se=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(se=M.instanceColor));const Se={};Se.attribute=se,se&&se.data&&(Se.data=se.data),k[H]=Se,q++}s.attributes=k,s.attributesNum=q,s.index=G}function v(){const M=s.newAttributes;for(let C=0,B=M.length;C<B;C++)M[C]=0}function m(M){u(M,0)}function u(M,C){const B=s.newAttributes,G=s.enabledAttributes,k=s.attributeDivisors;B[M]=1,G[M]===0&&(i.enableVertexAttribArray(M),G[M]=1),k[M]!==C&&(i.vertexAttribDivisor(M,C),k[M]=C)}function T(){const M=s.newAttributes,C=s.enabledAttributes;for(let B=0,G=C.length;B<G;B++)C[B]!==M[B]&&(i.disableVertexAttribArray(B),C[B]=0)}function E(M,C,B,G,k,K,q){q===!0?i.vertexAttribIPointer(M,C,B,k,K):i.vertexAttribPointer(M,C,B,G,k,K)}function w(M,C,B,G){v();const k=G.attributes,K=B.getAttributes(),q=C.defaultAttributeValues;for(const ne in K){const H=K[ne];if(H.location>=0){let te=k[ne];if(te===void 0&&(ne==="instanceMatrix"&&M.instanceMatrix&&(te=M.instanceMatrix),ne==="instanceColor"&&M.instanceColor&&(te=M.instanceColor)),te!==void 0){const se=te.normalized,Se=te.itemSize,Ge=e.get(te);if(Ge===void 0)continue;const qe=Ge.buffer,Je=Ge.type,Qe=Ge.bytesPerElement,X=Je===i.INT||Je===i.UNSIGNED_INT||te.gpuType===Bs;if(te.isInterleavedBufferAttribute){const $=te.data,he=$.stride,Le=te.offset;if($.isInstancedInterleavedBuffer){for(let ge=0;ge<H.locationSize;ge++)u(H.location+ge,$.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let ge=0;ge<H.locationSize;ge++)m(H.location+ge);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let ge=0;ge<H.locationSize;ge++)E(H.location+ge,Se/H.locationSize,Je,se,he*Qe,(Le+Se/H.locationSize*ge)*Qe,X)}else{if(te.isInstancedBufferAttribute){for(let $=0;$<H.locationSize;$++)u(H.location+$,te.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let $=0;$<H.locationSize;$++)m(H.location+$);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let $=0;$<H.locationSize;$++)E(H.location+$,Se/H.locationSize,Je,se,Se*Qe,Se/H.locationSize*$*Qe,X)}}else if(q!==void 0){const se=q[ne];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(H.location,se);break;case 3:i.vertexAttrib3fv(H.location,se);break;case 4:i.vertexAttrib4fv(H.location,se);break;default:i.vertexAttrib1fv(H.location,se)}}}}T()}function D(){z();for(const M in n){const C=n[M];for(const B in C){const G=C[B];for(const k in G)f(G[k].object),delete G[k];delete C[B]}delete n[M]}}function y(M){if(n[M.id]===void 0)return;const C=n[M.id];for(const B in C){const G=C[B];for(const k in G)f(G[k].object),delete G[k];delete C[B]}delete n[M.id]}function P(M){for(const C in n){const B=n[C];if(B[M.id]===void 0)continue;const G=B[M.id];for(const k in G)f(G[k].object),delete G[k];delete B[M.id]}}function z(){S(),a=!0,s!==r&&(s=r,c(s.object))}function S(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:z,resetDefaultState:S,dispose:D,releaseStatesOfGeometry:y,releaseStatesOfProgram:P,initAttributes:v,enableAttribute:m,disableUnusedAttributes:T}}function vh(i,e,t){let n;function r(c){n=c}function s(c,f){i.drawArrays(n,c,f),t.update(f,n,1)}function a(c,f,h){h!==0&&(i.drawArraysInstanced(n,c,f,h),t.update(f,n,h))}function o(c,f,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,f,0,h);let p=0;for(let g=0;g<h;g++)p+=f[g];t.update(p,n,1)}function l(c,f,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)a(c[g],f[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,f,0,d,0,h);let g=0;for(let v=0;v<h;v++)g+=f[v]*d[v];t.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Mh(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(P){return!(P!==Vt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(P){const z=P===ri&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(P!==Xt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&P!==nn&&!z)}function l(P){if(P==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const f=l(c);f!==c&&(Ce("WebGLRenderer:",c,"not supported, using",f,"instead."),c=f);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),w=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),D=g>0,y=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:u,maxVertexUniforms:T,maxVaryings:E,maxFragmentUniforms:w,vertexTextures:D,maxSamples:y}}function Sh(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new wn,o=new Ue,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||n!==0||r;return r=d,n=h.length,p},this.beginShadows=function(){s=!0,f(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=f(h,d,0)},this.setState=function(h,d,p){const g=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,u=i.get(h);if(!r||g===null||g.length===0||s&&!m)s?f(null):c();else{const T=s?0:n,E=T*4;let w=u.clippingState||null;l.value=w,w=f(g,d,E,p);for(let D=0;D!==E;++D)w[D]=t[D];u.clippingState=w,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=T}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function f(h,d,p,g){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=l.value,g!==!0||m===null){const u=p+v*4,T=d.matrixWorldInverse;o.getNormalMatrix(T),(m===null||m.length<u)&&(m=new Float32Array(u));for(let E=0,w=p;E!==v;++E,w+=4)a.copy(h[E]).applyMatrix4(T,o),a.normal.toArray(m,w),m[w+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}function bh(i){let e=new WeakMap;function t(a,o){return o===rs?a.mapping=ei:o===ss&&(a.mapping=ti),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===rs||o===ss)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new vl(l.height);return c.fromEquirectangularTexture(i,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const xn=4,Ba=[.125,.215,.35,.446,.526,.582],Pn=20,Eh=256,mi=new Ll,za=new We;let Wr=null,Xr=0,qr=0,Yr=!1;const yh=new N;class Va{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=yh}=s;Wr=this._renderer.getRenderTarget(),Xr=this._renderer.getActiveCubeFace(),qr=this._renderer.getActiveMipmapLevel(),Yr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ka(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ha(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Wr,Xr,qr),this._renderer.xr.enabled=Yr,e.scissorTest=!1,Zn(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ei||e.mapping===ti?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Wr=this._renderer.getRenderTarget(),Xr=this._renderer.getActiveCubeFace(),qr=this._renderer.getActiveMipmapLevel(),Yr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:It,minFilter:It,generateMipmaps:!1,type:ri,format:Vt,colorSpace:ni,depthBuffer:!1},r=Ga(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ga(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Th(s)),this._blurMaterial=Rh(s,e,t),this._ggxMaterial=Ah(s,e,t)}return r}_compileMaterial(e){const t=new vn(new qt,e);this._renderer.compile(t,mi)}_sceneToCubeUV(e,t,n,r,s){const l=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,p=h.toneMapping;h.getClearColor(za),h.toneMapping=_n,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(r),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new vn(new wi,new Eo({name:"PMREM.Background",side:yt,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let u=!1;const T=e.background;T?T.isColor&&(m.color.copy(T),e.background=null,u=!0):(m.color.copy(za),u=!0);for(let E=0;E<6;E++){const w=E%3;w===0?(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+f[E],s.y,s.z)):w===1?(l.up.set(0,0,c[E]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+f[E],s.z)):(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+f[E]));const D=this._cubeSize;Zn(r,w*D,E>2?D:0,D,D),h.setRenderTarget(r),u&&h.render(v,l),h.render(e,l)}h.toneMapping=p,h.autoClear=d,e.background=T}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===ei||e.mapping===ti;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ka()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ha());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Zn(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,mi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-f*f),d=.05+c*.95,p=h*d,{_lodMax:g}=this,v=this._sizeLods[n],m=3*v*(n>g-xn?n-g+xn:0),u=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=g-t,Zn(s,m,u,3*v,2*v),r.setRenderTarget(s),r.render(o,mi),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-n,Zn(e,m,u,3*v,2*v),r.setRenderTarget(e),r.render(o,mi)}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&lt("blur direction must be either latitudinal or longitudinal!");const f=3,h=this._lodMeshes[r];h.material=c;const d=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Pn-1),v=s/g,m=isFinite(s)?1+Math.floor(f*v):Pn;m>Pn&&Ce(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Pn}`);const u=[];let T=0;for(let P=0;P<Pn;++P){const z=P/v,S=Math.exp(-z*z/2);u.push(S),P===0?T+=S:P<m&&(T+=2*S)}for(let P=0;P<u.length;P++)u[P]=u[P]/T;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=u,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=g,d.mipInt.value=E-n;const w=this._sizeLods[r],D=3*w*(r>E-xn?r-E+xn:0),y=4*(this._cubeSize-w);Zn(t,D,y,3*w,2*w),l.setRenderTarget(t),l.render(h,mi)}}function Th(i){const e=[],t=[],n=[];let r=i;const s=i-xn+1+Ba.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>i-xn?l=Ba[a-i+xn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),f=-c,h=1+c,d=[f,f,h,f,h,h,f,f,h,h,f,h],p=6,g=6,v=3,m=2,u=1,T=new Float32Array(v*g*p),E=new Float32Array(m*g*p),w=new Float32Array(u*g*p);for(let y=0;y<p;y++){const P=y%3*2/3-1,z=y>2?0:-1,S=[P,z,0,P+2/3,z,0,P+2/3,z+1,0,P,z,0,P+2/3,z+1,0,P,z+1,0];T.set(S,v*g*y),E.set(d,m*g*y);const M=[y,y,y,y,y,y];w.set(M,u*g*y)}const D=new qt;D.setAttribute("position",new Wt(T,v)),D.setAttribute("uv",new Wt(E,m)),D.setAttribute("faceIndex",new Wt(w,u)),n.push(new vn(D,null)),r>xn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Ga(i,e,t){const n=new Un(i,e,t);return n.texture.mapping=hr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Zn(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Ah(i,e,t){return new cn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Eh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:pr(),fragmentShader:`
3587
+
3588
+ precision highp float;
3589
+ precision highp int;
3590
+
3591
+ varying vec3 vOutputDirection;
3592
+
3593
+ uniform sampler2D envMap;
3594
+ uniform float roughness;
3595
+ uniform float mipInt;
3596
+
3597
+ #define ENVMAP_TYPE_CUBE_UV
3598
+ #include <cube_uv_reflection_fragment>
3599
+
3600
+ #define PI 3.14159265359
3601
+
3602
+ // Van der Corput radical inverse
3603
+ float radicalInverse_VdC(uint bits) {
3604
+ bits = (bits << 16u) | (bits >> 16u);
3605
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
3606
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
3607
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
3608
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
3609
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
3610
+ }
3611
+
3612
+ // Hammersley sequence
3613
+ vec2 hammersley(uint i, uint N) {
3614
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
3615
+ }
3616
+
3617
+ // GGX VNDF importance sampling (Eric Heitz 2018)
3618
+ // "Sampling the GGX Distribution of Visible Normals"
3619
+ // https://jcgt.org/published/0007/04/01/
3620
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
3621
+ float alpha = roughness * roughness;
3622
+
3623
+ // Section 3.2: Transform view direction to hemisphere configuration
3624
+ vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
3625
+
3626
+ // Section 4.1: Orthonormal basis
3627
+ float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
3628
+ vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
3629
+ vec3 T2 = cross(Vh, T1);
3630
+
3631
+ // Section 4.2: Parameterization of projected area
3632
+ float r = sqrt(Xi.x);
3633
+ float phi = 2.0 * PI * Xi.y;
3634
+ float t1 = r * cos(phi);
3635
+ float t2 = r * sin(phi);
3636
+ float s = 0.5 * (1.0 + Vh.z);
3637
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
3638
+
3639
+ // Section 4.3: Reprojection onto hemisphere
3640
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
3641
+
3642
+ // Section 3.4: Transform back to ellipsoid configuration
3643
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
3644
+ }
3645
+
3646
+ void main() {
3647
+ vec3 N = normalize(vOutputDirection);
3648
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
3649
+
3650
+ vec3 prefilteredColor = vec3(0.0);
3651
+ float totalWeight = 0.0;
3652
+
3653
+ // For very low roughness, just sample the environment directly
3654
+ if (roughness < 0.001) {
3655
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
3656
+ return;
3657
+ }
3658
+
3659
+ // Tangent space basis for VNDF sampling
3660
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
3661
+ vec3 tangent = normalize(cross(up, N));
3662
+ vec3 bitangent = cross(N, tangent);
3663
+
3664
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
3665
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
3666
+
3667
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
3668
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
3669
+
3670
+ // Transform H back to world space
3671
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
3672
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
3673
+
3674
+ float NdotL = max(dot(N, L), 0.0);
3675
+
3676
+ if(NdotL > 0.0) {
3677
+ // Sample environment at fixed mip level
3678
+ // VNDF importance sampling handles the distribution filtering
3679
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
3680
+
3681
+ // Weight by NdotL for the split-sum approximation
3682
+ // VNDF PDF naturally accounts for the visible microfacet distribution
3683
+ prefilteredColor += sampleColor * NdotL;
3684
+ totalWeight += NdotL;
3685
+ }
3686
+ }
3687
+
3688
+ if (totalWeight > 0.0) {
3689
+ prefilteredColor = prefilteredColor / totalWeight;
3690
+ }
3691
+
3692
+ gl_FragColor = vec4(prefilteredColor, 1.0);
3693
+ }
3694
+ `,blending:rn,depthTest:!1,depthWrite:!1})}function Rh(i,e,t){const n=new Float32Array(Pn),r=new N(0,1,0);return new cn({name:"SphericalGaussianBlur",defines:{n:Pn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:pr(),fragmentShader:`
3695
+
3696
+ precision mediump float;
3697
+ precision mediump int;
3698
+
3699
+ varying vec3 vOutputDirection;
3700
+
3701
+ uniform sampler2D envMap;
3702
+ uniform int samples;
3703
+ uniform float weights[ n ];
3704
+ uniform bool latitudinal;
3705
+ uniform float dTheta;
3706
+ uniform float mipInt;
3707
+ uniform vec3 poleAxis;
3708
+
3709
+ #define ENVMAP_TYPE_CUBE_UV
3710
+ #include <cube_uv_reflection_fragment>
3711
+
3712
+ vec3 getSample( float theta, vec3 axis ) {
3713
+
3714
+ float cosTheta = cos( theta );
3715
+ // Rodrigues' axis-angle rotation
3716
+ vec3 sampleDirection = vOutputDirection * cosTheta
3717
+ + cross( axis, vOutputDirection ) * sin( theta )
3718
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3719
+
3720
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3721
+
3722
+ }
3723
+
3724
+ void main() {
3725
+
3726
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3727
+
3728
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3729
+
3730
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3731
+
3732
+ }
3733
+
3734
+ axis = normalize( axis );
3735
+
3736
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3737
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3738
+
3739
+ for ( int i = 1; i < n; i++ ) {
3740
+
3741
+ if ( i >= samples ) {
3742
+
3743
+ break;
3744
+
3745
+ }
3746
+
3747
+ float theta = dTheta * float( i );
3748
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3749
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3750
+
3751
+ }
3752
+
3753
+ }
3754
+ `,blending:rn,depthTest:!1,depthWrite:!1})}function Ha(){return new cn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:pr(),fragmentShader:`
3755
+
3756
+ precision mediump float;
3757
+ precision mediump int;
3758
+
3759
+ varying vec3 vOutputDirection;
3760
+
3761
+ uniform sampler2D envMap;
3762
+
3763
+ #include <common>
3764
+
3765
+ void main() {
3766
+
3767
+ vec3 outputDirection = normalize( vOutputDirection );
3768
+ vec2 uv = equirectUv( outputDirection );
3769
+
3770
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3771
+
3772
+ }
3773
+ `,blending:rn,depthTest:!1,depthWrite:!1})}function ka(){return new cn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:pr(),fragmentShader:`
3774
+
3775
+ precision mediump float;
3776
+ precision mediump int;
3777
+
3778
+ uniform float flipEnvMap;
3779
+
3780
+ varying vec3 vOutputDirection;
3781
+
3782
+ uniform samplerCube envMap;
3783
+
3784
+ void main() {
3785
+
3786
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3787
+
3788
+ }
3789
+ `,blending:rn,depthTest:!1,depthWrite:!1})}function pr(){return`
3790
+
3791
+ precision mediump float;
3792
+ precision mediump int;
3793
+
3794
+ attribute float faceIndex;
3795
+
3796
+ varying vec3 vOutputDirection;
3797
+
3798
+ // RH coordinate system; PMREM face-indexing convention
3799
+ vec3 getDirection( vec2 uv, float face ) {
3800
+
3801
+ uv = 2.0 * uv - 1.0;
3802
+
3803
+ vec3 direction = vec3( uv, 1.0 );
3804
+
3805
+ if ( face == 0.0 ) {
3806
+
3807
+ direction = direction.zyx; // ( 1, v, u ) pos x
3808
+
3809
+ } else if ( face == 1.0 ) {
3810
+
3811
+ direction = direction.xzy;
3812
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3813
+
3814
+ } else if ( face == 2.0 ) {
3815
+
3816
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3817
+
3818
+ } else if ( face == 3.0 ) {
3819
+
3820
+ direction = direction.zyx;
3821
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3822
+
3823
+ } else if ( face == 4.0 ) {
3824
+
3825
+ direction = direction.xzy;
3826
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3827
+
3828
+ } else if ( face == 5.0 ) {
3829
+
3830
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3831
+
3832
+ }
3833
+
3834
+ return direction;
3835
+
3836
+ }
3837
+
3838
+ void main() {
3839
+
3840
+ vOutputDirection = getDirection( uv, faceIndex );
3841
+ gl_Position = vec4( position, 1.0 );
3842
+
3843
+ }
3844
+ `}function wh(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===rs||l===ss,f=l===ei||l===ti;if(c||f){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Va(i)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const p=o.image;return c&&p&&p.height>0||f&&p&&r(p)?(t===null&&(t=new Va(i)),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function r(o){let l=0;const c=6;for(let f=0;f<c;f++)o[f]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Ch(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const r=i.getExtension(n);return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&Ei("WebGLRenderer: "+n+" extension not supported."),r}}}function Ph(i,e,t,n){const r={},s=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const p in d)e.update(d[p],i.ARRAY_BUFFER)}function c(h){const d=[],p=h.index,g=h.attributes.position;let v=0;if(p!==null){const T=p.array;v=p.version;for(let E=0,w=T.length;E<w;E+=3){const D=T[E+0],y=T[E+1],P=T[E+2];d.push(D,y,y,P,P,D)}}else if(g!==void 0){const T=g.array;v=g.version;for(let E=0,w=T.length/3-1;E<w;E+=3){const D=E+0,y=E+1,P=E+2;d.push(D,y,y,P,P,D)}}else return;const m=new(vo(d)?To:yo)(d,1);m.version=v;const u=s.get(h);u&&e.remove(u),s.set(h,m)}function f(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:f}}function Dh(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){i.drawElements(n,p,s,d*a),t.update(p,n,1)}function c(d,p,g){g!==0&&(i.drawElementsInstanced(n,p,s,d*a,g),t.update(p,n,g))}function f(d,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,s,d,0,g);let m=0;for(let u=0;u<g;u++)m+=p[u];t.update(m,n,1)}function h(d,p,g,v){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let u=0;u<d.length;u++)c(d[u]/a,p[u],v[u]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,s,d,0,v,0,g);let u=0;for(let T=0;T<g;T++)u+=p[T]*v[T];t.update(u,n,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=f,this.renderMultiDrawInstances=h}function Lh(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:lt("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function Uh(i,e,t){const n=new WeakMap,r=new $e;function s(a,o,l){const c=a.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=f!==void 0?f.length:0;let d=n.get(o);if(d===void 0||d.count!==h){let S=function(){P.dispose(),n.delete(o),o.removeEventListener("dispose",S)};d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],T=o.morphAttributes.color||[];let E=0;p===!0&&(E=1),g===!0&&(E=2),v===!0&&(E=3);let w=o.attributes.position.count*E,D=1;w>e.maxTextureSize&&(D=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const y=new Float32Array(w*D*4*h),P=new Mo(y,w,D,h);P.type=nn,P.needsUpdate=!0;const z=E*4;for(let M=0;M<h;M++){const C=m[M],B=u[M],G=T[M],k=w*D*4*M;for(let K=0;K<C.count;K++){const q=K*z;p===!0&&(r.fromBufferAttribute(C,K),y[k+q+0]=r.x,y[k+q+1]=r.y,y[k+q+2]=r.z,y[k+q+3]=0),g===!0&&(r.fromBufferAttribute(B,K),y[k+q+4]=r.x,y[k+q+5]=r.y,y[k+q+6]=r.z,y[k+q+7]=0),v===!0&&(r.fromBufferAttribute(G,K),y[k+q+8]=r.x,y[k+q+9]=r.y,y[k+q+10]=r.z,y[k+q+11]=G.itemSize===4?r.w:1)}}d={count:h,texture:P,size:new Xe(w,D)},n.set(o,d),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const g=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function Ih(i,e,t,n){let r=new WeakMap;function s(l){const c=n.render.frame,f=l.geometry,h=e.get(l,f);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Io=new St,Wa=new Po(1,1),No=new Mo,Fo=new nl,Oo=new wo,Xa=[],qa=[],Ya=new Float32Array(16),Ka=new Float32Array(9),Za=new Float32Array(4);function oi(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Xa[r];if(s===void 0&&(s=new Float32Array(r),Xa[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function ft(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function ht(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function mr(i,e){let t=qa[e];t===void 0&&(t=new Int32Array(e),qa[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Nh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Fh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2fv(this.addr,e),ht(t,e)}}function Oh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ft(t,e))return;i.uniform3fv(this.addr,e),ht(t,e)}}function Bh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ft(t,e))return;i.uniform4fv(this.addr,e),ht(t,e)}}function zh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),ht(t,e)}else{if(ft(t,n))return;Za.set(n),i.uniformMatrix2fv(this.addr,!1,Za),ht(t,n)}}function Vh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),ht(t,e)}else{if(ft(t,n))return;Ka.set(n),i.uniformMatrix3fv(this.addr,!1,Ka),ht(t,n)}}function Gh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),ht(t,e)}else{if(ft(t,n))return;Ya.set(n),i.uniformMatrix4fv(this.addr,!1,Ya),ht(t,n)}}function Hh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function kh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2iv(this.addr,e),ht(t,e)}}function Wh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ft(t,e))return;i.uniform3iv(this.addr,e),ht(t,e)}}function Xh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ft(t,e))return;i.uniform4iv(this.addr,e),ht(t,e)}}function qh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Yh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2uiv(this.addr,e),ht(t,e)}}function Kh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ft(t,e))return;i.uniform3uiv(this.addr,e),ht(t,e)}}function Zh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ft(t,e))return;i.uniform4uiv(this.addr,e),ht(t,e)}}function $h(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Wa.compareFunction=go,s=Wa):s=Io,t.setTexture2D(e||s,r)}function jh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Fo,r)}function Jh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Oo,r)}function Qh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||No,r)}function ed(i){switch(i){case 5126:return Nh;case 35664:return Fh;case 35665:return Oh;case 35666:return Bh;case 35674:return zh;case 35675:return Vh;case 35676:return Gh;case 5124:case 35670:return Hh;case 35667:case 35671:return kh;case 35668:case 35672:return Wh;case 35669:case 35673:return Xh;case 5125:return qh;case 36294:return Yh;case 36295:return Kh;case 36296:return Zh;case 35678:case 36198:case 36298:case 36306:case 35682:return $h;case 35679:case 36299:case 36307:return jh;case 35680:case 36300:case 36308:case 36293:return Jh;case 36289:case 36303:case 36311:case 36292:return Qh}}function td(i,e){i.uniform1fv(this.addr,e)}function nd(i,e){const t=oi(e,this.size,2);i.uniform2fv(this.addr,t)}function id(i,e){const t=oi(e,this.size,3);i.uniform3fv(this.addr,t)}function rd(i,e){const t=oi(e,this.size,4);i.uniform4fv(this.addr,t)}function sd(i,e){const t=oi(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function ad(i,e){const t=oi(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function od(i,e){const t=oi(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function cd(i,e){i.uniform1iv(this.addr,e)}function ld(i,e){i.uniform2iv(this.addr,e)}function ud(i,e){i.uniform3iv(this.addr,e)}function fd(i,e){i.uniform4iv(this.addr,e)}function hd(i,e){i.uniform1uiv(this.addr,e)}function dd(i,e){i.uniform2uiv(this.addr,e)}function pd(i,e){i.uniform3uiv(this.addr,e)}function md(i,e){i.uniform4uiv(this.addr,e)}function xd(i,e,t){const n=this.cache,r=e.length,s=mr(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Io,s[a])}function _d(i,e,t){const n=this.cache,r=e.length,s=mr(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Fo,s[a])}function gd(i,e,t){const n=this.cache,r=e.length,s=mr(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Oo,s[a])}function vd(i,e,t){const n=this.cache,r=e.length,s=mr(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||No,s[a])}function Md(i){switch(i){case 5126:return td;case 35664:return nd;case 35665:return id;case 35666:return rd;case 35674:return sd;case 35675:return ad;case 35676:return od;case 5124:case 35670:return cd;case 35667:case 35671:return ld;case 35668:case 35672:return ud;case 35669:case 35673:return fd;case 5125:return hd;case 36294:return dd;case 36295:return pd;case 36296:return md;case 35678:case 36198:case 36298:case 36306:case 35682:return xd;case 35679:case 36299:case 36307:return _d;case 35680:case 36300:case 36308:case 36293:return gd;case 36289:case 36303:case 36311:case 36292:return vd}}class Sd{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=ed(t.type)}}class bd{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Md(t.type)}}class Ed{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Kr=/(\w+)(\])?(\[|\.)?/g;function $a(i,e){i.seq.push(e),i.map[e.id]=e}function yd(i,e,t){const n=i.name,r=n.length;for(Kr.lastIndex=0;;){const s=Kr.exec(n),a=Kr.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){$a(t,c===void 0?new Sd(o,i,e):new bd(o,i,e));break}else{let h=t.map[o];h===void 0&&(h=new Ed(o),$a(t,h)),t=h}}}class ar{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);yd(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function ja(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Td=37297;let Ad=0;function Rd(i,e){const t=i.split(`
3845
+ `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3846
+ `)}const Ja=new Ue;function wd(i){ke._getMatrix(Ja,ke.workingColorSpace,i);const e=`mat3( ${Ja.elements.map(t=>t.toFixed(4))} )`;switch(ke.getTransfer(i)){case or:return[e,"LinearTransferOETF"];case Ze:return[e,"sRGBTransferOETF"];default:return Ce("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Qa(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
3847
+
3848
+ `+s+`
3849
+
3850
+ `+Rd(i.getShaderSource(e),o)}else return s}function Cd(i,e){const t=wd(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3851
+ `)}function Pd(i,e){let t;switch(e){case pc:t="Linear";break;case mc:t="Reinhard";break;case xc:t="Cineon";break;case _c:t="ACESFilmic";break;case vc:t="AgX";break;case Mc:t="Neutral";break;case gc:t="Custom";break;default:Ce("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const tr=new N;function Dd(){ke.getLuminanceCoefficients(tr);const i=tr.x.toFixed(4),e=tr.y.toFixed(4),t=tr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3852
+ `)}function Ld(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xi).join(`
3853
+ `)}function Ud(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3854
+ `)}function Id(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function xi(i){return i!==""}function eo(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function to(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Nd=/^[ \t]*#include +<([\w\d./]+)>/gm;function Os(i){return i.replace(Nd,Od)}const Fd=new Map;function Od(i,e){let t=Ie[e];if(t===void 0){const n=Fd.get(e);if(n!==void 0)t=Ie[n],Ce('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Os(t)}const Bd=/#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 no(i){return i.replace(Bd,zd)}function zd(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function io(i){let e=`precision ${i.precision} float;
3855
+ precision ${i.precision} int;
3856
+ precision ${i.precision} sampler2D;
3857
+ precision ${i.precision} samplerCube;
3858
+ precision ${i.precision} sampler3D;
3859
+ precision ${i.precision} sampler2DArray;
3860
+ precision ${i.precision} sampler2DShadow;
3861
+ precision ${i.precision} samplerCubeShadow;
3862
+ precision ${i.precision} sampler2DArrayShadow;
3863
+ precision ${i.precision} isampler2D;
3864
+ precision ${i.precision} isampler3D;
3865
+ precision ${i.precision} isamplerCube;
3866
+ precision ${i.precision} isampler2DArray;
3867
+ precision ${i.precision} usampler2D;
3868
+ precision ${i.precision} usampler3D;
3869
+ precision ${i.precision} usamplerCube;
3870
+ precision ${i.precision} usampler2DArray;
3871
+ `;return i.precision==="highp"?e+=`
3872
+ #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3873
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3874
+ #define LOW_PRECISION`),e}function Vd(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===oo?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Yo?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Qt&&(e="SHADOWMAP_TYPE_VSM"),e}function Gd(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ei:case ti:e="ENVMAP_TYPE_CUBE";break;case hr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Hd(i){let e="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===ti&&(e="ENVMAP_MODE_REFRACTION"),e}function kd(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case co:e="ENVMAP_BLENDING_MULTIPLY";break;case hc:e="ENVMAP_BLENDING_MIX";break;case dc:e="ENVMAP_BLENDING_ADD";break}return e}function Wd(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Xd(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=Vd(t),c=Gd(t),f=Hd(t),h=kd(t),d=Wd(t),p=Ld(t),g=Ud(s),v=r.createProgram();let m,u,T=t.glslVersion?"#version "+t.glslVersion+`
3875
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(xi).join(`
3876
+ `),m.length>0&&(m+=`
3877
+ `),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(xi).join(`
3878
+ `),u.length>0&&(u+=`
3879
+ `)):(m=[io(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3880
+ `].filter(xi).join(`
3881
+ `),u=[io(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+f:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==_n?"#define TONE_MAPPING":"",t.toneMapping!==_n?Ie.tonemapping_pars_fragment:"",t.toneMapping!==_n?Pd("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ie.colorspace_pars_fragment,Cd("linearToOutputTexel",t.outputColorSpace),Dd(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3882
+ `].filter(xi).join(`
3883
+ `)),a=Os(a),a=eo(a,t),a=to(a,t),o=Os(o),o=eo(o,t),o=to(o,t),a=no(a),o=no(o),t.isRawShaderMaterial!==!0&&(T=`#version 300 es
3884
+ `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3885
+ `)+`
3886
+ `+m,u=["#define varying in",t.glslVersion===ca?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ca?"":"#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(`
3887
+ `)+`
3888
+ `+u);const E=T+m+a,w=T+u+o,D=ja(r,r.VERTEX_SHADER,E),y=ja(r,r.FRAGMENT_SHADER,w);r.attachShader(v,D),r.attachShader(v,y),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function P(C){if(i.debug.checkShaderErrors){const B=r.getProgramInfoLog(v)||"",G=r.getShaderInfoLog(D)||"",k=r.getShaderInfoLog(y)||"",K=B.trim(),q=G.trim(),ne=k.trim();let H=!0,te=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(H=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,D,y);else{const se=Qa(r,D,"vertex"),Se=Qa(r,y,"fragment");lt("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3889
+
3890
+ Material Name: `+C.name+`
3891
+ Material Type: `+C.type+`
3892
+
3893
+ Program Info Log: `+K+`
3894
+ `+se+`
3895
+ `+Se)}else K!==""?Ce("WebGLProgram: Program Info Log:",K):(q===""||ne==="")&&(te=!1);te&&(C.diagnostics={runnable:H,programLog:K,vertexShader:{log:q,prefix:m},fragmentShader:{log:ne,prefix:u}})}r.deleteShader(D),r.deleteShader(y),z=new ar(r,v),S=Id(r,v)}let z;this.getUniforms=function(){return z===void 0&&P(this),z};let S;this.getAttributes=function(){return S===void 0&&P(this),S};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,Td)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Ad++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=D,this.fragmentShader=y,this}let qd=0;class Yd{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Kd(e),t.set(e,n)),n}}class Kd{constructor(e){this.id=qd++,this.code=e,this.usedTimes=0}}function Zd(i,e,t,n,r,s,a){const o=new So,l=new Yd,c=new Set,f=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const g={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 v(S){return c.add(S),S===0?"uv":`uv${S}`}function m(S,M,C,B,G){const k=B.fog,K=G.geometry,q=S.isMeshStandardMaterial?B.environment:null,ne=(S.isMeshStandardMaterial?t:e).get(S.envMap||q),H=ne&&ne.mapping===hr?ne.image.height:null,te=g[S.type];S.precision!==null&&(p=r.getMaxPrecision(S.precision),p!==S.precision&&Ce("WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));const se=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,Se=se!==void 0?se.length:0;let Ge=0;K.morphAttributes.position!==void 0&&(Ge=1),K.morphAttributes.normal!==void 0&&(Ge=2),K.morphAttributes.color!==void 0&&(Ge=3);let qe,Je,Qe,X;if(te){const Ye=Ht[te];qe=Ye.vertexShader,Je=Ye.fragmentShader}else qe=S.vertexShader,Je=S.fragmentShader,l.update(S),Qe=l.getVertexShaderID(S),X=l.getFragmentShaderID(S);const $=i.getRenderTarget(),he=i.state.buffers.depth.getReversed(),Le=G.isInstancedMesh===!0,ge=G.isBatchedMesh===!0,Oe=!!S.map,pt=!!S.matcap,Fe=!!ne,nt=!!S.aoMap,A=!!S.lightMap,Be=!!S.bumpMap,ze=!!S.normalMap,et=!!S.displacementMap,me=!!S.emissiveMap,rt=!!S.metalnessMap,Me=!!S.roughnessMap,De=S.anisotropy>0,b=S.clearcoat>0,x=S.dispersion>0,I=S.iridescence>0,W=S.sheen>0,Z=S.transmission>0,V=De&&!!S.anisotropyMap,_e=b&&!!S.clearcoatMap,oe=b&&!!S.clearcoatNormalMap,be=b&&!!S.clearcoatRoughnessMap,xe=I&&!!S.iridescenceMap,j=I&&!!S.iridescenceThicknessMap,ee=W&&!!S.sheenColorMap,Ae=W&&!!S.sheenRoughnessMap,ye=!!S.specularMap,ue=!!S.specularColorMap,we=!!S.specularIntensityMap,R=Z&&!!S.transmissionMap,ce=Z&&!!S.thicknessMap,ie=!!S.gradientMap,re=!!S.alphaMap,J=S.alphaTest>0,Y=!!S.alphaHash,de=!!S.extensions;let Pe=_n;S.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(Pe=i.toneMapping);const tt={shaderID:te,shaderType:S.type,shaderName:S.name,vertexShader:qe,fragmentShader:Je,defines:S.defines,customVertexShaderID:Qe,customFragmentShaderID:X,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:ge,batchingColor:ge&&G._colorsTexture!==null,instancing:Le,instancingColor:Le&&G.instanceColor!==null,instancingMorph:Le&&G.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:$===null?i.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:ni,alphaToCoverage:!!S.alphaToCoverage,map:Oe,matcap:pt,envMap:Fe,envMapMode:Fe&&ne.mapping,envMapCubeUVHeight:H,aoMap:nt,lightMap:A,bumpMap:Be,normalMap:ze,displacementMap:d&&et,emissiveMap:me,normalMapObjectSpace:ze&&S.normalMapType===Tc,normalMapTangentSpace:ze&&S.normalMapType===yc,metalnessMap:rt,roughnessMap:Me,anisotropy:De,anisotropyMap:V,clearcoat:b,clearcoatMap:_e,clearcoatNormalMap:oe,clearcoatRoughnessMap:be,dispersion:x,iridescence:I,iridescenceMap:xe,iridescenceThicknessMap:j,sheen:W,sheenColorMap:ee,sheenRoughnessMap:Ae,specularMap:ye,specularColorMap:ue,specularIntensityMap:we,transmission:Z,transmissionMap:R,thicknessMap:ce,gradientMap:ie,opaque:S.transparent===!1&&S.blending===jn&&S.alphaToCoverage===!1,alphaMap:re,alphaTest:J,alphaHash:Y,combine:S.combine,mapUv:Oe&&v(S.map.channel),aoMapUv:nt&&v(S.aoMap.channel),lightMapUv:A&&v(S.lightMap.channel),bumpMapUv:Be&&v(S.bumpMap.channel),normalMapUv:ze&&v(S.normalMap.channel),displacementMapUv:et&&v(S.displacementMap.channel),emissiveMapUv:me&&v(S.emissiveMap.channel),metalnessMapUv:rt&&v(S.metalnessMap.channel),roughnessMapUv:Me&&v(S.roughnessMap.channel),anisotropyMapUv:V&&v(S.anisotropyMap.channel),clearcoatMapUv:_e&&v(S.clearcoatMap.channel),clearcoatNormalMapUv:oe&&v(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:be&&v(S.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&v(S.iridescenceMap.channel),iridescenceThicknessMapUv:j&&v(S.iridescenceThicknessMap.channel),sheenColorMapUv:ee&&v(S.sheenColorMap.channel),sheenRoughnessMapUv:Ae&&v(S.sheenRoughnessMap.channel),specularMapUv:ye&&v(S.specularMap.channel),specularColorMapUv:ue&&v(S.specularColorMap.channel),specularIntensityMapUv:we&&v(S.specularIntensityMap.channel),transmissionMapUv:R&&v(S.transmissionMap.channel),thicknessMapUv:ce&&v(S.thicknessMap.channel),alphaMapUv:re&&v(S.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(ze||De),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!K.attributes.uv&&(Oe||re),fog:!!k,useFog:S.fog===!0,fogExp2:!!k&&k.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:he,skinning:G.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:Ge,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:Pe,decodeVideoTexture:Oe&&S.map.isVideoTexture===!0&&ke.getTransfer(S.map.colorSpace)===Ze,decodeVideoTextureEmissive:me&&S.emissiveMap.isVideoTexture===!0&&ke.getTransfer(S.emissiveMap.colorSpace)===Ze,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===en,flipSided:S.side===yt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:de&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(de&&S.extensions.multiDraw===!0||ge)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return tt.vertexUv1s=c.has(1),tt.vertexUv2s=c.has(2),tt.vertexUv3s=c.has(3),c.clear(),tt}function u(S){const M=[];if(S.shaderID?M.push(S.shaderID):(M.push(S.customVertexShaderID),M.push(S.customFragmentShaderID)),S.defines!==void 0)for(const C in S.defines)M.push(C),M.push(S.defines[C]);return S.isRawShaderMaterial===!1&&(T(M,S),E(M,S),M.push(i.outputColorSpace)),M.push(S.customProgramCacheKey),M.join()}function T(S,M){S.push(M.precision),S.push(M.outputColorSpace),S.push(M.envMapMode),S.push(M.envMapCubeUVHeight),S.push(M.mapUv),S.push(M.alphaMapUv),S.push(M.lightMapUv),S.push(M.aoMapUv),S.push(M.bumpMapUv),S.push(M.normalMapUv),S.push(M.displacementMapUv),S.push(M.emissiveMapUv),S.push(M.metalnessMapUv),S.push(M.roughnessMapUv),S.push(M.anisotropyMapUv),S.push(M.clearcoatMapUv),S.push(M.clearcoatNormalMapUv),S.push(M.clearcoatRoughnessMapUv),S.push(M.iridescenceMapUv),S.push(M.iridescenceThicknessMapUv),S.push(M.sheenColorMapUv),S.push(M.sheenRoughnessMapUv),S.push(M.specularMapUv),S.push(M.specularColorMapUv),S.push(M.specularIntensityMapUv),S.push(M.transmissionMapUv),S.push(M.thicknessMapUv),S.push(M.combine),S.push(M.fogExp2),S.push(M.sizeAttenuation),S.push(M.morphTargetsCount),S.push(M.morphAttributeCount),S.push(M.numDirLights),S.push(M.numPointLights),S.push(M.numSpotLights),S.push(M.numSpotLightMaps),S.push(M.numHemiLights),S.push(M.numRectAreaLights),S.push(M.numDirLightShadows),S.push(M.numPointLightShadows),S.push(M.numSpotLightShadows),S.push(M.numSpotLightShadowsWithMaps),S.push(M.numLightProbes),S.push(M.shadowMapType),S.push(M.toneMapping),S.push(M.numClippingPlanes),S.push(M.numClipIntersection),S.push(M.depthPacking)}function E(S,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),S.push(o.mask)}function w(S){const M=g[S.type];let C;if(M){const B=Ht[M];C=ml.clone(B.uniforms)}else C=S.uniforms;return C}function D(S,M){let C;for(let B=0,G=f.length;B<G;B++){const k=f[B];if(k.cacheKey===M){C=k,++C.usedTimes;break}}return C===void 0&&(C=new Xd(i,M,S,s),f.push(C)),C}function y(S){if(--S.usedTimes===0){const M=f.indexOf(S);f[M]=f[f.length-1],f.pop(),S.destroy()}}function P(S){l.remove(S)}function z(){l.dispose()}return{getParameters:m,getProgramCacheKey:u,getUniforms:w,acquireProgram:D,releaseProgram:y,releaseShaderCache:P,programs:f,dispose:z}}function $d(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function jd(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function ro(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function so(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(h,d,p,g,v,m){let u=i[e];return u===void 0?(u={id:h.id,object:h,geometry:d,material:p,groupOrder:g,renderOrder:h.renderOrder,z:v,group:m},i[e]=u):(u.id=h.id,u.object=h,u.geometry=d,u.material=p,u.groupOrder=g,u.renderOrder=h.renderOrder,u.z=v,u.group=m),e++,u}function o(h,d,p,g,v,m){const u=a(h,d,p,g,v,m);p.transmission>0?n.push(u):p.transparent===!0?r.push(u):t.push(u)}function l(h,d,p,g,v,m){const u=a(h,d,p,g,v,m);p.transmission>0?n.unshift(u):p.transparent===!0?r.unshift(u):t.unshift(u)}function c(h,d){t.length>1&&t.sort(h||jd),n.length>1&&n.sort(d||ro),r.length>1&&r.sort(d||ro)}function f(){for(let h=e,d=i.length;h<d;h++){const p=i[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:f,sort:c}}function Jd(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new so,i.set(n,[a])):r>=s.length?(a=new so,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Qd(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new We};break;case"SpotLight":t={position:new N,direction:new N,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new We,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new We,groundColor:new We};break;case"RectAreaLight":t={color:new We,position:new N,halfWidth:new N,halfHeight:new N};break}return i[e.id]=t,t}}}function ep(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let tp=0;function np(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function ip(i){const e=new Qd,t=ep(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new N);const r=new N,s=new it,a=new it;function o(c){let f=0,h=0,d=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let p=0,g=0,v=0,m=0,u=0,T=0,E=0,w=0,D=0,y=0,P=0;c.sort(np);for(let S=0,M=c.length;S<M;S++){const C=c[S],B=C.color,G=C.intensity,k=C.distance,K=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)f+=B.r*G,h+=B.g*G,d+=B.b*G;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],G);P++}else if(C.isDirectionalLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const ne=C.shadow,H=t.get(C);H.shadowIntensity=ne.intensity,H.shadowBias=ne.bias,H.shadowNormalBias=ne.normalBias,H.shadowRadius=ne.radius,H.shadowMapSize=ne.mapSize,n.directionalShadow[p]=H,n.directionalShadowMap[p]=K,n.directionalShadowMatrix[p]=C.shadow.matrix,T++}n.directional[p]=q,p++}else if(C.isSpotLight){const q=e.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(B).multiplyScalar(G),q.distance=k,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[v]=q;const ne=C.shadow;if(C.map&&(n.spotLightMap[D]=C.map,D++,ne.updateMatrices(C),C.castShadow&&y++),n.spotLightMatrix[v]=ne.matrix,C.castShadow){const H=t.get(C);H.shadowIntensity=ne.intensity,H.shadowBias=ne.bias,H.shadowNormalBias=ne.normalBias,H.shadowRadius=ne.radius,H.shadowMapSize=ne.mapSize,n.spotShadow[v]=H,n.spotShadowMap[v]=K,w++}v++}else if(C.isRectAreaLight){const q=e.get(C);q.color.copy(B).multiplyScalar(G),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const ne=C.shadow,H=t.get(C);H.shadowIntensity=ne.intensity,H.shadowBias=ne.bias,H.shadowNormalBias=ne.normalBias,H.shadowRadius=ne.radius,H.shadowMapSize=ne.mapSize,H.shadowCameraNear=ne.camera.near,H.shadowCameraFar=ne.camera.far,n.pointShadow[g]=H,n.pointShadowMap[g]=K,n.pointShadowMatrix[g]=C.shadow.matrix,E++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=e.get(C);q.skyColor.copy(C.color).multiplyScalar(G),q.groundColor.copy(C.groundColor).multiplyScalar(G),n.hemi[u]=q,u++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ae.LTC_FLOAT_1,n.rectAreaLTC2=ae.LTC_FLOAT_2):(n.rectAreaLTC1=ae.LTC_HALF_1,n.rectAreaLTC2=ae.LTC_HALF_2)),n.ambient[0]=f,n.ambient[1]=h,n.ambient[2]=d;const z=n.hash;(z.directionalLength!==p||z.pointLength!==g||z.spotLength!==v||z.rectAreaLength!==m||z.hemiLength!==u||z.numDirectionalShadows!==T||z.numPointShadows!==E||z.numSpotShadows!==w||z.numSpotMaps!==D||z.numLightProbes!==P)&&(n.directional.length=p,n.spot.length=v,n.rectArea.length=m,n.point.length=g,n.hemi.length=u,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=w+D-y,n.spotLightMap.length=D,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=P,z.directionalLength=p,z.pointLength=g,z.spotLength=v,z.rectAreaLength=m,z.hemiLength=u,z.numDirectionalShadows=T,z.numPointShadows=E,z.numSpotShadows=w,z.numSpotMaps=D,z.numLightProbes=P,n.version=tp++)}function l(c,f){let h=0,d=0,p=0,g=0,v=0;const m=f.matrixWorldInverse;for(let u=0,T=c.length;u<T;u++){const E=c[u];if(E.isDirectionalLight){const w=n.directional[h];w.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(m),h++}else if(E.isSpotLight){const w=n.spot[p];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(m),w.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(m),p++}else if(E.isRectAreaLight){const w=n.rectArea[g];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(m),a.identity(),s.copy(E.matrixWorld),s.premultiply(m),a.extractRotation(s),w.halfWidth.set(E.width*.5,0,0),w.halfHeight.set(0,E.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),g++}else if(E.isPointLight){const w=n.point[d];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(m),d++}else if(E.isHemisphereLight){const w=n.hemi[v];w.direction.setFromMatrixPosition(E.matrixWorld),w.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:n}}function ao(i){const e=new ip(i),t=[],n=[];function r(f){c.camera=f,t.length=0,n.length=0}function s(f){t.push(f)}function a(f){n.push(f)}function o(){e.setup(t)}function l(f){e.setupView(t,f)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function rp(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ao(i),e.set(r,[o])):s>=a.length?(o=new ao(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const sp=`void main() {
3896
+ gl_Position = vec4( position, 1.0 );
3897
+ }`,ap=`uniform sampler2D shadow_pass;
3898
+ uniform vec2 resolution;
3899
+ uniform float radius;
3900
+ #include <packing>
3901
+ void main() {
3902
+ const float samples = float( VSM_SAMPLES );
3903
+ float mean = 0.0;
3904
+ float squared_mean = 0.0;
3905
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3906
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3907
+ for ( float i = 0.0; i < samples; i ++ ) {
3908
+ float uvOffset = uvStart + i * uvStride;
3909
+ #ifdef HORIZONTAL_PASS
3910
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3911
+ mean += distribution.x;
3912
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3913
+ #else
3914
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3915
+ mean += depth;
3916
+ squared_mean += depth * depth;
3917
+ #endif
3918
+ }
3919
+ mean = mean / samples;
3920
+ squared_mean = squared_mean / samples;
3921
+ float std_dev = sqrt( squared_mean - mean * mean );
3922
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3923
+ }`;function op(i,e,t){let n=new Ks;const r=new Xe,s=new Xe,a=new $e,o=new wl({depthPacking:Ec}),l=new Cl,c={},f=t.maxTextureSize,h={[gn]:yt,[yt]:gn,[en]:en},d=new cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xe},radius:{value:4}},vertexShader:sp,fragmentShader:ap}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new qt;g.setAttribute("position",new Wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new vn(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=oo;let u=this.type;this.render=function(y,P,z){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||y.length===0)return;const S=i.getRenderTarget(),M=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),B=i.state;B.setBlending(rn),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const G=u!==Qt&&this.type===Qt,k=u===Qt&&this.type!==Qt;for(let K=0,q=y.length;K<q;K++){const ne=y[K],H=ne.shadow;if(H===void 0){Ce("WebGLShadowMap:",ne,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const te=H.getFrameExtents();if(r.multiply(te),s.copy(H.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/te.x),r.x=s.x*te.x,H.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/te.y),r.y=s.y*te.y,H.mapSize.y=s.y)),H.map===null||G===!0||k===!0){const Se=this.type!==Qt?{minFilter:Ct,magFilter:Ct}:{};H.map!==null&&H.map.dispose(),H.map=new Un(r.x,r.y,Se),H.map.texture.name=ne.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const se=H.getViewportCount();for(let Se=0;Se<se;Se++){const Ge=H.getViewport(Se);a.set(s.x*Ge.x,s.y*Ge.y,s.x*Ge.z,s.y*Ge.w),B.viewport(a),H.updateMatrices(ne,Se),n=H.getFrustum(),w(P,z,H.camera,ne,this.type)}H.isPointLightShadow!==!0&&this.type===Qt&&T(H,z),H.needsUpdate=!1}u=this.type,m.needsUpdate=!1,i.setRenderTarget(S,M,C)};function T(y,P){const z=e.update(v);d.defines.VSM_SAMPLES!==y.blurSamples&&(d.defines.VSM_SAMPLES=y.blurSamples,p.defines.VSM_SAMPLES=y.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),y.mapPass===null&&(y.mapPass=new Un(r.x,r.y)),d.uniforms.shadow_pass.value=y.map.texture,d.uniforms.resolution.value=y.mapSize,d.uniforms.radius.value=y.radius,i.setRenderTarget(y.mapPass),i.clear(),i.renderBufferDirect(P,null,z,d,v,null),p.uniforms.shadow_pass.value=y.mapPass.texture,p.uniforms.resolution.value=y.mapSize,p.uniforms.radius.value=y.radius,i.setRenderTarget(y.map),i.clear(),i.renderBufferDirect(P,null,z,p,v,null)}function E(y,P,z,S){let M=null;const C=z.isPointLight===!0?y.customDistanceMaterial:y.customDepthMaterial;if(C!==void 0)M=C;else if(M=z.isPointLight===!0?l:o,i.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0||P.alphaToCoverage===!0){const B=M.uuid,G=P.uuid;let k=c[B];k===void 0&&(k={},c[B]=k);let K=k[G];K===void 0&&(K=M.clone(),k[G]=K,P.addEventListener("dispose",D)),M=K}if(M.visible=P.visible,M.wireframe=P.wireframe,S===Qt?M.side=P.shadowSide!==null?P.shadowSide:P.side:M.side=P.shadowSide!==null?P.shadowSide:h[P.side],M.alphaMap=P.alphaMap,M.alphaTest=P.alphaToCoverage===!0?.5:P.alphaTest,M.map=P.map,M.clipShadows=P.clipShadows,M.clippingPlanes=P.clippingPlanes,M.clipIntersection=P.clipIntersection,M.displacementMap=P.displacementMap,M.displacementScale=P.displacementScale,M.displacementBias=P.displacementBias,M.wireframeLinewidth=P.wireframeLinewidth,M.linewidth=P.linewidth,z.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const B=i.properties.get(M);B.light=z}return M}function w(y,P,z,S,M){if(y.visible===!1)return;if(y.layers.test(P.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&M===Qt)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,y.matrixWorld);const G=e.update(y),k=y.material;if(Array.isArray(k)){const K=G.groups;for(let q=0,ne=K.length;q<ne;q++){const H=K[q],te=k[H.materialIndex];if(te&&te.visible){const se=E(y,te,S,M);y.onBeforeShadow(i,y,P,z,G,se,H),i.renderBufferDirect(z,null,G,se,y,H),y.onAfterShadow(i,y,P,z,G,se,H)}}}else if(k.visible){const K=E(y,k,S,M);y.onBeforeShadow(i,y,P,z,G,K,null),i.renderBufferDirect(z,null,G,K,y,null),y.onAfterShadow(i,y,P,z,G,K,null)}}const B=y.children;for(let G=0,k=B.length;G<k;G++)w(B[G],P,z,S,M)}function D(y){y.target.removeEventListener("dispose",D);for(const z in c){const S=c[z],M=y.target.uuid;M in S&&(S[M].dispose(),delete S[M])}}}const cp={[jr]:Jr,[Qr]:ns,[es]:is,[Qn]:ts,[Jr]:jr,[ns]:Qr,[is]:es,[ts]:Qn};function lp(i,e){function t(){let R=!1;const ce=new $e;let ie=null;const re=new $e(0,0,0,0);return{setMask:function(J){ie!==J&&!R&&(i.colorMask(J,J,J,J),ie=J)},setLocked:function(J){R=J},setClear:function(J,Y,de,Pe,tt){tt===!0&&(J*=Pe,Y*=Pe,de*=Pe),ce.set(J,Y,de,Pe),re.equals(ce)===!1&&(i.clearColor(J,Y,de,Pe),re.copy(ce))},reset:function(){R=!1,ie=null,re.set(-1,0,0,0)}}}function n(){let R=!1,ce=!1,ie=null,re=null,J=null;return{setReversed:function(Y){if(ce!==Y){const de=e.get("EXT_clip_control");Y?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),ce=Y;const Pe=J;J=null,this.setClear(Pe)}},getReversed:function(){return ce},setTest:function(Y){Y?$(i.DEPTH_TEST):he(i.DEPTH_TEST)},setMask:function(Y){ie!==Y&&!R&&(i.depthMask(Y),ie=Y)},setFunc:function(Y){if(ce&&(Y=cp[Y]),re!==Y){switch(Y){case jr:i.depthFunc(i.NEVER);break;case Jr:i.depthFunc(i.ALWAYS);break;case Qr:i.depthFunc(i.LESS);break;case Qn:i.depthFunc(i.LEQUAL);break;case es:i.depthFunc(i.EQUAL);break;case ts:i.depthFunc(i.GEQUAL);break;case ns:i.depthFunc(i.GREATER);break;case is:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}re=Y}},setLocked:function(Y){R=Y},setClear:function(Y){J!==Y&&(ce&&(Y=1-Y),i.clearDepth(Y),J=Y)},reset:function(){R=!1,ie=null,re=null,J=null,ce=!1}}}function r(){let R=!1,ce=null,ie=null,re=null,J=null,Y=null,de=null,Pe=null,tt=null;return{setTest:function(Ye){R||(Ye?$(i.STENCIL_TEST):he(i.STENCIL_TEST))},setMask:function(Ye){ce!==Ye&&!R&&(i.stencilMask(Ye),ce=Ye)},setFunc:function(Ye,Gt,Nt){(ie!==Ye||re!==Gt||J!==Nt)&&(i.stencilFunc(Ye,Gt,Nt),ie=Ye,re=Gt,J=Nt)},setOp:function(Ye,Gt,Nt){(Y!==Ye||de!==Gt||Pe!==Nt)&&(i.stencilOp(Ye,Gt,Nt),Y=Ye,de=Gt,Pe=Nt)},setLocked:function(Ye){R=Ye},setClear:function(Ye){tt!==Ye&&(i.clearStencil(Ye),tt=Ye)},reset:function(){R=!1,ce=null,ie=null,re=null,J=null,Y=null,de=null,Pe=null,tt=null}}}const s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let f={},h={},d=new WeakMap,p=[],g=null,v=!1,m=null,u=null,T=null,E=null,w=null,D=null,y=null,P=new We(0,0,0),z=0,S=!1,M=null,C=null,B=null,G=null,k=null;const K=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,ne=0;const H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(H)[1]),q=ne>=1):H.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),q=ne>=2);let te=null,se={};const Se=i.getParameter(i.SCISSOR_BOX),Ge=i.getParameter(i.VIEWPORT),qe=new $e().fromArray(Se),Je=new $e().fromArray(Ge);function Qe(R,ce,ie,re){const J=new Uint8Array(4),Y=i.createTexture();i.bindTexture(R,Y),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let de=0;de<ie;de++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(ce,0,i.RGBA,1,1,re,0,i.RGBA,i.UNSIGNED_BYTE,J):i.texImage2D(ce+de,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,J);return Y}const X={};X[i.TEXTURE_2D]=Qe(i.TEXTURE_2D,i.TEXTURE_2D,1),X[i.TEXTURE_CUBE_MAP]=Qe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),X[i.TEXTURE_2D_ARRAY]=Qe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),X[i.TEXTURE_3D]=Qe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),$(i.DEPTH_TEST),a.setFunc(Qn),Be(!1),ze(na),$(i.CULL_FACE),nt(rn);function $(R){f[R]!==!0&&(i.enable(R),f[R]=!0)}function he(R){f[R]!==!1&&(i.disable(R),f[R]=!1)}function Le(R,ce){return h[R]!==ce?(i.bindFramebuffer(R,ce),h[R]=ce,R===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ce),R===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ce),!0):!1}function ge(R,ce){let ie=p,re=!1;if(R){ie=d.get(ce),ie===void 0&&(ie=[],d.set(ce,ie));const J=R.textures;if(ie.length!==J.length||ie[0]!==i.COLOR_ATTACHMENT0){for(let Y=0,de=J.length;Y<de;Y++)ie[Y]=i.COLOR_ATTACHMENT0+Y;ie.length=J.length,re=!0}}else ie[0]!==i.BACK&&(ie[0]=i.BACK,re=!0);re&&i.drawBuffers(ie)}function Oe(R){return g!==R?(i.useProgram(R),g=R,!0):!1}const pt={[Cn]:i.FUNC_ADD,[Zo]:i.FUNC_SUBTRACT,[$o]:i.FUNC_REVERSE_SUBTRACT};pt[jo]=i.MIN,pt[Jo]=i.MAX;const Fe={[Qo]:i.ZERO,[ec]:i.ONE,[tc]:i.SRC_COLOR,[Zr]:i.SRC_ALPHA,[oc]:i.SRC_ALPHA_SATURATE,[sc]:i.DST_COLOR,[ic]:i.DST_ALPHA,[nc]:i.ONE_MINUS_SRC_COLOR,[$r]:i.ONE_MINUS_SRC_ALPHA,[ac]:i.ONE_MINUS_DST_COLOR,[rc]:i.ONE_MINUS_DST_ALPHA,[cc]:i.CONSTANT_COLOR,[lc]:i.ONE_MINUS_CONSTANT_COLOR,[uc]:i.CONSTANT_ALPHA,[fc]:i.ONE_MINUS_CONSTANT_ALPHA};function nt(R,ce,ie,re,J,Y,de,Pe,tt,Ye){if(R===rn){v===!0&&(he(i.BLEND),v=!1);return}if(v===!1&&($(i.BLEND),v=!0),R!==Ko){if(R!==m||Ye!==S){if((u!==Cn||w!==Cn)&&(i.blendEquation(i.FUNC_ADD),u=Cn,w=Cn),Ye)switch(R){case jn:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ia:i.blendFunc(i.ONE,i.ONE);break;case ra:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case sa:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:lt("WebGLState: Invalid blending: ",R);break}else switch(R){case jn:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ia:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ra:lt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case sa:lt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:lt("WebGLState: Invalid blending: ",R);break}T=null,E=null,D=null,y=null,P.set(0,0,0),z=0,m=R,S=Ye}return}J=J||ce,Y=Y||ie,de=de||re,(ce!==u||J!==w)&&(i.blendEquationSeparate(pt[ce],pt[J]),u=ce,w=J),(ie!==T||re!==E||Y!==D||de!==y)&&(i.blendFuncSeparate(Fe[ie],Fe[re],Fe[Y],Fe[de]),T=ie,E=re,D=Y,y=de),(Pe.equals(P)===!1||tt!==z)&&(i.blendColor(Pe.r,Pe.g,Pe.b,tt),P.copy(Pe),z=tt),m=R,S=!1}function A(R,ce){R.side===en?he(i.CULL_FACE):$(i.CULL_FACE);let ie=R.side===yt;ce&&(ie=!ie),Be(ie),R.blending===jn&&R.transparent===!1?nt(rn):nt(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),a.setFunc(R.depthFunc),a.setTest(R.depthTest),a.setMask(R.depthWrite),s.setMask(R.colorWrite);const re=R.stencilWrite;o.setTest(re),re&&(o.setMask(R.stencilWriteMask),o.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),o.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),me(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?$(i.SAMPLE_ALPHA_TO_COVERAGE):he(i.SAMPLE_ALPHA_TO_COVERAGE)}function Be(R){M!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),M=R)}function ze(R){R!==Xo?($(i.CULL_FACE),R!==C&&(R===na?i.cullFace(i.BACK):R===qo?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):he(i.CULL_FACE),C=R}function et(R){R!==B&&(q&&i.lineWidth(R),B=R)}function me(R,ce,ie){R?($(i.POLYGON_OFFSET_FILL),(G!==ce||k!==ie)&&(i.polygonOffset(ce,ie),G=ce,k=ie)):he(i.POLYGON_OFFSET_FILL)}function rt(R){R?$(i.SCISSOR_TEST):he(i.SCISSOR_TEST)}function Me(R){R===void 0&&(R=i.TEXTURE0+K-1),te!==R&&(i.activeTexture(R),te=R)}function De(R,ce,ie){ie===void 0&&(te===null?ie=i.TEXTURE0+K-1:ie=te);let re=se[ie];re===void 0&&(re={type:void 0,texture:void 0},se[ie]=re),(re.type!==R||re.texture!==ce)&&(te!==ie&&(i.activeTexture(ie),te=ie),i.bindTexture(R,ce||X[R]),re.type=R,re.texture=ce)}function b(){const R=se[te];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function x(){try{i.compressedTexImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function I(){try{i.compressedTexImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function W(){try{i.texSubImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function Z(){try{i.texSubImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function V(){try{i.compressedTexSubImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function _e(){try{i.compressedTexSubImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function oe(){try{i.texStorage2D(...arguments)}catch(R){R("WebGLState:",R)}}function be(){try{i.texStorage3D(...arguments)}catch(R){R("WebGLState:",R)}}function xe(){try{i.texImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function j(){try{i.texImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function ee(R){qe.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),qe.copy(R))}function Ae(R){Je.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),Je.copy(R))}function ye(R,ce){let ie=c.get(ce);ie===void 0&&(ie=new WeakMap,c.set(ce,ie));let re=ie.get(R);re===void 0&&(re=i.getUniformBlockIndex(ce,R.name),ie.set(R,re))}function ue(R,ce){const re=c.get(ce).get(R);l.get(ce)!==re&&(i.uniformBlockBinding(ce,re,R.__bindingPointIndex),l.set(ce,re))}function we(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),f={},te=null,se={},h={},d=new WeakMap,p=[],g=null,v=!1,m=null,u=null,T=null,E=null,w=null,D=null,y=null,P=new We(0,0,0),z=0,S=!1,M=null,C=null,B=null,G=null,k=null,qe.set(0,0,i.canvas.width,i.canvas.height),Je.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:$,disable:he,bindFramebuffer:Le,drawBuffers:ge,useProgram:Oe,setBlending:nt,setMaterial:A,setFlipSided:Be,setCullFace:ze,setLineWidth:et,setPolygonOffset:me,setScissorTest:rt,activeTexture:Me,bindTexture:De,unbindTexture:b,compressedTexImage2D:x,compressedTexImage3D:I,texImage2D:xe,texImage3D:j,updateUBOMapping:ye,uniformBlockBinding:ue,texStorage2D:oe,texStorage3D:be,texSubImage2D:W,texSubImage3D:Z,compressedTexSubImage2D:V,compressedTexSubImage3D:_e,scissor:ee,viewport:Ae,reset:we}}function up(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Xe,f=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(b,x){return p?new OffscreenCanvas(b,x):lr("canvas")}function v(b,x,I){let W=1;const Z=De(b);if((Z.width>I||Z.height>I)&&(W=I/Math.max(Z.width,Z.height)),W<1)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap||typeof VideoFrame<"u"&&b instanceof VideoFrame){const V=Math.floor(W*Z.width),_e=Math.floor(W*Z.height);h===void 0&&(h=g(V,_e));const oe=x?g(V,_e):h;return oe.width=V,oe.height=_e,oe.getContext("2d").drawImage(b,0,0,V,_e),Ce("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+V+"x"+_e+")."),oe}else return"data"in b&&Ce("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),b;return b}function m(b){return b.generateMipmaps}function u(b){i.generateMipmap(b)}function T(b){return b.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:b.isWebGL3DRenderTarget?i.TEXTURE_3D:b.isWebGLArrayRenderTarget||b.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(b,x,I,W,Z=!1){if(b!==null){if(i[b]!==void 0)return i[b];Ce("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let V=x;if(x===i.RED&&(I===i.FLOAT&&(V=i.R32F),I===i.HALF_FLOAT&&(V=i.R16F),I===i.UNSIGNED_BYTE&&(V=i.R8)),x===i.RED_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.R8UI),I===i.UNSIGNED_SHORT&&(V=i.R16UI),I===i.UNSIGNED_INT&&(V=i.R32UI),I===i.BYTE&&(V=i.R8I),I===i.SHORT&&(V=i.R16I),I===i.INT&&(V=i.R32I)),x===i.RG&&(I===i.FLOAT&&(V=i.RG32F),I===i.HALF_FLOAT&&(V=i.RG16F),I===i.UNSIGNED_BYTE&&(V=i.RG8)),x===i.RG_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RG8UI),I===i.UNSIGNED_SHORT&&(V=i.RG16UI),I===i.UNSIGNED_INT&&(V=i.RG32UI),I===i.BYTE&&(V=i.RG8I),I===i.SHORT&&(V=i.RG16I),I===i.INT&&(V=i.RG32I)),x===i.RGB_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RGB8UI),I===i.UNSIGNED_SHORT&&(V=i.RGB16UI),I===i.UNSIGNED_INT&&(V=i.RGB32UI),I===i.BYTE&&(V=i.RGB8I),I===i.SHORT&&(V=i.RGB16I),I===i.INT&&(V=i.RGB32I)),x===i.RGBA_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RGBA8UI),I===i.UNSIGNED_SHORT&&(V=i.RGBA16UI),I===i.UNSIGNED_INT&&(V=i.RGBA32UI),I===i.BYTE&&(V=i.RGBA8I),I===i.SHORT&&(V=i.RGBA16I),I===i.INT&&(V=i.RGBA32I)),x===i.RGB&&(I===i.UNSIGNED_INT_5_9_9_9_REV&&(V=i.RGB9_E5),I===i.UNSIGNED_INT_10F_11F_11F_REV&&(V=i.R11F_G11F_B10F)),x===i.RGBA){const _e=Z?or:ke.getTransfer(W);I===i.FLOAT&&(V=i.RGBA32F),I===i.HALF_FLOAT&&(V=i.RGBA16F),I===i.UNSIGNED_BYTE&&(V=_e===Ze?i.SRGB8_ALPHA8:i.RGBA8),I===i.UNSIGNED_SHORT_4_4_4_4&&(V=i.RGBA4),I===i.UNSIGNED_SHORT_5_5_5_1&&(V=i.RGB5_A1)}return(V===i.R16F||V===i.R32F||V===i.RG16F||V===i.RG32F||V===i.RGBA16F||V===i.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function w(b,x){let I;return b?x===null||x===Ln||x===Mi?I=i.DEPTH24_STENCIL8:x===nn?I=i.DEPTH32F_STENCIL8:x===vi&&(I=i.DEPTH24_STENCIL8,Ce("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Ln||x===Mi?I=i.DEPTH_COMPONENT24:x===nn?I=i.DEPTH_COMPONENT32F:x===vi&&(I=i.DEPTH_COMPONENT16),I}function D(b,x){return m(b)===!0||b.isFramebufferTexture&&b.minFilter!==Ct&&b.minFilter!==It?Math.log2(Math.max(x.width,x.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?x.mipmaps.length:1}function y(b){const x=b.target;x.removeEventListener("dispose",y),z(x),x.isVideoTexture&&f.delete(x)}function P(b){const x=b.target;x.removeEventListener("dispose",P),M(x)}function z(b){const x=n.get(b);if(x.__webglInit===void 0)return;const I=b.source,W=d.get(I);if(W){const Z=W[x.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&S(b),Object.keys(W).length===0&&d.delete(I)}n.remove(b)}function S(b){const x=n.get(b);i.deleteTexture(x.__webglTexture);const I=b.source,W=d.get(I);delete W[x.__cacheKey],a.memory.textures--}function M(b){const x=n.get(b);if(b.depthTexture&&(b.depthTexture.dispose(),n.remove(b.depthTexture)),b.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(x.__webglFramebuffer[W]))for(let Z=0;Z<x.__webglFramebuffer[W].length;Z++)i.deleteFramebuffer(x.__webglFramebuffer[W][Z]);else i.deleteFramebuffer(x.__webglFramebuffer[W]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[W])}else{if(Array.isArray(x.__webglFramebuffer))for(let W=0;W<x.__webglFramebuffer.length;W++)i.deleteFramebuffer(x.__webglFramebuffer[W]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let W=0;W<x.__webglColorRenderbuffer.length;W++)x.__webglColorRenderbuffer[W]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[W]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const I=b.textures;for(let W=0,Z=I.length;W<Z;W++){const V=n.get(I[W]);V.__webglTexture&&(i.deleteTexture(V.__webglTexture),a.memory.textures--),n.remove(I[W])}n.remove(b)}let C=0;function B(){C=0}function G(){const b=C;return b>=r.maxTextures&&Ce("WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+r.maxTextures),C+=1,b}function k(b){const x=[];return x.push(b.wrapS),x.push(b.wrapT),x.push(b.wrapR||0),x.push(b.magFilter),x.push(b.minFilter),x.push(b.anisotropy),x.push(b.internalFormat),x.push(b.format),x.push(b.type),x.push(b.generateMipmaps),x.push(b.premultiplyAlpha),x.push(b.flipY),x.push(b.unpackAlignment),x.push(b.colorSpace),x.join()}function K(b,x){const I=n.get(b);if(b.isVideoTexture&&rt(b),b.isRenderTargetTexture===!1&&b.isExternalTexture!==!0&&b.version>0&&I.__version!==b.version){const W=b.image;if(W===null)Ce("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Ce("WebGLRenderer: Texture marked for update but image is incomplete");else{X(I,b,x);return}}else b.isExternalTexture&&(I.__webglTexture=b.sourceTexture?b.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,I.__webglTexture,i.TEXTURE0+x)}function q(b,x){const I=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&I.__version!==b.version){X(I,b,x);return}else b.isExternalTexture&&(I.__webglTexture=b.sourceTexture?b.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,I.__webglTexture,i.TEXTURE0+x)}function ne(b,x){const I=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&I.__version!==b.version){X(I,b,x);return}t.bindTexture(i.TEXTURE_3D,I.__webglTexture,i.TEXTURE0+x)}function H(b,x){const I=n.get(b);if(b.version>0&&I.__version!==b.version){$(I,b,x);return}t.bindTexture(i.TEXTURE_CUBE_MAP,I.__webglTexture,i.TEXTURE0+x)}const te={[as]:i.REPEAT,[tn]:i.CLAMP_TO_EDGE,[os]:i.MIRRORED_REPEAT},se={[Ct]:i.NEAREST,[Sc]:i.NEAREST_MIPMAP_NEAREST,[Di]:i.NEAREST_MIPMAP_LINEAR,[It]:i.LINEAR,[gr]:i.LINEAR_MIPMAP_NEAREST,[Dn]:i.LINEAR_MIPMAP_LINEAR},Se={[Ac]:i.NEVER,[Lc]:i.ALWAYS,[Rc]:i.LESS,[go]:i.LEQUAL,[wc]:i.EQUAL,[Dc]:i.GEQUAL,[Cc]:i.GREATER,[Pc]:i.NOTEQUAL};function Ge(b,x){if(x.type===nn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===It||x.magFilter===gr||x.magFilter===Di||x.magFilter===Dn||x.minFilter===It||x.minFilter===gr||x.minFilter===Di||x.minFilter===Dn)&&Ce("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(b,i.TEXTURE_WRAP_S,te[x.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,te[x.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,te[x.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,se[x.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,se[x.minFilter]),x.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,Se[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Ct||x.minFilter!==Di&&x.minFilter!==Dn||x.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const I=e.get("EXT_texture_filter_anisotropic");i.texParameterf(b,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,r.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function qe(b,x){let I=!1;b.__webglInit===void 0&&(b.__webglInit=!0,x.addEventListener("dispose",y));const W=x.source;let Z=d.get(W);Z===void 0&&(Z={},d.set(W,Z));const V=k(x);if(V!==b.__cacheKey){Z[V]===void 0&&(Z[V]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,I=!0),Z[V].usedTimes++;const _e=Z[b.__cacheKey];_e!==void 0&&(Z[b.__cacheKey].usedTimes--,_e.usedTimes===0&&S(x)),b.__cacheKey=V,b.__webglTexture=Z[V].texture}return I}function Je(b,x,I){return Math.floor(Math.floor(b/I)/x)}function Qe(b,x,I,W){const V=b.updateRanges;if(V.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,I,W,x.data);else{V.sort((j,ee)=>j.start-ee.start);let _e=0;for(let j=1;j<V.length;j++){const ee=V[_e],Ae=V[j],ye=ee.start+ee.count,ue=Je(Ae.start,x.width,4),we=Je(ee.start,x.width,4);Ae.start<=ye+1&&ue===we&&Je(Ae.start+Ae.count-1,x.width,4)===ue?ee.count=Math.max(ee.count,Ae.start+Ae.count-ee.start):(++_e,V[_e]=Ae)}V.length=_e+1;const oe=i.getParameter(i.UNPACK_ROW_LENGTH),be=i.getParameter(i.UNPACK_SKIP_PIXELS),xe=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let j=0,ee=V.length;j<ee;j++){const Ae=V[j],ye=Math.floor(Ae.start/4),ue=Math.ceil(Ae.count/4),we=ye%x.width,R=Math.floor(ye/x.width),ce=ue,ie=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,we),i.pixelStorei(i.UNPACK_SKIP_ROWS,R),t.texSubImage2D(i.TEXTURE_2D,0,we,R,ce,ie,I,W,x.data)}b.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,oe),i.pixelStorei(i.UNPACK_SKIP_PIXELS,be),i.pixelStorei(i.UNPACK_SKIP_ROWS,xe)}}function X(b,x,I){let W=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(W=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(W=i.TEXTURE_3D);const Z=qe(b,x),V=x.source;t.bindTexture(W,b.__webglTexture,i.TEXTURE0+I);const _e=n.get(V);if(V.version!==_e.__version||Z===!0){t.activeTexture(i.TEXTURE0+I);const oe=ke.getPrimaries(ke.workingColorSpace),be=x.colorSpace===mn?null:ke.getPrimaries(x.colorSpace),xe=x.colorSpace===mn||oe===be?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let j=v(x.image,!1,r.maxTextureSize);j=Me(x,j);const ee=s.convert(x.format,x.colorSpace),Ae=s.convert(x.type);let ye=E(x.internalFormat,ee,Ae,x.colorSpace,x.isVideoTexture);Ge(W,x);let ue;const we=x.mipmaps,R=x.isVideoTexture!==!0,ce=_e.__version===void 0||Z===!0,ie=V.dataReady,re=D(x,j);if(x.isDepthTexture)ye=w(x.format===bi,x.type),ce&&(R?t.texStorage2D(i.TEXTURE_2D,1,ye,j.width,j.height):t.texImage2D(i.TEXTURE_2D,0,ye,j.width,j.height,0,ee,Ae,null));else if(x.isDataTexture)if(we.length>0){R&&ce&&t.texStorage2D(i.TEXTURE_2D,re,ye,we[0].width,we[0].height);for(let J=0,Y=we.length;J<Y;J++)ue=we[J],R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ue.width,ue.height,ee,Ae,ue.data):t.texImage2D(i.TEXTURE_2D,J,ye,ue.width,ue.height,0,ee,Ae,ue.data);x.generateMipmaps=!1}else R?(ce&&t.texStorage2D(i.TEXTURE_2D,re,ye,j.width,j.height),ie&&Qe(x,j,ee,Ae)):t.texImage2D(i.TEXTURE_2D,0,ye,j.width,j.height,0,ee,Ae,j.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){R&&ce&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,ye,we[0].width,we[0].height,j.depth);for(let J=0,Y=we.length;J<Y;J++)if(ue=we[J],x.format!==Vt)if(ee!==null)if(R){if(ie)if(x.layerUpdates.size>0){const de=Oa(ue.width,ue.height,x.format,x.type);for(const Pe of x.layerUpdates){const tt=ue.data.subarray(Pe*de/ue.data.BYTES_PER_ELEMENT,(Pe+1)*de/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,Pe,ue.width,ue.height,1,ee,tt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ue.width,ue.height,j.depth,ee,ue.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,ye,ue.width,ue.height,j.depth,0,ue.data,0,0);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?ie&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ue.width,ue.height,j.depth,ee,Ae,ue.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,ye,ue.width,ue.height,j.depth,0,ee,Ae,ue.data)}else{R&&ce&&t.texStorage2D(i.TEXTURE_2D,re,ye,we[0].width,we[0].height);for(let J=0,Y=we.length;J<Y;J++)ue=we[J],x.format!==Vt?ee!==null?R?ie&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,ue.width,ue.height,ee,ue.data):t.compressedTexImage2D(i.TEXTURE_2D,J,ye,ue.width,ue.height,0,ue.data):Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ue.width,ue.height,ee,Ae,ue.data):t.texImage2D(i.TEXTURE_2D,J,ye,ue.width,ue.height,0,ee,Ae,ue.data)}else if(x.isDataArrayTexture)if(R){if(ce&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,ye,j.width,j.height,j.depth),ie)if(x.layerUpdates.size>0){const J=Oa(j.width,j.height,x.format,x.type);for(const Y of x.layerUpdates){const de=j.data.subarray(Y*J/j.data.BYTES_PER_ELEMENT,(Y+1)*J/j.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Y,j.width,j.height,1,ee,Ae,de)}x.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,ee,Ae,j.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ye,j.width,j.height,j.depth,0,ee,Ae,j.data);else if(x.isData3DTexture)R?(ce&&t.texStorage3D(i.TEXTURE_3D,re,ye,j.width,j.height,j.depth),ie&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,ee,Ae,j.data)):t.texImage3D(i.TEXTURE_3D,0,ye,j.width,j.height,j.depth,0,ee,Ae,j.data);else if(x.isFramebufferTexture){if(ce)if(R)t.texStorage2D(i.TEXTURE_2D,re,ye,j.width,j.height);else{let J=j.width,Y=j.height;for(let de=0;de<re;de++)t.texImage2D(i.TEXTURE_2D,de,ye,J,Y,0,ee,Ae,null),J>>=1,Y>>=1}}else if(we.length>0){if(R&&ce){const J=De(we[0]);t.texStorage2D(i.TEXTURE_2D,re,ye,J.width,J.height)}for(let J=0,Y=we.length;J<Y;J++)ue=we[J],R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ee,Ae,ue):t.texImage2D(i.TEXTURE_2D,J,ye,ee,Ae,ue);x.generateMipmaps=!1}else if(R){if(ce){const J=De(j);t.texStorage2D(i.TEXTURE_2D,re,ye,J.width,J.height)}ie&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ee,Ae,j)}else t.texImage2D(i.TEXTURE_2D,0,ye,ee,Ae,j);m(x)&&u(W),_e.__version=V.version,x.onUpdate&&x.onUpdate(x)}b.__version=x.version}function $(b,x,I){if(x.image.length!==6)return;const W=qe(b,x),Z=x.source;t.bindTexture(i.TEXTURE_CUBE_MAP,b.__webglTexture,i.TEXTURE0+I);const V=n.get(Z);if(Z.version!==V.__version||W===!0){t.activeTexture(i.TEXTURE0+I);const _e=ke.getPrimaries(ke.workingColorSpace),oe=x.colorSpace===mn?null:ke.getPrimaries(x.colorSpace),be=x.colorSpace===mn||_e===oe?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,be);const xe=x.isCompressedTexture||x.image[0].isCompressedTexture,j=x.image[0]&&x.image[0].isDataTexture,ee=[];for(let Y=0;Y<6;Y++)!xe&&!j?ee[Y]=v(x.image[Y],!0,r.maxCubemapSize):ee[Y]=j?x.image[Y].image:x.image[Y],ee[Y]=Me(x,ee[Y]);const Ae=ee[0],ye=s.convert(x.format,x.colorSpace),ue=s.convert(x.type),we=E(x.internalFormat,ye,ue,x.colorSpace),R=x.isVideoTexture!==!0,ce=V.__version===void 0||W===!0,ie=Z.dataReady;let re=D(x,Ae);Ge(i.TEXTURE_CUBE_MAP,x);let J;if(xe){R&&ce&&t.texStorage2D(i.TEXTURE_CUBE_MAP,re,we,Ae.width,Ae.height);for(let Y=0;Y<6;Y++){J=ee[Y].mipmaps;for(let de=0;de<J.length;de++){const Pe=J[de];x.format!==Vt?ye!==null?R?ie&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de,0,0,Pe.width,Pe.height,ye,Pe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de,we,Pe.width,Pe.height,0,Pe.data):Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de,0,0,Pe.width,Pe.height,ye,ue,Pe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de,we,Pe.width,Pe.height,0,ye,ue,Pe.data)}}}else{if(J=x.mipmaps,R&&ce){J.length>0&&re++;const Y=De(ee[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,re,we,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(j){R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,ee[Y].width,ee[Y].height,ye,ue,ee[Y].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,we,ee[Y].width,ee[Y].height,0,ye,ue,ee[Y].data);for(let de=0;de<J.length;de++){const tt=J[de].image[Y].image;R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de+1,0,0,tt.width,tt.height,ye,ue,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de+1,we,tt.width,tt.height,0,ye,ue,tt.data)}}else{R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,ye,ue,ee[Y]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,we,ye,ue,ee[Y]);for(let de=0;de<J.length;de++){const Pe=J[de];R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de+1,0,0,ye,ue,Pe.image[Y]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,de+1,we,ye,ue,Pe.image[Y])}}}m(x)&&u(i.TEXTURE_CUBE_MAP),V.__version=Z.version,x.onUpdate&&x.onUpdate(x)}b.__version=x.version}function he(b,x,I,W,Z,V){const _e=s.convert(I.format,I.colorSpace),oe=s.convert(I.type),be=E(I.internalFormat,_e,oe,I.colorSpace),xe=n.get(x),j=n.get(I);if(j.__renderTarget=x,!xe.__hasExternalTextures){const ee=Math.max(1,x.width>>V),Ae=Math.max(1,x.height>>V);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?t.texImage3D(Z,V,be,ee,Ae,x.depth,0,_e,oe,null):t.texImage2D(Z,V,be,ee,Ae,0,_e,oe,null)}t.bindFramebuffer(i.FRAMEBUFFER,b),me(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,W,Z,j.__webglTexture,0,et(x)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,W,Z,j.__webglTexture,V),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Le(b,x,I){if(i.bindRenderbuffer(i.RENDERBUFFER,b),x.depthBuffer){const W=x.depthTexture,Z=W&&W.isDepthTexture?W.type:null,V=w(x.stencilBuffer,Z),_e=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=et(x);me(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,oe,V,x.width,x.height):I?i.renderbufferStorageMultisample(i.RENDERBUFFER,oe,V,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,V,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,_e,i.RENDERBUFFER,b)}else{const W=x.textures;for(let Z=0;Z<W.length;Z++){const V=W[Z],_e=s.convert(V.format,V.colorSpace),oe=s.convert(V.type),be=E(V.internalFormat,_e,oe,V.colorSpace),xe=et(x);I&&me(x)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,xe,be,x.width,x.height):me(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xe,be,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,be,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ge(b,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,b),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const W=n.get(x.depthTexture);W.__renderTarget=x,(!W.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),K(x.depthTexture,0);const Z=W.__webglTexture,V=et(x);if(x.depthTexture.format===Si)me(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(x.depthTexture.format===bi)me(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function Oe(b){const x=n.get(b),I=b.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==b.depthTexture){const W=b.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),W){const Z=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,W.removeEventListener("dispose",Z)};W.addEventListener("dispose",Z),x.__depthDisposeCallback=Z}x.__boundDepthTexture=W}if(b.depthTexture&&!x.__autoAllocateDepthBuffer){if(I)throw new Error("target.depthTexture not supported in Cube render targets");const W=b.texture.mipmaps;W&&W.length>0?ge(x.__webglFramebuffer[0],b):ge(x.__webglFramebuffer,b)}else if(I){x.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[W]),x.__webglDepthbuffer[W]===void 0)x.__webglDepthbuffer[W]=i.createRenderbuffer(),Le(x.__webglDepthbuffer[W],b,!1);else{const Z=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer[W];i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,V)}}else{const W=b.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),Le(x.__webglDepthbuffer,b,!1);else{const Z=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,V)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function pt(b,x,I){const W=n.get(b);x!==void 0&&he(W.__webglFramebuffer,b,b.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),I!==void 0&&Oe(b)}function Fe(b){const x=b.texture,I=n.get(b),W=n.get(x);b.addEventListener("dispose",P);const Z=b.textures,V=b.isWebGLCubeRenderTarget===!0,_e=Z.length>1;if(_e||(W.__webglTexture===void 0&&(W.__webglTexture=i.createTexture()),W.__version=x.version,a.memory.textures++),V){I.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)if(x.mipmaps&&x.mipmaps.length>0){I.__webglFramebuffer[oe]=[];for(let be=0;be<x.mipmaps.length;be++)I.__webglFramebuffer[oe][be]=i.createFramebuffer()}else I.__webglFramebuffer[oe]=i.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){I.__webglFramebuffer=[];for(let oe=0;oe<x.mipmaps.length;oe++)I.__webglFramebuffer[oe]=i.createFramebuffer()}else I.__webglFramebuffer=i.createFramebuffer();if(_e)for(let oe=0,be=Z.length;oe<be;oe++){const xe=n.get(Z[oe]);xe.__webglTexture===void 0&&(xe.__webglTexture=i.createTexture(),a.memory.textures++)}if(b.samples>0&&me(b)===!1){I.__webglMultisampledFramebuffer=i.createFramebuffer(),I.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let oe=0;oe<Z.length;oe++){const be=Z[oe];I.__webglColorRenderbuffer[oe]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,I.__webglColorRenderbuffer[oe]);const xe=s.convert(be.format,be.colorSpace),j=s.convert(be.type),ee=E(be.internalFormat,xe,j,be.colorSpace,b.isXRRenderTarget===!0),Ae=et(b);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ae,ee,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,I.__webglColorRenderbuffer[oe])}i.bindRenderbuffer(i.RENDERBUFFER,null),b.depthBuffer&&(I.__webglDepthRenderbuffer=i.createRenderbuffer(),Le(I.__webglDepthRenderbuffer,b,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(V){t.bindTexture(i.TEXTURE_CUBE_MAP,W.__webglTexture),Ge(i.TEXTURE_CUBE_MAP,x);for(let oe=0;oe<6;oe++)if(x.mipmaps&&x.mipmaps.length>0)for(let be=0;be<x.mipmaps.length;be++)he(I.__webglFramebuffer[oe][be],b,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,be);else he(I.__webglFramebuffer[oe],b,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0);m(x)&&u(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let oe=0,be=Z.length;oe<be;oe++){const xe=Z[oe],j=n.get(xe);let ee=i.TEXTURE_2D;(b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(ee=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ee,j.__webglTexture),Ge(ee,xe),he(I.__webglFramebuffer,b,xe,i.COLOR_ATTACHMENT0+oe,ee,0),m(xe)&&u(ee)}t.unbindTexture()}else{let oe=i.TEXTURE_2D;if((b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(oe=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(oe,W.__webglTexture),Ge(oe,x),x.mipmaps&&x.mipmaps.length>0)for(let be=0;be<x.mipmaps.length;be++)he(I.__webglFramebuffer[be],b,x,i.COLOR_ATTACHMENT0,oe,be);else he(I.__webglFramebuffer,b,x,i.COLOR_ATTACHMENT0,oe,0);m(x)&&u(oe),t.unbindTexture()}b.depthBuffer&&Oe(b)}function nt(b){const x=b.textures;for(let I=0,W=x.length;I<W;I++){const Z=x[I];if(m(Z)){const V=T(b),_e=n.get(Z).__webglTexture;t.bindTexture(V,_e),u(V),t.unbindTexture()}}}const A=[],Be=[];function ze(b){if(b.samples>0){if(me(b)===!1){const x=b.textures,I=b.width,W=b.height;let Z=i.COLOR_BUFFER_BIT;const V=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_e=n.get(b),oe=x.length>1;if(oe)for(let xe=0;xe<x.length;xe++)t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer);const be=b.texture.mipmaps;be&&be.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let xe=0;xe<x.length;xe++){if(b.resolveDepthBuffer&&(b.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),b.stencilBuffer&&b.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),oe){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,_e.__webglColorRenderbuffer[xe]);const j=n.get(x[xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,j,0)}i.blitFramebuffer(0,0,I,W,0,0,I,W,Z,i.NEAREST),l===!0&&(A.length=0,Be.length=0,A.push(i.COLOR_ATTACHMENT0+xe),b.depthBuffer&&b.resolveDepthBuffer===!1&&(A.push(V),Be.push(V),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Be)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,A))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),oe)for(let xe=0;xe<x.length;xe++){t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,_e.__webglColorRenderbuffer[xe]);const j=n.get(x[xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,j,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(b.depthBuffer&&b.resolveDepthBuffer===!1&&l){const x=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function et(b){return Math.min(r.maxSamples,b.samples)}function me(b){const x=n.get(b);return b.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function rt(b){const x=a.render.frame;f.get(b)!==x&&(f.set(b,x),b.update())}function Me(b,x){const I=b.colorSpace,W=b.format,Z=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||I!==ni&&I!==mn&&(ke.getTransfer(I)===Ze?(W!==Vt||Z!==Xt)&&Ce("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):lt("WebGLTextures: Unsupported texture color space:",I)),x}function De(b){return typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement?(c.width=b.naturalWidth||b.width,c.height=b.naturalHeight||b.height):typeof VideoFrame<"u"&&b instanceof VideoFrame?(c.width=b.displayWidth,c.height=b.displayHeight):(c.width=b.width,c.height=b.height),c}this.allocateTextureUnit=G,this.resetTextureUnits=B,this.setTexture2D=K,this.setTexture2DArray=q,this.setTexture3D=ne,this.setTextureCube=H,this.rebindTextures=pt,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=nt,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=he,this.useMultisampledRTT=me}function fp(i,e){function t(n,r=mn){let s;const a=ke.getTransfer(r);if(n===Xt)return i.UNSIGNED_BYTE;if(n===zs)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Vs)return i.UNSIGNED_SHORT_5_5_5_1;if(n===ho)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===po)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===uo)return i.BYTE;if(n===fo)return i.SHORT;if(n===vi)return i.UNSIGNED_SHORT;if(n===Bs)return i.INT;if(n===Ln)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===ri)return i.HALF_FLOAT;if(n===mo)return i.ALPHA;if(n===xo)return i.RGB;if(n===Vt)return i.RGBA;if(n===Si)return i.DEPTH_COMPONENT;if(n===bi)return i.DEPTH_STENCIL;if(n===_o)return i.RED;if(n===Gs)return i.RED_INTEGER;if(n===Hs)return i.RG;if(n===ks)return i.RG_INTEGER;if(n===Ws)return i.RGBA_INTEGER;if(n===nr||n===ir||n===rr||n===sr)if(a===Ze)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===nr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ir)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===rr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===sr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===nr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ir)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===rr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===sr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===cs||n===ls||n===us||n===fs)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===cs)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ls)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===us)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===fs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===hs||n===ds||n===ps)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===hs||n===ds)return a===Ze?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ps)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ms||n===xs||n===_s||n===gs||n===vs||n===Ms||n===Ss||n===bs||n===Es||n===ys||n===Ts||n===As||n===Rs||n===ws)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ms)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===xs)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===_s)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===gs)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===vs)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ms)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ss)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===bs)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Es)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ys)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ts)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===As)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Rs)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ws)return a===Ze?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Cs||n===Ps||n===Ds)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Cs)return a===Ze?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ps)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ds)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ls||n===Us||n===Is||n===Ns)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Ls)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Us)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Is)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ns)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Mi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const hp=`
3924
+ void main() {
3925
+
3926
+ gl_Position = vec4( position, 1.0 );
3927
+
3928
+ }`,dp=`
3929
+ uniform sampler2DArray depthColor;
3930
+ uniform float depthWidth;
3931
+ uniform float depthHeight;
3932
+
3933
+ void main() {
3934
+
3935
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3936
+
3937
+ if ( coord.x >= 1.0 ) {
3938
+
3939
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3940
+
3941
+ } else {
3942
+
3943
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3944
+
3945
+ }
3946
+
3947
+ }`;class pp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Do(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new cn({vertexShader:hp,fragmentShader:dp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new vn(new dr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class mp extends In{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,f=null,h=null,d=null,p=null,g=null;const v=typeof XRWebGLBinding<"u",m=new pp,u={},T=t.getContextAttributes();let E=null,w=null;const D=[],y=[],P=new Xe;let z=null;const S=new Ut;S.viewport=new $e;const M=new Ut;M.viewport=new $e;const C=[S,M],B=new Ul;let G=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let $=D[X];return $===void 0&&($=new zr,D[X]=$),$.getTargetRaySpace()},this.getControllerGrip=function(X){let $=D[X];return $===void 0&&($=new zr,D[X]=$),$.getGripSpace()},this.getHand=function(X){let $=D[X];return $===void 0&&($=new zr,D[X]=$),$.getHandSpace()};function K(X){const $=y.indexOf(X.inputSource);if($===-1)return;const he=D[$];he!==void 0&&(he.update(X.inputSource,X.frame,c||a),he.dispatchEvent({type:X.type,data:X.inputSource}))}function q(){r.removeEventListener("select",K),r.removeEventListener("selectstart",K),r.removeEventListener("selectend",K),r.removeEventListener("squeeze",K),r.removeEventListener("squeezestart",K),r.removeEventListener("squeezeend",K),r.removeEventListener("end",q),r.removeEventListener("inputsourceschange",ne);for(let X=0;X<D.length;X++){const $=y[X];$!==null&&(y[X]=null,D[X].disconnect($))}G=null,k=null,m.reset();for(const X in u)delete u[X];e.setRenderTarget(E),p=null,d=null,h=null,r=null,w=null,Qe.stop(),n.isPresenting=!1,e.setPixelRatio(z),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&Ce("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&Ce("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(r,t)),h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(E=e.getRenderTarget(),r.addEventListener("select",K),r.addEventListener("selectstart",K),r.addEventListener("selectend",K),r.addEventListener("squeeze",K),r.addEventListener("squeezestart",K),r.addEventListener("squeezeend",K),r.addEventListener("end",q),r.addEventListener("inputsourceschange",ne),T.xrCompatible!==!0&&await t.makeXRCompatible(),z=e.getPixelRatio(),e.getSize(P),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let he=null,Le=null,ge=null;T.depth&&(ge=T.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,he=T.stencil?bi:Si,Le=T.stencil?Mi:Ln);const Oe={colorFormat:t.RGBA8,depthFormat:ge,scaleFactor:s};h=this.getBinding(),d=h.createProjectionLayer(Oe),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),w=new Un(d.textureWidth,d.textureHeight,{format:Vt,type:Xt,depthTexture:new Po(d.textureWidth,d.textureHeight,Le,void 0,void 0,void 0,void 0,void 0,void 0,he),stencilBuffer:T.stencil,colorSpace:e.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const he={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,he),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),w=new Un(p.framebufferWidth,p.framebufferHeight,{format:Vt,type:Xt,colorSpace:e.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Qe.setContext(r),Qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ne(X){for(let $=0;$<X.removed.length;$++){const he=X.removed[$],Le=y.indexOf(he);Le>=0&&(y[Le]=null,D[Le].disconnect(he))}for(let $=0;$<X.added.length;$++){const he=X.added[$];let Le=y.indexOf(he);if(Le===-1){for(let Oe=0;Oe<D.length;Oe++)if(Oe>=y.length){y.push(he),Le=Oe;break}else if(y[Oe]===null){y[Oe]=he,Le=Oe;break}if(Le===-1)break}const ge=D[Le];ge&&ge.connect(he)}}const H=new N,te=new N;function se(X,$,he){H.setFromMatrixPosition($.matrixWorld),te.setFromMatrixPosition(he.matrixWorld);const Le=H.distanceTo(te),ge=$.projectionMatrix.elements,Oe=he.projectionMatrix.elements,pt=ge[14]/(ge[10]-1),Fe=ge[14]/(ge[10]+1),nt=(ge[9]+1)/ge[5],A=(ge[9]-1)/ge[5],Be=(ge[8]-1)/ge[0],ze=(Oe[8]+1)/Oe[0],et=pt*Be,me=pt*ze,rt=Le/(-Be+ze),Me=rt*-Be;if($.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Me),X.translateZ(rt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),ge[10]===-1)X.projectionMatrix.copy($.projectionMatrix),X.projectionMatrixInverse.copy($.projectionMatrixInverse);else{const De=pt+rt,b=Fe+rt,x=et-Me,I=me+(Le-Me),W=nt*Fe/b*De,Z=A*Fe/b*De;X.projectionMatrix.makePerspective(x,I,W,Z,De,b),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function Se(X,$){$===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices($.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;let $=X.near,he=X.far;m.texture!==null&&(m.depthNear>0&&($=m.depthNear),m.depthFar>0&&(he=m.depthFar)),B.near=M.near=S.near=$,B.far=M.far=S.far=he,(G!==B.near||k!==B.far)&&(r.updateRenderState({depthNear:B.near,depthFar:B.far}),G=B.near,k=B.far),B.layers.mask=X.layers.mask|6,S.layers.mask=B.layers.mask&3,M.layers.mask=B.layers.mask&5;const Le=X.parent,ge=B.cameras;Se(B,Le);for(let Oe=0;Oe<ge.length;Oe++)Se(ge[Oe],Le);ge.length===2?se(B,S,M):B.projectionMatrix.copy(S.projectionMatrix),Ge(X,B,Le)};function Ge(X,$,he){he===null?X.matrix.copy($.matrixWorld):(X.matrix.copy(he.matrixWorld),X.matrix.invert(),X.matrix.multiply($.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy($.projectionMatrix),X.projectionMatrixInverse.copy($.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=yi*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(X){l=X,d!==null&&(d.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(X){return u[X]};let qe=null;function Je(X,$){if(f=$.getViewerPose(c||a),g=$,f!==null){const he=f.views;p!==null&&(e.setRenderTargetFramebuffer(w,p.framebuffer),e.setRenderTarget(w));let Le=!1;he.length!==B.cameras.length&&(B.cameras.length=0,Le=!0);for(let Fe=0;Fe<he.length;Fe++){const nt=he[Fe];let A=null;if(p!==null)A=p.getViewport(nt);else{const ze=h.getViewSubImage(d,nt);A=ze.viewport,Fe===0&&(e.setRenderTargetTextures(w,ze.colorTexture,ze.depthStencilTexture),e.setRenderTarget(w))}let Be=C[Fe];Be===void 0&&(Be=new Ut,Be.layers.enable(Fe),Be.viewport=new $e,C[Fe]=Be),Be.matrix.fromArray(nt.transform.matrix),Be.matrix.decompose(Be.position,Be.quaternion,Be.scale),Be.projectionMatrix.fromArray(nt.projectionMatrix),Be.projectionMatrixInverse.copy(Be.projectionMatrix).invert(),Be.viewport.set(A.x,A.y,A.width,A.height),Fe===0&&(B.matrix.copy(Be.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),Le===!0&&B.cameras.push(Be)}const ge=r.enabledFeatures;if(ge&&ge.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&v){h=n.getBinding();const Fe=h.getDepthInformation(he[0]);Fe&&Fe.isValid&&Fe.texture&&m.init(Fe,r.renderState)}if(ge&&ge.includes("camera-access")&&v){e.state.unbindTexture(),h=n.getBinding();for(let Fe=0;Fe<he.length;Fe++){const nt=he[Fe].camera;if(nt){let A=u[nt];A||(A=new Do,u[nt]=A);const Be=h.getCameraImage(nt);A.sourceTexture=Be}}}}for(let he=0;he<D.length;he++){const Le=y[he],ge=D[he];Le!==null&&ge!==void 0&&ge.update(Le,$,c||a)}qe&&qe(X,$),$.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:$}),g=null}const Qe=new Uo;Qe.setAnimationLoop(Je),this.setAnimationLoop=function(X){qe=X},this.dispose=function(){}}}const Rn=new on,xp=new it;function _p(i,e){function t(m,u){m.matrixAutoUpdate===!0&&m.updateMatrix(),u.value.copy(m.matrix)}function n(m,u){u.color.getRGB(m.fogColor.value,Ao(i)),u.isFog?(m.fogNear.value=u.near,m.fogFar.value=u.far):u.isFogExp2&&(m.fogDensity.value=u.density)}function r(m,u,T,E,w){u.isMeshBasicMaterial||u.isMeshLambertMaterial?s(m,u):u.isMeshToonMaterial?(s(m,u),h(m,u)):u.isMeshPhongMaterial?(s(m,u),f(m,u)):u.isMeshStandardMaterial?(s(m,u),d(m,u),u.isMeshPhysicalMaterial&&p(m,u,w)):u.isMeshMatcapMaterial?(s(m,u),g(m,u)):u.isMeshDepthMaterial?s(m,u):u.isMeshDistanceMaterial?(s(m,u),v(m,u)):u.isMeshNormalMaterial?s(m,u):u.isLineBasicMaterial?(a(m,u),u.isLineDashedMaterial&&o(m,u)):u.isPointsMaterial?l(m,u,T,E):u.isSpriteMaterial?c(m,u):u.isShadowMaterial?(m.color.value.copy(u.color),m.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function s(m,u){m.opacity.value=u.opacity,u.color&&m.diffuse.value.copy(u.color),u.emissive&&m.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(m.map.value=u.map,t(u.map,m.mapTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap,t(u.alphaMap,m.alphaMapTransform)),u.bumpMap&&(m.bumpMap.value=u.bumpMap,t(u.bumpMap,m.bumpMapTransform),m.bumpScale.value=u.bumpScale,u.side===yt&&(m.bumpScale.value*=-1)),u.normalMap&&(m.normalMap.value=u.normalMap,t(u.normalMap,m.normalMapTransform),m.normalScale.value.copy(u.normalScale),u.side===yt&&m.normalScale.value.negate()),u.displacementMap&&(m.displacementMap.value=u.displacementMap,t(u.displacementMap,m.displacementMapTransform),m.displacementScale.value=u.displacementScale,m.displacementBias.value=u.displacementBias),u.emissiveMap&&(m.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,m.emissiveMapTransform)),u.specularMap&&(m.specularMap.value=u.specularMap,t(u.specularMap,m.specularMapTransform)),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest);const T=e.get(u),E=T.envMap,w=T.envMapRotation;E&&(m.envMap.value=E,Rn.copy(w),Rn.x*=-1,Rn.y*=-1,Rn.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Rn.y*=-1,Rn.z*=-1),m.envMapRotation.value.setFromMatrix4(xp.makeRotationFromEuler(Rn)),m.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=u.reflectivity,m.ior.value=u.ior,m.refractionRatio.value=u.refractionRatio),u.lightMap&&(m.lightMap.value=u.lightMap,m.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,m.lightMapTransform)),u.aoMap&&(m.aoMap.value=u.aoMap,m.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,m.aoMapTransform))}function a(m,u){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,u.map&&(m.map.value=u.map,t(u.map,m.mapTransform))}function o(m,u){m.dashSize.value=u.dashSize,m.totalSize.value=u.dashSize+u.gapSize,m.scale.value=u.scale}function l(m,u,T,E){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,m.size.value=u.size*T,m.scale.value=E*.5,u.map&&(m.map.value=u.map,t(u.map,m.uvTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap,t(u.alphaMap,m.alphaMapTransform)),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest)}function c(m,u){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,m.rotation.value=u.rotation,u.map&&(m.map.value=u.map,t(u.map,m.mapTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap,t(u.alphaMap,m.alphaMapTransform)),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest)}function f(m,u){m.specular.value.copy(u.specular),m.shininess.value=Math.max(u.shininess,1e-4)}function h(m,u){u.gradientMap&&(m.gradientMap.value=u.gradientMap)}function d(m,u){m.metalness.value=u.metalness,u.metalnessMap&&(m.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,m.metalnessMapTransform)),m.roughness.value=u.roughness,u.roughnessMap&&(m.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,m.roughnessMapTransform)),u.envMap&&(m.envMapIntensity.value=u.envMapIntensity)}function p(m,u,T){m.ior.value=u.ior,u.sheen>0&&(m.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),m.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(m.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,m.sheenColorMapTransform)),u.sheenRoughnessMap&&(m.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,m.sheenRoughnessMapTransform))),u.clearcoat>0&&(m.clearcoat.value=u.clearcoat,m.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(m.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,m.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(m.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===yt&&m.clearcoatNormalScale.value.negate())),u.dispersion>0&&(m.dispersion.value=u.dispersion),u.iridescence>0&&(m.iridescence.value=u.iridescence,m.iridescenceIOR.value=u.iridescenceIOR,m.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(m.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,m.iridescenceMapTransform)),u.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),u.transmission>0&&(m.transmission.value=u.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),u.transmissionMap&&(m.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,m.transmissionMapTransform)),m.thickness.value=u.thickness,u.thicknessMap&&(m.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=u.attenuationDistance,m.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(m.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(m.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=u.specularIntensity,m.specularColor.value.copy(u.specularColor),u.specularColorMap&&(m.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,m.specularColorMapTransform)),u.specularIntensityMap&&(m.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,u){u.matcap&&(m.matcap.value=u.matcap)}function v(m,u){const T=e.get(u).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function gp(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(T,E){const w=E.program;n.uniformBlockBinding(T,w)}function c(T,E){let w=r[T.id];w===void 0&&(g(T),w=f(T),r[T.id]=w,T.addEventListener("dispose",m));const D=E.program;n.updateUBOMapping(T,D);const y=e.render.frame;s[T.id]!==y&&(d(T),s[T.id]=y)}function f(T){const E=h();T.__bindingPointIndex=E;const w=i.createBuffer(),D=T.__size,y=T.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,D,y),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,E,w),w}function h(){for(let T=0;T<o;T++)if(a.indexOf(T)===-1)return a.push(T),T;return lt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(T){const E=r[T.id],w=T.uniforms,D=T.__cache;i.bindBuffer(i.UNIFORM_BUFFER,E);for(let y=0,P=w.length;y<P;y++){const z=Array.isArray(w[y])?w[y]:[w[y]];for(let S=0,M=z.length;S<M;S++){const C=z[S];if(p(C,y,S,D)===!0){const B=C.__offset,G=Array.isArray(C.value)?C.value:[C.value];let k=0;for(let K=0;K<G.length;K++){const q=G[K],ne=v(q);typeof q=="number"||typeof q=="boolean"?(C.__data[0]=q,i.bufferSubData(i.UNIFORM_BUFFER,B+k,C.__data)):q.isMatrix3?(C.__data[0]=q.elements[0],C.__data[1]=q.elements[1],C.__data[2]=q.elements[2],C.__data[3]=0,C.__data[4]=q.elements[3],C.__data[5]=q.elements[4],C.__data[6]=q.elements[5],C.__data[7]=0,C.__data[8]=q.elements[6],C.__data[9]=q.elements[7],C.__data[10]=q.elements[8],C.__data[11]=0):(q.toArray(C.__data,k),k+=ne.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,B,C.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(T,E,w,D){const y=T.value,P=E+"_"+w;if(D[P]===void 0)return typeof y=="number"||typeof y=="boolean"?D[P]=y:D[P]=y.clone(),!0;{const z=D[P];if(typeof y=="number"||typeof y=="boolean"){if(z!==y)return D[P]=y,!0}else if(z.equals(y)===!1)return z.copy(y),!0}return!1}function g(T){const E=T.uniforms;let w=0;const D=16;for(let P=0,z=E.length;P<z;P++){const S=Array.isArray(E[P])?E[P]:[E[P]];for(let M=0,C=S.length;M<C;M++){const B=S[M],G=Array.isArray(B.value)?B.value:[B.value];for(let k=0,K=G.length;k<K;k++){const q=G[k],ne=v(q),H=w%D,te=H%ne.boundary,se=H+te;w+=te,se!==0&&D-se<ne.storage&&(w+=D-se),B.__data=new Float32Array(ne.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=w,w+=ne.storage}}}const y=w%D;return y>0&&(w+=D-y),T.__size=w,T.__cache={},this}function v(T){const E={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(E.boundary=4,E.storage=4):T.isVector2?(E.boundary=8,E.storage=8):T.isVector3||T.isColor?(E.boundary=16,E.storage=12):T.isVector4?(E.boundary=16,E.storage=16):T.isMatrix3?(E.boundary=48,E.storage=48):T.isMatrix4?(E.boundary=64,E.storage=64):T.isTexture?Ce("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ce("WebGLRenderer: Unsupported uniform value type.",T),E}function m(T){const E=T.target;E.removeEventListener("dispose",m);const w=a.indexOf(E.__bindingPointIndex);a.splice(w,1),i.deleteBuffer(r[E.id]),delete r[E.id],delete s[E.id]}function u(){for(const T in r)i.deleteBuffer(r[T]);a=[],r={},s={}}return{bind:l,update:c,dispose:u}}const vp=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Jt=null;function Mp(){return Jt===null&&(Jt=new Sl(vp,32,32,Hs,ri),Jt.minFilter=It,Jt.magFilter=It,Jt.wrapS=tn,Jt.wrapT=tn,Jt.generateMipmaps=!1,Jt.needsUpdate=!0),Jt}class Lp{constructor(e={}){const{canvas:t=Uc(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const g=new Set([Ws,ks,Gs]),v=new Set([Xt,Ln,vi,Mi,zs,Vs]),m=new Uint32Array(4),u=new Int32Array(4);let T=null,E=null;const w=[],D=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=_n,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let P=!1;this._outputColorSpace=Lt;let z=0,S=0,M=null,C=-1,B=null;const G=new $e,k=new $e;let K=null;const q=new We(0);let ne=0,H=t.width,te=t.height,se=1,Se=null,Ge=null;const qe=new $e(0,0,H,te),Je=new $e(0,0,H,te);let Qe=!1;const X=new Ks;let $=!1,he=!1;const Le=new it,ge=new N,Oe=new $e,pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Fe=!1;function nt(){return M===null?se:1}let A=n;function Be(_,L){return t.getContext(_,L)}try{const _={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:f,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r181"),t.addEventListener("webglcontextlost",J,!1),t.addEventListener("webglcontextrestored",Y,!1),t.addEventListener("webglcontextcreationerror",de,!1),A===null){const L="webgl2";if(A=Be(L,_),A===null)throw Be(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(_){throw _("WebGLRenderer: "+_.message),_}let ze,et,me,rt,Me,De,b,x,I,W,Z,V,_e,oe,be,xe,j,ee,Ae,ye,ue,we,R,ce;function ie(){ze=new Ch(A),ze.init(),we=new fp(A,ze),et=new Mh(A,ze,e,we),me=new lp(A,ze),et.reversedDepthBuffer&&d&&me.buffers.depth.setReversed(!0),rt=new Lh(A),Me=new $d,De=new up(A,ze,me,Me,et,we,rt),b=new bh(y),x=new wh(y),I=new Nl(A),R=new gh(A,I),W=new Ph(A,I,rt,R),Z=new Ih(A,W,I,rt),Ae=new Uh(A,et,De),xe=new Sh(Me),V=new Zd(y,b,x,ze,et,R,xe),_e=new _p(y,Me),oe=new Jd,be=new rp(ze),ee=new _h(y,b,x,me,Z,p,l),j=new op(y,Z,et),ce=new gp(A,rt,et,me),ye=new vh(A,ze,rt),ue=new Dh(A,ze,rt),rt.programs=V.programs,y.capabilities=et,y.extensions=ze,y.properties=Me,y.renderLists=oe,y.shadowMap=j,y.state=me,y.info=rt}ie();const re=new mp(y,A);this.xr=re,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const _=ze.get("WEBGL_lose_context");_&&_.loseContext()},this.forceContextRestore=function(){const _=ze.get("WEBGL_lose_context");_&&_.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(_){_!==void 0&&(se=_,this.setSize(H,te,!1))},this.getSize=function(_){return _.set(H,te)},this.setSize=function(_,L,F=!0){if(re.isPresenting){Ce("WebGLRenderer: Can't change size while VR device is presenting.");return}H=_,te=L,t.width=Math.floor(_*se),t.height=Math.floor(L*se),F===!0&&(t.style.width=_+"px",t.style.height=L+"px"),this.setViewport(0,0,_,L)},this.getDrawingBufferSize=function(_){return _.set(H*se,te*se).floor()},this.setDrawingBufferSize=function(_,L,F){H=_,te=L,se=F,t.width=Math.floor(_*F),t.height=Math.floor(L*F),this.setViewport(0,0,_,L)},this.getCurrentViewport=function(_){return _.copy(G)},this.getViewport=function(_){return _.copy(qe)},this.setViewport=function(_,L,F,O){_.isVector4?qe.set(_.x,_.y,_.z,_.w):qe.set(_,L,F,O),me.viewport(G.copy(qe).multiplyScalar(se).round())},this.getScissor=function(_){return _.copy(Je)},this.setScissor=function(_,L,F,O){_.isVector4?Je.set(_.x,_.y,_.z,_.w):Je.set(_,L,F,O),me.scissor(k.copy(Je).multiplyScalar(se).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(_){me.setScissorTest(Qe=_)},this.setOpaqueSort=function(_){Se=_},this.setTransparentSort=function(_){Ge=_},this.getClearColor=function(_){return _.copy(ee.getClearColor())},this.setClearColor=function(){ee.setClearColor(...arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha(...arguments)},this.clear=function(_=!0,L=!0,F=!0){let O=0;if(_){let U=!1;if(M!==null){const Q=M.texture.format;U=g.has(Q)}if(U){const Q=M.texture.type,le=v.has(Q),pe=ee.getClearColor(),fe=ee.getClearAlpha(),Te=pe.r,Re=pe.g,ve=pe.b;le?(m[0]=Te,m[1]=Re,m[2]=ve,m[3]=fe,A.clearBufferuiv(A.COLOR,0,m)):(u[0]=Te,u[1]=Re,u[2]=ve,u[3]=fe,A.clearBufferiv(A.COLOR,0,u))}else O|=A.COLOR_BUFFER_BIT}L&&(O|=A.DEPTH_BUFFER_BIT),F&&(O|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(O)},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(){t.removeEventListener("webglcontextlost",J,!1),t.removeEventListener("webglcontextrestored",Y,!1),t.removeEventListener("webglcontextcreationerror",de,!1),ee.dispose(),oe.dispose(),be.dispose(),Me.dispose(),b.dispose(),x.dispose(),Z.dispose(),R.dispose(),ce.dispose(),V.dispose(),re.dispose(),re.removeEventListener("sessionstart",Zs),re.removeEventListener("sessionend",$s),Mn.stop()};function J(_){_.preventDefault(),ua("WebGLRenderer: Context Lost."),P=!0}function Y(){ua("WebGLRenderer: Context Restored."),P=!1;const _=rt.autoReset,L=j.enabled,F=j.autoUpdate,O=j.needsUpdate,U=j.type;ie(),rt.autoReset=_,j.enabled=L,j.autoUpdate=F,j.needsUpdate=O,j.type=U}function de(_){lt("WebGLRenderer: A WebGL context could not be created. Reason: ",_.statusMessage)}function Pe(_){const L=_.target;L.removeEventListener("dispose",Pe),tt(L)}function tt(_){Ye(_),Me.remove(_)}function Ye(_){const L=Me.get(_).programs;L!==void 0&&(L.forEach(function(F){V.releaseProgram(F)}),_.isShaderMaterial&&V.releaseShaderCache(_))}this.renderBufferDirect=function(_,L,F,O,U,Q){L===null&&(L=pt);const le=U.isMesh&&U.matrixWorld.determinant()<0,pe=zo(_,L,F,O,U);me.setMaterial(O,le);let fe=F.index,Te=1;if(O.wireframe===!0){if(fe=W.getWireframeAttribute(F),fe===void 0)return;Te=2}const Re=F.drawRange,ve=F.attributes.position;let Ve=Re.start*Te,Ke=(Re.start+Re.count)*Te;Q!==null&&(Ve=Math.max(Ve,Q.start*Te),Ke=Math.min(Ke,(Q.start+Q.count)*Te)),fe!==null?(Ve=Math.max(Ve,0),Ke=Math.min(Ke,fe.count)):ve!=null&&(Ve=Math.max(Ve,0),Ke=Math.min(Ke,ve.count));const ot=Ke-Ve;if(ot<0||ot===1/0)return;R.setup(U,O,pe,F,fe);let ct,je=ye;if(fe!==null&&(ct=I.get(fe),je=ue,je.setIndex(ct)),U.isMesh)O.wireframe===!0?(me.setLineWidth(O.wireframeLinewidth*nt()),je.setMode(A.LINES)):je.setMode(A.TRIANGLES);else if(U.isLine){let Ee=O.linewidth;Ee===void 0&&(Ee=1),me.setLineWidth(Ee*nt()),U.isLineSegments?je.setMode(A.LINES):U.isLineLoop?je.setMode(A.LINE_LOOP):je.setMode(A.LINE_STRIP)}else U.isPoints?je.setMode(A.POINTS):U.isSprite&&je.setMode(A.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)Ei("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),je.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(ze.get("WEBGL_multi_draw"))je.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const Ee=U._multiDrawStarts,st=U._multiDrawCounts,He=U._multiDrawCount,Tt=fe?I.get(fe).bytesPerElement:1,Nn=Me.get(O).currentProgram.getUniforms();for(let At=0;At<He;At++)Nn.setValue(A,"_gl_DrawID",At),je.render(Ee[At]/Tt,st[At])}else if(U.isInstancedMesh)je.renderInstances(Ve,ot,U.count);else if(F.isInstancedBufferGeometry){const Ee=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,st=Math.min(F.instanceCount,Ee);je.renderInstances(Ve,ot,st)}else je.render(Ve,ot)};function Gt(_,L,F){_.transparent===!0&&_.side===en&&_.forceSinglePass===!1?(_.side=yt,_.needsUpdate=!0,Pi(_,L,F),_.side=gn,_.needsUpdate=!0,Pi(_,L,F),_.side=en):Pi(_,L,F)}this.compile=function(_,L,F=null){F===null&&(F=_),E=be.get(F),E.init(L),D.push(E),F.traverseVisible(function(U){U.isLight&&U.layers.test(L.layers)&&(E.pushLight(U),U.castShadow&&E.pushShadow(U))}),_!==F&&_.traverseVisible(function(U){U.isLight&&U.layers.test(L.layers)&&(E.pushLight(U),U.castShadow&&E.pushShadow(U))}),E.setupLights();const O=new Set;return _.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;const Q=U.material;if(Q)if(Array.isArray(Q))for(let le=0;le<Q.length;le++){const pe=Q[le];Gt(pe,F,U),O.add(pe)}else Gt(Q,F,U),O.add(Q)}),E=D.pop(),O},this.compileAsync=function(_,L,F=null){const O=this.compile(_,L,F);return new Promise(U=>{function Q(){if(O.forEach(function(le){Me.get(le).currentProgram.isReady()&&O.delete(le)}),O.size===0){U(_);return}setTimeout(Q,10)}ze.get("KHR_parallel_shader_compile")!==null?Q():setTimeout(Q,10)})};let Nt=null;function Bo(_){Nt&&Nt(_)}function Zs(){Mn.stop()}function $s(){Mn.start()}const Mn=new Uo;Mn.setAnimationLoop(Bo),typeof self<"u"&&Mn.setContext(self),this.setAnimationLoop=function(_){Nt=_,re.setAnimationLoop(_),_===null?Mn.stop():Mn.start()},re.addEventListener("sessionstart",Zs),re.addEventListener("sessionend",$s),this.render=function(_,L){if(L!==void 0&&L.isCamera!==!0){lt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(L),L=re.getCamera()),_.isScene===!0&&_.onBeforeRender(y,_,L,M),E=be.get(_,D.length),E.init(L),D.push(E),Le.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),X.setFromProjectionMatrix(Le,kt,L.reversedDepth),he=this.localClippingEnabled,$=xe.init(this.clippingPlanes,he),T=oe.get(_,w.length),T.init(),w.push(T),re.enabled===!0&&re.isPresenting===!0){const Q=y.xr.getDepthSensingMesh();Q!==null&&xr(Q,L,-1/0,y.sortObjects)}xr(_,L,0,y.sortObjects),T.finish(),y.sortObjects===!0&&T.sort(Se,Ge),Fe=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,Fe&&ee.addToRenderList(T,_),this.info.render.frame++,$===!0&&xe.beginShadows();const F=E.state.shadowsArray;j.render(F,_,L),$===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset();const O=T.opaque,U=T.transmissive;if(E.setupLights(),L.isArrayCamera){const Q=L.cameras;if(U.length>0)for(let le=0,pe=Q.length;le<pe;le++){const fe=Q[le];Js(O,U,_,fe)}Fe&&ee.render(_);for(let le=0,pe=Q.length;le<pe;le++){const fe=Q[le];js(T,_,fe,fe.viewport)}}else U.length>0&&Js(O,U,_,L),Fe&&ee.render(_),js(T,_,L);M!==null&&S===0&&(De.updateMultisampleRenderTarget(M),De.updateRenderTargetMipmap(M)),_.isScene===!0&&_.onAfterRender(y,_,L),R.resetDefaultState(),C=-1,B=null,D.pop(),D.length>0?(E=D[D.length-1],$===!0&&xe.setGlobalState(y.clippingPlanes,E.state.camera)):E=null,w.pop(),w.length>0?T=w[w.length-1]:T=null};function xr(_,L,F,O){if(_.visible===!1)return;if(_.layers.test(L.layers)){if(_.isGroup)F=_.renderOrder;else if(_.isLOD)_.autoUpdate===!0&&_.update(L);else if(_.isLight)E.pushLight(_),_.castShadow&&E.pushShadow(_);else if(_.isSprite){if(!_.frustumCulled||X.intersectsSprite(_)){O&&Oe.setFromMatrixPosition(_.matrixWorld).applyMatrix4(Le);const le=Z.update(_),pe=_.material;pe.visible&&T.push(_,le,pe,F,Oe.z,null)}}else if((_.isMesh||_.isLine||_.isPoints)&&(!_.frustumCulled||X.intersectsObject(_))){const le=Z.update(_),pe=_.material;if(O&&(_.boundingSphere!==void 0?(_.boundingSphere===null&&_.computeBoundingSphere(),Oe.copy(_.boundingSphere.center)):(le.boundingSphere===null&&le.computeBoundingSphere(),Oe.copy(le.boundingSphere.center)),Oe.applyMatrix4(_.matrixWorld).applyMatrix4(Le)),Array.isArray(pe)){const fe=le.groups;for(let Te=0,Re=fe.length;Te<Re;Te++){const ve=fe[Te],Ve=pe[ve.materialIndex];Ve&&Ve.visible&&T.push(_,le,Ve,F,Oe.z,ve)}}else pe.visible&&T.push(_,le,pe,F,Oe.z,null)}}const Q=_.children;for(let le=0,pe=Q.length;le<pe;le++)xr(Q[le],L,F,O)}function js(_,L,F,O){const{opaque:U,transmissive:Q,transparent:le}=_;E.setupLightsView(F),$===!0&&xe.setGlobalState(y.clippingPlanes,F),O&&me.viewport(G.copy(O)),U.length>0&&Ci(U,L,F),Q.length>0&&Ci(Q,L,F),le.length>0&&Ci(le,L,F),me.buffers.depth.setTest(!0),me.buffers.depth.setMask(!0),me.buffers.color.setMask(!0),me.setPolygonOffset(!1)}function Js(_,L,F,O){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[O.id]===void 0&&(E.state.transmissionRenderTarget[O.id]=new Un(1,1,{generateMipmaps:!0,type:ze.has("EXT_color_buffer_half_float")||ze.has("EXT_color_buffer_float")?ri:Xt,minFilter:Dn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ke.workingColorSpace}));const Q=E.state.transmissionRenderTarget[O.id],le=O.viewport||G;Q.setSize(le.z*y.transmissionResolutionScale,le.w*y.transmissionResolutionScale);const pe=y.getRenderTarget(),fe=y.getActiveCubeFace(),Te=y.getActiveMipmapLevel();y.setRenderTarget(Q),y.getClearColor(q),ne=y.getClearAlpha(),ne<1&&y.setClearColor(16777215,.5),y.clear(),Fe&&ee.render(F);const Re=y.toneMapping;y.toneMapping=_n;const ve=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),E.setupLightsView(O),$===!0&&xe.setGlobalState(y.clippingPlanes,O),Ci(_,F,O),De.updateMultisampleRenderTarget(Q),De.updateRenderTargetMipmap(Q),ze.has("WEBGL_multisampled_render_to_texture")===!1){let Ve=!1;for(let Ke=0,ot=L.length;Ke<ot;Ke++){const ct=L[Ke],{object:je,geometry:Ee,material:st,group:He}=ct;if(st.side===en&&je.layers.test(O.layers)){const Tt=st.side;st.side=yt,st.needsUpdate=!0,Qs(je,F,O,Ee,st,He),st.side=Tt,st.needsUpdate=!0,Ve=!0}}Ve===!0&&(De.updateMultisampleRenderTarget(Q),De.updateRenderTargetMipmap(Q))}y.setRenderTarget(pe,fe,Te),y.setClearColor(q,ne),ve!==void 0&&(O.viewport=ve),y.toneMapping=Re}function Ci(_,L,F){const O=L.isScene===!0?L.overrideMaterial:null;for(let U=0,Q=_.length;U<Q;U++){const le=_[U],{object:pe,geometry:fe,group:Te}=le;let Re=le.material;Re.allowOverride===!0&&O!==null&&(Re=O),pe.layers.test(F.layers)&&Qs(pe,L,F,fe,Re,Te)}}function Qs(_,L,F,O,U,Q){_.onBeforeRender(y,L,F,O,U,Q),_.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,_.matrixWorld),_.normalMatrix.getNormalMatrix(_.modelViewMatrix),U.onBeforeRender(y,L,F,O,_,Q),U.transparent===!0&&U.side===en&&U.forceSinglePass===!1?(U.side=yt,U.needsUpdate=!0,y.renderBufferDirect(F,L,O,U,_,Q),U.side=gn,U.needsUpdate=!0,y.renderBufferDirect(F,L,O,U,_,Q),U.side=en):y.renderBufferDirect(F,L,O,U,_,Q),_.onAfterRender(y,L,F,O,U,Q)}function Pi(_,L,F){L.isScene!==!0&&(L=pt);const O=Me.get(_),U=E.state.lights,Q=E.state.shadowsArray,le=U.state.version,pe=V.getParameters(_,U.state,Q,L,F),fe=V.getProgramCacheKey(pe);let Te=O.programs;O.environment=_.isMeshStandardMaterial?L.environment:null,O.fog=L.fog,O.envMap=(_.isMeshStandardMaterial?x:b).get(_.envMap||O.environment),O.envMapRotation=O.environment!==null&&_.envMap===null?L.environmentRotation:_.envMapRotation,Te===void 0&&(_.addEventListener("dispose",Pe),Te=new Map,O.programs=Te);let Re=Te.get(fe);if(Re!==void 0){if(O.currentProgram===Re&&O.lightsStateVersion===le)return ta(_,pe),Re}else pe.uniforms=V.getUniforms(_),_.onBeforeCompile(pe,y),Re=V.acquireProgram(pe,fe),Te.set(fe,Re),O.uniforms=pe.uniforms;const ve=O.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(ve.clippingPlanes=xe.uniform),ta(_,pe),O.needsLights=Go(_),O.lightsStateVersion=le,O.needsLights&&(ve.ambientLightColor.value=U.state.ambient,ve.lightProbe.value=U.state.probe,ve.directionalLights.value=U.state.directional,ve.directionalLightShadows.value=U.state.directionalShadow,ve.spotLights.value=U.state.spot,ve.spotLightShadows.value=U.state.spotShadow,ve.rectAreaLights.value=U.state.rectArea,ve.ltc_1.value=U.state.rectAreaLTC1,ve.ltc_2.value=U.state.rectAreaLTC2,ve.pointLights.value=U.state.point,ve.pointLightShadows.value=U.state.pointShadow,ve.hemisphereLights.value=U.state.hemi,ve.directionalShadowMap.value=U.state.directionalShadowMap,ve.directionalShadowMatrix.value=U.state.directionalShadowMatrix,ve.spotShadowMap.value=U.state.spotShadowMap,ve.spotLightMatrix.value=U.state.spotLightMatrix,ve.spotLightMap.value=U.state.spotLightMap,ve.pointShadowMap.value=U.state.pointShadowMap,ve.pointShadowMatrix.value=U.state.pointShadowMatrix),O.currentProgram=Re,O.uniformsList=null,Re}function ea(_){if(_.uniformsList===null){const L=_.currentProgram.getUniforms();_.uniformsList=ar.seqWithValue(L.seq,_.uniforms)}return _.uniformsList}function ta(_,L){const F=Me.get(_);F.outputColorSpace=L.outputColorSpace,F.batching=L.batching,F.batchingColor=L.batchingColor,F.instancing=L.instancing,F.instancingColor=L.instancingColor,F.instancingMorph=L.instancingMorph,F.skinning=L.skinning,F.morphTargets=L.morphTargets,F.morphNormals=L.morphNormals,F.morphColors=L.morphColors,F.morphTargetsCount=L.morphTargetsCount,F.numClippingPlanes=L.numClippingPlanes,F.numIntersection=L.numClipIntersection,F.vertexAlphas=L.vertexAlphas,F.vertexTangents=L.vertexTangents,F.toneMapping=L.toneMapping}function zo(_,L,F,O,U){L.isScene!==!0&&(L=pt),De.resetTextureUnits();const Q=L.fog,le=O.isMeshStandardMaterial?L.environment:null,pe=M===null?y.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:ni,fe=(O.isMeshStandardMaterial?x:b).get(O.envMap||le),Te=O.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Re=!!F.attributes.tangent&&(!!O.normalMap||O.anisotropy>0),ve=!!F.morphAttributes.position,Ve=!!F.morphAttributes.normal,Ke=!!F.morphAttributes.color;let ot=_n;O.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(ot=y.toneMapping);const ct=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,je=ct!==void 0?ct.length:0,Ee=Me.get(O),st=E.state.lights;if($===!0&&(he===!0||_!==B)){const gt=_===B&&O.id===C;xe.setState(O,_,gt)}let He=!1;O.version===Ee.__version?(Ee.needsLights&&Ee.lightsStateVersion!==st.state.version||Ee.outputColorSpace!==pe||U.isBatchedMesh&&Ee.batching===!1||!U.isBatchedMesh&&Ee.batching===!0||U.isBatchedMesh&&Ee.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&Ee.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&Ee.instancing===!1||!U.isInstancedMesh&&Ee.instancing===!0||U.isSkinnedMesh&&Ee.skinning===!1||!U.isSkinnedMesh&&Ee.skinning===!0||U.isInstancedMesh&&Ee.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Ee.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Ee.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Ee.instancingMorph===!1&&U.morphTexture!==null||Ee.envMap!==fe||O.fog===!0&&Ee.fog!==Q||Ee.numClippingPlanes!==void 0&&(Ee.numClippingPlanes!==xe.numPlanes||Ee.numIntersection!==xe.numIntersection)||Ee.vertexAlphas!==Te||Ee.vertexTangents!==Re||Ee.morphTargets!==ve||Ee.morphNormals!==Ve||Ee.morphColors!==Ke||Ee.toneMapping!==ot||Ee.morphTargetsCount!==je)&&(He=!0):(He=!0,Ee.__version=O.version);let Tt=Ee.currentProgram;He===!0&&(Tt=Pi(O,L,U));let Nn=!1,At=!1,ci=!1;const at=Tt.getUniforms(),bt=Ee.uniforms;if(me.useProgram(Tt.program)&&(Nn=!0,At=!0,ci=!0),O.id!==C&&(C=O.id,At=!0),Nn||B!==_){me.buffers.depth.getReversed()&&_.reversedDepth!==!0&&(_._reversedDepth=!0,_.updateProjectionMatrix()),at.setValue(A,"projectionMatrix",_.projectionMatrix),at.setValue(A,"viewMatrix",_.matrixWorldInverse);const Et=at.map.cameraPosition;Et!==void 0&&Et.setValue(A,ge.setFromMatrixPosition(_.matrixWorld)),et.logarithmicDepthBuffer&&at.setValue(A,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&at.setValue(A,"isOrthographic",_.isOrthographicCamera===!0),B!==_&&(B=_,At=!0,ci=!0)}if(U.isSkinnedMesh){at.setOptional(A,U,"bindMatrix"),at.setOptional(A,U,"bindMatrixInverse");const gt=U.skeleton;gt&&(gt.boneTexture===null&&gt.computeBoneTexture(),at.setValue(A,"boneTexture",gt.boneTexture,De))}U.isBatchedMesh&&(at.setOptional(A,U,"batchingTexture"),at.setValue(A,"batchingTexture",U._matricesTexture,De),at.setOptional(A,U,"batchingIdTexture"),at.setValue(A,"batchingIdTexture",U._indirectTexture,De),at.setOptional(A,U,"batchingColorTexture"),U._colorsTexture!==null&&at.setValue(A,"batchingColorTexture",U._colorsTexture,De));const Pt=F.morphAttributes;if((Pt.position!==void 0||Pt.normal!==void 0||Pt.color!==void 0)&&Ae.update(U,F,Tt),(At||Ee.receiveShadow!==U.receiveShadow)&&(Ee.receiveShadow=U.receiveShadow,at.setValue(A,"receiveShadow",U.receiveShadow)),O.isMeshGouraudMaterial&&O.envMap!==null&&(bt.envMap.value=fe,bt.flipEnvMap.value=fe.isCubeTexture&&fe.isRenderTargetTexture===!1?-1:1),O.isMeshStandardMaterial&&O.envMap===null&&L.environment!==null&&(bt.envMapIntensity.value=L.environmentIntensity),bt.dfgLUT!==void 0&&(bt.dfgLUT.value=Mp()),At&&(at.setValue(A,"toneMappingExposure",y.toneMappingExposure),Ee.needsLights&&Vo(bt,ci),Q&&O.fog===!0&&_e.refreshFogUniforms(bt,Q),_e.refreshMaterialUniforms(bt,O,se,te,E.state.transmissionRenderTarget[_.id]),ar.upload(A,ea(Ee),bt,De)),O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(ar.upload(A,ea(Ee),bt,De),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&at.setValue(A,"center",U.center),at.setValue(A,"modelViewMatrix",U.modelViewMatrix),at.setValue(A,"normalMatrix",U.normalMatrix),at.setValue(A,"modelMatrix",U.matrixWorld),O.isShaderMaterial||O.isRawShaderMaterial){const gt=O.uniformsGroups;for(let Et=0,_r=gt.length;Et<_r;Et++){const Sn=gt[Et];ce.update(Sn,Tt),ce.bind(Sn,Tt)}}return Tt}function Vo(_,L){_.ambientLightColor.needsUpdate=L,_.lightProbe.needsUpdate=L,_.directionalLights.needsUpdate=L,_.directionalLightShadows.needsUpdate=L,_.pointLights.needsUpdate=L,_.pointLightShadows.needsUpdate=L,_.spotLights.needsUpdate=L,_.spotLightShadows.needsUpdate=L,_.rectAreaLights.needsUpdate=L,_.hemisphereLights.needsUpdate=L}function Go(_){return _.isMeshLambertMaterial||_.isMeshToonMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isShadowMaterial||_.isShaderMaterial&&_.lights===!0}this.getActiveCubeFace=function(){return z},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(_,L,F){const O=Me.get(_);O.__autoAllocateDepthBuffer=_.resolveDepthBuffer===!1,O.__autoAllocateDepthBuffer===!1&&(O.__useRenderToTexture=!1),Me.get(_.texture).__webglTexture=L,Me.get(_.depthTexture).__webglTexture=O.__autoAllocateDepthBuffer?void 0:F,O.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(_,L){const F=Me.get(_);F.__webglFramebuffer=L,F.__useDefaultFramebuffer=L===void 0};const Ho=A.createFramebuffer();this.setRenderTarget=function(_,L=0,F=0){M=_,z=L,S=F;let O=!0,U=null,Q=!1,le=!1;if(_){const fe=Me.get(_);if(fe.__useDefaultFramebuffer!==void 0)me.bindFramebuffer(A.FRAMEBUFFER,null),O=!1;else if(fe.__webglFramebuffer===void 0)De.setupRenderTarget(_);else if(fe.__hasExternalTextures)De.rebindTextures(_,Me.get(_.texture).__webglTexture,Me.get(_.depthTexture).__webglTexture);else if(_.depthBuffer){const ve=_.depthTexture;if(fe.__boundDepthTexture!==ve){if(ve!==null&&Me.has(ve)&&(_.width!==ve.image.width||_.height!==ve.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");De.setupDepthRenderbuffer(_)}}const Te=_.texture;(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)&&(le=!0);const Re=Me.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(Re[L])?U=Re[L][F]:U=Re[L],Q=!0):_.samples>0&&De.useMultisampledRTT(_)===!1?U=Me.get(_).__webglMultisampledFramebuffer:Array.isArray(Re)?U=Re[F]:U=Re,G.copy(_.viewport),k.copy(_.scissor),K=_.scissorTest}else G.copy(qe).multiplyScalar(se).floor(),k.copy(Je).multiplyScalar(se).floor(),K=Qe;if(F!==0&&(U=Ho),me.bindFramebuffer(A.FRAMEBUFFER,U)&&O&&me.drawBuffers(_,U),me.viewport(G),me.scissor(k),me.setScissorTest(K),Q){const fe=Me.get(_.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+L,fe.__webglTexture,F)}else if(le){const fe=L;for(let Te=0;Te<_.textures.length;Te++){const Re=Me.get(_.textures[Te]);A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0+Te,Re.__webglTexture,F,fe)}}else if(_!==null&&F!==0){const fe=Me.get(_.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,fe.__webglTexture,F)}C=-1},this.readRenderTargetPixels=function(_,L,F,O,U,Q,le,pe=0){if(!(_&&_.isWebGLRenderTarget)){lt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let fe=Me.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&le!==void 0&&(fe=fe[le]),fe){me.bindFramebuffer(A.FRAMEBUFFER,fe);try{const Te=_.textures[pe],Re=Te.format,ve=Te.type;if(!et.textureFormatReadable(Re)){lt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!et.textureTypeReadable(ve)){lt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=_.width-O&&F>=0&&F<=_.height-U&&(_.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+pe),A.readPixels(L,F,O,U,we.convert(Re),we.convert(ve),Q))}finally{const Te=M!==null?Me.get(M).__webglFramebuffer:null;me.bindFramebuffer(A.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(_,L,F,O,U,Q,le,pe=0){if(!(_&&_.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let fe=Me.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&le!==void 0&&(fe=fe[le]),fe)if(L>=0&&L<=_.width-O&&F>=0&&F<=_.height-U){me.bindFramebuffer(A.FRAMEBUFFER,fe);const Te=_.textures[pe],Re=Te.format,ve=Te.type;if(!et.textureFormatReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ve=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Ve),A.bufferData(A.PIXEL_PACK_BUFFER,Q.byteLength,A.STREAM_READ),_.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+pe),A.readPixels(L,F,O,U,we.convert(Re),we.convert(ve),0);const Ke=M!==null?Me.get(M).__webglFramebuffer:null;me.bindFramebuffer(A.FRAMEBUFFER,Ke);const ot=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await Ic(A,ot,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Ve),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,Q),A.deleteBuffer(Ve),A.deleteSync(ot),Q}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(_,L=null,F=0){const O=Math.pow(2,-F),U=Math.floor(_.image.width*O),Q=Math.floor(_.image.height*O),le=L!==null?L.x:0,pe=L!==null?L.y:0;De.setTexture2D(_,0),A.copyTexSubImage2D(A.TEXTURE_2D,F,0,0,le,pe,U,Q),me.unbindTexture()};const ko=A.createFramebuffer(),Wo=A.createFramebuffer();this.copyTextureToTexture=function(_,L,F=null,O=null,U=0,Q=null){Q===null&&(U!==0?(Ei("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Q=U,U=0):Q=0);let le,pe,fe,Te,Re,ve,Ve,Ke,ot;const ct=_.isCompressedTexture?_.mipmaps[Q]:_.image;if(F!==null)le=F.max.x-F.min.x,pe=F.max.y-F.min.y,fe=F.isBox3?F.max.z-F.min.z:1,Te=F.min.x,Re=F.min.y,ve=F.isBox3?F.min.z:0;else{const Pt=Math.pow(2,-U);le=Math.floor(ct.width*Pt),pe=Math.floor(ct.height*Pt),_.isDataArrayTexture?fe=ct.depth:_.isData3DTexture?fe=Math.floor(ct.depth*Pt):fe=1,Te=0,Re=0,ve=0}O!==null?(Ve=O.x,Ke=O.y,ot=O.z):(Ve=0,Ke=0,ot=0);const je=we.convert(L.format),Ee=we.convert(L.type);let st;L.isData3DTexture?(De.setTexture3D(L,0),st=A.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(De.setTexture2DArray(L,0),st=A.TEXTURE_2D_ARRAY):(De.setTexture2D(L,0),st=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,L.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,L.unpackAlignment);const He=A.getParameter(A.UNPACK_ROW_LENGTH),Tt=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Nn=A.getParameter(A.UNPACK_SKIP_PIXELS),At=A.getParameter(A.UNPACK_SKIP_ROWS),ci=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,ct.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ct.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Te),A.pixelStorei(A.UNPACK_SKIP_ROWS,Re),A.pixelStorei(A.UNPACK_SKIP_IMAGES,ve);const at=_.isDataArrayTexture||_.isData3DTexture,bt=L.isDataArrayTexture||L.isData3DTexture;if(_.isDepthTexture){const Pt=Me.get(_),gt=Me.get(L),Et=Me.get(Pt.__renderTarget),_r=Me.get(gt.__renderTarget);me.bindFramebuffer(A.READ_FRAMEBUFFER,Et.__webglFramebuffer),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,_r.__webglFramebuffer);for(let Sn=0;Sn<fe;Sn++)at&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Me.get(_).__webglTexture,U,ve+Sn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Me.get(L).__webglTexture,Q,ot+Sn)),A.blitFramebuffer(Te,Re,le,pe,Ve,Ke,le,pe,A.DEPTH_BUFFER_BIT,A.NEAREST);me.bindFramebuffer(A.READ_FRAMEBUFFER,null),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(U!==0||_.isRenderTargetTexture||Me.has(_)){const Pt=Me.get(_),gt=Me.get(L);me.bindFramebuffer(A.READ_FRAMEBUFFER,ko),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,Wo);for(let Et=0;Et<fe;Et++)at?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Pt.__webglTexture,U,ve+Et):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Pt.__webglTexture,U),bt?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,gt.__webglTexture,Q,ot+Et):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,gt.__webglTexture,Q),U!==0?A.blitFramebuffer(Te,Re,le,pe,Ve,Ke,le,pe,A.COLOR_BUFFER_BIT,A.NEAREST):bt?A.copyTexSubImage3D(st,Q,Ve,Ke,ot+Et,Te,Re,le,pe):A.copyTexSubImage2D(st,Q,Ve,Ke,Te,Re,le,pe);me.bindFramebuffer(A.READ_FRAMEBUFFER,null),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else bt?_.isDataTexture||_.isData3DTexture?A.texSubImage3D(st,Q,Ve,Ke,ot,le,pe,fe,je,Ee,ct.data):L.isCompressedArrayTexture?A.compressedTexSubImage3D(st,Q,Ve,Ke,ot,le,pe,fe,je,ct.data):A.texSubImage3D(st,Q,Ve,Ke,ot,le,pe,fe,je,Ee,ct):_.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,Q,Ve,Ke,le,pe,je,Ee,ct.data):_.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,Q,Ve,Ke,ct.width,ct.height,je,ct.data):A.texSubImage2D(A.TEXTURE_2D,Q,Ve,Ke,le,pe,je,Ee,ct);A.pixelStorei(A.UNPACK_ROW_LENGTH,He),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Tt),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Nn),A.pixelStorei(A.UNPACK_SKIP_ROWS,At),A.pixelStorei(A.UNPACK_SKIP_IMAGES,ci),Q===0&&L.generateMipmaps&&A.generateMipmap(st),me.unbindTexture()},this.initRenderTarget=function(_){Me.get(_).__webglFramebuffer===void 0&&De.setupRenderTarget(_)},this.initTexture=function(_){_.isCubeTexture?De.setTextureCube(_,0):_.isData3DTexture?De.setTexture3D(_,0):_.isDataArrayTexture||_.isCompressedArrayTexture?De.setTexture2DArray(_,0):De.setTexture2D(_,0),me.unbindTexture()},this.resetState=function(){z=0,S=0,M=null,me.reset(),R.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=ke._getUnpackColorSpace()}}export{_c as A,Ai as B,Cp as C,an as F,Ki as G,ri as H,Tl as L,Sp as M,rn as N,_t as O,Ut as P,Ti as Q,Ys as R,Lt as S,bp as T,ml as U,Xe as V,Un as W,ia as a,wp as b,qt as c,We as d,Dp as e,Co as f,Tp as g,Ep as h,it as i,vn as j,Eo as k,Ll as l,wn as m,Rp as n,Ap as o,yp as p,cn as q,Pp as r,N as s,Lp as t};