opencroc 1.8.1 → 1.8.2

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 (71) hide show
  1. package/dist/cli/index.js +755 -8
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/index.d.ts +128 -1
  4. package/dist/index.js +548 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/web/dist/assets/main-Ccg3eDNK.js +1 -0
  7. package/dist/web/dist/assets/office-runtime-B3iNctxE.css +1 -0
  8. package/dist/web/dist/assets/office-runtime-BsCh82Pj.js +183 -0
  9. package/dist/web/dist/assets/pixel-page-3BYGm7dH.js +470 -0
  10. package/dist/web/dist/assets/react-vendor-C8RhVn0h.js +49 -0
  11. package/dist/web/dist/assets/studio-page-BInoyoV2.css +1 -0
  12. package/dist/web/dist/assets/studio-page-o3SCvE_v.js +351 -0
  13. package/dist/web/dist/assets/three-addons-BdrPp04O.js +470 -0
  14. package/dist/web/dist/assets/three-core-CsxM1PCY.js +4057 -0
  15. package/dist/web/dist/index.html +15 -0
  16. package/dist/web/index.html +11 -572
  17. package/dist/web/public/botreview/char_0.png +0 -0
  18. package/dist/web/public/botreview/char_1.png +0 -0
  19. package/dist/web/public/botreview/char_2.png +0 -0
  20. package/dist/web/public/botreview/coffee-machine.gif +0 -0
  21. package/dist/web/public/botreview/server.gif +0 -0
  22. package/dist/web/public/botreview/walls.png +0 -0
  23. package/dist/web/public/star/desk-v3.webp +0 -0
  24. package/dist/web/public/star/office_bg_small.webp +0 -0
  25. package/dist/web/public/star/star-idle-v5.png +0 -0
  26. package/dist/web/public/star/star-working-spritesheet-grid.webp +0 -0
  27. package/dist/web/src/app/AppLayout.tsx +34 -0
  28. package/dist/web/src/app/AppRouter.tsx +46 -0
  29. package/dist/web/src/app/bootstrap.tsx +22 -0
  30. package/dist/web/src/app/routes.tsx +52 -0
  31. package/dist/web/src/features/office/runtime/index.ts +1 -0
  32. package/dist/web/src/features/office/runtime/mount.ts +809 -0
  33. package/dist/web/src/features/pixel/runtime/index.ts +1 -0
  34. package/dist/web/src/features/pixel/runtime/mount.ts +728 -0
  35. package/dist/web/src/features/studio/runtime/index.ts +1 -0
  36. package/dist/web/src/features/studio/runtime/mount.ts +664 -0
  37. package/dist/web/src/features/three/engine/index.ts +1 -0
  38. package/dist/web/src/main.tsx +7 -0
  39. package/dist/web/src/pages/office/index.ts +1 -0
  40. package/dist/web/src/pages/office/page.tsx +283 -0
  41. package/dist/web/src/pages/pixel/index.ts +1 -0
  42. package/dist/web/src/pages/pixel/page.tsx +564 -0
  43. package/dist/web/src/pages/studio/index.ts +1 -0
  44. package/dist/web/src/pages/studio/page.tsx +446 -0
  45. package/dist/web/{js/agents.js → src/runtime/agents.ts} +304 -31
  46. package/dist/web/{js/camera.js → src/runtime/camera.ts} +12 -5
  47. package/dist/web/{js/dataviz.js → src/runtime/dataviz.ts} +38 -14
  48. package/dist/web/{js/effects.js → src/runtime/effects.ts} +139 -2
  49. package/dist/web/{js/engine.js → src/runtime/engine.ts} +45 -6
  50. package/dist/web/{js/office.js → src/runtime/office.ts} +136 -20
  51. package/dist/web/{js/ui.js → src/runtime/ui.ts} +11 -7
  52. package/dist/web/src/shared/assets.ts +4 -0
  53. package/dist/web/src/shared/navigation.ts +47 -0
  54. package/dist/web/src/styles/app-layout.css +19 -0
  55. package/dist/web/src/styles/office.css +268 -0
  56. package/dist/web/tsconfig.json +28 -0
  57. package/dist/web/vite.config.ts +93 -0
  58. package/package.json +11 -2
  59. package/dist/web/index-studio.html +0 -1644
  60. package/dist/web/index-v2-pixel.html +0 -1571
  61. /package/dist/web/{assets → dist}/botreview/char_0.png +0 -0
  62. /package/dist/web/{assets → dist}/botreview/char_1.png +0 -0
  63. /package/dist/web/{assets → dist}/botreview/char_2.png +0 -0
  64. /package/dist/web/{assets → dist}/botreview/coffee-machine.gif +0 -0
  65. /package/dist/web/{assets → dist}/botreview/server.gif +0 -0
  66. /package/dist/web/{assets → dist}/botreview/walls.png +0 -0
  67. /package/dist/web/{assets → dist}/star/desk-v3.webp +0 -0
  68. /package/dist/web/{assets → dist}/star/office_bg_small.webp +0 -0
  69. /package/dist/web/{assets → dist}/star/star-idle-v5.png +0 -0
  70. /package/dist/web/{assets → dist}/star/star-working-spritesheet-grid.webp +0 -0
  71. /package/dist/web/{js/state.js → src/runtime/state.ts} +0 -0
@@ -0,0 +1,4057 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2010-2026 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const jr="183",Op={ROTATE:0,DOLLY:1,PAN:2},Bp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Sl=0,Sa=1,El=2,rs=1,yl=2,Mi=3,Tn=0,Rt=1,on=2,cn=0,ii=1,Ea=2,ya=3,Ta=4,Tl=5,Un=100,bl=101,Al=102,Rl=103,wl=104,Cl=200,Pl=201,Dl=202,Ll=203,sr=204,rr=205,Il=206,Ul=207,Nl=208,Fl=209,Ol=210,Bl=211,zl=212,Vl=213,Gl=214,ar=0,or=1,lr=2,ri=3,cr=4,hr=5,ur=6,fr=7,bo=0,Hl=1,kl=2,Yt=0,Ao=1,Ro=2,wo=3,Co=4,Po=5,Do=6,Lo=7,Io=300,Bn=301,ai=302,Ts=303,bs=304,gs=306,dr=1e3,ln=1001,pr=1002,vt=1003,Wl=1004,Li=1005,yt=1006,As=1007,Fn=1008,Dt=1009,Uo=1010,No=1011,Ei=1012,Jr=1013,$t=1014,Xt=1015,un=1016,Qr=1017,ea=1018,yi=1020,Fo=35902,Oo=35899,Bo=1021,zo=1022,Vt=1023,fn=1026,On=1027,Vo=1028,ta=1029,oi=1030,na=1031,ia=1033,as=33776,os=33777,ls=33778,cs=33779,mr=35840,_r=35841,gr=35842,xr=35843,vr=36196,Mr=37492,Sr=37496,Er=37488,yr=37489,Tr=37490,br=37491,Ar=37808,Rr=37809,wr=37810,Cr=37811,Pr=37812,Dr=37813,Lr=37814,Ir=37815,Ur=37816,Nr=37817,Fr=37818,Or=37819,Br=37820,zr=37821,Vr=36492,Gr=36494,Hr=36495,kr=36283,Wr=36284,Xr=36285,qr=36286,Xl=3200,Go=0,ql=1,En="",It="srgb",li="srgb-linear",fs="linear",Ze="srgb",kn=7680,ba=519,Yl=512,Kl=513,Zl=514,sa=515,$l=516,jl=517,ra=518,Jl=519,Aa=35044,Ra="300 es",qt=2e3,Ti=2001;function Ql(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ds(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ec(){const i=ds("canvas");return i.style.display="block",i}const wa={};function Ca(...i){const e="THREE."+i.shift();console.log(e,...i)}function Ho(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Re(...i){i=Ho(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=Ho(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ps(...i){const e=i.join(" ");e in wa||(wa[e]=!0,Re(...i))}function tc(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const nc={[ar]:or,[lr]:ur,[cr]:fr,[ri]:hr,[or]:ar,[ur]:lr,[fr]:cr,[hr]:ri};class zn{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 s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,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 s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const St=["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"],hs=Math.PI/180,Yr=180/Math.PI;function Ai(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(St[i&255]+St[i>>8&255]+St[i>>16&255]+St[i>>24&255]+"-"+St[e&255]+St[e>>8&255]+"-"+St[e>>16&15|64]+St[e>>24&255]+"-"+St[t&63|128]+St[t>>8&255]+"-"+St[t>>16&255]+St[t>>24&255]+St[n&255]+St[n>>8&255]+St[n>>16&255]+St[n>>24&255]).toLowerCase()}function ze(i,e,t){return Math.max(e,Math.min(t,i))}function ic(i,e){return(i%e+e)%e}function Rs(i,e,t){return(1-t)*i+t*e}function fi(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 At(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 zp={DEG2RAD:hs};class Ve{constructor(e=0,t=0){Ve.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,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ze(this.x,e.x,t.x),this.y=ze(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ze(this.x,e,t),this.y=ze(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ze(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(ze(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),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+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 hi{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],f=n[s+2],m=n[s+3],h=r[a+0],p=r[a+1],g=r[a+2],S=r[a+3];if(m!==S||c!==h||l!==p||f!==g){let d=c*h+l*p+f*g+m*S;d<0&&(h=-h,p=-p,g=-g,S=-S,d=-d);let u=1-o;if(d<.9995){const v=Math.acos(d),T=Math.sin(v);u=Math.sin(u*v)/T,o=Math.sin(o*v)/T,c=c*u+h*o,l=l*u+p*o,f=f*u+g*o,m=m*u+S*o}else{c=c*u+h*o,l=l*u+p*o,f=f*u+g*o,m=m*u+S*o;const v=1/Math.sqrt(c*c+l*l+f*f+m*m);c*=v,l*=v,f*=v,m*=v}}e[t]=c,e[t+1]=l,e[t+2]=f,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],f=n[s+3],m=r[a],h=r[a+1],p=r[a+2],g=r[a+3];return e[t]=o*g+f*m+c*p-l*h,e[t+1]=c*g+f*h+l*m-o*p,e[t+2]=l*g+f*p+o*h-c*m,e[t+3]=f*g-o*m-c*h-l*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,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),f=o(s/2),m=o(r/2),h=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=h*f*m+l*p*g,this._y=l*p*m-h*f*g,this._z=l*f*g+h*p*m,this._w=l*f*m-h*p*g;break;case"YXZ":this._x=h*f*m+l*p*g,this._y=l*p*m-h*f*g,this._z=l*f*g-h*p*m,this._w=l*f*m+h*p*g;break;case"ZXY":this._x=h*f*m-l*p*g,this._y=l*p*m+h*f*g,this._z=l*f*g+h*p*m,this._w=l*f*m-h*p*g;break;case"ZYX":this._x=h*f*m-l*p*g,this._y=l*p*m+h*f*g,this._z=l*f*g-h*p*m,this._w=l*f*m+h*p*g;break;case"YZX":this._x=h*f*m+l*p*g,this._y=l*p*m+h*f*g,this._z=l*f*g-h*p*m,this._w=l*f*m-h*p*g;break;case"XZY":this._x=h*f*m-l*p*g,this._y=l*p*m-h*f*g,this._z=l*f*g+h*p*m,this._w=l*f*m+h*p*g;break;default:Re("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],f=t[6],m=t[10],h=n+o+m;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(f-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>m){const p=2*Math.sqrt(1+n-o-m);this._w=(f-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>m){const p=2*Math.sqrt(1+o-n-m);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+f)/p}else{const p=2*Math.sqrt(1+m-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+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(ze(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,f=t._w;return this._x=n*f+a*o+s*l-r*c,this._y=s*f+a*c+r*o-n*l,this._z=r*f+a*l+n*c-s*o,this._w=a*f-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),f=Math.sin(l);c=Math.sin(c*l)/f,t=Math.sin(t*l)/f,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+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(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{constructor(e=0,t=0,n=0){U.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(Pa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pa.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),f=2*(o*t-r*s),m=2*(r*n-a*t);return this.x=t+c*l+a*m-o*f,this.y=n+c*f+o*l-r*m,this.z=s+c*m+r*f-a*l,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,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ze(this.x,e.x,t.x),this.y=ze(this.y,e.y,t.y),this.z=ze(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ze(this.x,e,t),this.y=ze(this.y,e,t),this.z=ze(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ze(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,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*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 ws.copy(this).projectOnVector(e),this.sub(ws)}reflect(e){return this.sub(ws.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(ze(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){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 ws=new U,Pa=new hi;class Le{constructor(e,t,n,s,r,a,o,c,l){Le.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const f=this.elements;return f[0]=e,f[1]=s,f[2]=o,f[3]=t,f[4]=r,f[5]=c,f[6]=n,f[7]=a,f[8]=l,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,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],f=n[4],m=n[7],h=n[2],p=n[5],g=n[8],S=s[0],d=s[3],u=s[6],v=s[1],T=s[4],E=s[7],R=s[2],A=s[5],P=s[8];return r[0]=a*S+o*v+c*R,r[3]=a*d+o*T+c*A,r[6]=a*u+o*E+c*P,r[1]=l*S+f*v+m*R,r[4]=l*d+f*T+m*A,r[7]=l*u+f*E+m*P,r[2]=h*S+p*v+g*R,r[5]=h*d+p*T+g*A,r[8]=h*u+p*E+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],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8];return t*a*f-t*o*l-n*r*f+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=f*a-o*l,h=o*c-f*r,p=l*r-a*c,g=t*m+n*h+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/g;return e[0]=m*S,e[1]=(s*l-f*n)*S,e[2]=(o*n-s*a)*S,e[3]=h*S,e[4]=(f*t-s*c)*S,e[5]=(s*r-o*t)*S,e[6]=p*S,e[7]=(n*c-l*t)*S,e[8]=(a*t-n*r)*S,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,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Cs.makeScale(e,t)),this}rotate(e){return this.premultiply(Cs.makeRotation(-e)),this}translate(e,t){return this.premultiply(Cs.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 s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){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 Cs=new Le,Da=new Le().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),La=new Le().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function sc(){const i={enabled:!0,workingColorSpace:li,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ze&&(s.r=hn(s.r),s.g=hn(s.g),s.b=hn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ze&&(s.r=si(s.r),s.g=si(s.g),s.b=si(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===En?fs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return ps("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ps("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[li]:{primaries:e,whitePoint:n,transfer:fs,toXYZ:Da,fromXYZ:La,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:It},outputColorSpaceConfig:{drawingBufferColorSpace:It}},[It]:{primaries:e,whitePoint:n,transfer:Ze,toXYZ:Da,fromXYZ:La,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:It}}}),i}const He=sc();function hn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function si(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Wn;class rc{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{Wn===void 0&&(Wn=ds("canvas")),Wn.width=e.width,Wn.height=e.height;const s=Wn.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Wn}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=ds("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=hn(r[a]/255)*255;return n.putImageData(s,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(hn(t[n]/255)*255):t[n]=hn(t[n]);return{data:t,width:e.width,height:e.height}}else return Re("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let ac=0;class aa{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ac++}),this.uuid=Ai(),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):typeof VideoFrame<"u"&&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:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(Ps(s[a].image)):r.push(Ps(s[a]))}else r=Ps(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Ps(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?rc.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Re("Texture: Unable to serialize Texture."),{})}let oc=0;const Ds=new U;class bt extends zn{constructor(e=bt.DEFAULT_IMAGE,t=bt.DEFAULT_MAPPING,n=ln,s=ln,r=yt,a=Fn,o=Vt,c=Dt,l=bt.DEFAULT_ANISOTROPY,f=En){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:oc++}),this.uuid=Ai(),this.name="",this.source=new aa(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Le,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(Ds).x}get height(){return this.source.getSize(Ds).y}get depth(){return this.source.getSize(Ds).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){Re(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Re(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){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!==Io)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case dr:e.x=e.x-Math.floor(e.x);break;case ln:e.x=e.x<0?0:1;break;case pr: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 dr:e.y=e.y-Math.floor(e.y);break;case ln:e.y=e.y<0?0:1;break;case pr: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++}}bt.DEFAULT_IMAGE=null;bt.DEFAULT_MAPPING=Io;bt.DEFAULT_ANISOTROPY=1;class at{constructor(e=0,t=0,n=0,s=1){at.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("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,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,s,r;const c=e.elements,l=c[0],f=c[4],m=c[8],h=c[1],p=c[5],g=c[9],S=c[2],d=c[6],u=c[10];if(Math.abs(f-h)<.01&&Math.abs(m-S)<.01&&Math.abs(g-d)<.01){if(Math.abs(f+h)<.1&&Math.abs(m+S)<.1&&Math.abs(g+d)<.1&&Math.abs(l+p+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(l+1)/2,E=(p+1)/2,R=(u+1)/2,A=(f+h)/4,P=(m+S)/4,x=(g+d)/4;return T>E&&T>R?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=A/n,r=P/n):E>R?E<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(E),n=A/s,r=x/s):R<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(R),n=P/r,s=x/r),this.set(n,s,r,t),this}let v=Math.sqrt((d-g)*(d-g)+(m-S)*(m-S)+(h-f)*(h-f));return Math.abs(v)<.001&&(v=1),this.x=(d-g)/v,this.y=(m-S)/v,this.z=(h-f)/v,this.w=Math.acos((l+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=ze(this.x,e.x,t.x),this.y=ze(this.y,e.y,t.y),this.z=ze(this.z,e.z,t.z),this.w=ze(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ze(this.x,e,t),this.y=ze(this.y,e,t),this.z=ze(this.z,e,t),this.w=ze(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ze(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 lc extends zn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yt,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 at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new bt(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.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:yt,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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new aa(s)}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 Kt extends lc{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class ko extends bt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=vt,this.minFilter=vt,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class cc extends bt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=vt,this.minFilter=vt,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class st{constructor(e,t,n,s,r,a,o,c,l,f,m,h,p,g,S,d){st.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,s,r,a,o,c,l,f,m,h,p,g,S,d)}set(e,t,n,s,r,a,o,c,l,f,m,h,p,g,S,d){const u=this.elements;return u[0]=e,u[4]=t,u[8]=n,u[12]=s,u[1]=r,u[5]=a,u[9]=o,u[13]=c,u[2]=l,u[6]=f,u[10]=m,u[14]=h,u[3]=p,u[7]=g,u[11]=S,u[15]=d,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 st().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 this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,s=1/Xn.setFromMatrixColumn(e,0).length(),r=1/Xn.setFromMatrixColumn(e,1).length(),a=1/Xn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*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,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),f=Math.cos(r),m=Math.sin(r);if(e.order==="XYZ"){const h=a*f,p=a*m,g=o*f,S=o*m;t[0]=c*f,t[4]=-c*m,t[8]=l,t[1]=p+g*l,t[5]=h-S*l,t[9]=-o*c,t[2]=S-h*l,t[6]=g+p*l,t[10]=a*c}else if(e.order==="YXZ"){const h=c*f,p=c*m,g=l*f,S=l*m;t[0]=h+S*o,t[4]=g*o-p,t[8]=a*l,t[1]=a*m,t[5]=a*f,t[9]=-o,t[2]=p*o-g,t[6]=S+h*o,t[10]=a*c}else if(e.order==="ZXY"){const h=c*f,p=c*m,g=l*f,S=l*m;t[0]=h-S*o,t[4]=-a*m,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*f,t[9]=S-h*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const h=a*f,p=a*m,g=o*f,S=o*m;t[0]=c*f,t[4]=g*l-p,t[8]=h*l+S,t[1]=c*m,t[5]=S*l+h,t[9]=p*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const h=a*c,p=a*l,g=o*c,S=o*l;t[0]=c*f,t[4]=S-h*m,t[8]=g*m+p,t[1]=m,t[5]=a*f,t[9]=-o*f,t[2]=-l*f,t[6]=p*m+g,t[10]=h-S*m}else if(e.order==="XZY"){const h=a*c,p=a*l,g=o*c,S=o*l;t[0]=c*f,t[4]=-m,t[8]=l*f,t[1]=h*m+S,t[5]=a*f,t[9]=p*m-g,t[2]=g*m-p,t[6]=o*f,t[10]=S*m+h}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(hc,e,uc)}lookAt(e,t,n){const s=this.elements;return Ct.subVectors(e,t),Ct.lengthSq()===0&&(Ct.z=1),Ct.normalize(),_n.crossVectors(n,Ct),_n.lengthSq()===0&&(Math.abs(n.z)===1?Ct.x+=1e-4:Ct.z+=1e-4,Ct.normalize(),_n.crossVectors(n,Ct)),_n.normalize(),Ii.crossVectors(Ct,_n),s[0]=_n.x,s[4]=Ii.x,s[8]=Ct.x,s[1]=_n.y,s[5]=Ii.y,s[9]=Ct.y,s[2]=_n.z,s[6]=Ii.z,s[10]=Ct.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],f=n[1],m=n[5],h=n[9],p=n[13],g=n[2],S=n[6],d=n[10],u=n[14],v=n[3],T=n[7],E=n[11],R=n[15],A=s[0],P=s[4],x=s[8],y=s[12],V=s[1],w=s[5],N=s[9],O=s[13],k=s[2],G=s[6],z=s[10],H=s[14],Q=s[3],$=s[7],ce=s[11],pe=s[15];return r[0]=a*A+o*V+c*k+l*Q,r[4]=a*P+o*w+c*G+l*$,r[8]=a*x+o*N+c*z+l*ce,r[12]=a*y+o*O+c*H+l*pe,r[1]=f*A+m*V+h*k+p*Q,r[5]=f*P+m*w+h*G+p*$,r[9]=f*x+m*N+h*z+p*ce,r[13]=f*y+m*O+h*H+p*pe,r[2]=g*A+S*V+d*k+u*Q,r[6]=g*P+S*w+d*G+u*$,r[10]=g*x+S*N+d*z+u*ce,r[14]=g*y+S*O+d*H+u*pe,r[3]=v*A+T*V+E*k+R*Q,r[7]=v*P+T*w+E*G+R*$,r[11]=v*x+T*N+E*z+R*ce,r[15]=v*y+T*O+E*H+R*pe,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],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],f=e[2],m=e[6],h=e[10],p=e[14],g=e[3],S=e[7],d=e[11],u=e[15],v=c*p-l*h,T=o*p-l*m,E=o*h-c*m,R=a*p-l*f,A=a*h-c*f,P=a*m-o*f;return t*(S*v-d*T+u*E)-n*(g*v-d*R+u*A)+s*(g*T-S*R+u*P)-r*(g*E-S*A+d*P)}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 s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=e[9],h=e[10],p=e[11],g=e[12],S=e[13],d=e[14],u=e[15],v=t*o-n*a,T=t*c-s*a,E=t*l-r*a,R=n*c-s*o,A=n*l-r*o,P=s*l-r*c,x=f*S-m*g,y=f*d-h*g,V=f*u-p*g,w=m*d-h*S,N=m*u-p*S,O=h*u-p*d,k=v*O-T*N+E*w+R*V-A*y+P*x;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/k;return e[0]=(o*O-c*N+l*w)*G,e[1]=(s*N-n*O-r*w)*G,e[2]=(S*P-d*A+u*R)*G,e[3]=(h*A-m*P-p*R)*G,e[4]=(c*V-a*O-l*y)*G,e[5]=(t*O-s*V+r*y)*G,e[6]=(d*E-g*P-u*T)*G,e[7]=(f*P-h*E+p*T)*G,e[8]=(a*N-o*V+l*x)*G,e[9]=(n*V-t*N-r*x)*G,e[10]=(g*A-S*E+u*v)*G,e[11]=(m*E-f*A-p*v)*G,e[12]=(o*y-a*w-c*x)*G,e[13]=(t*w-n*y+s*x)*G,e[14]=(S*T-g*R-d*v)*G,e[15]=(f*R-m*T+h*v)*G,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){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),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,f=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,f*o+n,f*c-s*a,0,l*c-s*o,f*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,f=a+a,m=o+o,h=r*l,p=r*f,g=r*m,S=a*f,d=a*m,u=o*m,v=c*l,T=c*f,E=c*m,R=n.x,A=n.y,P=n.z;return s[0]=(1-(S+u))*R,s[1]=(p+E)*R,s[2]=(g-T)*R,s[3]=0,s[4]=(p-E)*A,s[5]=(1-(h+u))*A,s[6]=(d+v)*A,s[7]=0,s[8]=(g+T)*P,s[9]=(d-v)*P,s[10]=(1-(h+S))*P,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];const r=this.determinant();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Xn.set(s[0],s[1],s[2]).length();const o=Xn.set(s[4],s[5],s[6]).length(),c=Xn.set(s[8],s[9],s[10]).length();r<0&&(a=-a),Ft.copy(this);const l=1/a,f=1/o,m=1/c;return Ft.elements[0]*=l,Ft.elements[1]*=l,Ft.elements[2]*=l,Ft.elements[4]*=f,Ft.elements[5]*=f,Ft.elements[6]*=f,Ft.elements[8]*=m,Ft.elements[9]*=m,Ft.elements[10]*=m,t.setFromRotationMatrix(Ft),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=qt,c=!1){const l=this.elements,f=2*r/(t-e),m=2*r/(n-s),h=(t+e)/(t-e),p=(n+s)/(n-s);let g,S;if(c)g=r/(a-r),S=a*r/(a-r);else if(o===qt)g=-(a+r)/(a-r),S=-2*a*r/(a-r);else if(o===Ti)g=-a/(a-r),S=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=f,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=m,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=S,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=qt,c=!1){const l=this.elements,f=2/(t-e),m=2/(n-s),h=-(t+e)/(t-e),p=-(n+s)/(n-s);let g,S;if(c)g=1/(a-r),S=a/(a-r);else if(o===qt)g=-2/(a-r),S=-(a+r)/(a-r);else if(o===Ti)g=-1/(a-r),S=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=f,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=m,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=g,l[14]=S,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){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 Xn=new U,Ft=new st,hc=new U(0,0,0),uc=new U(1,1,1),_n=new U,Ii=new U,Ct=new U,Ia=new st,Ua=new hi;class jt{constructor(e=0,t=0,n=0,s=jt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],f=s[9],m=s[2],h=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(ze(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ze(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-m,r),this._z=0);break;case"ZXY":this._x=Math.asin(ze(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-m,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-ze(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ze(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,l),this._y=Math.atan2(-m,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-ze(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-f,p),this._y=0);break;default:Re("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ia.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ia,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ua.setFromEuler(this),this.setFromQuaternion(Ua,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}}jt.DEFAULT_ORDER="XYZ";class Wo{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 fc=0;const Na=new U,qn=new hi,tn=new st,Ui=new U,di=new U,dc=new U,pc=new hi,Fa=new U(1,0,0),Oa=new U(0,1,0),Ba=new U(0,0,1),za={type:"added"},mc={type:"removed"},Yn={type:"childadded",child:null},Ls={type:"childremoved",child:null};class ut extends zn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:fc++}),this.uuid=Ai(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();const e=new U,t=new jt,n=new hi,s=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),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:s},modelViewMatrix:{value:new st},normalMatrix:{value:new Le}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Wo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}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 qn.setFromAxisAngle(e,t),this.quaternion.multiply(qn),this}rotateOnWorldAxis(e,t){return qn.setFromAxisAngle(e,t),this.quaternion.premultiply(qn),this}rotateX(e){return this.rotateOnAxis(Fa,e)}rotateY(e){return this.rotateOnAxis(Oa,e)}rotateZ(e){return this.rotateOnAxis(Ba,e)}translateOnAxis(e,t){return Na.copy(e).applyQuaternion(this.quaternion),this.position.add(Na.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Fa,e)}translateY(e){return this.translateOnAxis(Oa,e)}translateZ(e){return this.translateOnAxis(Ba,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(tn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ui.copy(e):Ui.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),di.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tn.lookAt(di,Ui,this.up):tn.lookAt(Ui,di,this.up),this.quaternion.setFromRotationMatrix(tn),s&&(tn.extractRotation(s.matrixWorld),qn.setFromRotationMatrix(tn),this.quaternion.premultiply(qn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(We("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(za),Yn.child=e,this.dispatchEvent(Yn),Yn.child=null):We("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(mc),Ls.child=e,this.dispatchEvent(Ls),Ls.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),tn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),tn.multiply(e.parent.matrixWorld)),e.applyMatrix4(tn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(za),Yn.child=e,this.dispatchEvent(Yn),Yn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){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 s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(di,e,dc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(di,pc,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,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;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);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;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 s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].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 s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,f=c.length;l<f;l++){const m=c[l];r(e.shapes,m)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),f=a(e.images),m=a(e.shapes),h=a(e.skeletons),p=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),f.length>0&&(n.images=f),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const c=[];for(const l in o){const f=o[l];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}ut.DEFAULT_UP=new U(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Ni extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}}const _c={type:"move"};class Is{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ni,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 Ni,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ni,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),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 s=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const S of e.hand.values()){const d=t.getJointPose(S,n),u=this._getHandJoint(l,S);d!==null&&(u.matrix.fromArray(d.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=d.radius),u.visible=d!==null}const f=l.joints["index-finger-tip"],m=l.joints["thumb-tip"],h=f.position.distanceTo(m.position),p=.02,g=.005;l.inputState.pinching&&h>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_c)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ni;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Xo={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},gn={h:0,s:0,l:0},Fi={h:0,s:0,l:0};function Us(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 Ne{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 s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=It){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,He.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=He.workingColorSpace){return this.r=e,this.g=t,this.b=n,He.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=He.workingColorSpace){if(e=ic(e,1),t=ze(t,0,1),n=ze(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=Us(a,r,e+1/3),this.g=Us(a,r,e),this.b=Us(a,r,e-1/3)}return He.colorSpaceToWorking(this,s),this}setStyle(e,t=It){function n(r){r!==void 0&&parseFloat(r)<1&&Re("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Re("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Re("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=It){const n=Xo[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Re("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=hn(e.r),this.g=hn(e.g),this.b=hn(e.b),this}copyLinearToSRGB(e){return this.r=si(e.r),this.g=si(e.g),this.b=si(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=It){return He.workingToColorSpace(Et.copy(this),e),Math.round(ze(Et.r*255,0,255))*65536+Math.round(ze(Et.g*255,0,255))*256+Math.round(ze(Et.b*255,0,255))}getHexString(e=It){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=He.workingColorSpace){He.workingToColorSpace(Et.copy(this),t);const n=Et.r,s=Et.g,r=Et.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const f=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=f<=.5?m/(a+o):m/(2-a-o),a){case n:c=(s-r)/m+(s<r?6:0);break;case s:c=(r-n)/m+2;break;case r:c=(n-s)/m+4;break}c/=6}return e.h=c,e.s=l,e.l=f,e}getRGB(e,t=He.workingColorSpace){return He.workingToColorSpace(Et.copy(this),t),e.r=Et.r,e.g=Et.g,e.b=Et.b,e}getStyle(e=It){He.workingToColorSpace(Et.copy(this),e);const t=Et.r,n=Et.g,s=Et.b;return e!==It?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(gn),this.setHSL(gn.h+e,gn.s+t,gn.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(gn),e.getHSL(Fi);const n=Rs(gn.h,Fi.h,t),s=Rs(gn.s,Fi.s,t),r=Rs(gn.l,Fi.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Et=new Ne;Ne.NAMES=Xo;class qo{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ne(e),this.density=t}clone(){return new qo(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Vp extends ut{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 jt,this.environmentIntensity=1,this.environmentRotation=new jt,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}}const Ot=new U,nn=new U,Ns=new U,sn=new U,Kn=new U,Zn=new U,Va=new U,Fs=new U,Os=new U,Bs=new U,zs=new at,Vs=new at,Gs=new at;class zt{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ot.subVectors(e,t),s.cross(Ot);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Ot.subVectors(s,t),nn.subVectors(n,t),Ns.subVectors(e,t);const a=Ot.dot(Ot),o=Ot.dot(nn),c=Ot.dot(Ns),l=nn.dot(nn),f=nn.dot(Ns),m=a*l-o*o;if(m===0)return r.set(0,0,0),null;const h=1/m,p=(l*c-o*f)*h,g=(a*f-o*c)*h;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,sn)===null?!1:sn.x>=0&&sn.y>=0&&sn.x+sn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,sn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,sn.x),c.addScaledVector(a,sn.y),c.addScaledVector(o,sn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return zs.setScalar(0),Vs.setScalar(0),Gs.setScalar(0),zs.fromBufferAttribute(e,t),Vs.fromBufferAttribute(e,n),Gs.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zs,r.x),a.addScaledVector(Vs,r.y),a.addScaledVector(Gs,r.z),a}static isFrontFacing(e,t,n,s){return Ot.subVectors(n,t),nn.subVectors(e,t),Ot.cross(nn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ot.subVectors(this.c,this.b),nn.subVectors(this.a,this.b),Ot.cross(nn).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,s,r){return zt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}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,s=this.b,r=this.c;let a,o;Kn.subVectors(s,n),Zn.subVectors(r,n),Fs.subVectors(e,n);const c=Kn.dot(Fs),l=Zn.dot(Fs);if(c<=0&&l<=0)return t.copy(n);Os.subVectors(e,s);const f=Kn.dot(Os),m=Zn.dot(Os);if(f>=0&&m<=f)return t.copy(s);const h=c*m-f*l;if(h<=0&&c>=0&&f<=0)return a=c/(c-f),t.copy(n).addScaledVector(Kn,a);Bs.subVectors(e,r);const p=Kn.dot(Bs),g=Zn.dot(Bs);if(g>=0&&p<=g)return t.copy(r);const S=p*l-c*g;if(S<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(Zn,o);const d=f*g-p*m;if(d<=0&&m-f>=0&&p-g>=0)return Va.subVectors(r,s),o=(m-f)/(m-f+(p-g)),t.copy(s).addScaledVector(Va,o);const u=1/(d+S+h);return a=S*u,o=h*u,t.copy(n).addScaledVector(Kn,a).addScaledVector(Zn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ri{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(Bt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Bt.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=Bt.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 r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Bt):Bt.fromBufferAttribute(r,a),Bt.applyMatrix4(e.matrixWorld),this.expandByPoint(Bt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Oi.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Oi.copy(n.boundingBox)),Oi.applyMatrix4(e.matrixWorld),this.union(Oi)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Bt),Bt.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(pi),Bi.subVectors(this.max,pi),$n.subVectors(e.a,pi),jn.subVectors(e.b,pi),Jn.subVectors(e.c,pi),xn.subVectors(jn,$n),vn.subVectors(Jn,jn),Rn.subVectors($n,Jn);let t=[0,-xn.z,xn.y,0,-vn.z,vn.y,0,-Rn.z,Rn.y,xn.z,0,-xn.x,vn.z,0,-vn.x,Rn.z,0,-Rn.x,-xn.y,xn.x,0,-vn.y,vn.x,0,-Rn.y,Rn.x,0];return!Hs(t,$n,jn,Jn,Bi)||(t=[1,0,0,0,1,0,0,0,1],!Hs(t,$n,jn,Jn,Bi))?!1:(zi.crossVectors(xn,vn),t=[zi.x,zi.y,zi.z],Hs(t,$n,jn,Jn,Bi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Bt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Bt).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:(rn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),rn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),rn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),rn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),rn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),rn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),rn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),rn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(rn),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 rn=[new U,new U,new U,new U,new U,new U,new U,new U],Bt=new U,Oi=new Ri,$n=new U,jn=new U,Jn=new U,xn=new U,vn=new U,Rn=new U,pi=new U,Bi=new U,zi=new U,wn=new U;function Hs(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){wn.fromArray(i,r);const o=s.x*Math.abs(wn.x)+s.y*Math.abs(wn.y)+s.z*Math.abs(wn.z),c=e.dot(wn),l=t.dot(wn),f=n.dot(wn);if(Math.max(-Math.max(c,l,f),Math.min(c,l,f))>o)return!1}return!0}const ht=new U,Vi=new Ve;let gc=0;class Zt{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:gc++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Aa,this.updateRanges=[],this.gpuType=Xt,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 s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)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++)ht.fromBufferAttribute(this,t),ht.applyMatrix3(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ht.fromBufferAttribute(this,t),ht.applyMatrix4(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ht.fromBufferAttribute(this,t),ht.applyNormalMatrix(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ht.fromBufferAttribute(this,t),ht.transformDirection(e),this.setXYZ(t,ht.x,ht.y,ht.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=fi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=At(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=fi(t,this.array)),t}setX(e,t){return this.normalized&&(t=At(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=fi(t,this.array)),t}setY(e,t){return this.normalized&&(t=At(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=fi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=At(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=fi(t,this.array)),t}setW(e,t){return this.normalized&&(t=At(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=At(t,this.array),n=At(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=At(t,this.array),n=At(n,this.array),s=At(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=At(t,this.array),n=At(n,this.array),s=At(s,this.array),r=At(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==Aa&&(e.usage=this.usage),e}}class Yo extends Zt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ko extends Zt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Xe extends Zt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const xc=new Ri,mi=new U,ks=new U;class wi{constructor(e=new U,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):xc.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){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;mi.subVectors(e,this.center);const t=mi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(mi,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ks.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(mi.copy(e.center).add(ks)),this.expandByPoint(mi.copy(e.center).sub(ks))),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}}let vc=0;const Lt=new st,Ws=new ut,Qn=new U,Pt=new Ri,_i=new Ri,_t=new U;class gt extends zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:vc++}),this.uuid=Ai(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ql(e)?Ko:Yo)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Le().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lt.makeRotationFromQuaternion(e),this.applyMatrix4(Lt),this}rotateX(e){return Lt.makeRotationX(e),this.applyMatrix4(Lt),this}rotateY(e){return Lt.makeRotationY(e),this.applyMatrix4(Lt),this}rotateZ(e){return Lt.makeRotationZ(e),this.applyMatrix4(Lt),this}translate(e,t,n){return Lt.makeTranslation(e,t,n),this.applyMatrix4(Lt),this}scale(e,t,n){return Lt.makeScale(e,t,n),this.applyMatrix4(Lt),this}lookAt(e){return Ws.lookAt(e),Ws.updateMatrix(),this.applyMatrix4(Ws.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 s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Xe(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Re("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 Ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];Pt.setFromBufferAttribute(r),this.morphTargetsRelative?(_t.addVectors(this.boundingBox.min,Pt.min),this.boundingBox.expandByPoint(_t),_t.addVectors(this.boundingBox.max,Pt.max),this.boundingBox.expandByPoint(_t)):(this.boundingBox.expandByPoint(Pt.min),this.boundingBox.expandByPoint(Pt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&We('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 wi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(Pt.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];_i.setFromBufferAttribute(o),this.morphTargetsRelative?(_t.addVectors(Pt.min,_i.min),Pt.expandByPoint(_t),_t.addVectors(Pt.max,_i.max),Pt.expandByPoint(_t)):(Pt.expandByPoint(_i.min),Pt.expandByPoint(_i.max))}Pt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)_t.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(_t));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,f=o.count;l<f;l++)_t.fromBufferAttribute(o,l),c&&(Qn.fromBufferAttribute(e,l),_t.add(Qn)),s=Math.max(s,n.distanceToSquared(_t))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&We('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){We("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Zt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let x=0;x<n.count;x++)o[x]=new U,c[x]=new U;const l=new U,f=new U,m=new U,h=new Ve,p=new Ve,g=new Ve,S=new U,d=new U;function u(x,y,V){l.fromBufferAttribute(n,x),f.fromBufferAttribute(n,y),m.fromBufferAttribute(n,V),h.fromBufferAttribute(r,x),p.fromBufferAttribute(r,y),g.fromBufferAttribute(r,V),f.sub(l),m.sub(l),p.sub(h),g.sub(h);const w=1/(p.x*g.y-g.x*p.y);isFinite(w)&&(S.copy(f).multiplyScalar(g.y).addScaledVector(m,-p.y).multiplyScalar(w),d.copy(m).multiplyScalar(p.x).addScaledVector(f,-g.x).multiplyScalar(w),o[x].add(S),o[y].add(S),o[V].add(S),c[x].add(d),c[y].add(d),c[V].add(d))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let x=0,y=v.length;x<y;++x){const V=v[x],w=V.start,N=V.count;for(let O=w,k=w+N;O<k;O+=3)u(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const T=new U,E=new U,R=new U,A=new U;function P(x){R.fromBufferAttribute(s,x),A.copy(R);const y=o[x];T.copy(y),T.sub(R.multiplyScalar(R.dot(y))).normalize(),E.crossVectors(A,y);const w=E.dot(c[x])<0?-1:1;a.setXYZW(x,T.x,T.y,T.z,w)}for(let x=0,y=v.length;x<y;++x){const V=v[x],w=V.start,N=V.count;for(let O=w,k=w+N;O<k;O+=3)P(e.getX(O+0)),P(e.getX(O+1)),P(e.getX(O+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 Zt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,p=n.count;h<p;h++)n.setXYZ(h,0,0,0);const s=new U,r=new U,a=new U,o=new U,c=new U,l=new U,f=new U,m=new U;if(e)for(let h=0,p=e.count;h<p;h+=3){const g=e.getX(h+0),S=e.getX(h+1),d=e.getX(h+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,S),a.fromBufferAttribute(t,d),f.subVectors(a,r),m.subVectors(s,r),f.cross(m),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,S),l.fromBufferAttribute(n,d),o.add(f),c.add(f),l.add(f),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(S,c.x,c.y,c.z),n.setXYZ(d,l.x,l.y,l.z)}else for(let h=0,p=t.count;h<p;h+=3)s.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),f.subVectors(a,r),m.subVectors(s,r),f.cross(m),n.setXYZ(h+0,f.x,f.y,f.z),n.setXYZ(h+1,f.x,f.y,f.z),n.setXYZ(h+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++)_t.fromBufferAttribute(e,t),_t.normalize(),e.setXYZ(t,_t.x,_t.y,_t.z)}toNonIndexed(){function e(o,c){const l=o.array,f=o.itemSize,m=o.normalized,h=new l.constructor(c.length*f);let p=0,g=0;for(let S=0,d=c.length;S<d;S++){o.isInterleavedBufferAttribute?p=c[S]*o.data.stride+o.offset:p=c[S]*f;for(let u=0;u<f;u++)h[g++]=l[p++]}return new Zt(h,f,m)}if(this.index===null)return Re("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new gt,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let f=0,m=l.length;f<m;f++){const h=l[f],p=e(h,n);c.push(p)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);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 c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],f=[];for(let m=0,h=l.length;m<h;m++){const p=l[m];f.push(p.toJSON(e.data))}f.length>0&&(s[c]=f,r=!0)}r&&(e.data.morphAttributes=s,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 s=e.attributes;for(const l in s){const f=s[l];this.setAttribute(l,f.clone(t))}const r=e.morphAttributes;for(const l in r){const f=[],m=r[l];for(let h=0,p=m.length;h<p;h++)f.push(m[h].clone(t));this.morphAttributes[l]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,f=a.length;l<f;l++){const m=a[l];this.addGroup(m.start,m.count,m.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Mc=0;class Vn extends zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Mc++}),this.uuid=Ai(),this.name="",this.type="Material",this.blending=ii,this.side=Tn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=sr,this.blendDst=rr,this.blendEquation=Un,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ne(0,0,0),this.blendAlpha=0,this.depthFunc=ri,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ba,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kn,this.stencilZFail=kn,this.stencilZPass=kn,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){Re(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Re(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.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!==ii&&(n.blending=this.blending),this.side!==Tn&&(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!==sr&&(n.blendSrc=this.blendSrc),this.blendDst!==rr&&(n.blendDst=this.blendDst),this.blendEquation!==Un&&(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!==ri&&(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!==ba&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kn&&(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.allowOverride===!1&&(n.allowOverride=!1),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 s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),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 s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const an=new U,Xs=new U,Gi=new U,Mn=new U,qs=new U,Hi=new U,Ys=new U;class oa{constructor(e=new U,t=new U(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,an)),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=an.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(an.copy(this.origin).addScaledVector(this.direction,t),an.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Xs.copy(e).add(t).multiplyScalar(.5),Gi.copy(t).sub(e).normalize(),Mn.copy(this.origin).sub(Xs);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Gi),o=Mn.dot(this.direction),c=-Mn.dot(Gi),l=Mn.lengthSq(),f=Math.abs(1-a*a);let m,h,p,g;if(f>0)if(m=a*c-o,h=a*o-c,g=r*f,m>=0)if(h>=-g)if(h<=g){const S=1/f;m*=S,h*=S,p=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=r,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*c)+l;else h=-r,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*c)+l;else h<=-g?(m=Math.max(0,-(-a*r+o)),h=m>0?-r:Math.min(Math.max(-r,-c),r),p=-m*m+h*(h+2*c)+l):h<=g?(m=0,h=Math.min(Math.max(-r,-c),r),p=h*(h+2*c)+l):(m=Math.max(0,-(a*r+o)),h=m>0?r:Math.min(Math.max(-r,-c),r),p=-m*m+h*(h+2*c)+l);else h=a>0?-r:r,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(Xs).addScaledVector(Gi,h),p}intersectSphere(e,t){an.subVectors(e.center,this.origin);const n=an.dot(this.direction),s=an.dot(an)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,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,s,r,a,o,c;const l=1/this.direction.x,f=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,s=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,s=(e.min.x-h.x)*l),f>=0?(r=(e.min.y-h.y)*f,a=(e.max.y-h.y)*f):(r=(e.max.y-h.y)*f,a=(e.min.y-h.y)*f),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),m>=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,an)!==null}intersectTriangle(e,t,n,s,r){qs.subVectors(t,e),Hi.subVectors(n,e),Ys.crossVectors(qs,Hi);let a=this.direction.dot(Ys),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Mn.subVectors(this.origin,e);const c=o*this.direction.dot(Hi.crossVectors(Mn,Hi));if(c<0)return null;const l=o*this.direction.dot(qs.cross(Mn));if(l<0||c+l>a)return null;const f=-o*Mn.dot(Ys);return f<0?null:this.at(f/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Zo extends Vn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(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 jt,this.combine=bo,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 Ga=new st,Cn=new oa,ki=new wi,Ha=new U,Wi=new U,Xi=new U,qi=new U,Ks=new U,Yi=new U,ka=new U,Ki=new U;class dn extends ut{constructor(e=new gt,t=new Zo){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 s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){Yi.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const f=o[c],m=r[c];f!==0&&(Ks.fromBufferAttribute(m,e),a?Yi.addScaledVector(Ks,f):Yi.addScaledVector(Ks.sub(t),f))}t.add(Yi)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ki.copy(n.boundingSphere),ki.applyMatrix4(r),Cn.copy(e.ray).recast(e.near),!(ki.containsPoint(Cn.origin)===!1&&(Cn.intersectSphere(ki,Ha)===null||Cn.origin.distanceToSquared(Ha)>(e.far-e.near)**2))&&(Ga.copy(r).invert(),Cn.copy(e.ray).applyMatrix4(Ga),!(n.boundingBox!==null&&Cn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Cn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,f=r.attributes.uv1,m=r.attributes.normal,h=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,S=h.length;g<S;g++){const d=h[g],u=a[d.materialIndex],v=Math.max(d.start,p.start),T=Math.min(o.count,Math.min(d.start+d.count,p.start+p.count));for(let E=v,R=T;E<R;E+=3){const A=o.getX(E),P=o.getX(E+1),x=o.getX(E+2);s=Zi(this,u,e,n,l,f,m,A,P,x),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),S=Math.min(o.count,p.start+p.count);for(let d=g,u=S;d<u;d+=3){const v=o.getX(d),T=o.getX(d+1),E=o.getX(d+2);s=Zi(this,a,e,n,l,f,m,v,T,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,S=h.length;g<S;g++){const d=h[g],u=a[d.materialIndex],v=Math.max(d.start,p.start),T=Math.min(c.count,Math.min(d.start+d.count,p.start+p.count));for(let E=v,R=T;E<R;E+=3){const A=E,P=E+1,x=E+2;s=Zi(this,u,e,n,l,f,m,A,P,x),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),S=Math.min(c.count,p.start+p.count);for(let d=g,u=S;d<u;d+=3){const v=d,T=d+1,E=d+2;s=Zi(this,a,e,n,l,f,m,v,T,E),s&&(s.faceIndex=Math.floor(d/3),t.push(s))}}}}function Sc(i,e,t,n,s,r,a,o){let c;if(e.side===Rt?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===Tn,o),c===null)return null;Ki.copy(o),Ki.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Ki);return l<t.near||l>t.far?null:{distance:l,point:Ki.clone(),object:i}}function Zi(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Wi),i.getVertexPosition(c,Xi),i.getVertexPosition(l,qi);const f=Sc(i,e,t,n,Wi,Xi,qi,ka);if(f){const m=new U;zt.getBarycoord(ka,Wi,Xi,qi,m),s&&(f.uv=zt.getInterpolatedAttribute(s,o,c,l,m,new Ve)),r&&(f.uv1=zt.getInterpolatedAttribute(r,o,c,l,m,new Ve)),a&&(f.normal=zt.getInterpolatedAttribute(a,o,c,l,m,new U),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new U,materialIndex:0};zt.getNormal(Wi,Xi,qi,h.normal),f.face=h,f.barycoord=m}return f}class Ec extends bt{constructor(e=null,t=1,n=1,s,r,a,o,c,l=vt,f=vt,m,h){super(null,a,o,c,l,f,s,r,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Zs=new U,yc=new U,Tc=new Le;class In{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Zs.subVectors(n,t).cross(yc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,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(Zs),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||Tc.getNormalMatrix(e),s=this.coplanarPoint(Zs).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Pn=new wi,bc=new Ve(.5,.5),$i=new U;class la{constructor(e=new In,t=new In,n=new In,s=new In,r=new In,a=new In){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),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=qt,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],f=r[4],m=r[5],h=r[6],p=r[7],g=r[8],S=r[9],d=r[10],u=r[11],v=r[12],T=r[13],E=r[14],R=r[15];if(s[0].setComponents(l-a,p-f,u-g,R-v).normalize(),s[1].setComponents(l+a,p+f,u+g,R+v).normalize(),s[2].setComponents(l+o,p+m,u+S,R+T).normalize(),s[3].setComponents(l-o,p-m,u-S,R-T).normalize(),n)s[4].setComponents(c,h,d,E).normalize(),s[5].setComponents(l-c,p-h,u-d,R-E).normalize();else if(s[4].setComponents(l-c,p-h,u-d,R-E).normalize(),t===qt)s[5].setComponents(l+c,p+h,u+d,R+E).normalize();else if(t===Ti)s[5].setComponents(c,h,d,E).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(),Pn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Pn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pn)}intersectsSprite(e){Pn.center.set(0,0,0);const t=bc.distanceTo(e.center);return Pn.radius=.7071067811865476+t,Pn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pn)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if($i.x=s.normal.x>0?e.max.x:e.min.x,$i.y=s.normal.y>0?e.max.y:e.min.y,$i.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint($i)<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 $o extends Vn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(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 ms=new U,_s=new U,Wa=new st,gi=new oa,ji=new wi,$s=new U,Xa=new U;class Ac extends ut{constructor(e=new gt,t=new $o){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 s=1,r=t.count;s<r;s++)ms.fromBufferAttribute(t,s-1),_s.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=ms.distanceTo(_s);e.setAttribute("lineDistance",new Xe(n,1))}else Re("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ji.copy(n.boundingSphere),ji.applyMatrix4(s),ji.radius+=r,e.ray.intersectsSphere(ji)===!1)return;Wa.copy(s).invert(),gi.copy(e.ray).applyMatrix4(Wa);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,f=n.index,h=n.attributes.position;if(f!==null){const p=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let S=p,d=g-1;S<d;S+=l){const u=f.getX(S),v=f.getX(S+1),T=Ji(this,e,gi,c,u,v,S);T&&t.push(T)}if(this.isLineLoop){const S=f.getX(g-1),d=f.getX(p),u=Ji(this,e,gi,c,S,d,g-1);u&&t.push(u)}}else{const p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let S=p,d=g-1;S<d;S+=l){const u=Ji(this,e,gi,c,S,S+1,S);u&&t.push(u)}if(this.isLineLoop){const S=Ji(this,e,gi,c,g-1,p,g-1);S&&t.push(S)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ji(i,e,t,n,s,r,a){const o=i.geometry.attributes.position;if(ms.fromBufferAttribute(o,s),_s.fromBufferAttribute(o,r),t.distanceSqToSegment(ms,_s,$s,Xa)>n)return;$s.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo($s);if(!(l<e.near||l>e.far))return{distance:l,point:Xa.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const qa=new U,Ya=new U;class Rc extends Ac{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 s=0,r=t.count;s<r;s+=2)qa.fromBufferAttribute(t,s),Ya.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+qa.distanceTo(Ya);e.setAttribute("lineDistance",new Xe(n,1))}else Re("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wc extends Vn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ne(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 Ka=new st,Kr=new oa,Qi=new wi,es=new U;class Gp extends ut{constructor(e=new gt,t=new wc){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,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Qi.copy(n.boundingSphere),Qi.applyMatrix4(s),Qi.radius+=r,e.ray.intersectsSphere(Qi)===!1)return;Ka.copy(s).invert(),Kr.copy(e.ray).applyMatrix4(Ka);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,m=n.attributes.position;if(l!==null){const h=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=h,S=p;g<S;g++){const d=l.getX(g);es.fromBufferAttribute(m,d),Za(es,d,c,s,e,t,this)}}else{const h=Math.max(0,a.start),p=Math.min(m.count,a.start+a.count);for(let g=h,S=p;g<S;g++)es.fromBufferAttribute(m,g),Za(es,g,c,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Za(i,e,t,n,s,r,a){const o=Kr.distanceSqToPoint(i);if(o<t){const c=new U;Kr.closestPointToPoint(i,c),c.applyMatrix4(n);const l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class jo extends bt{constructor(e=[],t=Bn,n,s,r,a,o,c,l,f){super(e,t,n,s,r,a,o,c,l,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class bi extends bt{constructor(e,t,n=$t,s,r,a,o=vt,c=vt,l,f=fn,m=1){if(f!==fn&&f!==On)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:m};super(h,s,r,a,o,c,f,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new aa(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 Cc extends bi{constructor(e,t=$t,n=Bn,s,r,a=vt,o=vt,c,l=fn){const f={width:e,height:e,depth:1},m=[f,f,f,f,f,f];super(e,e,t,n,s,r,a,o,c,l),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Jo extends bt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ci extends gt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],f=[],m=[];let h=0,p=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,s,a,2),g("x","z","y",1,-1,e,n,-t,s,a,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Xe(l,3)),this.setAttribute("normal",new Xe(f,3)),this.setAttribute("uv",new Xe(m,2));function g(S,d,u,v,T,E,R,A,P,x,y){const V=E/P,w=R/x,N=E/2,O=R/2,k=A/2,G=P+1,z=x+1;let H=0,Q=0;const $=new U;for(let ce=0;ce<z;ce++){const pe=ce*w-O;for(let ue=0;ue<G;ue++){const Ie=ue*V-N;$[S]=Ie*v,$[d]=pe*T,$[u]=k,l.push($.x,$.y,$.z),$[S]=0,$[d]=0,$[u]=A>0?1:-1,f.push($.x,$.y,$.z),m.push(ue/P),m.push(1-ce/x),H+=1}}for(let ce=0;ce<x;ce++)for(let pe=0;pe<P;pe++){const ue=h+pe+G*ce,Ie=h+pe+G*(ce+1),it=h+(pe+1)+G*(ce+1),nt=h+(pe+1)+G*ce;c.push(ue,Ie,nt),c.push(Ie,it,nt),Q+=6}o.addGroup(p,Q,y),p+=Q,h+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ci(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Qo extends gt{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const r=[],a=[],o=[],c=[],l=new U,f=new Ve;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let m=0,h=3;m<=t;m++,h+=3){const p=n+m/t*s;l.x=e*Math.cos(p),l.y=e*Math.sin(p),a.push(l.x,l.y,l.z),o.push(0,0,1),f.x=(a[h]/e+1)/2,f.y=(a[h+1]/e+1)/2,c.push(f.x,f.y)}for(let m=1;m<=t;m++)r.push(m,m+1,0);this.setIndex(r),this.setAttribute("position",new Xe(a,3)),this.setAttribute("normal",new Xe(o,3)),this.setAttribute("uv",new Xe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ca extends gt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;s=Math.floor(s),r=Math.floor(r);const f=[],m=[],h=[],p=[];let g=0;const S=[],d=n/2;let u=0;v(),a===!1&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(f),this.setAttribute("position",new Xe(m,3)),this.setAttribute("normal",new Xe(h,3)),this.setAttribute("uv",new Xe(p,2));function v(){const E=new U,R=new U;let A=0;const P=(t-e)/n;for(let x=0;x<=r;x++){const y=[],V=x/r,w=V*(t-e)+e;for(let N=0;N<=s;N++){const O=N/s,k=O*c+o,G=Math.sin(k),z=Math.cos(k);R.x=w*G,R.y=-V*n+d,R.z=w*z,m.push(R.x,R.y,R.z),E.set(G,P,z).normalize(),h.push(E.x,E.y,E.z),p.push(O,1-V),y.push(g++)}S.push(y)}for(let x=0;x<s;x++)for(let y=0;y<r;y++){const V=S[y][x],w=S[y+1][x],N=S[y+1][x+1],O=S[y][x+1];(e>0||y!==0)&&(f.push(V,w,O),A+=3),(t>0||y!==r-1)&&(f.push(w,N,O),A+=3)}l.addGroup(u,A,0),u+=A}function T(E){const R=g,A=new Ve,P=new U;let x=0;const y=E===!0?e:t,V=E===!0?1:-1;for(let N=1;N<=s;N++)m.push(0,d*V,0),h.push(0,V,0),p.push(.5,.5),g++;const w=g;for(let N=0;N<=s;N++){const k=N/s*c+o,G=Math.cos(k),z=Math.sin(k);P.x=y*z,P.y=d*V,P.z=y*G,m.push(P.x,P.y,P.z),h.push(0,V,0),A.x=G*.5+.5,A.y=z*.5*V+.5,p.push(A.x,A.y),g++}for(let N=0;N<s;N++){const O=R+N,k=w+N;E===!0?f.push(k,k+1,O):f.push(k+1,k,O),x+=3}l.addGroup(u,x,E===!0?1:2),u+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ca(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class el extends ca{constructor(e=1,t=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new el(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ha extends gt{constructor(e=[],t=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:s};const r=[],a=[];o(s),l(n),f(),this.setAttribute("position",new Xe(r,3)),this.setAttribute("normal",new Xe(r.slice(),3)),this.setAttribute("uv",new Xe(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(v){const T=new U,E=new U,R=new U;for(let A=0;A<t.length;A+=3)p(t[A+0],T),p(t[A+1],E),p(t[A+2],R),c(T,E,R,v)}function c(v,T,E,R){const A=R+1,P=[];for(let x=0;x<=A;x++){P[x]=[];const y=v.clone().lerp(E,x/A),V=T.clone().lerp(E,x/A),w=A-x;for(let N=0;N<=w;N++)N===0&&x===A?P[x][N]=y:P[x][N]=y.clone().lerp(V,N/w)}for(let x=0;x<A;x++)for(let y=0;y<2*(A-x)-1;y++){const V=Math.floor(y/2);y%2===0?(h(P[x][V+1]),h(P[x+1][V]),h(P[x][V])):(h(P[x][V+1]),h(P[x+1][V+1]),h(P[x+1][V]))}}function l(v){const T=new U;for(let E=0;E<r.length;E+=3)T.x=r[E+0],T.y=r[E+1],T.z=r[E+2],T.normalize().multiplyScalar(v),r[E+0]=T.x,r[E+1]=T.y,r[E+2]=T.z}function f(){const v=new U;for(let T=0;T<r.length;T+=3){v.x=r[T+0],v.y=r[T+1],v.z=r[T+2];const E=d(v)/2/Math.PI+.5,R=u(v)/Math.PI+.5;a.push(E,1-R)}g(),m()}function m(){for(let v=0;v<a.length;v+=6){const T=a[v+0],E=a[v+2],R=a[v+4],A=Math.max(T,E,R),P=Math.min(T,E,R);A>.9&&P<.1&&(T<.2&&(a[v+0]+=1),E<.2&&(a[v+2]+=1),R<.2&&(a[v+4]+=1))}}function h(v){r.push(v.x,v.y,v.z)}function p(v,T){const E=v*3;T.x=e[E+0],T.y=e[E+1],T.z=e[E+2]}function g(){const v=new U,T=new U,E=new U,R=new U,A=new Ve,P=new Ve,x=new Ve;for(let y=0,V=0;y<r.length;y+=9,V+=6){v.set(r[y+0],r[y+1],r[y+2]),T.set(r[y+3],r[y+4],r[y+5]),E.set(r[y+6],r[y+7],r[y+8]),A.set(a[V+0],a[V+1]),P.set(a[V+2],a[V+3]),x.set(a[V+4],a[V+5]),R.copy(v).add(T).add(E).divideScalar(3);const w=d(R);S(A,V+0,v,w),S(P,V+2,T,w),S(x,V+4,E,w)}}function S(v,T,E,R){R<0&&v.x===1&&(a[T]=v.x-1),E.x===0&&E.z===0&&(a[T]=R/2/Math.PI+.5)}function d(v){return Math.atan2(v.z,-v.x)}function u(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ha(e.vertices,e.indices,e.radius,e.detail)}}class tl extends ha{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(s,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new tl(e.radius,e.detail)}}class xs extends gt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,f=c+1,m=e/o,h=t/c,p=[],g=[],S=[],d=[];for(let u=0;u<f;u++){const v=u*h-a;for(let T=0;T<l;T++){const E=T*m-r;g.push(E,-v,0),S.push(0,0,1),d.push(T/o),d.push(1-u/c)}}for(let u=0;u<c;u++)for(let v=0;v<o;v++){const T=v+l*u,E=v+l*(u+1),R=v+1+l*(u+1),A=v+1+l*u;p.push(T,E,A),p.push(E,R,A)}this.setIndex(p),this.setAttribute("position",new Xe(g,3)),this.setAttribute("normal",new Xe(S,3)),this.setAttribute("uv",new Xe(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xs(e.width,e.height,e.widthSegments,e.heightSegments)}}class nl extends gt{constructor(e=.5,t=1,n=32,s=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:s,thetaStart:r,thetaLength:a},n=Math.max(3,n),s=Math.max(1,s);const o=[],c=[],l=[],f=[];let m=e;const h=(t-e)/s,p=new U,g=new Ve;for(let S=0;S<=s;S++){for(let d=0;d<=n;d++){const u=r+d/n*a;p.x=m*Math.cos(u),p.y=m*Math.sin(u),c.push(p.x,p.y,p.z),l.push(0,0,1),g.x=(p.x/t+1)/2,g.y=(p.y/t+1)/2,f.push(g.x,g.y)}m+=h}for(let S=0;S<s;S++){const d=S*(n+1);for(let u=0;u<n;u++){const v=u+d,T=v,E=v+n+1,R=v+n+2,A=v+1;o.push(T,E,A),o.push(E,R,A)}}this.setIndex(o),this.setAttribute("position",new Xe(c,3)),this.setAttribute("normal",new Xe(l,3)),this.setAttribute("uv",new Xe(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nl(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class il extends gt{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const f=[],m=new U,h=new U,p=[],g=[],S=[],d=[];for(let u=0;u<=n;u++){const v=[],T=u/n;let E=0;u===0&&a===0?E=.5/t:u===n&&c===Math.PI&&(E=-.5/t);for(let R=0;R<=t;R++){const A=R/t;m.x=-e*Math.cos(s+A*r)*Math.sin(a+T*o),m.y=e*Math.cos(a+T*o),m.z=e*Math.sin(s+A*r)*Math.sin(a+T*o),g.push(m.x,m.y,m.z),h.copy(m).normalize(),S.push(h.x,h.y,h.z),d.push(A+E,1-T),v.push(l++)}f.push(v)}for(let u=0;u<n;u++)for(let v=0;v<t;v++){const T=f[u][v+1],E=f[u][v],R=f[u+1][v],A=f[u+1][v+1];(u!==0||a>0)&&p.push(T,E,A),(u!==n-1||c<Math.PI)&&p.push(E,R,A)}this.setIndex(p),this.setAttribute("position",new Xe(g,3)),this.setAttribute("normal",new Xe(S,3)),this.setAttribute("uv",new Xe(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new il(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class sl extends gt{constructor(e=1,t=.4,n=12,s=48,r=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:s,arc:r,thetaStart:a,thetaLength:o},n=Math.floor(n),s=Math.floor(s);const c=[],l=[],f=[],m=[],h=new U,p=new U,g=new U;for(let S=0;S<=n;S++){const d=a+S/n*o;for(let u=0;u<=s;u++){const v=u/s*r;p.x=(e+t*Math.cos(d))*Math.cos(v),p.y=(e+t*Math.cos(d))*Math.sin(v),p.z=t*Math.sin(d),l.push(p.x,p.y,p.z),h.x=e*Math.cos(v),h.y=e*Math.sin(v),g.subVectors(p,h).normalize(),f.push(g.x,g.y,g.z),m.push(u/s),m.push(S/n)}}for(let S=1;S<=n;S++)for(let d=1;d<=s;d++){const u=(s+1)*S+d-1,v=(s+1)*(S-1)+d-1,T=(s+1)*(S-1)+d,E=(s+1)*S+d;c.push(u,v,E),c.push(v,T,E)}this.setIndex(c),this.setAttribute("position",new Xe(l,3)),this.setAttribute("normal",new Xe(f,3)),this.setAttribute("uv",new Xe(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}function ci(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(Re("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function Tt(i){const e={};for(let t=0;t<i.length;t++){const n=ci(i[t]);for(const s in n)e[s]=n[s]}return e}function Pc(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function rl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:He.workingColorSpace}const Dc={clone:ci,merge:Tt};var Lc=`void main() {
6
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
+ }`,Ic=`void main() {
8
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
+ }`;class Jt extends Vn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Lc,this.fragmentShader=Ic,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=ci(e.uniforms),this.uniformsGroups=Pc(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={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 s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Uc extends Jt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Nc extends Vn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ne(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Go,this.normalScale=new Ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Hp extends Nc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ve(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ze(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ne(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ne(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ne(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Fc extends Vn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Xl,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 Oc extends Vn{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 vs extends ut{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(e),this.intensity=t}dispose(){this.dispatchEvent({type:"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,t}}class kp extends vs{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const js=new st,$a=new U,ja=new U;class al{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ve(512,512),this.mapType=Dt,this.map=null,this.mapPass=null,this.matrix=new st,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new la,this._frameExtents=new Ve(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;$a.setFromMatrixPosition(e.matrixWorld),t.position.copy($a),ja.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ja),t.updateMatrixWorld(),js.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(js,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ti||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(js)}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.biasNode=e.biasNode,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 ts=new U,ns=new hi,Ht=new U;class ol extends ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new st,this.projectionMatrix=new st,this.projectionMatrixInverse=new st,this.coordinateSystem=qt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ts,ns,Ht),Ht.x===1&&Ht.y===1&&Ht.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ts,ns,Ht.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(ts,ns,Ht),Ht.x===1&&Ht.y===1&&Ht.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ts,ns,Ht.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Sn=new U,Ja=new Ve,Qa=new Ve;class Ut extends ol{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Yr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(hs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Yr*2*Math.atan(Math.tan(hs*.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){Sn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Sn.x,Sn.y).multiplyScalar(-e/Sn.z),Sn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Sn.x,Sn.y).multiplyScalar(-e/Sn.z)}getViewSize(e,t){return this.getViewBounds(e,Ja,Qa),t.subVectors(Qa,Ja)}setViewOffset(e,t,n,s,r,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=s,this.view.width=r,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(hs*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){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}}class Bc extends al{constructor(){super(new Ut(90,1,.5,500)),this.isPointLightShadow=!0}}class Wp extends vs{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Bc}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class ua extends ol{constructor(e=-1,t=1,n=1,s=-1,r=.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=s,this.near=r,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,s,r,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=s,this.view.width=r,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,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,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 zc extends al{constructor(){super(new ua(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Xp extends vs{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new zc}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class qp extends vs{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const ei=-90,ti=1;class Vc extends ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Ut(ei,ti,e,t);s.layers=this.layers,this.add(s);const r=new Ut(ei,ti,e,t);r.layers=this.layers,this.add(r);const a=new Ut(ei,ti,e,t);a.layers=this.layers,this.add(a);const o=new Ut(ei,ti,e,t);o.layers=this.layers,this.add(o);const c=new Ut(ei,ti,e,t);c.layers=this.layers,this.add(c);const l=new Ut(ei,ti,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===qt)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Ti)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,f]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let d=!1;e.isWebGLRenderer===!0?d=e.state.buffers.depth.getReversed():d=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,s),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,f),e.setRenderTarget(m,h,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Gc extends Ut{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Yp{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=Hc.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Hc(){this._document.hidden===!1&&this.reset()}class Kp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Re("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let 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 Zp{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=ze(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(ze(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class $p extends Rc{constructor(e=10,t=10,n=4473924,s=8947848){n=new Ne(n),s=new Ne(s);const r=t/2,a=e/t,o=e/2,c=[],l=[];for(let h=0,p=0,g=-o;h<=t;h++,g+=a){c.push(-o,0,g,o,0,g),c.push(g,0,-o,g,0,o);const S=h===r?n:s;S.toArray(l,p),p+=3,S.toArray(l,p),p+=3,S.toArray(l,p),p+=3,S.toArray(l,p),p+=3}const f=new gt;f.setAttribute("position",new Xe(c,3)),f.setAttribute("color",new Xe(l,3));const m=new $o({vertexColors:!0,toneMapped:!1});super(f,m),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class jp extends zn{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){Re("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function eo(i,e,t,n){const s=kc(n);switch(t){case Bo:return i*e;case Vo:return i*e/s.components*s.byteLength;case ta:return i*e/s.components*s.byteLength;case oi:return i*e*2/s.components*s.byteLength;case na:return i*e*2/s.components*s.byteLength;case zo:return i*e*3/s.components*s.byteLength;case Vt:return i*e*4/s.components*s.byteLength;case ia:return i*e*4/s.components*s.byteLength;case as:case os:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ls:case cs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case _r:case xr:return Math.max(i,16)*Math.max(e,8)/4;case mr:case gr:return Math.max(i,8)*Math.max(e,8)/2;case vr:case Mr:case Er:case yr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Sr:case Tr:case br:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ar:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Rr:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case wr:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Cr:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Pr:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Dr:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Lr:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ir:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Ur:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Nr:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Fr:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Or:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Br:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case zr:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Vr:case Gr:case Hr:return Math.ceil(i/4)*Math.ceil(e/4)*16;case kr:case Wr:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Xr:case qr:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function kc(i){switch(i){case Dt:case Uo:return{byteLength:1,components:1};case Ei:case No:case un:return{byteLength:2,components:1};case Qr:case ea:return{byteLength:2,components:4};case $t:case Jr:case Xt:return{byteLength:4,components:1};case Fo:case Oo:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jr}}));typeof window<"u"&&(window.__THREE__?Re("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jr);/**
10
+ * @license
11
+ * Copyright 2010-2026 Three.js Authors
12
+ * SPDX-License-Identifier: MIT
13
+ */function ll(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Wc(i){const e=new WeakMap;function t(o,c){const l=o.array,f=o.usage,m=l.byteLength,h=i.createBuffer();i.bindBuffer(c,h),i.bufferData(c,l,f),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:m}}function n(o,c,l){const f=c.array,m=c.updateRanges;if(i.bindBuffer(l,o),m.length===0)i.bufferSubData(l,0,f);else{m.sort((p,g)=>p.start-g.start);let h=0;for(let p=1;p<m.length;p++){const g=m[h],S=m[p];S.start<=g.start+g.count+1?g.count=Math.max(g.count,S.start+S.count-g.start):(++h,m[h]=S)}m.length=h+1;for(let p=0,g=m.length;p<g;p++){const S=m[p];i.bufferSubData(l,S.start*f.BYTES_PER_ELEMENT,f,S.start,S.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){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 l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.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(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var Xc=`#ifdef USE_ALPHAHASH
14
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
15
+ #endif`,qc=`#ifdef USE_ALPHAHASH
16
+ const float ALPHA_HASH_SCALE = 0.05;
17
+ float hash2D( vec2 value ) {
18
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
19
+ }
20
+ float hash3D( vec3 value ) {
21
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
22
+ }
23
+ float getAlphaHashThreshold( vec3 position ) {
24
+ float maxDeriv = max(
25
+ length( dFdx( position.xyz ) ),
26
+ length( dFdy( position.xyz ) )
27
+ );
28
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
29
+ vec2 pixScales = vec2(
30
+ exp2( floor( log2( pixScale ) ) ),
31
+ exp2( ceil( log2( pixScale ) ) )
32
+ );
33
+ vec2 alpha = vec2(
34
+ hash3D( floor( pixScales.x * position.xyz ) ),
35
+ hash3D( floor( pixScales.y * position.xyz ) )
36
+ );
37
+ float lerpFactor = fract( log2( pixScale ) );
38
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
39
+ float a = min( lerpFactor, 1.0 - lerpFactor );
40
+ vec3 cases = vec3(
41
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
42
+ ( x - 0.5 * a ) / ( 1.0 - a ),
43
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
44
+ );
45
+ float threshold = ( x < ( 1.0 - a ) )
46
+ ? ( ( x < a ) ? cases.x : cases.y )
47
+ : cases.z;
48
+ return clamp( threshold , 1.0e-6, 1.0 );
49
+ }
50
+ #endif`,Yc=`#ifdef USE_ALPHAMAP
51
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
52
+ #endif`,Kc=`#ifdef USE_ALPHAMAP
53
+ uniform sampler2D alphaMap;
54
+ #endif`,Zc=`#ifdef USE_ALPHATEST
55
+ #ifdef ALPHA_TO_COVERAGE
56
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
57
+ if ( diffuseColor.a == 0.0 ) discard;
58
+ #else
59
+ if ( diffuseColor.a < alphaTest ) discard;
60
+ #endif
61
+ #endif`,$c=`#ifdef USE_ALPHATEST
62
+ uniform float alphaTest;
63
+ #endif`,jc=`#ifdef USE_AOMAP
64
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
65
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
66
+ #if defined( USE_CLEARCOAT )
67
+ clearcoatSpecularIndirect *= ambientOcclusion;
68
+ #endif
69
+ #if defined( USE_SHEEN )
70
+ sheenSpecularIndirect *= ambientOcclusion;
71
+ #endif
72
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
73
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
74
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
75
+ #endif
76
+ #endif`,Jc=`#ifdef USE_AOMAP
77
+ uniform sampler2D aoMap;
78
+ uniform float aoMapIntensity;
79
+ #endif`,Qc=`#ifdef USE_BATCHING
80
+ #if ! defined( GL_ANGLE_multi_draw )
81
+ #define gl_DrawID _gl_DrawID
82
+ uniform int _gl_DrawID;
83
+ #endif
84
+ uniform highp sampler2D batchingTexture;
85
+ uniform highp usampler2D batchingIdTexture;
86
+ mat4 getBatchingMatrix( const in float i ) {
87
+ int size = textureSize( batchingTexture, 0 ).x;
88
+ int j = int( i ) * 4;
89
+ int x = j % size;
90
+ int y = j / size;
91
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
92
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
93
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
94
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
95
+ return mat4( v1, v2, v3, v4 );
96
+ }
97
+ float getIndirectIndex( const in int i ) {
98
+ int size = textureSize( batchingIdTexture, 0 ).x;
99
+ int x = i % size;
100
+ int y = i / size;
101
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
102
+ }
103
+ #endif
104
+ #ifdef USE_BATCHING_COLOR
105
+ uniform sampler2D batchingColorTexture;
106
+ vec4 getBatchingColor( const in float i ) {
107
+ int size = textureSize( batchingColorTexture, 0 ).x;
108
+ int j = int( i );
109
+ int x = j % size;
110
+ int y = j / size;
111
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
112
+ }
113
+ #endif`,eh=`#ifdef USE_BATCHING
114
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
115
+ #endif`,th=`vec3 transformed = vec3( position );
116
+ #ifdef USE_ALPHAHASH
117
+ vPosition = vec3( position );
118
+ #endif`,nh=`vec3 objectNormal = vec3( normal );
119
+ #ifdef USE_TANGENT
120
+ vec3 objectTangent = vec3( tangent.xyz );
121
+ #endif`,ih=`float G_BlinnPhong_Implicit( ) {
122
+ return 0.25;
123
+ }
124
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
125
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
126
+ }
127
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
128
+ vec3 halfDir = normalize( lightDir + viewDir );
129
+ float dotNH = saturate( dot( normal, halfDir ) );
130
+ float dotVH = saturate( dot( viewDir, halfDir ) );
131
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
132
+ float G = G_BlinnPhong_Implicit( );
133
+ float D = D_BlinnPhong( shininess, dotNH );
134
+ return F * ( G * D );
135
+ } // validated`,sh=`#ifdef USE_IRIDESCENCE
136
+ const mat3 XYZ_TO_REC709 = mat3(
137
+ 3.2404542, -0.9692660, 0.0556434,
138
+ -1.5371385, 1.8760108, -0.2040259,
139
+ -0.4985314, 0.0415560, 1.0572252
140
+ );
141
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
142
+ vec3 sqrtF0 = sqrt( fresnel0 );
143
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
144
+ }
145
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
146
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
147
+ }
148
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
149
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
150
+ }
151
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
152
+ float phase = 2.0 * PI * OPD * 1.0e-9;
153
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
154
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
155
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
156
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
157
+ 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 ) );
158
+ xyz /= 1.0685e-7;
159
+ vec3 rgb = XYZ_TO_REC709 * xyz;
160
+ return rgb;
161
+ }
162
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
163
+ vec3 I;
164
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
165
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
166
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
167
+ if ( cosTheta2Sq < 0.0 ) {
168
+ return vec3( 1.0 );
169
+ }
170
+ float cosTheta2 = sqrt( cosTheta2Sq );
171
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
172
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
173
+ float T121 = 1.0 - R12;
174
+ float phi12 = 0.0;
175
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
176
+ float phi21 = PI - phi12;
177
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
178
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
179
+ vec3 phi23 = vec3( 0.0 );
180
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
181
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
182
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
183
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
184
+ vec3 phi = vec3( phi21 ) + phi23;
185
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
186
+ vec3 r123 = sqrt( R123 );
187
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
188
+ vec3 C0 = R12 + Rs;
189
+ I = C0;
190
+ vec3 Cm = Rs - T121;
191
+ for ( int m = 1; m <= 2; ++ m ) {
192
+ Cm *= r123;
193
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
194
+ I += Cm * Sm;
195
+ }
196
+ return max( I, vec3( 0.0 ) );
197
+ }
198
+ #endif`,rh=`#ifdef USE_BUMPMAP
199
+ uniform sampler2D bumpMap;
200
+ uniform float bumpScale;
201
+ vec2 dHdxy_fwd() {
202
+ vec2 dSTdx = dFdx( vBumpMapUv );
203
+ vec2 dSTdy = dFdy( vBumpMapUv );
204
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
205
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
206
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
207
+ return vec2( dBx, dBy );
208
+ }
209
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
210
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
211
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
212
+ vec3 vN = surf_norm;
213
+ vec3 R1 = cross( vSigmaY, vN );
214
+ vec3 R2 = cross( vN, vSigmaX );
215
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
216
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
217
+ return normalize( abs( fDet ) * surf_norm - vGrad );
218
+ }
219
+ #endif`,ah=`#if NUM_CLIPPING_PLANES > 0
220
+ vec4 plane;
221
+ #ifdef ALPHA_TO_COVERAGE
222
+ float distanceToPlane, distanceGradient;
223
+ float clipOpacity = 1.0;
224
+ #pragma unroll_loop_start
225
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
226
+ plane = clippingPlanes[ i ];
227
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
228
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
229
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
230
+ if ( clipOpacity == 0.0 ) discard;
231
+ }
232
+ #pragma unroll_loop_end
233
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
234
+ float unionClipOpacity = 1.0;
235
+ #pragma unroll_loop_start
236
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
237
+ plane = clippingPlanes[ i ];
238
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
239
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
240
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
241
+ }
242
+ #pragma unroll_loop_end
243
+ clipOpacity *= 1.0 - unionClipOpacity;
244
+ #endif
245
+ diffuseColor.a *= clipOpacity;
246
+ if ( diffuseColor.a == 0.0 ) discard;
247
+ #else
248
+ #pragma unroll_loop_start
249
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
250
+ plane = clippingPlanes[ i ];
251
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
252
+ }
253
+ #pragma unroll_loop_end
254
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
255
+ bool clipped = true;
256
+ #pragma unroll_loop_start
257
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
258
+ plane = clippingPlanes[ i ];
259
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
260
+ }
261
+ #pragma unroll_loop_end
262
+ if ( clipped ) discard;
263
+ #endif
264
+ #endif
265
+ #endif`,oh=`#if NUM_CLIPPING_PLANES > 0
266
+ varying vec3 vClipPosition;
267
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
268
+ #endif`,lh=`#if NUM_CLIPPING_PLANES > 0
269
+ varying vec3 vClipPosition;
270
+ #endif`,ch=`#if NUM_CLIPPING_PLANES > 0
271
+ vClipPosition = - mvPosition.xyz;
272
+ #endif`,hh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
273
+ diffuseColor *= vColor;
274
+ #endif`,uh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
275
+ varying vec4 vColor;
276
+ #endif`,fh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
277
+ varying vec4 vColor;
278
+ #endif`,dh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
279
+ vColor = vec4( 1.0 );
280
+ #endif
281
+ #ifdef USE_COLOR_ALPHA
282
+ vColor *= color;
283
+ #elif defined( USE_COLOR )
284
+ vColor.rgb *= color;
285
+ #endif
286
+ #ifdef USE_INSTANCING_COLOR
287
+ vColor.rgb *= instanceColor.rgb;
288
+ #endif
289
+ #ifdef USE_BATCHING_COLOR
290
+ vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
291
+ #endif`,ph=`#define PI 3.141592653589793
292
+ #define PI2 6.283185307179586
293
+ #define PI_HALF 1.5707963267948966
294
+ #define RECIPROCAL_PI 0.3183098861837907
295
+ #define RECIPROCAL_PI2 0.15915494309189535
296
+ #define EPSILON 1e-6
297
+ #ifndef saturate
298
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
299
+ #endif
300
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
301
+ float pow2( const in float x ) { return x*x; }
302
+ vec3 pow2( const in vec3 x ) { return x*x; }
303
+ float pow3( const in float x ) { return x*x*x; }
304
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
305
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
306
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
307
+ highp float rand( const in vec2 uv ) {
308
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
309
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
310
+ return fract( sin( sn ) * c );
311
+ }
312
+ #ifdef HIGH_PRECISION
313
+ float precisionSafeLength( vec3 v ) { return length( v ); }
314
+ #else
315
+ float precisionSafeLength( vec3 v ) {
316
+ float maxComponent = max3( abs( v ) );
317
+ return length( v / maxComponent ) * maxComponent;
318
+ }
319
+ #endif
320
+ struct IncidentLight {
321
+ vec3 color;
322
+ vec3 direction;
323
+ bool visible;
324
+ };
325
+ struct ReflectedLight {
326
+ vec3 directDiffuse;
327
+ vec3 directSpecular;
328
+ vec3 indirectDiffuse;
329
+ vec3 indirectSpecular;
330
+ };
331
+ #ifdef USE_ALPHAHASH
332
+ varying vec3 vPosition;
333
+ #endif
334
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
335
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
336
+ }
337
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
338
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
339
+ }
340
+ bool isPerspectiveMatrix( mat4 m ) {
341
+ return m[ 2 ][ 3 ] == - 1.0;
342
+ }
343
+ vec2 equirectUv( in vec3 dir ) {
344
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
345
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
346
+ return vec2( u, v );
347
+ }
348
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
349
+ return RECIPROCAL_PI * diffuseColor;
350
+ }
351
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
352
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
+ }
355
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
356
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
357
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
358
+ } // validated`,mh=`#ifdef ENVMAP_TYPE_CUBE_UV
359
+ #define cubeUV_minMipLevel 4.0
360
+ #define cubeUV_minTileSize 16.0
361
+ float getFace( vec3 direction ) {
362
+ vec3 absDirection = abs( direction );
363
+ float face = - 1.0;
364
+ if ( absDirection.x > absDirection.z ) {
365
+ if ( absDirection.x > absDirection.y )
366
+ face = direction.x > 0.0 ? 0.0 : 3.0;
367
+ else
368
+ face = direction.y > 0.0 ? 1.0 : 4.0;
369
+ } else {
370
+ if ( absDirection.z > absDirection.y )
371
+ face = direction.z > 0.0 ? 2.0 : 5.0;
372
+ else
373
+ face = direction.y > 0.0 ? 1.0 : 4.0;
374
+ }
375
+ return face;
376
+ }
377
+ vec2 getUV( vec3 direction, float face ) {
378
+ vec2 uv;
379
+ if ( face == 0.0 ) {
380
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
381
+ } else if ( face == 1.0 ) {
382
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
383
+ } else if ( face == 2.0 ) {
384
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
385
+ } else if ( face == 3.0 ) {
386
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
387
+ } else if ( face == 4.0 ) {
388
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
389
+ } else {
390
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
391
+ }
392
+ return 0.5 * ( uv + 1.0 );
393
+ }
394
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
395
+ float face = getFace( direction );
396
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
397
+ mipInt = max( mipInt, cubeUV_minMipLevel );
398
+ float faceSize = exp2( mipInt );
399
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
400
+ if ( face > 2.0 ) {
401
+ uv.y += faceSize;
402
+ face -= 3.0;
403
+ }
404
+ uv.x += face * faceSize;
405
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
406
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
407
+ uv.x *= CUBEUV_TEXEL_WIDTH;
408
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
409
+ #ifdef texture2DGradEXT
410
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
411
+ #else
412
+ return texture2D( envMap, uv ).rgb;
413
+ #endif
414
+ }
415
+ #define cubeUV_r0 1.0
416
+ #define cubeUV_m0 - 2.0
417
+ #define cubeUV_r1 0.8
418
+ #define cubeUV_m1 - 1.0
419
+ #define cubeUV_r4 0.4
420
+ #define cubeUV_m4 2.0
421
+ #define cubeUV_r5 0.305
422
+ #define cubeUV_m5 3.0
423
+ #define cubeUV_r6 0.21
424
+ #define cubeUV_m6 4.0
425
+ float roughnessToMip( float roughness ) {
426
+ float mip = 0.0;
427
+ if ( roughness >= cubeUV_r1 ) {
428
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
429
+ } else if ( roughness >= cubeUV_r4 ) {
430
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
431
+ } else if ( roughness >= cubeUV_r5 ) {
432
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
433
+ } else if ( roughness >= cubeUV_r6 ) {
434
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
435
+ } else {
436
+ mip = - 2.0 * log2( 1.16 * roughness ); }
437
+ return mip;
438
+ }
439
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
440
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
441
+ float mipF = fract( mip );
442
+ float mipInt = floor( mip );
443
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
444
+ if ( mipF == 0.0 ) {
445
+ return vec4( color0, 1.0 );
446
+ } else {
447
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
448
+ return vec4( mix( color0, color1, mipF ), 1.0 );
449
+ }
450
+ }
451
+ #endif`,_h=`vec3 transformedNormal = objectNormal;
452
+ #ifdef USE_TANGENT
453
+ vec3 transformedTangent = objectTangent;
454
+ #endif
455
+ #ifdef USE_BATCHING
456
+ mat3 bm = mat3( batchingMatrix );
457
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
458
+ transformedNormal = bm * transformedNormal;
459
+ #ifdef USE_TANGENT
460
+ transformedTangent = bm * transformedTangent;
461
+ #endif
462
+ #endif
463
+ #ifdef USE_INSTANCING
464
+ mat3 im = mat3( instanceMatrix );
465
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
466
+ transformedNormal = im * transformedNormal;
467
+ #ifdef USE_TANGENT
468
+ transformedTangent = im * transformedTangent;
469
+ #endif
470
+ #endif
471
+ transformedNormal = normalMatrix * transformedNormal;
472
+ #ifdef FLIP_SIDED
473
+ transformedNormal = - transformedNormal;
474
+ #endif
475
+ #ifdef USE_TANGENT
476
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
477
+ #ifdef FLIP_SIDED
478
+ transformedTangent = - transformedTangent;
479
+ #endif
480
+ #endif`,gh=`#ifdef USE_DISPLACEMENTMAP
481
+ uniform sampler2D displacementMap;
482
+ uniform float displacementScale;
483
+ uniform float displacementBias;
484
+ #endif`,xh=`#ifdef USE_DISPLACEMENTMAP
485
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
486
+ #endif`,vh=`#ifdef USE_EMISSIVEMAP
487
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
488
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
489
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
490
+ #endif
491
+ totalEmissiveRadiance *= emissiveColor.rgb;
492
+ #endif`,Mh=`#ifdef USE_EMISSIVEMAP
493
+ uniform sampler2D emissiveMap;
494
+ #endif`,Sh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Eh=`vec4 LinearTransferOETF( in vec4 value ) {
495
+ return value;
496
+ }
497
+ vec4 sRGBTransferEOTF( in vec4 value ) {
498
+ 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 );
499
+ }
500
+ vec4 sRGBTransferOETF( in vec4 value ) {
501
+ 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 );
502
+ }`,yh=`#ifdef USE_ENVMAP
503
+ #ifdef ENV_WORLDPOS
504
+ vec3 cameraToFrag;
505
+ if ( isOrthographic ) {
506
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
507
+ } else {
508
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
509
+ }
510
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
511
+ #ifdef ENVMAP_MODE_REFLECTION
512
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
513
+ #else
514
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
515
+ #endif
516
+ #else
517
+ vec3 reflectVec = vReflect;
518
+ #endif
519
+ #ifdef ENVMAP_TYPE_CUBE
520
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
521
+ #ifdef ENVMAP_BLENDING_MULTIPLY
522
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
523
+ #elif defined( ENVMAP_BLENDING_MIX )
524
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
525
+ #elif defined( ENVMAP_BLENDING_ADD )
526
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
527
+ #endif
528
+ #endif
529
+ #endif`,Th=`#ifdef USE_ENVMAP
530
+ uniform float envMapIntensity;
531
+ uniform float flipEnvMap;
532
+ uniform mat3 envMapRotation;
533
+ #ifdef ENVMAP_TYPE_CUBE
534
+ uniform samplerCube envMap;
535
+ #else
536
+ uniform sampler2D envMap;
537
+ #endif
538
+ #endif`,bh=`#ifdef USE_ENVMAP
539
+ uniform float reflectivity;
540
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
541
+ #define ENV_WORLDPOS
542
+ #endif
543
+ #ifdef ENV_WORLDPOS
544
+ varying vec3 vWorldPosition;
545
+ uniform float refractionRatio;
546
+ #else
547
+ varying vec3 vReflect;
548
+ #endif
549
+ #endif`,Ah=`#ifdef USE_ENVMAP
550
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
551
+ #define ENV_WORLDPOS
552
+ #endif
553
+ #ifdef ENV_WORLDPOS
554
+
555
+ varying vec3 vWorldPosition;
556
+ #else
557
+ varying vec3 vReflect;
558
+ uniform float refractionRatio;
559
+ #endif
560
+ #endif`,Rh=`#ifdef USE_ENVMAP
561
+ #ifdef ENV_WORLDPOS
562
+ vWorldPosition = worldPosition.xyz;
563
+ #else
564
+ vec3 cameraToVertex;
565
+ if ( isOrthographic ) {
566
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
567
+ } else {
568
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
569
+ }
570
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
571
+ #ifdef ENVMAP_MODE_REFLECTION
572
+ vReflect = reflect( cameraToVertex, worldNormal );
573
+ #else
574
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
575
+ #endif
576
+ #endif
577
+ #endif`,wh=`#ifdef USE_FOG
578
+ vFogDepth = - mvPosition.z;
579
+ #endif`,Ch=`#ifdef USE_FOG
580
+ varying float vFogDepth;
581
+ #endif`,Ph=`#ifdef USE_FOG
582
+ #ifdef FOG_EXP2
583
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
584
+ #else
585
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
586
+ #endif
587
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
588
+ #endif`,Dh=`#ifdef USE_FOG
589
+ uniform vec3 fogColor;
590
+ varying float vFogDepth;
591
+ #ifdef FOG_EXP2
592
+ uniform float fogDensity;
593
+ #else
594
+ uniform float fogNear;
595
+ uniform float fogFar;
596
+ #endif
597
+ #endif`,Lh=`#ifdef USE_GRADIENTMAP
598
+ uniform sampler2D gradientMap;
599
+ #endif
600
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
601
+ float dotNL = dot( normal, lightDirection );
602
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
603
+ #ifdef USE_GRADIENTMAP
604
+ return vec3( texture2D( gradientMap, coord ).r );
605
+ #else
606
+ vec2 fw = fwidth( coord ) * 0.5;
607
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
608
+ #endif
609
+ }`,Ih=`#ifdef USE_LIGHTMAP
610
+ uniform sampler2D lightMap;
611
+ uniform float lightMapIntensity;
612
+ #endif`,Uh=`LambertMaterial material;
613
+ material.diffuseColor = diffuseColor.rgb;
614
+ material.specularStrength = specularStrength;`,Nh=`varying vec3 vViewPosition;
615
+ struct LambertMaterial {
616
+ vec3 diffuseColor;
617
+ float specularStrength;
618
+ };
619
+ 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 ) {
620
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
621
+ vec3 irradiance = dotNL * directLight.color;
622
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
623
+ }
624
+ 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 ) {
625
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
626
+ }
627
+ #define RE_Direct RE_Direct_Lambert
628
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Fh=`uniform bool receiveShadow;
629
+ uniform vec3 ambientLightColor;
630
+ #if defined( USE_LIGHT_PROBES )
631
+ uniform vec3 lightProbe[ 9 ];
632
+ #endif
633
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
634
+ float x = normal.x, y = normal.y, z = normal.z;
635
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
636
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
637
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
638
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
639
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
640
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
641
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
642
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
643
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
644
+ return result;
645
+ }
646
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
647
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
648
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
649
+ return irradiance;
650
+ }
651
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
652
+ vec3 irradiance = ambientLightColor;
653
+ return irradiance;
654
+ }
655
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
656
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
657
+ if ( cutoffDistance > 0.0 ) {
658
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
659
+ }
660
+ return distanceFalloff;
661
+ }
662
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
663
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
664
+ }
665
+ #if NUM_DIR_LIGHTS > 0
666
+ struct DirectionalLight {
667
+ vec3 direction;
668
+ vec3 color;
669
+ };
670
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
671
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
672
+ light.color = directionalLight.color;
673
+ light.direction = directionalLight.direction;
674
+ light.visible = true;
675
+ }
676
+ #endif
677
+ #if NUM_POINT_LIGHTS > 0
678
+ struct PointLight {
679
+ vec3 position;
680
+ vec3 color;
681
+ float distance;
682
+ float decay;
683
+ };
684
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
685
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
686
+ vec3 lVector = pointLight.position - geometryPosition;
687
+ light.direction = normalize( lVector );
688
+ float lightDistance = length( lVector );
689
+ light.color = pointLight.color;
690
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
691
+ light.visible = ( light.color != vec3( 0.0 ) );
692
+ }
693
+ #endif
694
+ #if NUM_SPOT_LIGHTS > 0
695
+ struct SpotLight {
696
+ vec3 position;
697
+ vec3 direction;
698
+ vec3 color;
699
+ float distance;
700
+ float decay;
701
+ float coneCos;
702
+ float penumbraCos;
703
+ };
704
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
705
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
706
+ vec3 lVector = spotLight.position - geometryPosition;
707
+ light.direction = normalize( lVector );
708
+ float angleCos = dot( light.direction, spotLight.direction );
709
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
710
+ if ( spotAttenuation > 0.0 ) {
711
+ float lightDistance = length( lVector );
712
+ light.color = spotLight.color * spotAttenuation;
713
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
714
+ light.visible = ( light.color != vec3( 0.0 ) );
715
+ } else {
716
+ light.color = vec3( 0.0 );
717
+ light.visible = false;
718
+ }
719
+ }
720
+ #endif
721
+ #if NUM_RECT_AREA_LIGHTS > 0
722
+ struct RectAreaLight {
723
+ vec3 color;
724
+ vec3 position;
725
+ vec3 halfWidth;
726
+ vec3 halfHeight;
727
+ };
728
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
729
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
730
+ #endif
731
+ #if NUM_HEMI_LIGHTS > 0
732
+ struct HemisphereLight {
733
+ vec3 direction;
734
+ vec3 skyColor;
735
+ vec3 groundColor;
736
+ };
737
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
738
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
739
+ float dotNL = dot( normal, hemiLight.direction );
740
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
741
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
742
+ return irradiance;
743
+ }
744
+ #endif`,Oh=`#ifdef USE_ENVMAP
745
+ vec3 getIBLIrradiance( const in vec3 normal ) {
746
+ #ifdef ENVMAP_TYPE_CUBE_UV
747
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
748
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
749
+ return PI * envMapColor.rgb * envMapIntensity;
750
+ #else
751
+ return vec3( 0.0 );
752
+ #endif
753
+ }
754
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
755
+ #ifdef ENVMAP_TYPE_CUBE_UV
756
+ vec3 reflectVec = reflect( - viewDir, normal );
757
+ reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
758
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
759
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
760
+ return envMapColor.rgb * envMapIntensity;
761
+ #else
762
+ return vec3( 0.0 );
763
+ #endif
764
+ }
765
+ #ifdef USE_ANISOTROPY
766
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
767
+ #ifdef ENVMAP_TYPE_CUBE_UV
768
+ vec3 bentNormal = cross( bitangent, viewDir );
769
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
770
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
771
+ return getIBLRadiance( viewDir, bentNormal, roughness );
772
+ #else
773
+ return vec3( 0.0 );
774
+ #endif
775
+ }
776
+ #endif
777
+ #endif`,Bh=`ToonMaterial material;
778
+ material.diffuseColor = diffuseColor.rgb;`,zh=`varying vec3 vViewPosition;
779
+ struct ToonMaterial {
780
+ vec3 diffuseColor;
781
+ };
782
+ 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 ) {
783
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
784
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
785
+ }
786
+ 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 ) {
787
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
788
+ }
789
+ #define RE_Direct RE_Direct_Toon
790
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Vh=`BlinnPhongMaterial material;
791
+ material.diffuseColor = diffuseColor.rgb;
792
+ material.specularColor = specular;
793
+ material.specularShininess = shininess;
794
+ material.specularStrength = specularStrength;`,Gh=`varying vec3 vViewPosition;
795
+ struct BlinnPhongMaterial {
796
+ vec3 diffuseColor;
797
+ vec3 specularColor;
798
+ float specularShininess;
799
+ float specularStrength;
800
+ };
801
+ 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 ) {
802
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
803
+ vec3 irradiance = dotNL * directLight.color;
804
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
805
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
806
+ }
807
+ 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 ) {
808
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
809
+ }
810
+ #define RE_Direct RE_Direct_BlinnPhong
811
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Hh=`PhysicalMaterial material;
812
+ material.diffuseColor = diffuseColor.rgb;
813
+ material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
814
+ material.metalness = metalnessFactor;
815
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
816
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
817
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
818
+ material.roughness = min( material.roughness, 1.0 );
819
+ #ifdef IOR
820
+ material.ior = ior;
821
+ #ifdef USE_SPECULAR
822
+ float specularIntensityFactor = specularIntensity;
823
+ vec3 specularColorFactor = specularColor;
824
+ #ifdef USE_SPECULAR_COLORMAP
825
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
826
+ #endif
827
+ #ifdef USE_SPECULAR_INTENSITYMAP
828
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
829
+ #endif
830
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
831
+ #else
832
+ float specularIntensityFactor = 1.0;
833
+ vec3 specularColorFactor = vec3( 1.0 );
834
+ material.specularF90 = 1.0;
835
+ #endif
836
+ material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
837
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
838
+ #else
839
+ material.specularColor = vec3( 0.04 );
840
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
841
+ material.specularF90 = 1.0;
842
+ #endif
843
+ #ifdef USE_CLEARCOAT
844
+ material.clearcoat = clearcoat;
845
+ material.clearcoatRoughness = clearcoatRoughness;
846
+ material.clearcoatF0 = vec3( 0.04 );
847
+ material.clearcoatF90 = 1.0;
848
+ #ifdef USE_CLEARCOATMAP
849
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
850
+ #endif
851
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
852
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
853
+ #endif
854
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
855
+ material.clearcoatRoughness += geometryRoughness;
856
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
857
+ #endif
858
+ #ifdef USE_DISPERSION
859
+ material.dispersion = dispersion;
860
+ #endif
861
+ #ifdef USE_IRIDESCENCE
862
+ material.iridescence = iridescence;
863
+ material.iridescenceIOR = iridescenceIOR;
864
+ #ifdef USE_IRIDESCENCEMAP
865
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
866
+ #endif
867
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
868
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
869
+ #else
870
+ material.iridescenceThickness = iridescenceThicknessMaximum;
871
+ #endif
872
+ #endif
873
+ #ifdef USE_SHEEN
874
+ material.sheenColor = sheenColor;
875
+ #ifdef USE_SHEEN_COLORMAP
876
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
877
+ #endif
878
+ material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
879
+ #ifdef USE_SHEEN_ROUGHNESSMAP
880
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
881
+ #endif
882
+ #endif
883
+ #ifdef USE_ANISOTROPY
884
+ #ifdef USE_ANISOTROPYMAP
885
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
886
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
887
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
888
+ #else
889
+ vec2 anisotropyV = anisotropyVector;
890
+ #endif
891
+ material.anisotropy = length( anisotropyV );
892
+ if( material.anisotropy == 0.0 ) {
893
+ anisotropyV = vec2( 1.0, 0.0 );
894
+ } else {
895
+ anisotropyV /= material.anisotropy;
896
+ material.anisotropy = saturate( material.anisotropy );
897
+ }
898
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
899
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
900
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
901
+ #endif`,kh=`uniform sampler2D dfgLUT;
902
+ struct PhysicalMaterial {
903
+ vec3 diffuseColor;
904
+ vec3 diffuseContribution;
905
+ vec3 specularColor;
906
+ vec3 specularColorBlended;
907
+ float roughness;
908
+ float metalness;
909
+ float specularF90;
910
+ float dispersion;
911
+ #ifdef USE_CLEARCOAT
912
+ float clearcoat;
913
+ float clearcoatRoughness;
914
+ vec3 clearcoatF0;
915
+ float clearcoatF90;
916
+ #endif
917
+ #ifdef USE_IRIDESCENCE
918
+ float iridescence;
919
+ float iridescenceIOR;
920
+ float iridescenceThickness;
921
+ vec3 iridescenceFresnel;
922
+ vec3 iridescenceF0;
923
+ vec3 iridescenceFresnelDielectric;
924
+ vec3 iridescenceFresnelMetallic;
925
+ #endif
926
+ #ifdef USE_SHEEN
927
+ vec3 sheenColor;
928
+ float sheenRoughness;
929
+ #endif
930
+ #ifdef IOR
931
+ float ior;
932
+ #endif
933
+ #ifdef USE_TRANSMISSION
934
+ float transmission;
935
+ float transmissionAlpha;
936
+ float thickness;
937
+ float attenuationDistance;
938
+ vec3 attenuationColor;
939
+ #endif
940
+ #ifdef USE_ANISOTROPY
941
+ float anisotropy;
942
+ float alphaT;
943
+ vec3 anisotropyT;
944
+ vec3 anisotropyB;
945
+ #endif
946
+ };
947
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
948
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
949
+ vec3 sheenSpecularDirect = vec3( 0.0 );
950
+ vec3 sheenSpecularIndirect = vec3(0.0 );
951
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
952
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
953
+ float x2 = x * x;
954
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
955
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
956
+ }
957
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
958
+ float a2 = pow2( alpha );
959
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
960
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
961
+ return 0.5 / max( gv + gl, EPSILON );
962
+ }
963
+ float D_GGX( const in float alpha, const in float dotNH ) {
964
+ float a2 = pow2( alpha );
965
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
966
+ return RECIPROCAL_PI * a2 / pow2( denom );
967
+ }
968
+ #ifdef USE_ANISOTROPY
969
+ 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 ) {
970
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
971
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
972
+ float v = 0.5 / ( gv + gl );
973
+ return v;
974
+ }
975
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
976
+ float a2 = alphaT * alphaB;
977
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
978
+ highp float v2 = dot( v, v );
979
+ float w2 = a2 / v2;
980
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
981
+ }
982
+ #endif
983
+ #ifdef USE_CLEARCOAT
984
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
985
+ vec3 f0 = material.clearcoatF0;
986
+ float f90 = material.clearcoatF90;
987
+ float roughness = material.clearcoatRoughness;
988
+ float alpha = pow2( roughness );
989
+ vec3 halfDir = normalize( lightDir + viewDir );
990
+ float dotNL = saturate( dot( normal, lightDir ) );
991
+ float dotNV = saturate( dot( normal, viewDir ) );
992
+ float dotNH = saturate( dot( normal, halfDir ) );
993
+ float dotVH = saturate( dot( viewDir, halfDir ) );
994
+ vec3 F = F_Schlick( f0, f90, dotVH );
995
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
996
+ float D = D_GGX( alpha, dotNH );
997
+ return F * ( V * D );
998
+ }
999
+ #endif
1000
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1001
+ vec3 f0 = material.specularColorBlended;
1002
+ float f90 = material.specularF90;
1003
+ float roughness = material.roughness;
1004
+ float alpha = pow2( roughness );
1005
+ vec3 halfDir = normalize( lightDir + viewDir );
1006
+ float dotNL = saturate( dot( normal, lightDir ) );
1007
+ float dotNV = saturate( dot( normal, viewDir ) );
1008
+ float dotNH = saturate( dot( normal, halfDir ) );
1009
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1010
+ vec3 F = F_Schlick( f0, f90, dotVH );
1011
+ #ifdef USE_IRIDESCENCE
1012
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1013
+ #endif
1014
+ #ifdef USE_ANISOTROPY
1015
+ float dotTL = dot( material.anisotropyT, lightDir );
1016
+ float dotTV = dot( material.anisotropyT, viewDir );
1017
+ float dotTH = dot( material.anisotropyT, halfDir );
1018
+ float dotBL = dot( material.anisotropyB, lightDir );
1019
+ float dotBV = dot( material.anisotropyB, viewDir );
1020
+ float dotBH = dot( material.anisotropyB, halfDir );
1021
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1022
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1023
+ #else
1024
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1025
+ float D = D_GGX( alpha, dotNH );
1026
+ #endif
1027
+ return F * ( V * D );
1028
+ }
1029
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1030
+ const float LUT_SIZE = 64.0;
1031
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1032
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1033
+ float dotNV = saturate( dot( N, V ) );
1034
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1035
+ uv = uv * LUT_SCALE + LUT_BIAS;
1036
+ return uv;
1037
+ }
1038
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1039
+ float l = length( f );
1040
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1041
+ }
1042
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1043
+ float x = dot( v1, v2 );
1044
+ float y = abs( x );
1045
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1046
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1047
+ float v = a / b;
1048
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1049
+ return cross( v1, v2 ) * theta_sintheta;
1050
+ }
1051
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1052
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1053
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1054
+ vec3 lightNormal = cross( v1, v2 );
1055
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1056
+ vec3 T1, T2;
1057
+ T1 = normalize( V - N * dot( V, N ) );
1058
+ T2 = - cross( N, T1 );
1059
+ mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
1060
+ vec3 coords[ 4 ];
1061
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1062
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1063
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1064
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1065
+ coords[ 0 ] = normalize( coords[ 0 ] );
1066
+ coords[ 1 ] = normalize( coords[ 1 ] );
1067
+ coords[ 2 ] = normalize( coords[ 2 ] );
1068
+ coords[ 3 ] = normalize( coords[ 3 ] );
1069
+ vec3 vectorFormFactor = vec3( 0.0 );
1070
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1071
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1072
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1073
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1074
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1075
+ return vec3( result );
1076
+ }
1077
+ #if defined( USE_SHEEN )
1078
+ float D_Charlie( float roughness, float dotNH ) {
1079
+ float alpha = pow2( roughness );
1080
+ float invAlpha = 1.0 / alpha;
1081
+ float cos2h = dotNH * dotNH;
1082
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1083
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1084
+ }
1085
+ float V_Neubelt( float dotNV, float dotNL ) {
1086
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1087
+ }
1088
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1089
+ vec3 halfDir = normalize( lightDir + viewDir );
1090
+ float dotNL = saturate( dot( normal, lightDir ) );
1091
+ float dotNV = saturate( dot( normal, viewDir ) );
1092
+ float dotNH = saturate( dot( normal, halfDir ) );
1093
+ float D = D_Charlie( sheenRoughness, dotNH );
1094
+ float V = V_Neubelt( dotNV, dotNL );
1095
+ return sheenColor * ( D * V );
1096
+ }
1097
+ #endif
1098
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1099
+ float dotNV = saturate( dot( normal, viewDir ) );
1100
+ float r2 = roughness * roughness;
1101
+ float rInv = 1.0 / ( roughness + 0.1 );
1102
+ float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
1103
+ float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
1104
+ float DG = exp( a * dotNV + b );
1105
+ return saturate( DG );
1106
+ }
1107
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1108
+ float dotNV = saturate( dot( normal, viewDir ) );
1109
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
1110
+ return specularColor * fab.x + specularF90 * fab.y;
1111
+ }
1112
+ #ifdef USE_IRIDESCENCE
1113
+ 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 ) {
1114
+ #else
1115
+ 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 ) {
1116
+ #endif
1117
+ float dotNV = saturate( dot( normal, viewDir ) );
1118
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
1119
+ #ifdef USE_IRIDESCENCE
1120
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1121
+ #else
1122
+ vec3 Fr = specularColor;
1123
+ #endif
1124
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1125
+ float Ess = fab.x + fab.y;
1126
+ float Ems = 1.0 - Ess;
1127
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1128
+ singleScatter += FssEss;
1129
+ multiScatter += Fms * Ems;
1130
+ }
1131
+ vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1132
+ vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
1133
+ float dotNL = saturate( dot( normal, lightDir ) );
1134
+ float dotNV = saturate( dot( normal, viewDir ) );
1135
+ vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
1136
+ vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
1137
+ vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
1138
+ vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
1139
+ float Ess_V = dfgV.x + dfgV.y;
1140
+ float Ess_L = dfgL.x + dfgL.y;
1141
+ float Ems_V = 1.0 - Ess_V;
1142
+ float Ems_L = 1.0 - Ess_L;
1143
+ vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
1144
+ vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
1145
+ float compensationFactor = Ems_V * Ems_L;
1146
+ vec3 multiScatter = Fms * compensationFactor;
1147
+ return singleScatter + multiScatter;
1148
+ }
1149
+ #if NUM_RECT_AREA_LIGHTS > 0
1150
+ 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 ) {
1151
+ vec3 normal = geometryNormal;
1152
+ vec3 viewDir = geometryViewDir;
1153
+ vec3 position = geometryPosition;
1154
+ vec3 lightPos = rectAreaLight.position;
1155
+ vec3 halfWidth = rectAreaLight.halfWidth;
1156
+ vec3 halfHeight = rectAreaLight.halfHeight;
1157
+ vec3 lightColor = rectAreaLight.color;
1158
+ float roughness = material.roughness;
1159
+ vec3 rectCoords[ 4 ];
1160
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1161
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1162
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1163
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1164
+ vec4 t1 = texture2D( ltc_1, uv );
1165
+ vec4 t2 = texture2D( ltc_2, uv );
1166
+ mat3 mInv = mat3(
1167
+ vec3( t1.x, 0, t1.y ),
1168
+ vec3( 0, 1, 0 ),
1169
+ vec3( t1.z, 0, t1.w )
1170
+ );
1171
+ vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
1172
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1173
+ reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1174
+ #ifdef USE_CLEARCOAT
1175
+ vec3 Ncc = geometryClearcoatNormal;
1176
+ vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
1177
+ vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
1178
+ vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
1179
+ mat3 mInvClearcoat = mat3(
1180
+ vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
1181
+ vec3( 0, 1, 0 ),
1182
+ vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
1183
+ );
1184
+ vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
1185
+ clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
1186
+ #endif
1187
+ }
1188
+ #endif
1189
+ 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 ) {
1190
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1191
+ vec3 irradiance = dotNL * directLight.color;
1192
+ #ifdef USE_CLEARCOAT
1193
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1194
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1195
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1196
+ #endif
1197
+ #ifdef USE_SHEEN
1198
+
1199
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1200
+
1201
+ float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1202
+ float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
1203
+
1204
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
1205
+
1206
+ irradiance *= sheenEnergyComp;
1207
+
1208
+ #endif
1209
+ reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
1210
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
1211
+ }
1212
+ 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 ) {
1213
+ vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
1214
+ #ifdef USE_SHEEN
1215
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1216
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
1217
+ diffuse *= sheenEnergyComp;
1218
+ #endif
1219
+ reflectedLight.indirectDiffuse += diffuse;
1220
+ }
1221
+ 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) {
1222
+ #ifdef USE_CLEARCOAT
1223
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1224
+ #endif
1225
+ #ifdef USE_SHEEN
1226
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
1227
+ #endif
1228
+ vec3 singleScatteringDielectric = vec3( 0.0 );
1229
+ vec3 multiScatteringDielectric = vec3( 0.0 );
1230
+ vec3 singleScatteringMetallic = vec3( 0.0 );
1231
+ vec3 multiScatteringMetallic = vec3( 0.0 );
1232
+ #ifdef USE_IRIDESCENCE
1233
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
1234
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
1235
+ #else
1236
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
1237
+ computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
1238
+ #endif
1239
+ vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
1240
+ vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
1241
+ vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
1242
+ vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
1243
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1244
+ vec3 indirectSpecular = radiance * singleScattering;
1245
+ indirectSpecular += multiScattering * cosineWeightedIrradiance;
1246
+ vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
1247
+ #ifdef USE_SHEEN
1248
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1249
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
1250
+ indirectSpecular *= sheenEnergyComp;
1251
+ indirectDiffuse *= sheenEnergyComp;
1252
+ #endif
1253
+ reflectedLight.indirectSpecular += indirectSpecular;
1254
+ reflectedLight.indirectDiffuse += indirectDiffuse;
1255
+ }
1256
+ #define RE_Direct RE_Direct_Physical
1257
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1258
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1259
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1260
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1261
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1262
+ }`,Wh=`
1263
+ vec3 geometryPosition = - vViewPosition;
1264
+ vec3 geometryNormal = normal;
1265
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1266
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1267
+ #ifdef USE_CLEARCOAT
1268
+ geometryClearcoatNormal = clearcoatNormal;
1269
+ #endif
1270
+ #ifdef USE_IRIDESCENCE
1271
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1272
+ if ( material.iridescenceThickness == 0.0 ) {
1273
+ material.iridescence = 0.0;
1274
+ } else {
1275
+ material.iridescence = saturate( material.iridescence );
1276
+ }
1277
+ if ( material.iridescence > 0.0 ) {
1278
+ material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1279
+ material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
1280
+ material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
1281
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1282
+ }
1283
+ #endif
1284
+ IncidentLight directLight;
1285
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1286
+ PointLight pointLight;
1287
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1288
+ PointLightShadow pointLightShadow;
1289
+ #endif
1290
+ #pragma unroll_loop_start
1291
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1292
+ pointLight = pointLights[ i ];
1293
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1294
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
1295
+ pointLightShadow = pointLightShadows[ i ];
1296
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1297
+ #endif
1298
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1299
+ }
1300
+ #pragma unroll_loop_end
1301
+ #endif
1302
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1303
+ SpotLight spotLight;
1304
+ vec4 spotColor;
1305
+ vec3 spotLightCoord;
1306
+ bool inSpotLightMap;
1307
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1308
+ SpotLightShadow spotLightShadow;
1309
+ #endif
1310
+ #pragma unroll_loop_start
1311
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1312
+ spotLight = spotLights[ i ];
1313
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1314
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1315
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1316
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1317
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1318
+ #else
1319
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1320
+ #endif
1321
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1322
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1323
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1324
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1325
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1326
+ #endif
1327
+ #undef SPOT_LIGHT_MAP_INDEX
1328
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1329
+ spotLightShadow = spotLightShadows[ i ];
1330
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1331
+ #endif
1332
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1333
+ }
1334
+ #pragma unroll_loop_end
1335
+ #endif
1336
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1337
+ DirectionalLight directionalLight;
1338
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1339
+ DirectionalLightShadow directionalLightShadow;
1340
+ #endif
1341
+ #pragma unroll_loop_start
1342
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1343
+ directionalLight = directionalLights[ i ];
1344
+ getDirectionalLightInfo( directionalLight, directLight );
1345
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1346
+ directionalLightShadow = directionalLightShadows[ i ];
1347
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1348
+ #endif
1349
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1350
+ }
1351
+ #pragma unroll_loop_end
1352
+ #endif
1353
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1354
+ RectAreaLight rectAreaLight;
1355
+ #pragma unroll_loop_start
1356
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1357
+ rectAreaLight = rectAreaLights[ i ];
1358
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1359
+ }
1360
+ #pragma unroll_loop_end
1361
+ #endif
1362
+ #if defined( RE_IndirectDiffuse )
1363
+ vec3 iblIrradiance = vec3( 0.0 );
1364
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1365
+ #if defined( USE_LIGHT_PROBES )
1366
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1367
+ #endif
1368
+ #if ( NUM_HEMI_LIGHTS > 0 )
1369
+ #pragma unroll_loop_start
1370
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1371
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1372
+ }
1373
+ #pragma unroll_loop_end
1374
+ #endif
1375
+ #endif
1376
+ #if defined( RE_IndirectSpecular )
1377
+ vec3 radiance = vec3( 0.0 );
1378
+ vec3 clearcoatRadiance = vec3( 0.0 );
1379
+ #endif`,Xh=`#if defined( RE_IndirectDiffuse )
1380
+ #ifdef USE_LIGHTMAP
1381
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1382
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1383
+ irradiance += lightMapIrradiance;
1384
+ #endif
1385
+ #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
1386
+ #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
1387
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1388
+ #endif
1389
+ #endif
1390
+ #endif
1391
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1392
+ #ifdef USE_ANISOTROPY
1393
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1394
+ #else
1395
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1396
+ #endif
1397
+ #ifdef USE_CLEARCOAT
1398
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1399
+ #endif
1400
+ #endif`,qh=`#if defined( RE_IndirectDiffuse )
1401
+ #if defined( LAMBERT ) || defined( PHONG )
1402
+ irradiance += iblIrradiance;
1403
+ #endif
1404
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1405
+ #endif
1406
+ #if defined( RE_IndirectSpecular )
1407
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1408
+ #endif`,Yh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1409
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1410
+ #endif`,Kh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1411
+ uniform float logDepthBufFC;
1412
+ varying float vFragDepth;
1413
+ varying float vIsPerspective;
1414
+ #endif`,Zh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1415
+ varying float vFragDepth;
1416
+ varying float vIsPerspective;
1417
+ #endif`,$h=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1418
+ vFragDepth = 1.0 + gl_Position.w;
1419
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1420
+ #endif`,jh=`#ifdef USE_MAP
1421
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1422
+ #ifdef DECODE_VIDEO_TEXTURE
1423
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1424
+ #endif
1425
+ diffuseColor *= sampledDiffuseColor;
1426
+ #endif`,Jh=`#ifdef USE_MAP
1427
+ uniform sampler2D map;
1428
+ #endif`,Qh=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1429
+ #if defined( USE_POINTS_UV )
1430
+ vec2 uv = vUv;
1431
+ #else
1432
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1433
+ #endif
1434
+ #endif
1435
+ #ifdef USE_MAP
1436
+ diffuseColor *= texture2D( map, uv );
1437
+ #endif
1438
+ #ifdef USE_ALPHAMAP
1439
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1440
+ #endif`,eu=`#if defined( USE_POINTS_UV )
1441
+ varying vec2 vUv;
1442
+ #else
1443
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1444
+ uniform mat3 uvTransform;
1445
+ #endif
1446
+ #endif
1447
+ #ifdef USE_MAP
1448
+ uniform sampler2D map;
1449
+ #endif
1450
+ #ifdef USE_ALPHAMAP
1451
+ uniform sampler2D alphaMap;
1452
+ #endif`,tu=`float metalnessFactor = metalness;
1453
+ #ifdef USE_METALNESSMAP
1454
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1455
+ metalnessFactor *= texelMetalness.b;
1456
+ #endif`,nu=`#ifdef USE_METALNESSMAP
1457
+ uniform sampler2D metalnessMap;
1458
+ #endif`,iu=`#ifdef USE_INSTANCING_MORPH
1459
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1460
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1461
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1462
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1463
+ }
1464
+ #endif`,su=`#if defined( USE_MORPHCOLORS )
1465
+ vColor *= morphTargetBaseInfluence;
1466
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1467
+ #if defined( USE_COLOR_ALPHA )
1468
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1469
+ #elif defined( USE_COLOR )
1470
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1471
+ #endif
1472
+ }
1473
+ #endif`,ru=`#ifdef USE_MORPHNORMALS
1474
+ objectNormal *= morphTargetBaseInfluence;
1475
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1476
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1477
+ }
1478
+ #endif`,au=`#ifdef USE_MORPHTARGETS
1479
+ #ifndef USE_INSTANCING_MORPH
1480
+ uniform float morphTargetBaseInfluence;
1481
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1482
+ #endif
1483
+ uniform sampler2DArray morphTargetsTexture;
1484
+ uniform ivec2 morphTargetsTextureSize;
1485
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1486
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1487
+ int y = texelIndex / morphTargetsTextureSize.x;
1488
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1489
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1490
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1491
+ }
1492
+ #endif`,ou=`#ifdef USE_MORPHTARGETS
1493
+ transformed *= morphTargetBaseInfluence;
1494
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1495
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1496
+ }
1497
+ #endif`,lu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1498
+ #ifdef FLAT_SHADED
1499
+ vec3 fdx = dFdx( vViewPosition );
1500
+ vec3 fdy = dFdy( vViewPosition );
1501
+ vec3 normal = normalize( cross( fdx, fdy ) );
1502
+ #else
1503
+ vec3 normal = normalize( vNormal );
1504
+ #ifdef DOUBLE_SIDED
1505
+ normal *= faceDirection;
1506
+ #endif
1507
+ #endif
1508
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1509
+ #ifdef USE_TANGENT
1510
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1511
+ #else
1512
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1513
+ #if defined( USE_NORMALMAP )
1514
+ vNormalMapUv
1515
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1516
+ vClearcoatNormalMapUv
1517
+ #else
1518
+ vUv
1519
+ #endif
1520
+ );
1521
+ #endif
1522
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1523
+ tbn[0] *= faceDirection;
1524
+ tbn[1] *= faceDirection;
1525
+ #endif
1526
+ #endif
1527
+ #ifdef USE_CLEARCOAT_NORMALMAP
1528
+ #ifdef USE_TANGENT
1529
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1530
+ #else
1531
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1532
+ #endif
1533
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1534
+ tbn2[0] *= faceDirection;
1535
+ tbn2[1] *= faceDirection;
1536
+ #endif
1537
+ #endif
1538
+ vec3 nonPerturbedNormal = normal;`,cu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1539
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1540
+ #ifdef FLIP_SIDED
1541
+ normal = - normal;
1542
+ #endif
1543
+ #ifdef DOUBLE_SIDED
1544
+ normal = normal * faceDirection;
1545
+ #endif
1546
+ normal = normalize( normalMatrix * normal );
1547
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1548
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1549
+ mapN.xy *= normalScale;
1550
+ normal = normalize( tbn * mapN );
1551
+ #elif defined( USE_BUMPMAP )
1552
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1553
+ #endif`,hu=`#ifndef FLAT_SHADED
1554
+ varying vec3 vNormal;
1555
+ #ifdef USE_TANGENT
1556
+ varying vec3 vTangent;
1557
+ varying vec3 vBitangent;
1558
+ #endif
1559
+ #endif`,uu=`#ifndef FLAT_SHADED
1560
+ varying vec3 vNormal;
1561
+ #ifdef USE_TANGENT
1562
+ varying vec3 vTangent;
1563
+ varying vec3 vBitangent;
1564
+ #endif
1565
+ #endif`,fu=`#ifndef FLAT_SHADED
1566
+ vNormal = normalize( transformedNormal );
1567
+ #ifdef USE_TANGENT
1568
+ vTangent = normalize( transformedTangent );
1569
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1570
+ #endif
1571
+ #endif`,du=`#ifdef USE_NORMALMAP
1572
+ uniform sampler2D normalMap;
1573
+ uniform vec2 normalScale;
1574
+ #endif
1575
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1576
+ uniform mat3 normalMatrix;
1577
+ #endif
1578
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1579
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1580
+ vec3 q0 = dFdx( eye_pos.xyz );
1581
+ vec3 q1 = dFdy( eye_pos.xyz );
1582
+ vec2 st0 = dFdx( uv.st );
1583
+ vec2 st1 = dFdy( uv.st );
1584
+ vec3 N = surf_norm;
1585
+ vec3 q1perp = cross( q1, N );
1586
+ vec3 q0perp = cross( N, q0 );
1587
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1588
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1589
+ float det = max( dot( T, T ), dot( B, B ) );
1590
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1591
+ return mat3( T * scale, B * scale, N );
1592
+ }
1593
+ #endif`,pu=`#ifdef USE_CLEARCOAT
1594
+ vec3 clearcoatNormal = nonPerturbedNormal;
1595
+ #endif`,mu=`#ifdef USE_CLEARCOAT_NORMALMAP
1596
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1597
+ clearcoatMapN.xy *= clearcoatNormalScale;
1598
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1599
+ #endif`,_u=`#ifdef USE_CLEARCOATMAP
1600
+ uniform sampler2D clearcoatMap;
1601
+ #endif
1602
+ #ifdef USE_CLEARCOAT_NORMALMAP
1603
+ uniform sampler2D clearcoatNormalMap;
1604
+ uniform vec2 clearcoatNormalScale;
1605
+ #endif
1606
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1607
+ uniform sampler2D clearcoatRoughnessMap;
1608
+ #endif`,gu=`#ifdef USE_IRIDESCENCEMAP
1609
+ uniform sampler2D iridescenceMap;
1610
+ #endif
1611
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1612
+ uniform sampler2D iridescenceThicknessMap;
1613
+ #endif`,xu=`#ifdef OPAQUE
1614
+ diffuseColor.a = 1.0;
1615
+ #endif
1616
+ #ifdef USE_TRANSMISSION
1617
+ diffuseColor.a *= material.transmissionAlpha;
1618
+ #endif
1619
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,vu=`vec3 packNormalToRGB( const in vec3 normal ) {
1620
+ return normalize( normal ) * 0.5 + 0.5;
1621
+ }
1622
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1623
+ return 2.0 * rgb.xyz - 1.0;
1624
+ }
1625
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1626
+ const float Inv255 = 1. / 255.;
1627
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1628
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1629
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1630
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1631
+ vec4 packDepthToRGBA( const in float v ) {
1632
+ if( v <= 0.0 )
1633
+ return vec4( 0., 0., 0., 0. );
1634
+ if( v >= 1.0 )
1635
+ return vec4( 1., 1., 1., 1. );
1636
+ float vuf;
1637
+ float af = modf( v * PackFactors.a, vuf );
1638
+ float bf = modf( vuf * ShiftRight8, vuf );
1639
+ float gf = modf( vuf * ShiftRight8, vuf );
1640
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1641
+ }
1642
+ vec3 packDepthToRGB( const in float v ) {
1643
+ if( v <= 0.0 )
1644
+ return vec3( 0., 0., 0. );
1645
+ if( v >= 1.0 )
1646
+ return vec3( 1., 1., 1. );
1647
+ float vuf;
1648
+ float bf = modf( v * PackFactors.b, vuf );
1649
+ float gf = modf( vuf * ShiftRight8, vuf );
1650
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1651
+ }
1652
+ vec2 packDepthToRG( const in float v ) {
1653
+ if( v <= 0.0 )
1654
+ return vec2( 0., 0. );
1655
+ if( v >= 1.0 )
1656
+ return vec2( 1., 1. );
1657
+ float vuf;
1658
+ float gf = modf( v * 256., vuf );
1659
+ return vec2( vuf * Inv255, gf );
1660
+ }
1661
+ float unpackRGBAToDepth( const in vec4 v ) {
1662
+ return dot( v, UnpackFactors4 );
1663
+ }
1664
+ float unpackRGBToDepth( const in vec3 v ) {
1665
+ return dot( v, UnpackFactors3 );
1666
+ }
1667
+ float unpackRGToDepth( const in vec2 v ) {
1668
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1669
+ }
1670
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1671
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1672
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1673
+ }
1674
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1675
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1676
+ }
1677
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1678
+ return ( viewZ + near ) / ( near - far );
1679
+ }
1680
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1681
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1682
+
1683
+ return depth * ( far - near ) - far;
1684
+ #else
1685
+ return depth * ( near - far ) - near;
1686
+ #endif
1687
+ }
1688
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1689
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1690
+ }
1691
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1692
+
1693
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1694
+ return ( near * far ) / ( ( near - far ) * depth - near );
1695
+ #else
1696
+ return ( near * far ) / ( ( far - near ) * depth - far );
1697
+ #endif
1698
+ }`,Mu=`#ifdef PREMULTIPLIED_ALPHA
1699
+ gl_FragColor.rgb *= gl_FragColor.a;
1700
+ #endif`,Su=`vec4 mvPosition = vec4( transformed, 1.0 );
1701
+ #ifdef USE_BATCHING
1702
+ mvPosition = batchingMatrix * mvPosition;
1703
+ #endif
1704
+ #ifdef USE_INSTANCING
1705
+ mvPosition = instanceMatrix * mvPosition;
1706
+ #endif
1707
+ mvPosition = modelViewMatrix * mvPosition;
1708
+ gl_Position = projectionMatrix * mvPosition;`,Eu=`#ifdef DITHERING
1709
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1710
+ #endif`,yu=`#ifdef DITHERING
1711
+ vec3 dithering( vec3 color ) {
1712
+ float grid_position = rand( gl_FragCoord.xy );
1713
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1714
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1715
+ return color + dither_shift_RGB;
1716
+ }
1717
+ #endif`,Tu=`float roughnessFactor = roughness;
1718
+ #ifdef USE_ROUGHNESSMAP
1719
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1720
+ roughnessFactor *= texelRoughness.g;
1721
+ #endif`,bu=`#ifdef USE_ROUGHNESSMAP
1722
+ uniform sampler2D roughnessMap;
1723
+ #endif`,Au=`#if NUM_SPOT_LIGHT_COORDS > 0
1724
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1725
+ #endif
1726
+ #if NUM_SPOT_LIGHT_MAPS > 0
1727
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1728
+ #endif
1729
+ #ifdef USE_SHADOWMAP
1730
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1731
+ #if defined( SHADOWMAP_TYPE_PCF )
1732
+ uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1733
+ #else
1734
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1735
+ #endif
1736
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1737
+ struct DirectionalLightShadow {
1738
+ float shadowIntensity;
1739
+ float shadowBias;
1740
+ float shadowNormalBias;
1741
+ float shadowRadius;
1742
+ vec2 shadowMapSize;
1743
+ };
1744
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1745
+ #endif
1746
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1747
+ #if defined( SHADOWMAP_TYPE_PCF )
1748
+ uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1749
+ #else
1750
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1751
+ #endif
1752
+ struct SpotLightShadow {
1753
+ float shadowIntensity;
1754
+ float shadowBias;
1755
+ float shadowNormalBias;
1756
+ float shadowRadius;
1757
+ vec2 shadowMapSize;
1758
+ };
1759
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1760
+ #endif
1761
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1762
+ #if defined( SHADOWMAP_TYPE_PCF )
1763
+ uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1764
+ #elif defined( SHADOWMAP_TYPE_BASIC )
1765
+ uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1766
+ #endif
1767
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1768
+ struct PointLightShadow {
1769
+ float shadowIntensity;
1770
+ float shadowBias;
1771
+ float shadowNormalBias;
1772
+ float shadowRadius;
1773
+ vec2 shadowMapSize;
1774
+ float shadowCameraNear;
1775
+ float shadowCameraFar;
1776
+ };
1777
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1778
+ #endif
1779
+ #if defined( SHADOWMAP_TYPE_PCF )
1780
+ float interleavedGradientNoise( vec2 position ) {
1781
+ return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
1782
+ }
1783
+ vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
1784
+ const float goldenAngle = 2.399963229728653;
1785
+ float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
1786
+ float theta = float( sampleIndex ) * goldenAngle + phi;
1787
+ return vec2( cos( theta ), sin( theta ) ) * r;
1788
+ }
1789
+ #endif
1790
+ #if defined( SHADOWMAP_TYPE_PCF )
1791
+ float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1792
+ float shadow = 1.0;
1793
+ shadowCoord.xyz /= shadowCoord.w;
1794
+ shadowCoord.z += shadowBias;
1795
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1796
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1797
+ if ( frustumTest ) {
1798
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1799
+ float radius = shadowRadius * texelSize.x;
1800
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
1801
+ shadow = (
1802
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
1803
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
1804
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
1805
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
1806
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
1807
+ ) * 0.2;
1808
+ }
1809
+ return mix( 1.0, shadow, shadowIntensity );
1810
+ }
1811
+ #elif defined( SHADOWMAP_TYPE_VSM )
1812
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1813
+ float shadow = 1.0;
1814
+ shadowCoord.xyz /= shadowCoord.w;
1815
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1816
+ shadowCoord.z -= shadowBias;
1817
+ #else
1818
+ shadowCoord.z += shadowBias;
1819
+ #endif
1820
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1821
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1822
+ if ( frustumTest ) {
1823
+ vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
1824
+ float mean = distribution.x;
1825
+ float variance = distribution.y * distribution.y;
1826
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1827
+ float hard_shadow = step( mean, shadowCoord.z );
1828
+ #else
1829
+ float hard_shadow = step( shadowCoord.z, mean );
1830
+ #endif
1831
+
1832
+ if ( hard_shadow == 1.0 ) {
1833
+ shadow = 1.0;
1834
+ } else {
1835
+ variance = max( variance, 0.0000001 );
1836
+ float d = shadowCoord.z - mean;
1837
+ float p_max = variance / ( variance + d * d );
1838
+ p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
1839
+ shadow = max( hard_shadow, p_max );
1840
+ }
1841
+ }
1842
+ return mix( 1.0, shadow, shadowIntensity );
1843
+ }
1844
+ #else
1845
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1846
+ float shadow = 1.0;
1847
+ shadowCoord.xyz /= shadowCoord.w;
1848
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1849
+ shadowCoord.z -= shadowBias;
1850
+ #else
1851
+ shadowCoord.z += shadowBias;
1852
+ #endif
1853
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1854
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1855
+ if ( frustumTest ) {
1856
+ float depth = texture2D( shadowMap, shadowCoord.xy ).r;
1857
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1858
+ shadow = step( depth, shadowCoord.z );
1859
+ #else
1860
+ shadow = step( shadowCoord.z, depth );
1861
+ #endif
1862
+ }
1863
+ return mix( 1.0, shadow, shadowIntensity );
1864
+ }
1865
+ #endif
1866
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1867
+ #if defined( SHADOWMAP_TYPE_PCF )
1868
+ float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1869
+ float shadow = 1.0;
1870
+ vec3 lightToPosition = shadowCoord.xyz;
1871
+ vec3 bd3D = normalize( lightToPosition );
1872
+ vec3 absVec = abs( lightToPosition );
1873
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
1874
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
1875
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1876
+ float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1877
+ dp -= shadowBias;
1878
+ #else
1879
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1880
+ dp += shadowBias;
1881
+ #endif
1882
+ float texelSize = shadowRadius / shadowMapSize.x;
1883
+ vec3 absDir = abs( bd3D );
1884
+ vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
1885
+ tangent = normalize( cross( bd3D, tangent ) );
1886
+ vec3 bitangent = cross( bd3D, tangent );
1887
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
1888
+ vec2 sample0 = vogelDiskSample( 0, 5, phi );
1889
+ vec2 sample1 = vogelDiskSample( 1, 5, phi );
1890
+ vec2 sample2 = vogelDiskSample( 2, 5, phi );
1891
+ vec2 sample3 = vogelDiskSample( 3, 5, phi );
1892
+ vec2 sample4 = vogelDiskSample( 4, 5, phi );
1893
+ shadow = (
1894
+ texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
1895
+ texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
1896
+ texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
1897
+ texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
1898
+ texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
1899
+ ) * 0.2;
1900
+ }
1901
+ return mix( 1.0, shadow, shadowIntensity );
1902
+ }
1903
+ #elif defined( SHADOWMAP_TYPE_BASIC )
1904
+ float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1905
+ float shadow = 1.0;
1906
+ vec3 lightToPosition = shadowCoord.xyz;
1907
+ vec3 absVec = abs( lightToPosition );
1908
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
1909
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
1910
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1911
+ dp += shadowBias;
1912
+ vec3 bd3D = normalize( lightToPosition );
1913
+ float depth = textureCube( shadowMap, bd3D ).r;
1914
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1915
+ depth = 1.0 - depth;
1916
+ #endif
1917
+ shadow = step( dp, depth );
1918
+ }
1919
+ return mix( 1.0, shadow, shadowIntensity );
1920
+ }
1921
+ #endif
1922
+ #endif
1923
+ #endif`,Ru=`#if NUM_SPOT_LIGHT_COORDS > 0
1924
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1925
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1926
+ #endif
1927
+ #ifdef USE_SHADOWMAP
1928
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1929
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1930
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1931
+ struct DirectionalLightShadow {
1932
+ float shadowIntensity;
1933
+ float shadowBias;
1934
+ float shadowNormalBias;
1935
+ float shadowRadius;
1936
+ vec2 shadowMapSize;
1937
+ };
1938
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1939
+ #endif
1940
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1941
+ struct SpotLightShadow {
1942
+ float shadowIntensity;
1943
+ float shadowBias;
1944
+ float shadowNormalBias;
1945
+ float shadowRadius;
1946
+ vec2 shadowMapSize;
1947
+ };
1948
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1949
+ #endif
1950
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1951
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1952
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1953
+ struct PointLightShadow {
1954
+ float shadowIntensity;
1955
+ float shadowBias;
1956
+ float shadowNormalBias;
1957
+ float shadowRadius;
1958
+ vec2 shadowMapSize;
1959
+ float shadowCameraNear;
1960
+ float shadowCameraFar;
1961
+ };
1962
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1963
+ #endif
1964
+ #endif`,wu=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1965
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1966
+ vec4 shadowWorldPosition;
1967
+ #endif
1968
+ #if defined( USE_SHADOWMAP )
1969
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1970
+ #pragma unroll_loop_start
1971
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1972
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1973
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1974
+ }
1975
+ #pragma unroll_loop_end
1976
+ #endif
1977
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1978
+ #pragma unroll_loop_start
1979
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1980
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1981
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1982
+ }
1983
+ #pragma unroll_loop_end
1984
+ #endif
1985
+ #endif
1986
+ #if NUM_SPOT_LIGHT_COORDS > 0
1987
+ #pragma unroll_loop_start
1988
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1989
+ shadowWorldPosition = worldPosition;
1990
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1991
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1992
+ #endif
1993
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1994
+ }
1995
+ #pragma unroll_loop_end
1996
+ #endif`,Cu=`float getShadowMask() {
1997
+ float shadow = 1.0;
1998
+ #ifdef USE_SHADOWMAP
1999
+ #if NUM_DIR_LIGHT_SHADOWS > 0
2000
+ DirectionalLightShadow directionalLight;
2001
+ #pragma unroll_loop_start
2002
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
2003
+ directionalLight = directionalLightShadows[ i ];
2004
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
2005
+ }
2006
+ #pragma unroll_loop_end
2007
+ #endif
2008
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
2009
+ SpotLightShadow spotLight;
2010
+ #pragma unroll_loop_start
2011
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
2012
+ spotLight = spotLightShadows[ i ];
2013
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
2014
+ }
2015
+ #pragma unroll_loop_end
2016
+ #endif
2017
+ #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
2018
+ PointLightShadow pointLight;
2019
+ #pragma unroll_loop_start
2020
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
2021
+ pointLight = pointLightShadows[ i ];
2022
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
2023
+ }
2024
+ #pragma unroll_loop_end
2025
+ #endif
2026
+ #endif
2027
+ return shadow;
2028
+ }`,Pu=`#ifdef USE_SKINNING
2029
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
2030
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
2031
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2032
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
2033
+ #endif`,Du=`#ifdef USE_SKINNING
2034
+ uniform mat4 bindMatrix;
2035
+ uniform mat4 bindMatrixInverse;
2036
+ uniform highp sampler2D boneTexture;
2037
+ mat4 getBoneMatrix( const in float i ) {
2038
+ int size = textureSize( boneTexture, 0 ).x;
2039
+ int j = int( i ) * 4;
2040
+ int x = j % size;
2041
+ int y = j / size;
2042
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2043
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2044
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2045
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2046
+ return mat4( v1, v2, v3, v4 );
2047
+ }
2048
+ #endif`,Lu=`#ifdef USE_SKINNING
2049
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2050
+ vec4 skinned = vec4( 0.0 );
2051
+ skinned += boneMatX * skinVertex * skinWeight.x;
2052
+ skinned += boneMatY * skinVertex * skinWeight.y;
2053
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2054
+ skinned += boneMatW * skinVertex * skinWeight.w;
2055
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2056
+ #endif`,Iu=`#ifdef USE_SKINNING
2057
+ mat4 skinMatrix = mat4( 0.0 );
2058
+ skinMatrix += skinWeight.x * boneMatX;
2059
+ skinMatrix += skinWeight.y * boneMatY;
2060
+ skinMatrix += skinWeight.z * boneMatZ;
2061
+ skinMatrix += skinWeight.w * boneMatW;
2062
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2063
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2064
+ #ifdef USE_TANGENT
2065
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2066
+ #endif
2067
+ #endif`,Uu=`float specularStrength;
2068
+ #ifdef USE_SPECULARMAP
2069
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2070
+ specularStrength = texelSpecular.r;
2071
+ #else
2072
+ specularStrength = 1.0;
2073
+ #endif`,Nu=`#ifdef USE_SPECULARMAP
2074
+ uniform sampler2D specularMap;
2075
+ #endif`,Fu=`#if defined( TONE_MAPPING )
2076
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2077
+ #endif`,Ou=`#ifndef saturate
2078
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2079
+ #endif
2080
+ uniform float toneMappingExposure;
2081
+ vec3 LinearToneMapping( vec3 color ) {
2082
+ return saturate( toneMappingExposure * color );
2083
+ }
2084
+ vec3 ReinhardToneMapping( vec3 color ) {
2085
+ color *= toneMappingExposure;
2086
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2087
+ }
2088
+ vec3 CineonToneMapping( vec3 color ) {
2089
+ color *= toneMappingExposure;
2090
+ color = max( vec3( 0.0 ), color - 0.004 );
2091
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2092
+ }
2093
+ vec3 RRTAndODTFit( vec3 v ) {
2094
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2095
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2096
+ return a / b;
2097
+ }
2098
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2099
+ const mat3 ACESInputMat = mat3(
2100
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2101
+ vec3( 0.04823, 0.01566, 0.83777 )
2102
+ );
2103
+ const mat3 ACESOutputMat = mat3(
2104
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2105
+ vec3( -0.07367, -0.00605, 1.07602 )
2106
+ );
2107
+ color *= toneMappingExposure / 0.6;
2108
+ color = ACESInputMat * color;
2109
+ color = RRTAndODTFit( color );
2110
+ color = ACESOutputMat * color;
2111
+ return saturate( color );
2112
+ }
2113
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2114
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2115
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2116
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2117
+ );
2118
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2119
+ vec3( 0.6274, 0.0691, 0.0164 ),
2120
+ vec3( 0.3293, 0.9195, 0.0880 ),
2121
+ vec3( 0.0433, 0.0113, 0.8956 )
2122
+ );
2123
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2124
+ vec3 x2 = x * x;
2125
+ vec3 x4 = x2 * x2;
2126
+ return + 15.5 * x4 * x2
2127
+ - 40.14 * x4 * x
2128
+ + 31.96 * x4
2129
+ - 6.868 * x2 * x
2130
+ + 0.4298 * x2
2131
+ + 0.1191 * x
2132
+ - 0.00232;
2133
+ }
2134
+ vec3 AgXToneMapping( vec3 color ) {
2135
+ const mat3 AgXInsetMatrix = mat3(
2136
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2137
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2138
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2139
+ );
2140
+ const mat3 AgXOutsetMatrix = mat3(
2141
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2142
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2143
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2144
+ );
2145
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2146
+ color *= toneMappingExposure;
2147
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2148
+ color = AgXInsetMatrix * color;
2149
+ color = max( color, 1e-10 ); color = log2( color );
2150
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2151
+ color = clamp( color, 0.0, 1.0 );
2152
+ color = agxDefaultContrastApprox( color );
2153
+ color = AgXOutsetMatrix * color;
2154
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2155
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2156
+ color = clamp( color, 0.0, 1.0 );
2157
+ return color;
2158
+ }
2159
+ vec3 NeutralToneMapping( vec3 color ) {
2160
+ const float StartCompression = 0.8 - 0.04;
2161
+ const float Desaturation = 0.15;
2162
+ color *= toneMappingExposure;
2163
+ float x = min( color.r, min( color.g, color.b ) );
2164
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2165
+ color -= offset;
2166
+ float peak = max( color.r, max( color.g, color.b ) );
2167
+ if ( peak < StartCompression ) return color;
2168
+ float d = 1. - StartCompression;
2169
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2170
+ color *= newPeak / peak;
2171
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2172
+ return mix( color, vec3( newPeak ), g );
2173
+ }
2174
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Bu=`#ifdef USE_TRANSMISSION
2175
+ material.transmission = transmission;
2176
+ material.transmissionAlpha = 1.0;
2177
+ material.thickness = thickness;
2178
+ material.attenuationDistance = attenuationDistance;
2179
+ material.attenuationColor = attenuationColor;
2180
+ #ifdef USE_TRANSMISSIONMAP
2181
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2182
+ #endif
2183
+ #ifdef USE_THICKNESSMAP
2184
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2185
+ #endif
2186
+ vec3 pos = vWorldPosition;
2187
+ vec3 v = normalize( cameraPosition - pos );
2188
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2189
+ vec4 transmitted = getIBLVolumeRefraction(
2190
+ n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
2191
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2192
+ material.attenuationColor, material.attenuationDistance );
2193
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2194
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2195
+ #endif`,zu=`#ifdef USE_TRANSMISSION
2196
+ uniform float transmission;
2197
+ uniform float thickness;
2198
+ uniform float attenuationDistance;
2199
+ uniform vec3 attenuationColor;
2200
+ #ifdef USE_TRANSMISSIONMAP
2201
+ uniform sampler2D transmissionMap;
2202
+ #endif
2203
+ #ifdef USE_THICKNESSMAP
2204
+ uniform sampler2D thicknessMap;
2205
+ #endif
2206
+ uniform vec2 transmissionSamplerSize;
2207
+ uniform sampler2D transmissionSamplerMap;
2208
+ uniform mat4 modelMatrix;
2209
+ uniform mat4 projectionMatrix;
2210
+ varying vec3 vWorldPosition;
2211
+ float w0( float a ) {
2212
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2213
+ }
2214
+ float w1( float a ) {
2215
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2216
+ }
2217
+ float w2( float a ){
2218
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2219
+ }
2220
+ float w3( float a ) {
2221
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2222
+ }
2223
+ float g0( float a ) {
2224
+ return w0( a ) + w1( a );
2225
+ }
2226
+ float g1( float a ) {
2227
+ return w2( a ) + w3( a );
2228
+ }
2229
+ float h0( float a ) {
2230
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2231
+ }
2232
+ float h1( float a ) {
2233
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2234
+ }
2235
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2236
+ uv = uv * texelSize.zw + 0.5;
2237
+ vec2 iuv = floor( uv );
2238
+ vec2 fuv = fract( uv );
2239
+ float g0x = g0( fuv.x );
2240
+ float g1x = g1( fuv.x );
2241
+ float h0x = h0( fuv.x );
2242
+ float h1x = h1( fuv.x );
2243
+ float h0y = h0( fuv.y );
2244
+ float h1y = h1( fuv.y );
2245
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2246
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2247
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2248
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2249
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2250
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2251
+ }
2252
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2253
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2254
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2255
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2256
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2257
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2258
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2259
+ return mix( fSample, cSample, fract( lod ) );
2260
+ }
2261
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2262
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2263
+ vec3 modelScale;
2264
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2265
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2266
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2267
+ return normalize( refractionVector ) * thickness * modelScale;
2268
+ }
2269
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2270
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2271
+ }
2272
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2273
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2274
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2275
+ }
2276
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2277
+ if ( isinf( attenuationDistance ) ) {
2278
+ return vec3( 1.0 );
2279
+ } else {
2280
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2281
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2282
+ }
2283
+ }
2284
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2285
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2286
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2287
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2288
+ vec4 transmittedLight;
2289
+ vec3 transmittance;
2290
+ #ifdef USE_DISPERSION
2291
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2292
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2293
+ for ( int i = 0; i < 3; i ++ ) {
2294
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2295
+ vec3 refractedRayExit = position + transmissionRay;
2296
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2297
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2298
+ refractionCoords += 1.0;
2299
+ refractionCoords /= 2.0;
2300
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2301
+ transmittedLight[ i ] = transmissionSample[ i ];
2302
+ transmittedLight.a += transmissionSample.a;
2303
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2304
+ }
2305
+ transmittedLight.a /= 3.0;
2306
+ #else
2307
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2308
+ vec3 refractedRayExit = position + transmissionRay;
2309
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2310
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2311
+ refractionCoords += 1.0;
2312
+ refractionCoords /= 2.0;
2313
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2314
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2315
+ #endif
2316
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2317
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2318
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2319
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2320
+ }
2321
+ #endif`,Vu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2322
+ varying vec2 vUv;
2323
+ #endif
2324
+ #ifdef USE_MAP
2325
+ varying vec2 vMapUv;
2326
+ #endif
2327
+ #ifdef USE_ALPHAMAP
2328
+ varying vec2 vAlphaMapUv;
2329
+ #endif
2330
+ #ifdef USE_LIGHTMAP
2331
+ varying vec2 vLightMapUv;
2332
+ #endif
2333
+ #ifdef USE_AOMAP
2334
+ varying vec2 vAoMapUv;
2335
+ #endif
2336
+ #ifdef USE_BUMPMAP
2337
+ varying vec2 vBumpMapUv;
2338
+ #endif
2339
+ #ifdef USE_NORMALMAP
2340
+ varying vec2 vNormalMapUv;
2341
+ #endif
2342
+ #ifdef USE_EMISSIVEMAP
2343
+ varying vec2 vEmissiveMapUv;
2344
+ #endif
2345
+ #ifdef USE_METALNESSMAP
2346
+ varying vec2 vMetalnessMapUv;
2347
+ #endif
2348
+ #ifdef USE_ROUGHNESSMAP
2349
+ varying vec2 vRoughnessMapUv;
2350
+ #endif
2351
+ #ifdef USE_ANISOTROPYMAP
2352
+ varying vec2 vAnisotropyMapUv;
2353
+ #endif
2354
+ #ifdef USE_CLEARCOATMAP
2355
+ varying vec2 vClearcoatMapUv;
2356
+ #endif
2357
+ #ifdef USE_CLEARCOAT_NORMALMAP
2358
+ varying vec2 vClearcoatNormalMapUv;
2359
+ #endif
2360
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2361
+ varying vec2 vClearcoatRoughnessMapUv;
2362
+ #endif
2363
+ #ifdef USE_IRIDESCENCEMAP
2364
+ varying vec2 vIridescenceMapUv;
2365
+ #endif
2366
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2367
+ varying vec2 vIridescenceThicknessMapUv;
2368
+ #endif
2369
+ #ifdef USE_SHEEN_COLORMAP
2370
+ varying vec2 vSheenColorMapUv;
2371
+ #endif
2372
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2373
+ varying vec2 vSheenRoughnessMapUv;
2374
+ #endif
2375
+ #ifdef USE_SPECULARMAP
2376
+ varying vec2 vSpecularMapUv;
2377
+ #endif
2378
+ #ifdef USE_SPECULAR_COLORMAP
2379
+ varying vec2 vSpecularColorMapUv;
2380
+ #endif
2381
+ #ifdef USE_SPECULAR_INTENSITYMAP
2382
+ varying vec2 vSpecularIntensityMapUv;
2383
+ #endif
2384
+ #ifdef USE_TRANSMISSIONMAP
2385
+ uniform mat3 transmissionMapTransform;
2386
+ varying vec2 vTransmissionMapUv;
2387
+ #endif
2388
+ #ifdef USE_THICKNESSMAP
2389
+ uniform mat3 thicknessMapTransform;
2390
+ varying vec2 vThicknessMapUv;
2391
+ #endif`,Gu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2392
+ varying vec2 vUv;
2393
+ #endif
2394
+ #ifdef USE_MAP
2395
+ uniform mat3 mapTransform;
2396
+ varying vec2 vMapUv;
2397
+ #endif
2398
+ #ifdef USE_ALPHAMAP
2399
+ uniform mat3 alphaMapTransform;
2400
+ varying vec2 vAlphaMapUv;
2401
+ #endif
2402
+ #ifdef USE_LIGHTMAP
2403
+ uniform mat3 lightMapTransform;
2404
+ varying vec2 vLightMapUv;
2405
+ #endif
2406
+ #ifdef USE_AOMAP
2407
+ uniform mat3 aoMapTransform;
2408
+ varying vec2 vAoMapUv;
2409
+ #endif
2410
+ #ifdef USE_BUMPMAP
2411
+ uniform mat3 bumpMapTransform;
2412
+ varying vec2 vBumpMapUv;
2413
+ #endif
2414
+ #ifdef USE_NORMALMAP
2415
+ uniform mat3 normalMapTransform;
2416
+ varying vec2 vNormalMapUv;
2417
+ #endif
2418
+ #ifdef USE_DISPLACEMENTMAP
2419
+ uniform mat3 displacementMapTransform;
2420
+ varying vec2 vDisplacementMapUv;
2421
+ #endif
2422
+ #ifdef USE_EMISSIVEMAP
2423
+ uniform mat3 emissiveMapTransform;
2424
+ varying vec2 vEmissiveMapUv;
2425
+ #endif
2426
+ #ifdef USE_METALNESSMAP
2427
+ uniform mat3 metalnessMapTransform;
2428
+ varying vec2 vMetalnessMapUv;
2429
+ #endif
2430
+ #ifdef USE_ROUGHNESSMAP
2431
+ uniform mat3 roughnessMapTransform;
2432
+ varying vec2 vRoughnessMapUv;
2433
+ #endif
2434
+ #ifdef USE_ANISOTROPYMAP
2435
+ uniform mat3 anisotropyMapTransform;
2436
+ varying vec2 vAnisotropyMapUv;
2437
+ #endif
2438
+ #ifdef USE_CLEARCOATMAP
2439
+ uniform mat3 clearcoatMapTransform;
2440
+ varying vec2 vClearcoatMapUv;
2441
+ #endif
2442
+ #ifdef USE_CLEARCOAT_NORMALMAP
2443
+ uniform mat3 clearcoatNormalMapTransform;
2444
+ varying vec2 vClearcoatNormalMapUv;
2445
+ #endif
2446
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2447
+ uniform mat3 clearcoatRoughnessMapTransform;
2448
+ varying vec2 vClearcoatRoughnessMapUv;
2449
+ #endif
2450
+ #ifdef USE_SHEEN_COLORMAP
2451
+ uniform mat3 sheenColorMapTransform;
2452
+ varying vec2 vSheenColorMapUv;
2453
+ #endif
2454
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2455
+ uniform mat3 sheenRoughnessMapTransform;
2456
+ varying vec2 vSheenRoughnessMapUv;
2457
+ #endif
2458
+ #ifdef USE_IRIDESCENCEMAP
2459
+ uniform mat3 iridescenceMapTransform;
2460
+ varying vec2 vIridescenceMapUv;
2461
+ #endif
2462
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2463
+ uniform mat3 iridescenceThicknessMapTransform;
2464
+ varying vec2 vIridescenceThicknessMapUv;
2465
+ #endif
2466
+ #ifdef USE_SPECULARMAP
2467
+ uniform mat3 specularMapTransform;
2468
+ varying vec2 vSpecularMapUv;
2469
+ #endif
2470
+ #ifdef USE_SPECULAR_COLORMAP
2471
+ uniform mat3 specularColorMapTransform;
2472
+ varying vec2 vSpecularColorMapUv;
2473
+ #endif
2474
+ #ifdef USE_SPECULAR_INTENSITYMAP
2475
+ uniform mat3 specularIntensityMapTransform;
2476
+ varying vec2 vSpecularIntensityMapUv;
2477
+ #endif
2478
+ #ifdef USE_TRANSMISSIONMAP
2479
+ uniform mat3 transmissionMapTransform;
2480
+ varying vec2 vTransmissionMapUv;
2481
+ #endif
2482
+ #ifdef USE_THICKNESSMAP
2483
+ uniform mat3 thicknessMapTransform;
2484
+ varying vec2 vThicknessMapUv;
2485
+ #endif`,Hu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2486
+ vUv = vec3( uv, 1 ).xy;
2487
+ #endif
2488
+ #ifdef USE_MAP
2489
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2490
+ #endif
2491
+ #ifdef USE_ALPHAMAP
2492
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2493
+ #endif
2494
+ #ifdef USE_LIGHTMAP
2495
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2496
+ #endif
2497
+ #ifdef USE_AOMAP
2498
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2499
+ #endif
2500
+ #ifdef USE_BUMPMAP
2501
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2502
+ #endif
2503
+ #ifdef USE_NORMALMAP
2504
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2505
+ #endif
2506
+ #ifdef USE_DISPLACEMENTMAP
2507
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2508
+ #endif
2509
+ #ifdef USE_EMISSIVEMAP
2510
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2511
+ #endif
2512
+ #ifdef USE_METALNESSMAP
2513
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2514
+ #endif
2515
+ #ifdef USE_ROUGHNESSMAP
2516
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2517
+ #endif
2518
+ #ifdef USE_ANISOTROPYMAP
2519
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2520
+ #endif
2521
+ #ifdef USE_CLEARCOATMAP
2522
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2523
+ #endif
2524
+ #ifdef USE_CLEARCOAT_NORMALMAP
2525
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2526
+ #endif
2527
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2528
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2529
+ #endif
2530
+ #ifdef USE_IRIDESCENCEMAP
2531
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2532
+ #endif
2533
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2534
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2535
+ #endif
2536
+ #ifdef USE_SHEEN_COLORMAP
2537
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2538
+ #endif
2539
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2540
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2541
+ #endif
2542
+ #ifdef USE_SPECULARMAP
2543
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2544
+ #endif
2545
+ #ifdef USE_SPECULAR_COLORMAP
2546
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2547
+ #endif
2548
+ #ifdef USE_SPECULAR_INTENSITYMAP
2549
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2550
+ #endif
2551
+ #ifdef USE_TRANSMISSIONMAP
2552
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2553
+ #endif
2554
+ #ifdef USE_THICKNESSMAP
2555
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2556
+ #endif`,ku=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2557
+ vec4 worldPosition = vec4( transformed, 1.0 );
2558
+ #ifdef USE_BATCHING
2559
+ worldPosition = batchingMatrix * worldPosition;
2560
+ #endif
2561
+ #ifdef USE_INSTANCING
2562
+ worldPosition = instanceMatrix * worldPosition;
2563
+ #endif
2564
+ worldPosition = modelMatrix * worldPosition;
2565
+ #endif`;const Wu=`varying vec2 vUv;
2566
+ uniform mat3 uvTransform;
2567
+ void main() {
2568
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2569
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2570
+ }`,Xu=`uniform sampler2D t2D;
2571
+ uniform float backgroundIntensity;
2572
+ varying vec2 vUv;
2573
+ void main() {
2574
+ vec4 texColor = texture2D( t2D, vUv );
2575
+ #ifdef DECODE_VIDEO_TEXTURE
2576
+ 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 );
2577
+ #endif
2578
+ texColor.rgb *= backgroundIntensity;
2579
+ gl_FragColor = texColor;
2580
+ #include <tonemapping_fragment>
2581
+ #include <colorspace_fragment>
2582
+ }`,qu=`varying vec3 vWorldDirection;
2583
+ #include <common>
2584
+ void main() {
2585
+ vWorldDirection = transformDirection( position, modelMatrix );
2586
+ #include <begin_vertex>
2587
+ #include <project_vertex>
2588
+ gl_Position.z = gl_Position.w;
2589
+ }`,Yu=`#ifdef ENVMAP_TYPE_CUBE
2590
+ uniform samplerCube envMap;
2591
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2592
+ uniform sampler2D envMap;
2593
+ #endif
2594
+ uniform float flipEnvMap;
2595
+ uniform float backgroundBlurriness;
2596
+ uniform float backgroundIntensity;
2597
+ uniform mat3 backgroundRotation;
2598
+ varying vec3 vWorldDirection;
2599
+ #include <cube_uv_reflection_fragment>
2600
+ void main() {
2601
+ #ifdef ENVMAP_TYPE_CUBE
2602
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2603
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2604
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2605
+ #else
2606
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2607
+ #endif
2608
+ texColor.rgb *= backgroundIntensity;
2609
+ gl_FragColor = texColor;
2610
+ #include <tonemapping_fragment>
2611
+ #include <colorspace_fragment>
2612
+ }`,Ku=`varying vec3 vWorldDirection;
2613
+ #include <common>
2614
+ void main() {
2615
+ vWorldDirection = transformDirection( position, modelMatrix );
2616
+ #include <begin_vertex>
2617
+ #include <project_vertex>
2618
+ gl_Position.z = gl_Position.w;
2619
+ }`,Zu=`uniform samplerCube tCube;
2620
+ uniform float tFlip;
2621
+ uniform float opacity;
2622
+ varying vec3 vWorldDirection;
2623
+ void main() {
2624
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2625
+ gl_FragColor = texColor;
2626
+ gl_FragColor.a *= opacity;
2627
+ #include <tonemapping_fragment>
2628
+ #include <colorspace_fragment>
2629
+ }`,$u=`#include <common>
2630
+ #include <batching_pars_vertex>
2631
+ #include <uv_pars_vertex>
2632
+ #include <displacementmap_pars_vertex>
2633
+ #include <morphtarget_pars_vertex>
2634
+ #include <skinning_pars_vertex>
2635
+ #include <logdepthbuf_pars_vertex>
2636
+ #include <clipping_planes_pars_vertex>
2637
+ varying vec2 vHighPrecisionZW;
2638
+ void main() {
2639
+ #include <uv_vertex>
2640
+ #include <batching_vertex>
2641
+ #include <skinbase_vertex>
2642
+ #include <morphinstance_vertex>
2643
+ #ifdef USE_DISPLACEMENTMAP
2644
+ #include <beginnormal_vertex>
2645
+ #include <morphnormal_vertex>
2646
+ #include <skinnormal_vertex>
2647
+ #endif
2648
+ #include <begin_vertex>
2649
+ #include <morphtarget_vertex>
2650
+ #include <skinning_vertex>
2651
+ #include <displacementmap_vertex>
2652
+ #include <project_vertex>
2653
+ #include <logdepthbuf_vertex>
2654
+ #include <clipping_planes_vertex>
2655
+ vHighPrecisionZW = gl_Position.zw;
2656
+ }`,ju=`#if DEPTH_PACKING == 3200
2657
+ uniform float opacity;
2658
+ #endif
2659
+ #include <common>
2660
+ #include <packing>
2661
+ #include <uv_pars_fragment>
2662
+ #include <map_pars_fragment>
2663
+ #include <alphamap_pars_fragment>
2664
+ #include <alphatest_pars_fragment>
2665
+ #include <alphahash_pars_fragment>
2666
+ #include <logdepthbuf_pars_fragment>
2667
+ #include <clipping_planes_pars_fragment>
2668
+ varying vec2 vHighPrecisionZW;
2669
+ void main() {
2670
+ vec4 diffuseColor = vec4( 1.0 );
2671
+ #include <clipping_planes_fragment>
2672
+ #if DEPTH_PACKING == 3200
2673
+ diffuseColor.a = opacity;
2674
+ #endif
2675
+ #include <map_fragment>
2676
+ #include <alphamap_fragment>
2677
+ #include <alphatest_fragment>
2678
+ #include <alphahash_fragment>
2679
+ #include <logdepthbuf_fragment>
2680
+ #ifdef USE_REVERSED_DEPTH_BUFFER
2681
+ float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
2682
+ #else
2683
+ float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
2684
+ #endif
2685
+ #if DEPTH_PACKING == 3200
2686
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2687
+ #elif DEPTH_PACKING == 3201
2688
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2689
+ #elif DEPTH_PACKING == 3202
2690
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2691
+ #elif DEPTH_PACKING == 3203
2692
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2693
+ #endif
2694
+ }`,Ju=`#define DISTANCE
2695
+ varying vec3 vWorldPosition;
2696
+ #include <common>
2697
+ #include <batching_pars_vertex>
2698
+ #include <uv_pars_vertex>
2699
+ #include <displacementmap_pars_vertex>
2700
+ #include <morphtarget_pars_vertex>
2701
+ #include <skinning_pars_vertex>
2702
+ #include <clipping_planes_pars_vertex>
2703
+ void main() {
2704
+ #include <uv_vertex>
2705
+ #include <batching_vertex>
2706
+ #include <skinbase_vertex>
2707
+ #include <morphinstance_vertex>
2708
+ #ifdef USE_DISPLACEMENTMAP
2709
+ #include <beginnormal_vertex>
2710
+ #include <morphnormal_vertex>
2711
+ #include <skinnormal_vertex>
2712
+ #endif
2713
+ #include <begin_vertex>
2714
+ #include <morphtarget_vertex>
2715
+ #include <skinning_vertex>
2716
+ #include <displacementmap_vertex>
2717
+ #include <project_vertex>
2718
+ #include <worldpos_vertex>
2719
+ #include <clipping_planes_vertex>
2720
+ vWorldPosition = worldPosition.xyz;
2721
+ }`,Qu=`#define DISTANCE
2722
+ uniform vec3 referencePosition;
2723
+ uniform float nearDistance;
2724
+ uniform float farDistance;
2725
+ varying vec3 vWorldPosition;
2726
+ #include <common>
2727
+ #include <uv_pars_fragment>
2728
+ #include <map_pars_fragment>
2729
+ #include <alphamap_pars_fragment>
2730
+ #include <alphatest_pars_fragment>
2731
+ #include <alphahash_pars_fragment>
2732
+ #include <clipping_planes_pars_fragment>
2733
+ void main () {
2734
+ vec4 diffuseColor = vec4( 1.0 );
2735
+ #include <clipping_planes_fragment>
2736
+ #include <map_fragment>
2737
+ #include <alphamap_fragment>
2738
+ #include <alphatest_fragment>
2739
+ #include <alphahash_fragment>
2740
+ float dist = length( vWorldPosition - referencePosition );
2741
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2742
+ dist = saturate( dist );
2743
+ gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2744
+ }`,ef=`varying vec3 vWorldDirection;
2745
+ #include <common>
2746
+ void main() {
2747
+ vWorldDirection = transformDirection( position, modelMatrix );
2748
+ #include <begin_vertex>
2749
+ #include <project_vertex>
2750
+ }`,tf=`uniform sampler2D tEquirect;
2751
+ varying vec3 vWorldDirection;
2752
+ #include <common>
2753
+ void main() {
2754
+ vec3 direction = normalize( vWorldDirection );
2755
+ vec2 sampleUV = equirectUv( direction );
2756
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2757
+ #include <tonemapping_fragment>
2758
+ #include <colorspace_fragment>
2759
+ }`,nf=`uniform float scale;
2760
+ attribute float lineDistance;
2761
+ varying float vLineDistance;
2762
+ #include <common>
2763
+ #include <uv_pars_vertex>
2764
+ #include <color_pars_vertex>
2765
+ #include <fog_pars_vertex>
2766
+ #include <morphtarget_pars_vertex>
2767
+ #include <logdepthbuf_pars_vertex>
2768
+ #include <clipping_planes_pars_vertex>
2769
+ void main() {
2770
+ vLineDistance = scale * lineDistance;
2771
+ #include <uv_vertex>
2772
+ #include <color_vertex>
2773
+ #include <morphinstance_vertex>
2774
+ #include <morphcolor_vertex>
2775
+ #include <begin_vertex>
2776
+ #include <morphtarget_vertex>
2777
+ #include <project_vertex>
2778
+ #include <logdepthbuf_vertex>
2779
+ #include <clipping_planes_vertex>
2780
+ #include <fog_vertex>
2781
+ }`,sf=`uniform vec3 diffuse;
2782
+ uniform float opacity;
2783
+ uniform float dashSize;
2784
+ uniform float totalSize;
2785
+ varying float vLineDistance;
2786
+ #include <common>
2787
+ #include <color_pars_fragment>
2788
+ #include <uv_pars_fragment>
2789
+ #include <map_pars_fragment>
2790
+ #include <fog_pars_fragment>
2791
+ #include <logdepthbuf_pars_fragment>
2792
+ #include <clipping_planes_pars_fragment>
2793
+ void main() {
2794
+ vec4 diffuseColor = vec4( diffuse, opacity );
2795
+ #include <clipping_planes_fragment>
2796
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2797
+ discard;
2798
+ }
2799
+ vec3 outgoingLight = vec3( 0.0 );
2800
+ #include <logdepthbuf_fragment>
2801
+ #include <map_fragment>
2802
+ #include <color_fragment>
2803
+ outgoingLight = diffuseColor.rgb;
2804
+ #include <opaque_fragment>
2805
+ #include <tonemapping_fragment>
2806
+ #include <colorspace_fragment>
2807
+ #include <fog_fragment>
2808
+ #include <premultiplied_alpha_fragment>
2809
+ }`,rf=`#include <common>
2810
+ #include <batching_pars_vertex>
2811
+ #include <uv_pars_vertex>
2812
+ #include <envmap_pars_vertex>
2813
+ #include <color_pars_vertex>
2814
+ #include <fog_pars_vertex>
2815
+ #include <morphtarget_pars_vertex>
2816
+ #include <skinning_pars_vertex>
2817
+ #include <logdepthbuf_pars_vertex>
2818
+ #include <clipping_planes_pars_vertex>
2819
+ void main() {
2820
+ #include <uv_vertex>
2821
+ #include <color_vertex>
2822
+ #include <morphinstance_vertex>
2823
+ #include <morphcolor_vertex>
2824
+ #include <batching_vertex>
2825
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2826
+ #include <beginnormal_vertex>
2827
+ #include <morphnormal_vertex>
2828
+ #include <skinbase_vertex>
2829
+ #include <skinnormal_vertex>
2830
+ #include <defaultnormal_vertex>
2831
+ #endif
2832
+ #include <begin_vertex>
2833
+ #include <morphtarget_vertex>
2834
+ #include <skinning_vertex>
2835
+ #include <project_vertex>
2836
+ #include <logdepthbuf_vertex>
2837
+ #include <clipping_planes_vertex>
2838
+ #include <worldpos_vertex>
2839
+ #include <envmap_vertex>
2840
+ #include <fog_vertex>
2841
+ }`,af=`uniform vec3 diffuse;
2842
+ uniform float opacity;
2843
+ #ifndef FLAT_SHADED
2844
+ varying vec3 vNormal;
2845
+ #endif
2846
+ #include <common>
2847
+ #include <dithering_pars_fragment>
2848
+ #include <color_pars_fragment>
2849
+ #include <uv_pars_fragment>
2850
+ #include <map_pars_fragment>
2851
+ #include <alphamap_pars_fragment>
2852
+ #include <alphatest_pars_fragment>
2853
+ #include <alphahash_pars_fragment>
2854
+ #include <aomap_pars_fragment>
2855
+ #include <lightmap_pars_fragment>
2856
+ #include <envmap_common_pars_fragment>
2857
+ #include <envmap_pars_fragment>
2858
+ #include <fog_pars_fragment>
2859
+ #include <specularmap_pars_fragment>
2860
+ #include <logdepthbuf_pars_fragment>
2861
+ #include <clipping_planes_pars_fragment>
2862
+ void main() {
2863
+ vec4 diffuseColor = vec4( diffuse, opacity );
2864
+ #include <clipping_planes_fragment>
2865
+ #include <logdepthbuf_fragment>
2866
+ #include <map_fragment>
2867
+ #include <color_fragment>
2868
+ #include <alphamap_fragment>
2869
+ #include <alphatest_fragment>
2870
+ #include <alphahash_fragment>
2871
+ #include <specularmap_fragment>
2872
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2873
+ #ifdef USE_LIGHTMAP
2874
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2875
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2876
+ #else
2877
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2878
+ #endif
2879
+ #include <aomap_fragment>
2880
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2881
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2882
+ #include <envmap_fragment>
2883
+ #include <opaque_fragment>
2884
+ #include <tonemapping_fragment>
2885
+ #include <colorspace_fragment>
2886
+ #include <fog_fragment>
2887
+ #include <premultiplied_alpha_fragment>
2888
+ #include <dithering_fragment>
2889
+ }`,of=`#define LAMBERT
2890
+ varying vec3 vViewPosition;
2891
+ #include <common>
2892
+ #include <batching_pars_vertex>
2893
+ #include <uv_pars_vertex>
2894
+ #include <displacementmap_pars_vertex>
2895
+ #include <envmap_pars_vertex>
2896
+ #include <color_pars_vertex>
2897
+ #include <fog_pars_vertex>
2898
+ #include <normal_pars_vertex>
2899
+ #include <morphtarget_pars_vertex>
2900
+ #include <skinning_pars_vertex>
2901
+ #include <shadowmap_pars_vertex>
2902
+ #include <logdepthbuf_pars_vertex>
2903
+ #include <clipping_planes_pars_vertex>
2904
+ void main() {
2905
+ #include <uv_vertex>
2906
+ #include <color_vertex>
2907
+ #include <morphinstance_vertex>
2908
+ #include <morphcolor_vertex>
2909
+ #include <batching_vertex>
2910
+ #include <beginnormal_vertex>
2911
+ #include <morphnormal_vertex>
2912
+ #include <skinbase_vertex>
2913
+ #include <skinnormal_vertex>
2914
+ #include <defaultnormal_vertex>
2915
+ #include <normal_vertex>
2916
+ #include <begin_vertex>
2917
+ #include <morphtarget_vertex>
2918
+ #include <skinning_vertex>
2919
+ #include <displacementmap_vertex>
2920
+ #include <project_vertex>
2921
+ #include <logdepthbuf_vertex>
2922
+ #include <clipping_planes_vertex>
2923
+ vViewPosition = - mvPosition.xyz;
2924
+ #include <worldpos_vertex>
2925
+ #include <envmap_vertex>
2926
+ #include <shadowmap_vertex>
2927
+ #include <fog_vertex>
2928
+ }`,lf=`#define LAMBERT
2929
+ uniform vec3 diffuse;
2930
+ uniform vec3 emissive;
2931
+ uniform float opacity;
2932
+ #include <common>
2933
+ #include <dithering_pars_fragment>
2934
+ #include <color_pars_fragment>
2935
+ #include <uv_pars_fragment>
2936
+ #include <map_pars_fragment>
2937
+ #include <alphamap_pars_fragment>
2938
+ #include <alphatest_pars_fragment>
2939
+ #include <alphahash_pars_fragment>
2940
+ #include <aomap_pars_fragment>
2941
+ #include <lightmap_pars_fragment>
2942
+ #include <emissivemap_pars_fragment>
2943
+ #include <cube_uv_reflection_fragment>
2944
+ #include <envmap_common_pars_fragment>
2945
+ #include <envmap_pars_fragment>
2946
+ #include <envmap_physical_pars_fragment>
2947
+ #include <fog_pars_fragment>
2948
+ #include <bsdfs>
2949
+ #include <lights_pars_begin>
2950
+ #include <normal_pars_fragment>
2951
+ #include <lights_lambert_pars_fragment>
2952
+ #include <shadowmap_pars_fragment>
2953
+ #include <bumpmap_pars_fragment>
2954
+ #include <normalmap_pars_fragment>
2955
+ #include <specularmap_pars_fragment>
2956
+ #include <logdepthbuf_pars_fragment>
2957
+ #include <clipping_planes_pars_fragment>
2958
+ void main() {
2959
+ vec4 diffuseColor = vec4( diffuse, opacity );
2960
+ #include <clipping_planes_fragment>
2961
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2962
+ vec3 totalEmissiveRadiance = emissive;
2963
+ #include <logdepthbuf_fragment>
2964
+ #include <map_fragment>
2965
+ #include <color_fragment>
2966
+ #include <alphamap_fragment>
2967
+ #include <alphatest_fragment>
2968
+ #include <alphahash_fragment>
2969
+ #include <specularmap_fragment>
2970
+ #include <normal_fragment_begin>
2971
+ #include <normal_fragment_maps>
2972
+ #include <emissivemap_fragment>
2973
+ #include <lights_lambert_fragment>
2974
+ #include <lights_fragment_begin>
2975
+ #include <lights_fragment_maps>
2976
+ #include <lights_fragment_end>
2977
+ #include <aomap_fragment>
2978
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2979
+ #include <envmap_fragment>
2980
+ #include <opaque_fragment>
2981
+ #include <tonemapping_fragment>
2982
+ #include <colorspace_fragment>
2983
+ #include <fog_fragment>
2984
+ #include <premultiplied_alpha_fragment>
2985
+ #include <dithering_fragment>
2986
+ }`,cf=`#define MATCAP
2987
+ varying vec3 vViewPosition;
2988
+ #include <common>
2989
+ #include <batching_pars_vertex>
2990
+ #include <uv_pars_vertex>
2991
+ #include <color_pars_vertex>
2992
+ #include <displacementmap_pars_vertex>
2993
+ #include <fog_pars_vertex>
2994
+ #include <normal_pars_vertex>
2995
+ #include <morphtarget_pars_vertex>
2996
+ #include <skinning_pars_vertex>
2997
+ #include <logdepthbuf_pars_vertex>
2998
+ #include <clipping_planes_pars_vertex>
2999
+ void main() {
3000
+ #include <uv_vertex>
3001
+ #include <color_vertex>
3002
+ #include <morphinstance_vertex>
3003
+ #include <morphcolor_vertex>
3004
+ #include <batching_vertex>
3005
+ #include <beginnormal_vertex>
3006
+ #include <morphnormal_vertex>
3007
+ #include <skinbase_vertex>
3008
+ #include <skinnormal_vertex>
3009
+ #include <defaultnormal_vertex>
3010
+ #include <normal_vertex>
3011
+ #include <begin_vertex>
3012
+ #include <morphtarget_vertex>
3013
+ #include <skinning_vertex>
3014
+ #include <displacementmap_vertex>
3015
+ #include <project_vertex>
3016
+ #include <logdepthbuf_vertex>
3017
+ #include <clipping_planes_vertex>
3018
+ #include <fog_vertex>
3019
+ vViewPosition = - mvPosition.xyz;
3020
+ }`,hf=`#define MATCAP
3021
+ uniform vec3 diffuse;
3022
+ uniform float opacity;
3023
+ uniform sampler2D matcap;
3024
+ varying vec3 vViewPosition;
3025
+ #include <common>
3026
+ #include <dithering_pars_fragment>
3027
+ #include <color_pars_fragment>
3028
+ #include <uv_pars_fragment>
3029
+ #include <map_pars_fragment>
3030
+ #include <alphamap_pars_fragment>
3031
+ #include <alphatest_pars_fragment>
3032
+ #include <alphahash_pars_fragment>
3033
+ #include <fog_pars_fragment>
3034
+ #include <normal_pars_fragment>
3035
+ #include <bumpmap_pars_fragment>
3036
+ #include <normalmap_pars_fragment>
3037
+ #include <logdepthbuf_pars_fragment>
3038
+ #include <clipping_planes_pars_fragment>
3039
+ void main() {
3040
+ vec4 diffuseColor = vec4( diffuse, opacity );
3041
+ #include <clipping_planes_fragment>
3042
+ #include <logdepthbuf_fragment>
3043
+ #include <map_fragment>
3044
+ #include <color_fragment>
3045
+ #include <alphamap_fragment>
3046
+ #include <alphatest_fragment>
3047
+ #include <alphahash_fragment>
3048
+ #include <normal_fragment_begin>
3049
+ #include <normal_fragment_maps>
3050
+ vec3 viewDir = normalize( vViewPosition );
3051
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3052
+ vec3 y = cross( viewDir, x );
3053
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3054
+ #ifdef USE_MATCAP
3055
+ vec4 matcapColor = texture2D( matcap, uv );
3056
+ #else
3057
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3058
+ #endif
3059
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3060
+ #include <opaque_fragment>
3061
+ #include <tonemapping_fragment>
3062
+ #include <colorspace_fragment>
3063
+ #include <fog_fragment>
3064
+ #include <premultiplied_alpha_fragment>
3065
+ #include <dithering_fragment>
3066
+ }`,uf=`#define NORMAL
3067
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3068
+ varying vec3 vViewPosition;
3069
+ #endif
3070
+ #include <common>
3071
+ #include <batching_pars_vertex>
3072
+ #include <uv_pars_vertex>
3073
+ #include <displacementmap_pars_vertex>
3074
+ #include <normal_pars_vertex>
3075
+ #include <morphtarget_pars_vertex>
3076
+ #include <skinning_pars_vertex>
3077
+ #include <logdepthbuf_pars_vertex>
3078
+ #include <clipping_planes_pars_vertex>
3079
+ void main() {
3080
+ #include <uv_vertex>
3081
+ #include <batching_vertex>
3082
+ #include <beginnormal_vertex>
3083
+ #include <morphinstance_vertex>
3084
+ #include <morphnormal_vertex>
3085
+ #include <skinbase_vertex>
3086
+ #include <skinnormal_vertex>
3087
+ #include <defaultnormal_vertex>
3088
+ #include <normal_vertex>
3089
+ #include <begin_vertex>
3090
+ #include <morphtarget_vertex>
3091
+ #include <skinning_vertex>
3092
+ #include <displacementmap_vertex>
3093
+ #include <project_vertex>
3094
+ #include <logdepthbuf_vertex>
3095
+ #include <clipping_planes_vertex>
3096
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3097
+ vViewPosition = - mvPosition.xyz;
3098
+ #endif
3099
+ }`,ff=`#define NORMAL
3100
+ uniform float opacity;
3101
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3102
+ varying vec3 vViewPosition;
3103
+ #endif
3104
+ #include <uv_pars_fragment>
3105
+ #include <normal_pars_fragment>
3106
+ #include <bumpmap_pars_fragment>
3107
+ #include <normalmap_pars_fragment>
3108
+ #include <logdepthbuf_pars_fragment>
3109
+ #include <clipping_planes_pars_fragment>
3110
+ void main() {
3111
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3112
+ #include <clipping_planes_fragment>
3113
+ #include <logdepthbuf_fragment>
3114
+ #include <normal_fragment_begin>
3115
+ #include <normal_fragment_maps>
3116
+ gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
3117
+ #ifdef OPAQUE
3118
+ gl_FragColor.a = 1.0;
3119
+ #endif
3120
+ }`,df=`#define PHONG
3121
+ varying vec3 vViewPosition;
3122
+ #include <common>
3123
+ #include <batching_pars_vertex>
3124
+ #include <uv_pars_vertex>
3125
+ #include <displacementmap_pars_vertex>
3126
+ #include <envmap_pars_vertex>
3127
+ #include <color_pars_vertex>
3128
+ #include <fog_pars_vertex>
3129
+ #include <normal_pars_vertex>
3130
+ #include <morphtarget_pars_vertex>
3131
+ #include <skinning_pars_vertex>
3132
+ #include <shadowmap_pars_vertex>
3133
+ #include <logdepthbuf_pars_vertex>
3134
+ #include <clipping_planes_pars_vertex>
3135
+ void main() {
3136
+ #include <uv_vertex>
3137
+ #include <color_vertex>
3138
+ #include <morphcolor_vertex>
3139
+ #include <batching_vertex>
3140
+ #include <beginnormal_vertex>
3141
+ #include <morphinstance_vertex>
3142
+ #include <morphnormal_vertex>
3143
+ #include <skinbase_vertex>
3144
+ #include <skinnormal_vertex>
3145
+ #include <defaultnormal_vertex>
3146
+ #include <normal_vertex>
3147
+ #include <begin_vertex>
3148
+ #include <morphtarget_vertex>
3149
+ #include <skinning_vertex>
3150
+ #include <displacementmap_vertex>
3151
+ #include <project_vertex>
3152
+ #include <logdepthbuf_vertex>
3153
+ #include <clipping_planes_vertex>
3154
+ vViewPosition = - mvPosition.xyz;
3155
+ #include <worldpos_vertex>
3156
+ #include <envmap_vertex>
3157
+ #include <shadowmap_vertex>
3158
+ #include <fog_vertex>
3159
+ }`,pf=`#define PHONG
3160
+ uniform vec3 diffuse;
3161
+ uniform vec3 emissive;
3162
+ uniform vec3 specular;
3163
+ uniform float shininess;
3164
+ uniform float opacity;
3165
+ #include <common>
3166
+ #include <dithering_pars_fragment>
3167
+ #include <color_pars_fragment>
3168
+ #include <uv_pars_fragment>
3169
+ #include <map_pars_fragment>
3170
+ #include <alphamap_pars_fragment>
3171
+ #include <alphatest_pars_fragment>
3172
+ #include <alphahash_pars_fragment>
3173
+ #include <aomap_pars_fragment>
3174
+ #include <lightmap_pars_fragment>
3175
+ #include <emissivemap_pars_fragment>
3176
+ #include <cube_uv_reflection_fragment>
3177
+ #include <envmap_common_pars_fragment>
3178
+ #include <envmap_pars_fragment>
3179
+ #include <envmap_physical_pars_fragment>
3180
+ #include <fog_pars_fragment>
3181
+ #include <bsdfs>
3182
+ #include <lights_pars_begin>
3183
+ #include <normal_pars_fragment>
3184
+ #include <lights_phong_pars_fragment>
3185
+ #include <shadowmap_pars_fragment>
3186
+ #include <bumpmap_pars_fragment>
3187
+ #include <normalmap_pars_fragment>
3188
+ #include <specularmap_pars_fragment>
3189
+ #include <logdepthbuf_pars_fragment>
3190
+ #include <clipping_planes_pars_fragment>
3191
+ void main() {
3192
+ vec4 diffuseColor = vec4( diffuse, opacity );
3193
+ #include <clipping_planes_fragment>
3194
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3195
+ vec3 totalEmissiveRadiance = emissive;
3196
+ #include <logdepthbuf_fragment>
3197
+ #include <map_fragment>
3198
+ #include <color_fragment>
3199
+ #include <alphamap_fragment>
3200
+ #include <alphatest_fragment>
3201
+ #include <alphahash_fragment>
3202
+ #include <specularmap_fragment>
3203
+ #include <normal_fragment_begin>
3204
+ #include <normal_fragment_maps>
3205
+ #include <emissivemap_fragment>
3206
+ #include <lights_phong_fragment>
3207
+ #include <lights_fragment_begin>
3208
+ #include <lights_fragment_maps>
3209
+ #include <lights_fragment_end>
3210
+ #include <aomap_fragment>
3211
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3212
+ #include <envmap_fragment>
3213
+ #include <opaque_fragment>
3214
+ #include <tonemapping_fragment>
3215
+ #include <colorspace_fragment>
3216
+ #include <fog_fragment>
3217
+ #include <premultiplied_alpha_fragment>
3218
+ #include <dithering_fragment>
3219
+ }`,mf=`#define STANDARD
3220
+ varying vec3 vViewPosition;
3221
+ #ifdef USE_TRANSMISSION
3222
+ varying vec3 vWorldPosition;
3223
+ #endif
3224
+ #include <common>
3225
+ #include <batching_pars_vertex>
3226
+ #include <uv_pars_vertex>
3227
+ #include <displacementmap_pars_vertex>
3228
+ #include <color_pars_vertex>
3229
+ #include <fog_pars_vertex>
3230
+ #include <normal_pars_vertex>
3231
+ #include <morphtarget_pars_vertex>
3232
+ #include <skinning_pars_vertex>
3233
+ #include <shadowmap_pars_vertex>
3234
+ #include <logdepthbuf_pars_vertex>
3235
+ #include <clipping_planes_pars_vertex>
3236
+ void main() {
3237
+ #include <uv_vertex>
3238
+ #include <color_vertex>
3239
+ #include <morphinstance_vertex>
3240
+ #include <morphcolor_vertex>
3241
+ #include <batching_vertex>
3242
+ #include <beginnormal_vertex>
3243
+ #include <morphnormal_vertex>
3244
+ #include <skinbase_vertex>
3245
+ #include <skinnormal_vertex>
3246
+ #include <defaultnormal_vertex>
3247
+ #include <normal_vertex>
3248
+ #include <begin_vertex>
3249
+ #include <morphtarget_vertex>
3250
+ #include <skinning_vertex>
3251
+ #include <displacementmap_vertex>
3252
+ #include <project_vertex>
3253
+ #include <logdepthbuf_vertex>
3254
+ #include <clipping_planes_vertex>
3255
+ vViewPosition = - mvPosition.xyz;
3256
+ #include <worldpos_vertex>
3257
+ #include <shadowmap_vertex>
3258
+ #include <fog_vertex>
3259
+ #ifdef USE_TRANSMISSION
3260
+ vWorldPosition = worldPosition.xyz;
3261
+ #endif
3262
+ }`,_f=`#define STANDARD
3263
+ #ifdef PHYSICAL
3264
+ #define IOR
3265
+ #define USE_SPECULAR
3266
+ #endif
3267
+ uniform vec3 diffuse;
3268
+ uniform vec3 emissive;
3269
+ uniform float roughness;
3270
+ uniform float metalness;
3271
+ uniform float opacity;
3272
+ #ifdef IOR
3273
+ uniform float ior;
3274
+ #endif
3275
+ #ifdef USE_SPECULAR
3276
+ uniform float specularIntensity;
3277
+ uniform vec3 specularColor;
3278
+ #ifdef USE_SPECULAR_COLORMAP
3279
+ uniform sampler2D specularColorMap;
3280
+ #endif
3281
+ #ifdef USE_SPECULAR_INTENSITYMAP
3282
+ uniform sampler2D specularIntensityMap;
3283
+ #endif
3284
+ #endif
3285
+ #ifdef USE_CLEARCOAT
3286
+ uniform float clearcoat;
3287
+ uniform float clearcoatRoughness;
3288
+ #endif
3289
+ #ifdef USE_DISPERSION
3290
+ uniform float dispersion;
3291
+ #endif
3292
+ #ifdef USE_IRIDESCENCE
3293
+ uniform float iridescence;
3294
+ uniform float iridescenceIOR;
3295
+ uniform float iridescenceThicknessMinimum;
3296
+ uniform float iridescenceThicknessMaximum;
3297
+ #endif
3298
+ #ifdef USE_SHEEN
3299
+ uniform vec3 sheenColor;
3300
+ uniform float sheenRoughness;
3301
+ #ifdef USE_SHEEN_COLORMAP
3302
+ uniform sampler2D sheenColorMap;
3303
+ #endif
3304
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3305
+ uniform sampler2D sheenRoughnessMap;
3306
+ #endif
3307
+ #endif
3308
+ #ifdef USE_ANISOTROPY
3309
+ uniform vec2 anisotropyVector;
3310
+ #ifdef USE_ANISOTROPYMAP
3311
+ uniform sampler2D anisotropyMap;
3312
+ #endif
3313
+ #endif
3314
+ varying vec3 vViewPosition;
3315
+ #include <common>
3316
+ #include <dithering_pars_fragment>
3317
+ #include <color_pars_fragment>
3318
+ #include <uv_pars_fragment>
3319
+ #include <map_pars_fragment>
3320
+ #include <alphamap_pars_fragment>
3321
+ #include <alphatest_pars_fragment>
3322
+ #include <alphahash_pars_fragment>
3323
+ #include <aomap_pars_fragment>
3324
+ #include <lightmap_pars_fragment>
3325
+ #include <emissivemap_pars_fragment>
3326
+ #include <iridescence_fragment>
3327
+ #include <cube_uv_reflection_fragment>
3328
+ #include <envmap_common_pars_fragment>
3329
+ #include <envmap_physical_pars_fragment>
3330
+ #include <fog_pars_fragment>
3331
+ #include <lights_pars_begin>
3332
+ #include <normal_pars_fragment>
3333
+ #include <lights_physical_pars_fragment>
3334
+ #include <transmission_pars_fragment>
3335
+ #include <shadowmap_pars_fragment>
3336
+ #include <bumpmap_pars_fragment>
3337
+ #include <normalmap_pars_fragment>
3338
+ #include <clearcoat_pars_fragment>
3339
+ #include <iridescence_pars_fragment>
3340
+ #include <roughnessmap_pars_fragment>
3341
+ #include <metalnessmap_pars_fragment>
3342
+ #include <logdepthbuf_pars_fragment>
3343
+ #include <clipping_planes_pars_fragment>
3344
+ void main() {
3345
+ vec4 diffuseColor = vec4( diffuse, opacity );
3346
+ #include <clipping_planes_fragment>
3347
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3348
+ vec3 totalEmissiveRadiance = emissive;
3349
+ #include <logdepthbuf_fragment>
3350
+ #include <map_fragment>
3351
+ #include <color_fragment>
3352
+ #include <alphamap_fragment>
3353
+ #include <alphatest_fragment>
3354
+ #include <alphahash_fragment>
3355
+ #include <roughnessmap_fragment>
3356
+ #include <metalnessmap_fragment>
3357
+ #include <normal_fragment_begin>
3358
+ #include <normal_fragment_maps>
3359
+ #include <clearcoat_normal_fragment_begin>
3360
+ #include <clearcoat_normal_fragment_maps>
3361
+ #include <emissivemap_fragment>
3362
+ #include <lights_physical_fragment>
3363
+ #include <lights_fragment_begin>
3364
+ #include <lights_fragment_maps>
3365
+ #include <lights_fragment_end>
3366
+ #include <aomap_fragment>
3367
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3368
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3369
+ #include <transmission_fragment>
3370
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3371
+ #ifdef USE_SHEEN
3372
+
3373
+ outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
3374
+
3375
+ #endif
3376
+ #ifdef USE_CLEARCOAT
3377
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3378
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3379
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3380
+ #endif
3381
+ #include <opaque_fragment>
3382
+ #include <tonemapping_fragment>
3383
+ #include <colorspace_fragment>
3384
+ #include <fog_fragment>
3385
+ #include <premultiplied_alpha_fragment>
3386
+ #include <dithering_fragment>
3387
+ }`,gf=`#define TOON
3388
+ varying vec3 vViewPosition;
3389
+ #include <common>
3390
+ #include <batching_pars_vertex>
3391
+ #include <uv_pars_vertex>
3392
+ #include <displacementmap_pars_vertex>
3393
+ #include <color_pars_vertex>
3394
+ #include <fog_pars_vertex>
3395
+ #include <normal_pars_vertex>
3396
+ #include <morphtarget_pars_vertex>
3397
+ #include <skinning_pars_vertex>
3398
+ #include <shadowmap_pars_vertex>
3399
+ #include <logdepthbuf_pars_vertex>
3400
+ #include <clipping_planes_pars_vertex>
3401
+ void main() {
3402
+ #include <uv_vertex>
3403
+ #include <color_vertex>
3404
+ #include <morphinstance_vertex>
3405
+ #include <morphcolor_vertex>
3406
+ #include <batching_vertex>
3407
+ #include <beginnormal_vertex>
3408
+ #include <morphnormal_vertex>
3409
+ #include <skinbase_vertex>
3410
+ #include <skinnormal_vertex>
3411
+ #include <defaultnormal_vertex>
3412
+ #include <normal_vertex>
3413
+ #include <begin_vertex>
3414
+ #include <morphtarget_vertex>
3415
+ #include <skinning_vertex>
3416
+ #include <displacementmap_vertex>
3417
+ #include <project_vertex>
3418
+ #include <logdepthbuf_vertex>
3419
+ #include <clipping_planes_vertex>
3420
+ vViewPosition = - mvPosition.xyz;
3421
+ #include <worldpos_vertex>
3422
+ #include <shadowmap_vertex>
3423
+ #include <fog_vertex>
3424
+ }`,xf=`#define TOON
3425
+ uniform vec3 diffuse;
3426
+ uniform vec3 emissive;
3427
+ uniform float opacity;
3428
+ #include <common>
3429
+ #include <dithering_pars_fragment>
3430
+ #include <color_pars_fragment>
3431
+ #include <uv_pars_fragment>
3432
+ #include <map_pars_fragment>
3433
+ #include <alphamap_pars_fragment>
3434
+ #include <alphatest_pars_fragment>
3435
+ #include <alphahash_pars_fragment>
3436
+ #include <aomap_pars_fragment>
3437
+ #include <lightmap_pars_fragment>
3438
+ #include <emissivemap_pars_fragment>
3439
+ #include <gradientmap_pars_fragment>
3440
+ #include <fog_pars_fragment>
3441
+ #include <bsdfs>
3442
+ #include <lights_pars_begin>
3443
+ #include <normal_pars_fragment>
3444
+ #include <lights_toon_pars_fragment>
3445
+ #include <shadowmap_pars_fragment>
3446
+ #include <bumpmap_pars_fragment>
3447
+ #include <normalmap_pars_fragment>
3448
+ #include <logdepthbuf_pars_fragment>
3449
+ #include <clipping_planes_pars_fragment>
3450
+ void main() {
3451
+ vec4 diffuseColor = vec4( diffuse, opacity );
3452
+ #include <clipping_planes_fragment>
3453
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3454
+ vec3 totalEmissiveRadiance = emissive;
3455
+ #include <logdepthbuf_fragment>
3456
+ #include <map_fragment>
3457
+ #include <color_fragment>
3458
+ #include <alphamap_fragment>
3459
+ #include <alphatest_fragment>
3460
+ #include <alphahash_fragment>
3461
+ #include <normal_fragment_begin>
3462
+ #include <normal_fragment_maps>
3463
+ #include <emissivemap_fragment>
3464
+ #include <lights_toon_fragment>
3465
+ #include <lights_fragment_begin>
3466
+ #include <lights_fragment_maps>
3467
+ #include <lights_fragment_end>
3468
+ #include <aomap_fragment>
3469
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3470
+ #include <opaque_fragment>
3471
+ #include <tonemapping_fragment>
3472
+ #include <colorspace_fragment>
3473
+ #include <fog_fragment>
3474
+ #include <premultiplied_alpha_fragment>
3475
+ #include <dithering_fragment>
3476
+ }`,vf=`uniform float size;
3477
+ uniform float scale;
3478
+ #include <common>
3479
+ #include <color_pars_vertex>
3480
+ #include <fog_pars_vertex>
3481
+ #include <morphtarget_pars_vertex>
3482
+ #include <logdepthbuf_pars_vertex>
3483
+ #include <clipping_planes_pars_vertex>
3484
+ #ifdef USE_POINTS_UV
3485
+ varying vec2 vUv;
3486
+ uniform mat3 uvTransform;
3487
+ #endif
3488
+ void main() {
3489
+ #ifdef USE_POINTS_UV
3490
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3491
+ #endif
3492
+ #include <color_vertex>
3493
+ #include <morphinstance_vertex>
3494
+ #include <morphcolor_vertex>
3495
+ #include <begin_vertex>
3496
+ #include <morphtarget_vertex>
3497
+ #include <project_vertex>
3498
+ gl_PointSize = size;
3499
+ #ifdef USE_SIZEATTENUATION
3500
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3501
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3502
+ #endif
3503
+ #include <logdepthbuf_vertex>
3504
+ #include <clipping_planes_vertex>
3505
+ #include <worldpos_vertex>
3506
+ #include <fog_vertex>
3507
+ }`,Mf=`uniform vec3 diffuse;
3508
+ uniform float opacity;
3509
+ #include <common>
3510
+ #include <color_pars_fragment>
3511
+ #include <map_particle_pars_fragment>
3512
+ #include <alphatest_pars_fragment>
3513
+ #include <alphahash_pars_fragment>
3514
+ #include <fog_pars_fragment>
3515
+ #include <logdepthbuf_pars_fragment>
3516
+ #include <clipping_planes_pars_fragment>
3517
+ void main() {
3518
+ vec4 diffuseColor = vec4( diffuse, opacity );
3519
+ #include <clipping_planes_fragment>
3520
+ vec3 outgoingLight = vec3( 0.0 );
3521
+ #include <logdepthbuf_fragment>
3522
+ #include <map_particle_fragment>
3523
+ #include <color_fragment>
3524
+ #include <alphatest_fragment>
3525
+ #include <alphahash_fragment>
3526
+ outgoingLight = diffuseColor.rgb;
3527
+ #include <opaque_fragment>
3528
+ #include <tonemapping_fragment>
3529
+ #include <colorspace_fragment>
3530
+ #include <fog_fragment>
3531
+ #include <premultiplied_alpha_fragment>
3532
+ }`,Sf=`#include <common>
3533
+ #include <batching_pars_vertex>
3534
+ #include <fog_pars_vertex>
3535
+ #include <morphtarget_pars_vertex>
3536
+ #include <skinning_pars_vertex>
3537
+ #include <logdepthbuf_pars_vertex>
3538
+ #include <shadowmap_pars_vertex>
3539
+ void main() {
3540
+ #include <batching_vertex>
3541
+ #include <beginnormal_vertex>
3542
+ #include <morphinstance_vertex>
3543
+ #include <morphnormal_vertex>
3544
+ #include <skinbase_vertex>
3545
+ #include <skinnormal_vertex>
3546
+ #include <defaultnormal_vertex>
3547
+ #include <begin_vertex>
3548
+ #include <morphtarget_vertex>
3549
+ #include <skinning_vertex>
3550
+ #include <project_vertex>
3551
+ #include <logdepthbuf_vertex>
3552
+ #include <worldpos_vertex>
3553
+ #include <shadowmap_vertex>
3554
+ #include <fog_vertex>
3555
+ }`,Ef=`uniform vec3 color;
3556
+ uniform float opacity;
3557
+ #include <common>
3558
+ #include <fog_pars_fragment>
3559
+ #include <bsdfs>
3560
+ #include <lights_pars_begin>
3561
+ #include <logdepthbuf_pars_fragment>
3562
+ #include <shadowmap_pars_fragment>
3563
+ #include <shadowmask_pars_fragment>
3564
+ void main() {
3565
+ #include <logdepthbuf_fragment>
3566
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3567
+ #include <tonemapping_fragment>
3568
+ #include <colorspace_fragment>
3569
+ #include <fog_fragment>
3570
+ #include <premultiplied_alpha_fragment>
3571
+ }`,yf=`uniform float rotation;
3572
+ uniform vec2 center;
3573
+ #include <common>
3574
+ #include <uv_pars_vertex>
3575
+ #include <fog_pars_vertex>
3576
+ #include <logdepthbuf_pars_vertex>
3577
+ #include <clipping_planes_pars_vertex>
3578
+ void main() {
3579
+ #include <uv_vertex>
3580
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3581
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3582
+ #ifndef USE_SIZEATTENUATION
3583
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3584
+ if ( isPerspective ) scale *= - mvPosition.z;
3585
+ #endif
3586
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3587
+ vec2 rotatedPosition;
3588
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3589
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3590
+ mvPosition.xy += rotatedPosition;
3591
+ gl_Position = projectionMatrix * mvPosition;
3592
+ #include <logdepthbuf_vertex>
3593
+ #include <clipping_planes_vertex>
3594
+ #include <fog_vertex>
3595
+ }`,Tf=`uniform vec3 diffuse;
3596
+ uniform float opacity;
3597
+ #include <common>
3598
+ #include <uv_pars_fragment>
3599
+ #include <map_pars_fragment>
3600
+ #include <alphamap_pars_fragment>
3601
+ #include <alphatest_pars_fragment>
3602
+ #include <alphahash_pars_fragment>
3603
+ #include <fog_pars_fragment>
3604
+ #include <logdepthbuf_pars_fragment>
3605
+ #include <clipping_planes_pars_fragment>
3606
+ void main() {
3607
+ vec4 diffuseColor = vec4( diffuse, opacity );
3608
+ #include <clipping_planes_fragment>
3609
+ vec3 outgoingLight = vec3( 0.0 );
3610
+ #include <logdepthbuf_fragment>
3611
+ #include <map_fragment>
3612
+ #include <alphamap_fragment>
3613
+ #include <alphatest_fragment>
3614
+ #include <alphahash_fragment>
3615
+ outgoingLight = diffuseColor.rgb;
3616
+ #include <opaque_fragment>
3617
+ #include <tonemapping_fragment>
3618
+ #include <colorspace_fragment>
3619
+ #include <fog_fragment>
3620
+ }`,Ue={alphahash_fragment:Xc,alphahash_pars_fragment:qc,alphamap_fragment:Yc,alphamap_pars_fragment:Kc,alphatest_fragment:Zc,alphatest_pars_fragment:$c,aomap_fragment:jc,aomap_pars_fragment:Jc,batching_pars_vertex:Qc,batching_vertex:eh,begin_vertex:th,beginnormal_vertex:nh,bsdfs:ih,iridescence_fragment:sh,bumpmap_pars_fragment:rh,clipping_planes_fragment:ah,clipping_planes_pars_fragment:oh,clipping_planes_pars_vertex:lh,clipping_planes_vertex:ch,color_fragment:hh,color_pars_fragment:uh,color_pars_vertex:fh,color_vertex:dh,common:ph,cube_uv_reflection_fragment:mh,defaultnormal_vertex:_h,displacementmap_pars_vertex:gh,displacementmap_vertex:xh,emissivemap_fragment:vh,emissivemap_pars_fragment:Mh,colorspace_fragment:Sh,colorspace_pars_fragment:Eh,envmap_fragment:yh,envmap_common_pars_fragment:Th,envmap_pars_fragment:bh,envmap_pars_vertex:Ah,envmap_physical_pars_fragment:Oh,envmap_vertex:Rh,fog_vertex:wh,fog_pars_vertex:Ch,fog_fragment:Ph,fog_pars_fragment:Dh,gradientmap_pars_fragment:Lh,lightmap_pars_fragment:Ih,lights_lambert_fragment:Uh,lights_lambert_pars_fragment:Nh,lights_pars_begin:Fh,lights_toon_fragment:Bh,lights_toon_pars_fragment:zh,lights_phong_fragment:Vh,lights_phong_pars_fragment:Gh,lights_physical_fragment:Hh,lights_physical_pars_fragment:kh,lights_fragment_begin:Wh,lights_fragment_maps:Xh,lights_fragment_end:qh,logdepthbuf_fragment:Yh,logdepthbuf_pars_fragment:Kh,logdepthbuf_pars_vertex:Zh,logdepthbuf_vertex:$h,map_fragment:jh,map_pars_fragment:Jh,map_particle_fragment:Qh,map_particle_pars_fragment:eu,metalnessmap_fragment:tu,metalnessmap_pars_fragment:nu,morphinstance_vertex:iu,morphcolor_vertex:su,morphnormal_vertex:ru,morphtarget_pars_vertex:au,morphtarget_vertex:ou,normal_fragment_begin:lu,normal_fragment_maps:cu,normal_pars_fragment:hu,normal_pars_vertex:uu,normal_vertex:fu,normalmap_pars_fragment:du,clearcoat_normal_fragment_begin:pu,clearcoat_normal_fragment_maps:mu,clearcoat_pars_fragment:_u,iridescence_pars_fragment:gu,opaque_fragment:xu,packing:vu,premultiplied_alpha_fragment:Mu,project_vertex:Su,dithering_fragment:Eu,dithering_pars_fragment:yu,roughnessmap_fragment:Tu,roughnessmap_pars_fragment:bu,shadowmap_pars_fragment:Au,shadowmap_pars_vertex:Ru,shadowmap_vertex:wu,shadowmask_pars_fragment:Cu,skinbase_vertex:Pu,skinning_pars_vertex:Du,skinning_vertex:Lu,skinnormal_vertex:Iu,specularmap_fragment:Uu,specularmap_pars_fragment:Nu,tonemapping_fragment:Fu,tonemapping_pars_fragment:Ou,transmission_fragment:Bu,transmission_pars_fragment:zu,uv_pars_fragment:Vu,uv_pars_vertex:Gu,uv_vertex:Hu,worldpos_vertex:ku,background_vert:Wu,background_frag:Xu,backgroundCube_vert:qu,backgroundCube_frag:Yu,cube_vert:Ku,cube_frag:Zu,depth_vert:$u,depth_frag:ju,distance_vert:Ju,distance_frag:Qu,equirect_vert:ef,equirect_frag:tf,linedashed_vert:nf,linedashed_frag:sf,meshbasic_vert:rf,meshbasic_frag:af,meshlambert_vert:of,meshlambert_frag:lf,meshmatcap_vert:cf,meshmatcap_frag:hf,meshnormal_vert:uf,meshnormal_frag:ff,meshphong_vert:df,meshphong_frag:pf,meshphysical_vert:mf,meshphysical_frag:_f,meshtoon_vert:gf,meshtoon_frag:xf,points_vert:vf,points_frag:Mf,shadow_vert:Sf,shadow_frag:Ef,sprite_vert:yf,sprite_frag:Tf},ae={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Le}},envmap:{envMap:{value:null},envMapRotation:{value:new Le},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 Le}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Le}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Le},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Le},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Le},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Le}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Le}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Le}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0},uvTransform:{value:new Le}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}}},Wt={basic:{uniforms:Tt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.fog]),vertexShader:Ue.meshbasic_vert,fragmentShader:Ue.meshbasic_frag},lambert:{uniforms:Tt([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 Ne(0)},envMapIntensity:{value:1}}]),vertexShader:Ue.meshlambert_vert,fragmentShader:Ue.meshlambert_frag},phong:{uniforms:Tt([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 Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphong_vert,fragmentShader:Ue.meshphong_frag},standard:{uniforms:Tt([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 Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag},toon:{uniforms:Tt([ae.common,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.gradientmap,ae.fog,ae.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Ue.meshtoon_vert,fragmentShader:Ue.meshtoon_frag},matcap:{uniforms:Tt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,{matcap:{value:null}}]),vertexShader:Ue.meshmatcap_vert,fragmentShader:Ue.meshmatcap_frag},points:{uniforms:Tt([ae.points,ae.fog]),vertexShader:Ue.points_vert,fragmentShader:Ue.points_frag},dashed:{uniforms:Tt([ae.common,ae.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ue.linedashed_vert,fragmentShader:Ue.linedashed_frag},depth:{uniforms:Tt([ae.common,ae.displacementmap]),vertexShader:Ue.depth_vert,fragmentShader:Ue.depth_frag},normal:{uniforms:Tt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,{opacity:{value:1}}]),vertexShader:Ue.meshnormal_vert,fragmentShader:Ue.meshnormal_frag},sprite:{uniforms:Tt([ae.sprite,ae.fog]),vertexShader:Ue.sprite_vert,fragmentShader:Ue.sprite_frag},background:{uniforms:{uvTransform:{value:new Le},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ue.background_vert,fragmentShader:Ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Le}},vertexShader:Ue.backgroundCube_vert,fragmentShader:Ue.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ue.cube_vert,fragmentShader:Ue.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ue.equirect_vert,fragmentShader:Ue.equirect_frag},distance:{uniforms:Tt([ae.common,ae.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ue.distance_vert,fragmentShader:Ue.distance_frag},shadow:{uniforms:Tt([ae.lights,ae.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Ue.shadow_vert,fragmentShader:Ue.shadow_frag}};Wt.physical={uniforms:Tt([Wt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Le},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Le},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Le},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Le},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Le},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Le},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Le},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Le},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Le},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Le},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Le},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Le}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag};const is={r:0,b:0,g:0},Dn=new jt,bf=new st;function Af(i,e,t,n,s,r){const a=new Ne(0);let o=s===!0?0:1,c,l,f=null,m=0,h=null;function p(v){let T=v.isScene===!0?v.background:null;if(T&&T.isTexture){const E=v.backgroundBlurriness>0;T=e.get(T,E)}return T}function g(v){let T=!1;const E=p(v);E===null?d(a,o):E&&E.isColor&&(d(E,1),T=!0);const R=i.xr.getEnvironmentBlendMode();R==="additive"?t.buffers.color.setClear(0,0,0,1,r):R==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(v,T){const E=p(T);E&&(E.isCubeTexture||E.mapping===gs)?(l===void 0&&(l=new dn(new Ci(1,1,1),new Jt({name:"BackgroundCubeMaterial",uniforms:ci(Wt.backgroundCube.uniforms),vertexShader:Wt.backgroundCube.vertexShader,fragmentShader:Wt.backgroundCube.fragmentShader,side:Rt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(R,A,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),Dn.copy(T.backgroundRotation),Dn.x*=-1,Dn.y*=-1,Dn.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Dn.y*=-1,Dn.z*=-1),l.material.uniforms.envMap.value=E,l.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(bf.makeRotationFromEuler(Dn)),l.material.toneMapped=He.getTransfer(E.colorSpace)!==Ze,(f!==E||m!==E.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,f=E,m=E.version,h=i.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null)):E&&E.isTexture&&(c===void 0&&(c=new dn(new xs(2,2),new Jt({name:"BackgroundMaterial",uniforms:ci(Wt.background.uniforms),vertexShader:Wt.background.vertexShader,fragmentShader:Wt.background.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=E,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=He.getTransfer(E.colorSpace)!==Ze,E.matrixAutoUpdate===!0&&E.updateMatrix(),c.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||m!==E.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,f=E,m=E.version,h=i.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function d(v,T){v.getRGB(is,rl(i)),t.buffers.color.setClear(is.r,is.g,is.b,T,r)}function u(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(v,T=1){a.set(v),o=T,d(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(v){o=v,d(a,o)},render:g,addToRenderList:S,dispose:u}}function Rf(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null);let r=s,a=!1;function o(w,N,O,k,G){let z=!1;const H=m(w,k,O,N);r!==H&&(r=H,l(r.object)),z=p(w,k,O,G),z&&g(w,k,O,G),G!==null&&e.update(G,i.ELEMENT_ARRAY_BUFFER),(z||a)&&(a=!1,E(w,N,O,k),G!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(G).buffer))}function c(){return i.createVertexArray()}function l(w){return i.bindVertexArray(w)}function f(w){return i.deleteVertexArray(w)}function m(w,N,O,k){const G=k.wireframe===!0;let z=n[N.id];z===void 0&&(z={},n[N.id]=z);const H=w.isInstancedMesh===!0?w.id:0;let Q=z[H];Q===void 0&&(Q={},z[H]=Q);let $=Q[O.id];$===void 0&&($={},Q[O.id]=$);let ce=$[G];return ce===void 0&&(ce=h(c()),$[G]=ce),ce}function h(w){const N=[],O=[],k=[];for(let G=0;G<t;G++)N[G]=0,O[G]=0,k[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:O,attributeDivisors:k,object:w,attributes:{},index:null}}function p(w,N,O,k){const G=r.attributes,z=N.attributes;let H=0;const Q=O.getAttributes();for(const $ in Q)if(Q[$].location>=0){const pe=G[$];let ue=z[$];if(ue===void 0&&($==="instanceMatrix"&&w.instanceMatrix&&(ue=w.instanceMatrix),$==="instanceColor"&&w.instanceColor&&(ue=w.instanceColor)),pe===void 0||pe.attribute!==ue||ue&&pe.data!==ue.data)return!0;H++}return r.attributesNum!==H||r.index!==k}function g(w,N,O,k){const G={},z=N.attributes;let H=0;const Q=O.getAttributes();for(const $ in Q)if(Q[$].location>=0){let pe=z[$];pe===void 0&&($==="instanceMatrix"&&w.instanceMatrix&&(pe=w.instanceMatrix),$==="instanceColor"&&w.instanceColor&&(pe=w.instanceColor));const ue={};ue.attribute=pe,pe&&pe.data&&(ue.data=pe.data),G[$]=ue,H++}r.attributes=G,r.attributesNum=H,r.index=k}function S(){const w=r.newAttributes;for(let N=0,O=w.length;N<O;N++)w[N]=0}function d(w){u(w,0)}function u(w,N){const O=r.newAttributes,k=r.enabledAttributes,G=r.attributeDivisors;O[w]=1,k[w]===0&&(i.enableVertexAttribArray(w),k[w]=1),G[w]!==N&&(i.vertexAttribDivisor(w,N),G[w]=N)}function v(){const w=r.newAttributes,N=r.enabledAttributes;for(let O=0,k=N.length;O<k;O++)N[O]!==w[O]&&(i.disableVertexAttribArray(O),N[O]=0)}function T(w,N,O,k,G,z,H){H===!0?i.vertexAttribIPointer(w,N,O,G,z):i.vertexAttribPointer(w,N,O,k,G,z)}function E(w,N,O,k){S();const G=k.attributes,z=O.getAttributes(),H=N.defaultAttributeValues;for(const Q in z){const $=z[Q];if($.location>=0){let ce=G[Q];if(ce===void 0&&(Q==="instanceMatrix"&&w.instanceMatrix&&(ce=w.instanceMatrix),Q==="instanceColor"&&w.instanceColor&&(ce=w.instanceColor)),ce!==void 0){const pe=ce.normalized,ue=ce.itemSize,Ie=e.get(ce);if(Ie===void 0)continue;const it=Ie.buffer,nt=Ie.type,K=Ie.bytesPerElement,ne=nt===i.INT||nt===i.UNSIGNED_INT||ce.gpuType===Jr;if(ce.isInterleavedBufferAttribute){const re=ce.data,De=re.stride,be=ce.offset;if(re.isInstancedInterleavedBuffer){for(let we=0;we<$.locationSize;we++)u($.location+we,re.meshPerAttribute);w.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let we=0;we<$.locationSize;we++)d($.location+we);i.bindBuffer(i.ARRAY_BUFFER,it);for(let we=0;we<$.locationSize;we++)T($.location+we,ue/$.locationSize,nt,pe,De*K,(be+ue/$.locationSize*we)*K,ne)}else{if(ce.isInstancedBufferAttribute){for(let re=0;re<$.locationSize;re++)u($.location+re,ce.meshPerAttribute);w.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let re=0;re<$.locationSize;re++)d($.location+re);i.bindBuffer(i.ARRAY_BUFFER,it);for(let re=0;re<$.locationSize;re++)T($.location+re,ue/$.locationSize,nt,pe,ue*K,ue/$.locationSize*re*K,ne)}}else if(H!==void 0){const pe=H[Q];if(pe!==void 0)switch(pe.length){case 2:i.vertexAttrib2fv($.location,pe);break;case 3:i.vertexAttrib3fv($.location,pe);break;case 4:i.vertexAttrib4fv($.location,pe);break;default:i.vertexAttrib1fv($.location,pe)}}}}v()}function R(){y();for(const w in n){const N=n[w];for(const O in N){const k=N[O];for(const G in k){const z=k[G];for(const H in z)f(z[H].object),delete z[H];delete k[G]}}delete n[w]}}function A(w){if(n[w.id]===void 0)return;const N=n[w.id];for(const O in N){const k=N[O];for(const G in k){const z=k[G];for(const H in z)f(z[H].object),delete z[H];delete k[G]}}delete n[w.id]}function P(w){for(const N in n){const O=n[N];for(const k in O){const G=O[k];if(G[w.id]===void 0)continue;const z=G[w.id];for(const H in z)f(z[H].object),delete z[H];delete G[w.id]}}}function x(w){for(const N in n){const O=n[N],k=w.isInstancedMesh===!0?w.id:0,G=O[k];if(G!==void 0){for(const z in G){const H=G[z];for(const Q in H)f(H[Q].object),delete H[Q];delete G[z]}delete O[k],Object.keys(O).length===0&&delete n[N]}}}function y(){V(),a=!0,r!==s&&(r=s,l(r.object))}function V(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:y,resetDefaultState:V,dispose:R,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:P,initAttributes:S,enableAttribute:d,disableUnusedAttributes:v}}function wf(i,e,t){let n;function s(l){n=l}function r(l,f){i.drawArrays(n,l,f),t.update(f,n,1)}function a(l,f,m){m!==0&&(i.drawArraysInstanced(n,l,f,m),t.update(f,n,m))}function o(l,f,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,f,0,m);let p=0;for(let g=0;g<m;g++)p+=f[g];t.update(p,n,1)}function c(l,f,m,h){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<l.length;g++)a(l[g],f[g],h[g]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,f,0,h,0,m);let g=0;for(let S=0;S<m;S++)g+=f[S]*h[S];t.update(g,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function Cf(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(P){return!(P!==Vt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(P){const x=P===un&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(P!==Dt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&P!==Xt&&!x)}function c(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 l=t.precision!==void 0?t.precision:"highp";const f=c(l);f!==l&&(Re("WebGLRenderer:",l,"not supported, using",f,"instead."),l=f);const m=t.logarithmicDepthBuffer===!0,h=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),S=i.getParameter(i.MAX_TEXTURE_SIZE),d=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),v=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),E=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),R=i.getParameter(i.MAX_SAMPLES),A=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:g,maxTextureSize:S,maxCubemapSize:d,maxAttributes:u,maxVertexUniforms:v,maxVaryings:T,maxFragmentUniforms:E,maxSamples:R,samples:A}}function Pf(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new In,o=new Le,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const p=m.length!==0||h||n!==0||s;return s=h,n=m.length,p},this.beginShadows=function(){r=!0,f(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(m,h){t=f(m,h,0)},this.setState=function(m,h,p){const g=m.clippingPlanes,S=m.clipIntersection,d=m.clipShadows,u=i.get(m);if(!s||g===null||g.length===0||r&&!d)r?f(null):l();else{const v=r?0:n,T=v*4;let E=u.clippingState||null;c.value=E,E=f(g,h,T,p);for(let R=0;R!==T;++R)E[R]=t[R];u.clippingState=E,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function f(m,h,p,g){const S=m!==null?m.length:0;let d=null;if(S!==0){if(d=c.value,g!==!0||d===null){const u=p+S*4,v=h.matrixWorldInverse;o.getNormalMatrix(v),(d===null||d.length<u)&&(d=new Float32Array(u));for(let T=0,E=p;T!==S;++T,E+=4)a.copy(m[T]).applyMatrix4(v,o),a.normal.toArray(d,E),d[E+3]=a.constant}c.value=d,c.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,d}}const yn=4,to=[.125,.215,.35,.446,.526,.582],Nn=20,Df=256,xi=new ua,no=new Ne;let Js=null,Qs=0,er=0,tr=!1;const Lf=new U;class io{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,s=100,r={}){const{size:a=256,position:o=Lf}=r;Js=this._renderer.getRenderTarget(),Qs=this._renderer.getActiveCubeFace(),er=this._renderer.getActiveMipmapLevel(),tr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ao(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ro(),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(Js,Qs,er),this._renderer.xr.enabled=tr,e.scissorTest=!1,ni(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Bn||e.mapping===ai?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Js=this._renderer.getRenderTarget(),Qs=this._renderer.getActiveCubeFace(),er=this._renderer.getActiveMipmapLevel(),tr=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:yt,minFilter:yt,generateMipmaps:!1,type:un,format:Vt,colorSpace:li,depthBuffer:!1},s=so(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=so(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=If(r)),this._blurMaterial=Nf(r,e,t),this._ggxMaterial=Uf(r,e,t)}return s}_compileMaterial(e){const t=new dn(new gt,e);this._renderer.compile(t,xi)}_sceneToCubeUV(e,t,n,s,r){const c=new Ut(90,1,t,n),l=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],m=this._renderer,h=m.autoClear,p=m.toneMapping;m.getClearColor(no),m.toneMapping=Yt,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(s),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new dn(new Ci,new Zo({name:"PMREM.Background",side:Rt,depthWrite:!1,depthTest:!1})));const S=this._backgroundBox,d=S.material;let u=!1;const v=e.background;v?v.isColor&&(d.color.copy(v),e.background=null,u=!0):(d.color.copy(no),u=!0);for(let T=0;T<6;T++){const E=T%3;E===0?(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+f[T],r.y,r.z)):E===1?(c.up.set(0,0,l[T]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+f[T],r.z)):(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+f[T]));const R=this._cubeSize;ni(s,E*R,T>2?R:0,R,R),m.setRenderTarget(s),u&&m.render(S,c),m.render(e,c)}m.toneMapping=p,m.autoClear=h,e.background=v}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Bn||e.mapping===ai;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ao()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ro());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;ni(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,xi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),m=Math.sqrt(l*l-f*f),h=0+l*1.25,p=m*h,{_lodMax:g}=this,S=this._sizeLods[n],d=3*S*(n>g-yn?n-g+yn:0),u=4*(this._cubeSize-S);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=g-t,ni(r,d,u,3*S,2*S),s.setRenderTarget(r),s.render(o,xi),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,ni(e,d,u,3*S,2*S),s.setRenderTarget(e),s.render(o,xi)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&We("blur direction must be either latitudinal or longitudinal!");const f=3,m=this._lodMeshes[s];m.material=l;const h=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Nn-1),S=r/g,d=isFinite(r)?1+Math.floor(f*S):Nn;d>Nn&&Re(`sigmaRadians, ${r}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${Nn}`);const u=[];let v=0;for(let P=0;P<Nn;++P){const x=P/S,y=Math.exp(-x*x/2);u.push(y),P===0?v+=y:P<d&&(v+=2*y)}for(let P=0;P<u.length;P++)u[P]=u[P]/v;h.envMap.value=e.texture,h.samples.value=d,h.weights.value=u,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);const{_lodMax:T}=this;h.dTheta.value=g,h.mipInt.value=T-n;const E=this._sizeLods[s],R=3*E*(s>T-yn?s-T+yn:0),A=4*(this._cubeSize-E);ni(t,R,A,3*E,2*E),c.setRenderTarget(t),c.render(m,xi)}}function If(i){const e=[],t=[],n=[];let s=i;const r=i-yn+1+to.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let c=1/o;a>i-yn?c=to[a-i+yn-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),f=-l,m=1+l,h=[f,f,m,f,m,m,f,f,m,m,f,m],p=6,g=6,S=3,d=2,u=1,v=new Float32Array(S*g*p),T=new Float32Array(d*g*p),E=new Float32Array(u*g*p);for(let A=0;A<p;A++){const P=A%3*2/3-1,x=A>2?0:-1,y=[P,x,0,P+2/3,x,0,P+2/3,x+1,0,P,x,0,P+2/3,x+1,0,P,x+1,0];v.set(y,S*g*A),T.set(h,d*g*A);const V=[A,A,A,A,A,A];E.set(V,u*g*A)}const R=new gt;R.setAttribute("position",new Zt(v,S)),R.setAttribute("uv",new Zt(T,d)),R.setAttribute("faceIndex",new Zt(E,u)),n.push(new dn(R,null)),s>yn&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function so(i,e,t){const n=new Kt(i,e,t);return n.texture.mapping=gs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ni(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function Uf(i,e,t){return new Jt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Df,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:Ms(),fragmentShader:`
3621
+
3622
+ precision highp float;
3623
+ precision highp int;
3624
+
3625
+ varying vec3 vOutputDirection;
3626
+
3627
+ uniform sampler2D envMap;
3628
+ uniform float roughness;
3629
+ uniform float mipInt;
3630
+
3631
+ #define ENVMAP_TYPE_CUBE_UV
3632
+ #include <cube_uv_reflection_fragment>
3633
+
3634
+ #define PI 3.14159265359
3635
+
3636
+ // Van der Corput radical inverse
3637
+ float radicalInverse_VdC(uint bits) {
3638
+ bits = (bits << 16u) | (bits >> 16u);
3639
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
3640
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
3641
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
3642
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
3643
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
3644
+ }
3645
+
3646
+ // Hammersley sequence
3647
+ vec2 hammersley(uint i, uint N) {
3648
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
3649
+ }
3650
+
3651
+ // GGX VNDF importance sampling (Eric Heitz 2018)
3652
+ // "Sampling the GGX Distribution of Visible Normals"
3653
+ // https://jcgt.org/published/0007/04/01/
3654
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
3655
+ float alpha = roughness * roughness;
3656
+
3657
+ // Section 4.1: Orthonormal basis
3658
+ vec3 T1 = vec3(1.0, 0.0, 0.0);
3659
+ vec3 T2 = cross(V, T1);
3660
+
3661
+ // Section 4.2: Parameterization of projected area
3662
+ float r = sqrt(Xi.x);
3663
+ float phi = 2.0 * PI * Xi.y;
3664
+ float t1 = r * cos(phi);
3665
+ float t2 = r * sin(phi);
3666
+ float s = 0.5 * (1.0 + V.z);
3667
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
3668
+
3669
+ // Section 4.3: Reprojection onto hemisphere
3670
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
3671
+
3672
+ // Section 3.4: Transform back to ellipsoid configuration
3673
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
3674
+ }
3675
+
3676
+ void main() {
3677
+ vec3 N = normalize(vOutputDirection);
3678
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
3679
+
3680
+ vec3 prefilteredColor = vec3(0.0);
3681
+ float totalWeight = 0.0;
3682
+
3683
+ // For very low roughness, just sample the environment directly
3684
+ if (roughness < 0.001) {
3685
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
3686
+ return;
3687
+ }
3688
+
3689
+ // Tangent space basis for VNDF sampling
3690
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
3691
+ vec3 tangent = normalize(cross(up, N));
3692
+ vec3 bitangent = cross(N, tangent);
3693
+
3694
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
3695
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
3696
+
3697
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
3698
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
3699
+
3700
+ // Transform H back to world space
3701
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
3702
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
3703
+
3704
+ float NdotL = max(dot(N, L), 0.0);
3705
+
3706
+ if(NdotL > 0.0) {
3707
+ // Sample environment at fixed mip level
3708
+ // VNDF importance sampling handles the distribution filtering
3709
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
3710
+
3711
+ // Weight by NdotL for the split-sum approximation
3712
+ // VNDF PDF naturally accounts for the visible microfacet distribution
3713
+ prefilteredColor += sampleColor * NdotL;
3714
+ totalWeight += NdotL;
3715
+ }
3716
+ }
3717
+
3718
+ if (totalWeight > 0.0) {
3719
+ prefilteredColor = prefilteredColor / totalWeight;
3720
+ }
3721
+
3722
+ gl_FragColor = vec4(prefilteredColor, 1.0);
3723
+ }
3724
+ `,blending:cn,depthTest:!1,depthWrite:!1})}function Nf(i,e,t){const n=new Float32Array(Nn),s=new U(0,1,0);return new Jt({name:"SphericalGaussianBlur",defines:{n:Nn,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:s}},vertexShader:Ms(),fragmentShader:`
3725
+
3726
+ precision mediump float;
3727
+ precision mediump int;
3728
+
3729
+ varying vec3 vOutputDirection;
3730
+
3731
+ uniform sampler2D envMap;
3732
+ uniform int samples;
3733
+ uniform float weights[ n ];
3734
+ uniform bool latitudinal;
3735
+ uniform float dTheta;
3736
+ uniform float mipInt;
3737
+ uniform vec3 poleAxis;
3738
+
3739
+ #define ENVMAP_TYPE_CUBE_UV
3740
+ #include <cube_uv_reflection_fragment>
3741
+
3742
+ vec3 getSample( float theta, vec3 axis ) {
3743
+
3744
+ float cosTheta = cos( theta );
3745
+ // Rodrigues' axis-angle rotation
3746
+ vec3 sampleDirection = vOutputDirection * cosTheta
3747
+ + cross( axis, vOutputDirection ) * sin( theta )
3748
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3749
+
3750
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3751
+
3752
+ }
3753
+
3754
+ void main() {
3755
+
3756
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3757
+
3758
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3759
+
3760
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3761
+
3762
+ }
3763
+
3764
+ axis = normalize( axis );
3765
+
3766
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3767
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3768
+
3769
+ for ( int i = 1; i < n; i++ ) {
3770
+
3771
+ if ( i >= samples ) {
3772
+
3773
+ break;
3774
+
3775
+ }
3776
+
3777
+ float theta = dTheta * float( i );
3778
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3779
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3780
+
3781
+ }
3782
+
3783
+ }
3784
+ `,blending:cn,depthTest:!1,depthWrite:!1})}function ro(){return new Jt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ms(),fragmentShader:`
3785
+
3786
+ precision mediump float;
3787
+ precision mediump int;
3788
+
3789
+ varying vec3 vOutputDirection;
3790
+
3791
+ uniform sampler2D envMap;
3792
+
3793
+ #include <common>
3794
+
3795
+ void main() {
3796
+
3797
+ vec3 outputDirection = normalize( vOutputDirection );
3798
+ vec2 uv = equirectUv( outputDirection );
3799
+
3800
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3801
+
3802
+ }
3803
+ `,blending:cn,depthTest:!1,depthWrite:!1})}function ao(){return new Jt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ms(),fragmentShader:`
3804
+
3805
+ precision mediump float;
3806
+ precision mediump int;
3807
+
3808
+ uniform float flipEnvMap;
3809
+
3810
+ varying vec3 vOutputDirection;
3811
+
3812
+ uniform samplerCube envMap;
3813
+
3814
+ void main() {
3815
+
3816
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3817
+
3818
+ }
3819
+ `,blending:cn,depthTest:!1,depthWrite:!1})}function Ms(){return`
3820
+
3821
+ precision mediump float;
3822
+ precision mediump int;
3823
+
3824
+ attribute float faceIndex;
3825
+
3826
+ varying vec3 vOutputDirection;
3827
+
3828
+ // RH coordinate system; PMREM face-indexing convention
3829
+ vec3 getDirection( vec2 uv, float face ) {
3830
+
3831
+ uv = 2.0 * uv - 1.0;
3832
+
3833
+ vec3 direction = vec3( uv, 1.0 );
3834
+
3835
+ if ( face == 0.0 ) {
3836
+
3837
+ direction = direction.zyx; // ( 1, v, u ) pos x
3838
+
3839
+ } else if ( face == 1.0 ) {
3840
+
3841
+ direction = direction.xzy;
3842
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3843
+
3844
+ } else if ( face == 2.0 ) {
3845
+
3846
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3847
+
3848
+ } else if ( face == 3.0 ) {
3849
+
3850
+ direction = direction.zyx;
3851
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3852
+
3853
+ } else if ( face == 4.0 ) {
3854
+
3855
+ direction = direction.xzy;
3856
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3857
+
3858
+ } else if ( face == 5.0 ) {
3859
+
3860
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3861
+
3862
+ }
3863
+
3864
+ return direction;
3865
+
3866
+ }
3867
+
3868
+ void main() {
3869
+
3870
+ vOutputDirection = getDirection( uv, faceIndex );
3871
+ gl_Position = vec4( position, 1.0 );
3872
+
3873
+ }
3874
+ `}class cl extends Kt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new jo(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
3875
+
3876
+ varying vec3 vWorldDirection;
3877
+
3878
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
3879
+
3880
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
3881
+
3882
+ }
3883
+
3884
+ void main() {
3885
+
3886
+ vWorldDirection = transformDirection( position, modelMatrix );
3887
+
3888
+ #include <begin_vertex>
3889
+ #include <project_vertex>
3890
+
3891
+ }
3892
+ `,fragmentShader:`
3893
+
3894
+ uniform sampler2D tEquirect;
3895
+
3896
+ varying vec3 vWorldDirection;
3897
+
3898
+ #include <common>
3899
+
3900
+ void main() {
3901
+
3902
+ vec3 direction = normalize( vWorldDirection );
3903
+
3904
+ vec2 sampleUV = equirectUv( direction );
3905
+
3906
+ gl_FragColor = texture2D( tEquirect, sampleUV );
3907
+
3908
+ }
3909
+ `},s=new Ci(5,5,5),r=new Jt({name:"CubemapFromEquirect",uniforms:ci(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Rt,blending:cn});r.uniforms.tEquirect.value=t;const a=new dn(s,r),o=t.minFilter;return t.minFilter===Fn&&(t.minFilter=yt),new Vc(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function Ff(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,p=!1){return h==null?null:p?a(h):r(h)}function r(h){if(h&&h.isTexture){const p=h.mapping;if(p===Ts||p===bs)if(e.has(h)){const g=e.get(h).texture;return o(g,h.mapping)}else{const g=h.image;if(g&&g.height>0){const S=new cl(g.height);return S.fromEquirectangularTexture(i,h),e.set(h,S),h.addEventListener("dispose",l),o(S.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const p=h.mapping,g=p===Ts||p===bs,S=p===Bn||p===ai;if(g||S){let d=t.get(h);const u=d!==void 0?d.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==u)return n===null&&(n=new io(i)),d=g?n.fromEquirectangular(h,d):n.fromCubemap(h,d),d.texture.pmremVersion=h.pmremVersion,t.set(h,d),d.texture;if(d!==void 0)return d.texture;{const v=h.image;return g&&v&&v.height>0||S&&v&&c(v)?(n===null&&(n=new io(i)),d=g?n.fromEquirectangular(h):n.fromCubemap(h),d.texture.pmremVersion=h.pmremVersion,t.set(h,d),h.addEventListener("dispose",f),d.texture):null}}}return h}function o(h,p){return p===Ts?h.mapping=Bn:p===bs&&(h.mapping=ai),h}function c(h){let p=0;const g=6;for(let S=0;S<g;S++)h[S]!==void 0&&p++;return p===g}function l(h){const p=h.target;p.removeEventListener("dispose",l);const g=e.get(p);g!==void 0&&(e.delete(p),g.dispose())}function f(h){const p=h.target;p.removeEventListener("dispose",f);const g=t.get(p);g!==void 0&&(t.delete(p),g.dispose())}function m(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:m}}function Of(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&ps("WebGLRenderer: "+n+" extension not supported."),s}}}function Bf(i,e,t,n){const s={},r=new WeakMap;function a(m){const h=m.target;h.index!==null&&e.remove(h.index);for(const g in h.attributes)e.remove(h.attributes[g]);h.removeEventListener("dispose",a),delete s[h.id];const p=r.get(h);p&&(e.remove(p),r.delete(h)),n.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(m,h){return s[h.id]===!0||(h.addEventListener("dispose",a),s[h.id]=!0,t.memory.geometries++),h}function c(m){const h=m.attributes;for(const p in h)e.update(h[p],i.ARRAY_BUFFER)}function l(m){const h=[],p=m.index,g=m.attributes.position;let S=0;if(g===void 0)return;if(p!==null){const v=p.array;S=p.version;for(let T=0,E=v.length;T<E;T+=3){const R=v[T+0],A=v[T+1],P=v[T+2];h.push(R,A,A,P,P,R)}}else{const v=g.array;S=g.version;for(let T=0,E=v.length/3-1;T<E;T+=3){const R=T+0,A=T+1,P=T+2;h.push(R,A,A,P,P,R)}}const d=new(g.count>=65535?Ko:Yo)(h,1);d.version=S;const u=r.get(m);u&&e.remove(u),r.set(m,d)}function f(m){const h=r.get(m);if(h){const p=m.index;p!==null&&h.version<p.version&&l(m)}else l(m);return r.get(m)}return{get:o,update:c,getWireframeAttribute:f}}function zf(i,e,t){let n;function s(h){n=h}let r,a;function o(h){r=h.type,a=h.bytesPerElement}function c(h,p){i.drawElements(n,p,r,h*a),t.update(p,n,1)}function l(h,p,g){g!==0&&(i.drawElementsInstanced(n,p,r,h*a,g),t.update(p,n,g))}function f(h,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,h,0,g);let d=0;for(let u=0;u<g;u++)d+=p[u];t.update(d,n,1)}function m(h,p,g,S){if(g===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let u=0;u<h.length;u++)l(h[u]/a,p[u],S[u]);else{d.multiDrawElementsInstancedWEBGL(n,p,0,r,h,0,S,0,g);let u=0;for(let v=0;v<g;v++)u+=p[v]*S[v];t.update(u,n,1)}}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=f,this.renderMultiDrawInstances=m}function Vf(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:We("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Gf(i,e,t){const n=new WeakMap,s=new at;function r(a,o,c){const l=a.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=f!==void 0?f.length:0;let h=n.get(o);if(h===void 0||h.count!==m){let y=function(){P.dispose(),n.delete(o),o.removeEventListener("dispose",y)};h!==void 0&&h.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,d=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],v=o.morphAttributes.color||[];let T=0;p===!0&&(T=1),g===!0&&(T=2),S===!0&&(T=3);let E=o.attributes.position.count*T,R=1;E>e.maxTextureSize&&(R=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*R*4*m),P=new ko(A,E,R,m);P.type=Xt,P.needsUpdate=!0;const x=T*4;for(let V=0;V<m;V++){const w=d[V],N=u[V],O=v[V],k=E*R*4*V;for(let G=0;G<w.count;G++){const z=G*x;p===!0&&(s.fromBufferAttribute(w,G),A[k+z+0]=s.x,A[k+z+1]=s.y,A[k+z+2]=s.z,A[k+z+3]=0),g===!0&&(s.fromBufferAttribute(N,G),A[k+z+4]=s.x,A[k+z+5]=s.y,A[k+z+6]=s.z,A[k+z+7]=0),S===!0&&(s.fromBufferAttribute(O,G),A[k+z+8]=s.x,A[k+z+9]=s.y,A[k+z+10]=s.z,A[k+z+11]=O.itemSize===4?s.w:1)}}h={count:m,texture:P,size:new Ve(E,R)},n.set(o,h),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let S=0;S<l.length;S++)p+=l[S];const g=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",h.size)}return{update:r}}function Hf(i,e,t,n,s){let r=new WeakMap;function a(l){const f=s.render.frame,m=l.geometry,h=e.get(l,m);if(r.get(h)!==f&&(e.update(h),r.set(h,f)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==f&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,f))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==f&&(p.update(),r.set(p,f))}return h}function o(){r=new WeakMap}function c(l){const f=l.target;f.removeEventListener("dispose",c),n.releaseStatesOfObject(f),t.remove(f.instanceMatrix),f.instanceColor!==null&&t.remove(f.instanceColor)}return{update:a,dispose:o}}const kf={[Ao]:"LINEAR_TONE_MAPPING",[Ro]:"REINHARD_TONE_MAPPING",[wo]:"CINEON_TONE_MAPPING",[Co]:"ACES_FILMIC_TONE_MAPPING",[Do]:"AGX_TONE_MAPPING",[Lo]:"NEUTRAL_TONE_MAPPING",[Po]:"CUSTOM_TONE_MAPPING"};function Wf(i,e,t,n,s){const r=new Kt(e,t,{type:i,depthBuffer:n,stencilBuffer:s}),a=new Kt(e,t,{type:un,depthBuffer:!1,stencilBuffer:!1}),o=new gt;o.setAttribute("position",new Xe([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Xe([0,2,0,0,2,0],2));const c=new Uc({uniforms:{tDiffuse:{value:null}},vertexShader:`
3910
+ precision highp float;
3911
+
3912
+ uniform mat4 modelViewMatrix;
3913
+ uniform mat4 projectionMatrix;
3914
+
3915
+ attribute vec3 position;
3916
+ attribute vec2 uv;
3917
+
3918
+ varying vec2 vUv;
3919
+
3920
+ void main() {
3921
+ vUv = uv;
3922
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3923
+ }`,fragmentShader:`
3924
+ precision highp float;
3925
+
3926
+ uniform sampler2D tDiffuse;
3927
+
3928
+ varying vec2 vUv;
3929
+
3930
+ #include <tonemapping_pars_fragment>
3931
+ #include <colorspace_pars_fragment>
3932
+
3933
+ void main() {
3934
+ gl_FragColor = texture2D( tDiffuse, vUv );
3935
+
3936
+ #ifdef LINEAR_TONE_MAPPING
3937
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
3938
+ #elif defined( REINHARD_TONE_MAPPING )
3939
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
3940
+ #elif defined( CINEON_TONE_MAPPING )
3941
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
3942
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
3943
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
3944
+ #elif defined( AGX_TONE_MAPPING )
3945
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
3946
+ #elif defined( NEUTRAL_TONE_MAPPING )
3947
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
3948
+ #elif defined( CUSTOM_TONE_MAPPING )
3949
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
3950
+ #endif
3951
+
3952
+ #ifdef SRGB_TRANSFER
3953
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
3954
+ #endif
3955
+ }`,depthTest:!1,depthWrite:!1}),l=new dn(o,c),f=new ua(-1,1,1,-1,0,1);let m=null,h=null,p=!1,g,S=null,d=[],u=!1;this.setSize=function(v,T){r.setSize(v,T),a.setSize(v,T);for(let E=0;E<d.length;E++){const R=d[E];R.setSize&&R.setSize(v,T)}},this.setEffects=function(v){d=v,u=d.length>0&&d[0].isRenderPass===!0;const T=r.width,E=r.height;for(let R=0;R<d.length;R++){const A=d[R];A.setSize&&A.setSize(T,E)}},this.begin=function(v,T){if(p||v.toneMapping===Yt&&d.length===0)return!1;if(S=T,T!==null){const E=T.width,R=T.height;(r.width!==E||r.height!==R)&&this.setSize(E,R)}return u===!1&&v.setRenderTarget(r),g=v.toneMapping,v.toneMapping=Yt,!0},this.hasRenderPass=function(){return u},this.end=function(v,T){v.toneMapping=g,p=!0;let E=r,R=a;for(let A=0;A<d.length;A++){const P=d[A];if(P.enabled!==!1&&(P.render(v,R,E,T),P.needsSwap!==!1)){const x=E;E=R,R=x}}if(m!==v.outputColorSpace||h!==v.toneMapping){m=v.outputColorSpace,h=v.toneMapping,c.defines={},He.getTransfer(m)===Ze&&(c.defines.SRGB_TRANSFER="");const A=kf[h];A&&(c.defines[A]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=E.texture,v.setRenderTarget(S),v.render(l,f),S=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){r.dispose(),a.dispose(),o.dispose(),c.dispose()}}const hl=new bt,Zr=new bi(1,1),ul=new ko,fl=new cc,dl=new jo,oo=[],lo=[],co=new Float32Array(16),ho=new Float32Array(9),uo=new Float32Array(4);function ui(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=oo[s];if(r===void 0&&(r=new Float32Array(s),oo[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}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 dt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Ss(i,e){let t=lo[e];t===void 0&&(t=new Int32Array(e),lo[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Xf(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function qf(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),dt(t,e)}}function Yf(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),dt(t,e)}}function Kf(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),dt(t,e)}}function Zf(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;uo.set(n),i.uniformMatrix2fv(this.addr,!1,uo),dt(t,n)}}function $f(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;ho.set(n),i.uniformMatrix3fv(this.addr,!1,ho),dt(t,n)}}function jf(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;co.set(n),i.uniformMatrix4fv(this.addr,!1,co),dt(t,n)}}function Jf(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Qf(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),dt(t,e)}}function ed(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),dt(t,e)}}function td(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),dt(t,e)}}function nd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function id(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),dt(t,e)}}function sd(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),dt(t,e)}}function rd(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),dt(t,e)}}function ad(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Zr.compareFunction=t.isReversedDepthBuffer()?ra:sa,r=Zr):r=hl,t.setTexture2D(e||r,s)}function od(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||fl,s)}function ld(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||dl,s)}function cd(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||ul,s)}function hd(i){switch(i){case 5126:return Xf;case 35664:return qf;case 35665:return Yf;case 35666:return Kf;case 35674:return Zf;case 35675:return $f;case 35676:return jf;case 5124:case 35670:return Jf;case 35667:case 35671:return Qf;case 35668:case 35672:return ed;case 35669:case 35673:return td;case 5125:return nd;case 36294:return id;case 36295:return sd;case 36296:return rd;case 35678:case 36198:case 36298:case 36306:case 35682:return ad;case 35679:case 36299:case 36307:return od;case 35680:case 36300:case 36308:case 36293:return ld;case 36289:case 36303:case 36311:case 36292:return cd}}function ud(i,e){i.uniform1fv(this.addr,e)}function fd(i,e){const t=ui(e,this.size,2);i.uniform2fv(this.addr,t)}function dd(i,e){const t=ui(e,this.size,3);i.uniform3fv(this.addr,t)}function pd(i,e){const t=ui(e,this.size,4);i.uniform4fv(this.addr,t)}function md(i,e){const t=ui(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function _d(i,e){const t=ui(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function gd(i,e){const t=ui(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function xd(i,e){i.uniform1iv(this.addr,e)}function vd(i,e){i.uniform2iv(this.addr,e)}function Md(i,e){i.uniform3iv(this.addr,e)}function Sd(i,e){i.uniform4iv(this.addr,e)}function Ed(i,e){i.uniform1uiv(this.addr,e)}function yd(i,e){i.uniform2uiv(this.addr,e)}function Td(i,e){i.uniform3uiv(this.addr,e)}function bd(i,e){i.uniform4uiv(this.addr,e)}function Ad(i,e,t){const n=this.cache,s=e.length,r=Ss(t,s);ft(n,r)||(i.uniform1iv(this.addr,r),dt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=Zr:a=hl;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function Rd(i,e,t){const n=this.cache,s=e.length,r=Ss(t,s);ft(n,r)||(i.uniform1iv(this.addr,r),dt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||fl,r[a])}function wd(i,e,t){const n=this.cache,s=e.length,r=Ss(t,s);ft(n,r)||(i.uniform1iv(this.addr,r),dt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||dl,r[a])}function Cd(i,e,t){const n=this.cache,s=e.length,r=Ss(t,s);ft(n,r)||(i.uniform1iv(this.addr,r),dt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||ul,r[a])}function Pd(i){switch(i){case 5126:return ud;case 35664:return fd;case 35665:return dd;case 35666:return pd;case 35674:return md;case 35675:return _d;case 35676:return gd;case 5124:case 35670:return xd;case 35667:case 35671:return vd;case 35668:case 35672:return Md;case 35669:case 35673:return Sd;case 5125:return Ed;case 36294:return yd;case 36295:return Td;case 36296:return bd;case 35678:case 36198:case 36298:case 36306:case 35682:return Ad;case 35679:case 36299:case 36307:return Rd;case 35680:case 36300:case 36308:case 36293:return wd;case 36289:case 36303:case 36311:case 36292:return Cd}}class Dd{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=hd(t.type)}}class Ld{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Pd(t.type)}}class Id{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const nr=/(\w+)(\])?(\[|\.)?/g;function fo(i,e){i.seq.push(e),i.map[e.id]=e}function Ud(i,e,t){const n=i.name,s=n.length;for(nr.lastIndex=0;;){const r=nr.exec(n),a=nr.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){fo(t,l===void 0?new Dd(o,i,e):new Ld(o,i,e));break}else{let m=t.map[o];m===void 0&&(m=new Id(o),fo(t,m)),t=m}}}class us{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);Ud(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function po(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Nd=37297;let Fd=0;function Od(i,e){const t=i.split(`
3956
+ `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3957
+ `)}const mo=new Le;function Bd(i){He._getMatrix(mo,He.workingColorSpace,i);const e=`mat3( ${mo.elements.map(t=>t.toFixed(4))} )`;switch(He.getTransfer(i)){case fs:return[e,"LinearTransferOETF"];case Ze:return[e,"sRGBTransferOETF"];default:return Re("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function _o(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
3958
+
3959
+ `+r+`
3960
+
3961
+ `+Od(i.getShaderSource(e),o)}else return r}function zd(i,e){const t=Bd(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3962
+ `)}const Vd={[Ao]:"Linear",[Ro]:"Reinhard",[wo]:"Cineon",[Co]:"ACESFilmic",[Do]:"AgX",[Lo]:"Neutral",[Po]:"Custom"};function Gd(i,e){const t=Vd[e];return t===void 0?(Re("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ss=new U;function Hd(){He.getLuminanceCoefficients(ss);const i=ss.x.toFixed(4),e=ss.y.toFixed(4),t=ss.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3963
+ `)}function kd(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Si).join(`
3964
+ `)}function Wd(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3965
+ `)}function Xd(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Si(i){return i!==""}function go(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 xo(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const qd=/^[ \t]*#include +<([\w\d./]+)>/gm;function $r(i){return i.replace(qd,Kd)}const Yd=new Map;function Kd(i,e){let t=Ue[e];if(t===void 0){const n=Yd.get(e);if(n!==void 0)t=Ue[n],Re('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return $r(t)}const Zd=/#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 vo(i){return i.replace(Zd,$d)}function $d(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Mo(i){let e=`precision ${i.precision} float;
3966
+ precision ${i.precision} int;
3967
+ precision ${i.precision} sampler2D;
3968
+ precision ${i.precision} samplerCube;
3969
+ precision ${i.precision} sampler3D;
3970
+ precision ${i.precision} sampler2DArray;
3971
+ precision ${i.precision} sampler2DShadow;
3972
+ precision ${i.precision} samplerCubeShadow;
3973
+ precision ${i.precision} sampler2DArrayShadow;
3974
+ precision ${i.precision} isampler2D;
3975
+ precision ${i.precision} isampler3D;
3976
+ precision ${i.precision} isamplerCube;
3977
+ precision ${i.precision} isampler2DArray;
3978
+ precision ${i.precision} usampler2D;
3979
+ precision ${i.precision} usampler3D;
3980
+ precision ${i.precision} usamplerCube;
3981
+ precision ${i.precision} usampler2DArray;
3982
+ `;return i.precision==="highp"?e+=`
3983
+ #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3984
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3985
+ #define LOW_PRECISION`),e}const jd={[rs]:"SHADOWMAP_TYPE_PCF",[Mi]:"SHADOWMAP_TYPE_VSM"};function Jd(i){return jd[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const Qd={[Bn]:"ENVMAP_TYPE_CUBE",[ai]:"ENVMAP_TYPE_CUBE",[gs]:"ENVMAP_TYPE_CUBE_UV"};function ep(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":Qd[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const tp={[ai]:"ENVMAP_MODE_REFRACTION"};function np(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":tp[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const ip={[bo]:"ENVMAP_BLENDING_MULTIPLY",[Hl]:"ENVMAP_BLENDING_MIX",[kl]:"ENVMAP_BLENDING_ADD"};function sp(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":ip[i.combine]||"ENVMAP_BLENDING_NONE"}function rp(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),7*16)),texelHeight:n,maxMip:t}}function ap(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Jd(t),l=ep(t),f=np(t),m=sp(t),h=rp(t),p=kd(t),g=Wd(r),S=s.createProgram();let d,u,v=t.glslVersion?"#version "+t.glslVersion+`
3986
+ `:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Si).join(`
3987
+ `),d.length>0&&(d+=`
3988
+ `),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Si).join(`
3989
+ `),u.length>0&&(u+=`
3990
+ `)):(d=[Mo(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 "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3991
+ `].filter(Si).join(`
3992
+ `),u=[Mo(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 "+l:"",t.envMap?"#define "+f:"",t.envMap?"#define "+m:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.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?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Yt?"#define TONE_MAPPING":"",t.toneMapping!==Yt?Ue.tonemapping_pars_fragment:"",t.toneMapping!==Yt?Gd("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ue.colorspace_pars_fragment,zd("linearToOutputTexel",t.outputColorSpace),Hd(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3993
+ `].filter(Si).join(`
3994
+ `)),a=$r(a),a=go(a,t),a=xo(a,t),o=$r(o),o=go(o,t),o=xo(o,t),a=vo(a),o=vo(o),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
3995
+ `,d=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3996
+ `)+`
3997
+ `+d,u=["#define varying in",t.glslVersion===Ra?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ra?"":"#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(`
3998
+ `)+`
3999
+ `+u);const T=v+d+a,E=v+u+o,R=po(s,s.VERTEX_SHADER,T),A=po(s,s.FRAGMENT_SHADER,E);s.attachShader(S,R),s.attachShader(S,A),t.index0AttributeName!==void 0?s.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(S,0,"position"),s.linkProgram(S);function P(w){if(i.debug.checkShaderErrors){const N=s.getProgramInfoLog(S)||"",O=s.getShaderInfoLog(R)||"",k=s.getShaderInfoLog(A)||"",G=N.trim(),z=O.trim(),H=k.trim();let Q=!0,$=!0;if(s.getProgramParameter(S,s.LINK_STATUS)===!1)if(Q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,S,R,A);else{const ce=_o(s,R,"vertex"),pe=_o(s,A,"fragment");We("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(S,s.VALIDATE_STATUS)+`
4000
+
4001
+ Material Name: `+w.name+`
4002
+ Material Type: `+w.type+`
4003
+
4004
+ Program Info Log: `+G+`
4005
+ `+ce+`
4006
+ `+pe)}else G!==""?Re("WebGLProgram: Program Info Log:",G):(z===""||H==="")&&($=!1);$&&(w.diagnostics={runnable:Q,programLog:G,vertexShader:{log:z,prefix:d},fragmentShader:{log:H,prefix:u}})}s.deleteShader(R),s.deleteShader(A),x=new us(s,S),y=Xd(s,S)}let x;this.getUniforms=function(){return x===void 0&&P(this),x};let y;this.getAttributes=function(){return y===void 0&&P(this),y};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=s.getProgramParameter(S,Nd)),V},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Fd++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=R,this.fragmentShader=A,this}let op=0;class lp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 cp(e),t.set(e,n)),n}}class cp{constructor(e){this.id=op++,this.code=e,this.usedTimes=0}}function hp(i,e,t,n,s,r){const a=new Wo,o=new lp,c=new Set,l=[],f=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(x){return c.add(x),x===0?"uv":`uv${x}`}function S(x,y,V,w,N){const O=w.fog,k=N.geometry,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?w.environment:null,z=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,H=e.get(x.envMap||G,z),Q=H&&H.mapping===gs?H.image.height:null,$=p[x.type];x.precision!==null&&(h=n.getMaxPrecision(x.precision),h!==x.precision&&Re("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead."));const ce=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,pe=ce!==void 0?ce.length:0;let ue=0;k.morphAttributes.position!==void 0&&(ue=1),k.morphAttributes.normal!==void 0&&(ue=2),k.morphAttributes.color!==void 0&&(ue=3);let Ie,it,nt,K;if($){const Ke=Wt[$];Ie=Ke.vertexShader,it=Ke.fragmentShader}else Ie=x.vertexShader,it=x.fragmentShader,o.update(x),nt=o.getVertexShaderID(x),K=o.getFragmentShaderID(x);const ne=i.getRenderTarget(),re=i.state.buffers.depth.getReversed(),De=N.isInstancedMesh===!0,be=N.isBatchedMesh===!0,we=!!x.map,pt=!!x.matcap,Ge=!!H,Ye=!!x.aoMap,Je=!!x.lightMap,Fe=!!x.bumpMap,ot=!!x.normalMap,C=!!x.displacementMap,ct=!!x.emissiveMap,qe=!!x.metalnessMap,et=!!x.roughnessMap,Me=x.anisotropy>0,b=x.clearcoat>0,_=x.dispersion>0,L=x.iridescence>0,Y=x.sheen>0,Z=x.transmission>0,q=Me&&!!x.anisotropyMap,me=b&&!!x.clearcoatMap,ie=b&&!!x.clearcoatNormalMap,Te=b&&!!x.clearcoatRoughnessMap,Ae=L&&!!x.iridescenceMap,j=L&&!!x.iridescenceThicknessMap,ee=Y&&!!x.sheenColorMap,_e=Y&&!!x.sheenRoughnessMap,xe=!!x.specularMap,he=!!x.specularColorMap,Oe=!!x.specularIntensityMap,D=Z&&!!x.transmissionMap,se=Z&&!!x.thicknessMap,te=!!x.gradientMap,de=!!x.alphaMap,J=x.alphaTest>0,X=!!x.alphaHash,ge=!!x.extensions;let Ce=Yt;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(Ce=i.toneMapping);const tt={shaderID:$,shaderType:x.type,shaderName:x.name,vertexShader:Ie,fragmentShader:it,defines:x.defines,customVertexShaderID:nt,customFragmentShaderID:K,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:be,batchingColor:be&&N._colorsTexture!==null,instancing:De,instancingColor:De&&N.instanceColor!==null,instancingMorph:De&&N.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:li,alphaToCoverage:!!x.alphaToCoverage,map:we,matcap:pt,envMap:Ge,envMapMode:Ge&&H.mapping,envMapCubeUVHeight:Q,aoMap:Ye,lightMap:Je,bumpMap:Fe,normalMap:ot,displacementMap:C,emissiveMap:ct,normalMapObjectSpace:ot&&x.normalMapType===ql,normalMapTangentSpace:ot&&x.normalMapType===Go,metalnessMap:qe,roughnessMap:et,anisotropy:Me,anisotropyMap:q,clearcoat:b,clearcoatMap:me,clearcoatNormalMap:ie,clearcoatRoughnessMap:Te,dispersion:_,iridescence:L,iridescenceMap:Ae,iridescenceThicknessMap:j,sheen:Y,sheenColorMap:ee,sheenRoughnessMap:_e,specularMap:xe,specularColorMap:he,specularIntensityMap:Oe,transmission:Z,transmissionMap:D,thicknessMap:se,gradientMap:te,opaque:x.transparent===!1&&x.blending===ii&&x.alphaToCoverage===!1,alphaMap:de,alphaTest:J,alphaHash:X,combine:x.combine,mapUv:we&&g(x.map.channel),aoMapUv:Ye&&g(x.aoMap.channel),lightMapUv:Je&&g(x.lightMap.channel),bumpMapUv:Fe&&g(x.bumpMap.channel),normalMapUv:ot&&g(x.normalMap.channel),displacementMapUv:C&&g(x.displacementMap.channel),emissiveMapUv:ct&&g(x.emissiveMap.channel),metalnessMapUv:qe&&g(x.metalnessMap.channel),roughnessMapUv:et&&g(x.roughnessMap.channel),anisotropyMapUv:q&&g(x.anisotropyMap.channel),clearcoatMapUv:me&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:ie&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:j&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:ee&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:_e&&g(x.sheenRoughnessMap.channel),specularMapUv:xe&&g(x.specularMap.channel),specularColorMapUv:he&&g(x.specularColorMap.channel),specularIntensityMapUv:Oe&&g(x.specularIntensityMap.channel),transmissionMapUv:D&&g(x.transmissionMap.channel),thicknessMapUv:se&&g(x.thicknessMap.channel),alphaMapUv:de&&g(x.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(ot||Me),vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!k.attributes.uv&&(we||de),fog:!!O,useFog:x.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||k.attributes.normal===void 0&&ot===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:re,skinning:N.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:pe,morphTextureStride:ue,numDirLights:y.directional.length,numPointLights:y.point.length,numSpotLights:y.spot.length,numSpotLightMaps:y.spotLightMap.length,numRectAreaLights:y.rectArea.length,numHemiLights:y.hemi.length,numDirLightShadows:y.directionalShadowMap.length,numPointLightShadows:y.pointShadowMap.length,numSpotLightShadows:y.spotShadowMap.length,numSpotLightShadowsWithMaps:y.numSpotLightShadowsWithMaps,numLightProbes:y.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&V.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ce,decodeVideoTexture:we&&x.map.isVideoTexture===!0&&He.getTransfer(x.map.colorSpace)===Ze,decodeVideoTextureEmissive:ct&&x.emissiveMap.isVideoTexture===!0&&He.getTransfer(x.emissiveMap.colorSpace)===Ze,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===on,flipSided:x.side===Rt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ge&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&x.extensions.multiDraw===!0||be)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return tt.vertexUv1s=c.has(1),tt.vertexUv2s=c.has(2),tt.vertexUv3s=c.has(3),c.clear(),tt}function d(x){const y=[];if(x.shaderID?y.push(x.shaderID):(y.push(x.customVertexShaderID),y.push(x.customFragmentShaderID)),x.defines!==void 0)for(const V in x.defines)y.push(V),y.push(x.defines[V]);return x.isRawShaderMaterial===!1&&(u(y,x),v(y,x),y.push(i.outputColorSpace)),y.push(x.customProgramCacheKey),y.join()}function u(x,y){x.push(y.precision),x.push(y.outputColorSpace),x.push(y.envMapMode),x.push(y.envMapCubeUVHeight),x.push(y.mapUv),x.push(y.alphaMapUv),x.push(y.lightMapUv),x.push(y.aoMapUv),x.push(y.bumpMapUv),x.push(y.normalMapUv),x.push(y.displacementMapUv),x.push(y.emissiveMapUv),x.push(y.metalnessMapUv),x.push(y.roughnessMapUv),x.push(y.anisotropyMapUv),x.push(y.clearcoatMapUv),x.push(y.clearcoatNormalMapUv),x.push(y.clearcoatRoughnessMapUv),x.push(y.iridescenceMapUv),x.push(y.iridescenceThicknessMapUv),x.push(y.sheenColorMapUv),x.push(y.sheenRoughnessMapUv),x.push(y.specularMapUv),x.push(y.specularColorMapUv),x.push(y.specularIntensityMapUv),x.push(y.transmissionMapUv),x.push(y.thicknessMapUv),x.push(y.combine),x.push(y.fogExp2),x.push(y.sizeAttenuation),x.push(y.morphTargetsCount),x.push(y.morphAttributeCount),x.push(y.numDirLights),x.push(y.numPointLights),x.push(y.numSpotLights),x.push(y.numSpotLightMaps),x.push(y.numHemiLights),x.push(y.numRectAreaLights),x.push(y.numDirLightShadows),x.push(y.numPointLightShadows),x.push(y.numSpotLightShadows),x.push(y.numSpotLightShadowsWithMaps),x.push(y.numLightProbes),x.push(y.shadowMapType),x.push(y.toneMapping),x.push(y.numClippingPlanes),x.push(y.numClipIntersection),x.push(y.depthPacking)}function v(x,y){a.disableAll(),y.instancing&&a.enable(0),y.instancingColor&&a.enable(1),y.instancingMorph&&a.enable(2),y.matcap&&a.enable(3),y.envMap&&a.enable(4),y.normalMapObjectSpace&&a.enable(5),y.normalMapTangentSpace&&a.enable(6),y.clearcoat&&a.enable(7),y.iridescence&&a.enable(8),y.alphaTest&&a.enable(9),y.vertexColors&&a.enable(10),y.vertexAlphas&&a.enable(11),y.vertexUv1s&&a.enable(12),y.vertexUv2s&&a.enable(13),y.vertexUv3s&&a.enable(14),y.vertexTangents&&a.enable(15),y.anisotropy&&a.enable(16),y.alphaHash&&a.enable(17),y.batching&&a.enable(18),y.dispersion&&a.enable(19),y.batchingColor&&a.enable(20),y.gradientMap&&a.enable(21),x.push(a.mask),a.disableAll(),y.fog&&a.enable(0),y.useFog&&a.enable(1),y.flatShading&&a.enable(2),y.logarithmicDepthBuffer&&a.enable(3),y.reversedDepthBuffer&&a.enable(4),y.skinning&&a.enable(5),y.morphTargets&&a.enable(6),y.morphNormals&&a.enable(7),y.morphColors&&a.enable(8),y.premultipliedAlpha&&a.enable(9),y.shadowMapEnabled&&a.enable(10),y.doubleSided&&a.enable(11),y.flipSided&&a.enable(12),y.useDepthPacking&&a.enable(13),y.dithering&&a.enable(14),y.transmission&&a.enable(15),y.sheen&&a.enable(16),y.opaque&&a.enable(17),y.pointsUvs&&a.enable(18),y.decodeVideoTexture&&a.enable(19),y.decodeVideoTextureEmissive&&a.enable(20),y.alphaToCoverage&&a.enable(21),x.push(a.mask)}function T(x){const y=p[x.type];let V;if(y){const w=Wt[y];V=Dc.clone(w.uniforms)}else V=x.uniforms;return V}function E(x,y){let V=f.get(y);return V!==void 0?++V.usedTimes:(V=new ap(i,y,x,s),l.push(V),f.set(y,V)),V}function R(x){if(--x.usedTimes===0){const y=l.indexOf(x);l[y]=l[l.length-1],l.pop(),f.delete(x.cacheKey),x.destroy()}}function A(x){o.remove(x)}function P(){o.dispose()}return{getParameters:S,getProgramCacheKey:d,getUniforms:T,acquireProgram:E,releaseProgram:R,releaseShaderCache:A,programs:l,dispose:P}}function up(){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 s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function fp(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function So(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 Eo(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(h){let p=0;return h.isInstancedMesh&&(p+=2),h.isSkinnedMesh&&(p+=1),p}function o(h,p,g,S,d,u){let v=i[e];return v===void 0?(v={id:h.id,object:h,geometry:p,material:g,materialVariant:a(h),groupOrder:S,renderOrder:h.renderOrder,z:d,group:u},i[e]=v):(v.id=h.id,v.object=h,v.geometry=p,v.material=g,v.materialVariant=a(h),v.groupOrder=S,v.renderOrder=h.renderOrder,v.z=d,v.group=u),e++,v}function c(h,p,g,S,d,u){const v=o(h,p,g,S,d,u);g.transmission>0?n.push(v):g.transparent===!0?s.push(v):t.push(v)}function l(h,p,g,S,d,u){const v=o(h,p,g,S,d,u);g.transmission>0?n.unshift(v):g.transparent===!0?s.unshift(v):t.unshift(v)}function f(h,p){t.length>1&&t.sort(h||fp),n.length>1&&n.sort(p||So),s.length>1&&s.sort(p||So)}function m(){for(let h=e,p=i.length;h<p;h++){const g=i[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:m,sort:f}}function dp(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Eo,i.set(n,[a])):s>=r.length?(a=new Eo,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function pp(){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 U,color:new Ne};break;case"SpotLight":t={position:new U,direction:new U,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function mp(){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 Ve};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _p=0;function gp(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xp(i){const e=new pp,t=mp(),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 l=0;l<9;l++)n.probe.push(new U);const s=new U,r=new st,a=new st;function o(l){let f=0,m=0,h=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let p=0,g=0,S=0,d=0,u=0,v=0,T=0,E=0,R=0,A=0,P=0;l.sort(gp);for(let y=0,V=l.length;y<V;y++){const w=l[y],N=w.color,O=w.intensity,k=w.distance;let G=null;if(w.shadow&&w.shadow.map&&(w.shadow.map.texture.format===oi?G=w.shadow.map.texture:G=w.shadow.map.depthTexture||w.shadow.map.texture),w.isAmbientLight)f+=N.r*O,m+=N.g*O,h+=N.b*O;else if(w.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(w.sh.coefficients[z],O);P++}else if(w.isDirectionalLight){const z=e.get(w);if(z.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const H=w.shadow,Q=t.get(w);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,n.directionalShadow[p]=Q,n.directionalShadowMap[p]=G,n.directionalShadowMatrix[p]=w.shadow.matrix,v++}n.directional[p]=z,p++}else if(w.isSpotLight){const z=e.get(w);z.position.setFromMatrixPosition(w.matrixWorld),z.color.copy(N).multiplyScalar(O),z.distance=k,z.coneCos=Math.cos(w.angle),z.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),z.decay=w.decay,n.spot[S]=z;const H=w.shadow;if(w.map&&(n.spotLightMap[R]=w.map,R++,H.updateMatrices(w),w.castShadow&&A++),n.spotLightMatrix[S]=H.matrix,w.castShadow){const Q=t.get(w);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,n.spotShadow[S]=Q,n.spotShadowMap[S]=G,E++}S++}else if(w.isRectAreaLight){const z=e.get(w);z.color.copy(N).multiplyScalar(O),z.halfWidth.set(w.width*.5,0,0),z.halfHeight.set(0,w.height*.5,0),n.rectArea[d]=z,d++}else if(w.isPointLight){const z=e.get(w);if(z.color.copy(w.color).multiplyScalar(w.intensity),z.distance=w.distance,z.decay=w.decay,w.castShadow){const H=w.shadow,Q=t.get(w);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,Q.shadowCameraNear=H.camera.near,Q.shadowCameraFar=H.camera.far,n.pointShadow[g]=Q,n.pointShadowMap[g]=G,n.pointShadowMatrix[g]=w.shadow.matrix,T++}n.point[g]=z,g++}else if(w.isHemisphereLight){const z=e.get(w);z.skyColor.copy(w.color).multiplyScalar(O),z.groundColor.copy(w.groundColor).multiplyScalar(O),n.hemi[u]=z,u++}}d>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]=m,n.ambient[2]=h;const x=n.hash;(x.directionalLength!==p||x.pointLength!==g||x.spotLength!==S||x.rectAreaLength!==d||x.hemiLength!==u||x.numDirectionalShadows!==v||x.numPointShadows!==T||x.numSpotShadows!==E||x.numSpotMaps!==R||x.numLightProbes!==P)&&(n.directional.length=p,n.spot.length=S,n.rectArea.length=d,n.point.length=g,n.hemi.length=u,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=E,n.spotShadowMap.length=E,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=E+R-A,n.spotLightMap.length=R,n.numSpotLightShadowsWithMaps=A,n.numLightProbes=P,x.directionalLength=p,x.pointLength=g,x.spotLength=S,x.rectAreaLength=d,x.hemiLength=u,x.numDirectionalShadows=v,x.numPointShadows=T,x.numSpotShadows=E,x.numSpotMaps=R,x.numLightProbes=P,n.version=_p++)}function c(l,f){let m=0,h=0,p=0,g=0,S=0;const d=f.matrixWorldInverse;for(let u=0,v=l.length;u<v;u++){const T=l[u];if(T.isDirectionalLight){const E=n.directional[m];E.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),m++}else if(T.isSpotLight){const E=n.spot[p];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(d),E.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),p++}else if(T.isRectAreaLight){const E=n.rectArea[g];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(d),a.identity(),r.copy(T.matrixWorld),r.premultiply(d),a.extractRotation(r),E.halfWidth.set(T.width*.5,0,0),E.halfHeight.set(0,T.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),g++}else if(T.isPointLight){const E=n.point[h];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(d),h++}else if(T.isHemisphereLight){const E=n.hemi[S];E.direction.setFromMatrixPosition(T.matrixWorld),E.direction.transformDirection(d),S++}}}return{setup:o,setupView:c,state:n}}function yo(i){const e=new xp(i),t=[],n=[];function s(f){l.camera=f,t.length=0,n.length=0}function r(f){t.push(f)}function a(f){n.push(f)}function o(){e.setup(t)}function c(f){e.setupView(t,f)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:l,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:a}}function vp(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new yo(i),e.set(s,[o])):r>=a.length?(o=new yo(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Mp=`void main() {
4007
+ gl_Position = vec4( position, 1.0 );
4008
+ }`,Sp=`uniform sampler2D shadow_pass;
4009
+ uniform vec2 resolution;
4010
+ uniform float radius;
4011
+ void main() {
4012
+ const float samples = float( VSM_SAMPLES );
4013
+ float mean = 0.0;
4014
+ float squared_mean = 0.0;
4015
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
4016
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
4017
+ for ( float i = 0.0; i < samples; i ++ ) {
4018
+ float uvOffset = uvStart + i * uvStride;
4019
+ #ifdef HORIZONTAL_PASS
4020
+ vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
4021
+ mean += distribution.x;
4022
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
4023
+ #else
4024
+ float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
4025
+ mean += depth;
4026
+ squared_mean += depth * depth;
4027
+ #endif
4028
+ }
4029
+ mean = mean / samples;
4030
+ squared_mean = squared_mean / samples;
4031
+ float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4032
+ gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4033
+ }`,Ep=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],yp=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],To=new st,vi=new U,ir=new U;function Tp(i,e,t){let n=new la;const s=new Ve,r=new Ve,a=new at,o=new Fc,c=new Oc,l={},f=t.maxTextureSize,m={[Tn]:Rt,[Rt]:Tn,[on]:on},h=new Jt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:Mp,fragmentShader:Sp}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const g=new gt;g.setAttribute("position",new Zt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new dn(g,h),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rs;let u=this.type;this.render=function(A,P,x){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||A.length===0)return;this.type===yl&&(Re("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=rs);const y=i.getRenderTarget(),V=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),N=i.state;N.setBlending(cn),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const O=u!==this.type;O&&P.traverse(function(k){k.material&&(Array.isArray(k.material)?k.material.forEach(G=>G.needsUpdate=!0):k.material.needsUpdate=!0)});for(let k=0,G=A.length;k<G;k++){const z=A[k],H=z.shadow;if(H===void 0){Re("WebGLShadowMap:",z,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);const Q=H.getFrameExtents();s.multiply(Q),r.copy(H.mapSize),(s.x>f||s.y>f)&&(s.x>f&&(r.x=Math.floor(f/Q.x),s.x=r.x*Q.x,H.mapSize.x=r.x),s.y>f&&(r.y=Math.floor(f/Q.y),s.y=r.y*Q.y,H.mapSize.y=r.y));const $=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=$,H.map===null||O===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===Mi){if(z.isPointLight){Re("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Kt(s.x,s.y,{format:oi,type:un,minFilter:yt,magFilter:yt,generateMipmaps:!1}),H.map.texture.name=z.name+".shadowMap",H.map.depthTexture=new bi(s.x,s.y,Xt),H.map.depthTexture.name=z.name+".shadowMapDepth",H.map.depthTexture.format=fn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=vt,H.map.depthTexture.magFilter=vt}else z.isPointLight?(H.map=new cl(s.x),H.map.depthTexture=new Cc(s.x,$t)):(H.map=new Kt(s.x,s.y),H.map.depthTexture=new bi(s.x,s.y,$t)),H.map.depthTexture.name=z.name+".shadowMap",H.map.depthTexture.format=fn,this.type===rs?(H.map.depthTexture.compareFunction=$?ra:sa,H.map.depthTexture.minFilter=yt,H.map.depthTexture.magFilter=yt):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=vt,H.map.depthTexture.magFilter=vt);H.camera.updateProjectionMatrix()}const ce=H.map.isWebGLCubeRenderTarget?6:1;for(let pe=0;pe<ce;pe++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,pe),i.clear();else{pe===0&&(i.setRenderTarget(H.map),i.clear());const ue=H.getViewport(pe);a.set(r.x*ue.x,r.y*ue.y,r.x*ue.z,r.y*ue.w),N.viewport(a)}if(z.isPointLight){const ue=H.camera,Ie=H.matrix,it=z.distance||ue.far;it!==ue.far&&(ue.far=it,ue.updateProjectionMatrix()),vi.setFromMatrixPosition(z.matrixWorld),ue.position.copy(vi),ir.copy(ue.position),ir.add(Ep[pe]),ue.up.copy(yp[pe]),ue.lookAt(ir),ue.updateMatrixWorld(),Ie.makeTranslation(-vi.x,-vi.y,-vi.z),To.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),H._frustum.setFromProjectionMatrix(To,ue.coordinateSystem,ue.reversedDepth)}else H.updateMatrices(z);n=H.getFrustum(),E(P,x,H.camera,z,this.type)}H.isPointLightShadow!==!0&&this.type===Mi&&v(H,x),H.needsUpdate=!1}u=this.type,d.needsUpdate=!1,i.setRenderTarget(y,V,w)};function v(A,P){const x=e.update(S);h.defines.VSM_SAMPLES!==A.blurSamples&&(h.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Kt(s.x,s.y,{format:oi,type:un})),h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value=A.mapSize,h.uniforms.radius.value=A.radius,i.setRenderTarget(A.mapPass),i.clear(),i.renderBufferDirect(P,null,x,h,S,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,i.setRenderTarget(A.map),i.clear(),i.renderBufferDirect(P,null,x,p,S,null)}function T(A,P,x,y){let V=null;const w=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(w!==void 0)V=w;else if(V=x.isPointLight===!0?c: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 N=V.uuid,O=P.uuid;let k=l[N];k===void 0&&(k={},l[N]=k);let G=k[O];G===void 0&&(G=V.clone(),k[O]=G,P.addEventListener("dispose",R)),V=G}if(V.visible=P.visible,V.wireframe=P.wireframe,y===Mi?V.side=P.shadowSide!==null?P.shadowSide:P.side:V.side=P.shadowSide!==null?P.shadowSide:m[P.side],V.alphaMap=P.alphaMap,V.alphaTest=P.alphaToCoverage===!0?.5:P.alphaTest,V.map=P.map,V.clipShadows=P.clipShadows,V.clippingPlanes=P.clippingPlanes,V.clipIntersection=P.clipIntersection,V.displacementMap=P.displacementMap,V.displacementScale=P.displacementScale,V.displacementBias=P.displacementBias,V.wireframeLinewidth=P.wireframeLinewidth,V.linewidth=P.linewidth,x.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const N=i.properties.get(V);N.light=x}return V}function E(A,P,x,y,V){if(A.visible===!1)return;if(A.layers.test(P.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&V===Mi)&&(!A.frustumCulled||n.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);const O=e.update(A),k=A.material;if(Array.isArray(k)){const G=O.groups;for(let z=0,H=G.length;z<H;z++){const Q=G[z],$=k[Q.materialIndex];if($&&$.visible){const ce=T(A,$,y,V);A.onBeforeShadow(i,A,P,x,O,ce,Q),i.renderBufferDirect(x,null,O,ce,A,Q),A.onAfterShadow(i,A,P,x,O,ce,Q)}}}else if(k.visible){const G=T(A,k,y,V);A.onBeforeShadow(i,A,P,x,O,G,null),i.renderBufferDirect(x,null,O,G,A,null),A.onAfterShadow(i,A,P,x,O,G,null)}}const N=A.children;for(let O=0,k=N.length;O<k;O++)E(N[O],P,x,y,V)}function R(A){A.target.removeEventListener("dispose",R);for(const x in l){const y=l[x],V=A.target.uuid;V in y&&(y[V].dispose(),delete y[V])}}}function bp(i,e){function t(){let D=!1;const se=new at;let te=null;const de=new at(0,0,0,0);return{setMask:function(J){te!==J&&!D&&(i.colorMask(J,J,J,J),te=J)},setLocked:function(J){D=J},setClear:function(J,X,ge,Ce,tt){tt===!0&&(J*=Ce,X*=Ce,ge*=Ce),se.set(J,X,ge,Ce),de.equals(se)===!1&&(i.clearColor(J,X,ge,Ce),de.copy(se))},reset:function(){D=!1,te=null,de.set(-1,0,0,0)}}}function n(){let D=!1,se=!1,te=null,de=null,J=null;return{setReversed:function(X){if(se!==X){const ge=e.get("EXT_clip_control");X?ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.ZERO_TO_ONE_EXT):ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.NEGATIVE_ONE_TO_ONE_EXT),se=X;const Ce=J;J=null,this.setClear(Ce)}},getReversed:function(){return se},setTest:function(X){X?ne(i.DEPTH_TEST):re(i.DEPTH_TEST)},setMask:function(X){te!==X&&!D&&(i.depthMask(X),te=X)},setFunc:function(X){if(se&&(X=nc[X]),de!==X){switch(X){case ar:i.depthFunc(i.NEVER);break;case or:i.depthFunc(i.ALWAYS);break;case lr:i.depthFunc(i.LESS);break;case ri:i.depthFunc(i.LEQUAL);break;case cr:i.depthFunc(i.EQUAL);break;case hr:i.depthFunc(i.GEQUAL);break;case ur:i.depthFunc(i.GREATER);break;case fr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}de=X}},setLocked:function(X){D=X},setClear:function(X){J!==X&&(J=X,se&&(X=1-X),i.clearDepth(X))},reset:function(){D=!1,te=null,de=null,J=null,se=!1}}}function s(){let D=!1,se=null,te=null,de=null,J=null,X=null,ge=null,Ce=null,tt=null;return{setTest:function(Ke){D||(Ke?ne(i.STENCIL_TEST):re(i.STENCIL_TEST))},setMask:function(Ke){se!==Ke&&!D&&(i.stencilMask(Ke),se=Ke)},setFunc:function(Ke,Qt,en){(te!==Ke||de!==Qt||J!==en)&&(i.stencilFunc(Ke,Qt,en),te=Ke,de=Qt,J=en)},setOp:function(Ke,Qt,en){(X!==Ke||ge!==Qt||Ce!==en)&&(i.stencilOp(Ke,Qt,en),X=Ke,ge=Qt,Ce=en)},setLocked:function(Ke){D=Ke},setClear:function(Ke){tt!==Ke&&(i.clearStencil(Ke),tt=Ke)},reset:function(){D=!1,se=null,te=null,de=null,J=null,X=null,ge=null,Ce=null,tt=null}}}const r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let f={},m={},h=new WeakMap,p=[],g=null,S=!1,d=null,u=null,v=null,T=null,E=null,R=null,A=null,P=new Ne(0,0,0),x=0,y=!1,V=null,w=null,N=null,O=null,k=null;const G=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let z=!1,H=0;const Q=i.getParameter(i.VERSION);Q.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(Q)[1]),z=H>=1):Q.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),z=H>=2);let $=null,ce={};const pe=i.getParameter(i.SCISSOR_BOX),ue=i.getParameter(i.VIEWPORT),Ie=new at().fromArray(pe),it=new at().fromArray(ue);function nt(D,se,te,de){const J=new Uint8Array(4),X=i.createTexture();i.bindTexture(D,X),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ge=0;ge<te;ge++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(se,0,i.RGBA,1,1,de,0,i.RGBA,i.UNSIGNED_BYTE,J):i.texImage2D(se+ge,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,J);return X}const K={};K[i.TEXTURE_2D]=nt(i.TEXTURE_2D,i.TEXTURE_2D,1),K[i.TEXTURE_CUBE_MAP]=nt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[i.TEXTURE_2D_ARRAY]=nt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),K[i.TEXTURE_3D]=nt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(ri),Fe(!1),ot(Sa),ne(i.CULL_FACE),Ye(cn);function ne(D){f[D]!==!0&&(i.enable(D),f[D]=!0)}function re(D){f[D]!==!1&&(i.disable(D),f[D]=!1)}function De(D,se){return m[D]!==se?(i.bindFramebuffer(D,se),m[D]=se,D===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=se),D===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=se),!0):!1}function be(D,se){let te=p,de=!1;if(D){te=h.get(se),te===void 0&&(te=[],h.set(se,te));const J=D.textures;if(te.length!==J.length||te[0]!==i.COLOR_ATTACHMENT0){for(let X=0,ge=J.length;X<ge;X++)te[X]=i.COLOR_ATTACHMENT0+X;te.length=J.length,de=!0}}else te[0]!==i.BACK&&(te[0]=i.BACK,de=!0);de&&i.drawBuffers(te)}function we(D){return g!==D?(i.useProgram(D),g=D,!0):!1}const pt={[Un]:i.FUNC_ADD,[bl]:i.FUNC_SUBTRACT,[Al]:i.FUNC_REVERSE_SUBTRACT};pt[Rl]=i.MIN,pt[wl]=i.MAX;const Ge={[Cl]:i.ZERO,[Pl]:i.ONE,[Dl]:i.SRC_COLOR,[sr]:i.SRC_ALPHA,[Ol]:i.SRC_ALPHA_SATURATE,[Nl]:i.DST_COLOR,[Il]:i.DST_ALPHA,[Ll]:i.ONE_MINUS_SRC_COLOR,[rr]:i.ONE_MINUS_SRC_ALPHA,[Fl]:i.ONE_MINUS_DST_COLOR,[Ul]:i.ONE_MINUS_DST_ALPHA,[Bl]:i.CONSTANT_COLOR,[zl]:i.ONE_MINUS_CONSTANT_COLOR,[Vl]:i.CONSTANT_ALPHA,[Gl]:i.ONE_MINUS_CONSTANT_ALPHA};function Ye(D,se,te,de,J,X,ge,Ce,tt,Ke){if(D===cn){S===!0&&(re(i.BLEND),S=!1);return}if(S===!1&&(ne(i.BLEND),S=!0),D!==Tl){if(D!==d||Ke!==y){if((u!==Un||E!==Un)&&(i.blendEquation(i.FUNC_ADD),u=Un,E=Un),Ke)switch(D){case ii:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ea:i.blendFunc(i.ONE,i.ONE);break;case ya:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ta:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:We("WebGLState: Invalid blending: ",D);break}else switch(D){case ii:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ea:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ya:We("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ta:We("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:We("WebGLState: Invalid blending: ",D);break}v=null,T=null,R=null,A=null,P.set(0,0,0),x=0,d=D,y=Ke}return}J=J||se,X=X||te,ge=ge||de,(se!==u||J!==E)&&(i.blendEquationSeparate(pt[se],pt[J]),u=se,E=J),(te!==v||de!==T||X!==R||ge!==A)&&(i.blendFuncSeparate(Ge[te],Ge[de],Ge[X],Ge[ge]),v=te,T=de,R=X,A=ge),(Ce.equals(P)===!1||tt!==x)&&(i.blendColor(Ce.r,Ce.g,Ce.b,tt),P.copy(Ce),x=tt),d=D,y=!1}function Je(D,se){D.side===on?re(i.CULL_FACE):ne(i.CULL_FACE);let te=D.side===Rt;se&&(te=!te),Fe(te),D.blending===ii&&D.transparent===!1?Ye(cn):Ye(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),r.setMask(D.colorWrite);const de=D.stencilWrite;o.setTest(de),de&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),ct(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):re(i.SAMPLE_ALPHA_TO_COVERAGE)}function Fe(D){V!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),V=D)}function ot(D){D!==Sl?(ne(i.CULL_FACE),D!==w&&(D===Sa?i.cullFace(i.BACK):D===El?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):re(i.CULL_FACE),w=D}function C(D){D!==N&&(z&&i.lineWidth(D),N=D)}function ct(D,se,te){D?(ne(i.POLYGON_OFFSET_FILL),(O!==se||k!==te)&&(O=se,k=te,a.getReversed()&&(se=-se),i.polygonOffset(se,te))):re(i.POLYGON_OFFSET_FILL)}function qe(D){D?ne(i.SCISSOR_TEST):re(i.SCISSOR_TEST)}function et(D){D===void 0&&(D=i.TEXTURE0+G-1),$!==D&&(i.activeTexture(D),$=D)}function Me(D,se,te){te===void 0&&($===null?te=i.TEXTURE0+G-1:te=$);let de=ce[te];de===void 0&&(de={type:void 0,texture:void 0},ce[te]=de),(de.type!==D||de.texture!==se)&&($!==te&&(i.activeTexture(te),$=te),i.bindTexture(D,se||K[D]),de.type=D,de.texture=se)}function b(){const D=ce[$];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function _(){try{i.compressedTexImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function L(){try{i.compressedTexImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function Y(){try{i.texSubImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function Z(){try{i.texSubImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function q(){try{i.compressedTexSubImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function me(){try{i.compressedTexSubImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function ie(){try{i.texStorage2D(...arguments)}catch(D){We("WebGLState:",D)}}function Te(){try{i.texStorage3D(...arguments)}catch(D){We("WebGLState:",D)}}function Ae(){try{i.texImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function j(){try{i.texImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function ee(D){Ie.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),Ie.copy(D))}function _e(D){it.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),it.copy(D))}function xe(D,se){let te=l.get(se);te===void 0&&(te=new WeakMap,l.set(se,te));let de=te.get(D);de===void 0&&(de=i.getUniformBlockIndex(se,D.name),te.set(D,de))}function he(D,se){const de=l.get(se).get(D);c.get(se)!==de&&(i.uniformBlockBinding(se,de,D.__bindingPointIndex),c.set(se,de))}function Oe(){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={},$=null,ce={},m={},h=new WeakMap,p=[],g=null,S=!1,d=null,u=null,v=null,T=null,E=null,R=null,A=null,P=new Ne(0,0,0),x=0,y=!1,V=null,w=null,N=null,O=null,k=null,Ie.set(0,0,i.canvas.width,i.canvas.height),it.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:re,bindFramebuffer:De,drawBuffers:be,useProgram:we,setBlending:Ye,setMaterial:Je,setFlipSided:Fe,setCullFace:ot,setLineWidth:C,setPolygonOffset:ct,setScissorTest:qe,activeTexture:et,bindTexture:Me,unbindTexture:b,compressedTexImage2D:_,compressedTexImage3D:L,texImage2D:Ae,texImage3D:j,updateUBOMapping:xe,uniformBlockBinding:he,texStorage2D:ie,texStorage3D:Te,texSubImage2D:Y,texSubImage3D:Z,compressedTexSubImage2D:q,compressedTexSubImage3D:me,scissor:ee,viewport:_e,reset:Oe}}function Ap(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ve,f=new WeakMap;let m;const h=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(b,_){return p?new OffscreenCanvas(b,_):ds("canvas")}function S(b,_,L){let Y=1;const Z=Me(b);if((Z.width>L||Z.height>L)&&(Y=L/Math.max(Z.width,Z.height)),Y<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 q=Math.floor(Y*Z.width),me=Math.floor(Y*Z.height);m===void 0&&(m=g(q,me));const ie=_?g(q,me):m;return ie.width=q,ie.height=me,ie.getContext("2d").drawImage(b,0,0,q,me),Re("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+q+"x"+me+")."),ie}else return"data"in b&&Re("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),b;return b}function d(b){return b.generateMipmaps}function u(b){i.generateMipmap(b)}function v(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 T(b,_,L,Y,Z=!1){if(b!==null){if(i[b]!==void 0)return i[b];Re("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let q=_;if(_===i.RED&&(L===i.FLOAT&&(q=i.R32F),L===i.HALF_FLOAT&&(q=i.R16F),L===i.UNSIGNED_BYTE&&(q=i.R8)),_===i.RED_INTEGER&&(L===i.UNSIGNED_BYTE&&(q=i.R8UI),L===i.UNSIGNED_SHORT&&(q=i.R16UI),L===i.UNSIGNED_INT&&(q=i.R32UI),L===i.BYTE&&(q=i.R8I),L===i.SHORT&&(q=i.R16I),L===i.INT&&(q=i.R32I)),_===i.RG&&(L===i.FLOAT&&(q=i.RG32F),L===i.HALF_FLOAT&&(q=i.RG16F),L===i.UNSIGNED_BYTE&&(q=i.RG8)),_===i.RG_INTEGER&&(L===i.UNSIGNED_BYTE&&(q=i.RG8UI),L===i.UNSIGNED_SHORT&&(q=i.RG16UI),L===i.UNSIGNED_INT&&(q=i.RG32UI),L===i.BYTE&&(q=i.RG8I),L===i.SHORT&&(q=i.RG16I),L===i.INT&&(q=i.RG32I)),_===i.RGB_INTEGER&&(L===i.UNSIGNED_BYTE&&(q=i.RGB8UI),L===i.UNSIGNED_SHORT&&(q=i.RGB16UI),L===i.UNSIGNED_INT&&(q=i.RGB32UI),L===i.BYTE&&(q=i.RGB8I),L===i.SHORT&&(q=i.RGB16I),L===i.INT&&(q=i.RGB32I)),_===i.RGBA_INTEGER&&(L===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),L===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),L===i.UNSIGNED_INT&&(q=i.RGBA32UI),L===i.BYTE&&(q=i.RGBA8I),L===i.SHORT&&(q=i.RGBA16I),L===i.INT&&(q=i.RGBA32I)),_===i.RGB&&(L===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),L===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),_===i.RGBA){const me=Z?fs:He.getTransfer(Y);L===i.FLOAT&&(q=i.RGBA32F),L===i.HALF_FLOAT&&(q=i.RGBA16F),L===i.UNSIGNED_BYTE&&(q=me===Ze?i.SRGB8_ALPHA8:i.RGBA8),L===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),L===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function E(b,_){let L;return b?_===null||_===$t||_===yi?L=i.DEPTH24_STENCIL8:_===Xt?L=i.DEPTH32F_STENCIL8:_===Ei&&(L=i.DEPTH24_STENCIL8,Re("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===$t||_===yi?L=i.DEPTH_COMPONENT24:_===Xt?L=i.DEPTH_COMPONENT32F:_===Ei&&(L=i.DEPTH_COMPONENT16),L}function R(b,_){return d(b)===!0||b.isFramebufferTexture&&b.minFilter!==vt&&b.minFilter!==yt?Math.log2(Math.max(_.width,_.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?_.mipmaps.length:1}function A(b){const _=b.target;_.removeEventListener("dispose",A),x(_),_.isVideoTexture&&f.delete(_)}function P(b){const _=b.target;_.removeEventListener("dispose",P),V(_)}function x(b){const _=n.get(b);if(_.__webglInit===void 0)return;const L=b.source,Y=h.get(L);if(Y){const Z=Y[_.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&y(b),Object.keys(Y).length===0&&h.delete(L)}n.remove(b)}function y(b){const _=n.get(b);i.deleteTexture(_.__webglTexture);const L=b.source,Y=h.get(L);delete Y[_.__cacheKey],a.memory.textures--}function V(b){const _=n.get(b);if(b.depthTexture&&(b.depthTexture.dispose(),n.remove(b.depthTexture)),b.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(_.__webglFramebuffer[Y]))for(let Z=0;Z<_.__webglFramebuffer[Y].length;Z++)i.deleteFramebuffer(_.__webglFramebuffer[Y][Z]);else i.deleteFramebuffer(_.__webglFramebuffer[Y]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[Y])}else{if(Array.isArray(_.__webglFramebuffer))for(let Y=0;Y<_.__webglFramebuffer.length;Y++)i.deleteFramebuffer(_.__webglFramebuffer[Y]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Y=0;Y<_.__webglColorRenderbuffer.length;Y++)_.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[Y]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const L=b.textures;for(let Y=0,Z=L.length;Y<Z;Y++){const q=n.get(L[Y]);q.__webglTexture&&(i.deleteTexture(q.__webglTexture),a.memory.textures--),n.remove(L[Y])}n.remove(b)}let w=0;function N(){w=0}function O(){const b=w;return b>=s.maxTextures&&Re("WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+s.maxTextures),w+=1,b}function k(b){const _=[];return _.push(b.wrapS),_.push(b.wrapT),_.push(b.wrapR||0),_.push(b.magFilter),_.push(b.minFilter),_.push(b.anisotropy),_.push(b.internalFormat),_.push(b.format),_.push(b.type),_.push(b.generateMipmaps),_.push(b.premultiplyAlpha),_.push(b.flipY),_.push(b.unpackAlignment),_.push(b.colorSpace),_.join()}function G(b,_){const L=n.get(b);if(b.isVideoTexture&&qe(b),b.isRenderTargetTexture===!1&&b.isExternalTexture!==!0&&b.version>0&&L.__version!==b.version){const Y=b.image;if(Y===null)Re("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Re("WebGLRenderer: Texture marked for update but image is incomplete");else{K(L,b,_);return}}else b.isExternalTexture&&(L.__webglTexture=b.sourceTexture?b.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,L.__webglTexture,i.TEXTURE0+_)}function z(b,_){const L=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&L.__version!==b.version){K(L,b,_);return}else b.isExternalTexture&&(L.__webglTexture=b.sourceTexture?b.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,L.__webglTexture,i.TEXTURE0+_)}function H(b,_){const L=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&L.__version!==b.version){K(L,b,_);return}t.bindTexture(i.TEXTURE_3D,L.__webglTexture,i.TEXTURE0+_)}function Q(b,_){const L=n.get(b);if(b.isCubeDepthTexture!==!0&&b.version>0&&L.__version!==b.version){ne(L,b,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,L.__webglTexture,i.TEXTURE0+_)}const $={[dr]:i.REPEAT,[ln]:i.CLAMP_TO_EDGE,[pr]:i.MIRRORED_REPEAT},ce={[vt]:i.NEAREST,[Wl]:i.NEAREST_MIPMAP_NEAREST,[Li]:i.NEAREST_MIPMAP_LINEAR,[yt]:i.LINEAR,[As]:i.LINEAR_MIPMAP_NEAREST,[Fn]:i.LINEAR_MIPMAP_LINEAR},pe={[Yl]:i.NEVER,[Jl]:i.ALWAYS,[Kl]:i.LESS,[sa]:i.LEQUAL,[Zl]:i.EQUAL,[ra]:i.GEQUAL,[$l]:i.GREATER,[jl]:i.NOTEQUAL};function ue(b,_){if(_.type===Xt&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===yt||_.magFilter===As||_.magFilter===Li||_.magFilter===Fn||_.minFilter===yt||_.minFilter===As||_.minFilter===Li||_.minFilter===Fn)&&Re("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,$[_.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,$[_.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,$[_.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,ce[_.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,ce[_.minFilter]),_.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,pe[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===vt||_.minFilter!==Li&&_.minFilter!==Fn||_.type===Xt&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const L=e.get("EXT_texture_filter_anisotropic");i.texParameterf(b,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Ie(b,_){let L=!1;b.__webglInit===void 0&&(b.__webglInit=!0,_.addEventListener("dispose",A));const Y=_.source;let Z=h.get(Y);Z===void 0&&(Z={},h.set(Y,Z));const q=k(_);if(q!==b.__cacheKey){Z[q]===void 0&&(Z[q]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,L=!0),Z[q].usedTimes++;const me=Z[b.__cacheKey];me!==void 0&&(Z[b.__cacheKey].usedTimes--,me.usedTimes===0&&y(_)),b.__cacheKey=q,b.__webglTexture=Z[q].texture}return L}function it(b,_,L){return Math.floor(Math.floor(b/L)/_)}function nt(b,_,L,Y){const q=b.updateRanges;if(q.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,L,Y,_.data);else{q.sort((j,ee)=>j.start-ee.start);let me=0;for(let j=1;j<q.length;j++){const ee=q[me],_e=q[j],xe=ee.start+ee.count,he=it(_e.start,_.width,4),Oe=it(ee.start,_.width,4);_e.start<=xe+1&&he===Oe&&it(_e.start+_e.count-1,_.width,4)===he?ee.count=Math.max(ee.count,_e.start+_e.count-ee.start):(++me,q[me]=_e)}q.length=me+1;const ie=i.getParameter(i.UNPACK_ROW_LENGTH),Te=i.getParameter(i.UNPACK_SKIP_PIXELS),Ae=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let j=0,ee=q.length;j<ee;j++){const _e=q[j],xe=Math.floor(_e.start/4),he=Math.ceil(_e.count/4),Oe=xe%_.width,D=Math.floor(xe/_.width),se=he,te=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Oe),i.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Oe,D,se,te,L,Y,_.data)}b.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,ie),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Te),i.pixelStorei(i.UNPACK_SKIP_ROWS,Ae)}}function K(b,_,L){let Y=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Y=i.TEXTURE_3D);const Z=Ie(b,_),q=_.source;t.bindTexture(Y,b.__webglTexture,i.TEXTURE0+L);const me=n.get(q);if(q.version!==me.__version||Z===!0){t.activeTexture(i.TEXTURE0+L);const ie=He.getPrimaries(He.workingColorSpace),Te=_.colorSpace===En?null:He.getPrimaries(_.colorSpace),Ae=_.colorSpace===En||ie===Te?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let j=S(_.image,!1,s.maxTextureSize);j=et(_,j);const ee=r.convert(_.format,_.colorSpace),_e=r.convert(_.type);let xe=T(_.internalFormat,ee,_e,_.colorSpace,_.isVideoTexture);ue(Y,_);let he;const Oe=_.mipmaps,D=_.isVideoTexture!==!0,se=me.__version===void 0||Z===!0,te=q.dataReady,de=R(_,j);if(_.isDepthTexture)xe=E(_.format===On,_.type),se&&(D?t.texStorage2D(i.TEXTURE_2D,1,xe,j.width,j.height):t.texImage2D(i.TEXTURE_2D,0,xe,j.width,j.height,0,ee,_e,null));else if(_.isDataTexture)if(Oe.length>0){D&&se&&t.texStorage2D(i.TEXTURE_2D,de,xe,Oe[0].width,Oe[0].height);for(let J=0,X=Oe.length;J<X;J++)he=Oe[J],D?te&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,_e,he.data):t.texImage2D(i.TEXTURE_2D,J,xe,he.width,he.height,0,ee,_e,he.data);_.generateMipmaps=!1}else D?(se&&t.texStorage2D(i.TEXTURE_2D,de,xe,j.width,j.height),te&&nt(_,j,ee,_e)):t.texImage2D(i.TEXTURE_2D,0,xe,j.width,j.height,0,ee,_e,j.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){D&&se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,de,xe,Oe[0].width,Oe[0].height,j.depth);for(let J=0,X=Oe.length;J<X;J++)if(he=Oe[J],_.format!==Vt)if(ee!==null)if(D){if(te)if(_.layerUpdates.size>0){const ge=eo(he.width,he.height,_.format,_.type);for(const Ce of _.layerUpdates){const tt=he.data.subarray(Ce*ge/he.data.BYTES_PER_ELEMENT,(Ce+1)*ge/he.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,Ce,he.width,he.height,1,ee,tt)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,he.width,he.height,j.depth,ee,he.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,xe,he.width,he.height,j.depth,0,he.data,0,0);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?te&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,he.width,he.height,j.depth,ee,_e,he.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,xe,he.width,he.height,j.depth,0,ee,_e,he.data)}else{D&&se&&t.texStorage2D(i.TEXTURE_2D,de,xe,Oe[0].width,Oe[0].height);for(let J=0,X=Oe.length;J<X;J++)he=Oe[J],_.format!==Vt?ee!==null?D?te&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,he.data):t.compressedTexImage2D(i.TEXTURE_2D,J,xe,he.width,he.height,0,he.data):Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?te&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,_e,he.data):t.texImage2D(i.TEXTURE_2D,J,xe,he.width,he.height,0,ee,_e,he.data)}else if(_.isDataArrayTexture)if(D){if(se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,de,xe,j.width,j.height,j.depth),te)if(_.layerUpdates.size>0){const J=eo(j.width,j.height,_.format,_.type);for(const X of _.layerUpdates){const ge=j.data.subarray(X*J/j.data.BYTES_PER_ELEMENT,(X+1)*J/j.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,X,j.width,j.height,1,ee,_e,ge)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,ee,_e,j.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,xe,j.width,j.height,j.depth,0,ee,_e,j.data);else if(_.isData3DTexture)D?(se&&t.texStorage3D(i.TEXTURE_3D,de,xe,j.width,j.height,j.depth),te&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,ee,_e,j.data)):t.texImage3D(i.TEXTURE_3D,0,xe,j.width,j.height,j.depth,0,ee,_e,j.data);else if(_.isFramebufferTexture){if(se)if(D)t.texStorage2D(i.TEXTURE_2D,de,xe,j.width,j.height);else{let J=j.width,X=j.height;for(let ge=0;ge<de;ge++)t.texImage2D(i.TEXTURE_2D,ge,xe,J,X,0,ee,_e,null),J>>=1,X>>=1}}else if(Oe.length>0){if(D&&se){const J=Me(Oe[0]);t.texStorage2D(i.TEXTURE_2D,de,xe,J.width,J.height)}for(let J=0,X=Oe.length;J<X;J++)he=Oe[J],D?te&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ee,_e,he):t.texImage2D(i.TEXTURE_2D,J,xe,ee,_e,he);_.generateMipmaps=!1}else if(D){if(se){const J=Me(j);t.texStorage2D(i.TEXTURE_2D,de,xe,J.width,J.height)}te&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ee,_e,j)}else t.texImage2D(i.TEXTURE_2D,0,xe,ee,_e,j);d(_)&&u(Y),me.__version=q.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function ne(b,_,L){if(_.image.length!==6)return;const Y=Ie(b,_),Z=_.source;t.bindTexture(i.TEXTURE_CUBE_MAP,b.__webglTexture,i.TEXTURE0+L);const q=n.get(Z);if(Z.version!==q.__version||Y===!0){t.activeTexture(i.TEXTURE0+L);const me=He.getPrimaries(He.workingColorSpace),ie=_.colorSpace===En?null:He.getPrimaries(_.colorSpace),Te=_.colorSpace===En||me===ie?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const Ae=_.isCompressedTexture||_.image[0].isCompressedTexture,j=_.image[0]&&_.image[0].isDataTexture,ee=[];for(let X=0;X<6;X++)!Ae&&!j?ee[X]=S(_.image[X],!0,s.maxCubemapSize):ee[X]=j?_.image[X].image:_.image[X],ee[X]=et(_,ee[X]);const _e=ee[0],xe=r.convert(_.format,_.colorSpace),he=r.convert(_.type),Oe=T(_.internalFormat,xe,he,_.colorSpace),D=_.isVideoTexture!==!0,se=q.__version===void 0||Y===!0,te=Z.dataReady;let de=R(_,_e);ue(i.TEXTURE_CUBE_MAP,_);let J;if(Ae){D&&se&&t.texStorage2D(i.TEXTURE_CUBE_MAP,de,Oe,_e.width,_e.height);for(let X=0;X<6;X++){J=ee[X].mipmaps;for(let ge=0;ge<J.length;ge++){const Ce=J[ge];_.format!==Vt?xe!==null?D?te&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge,0,0,Ce.width,Ce.height,xe,Ce.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge,Oe,Ce.width,Ce.height,0,Ce.data):Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge,0,0,Ce.width,Ce.height,xe,he,Ce.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge,Oe,Ce.width,Ce.height,0,xe,he,Ce.data)}}}else{if(J=_.mipmaps,D&&se){J.length>0&&de++;const X=Me(ee[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,de,Oe,X.width,X.height)}for(let X=0;X<6;X++)if(j){D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,ee[X].width,ee[X].height,xe,he,ee[X].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,Oe,ee[X].width,ee[X].height,0,xe,he,ee[X].data);for(let ge=0;ge<J.length;ge++){const tt=J[ge].image[X].image;D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge+1,0,0,tt.width,tt.height,xe,he,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge+1,Oe,tt.width,tt.height,0,xe,he,tt.data)}}else{D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,xe,he,ee[X]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,Oe,xe,he,ee[X]);for(let ge=0;ge<J.length;ge++){const Ce=J[ge];D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge+1,0,0,xe,he,Ce.image[X]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ge+1,Oe,xe,he,Ce.image[X])}}}d(_)&&u(i.TEXTURE_CUBE_MAP),q.__version=Z.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function re(b,_,L,Y,Z,q){const me=r.convert(L.format,L.colorSpace),ie=r.convert(L.type),Te=T(L.internalFormat,me,ie,L.colorSpace),Ae=n.get(_),j=n.get(L);if(j.__renderTarget=_,!Ae.__hasExternalTextures){const ee=Math.max(1,_.width>>q),_e=Math.max(1,_.height>>q);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?t.texImage3D(Z,q,Te,ee,_e,_.depth,0,me,ie,null):t.texImage2D(Z,q,Te,ee,_e,0,me,ie,null)}t.bindFramebuffer(i.FRAMEBUFFER,b),ct(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,Z,j.__webglTexture,0,C(_)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,Z,j.__webglTexture,q),t.bindFramebuffer(i.FRAMEBUFFER,null)}function De(b,_,L){if(i.bindRenderbuffer(i.RENDERBUFFER,b),_.depthBuffer){const Y=_.depthTexture,Z=Y&&Y.isDepthTexture?Y.type:null,q=E(_.stencilBuffer,Z),me=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ct(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,C(_),q,_.width,_.height):L?i.renderbufferStorageMultisample(i.RENDERBUFFER,C(_),q,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,q,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,me,i.RENDERBUFFER,b)}else{const Y=_.textures;for(let Z=0;Z<Y.length;Z++){const q=Y[Z],me=r.convert(q.format,q.colorSpace),ie=r.convert(q.type),Te=T(q.internalFormat,me,ie,q.colorSpace);ct(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,C(_),Te,_.width,_.height):L?i.renderbufferStorageMultisample(i.RENDERBUFFER,C(_),Te,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Te,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function be(b,_,L){const Y=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,b),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Z=n.get(_.depthTexture);if(Z.__renderTarget=_,(!Z.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),Y){if(Z.__webglInit===void 0&&(Z.__webglInit=!0,_.depthTexture.addEventListener("dispose",A)),Z.__webglTexture===void 0){Z.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture),ue(i.TEXTURE_CUBE_MAP,_.depthTexture);const Ae=r.convert(_.depthTexture.format),j=r.convert(_.depthTexture.type);let ee;_.depthTexture.format===fn?ee=i.DEPTH_COMPONENT24:_.depthTexture.format===On&&(ee=i.DEPTH24_STENCIL8);for(let _e=0;_e<6;_e++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,ee,_.width,_.height,0,Ae,j,null)}}else G(_.depthTexture,0);const q=Z.__webglTexture,me=C(_),ie=Y?i.TEXTURE_CUBE_MAP_POSITIVE_X+L:i.TEXTURE_2D,Te=_.depthTexture.format===On?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===fn)ct(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Te,ie,q,0,me):i.framebufferTexture2D(i.FRAMEBUFFER,Te,ie,q,0);else if(_.depthTexture.format===On)ct(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Te,ie,q,0,me):i.framebufferTexture2D(i.FRAMEBUFFER,Te,ie,q,0);else throw new Error("Unknown depthTexture format")}function we(b){const _=n.get(b),L=b.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==b.depthTexture){const Y=b.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Y){const Z=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Y.removeEventListener("dispose",Z)};Y.addEventListener("dispose",Z),_.__depthDisposeCallback=Z}_.__boundDepthTexture=Y}if(b.depthTexture&&!_.__autoAllocateDepthBuffer)if(L)for(let Y=0;Y<6;Y++)be(_.__webglFramebuffer[Y],b,Y);else{const Y=b.texture.mipmaps;Y&&Y.length>0?be(_.__webglFramebuffer[0],b,0):be(_.__webglFramebuffer,b,0)}else if(L){_.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[Y]),_.__webglDepthbuffer[Y]===void 0)_.__webglDepthbuffer[Y]=i.createRenderbuffer(),De(_.__webglDepthbuffer[Y],b,!1);else{const Z=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,q),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,q)}}else{const Y=b.texture.mipmaps;if(Y&&Y.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),De(_.__webglDepthbuffer,b,!1);else{const Z=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,q),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,q)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function pt(b,_,L){const Y=n.get(b);_!==void 0&&re(Y.__webglFramebuffer,b,b.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),L!==void 0&&we(b)}function Ge(b){const _=b.texture,L=n.get(b),Y=n.get(_);b.addEventListener("dispose",P);const Z=b.textures,q=b.isWebGLCubeRenderTarget===!0,me=Z.length>1;if(me||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=_.version,a.memory.textures++),q){L.__webglFramebuffer=[];for(let ie=0;ie<6;ie++)if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer[ie]=[];for(let Te=0;Te<_.mipmaps.length;Te++)L.__webglFramebuffer[ie][Te]=i.createFramebuffer()}else L.__webglFramebuffer[ie]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer=[];for(let ie=0;ie<_.mipmaps.length;ie++)L.__webglFramebuffer[ie]=i.createFramebuffer()}else L.__webglFramebuffer=i.createFramebuffer();if(me)for(let ie=0,Te=Z.length;ie<Te;ie++){const Ae=n.get(Z[ie]);Ae.__webglTexture===void 0&&(Ae.__webglTexture=i.createTexture(),a.memory.textures++)}if(b.samples>0&&ct(b)===!1){L.__webglMultisampledFramebuffer=i.createFramebuffer(),L.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let ie=0;ie<Z.length;ie++){const Te=Z[ie];L.__webglColorRenderbuffer[ie]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,L.__webglColorRenderbuffer[ie]);const Ae=r.convert(Te.format,Te.colorSpace),j=r.convert(Te.type),ee=T(Te.internalFormat,Ae,j,Te.colorSpace,b.isXRRenderTarget===!0),_e=C(b);i.renderbufferStorageMultisample(i.RENDERBUFFER,_e,ee,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ie,i.RENDERBUFFER,L.__webglColorRenderbuffer[ie])}i.bindRenderbuffer(i.RENDERBUFFER,null),b.depthBuffer&&(L.__webglDepthRenderbuffer=i.createRenderbuffer(),De(L.__webglDepthRenderbuffer,b,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(q){t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),ue(i.TEXTURE_CUBE_MAP,_);for(let ie=0;ie<6;ie++)if(_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(L.__webglFramebuffer[ie][Te],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Te);else re(L.__webglFramebuffer[ie],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0);d(_)&&u(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(me){for(let ie=0,Te=Z.length;ie<Te;ie++){const Ae=Z[ie],j=n.get(Ae);let ee=i.TEXTURE_2D;(b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(ee=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ee,j.__webglTexture),ue(ee,Ae),re(L.__webglFramebuffer,b,Ae,i.COLOR_ATTACHMENT0+ie,ee,0),d(Ae)&&u(ee)}t.unbindTexture()}else{let ie=i.TEXTURE_2D;if((b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(ie=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ie,Y.__webglTexture),ue(ie,_),_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(L.__webglFramebuffer[Te],b,_,i.COLOR_ATTACHMENT0,ie,Te);else re(L.__webglFramebuffer,b,_,i.COLOR_ATTACHMENT0,ie,0);d(_)&&u(ie),t.unbindTexture()}b.depthBuffer&&we(b)}function Ye(b){const _=b.textures;for(let L=0,Y=_.length;L<Y;L++){const Z=_[L];if(d(Z)){const q=v(b),me=n.get(Z).__webglTexture;t.bindTexture(q,me),u(q),t.unbindTexture()}}}const Je=[],Fe=[];function ot(b){if(b.samples>0){if(ct(b)===!1){const _=b.textures,L=b.width,Y=b.height;let Z=i.COLOR_BUFFER_BIT;const q=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,me=n.get(b),ie=_.length>1;if(ie)for(let Ae=0;Ae<_.length;Ae++)t.bindFramebuffer(i.FRAMEBUFFER,me.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,me.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,me.__webglMultisampledFramebuffer);const Te=b.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglFramebuffer);for(let Ae=0;Ae<_.length;Ae++){if(b.resolveDepthBuffer&&(b.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),b.stencilBuffer&&b.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),ie){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,me.__webglColorRenderbuffer[Ae]);const j=n.get(_[Ae]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,j,0)}i.blitFramebuffer(0,0,L,Y,0,0,L,Y,Z,i.NEAREST),c===!0&&(Je.length=0,Fe.length=0,Je.push(i.COLOR_ATTACHMENT0+Ae),b.depthBuffer&&b.resolveDepthBuffer===!1&&(Je.push(q),Fe.push(q),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Fe)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Je))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ie)for(let Ae=0;Ae<_.length;Ae++){t.bindFramebuffer(i.FRAMEBUFFER,me.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.RENDERBUFFER,me.__webglColorRenderbuffer[Ae]);const j=n.get(_[Ae]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,me.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.TEXTURE_2D,j,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglMultisampledFramebuffer)}else if(b.depthBuffer&&b.resolveDepthBuffer===!1&&c){const _=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function C(b){return Math.min(s.maxSamples,b.samples)}function ct(b){const _=n.get(b);return b.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function qe(b){const _=a.render.frame;f.get(b)!==_&&(f.set(b,_),b.update())}function et(b,_){const L=b.colorSpace,Y=b.format,Z=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||L!==li&&L!==En&&(He.getTransfer(L)===Ze?(Y!==Vt||Z!==Dt)&&Re("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",L)),_}function Me(b){return typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement?(l.width=b.naturalWidth||b.width,l.height=b.naturalHeight||b.height):typeof VideoFrame<"u"&&b instanceof VideoFrame?(l.width=b.displayWidth,l.height=b.displayHeight):(l.width=b.width,l.height=b.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=N,this.setTexture2D=G,this.setTexture2DArray=z,this.setTexture3D=H,this.setTextureCube=Q,this.rebindTextures=pt,this.setupRenderTarget=Ge,this.updateRenderTargetMipmap=Ye,this.updateMultisampleRenderTarget=ot,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=re,this.useMultisampledRTT=ct,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Rp(i,e){function t(n,s=En){let r;const a=He.getTransfer(s);if(n===Dt)return i.UNSIGNED_BYTE;if(n===Qr)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ea)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Fo)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Oo)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Uo)return i.BYTE;if(n===No)return i.SHORT;if(n===Ei)return i.UNSIGNED_SHORT;if(n===Jr)return i.INT;if(n===$t)return i.UNSIGNED_INT;if(n===Xt)return i.FLOAT;if(n===un)return i.HALF_FLOAT;if(n===Bo)return i.ALPHA;if(n===zo)return i.RGB;if(n===Vt)return i.RGBA;if(n===fn)return i.DEPTH_COMPONENT;if(n===On)return i.DEPTH_STENCIL;if(n===Vo)return i.RED;if(n===ta)return i.RED_INTEGER;if(n===oi)return i.RG;if(n===na)return i.RG_INTEGER;if(n===ia)return i.RGBA_INTEGER;if(n===as||n===os||n===ls||n===cs)if(a===Ze)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===as)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===os)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ls)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===cs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===as)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===os)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ls)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===cs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===mr||n===_r||n===gr||n===xr)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===mr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===_r)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===gr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===vr||n===Mr||n===Sr||n===Er||n===yr||n===Tr||n===br)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===vr||n===Mr)return a===Ze?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Sr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Er)return r.COMPRESSED_R11_EAC;if(n===yr)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Tr)return r.COMPRESSED_RG11_EAC;if(n===br)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ar||n===Rr||n===wr||n===Cr||n===Pr||n===Dr||n===Lr||n===Ir||n===Ur||n===Nr||n===Fr||n===Or||n===Br||n===zr)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ar)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Rr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===wr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Cr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Pr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Dr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Lr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ir)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ur)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Nr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Fr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Or)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Br)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===zr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Vr||n===Gr||n===Hr)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Vr)return a===Ze?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Gr)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Hr)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===kr||n===Wr||n===Xr||n===qr)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===kr)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Wr)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Xr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===qr)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===yi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const wp=`
4034
+ void main() {
4035
+
4036
+ gl_Position = vec4( position, 1.0 );
4037
+
4038
+ }`,Cp=`
4039
+ uniform sampler2DArray depthColor;
4040
+ uniform float depthWidth;
4041
+ uniform float depthHeight;
4042
+
4043
+ void main() {
4044
+
4045
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
4046
+
4047
+ if ( coord.x >= 1.0 ) {
4048
+
4049
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
4050
+
4051
+ } else {
4052
+
4053
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
4054
+
4055
+ }
4056
+
4057
+ }`;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 Jo(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 Jt({vertexShader:wp,fragmentShader:Cp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new dn(new xs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Dp extends zn{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,f=null,m=null,h=null,p=null,g=null;const S=typeof XRWebGLBinding<"u",d=new Pp,u={},v=t.getContextAttributes();let T=null,E=null;const R=[],A=[],P=new Ve;let x=null;const y=new Ut;y.viewport=new at;const V=new Ut;V.viewport=new at;const w=[y,V],N=new Gc;let O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let ne=R[K];return ne===void 0&&(ne=new Is,R[K]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(K){let ne=R[K];return ne===void 0&&(ne=new Is,R[K]=ne),ne.getGripSpace()},this.getHand=function(K){let ne=R[K];return ne===void 0&&(ne=new Is,R[K]=ne),ne.getHandSpace()};function G(K){const ne=A.indexOf(K.inputSource);if(ne===-1)return;const re=R[ne];re!==void 0&&(re.update(K.inputSource,K.frame,l||a),re.dispatchEvent({type:K.type,data:K.inputSource}))}function z(){s.removeEventListener("select",G),s.removeEventListener("selectstart",G),s.removeEventListener("selectend",G),s.removeEventListener("squeeze",G),s.removeEventListener("squeezestart",G),s.removeEventListener("squeezeend",G),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",H);for(let K=0;K<R.length;K++){const ne=A[K];ne!==null&&(A[K]=null,R[K].disconnect(ne))}O=null,k=null,d.reset();for(const K in u)delete u[K];e.setRenderTarget(T),p=null,h=null,m=null,s=null,E=null,nt.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&Re("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&Re("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return h!==null?h:p},this.getBinding=function(){return m===null&&S&&(m=new XRWebGLBinding(s,t)),m},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(K){if(s=K,s!==null){if(T=e.getRenderTarget(),s.addEventListener("select",G),s.addEventListener("selectstart",G),s.addEventListener("selectend",G),s.addEventListener("squeeze",G),s.addEventListener("squeezestart",G),s.addEventListener("squeezeend",G),s.addEventListener("end",z),s.addEventListener("inputsourceschange",H),v.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(P),S&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,De=null,be=null;v.depth&&(be=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=v.stencil?On:fn,De=v.stencil?yi:$t);const we={colorFormat:t.RGBA8,depthFormat:be,scaleFactor:r};m=this.getBinding(),h=m.createProjectionLayer(we),s.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),E=new Kt(h.textureWidth,h.textureHeight,{format:Vt,type:Dt,depthTexture:new bi(h.textureWidth,h.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const re={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,t,re),s.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),E=new Kt(p.framebufferWidth,p.framebufferHeight,{format:Vt,type:Dt,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),nt.setContext(s),nt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return d.getDepthTexture()};function H(K){for(let ne=0;ne<K.removed.length;ne++){const re=K.removed[ne],De=A.indexOf(re);De>=0&&(A[De]=null,R[De].disconnect(re))}for(let ne=0;ne<K.added.length;ne++){const re=K.added[ne];let De=A.indexOf(re);if(De===-1){for(let we=0;we<R.length;we++)if(we>=A.length){A.push(re),De=we;break}else if(A[we]===null){A[we]=re,De=we;break}if(De===-1)break}const be=R[De];be&&be.connect(re)}}const Q=new U,$=new U;function ce(K,ne,re){Q.setFromMatrixPosition(ne.matrixWorld),$.setFromMatrixPosition(re.matrixWorld);const De=Q.distanceTo($),be=ne.projectionMatrix.elements,we=re.projectionMatrix.elements,pt=be[14]/(be[10]-1),Ge=be[14]/(be[10]+1),Ye=(be[9]+1)/be[5],Je=(be[9]-1)/be[5],Fe=(be[8]-1)/be[0],ot=(we[8]+1)/we[0],C=pt*Fe,ct=pt*ot,qe=De/(-Fe+ot),et=qe*-Fe;if(ne.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(et),K.translateZ(qe),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),be[10]===-1)K.projectionMatrix.copy(ne.projectionMatrix),K.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const Me=pt+qe,b=Ge+qe,_=C-et,L=ct+(De-et),Y=Ye*Ge/b*Me,Z=Je*Ge/b*Me;K.projectionMatrix.makePerspective(_,L,Y,Z,Me,b),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function pe(K,ne){ne===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(ne.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(s===null)return;let ne=K.near,re=K.far;d.texture!==null&&(d.depthNear>0&&(ne=d.depthNear),d.depthFar>0&&(re=d.depthFar)),N.near=V.near=y.near=ne,N.far=V.far=y.far=re,(O!==N.near||k!==N.far)&&(s.updateRenderState({depthNear:N.near,depthFar:N.far}),O=N.near,k=N.far),N.layers.mask=K.layers.mask|6,y.layers.mask=N.layers.mask&-5,V.layers.mask=N.layers.mask&-3;const De=K.parent,be=N.cameras;pe(N,De);for(let we=0;we<be.length;we++)pe(be[we],De);be.length===2?ce(N,y,V):N.projectionMatrix.copy(y.projectionMatrix),ue(K,N,De)};function ue(K,ne,re){re===null?K.matrix.copy(ne.matrixWorld):(K.matrix.copy(re.matrixWorld),K.matrix.invert(),K.matrix.multiply(ne.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(ne.projectionMatrix),K.projectionMatrixInverse.copy(ne.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Yr*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(h===null&&p===null))return c},this.setFoveation=function(K){c=K,h!==null&&(h.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return d.texture!==null},this.getDepthSensingMesh=function(){return d.getMesh(N)},this.getCameraTexture=function(K){return u[K]};let Ie=null;function it(K,ne){if(f=ne.getViewerPose(l||a),g=ne,f!==null){const re=f.views;p!==null&&(e.setRenderTargetFramebuffer(E,p.framebuffer),e.setRenderTarget(E));let De=!1;re.length!==N.cameras.length&&(N.cameras.length=0,De=!0);for(let Ge=0;Ge<re.length;Ge++){const Ye=re[Ge];let Je=null;if(p!==null)Je=p.getViewport(Ye);else{const ot=m.getViewSubImage(h,Ye);Je=ot.viewport,Ge===0&&(e.setRenderTargetTextures(E,ot.colorTexture,ot.depthStencilTexture),e.setRenderTarget(E))}let Fe=w[Ge];Fe===void 0&&(Fe=new Ut,Fe.layers.enable(Ge),Fe.viewport=new at,w[Ge]=Fe),Fe.matrix.fromArray(Ye.transform.matrix),Fe.matrix.decompose(Fe.position,Fe.quaternion,Fe.scale),Fe.projectionMatrix.fromArray(Ye.projectionMatrix),Fe.projectionMatrixInverse.copy(Fe.projectionMatrix).invert(),Fe.viewport.set(Je.x,Je.y,Je.width,Je.height),Ge===0&&(N.matrix.copy(Fe.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),De===!0&&N.cameras.push(Fe)}const be=s.enabledFeatures;if(be&&be.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&S){m=n.getBinding();const Ge=m.getDepthInformation(re[0]);Ge&&Ge.isValid&&Ge.texture&&d.init(Ge,s.renderState)}if(be&&be.includes("camera-access")&&S){e.state.unbindTexture(),m=n.getBinding();for(let Ge=0;Ge<re.length;Ge++){const Ye=re[Ge].camera;if(Ye){let Je=u[Ye];Je||(Je=new Jo,u[Ye]=Je);const Fe=m.getCameraImage(Ye);Je.sourceTexture=Fe}}}}for(let re=0;re<R.length;re++){const De=A[re],be=R[re];De!==null&&be!==void 0&&be.update(De,ne,l||a)}Ie&&Ie(K,ne),ne.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ne}),g=null}const nt=new ll;nt.setAnimationLoop(it),this.setAnimationLoop=function(K){Ie=K},this.dispose=function(){}}}const Ln=new jt,Lp=new st;function Ip(i,e){function t(d,u){d.matrixAutoUpdate===!0&&d.updateMatrix(),u.value.copy(d.matrix)}function n(d,u){u.color.getRGB(d.fogColor.value,rl(i)),u.isFog?(d.fogNear.value=u.near,d.fogFar.value=u.far):u.isFogExp2&&(d.fogDensity.value=u.density)}function s(d,u,v,T,E){u.isMeshBasicMaterial?r(d,u):u.isMeshLambertMaterial?(r(d,u),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)):u.isMeshToonMaterial?(r(d,u),m(d,u)):u.isMeshPhongMaterial?(r(d,u),f(d,u),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)):u.isMeshStandardMaterial?(r(d,u),h(d,u),u.isMeshPhysicalMaterial&&p(d,u,E)):u.isMeshMatcapMaterial?(r(d,u),g(d,u)):u.isMeshDepthMaterial?r(d,u):u.isMeshDistanceMaterial?(r(d,u),S(d,u)):u.isMeshNormalMaterial?r(d,u):u.isLineBasicMaterial?(a(d,u),u.isLineDashedMaterial&&o(d,u)):u.isPointsMaterial?c(d,u,v,T):u.isSpriteMaterial?l(d,u):u.isShadowMaterial?(d.color.value.copy(u.color),d.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function r(d,u){d.opacity.value=u.opacity,u.color&&d.diffuse.value.copy(u.color),u.emissive&&d.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.bumpMap&&(d.bumpMap.value=u.bumpMap,t(u.bumpMap,d.bumpMapTransform),d.bumpScale.value=u.bumpScale,u.side===Rt&&(d.bumpScale.value*=-1)),u.normalMap&&(d.normalMap.value=u.normalMap,t(u.normalMap,d.normalMapTransform),d.normalScale.value.copy(u.normalScale),u.side===Rt&&d.normalScale.value.negate()),u.displacementMap&&(d.displacementMap.value=u.displacementMap,t(u.displacementMap,d.displacementMapTransform),d.displacementScale.value=u.displacementScale,d.displacementBias.value=u.displacementBias),u.emissiveMap&&(d.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,d.emissiveMapTransform)),u.specularMap&&(d.specularMap.value=u.specularMap,t(u.specularMap,d.specularMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest);const v=e.get(u),T=v.envMap,E=v.envMapRotation;T&&(d.envMap.value=T,Ln.copy(E),Ln.x*=-1,Ln.y*=-1,Ln.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Ln.y*=-1,Ln.z*=-1),d.envMapRotation.value.setFromMatrix4(Lp.makeRotationFromEuler(Ln)),d.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=u.reflectivity,d.ior.value=u.ior,d.refractionRatio.value=u.refractionRatio),u.lightMap&&(d.lightMap.value=u.lightMap,d.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,d.lightMapTransform)),u.aoMap&&(d.aoMap.value=u.aoMap,d.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,d.aoMapTransform))}function a(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform))}function o(d,u){d.dashSize.value=u.dashSize,d.totalSize.value=u.dashSize+u.gapSize,d.scale.value=u.scale}function c(d,u,v,T){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.size.value=u.size*v,d.scale.value=T*.5,u.map&&(d.map.value=u.map,t(u.map,d.uvTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function l(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.rotation.value=u.rotation,u.map&&(d.map.value=u.map,t(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,t(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function f(d,u){d.specular.value.copy(u.specular),d.shininess.value=Math.max(u.shininess,1e-4)}function m(d,u){u.gradientMap&&(d.gradientMap.value=u.gradientMap)}function h(d,u){d.metalness.value=u.metalness,u.metalnessMap&&(d.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,d.metalnessMapTransform)),d.roughness.value=u.roughness,u.roughnessMap&&(d.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,d.roughnessMapTransform)),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)}function p(d,u,v){d.ior.value=u.ior,u.sheen>0&&(d.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),d.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(d.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,d.sheenColorMapTransform)),u.sheenRoughnessMap&&(d.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,d.sheenRoughnessMapTransform))),u.clearcoat>0&&(d.clearcoat.value=u.clearcoat,d.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(d.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,d.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(d.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===Rt&&d.clearcoatNormalScale.value.negate())),u.dispersion>0&&(d.dispersion.value=u.dispersion),u.iridescence>0&&(d.iridescence.value=u.iridescence,d.iridescenceIOR.value=u.iridescenceIOR,d.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(d.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,d.iridescenceMapTransform)),u.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),u.transmission>0&&(d.transmission.value=u.transmission,d.transmissionSamplerMap.value=v.texture,d.transmissionSamplerSize.value.set(v.width,v.height),u.transmissionMap&&(d.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,d.transmissionMapTransform)),d.thickness.value=u.thickness,u.thicknessMap&&(d.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=u.attenuationDistance,d.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(d.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(d.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=u.specularIntensity,d.specularColor.value.copy(u.specularColor),u.specularColorMap&&(d.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,d.specularColorMapTransform)),u.specularIntensityMap&&(d.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,u){u.matcap&&(d.matcap.value=u.matcap)}function S(d,u){const v=e.get(u).light;d.referencePosition.value.setFromMatrixPosition(v.matrixWorld),d.nearDistance.value=v.shadow.camera.near,d.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Up(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,T){const E=T.program;n.uniformBlockBinding(v,E)}function l(v,T){let E=s[v.id];E===void 0&&(g(v),E=f(v),s[v.id]=E,v.addEventListener("dispose",d));const R=T.program;n.updateUBOMapping(v,R);const A=e.render.frame;r[v.id]!==A&&(h(v),r[v.id]=A)}function f(v){const T=m();v.__bindingPointIndex=T;const E=i.createBuffer(),R=v.__size,A=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,R,A),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,E),E}function m(){for(let v=0;v<o;v++)if(a.indexOf(v)===-1)return a.push(v),v;return We("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){const T=s[v.id],E=v.uniforms,R=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let A=0,P=E.length;A<P;A++){const x=Array.isArray(E[A])?E[A]:[E[A]];for(let y=0,V=x.length;y<V;y++){const w=x[y];if(p(w,A,y,R)===!0){const N=w.__offset,O=Array.isArray(w.value)?w.value:[w.value];let k=0;for(let G=0;G<O.length;G++){const z=O[G],H=S(z);typeof z=="number"||typeof z=="boolean"?(w.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,N+k,w.__data)):z.isMatrix3?(w.__data[0]=z.elements[0],w.__data[1]=z.elements[1],w.__data[2]=z.elements[2],w.__data[3]=0,w.__data[4]=z.elements[3],w.__data[5]=z.elements[4],w.__data[6]=z.elements[5],w.__data[7]=0,w.__data[8]=z.elements[6],w.__data[9]=z.elements[7],w.__data[10]=z.elements[8],w.__data[11]=0):(z.toArray(w.__data,k),k+=H.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,N,w.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(v,T,E,R){const A=v.value,P=T+"_"+E;if(R[P]===void 0)return typeof A=="number"||typeof A=="boolean"?R[P]=A:R[P]=A.clone(),!0;{const x=R[P];if(typeof A=="number"||typeof A=="boolean"){if(x!==A)return R[P]=A,!0}else if(x.equals(A)===!1)return x.copy(A),!0}return!1}function g(v){const T=v.uniforms;let E=0;const R=16;for(let P=0,x=T.length;P<x;P++){const y=Array.isArray(T[P])?T[P]:[T[P]];for(let V=0,w=y.length;V<w;V++){const N=y[V],O=Array.isArray(N.value)?N.value:[N.value];for(let k=0,G=O.length;k<G;k++){const z=O[k],H=S(z),Q=E%R,$=Q%H.boundary,ce=Q+$;E+=$,ce!==0&&R-ce<H.storage&&(E+=R-ce),N.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=E,E+=H.storage}}}const A=E%R;return A>0&&(E+=R-A),v.__size=E,v.__cache={},this}function S(v){const T={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(T.boundary=4,T.storage=4):v.isVector2?(T.boundary=8,T.storage=8):v.isVector3||v.isColor?(T.boundary=16,T.storage=12):v.isVector4?(T.boundary=16,T.storage=16):v.isMatrix3?(T.boundary=48,T.storage=48):v.isMatrix4?(T.boundary=64,T.storage=64):v.isTexture?Re("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Re("WebGLRenderer: Unsupported uniform value type.",v),T}function d(v){const T=v.target;T.removeEventListener("dispose",d);const E=a.indexOf(T.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function u(){for(const v in s)i.deleteBuffer(s[v]);a=[],s={},r={}}return{bind:c,update:l,dispose:u}}const Np=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let kt=null;function Fp(){return kt===null&&(kt=new Ec(Np,16,16,oi,un),kt.name="DFG_LUT",kt.minFilter=yt,kt.magFilter=yt,kt.wrapS=ln,kt.wrapT=ln,kt.generateMipmaps=!1,kt.needsUpdate=!0),kt}class Jp{constructor(e={}){const{canvas:t=ec(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:p=Dt}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const S=p,d=new Set([ia,na,ta]),u=new Set([Dt,$t,Ei,yi,Qr,ea]),v=new Uint32Array(4),T=new Int32Array(4);let E=null,R=null;const A=[],P=[];let x=null;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=Yt,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let V=!1;this._outputColorSpace=It;let w=0,N=0,O=null,k=-1,G=null;const z=new at,H=new at;let Q=null;const $=new Ne(0);let ce=0,pe=t.width,ue=t.height,Ie=1,it=null,nt=null;const K=new at(0,0,pe,ue),ne=new at(0,0,pe,ue);let re=!1;const De=new la;let be=!1,we=!1;const pt=new st,Ge=new U,Ye=new at,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Fe=!1;function ot(){return O===null?Ie:1}let C=n;function ct(M,I){return t.getContext(M,I)}try{const M={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:f,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${jr}`),t.addEventListener("webglcontextlost",ge,!1),t.addEventListener("webglcontextrestored",Ce,!1),t.addEventListener("webglcontextcreationerror",tt,!1),C===null){const I="webgl2";if(C=ct(I,M),C===null)throw ct(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw We("WebGLRenderer: "+M.message),M}let qe,et,Me,b,_,L,Y,Z,q,me,ie,Te,Ae,j,ee,_e,xe,he,Oe,D,se,te,de;function J(){qe=new Of(C),qe.init(),se=new Rp(C,qe),et=new Cf(C,qe,e,se),Me=new bp(C,qe),et.reversedDepthBuffer&&h&&Me.buffers.depth.setReversed(!0),b=new Vf(C),_=new up,L=new Ap(C,qe,Me,_,et,se,b),Y=new Ff(y),Z=new Wc(C),te=new Rf(C,Z),q=new Bf(C,Z,b,te),me=new Hf(C,q,Z,te,b),he=new Gf(C,et,L),ee=new Pf(_),ie=new hp(y,Y,qe,et,te,ee),Te=new Ip(y,_),Ae=new dp,j=new vp(qe),xe=new Af(y,Y,Me,me,g,c),_e=new Tp(y,me,et),de=new Up(C,b,et,Me),Oe=new wf(C,qe,b),D=new zf(C,qe,b),b.programs=ie.programs,y.capabilities=et,y.extensions=qe,y.properties=_,y.renderLists=Ae,y.shadowMap=_e,y.state=Me,y.info=b}J(),S!==Dt&&(x=new Wf(S,t.width,t.height,s,r));const X=new Dp(y,C);this.xr=X,this.getContext=function(){return C},this.getContextAttributes=function(){return C.getContextAttributes()},this.forceContextLoss=function(){const M=qe.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=qe.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return Ie},this.setPixelRatio=function(M){M!==void 0&&(Ie=M,this.setSize(pe,ue,!1))},this.getSize=function(M){return M.set(pe,ue)},this.setSize=function(M,I,W=!0){if(X.isPresenting){Re("WebGLRenderer: Can't change size while VR device is presenting.");return}pe=M,ue=I,t.width=Math.floor(M*Ie),t.height=Math.floor(I*Ie),W===!0&&(t.style.width=M+"px",t.style.height=I+"px"),x!==null&&x.setSize(t.width,t.height),this.setViewport(0,0,M,I)},this.getDrawingBufferSize=function(M){return M.set(pe*Ie,ue*Ie).floor()},this.setDrawingBufferSize=function(M,I,W){pe=M,ue=I,Ie=W,t.width=Math.floor(M*W),t.height=Math.floor(I*W),this.setViewport(0,0,M,I)},this.setEffects=function(M){if(S===Dt){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(M){for(let I=0;I<M.length;I++)if(M[I].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(M||[])},this.getCurrentViewport=function(M){return M.copy(z)},this.getViewport=function(M){return M.copy(K)},this.setViewport=function(M,I,W,B){M.isVector4?K.set(M.x,M.y,M.z,M.w):K.set(M,I,W,B),Me.viewport(z.copy(K).multiplyScalar(Ie).round())},this.getScissor=function(M){return M.copy(ne)},this.setScissor=function(M,I,W,B){M.isVector4?ne.set(M.x,M.y,M.z,M.w):ne.set(M,I,W,B),Me.scissor(H.copy(ne).multiplyScalar(Ie).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(M){Me.setScissorTest(re=M)},this.setOpaqueSort=function(M){it=M},this.setTransparentSort=function(M){nt=M},this.getClearColor=function(M){return M.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor(...arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha(...arguments)},this.clear=function(M=!0,I=!0,W=!0){let B=0;if(M){let F=!1;if(O!==null){const oe=O.texture.format;F=d.has(oe)}if(F){const oe=O.texture.type,fe=u.has(oe),le=xe.getClearColor(),ve=xe.getClearAlpha(),Ee=le.r,Pe=le.g,Be=le.b;fe?(v[0]=Ee,v[1]=Pe,v[2]=Be,v[3]=ve,C.clearBufferuiv(C.COLOR,0,v)):(T[0]=Ee,T[1]=Pe,T[2]=Be,T[3]=ve,C.clearBufferiv(C.COLOR,0,T))}else B|=C.COLOR_BUFFER_BIT}I&&(B|=C.DEPTH_BUFFER_BIT),W&&(B|=C.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&C.clear(B)},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",ge,!1),t.removeEventListener("webglcontextrestored",Ce,!1),t.removeEventListener("webglcontextcreationerror",tt,!1),xe.dispose(),Ae.dispose(),j.dispose(),_.dispose(),Y.dispose(),me.dispose(),te.dispose(),de.dispose(),ie.dispose(),X.dispose(),X.removeEventListener("sessionstart",da),X.removeEventListener("sessionend",pa),bn.stop()};function ge(M){M.preventDefault(),Ca("WebGLRenderer: Context Lost."),V=!0}function Ce(){Ca("WebGLRenderer: Context Restored."),V=!1;const M=b.autoReset,I=_e.enabled,W=_e.autoUpdate,B=_e.needsUpdate,F=_e.type;J(),b.autoReset=M,_e.enabled=I,_e.autoUpdate=W,_e.needsUpdate=B,_e.type=F}function tt(M){We("WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function Ke(M){const I=M.target;I.removeEventListener("dispose",Ke),Qt(I)}function Qt(M){en(M),_.remove(M)}function en(M){const I=_.get(M).programs;I!==void 0&&(I.forEach(function(W){ie.releaseProgram(W)}),M.isShaderMaterial&&ie.releaseShaderCache(M))}this.renderBufferDirect=function(M,I,W,B,F,oe){I===null&&(I=Je);const fe=F.isMesh&&F.matrixWorld.determinant()<0,le=ml(M,I,W,B,F);Me.setMaterial(B,fe);let ve=W.index,Ee=1;if(B.wireframe===!0){if(ve=q.getWireframeAttribute(W),ve===void 0)return;Ee=2}const Pe=W.drawRange,Be=W.attributes.position;let ye=Pe.start*Ee,$e=(Pe.start+Pe.count)*Ee;oe!==null&&(ye=Math.max(ye,oe.start*Ee),$e=Math.min($e,(oe.start+oe.count)*Ee)),ve!==null?(ye=Math.max(ye,0),$e=Math.min($e,ve.count)):Be!=null&&(ye=Math.max(ye,0),$e=Math.min($e,Be.count));const lt=$e-ye;if(lt<0||lt===1/0)return;te.setup(F,B,le,W,ve);let rt,je=Oe;if(ve!==null&&(rt=Z.get(ve),je=D,je.setIndex(rt)),F.isMesh)B.wireframe===!0?(Me.setLineWidth(B.wireframeLinewidth*ot()),je.setMode(C.LINES)):je.setMode(C.TRIANGLES);else if(F.isLine){let Mt=B.linewidth;Mt===void 0&&(Mt=1),Me.setLineWidth(Mt*ot()),F.isLineSegments?je.setMode(C.LINES):F.isLineLoop?je.setMode(C.LINE_LOOP):je.setMode(C.LINE_STRIP)}else F.isPoints?je.setMode(C.POINTS):F.isSprite&&je.setMode(C.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)ps("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),je.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(qe.get("WEBGL_multi_draw"))je.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Mt=F._multiDrawStarts,Se=F._multiDrawCounts,wt=F._multiDrawCount,ke=ve?Z.get(ve).bytesPerElement:1,Nt=_.get(B).currentProgram.getUniforms();for(let Gt=0;Gt<wt;Gt++)Nt.setValue(C,"_gl_DrawID",Gt),je.render(Mt[Gt]/ke,Se[Gt])}else if(F.isInstancedMesh)je.renderInstances(ye,lt,F.count);else if(W.isInstancedBufferGeometry){const Mt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,Se=Math.min(W.instanceCount,Mt);je.renderInstances(ye,lt,Se)}else je.render(ye,lt)};function fa(M,I,W){M.transparent===!0&&M.side===on&&M.forceSinglePass===!1?(M.side=Rt,M.needsUpdate=!0,Di(M,I,W),M.side=Tn,M.needsUpdate=!0,Di(M,I,W),M.side=on):Di(M,I,W)}this.compile=function(M,I,W=null){W===null&&(W=M),R=j.get(W),R.init(I),P.push(R),W.traverseVisible(function(F){F.isLight&&F.layers.test(I.layers)&&(R.pushLight(F),F.castShadow&&R.pushShadow(F))}),M!==W&&M.traverseVisible(function(F){F.isLight&&F.layers.test(I.layers)&&(R.pushLight(F),F.castShadow&&R.pushShadow(F))}),R.setupLights();const B=new Set;return M.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const oe=F.material;if(oe)if(Array.isArray(oe))for(let fe=0;fe<oe.length;fe++){const le=oe[fe];fa(le,W,F),B.add(le)}else fa(oe,W,F),B.add(oe)}),R=P.pop(),B},this.compileAsync=function(M,I,W=null){const B=this.compile(M,I,W);return new Promise(F=>{function oe(){if(B.forEach(function(fe){_.get(fe).currentProgram.isReady()&&B.delete(fe)}),B.size===0){F(M);return}setTimeout(oe,10)}qe.get("KHR_parallel_shader_compile")!==null?oe():setTimeout(oe,10)})};let Es=null;function pl(M){Es&&Es(M)}function da(){bn.stop()}function pa(){bn.start()}const bn=new ll;bn.setAnimationLoop(pl),typeof self<"u"&&bn.setContext(self),this.setAnimationLoop=function(M){Es=M,X.setAnimationLoop(M),M===null?bn.stop():bn.start()},X.addEventListener("sessionstart",da),X.addEventListener("sessionend",pa),this.render=function(M,I){if(I!==void 0&&I.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(V===!0)return;const W=X.enabled===!0&&X.isPresenting===!0,B=x!==null&&(O===null||W)&&x.begin(y,O);if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),X.enabled===!0&&X.isPresenting===!0&&(x===null||x.isCompositing()===!1)&&(X.cameraAutoUpdate===!0&&X.updateCamera(I),I=X.getCamera()),M.isScene===!0&&M.onBeforeRender(y,M,I,O),R=j.get(M,P.length),R.init(I),P.push(R),pt.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),De.setFromProjectionMatrix(pt,qt,I.reversedDepth),we=this.localClippingEnabled,be=ee.init(this.clippingPlanes,we),E=Ae.get(M,A.length),E.init(),A.push(E),X.enabled===!0&&X.isPresenting===!0){const fe=y.xr.getDepthSensingMesh();fe!==null&&ys(fe,I,-1/0,y.sortObjects)}ys(M,I,0,y.sortObjects),E.finish(),y.sortObjects===!0&&E.sort(it,nt),Fe=X.enabled===!1||X.isPresenting===!1||X.hasDepthSensing()===!1,Fe&&xe.addToRenderList(E,M),this.info.render.frame++,be===!0&&ee.beginShadows();const F=R.state.shadowsArray;if(_e.render(F,M,I),be===!0&&ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(B&&x.hasRenderPass())===!1){const fe=E.opaque,le=E.transmissive;if(R.setupLights(),I.isArrayCamera){const ve=I.cameras;if(le.length>0)for(let Ee=0,Pe=ve.length;Ee<Pe;Ee++){const Be=ve[Ee];_a(fe,le,M,Be)}Fe&&xe.render(M);for(let Ee=0,Pe=ve.length;Ee<Pe;Ee++){const Be=ve[Ee];ma(E,M,Be,Be.viewport)}}else le.length>0&&_a(fe,le,M,I),Fe&&xe.render(M),ma(E,M,I)}O!==null&&N===0&&(L.updateMultisampleRenderTarget(O),L.updateRenderTargetMipmap(O)),B&&x.end(y),M.isScene===!0&&M.onAfterRender(y,M,I),te.resetDefaultState(),k=-1,G=null,P.pop(),P.length>0?(R=P[P.length-1],be===!0&&ee.setGlobalState(y.clippingPlanes,R.state.camera)):R=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function ys(M,I,W,B){if(M.visible===!1)return;if(M.layers.test(I.layers)){if(M.isGroup)W=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(I);else if(M.isLight)R.pushLight(M),M.castShadow&&R.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||De.intersectsSprite(M)){B&&Ye.setFromMatrixPosition(M.matrixWorld).applyMatrix4(pt);const fe=me.update(M),le=M.material;le.visible&&E.push(M,fe,le,W,Ye.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||De.intersectsObject(M))){const fe=me.update(M),le=M.material;if(B&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Ye.copy(M.boundingSphere.center)):(fe.boundingSphere===null&&fe.computeBoundingSphere(),Ye.copy(fe.boundingSphere.center)),Ye.applyMatrix4(M.matrixWorld).applyMatrix4(pt)),Array.isArray(le)){const ve=fe.groups;for(let Ee=0,Pe=ve.length;Ee<Pe;Ee++){const Be=ve[Ee],ye=le[Be.materialIndex];ye&&ye.visible&&E.push(M,fe,ye,W,Ye.z,Be)}}else le.visible&&E.push(M,fe,le,W,Ye.z,null)}}const oe=M.children;for(let fe=0,le=oe.length;fe<le;fe++)ys(oe[fe],I,W,B)}function ma(M,I,W,B){const{opaque:F,transmissive:oe,transparent:fe}=M;R.setupLightsView(W),be===!0&&ee.setGlobalState(y.clippingPlanes,W),B&&Me.viewport(z.copy(B)),F.length>0&&Pi(F,I,W),oe.length>0&&Pi(oe,I,W),fe.length>0&&Pi(fe,I,W),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1)}function _a(M,I,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(R.state.transmissionRenderTarget[B.id]===void 0){const ye=qe.has("EXT_color_buffer_half_float")||qe.has("EXT_color_buffer_float");R.state.transmissionRenderTarget[B.id]=new Kt(1,1,{generateMipmaps:!0,type:ye?un:Dt,minFilter:Fn,samples:Math.max(4,et.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:He.workingColorSpace})}const oe=R.state.transmissionRenderTarget[B.id],fe=B.viewport||z;oe.setSize(fe.z*y.transmissionResolutionScale,fe.w*y.transmissionResolutionScale);const le=y.getRenderTarget(),ve=y.getActiveCubeFace(),Ee=y.getActiveMipmapLevel();y.setRenderTarget(oe),y.getClearColor($),ce=y.getClearAlpha(),ce<1&&y.setClearColor(16777215,.5),y.clear(),Fe&&xe.render(W);const Pe=y.toneMapping;y.toneMapping=Yt;const Be=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),R.setupLightsView(B),be===!0&&ee.setGlobalState(y.clippingPlanes,B),Pi(M,W,B),L.updateMultisampleRenderTarget(oe),L.updateRenderTargetMipmap(oe),qe.has("WEBGL_multisampled_render_to_texture")===!1){let ye=!1;for(let $e=0,lt=I.length;$e<lt;$e++){const rt=I[$e],{object:je,geometry:Mt,material:Se,group:wt}=rt;if(Se.side===on&&je.layers.test(B.layers)){const ke=Se.side;Se.side=Rt,Se.needsUpdate=!0,ga(je,W,B,Mt,Se,wt),Se.side=ke,Se.needsUpdate=!0,ye=!0}}ye===!0&&(L.updateMultisampleRenderTarget(oe),L.updateRenderTargetMipmap(oe))}y.setRenderTarget(le,ve,Ee),y.setClearColor($,ce),Be!==void 0&&(B.viewport=Be),y.toneMapping=Pe}function Pi(M,I,W){const B=I.isScene===!0?I.overrideMaterial:null;for(let F=0,oe=M.length;F<oe;F++){const fe=M[F],{object:le,geometry:ve,group:Ee}=fe;let Pe=fe.material;Pe.allowOverride===!0&&B!==null&&(Pe=B),le.layers.test(W.layers)&&ga(le,I,W,ve,Pe,Ee)}}function ga(M,I,W,B,F,oe){M.onBeforeRender(y,I,W,B,F,oe),M.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),F.onBeforeRender(y,I,W,B,M,oe),F.transparent===!0&&F.side===on&&F.forceSinglePass===!1?(F.side=Rt,F.needsUpdate=!0,y.renderBufferDirect(W,I,B,F,M,oe),F.side=Tn,F.needsUpdate=!0,y.renderBufferDirect(W,I,B,F,M,oe),F.side=on):y.renderBufferDirect(W,I,B,F,M,oe),M.onAfterRender(y,I,W,B,F,oe)}function Di(M,I,W){I.isScene!==!0&&(I=Je);const B=_.get(M),F=R.state.lights,oe=R.state.shadowsArray,fe=F.state.version,le=ie.getParameters(M,F.state,oe,I,W),ve=ie.getProgramCacheKey(le);let Ee=B.programs;B.environment=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?I.environment:null,B.fog=I.fog;const Pe=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap;B.envMap=Y.get(M.envMap||B.environment,Pe),B.envMapRotation=B.environment!==null&&M.envMap===null?I.environmentRotation:M.envMapRotation,Ee===void 0&&(M.addEventListener("dispose",Ke),Ee=new Map,B.programs=Ee);let Be=Ee.get(ve);if(Be!==void 0){if(B.currentProgram===Be&&B.lightsStateVersion===fe)return va(M,le),Be}else le.uniforms=ie.getUniforms(M),M.onBeforeCompile(le,y),Be=ie.acquireProgram(le,ve),Ee.set(ve,Be),B.uniforms=le.uniforms;const ye=B.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(ye.clippingPlanes=ee.uniform),va(M,le),B.needsLights=gl(M),B.lightsStateVersion=fe,B.needsLights&&(ye.ambientLightColor.value=F.state.ambient,ye.lightProbe.value=F.state.probe,ye.directionalLights.value=F.state.directional,ye.directionalLightShadows.value=F.state.directionalShadow,ye.spotLights.value=F.state.spot,ye.spotLightShadows.value=F.state.spotShadow,ye.rectAreaLights.value=F.state.rectArea,ye.ltc_1.value=F.state.rectAreaLTC1,ye.ltc_2.value=F.state.rectAreaLTC2,ye.pointLights.value=F.state.point,ye.pointLightShadows.value=F.state.pointShadow,ye.hemisphereLights.value=F.state.hemi,ye.directionalShadowMatrix.value=F.state.directionalShadowMatrix,ye.spotLightMatrix.value=F.state.spotLightMatrix,ye.spotLightMap.value=F.state.spotLightMap,ye.pointShadowMatrix.value=F.state.pointShadowMatrix),B.currentProgram=Be,B.uniformsList=null,Be}function xa(M){if(M.uniformsList===null){const I=M.currentProgram.getUniforms();M.uniformsList=us.seqWithValue(I.seq,M.uniforms)}return M.uniformsList}function va(M,I){const W=_.get(M);W.outputColorSpace=I.outputColorSpace,W.batching=I.batching,W.batchingColor=I.batchingColor,W.instancing=I.instancing,W.instancingColor=I.instancingColor,W.instancingMorph=I.instancingMorph,W.skinning=I.skinning,W.morphTargets=I.morphTargets,W.morphNormals=I.morphNormals,W.morphColors=I.morphColors,W.morphTargetsCount=I.morphTargetsCount,W.numClippingPlanes=I.numClippingPlanes,W.numIntersection=I.numClipIntersection,W.vertexAlphas=I.vertexAlphas,W.vertexTangents=I.vertexTangents,W.toneMapping=I.toneMapping}function ml(M,I,W,B,F){I.isScene!==!0&&(I=Je),L.resetTextureUnits();const oe=I.fog,fe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?I.environment:null,le=O===null?y.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:li,ve=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Ee=Y.get(B.envMap||fe,ve),Pe=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Be=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),ye=!!W.morphAttributes.position,$e=!!W.morphAttributes.normal,lt=!!W.morphAttributes.color;let rt=Yt;B.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(rt=y.toneMapping);const je=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Mt=je!==void 0?je.length:0,Se=_.get(B),wt=R.state.lights;if(be===!0&&(we===!0||M!==G)){const mt=M===G&&B.id===k;ee.setState(B,M,mt)}let ke=!1;B.version===Se.__version?(Se.needsLights&&Se.lightsStateVersion!==wt.state.version||Se.outputColorSpace!==le||F.isBatchedMesh&&Se.batching===!1||!F.isBatchedMesh&&Se.batching===!0||F.isBatchedMesh&&Se.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Se.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Se.instancing===!1||!F.isInstancedMesh&&Se.instancing===!0||F.isSkinnedMesh&&Se.skinning===!1||!F.isSkinnedMesh&&Se.skinning===!0||F.isInstancedMesh&&Se.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Se.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Se.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Se.instancingMorph===!1&&F.morphTexture!==null||Se.envMap!==Ee||B.fog===!0&&Se.fog!==oe||Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==ee.numPlanes||Se.numIntersection!==ee.numIntersection)||Se.vertexAlphas!==Pe||Se.vertexTangents!==Be||Se.morphTargets!==ye||Se.morphNormals!==$e||Se.morphColors!==lt||Se.toneMapping!==rt||Se.morphTargetsCount!==Mt)&&(ke=!0):(ke=!0,Se.__version=B.version);let Nt=Se.currentProgram;ke===!0&&(Nt=Di(B,I,F));let Gt=!1,An=!1,Gn=!1;const Qe=Nt.getUniforms(),xt=Se.uniforms;if(Me.useProgram(Nt.program)&&(Gt=!0,An=!0,Gn=!0),B.id!==k&&(k=B.id,An=!0),Gt||G!==M){Me.buffers.depth.getReversed()&&M.reversedDepth!==!0&&(M._reversedDepth=!0,M.updateProjectionMatrix()),Qe.setValue(C,"projectionMatrix",M.projectionMatrix),Qe.setValue(C,"viewMatrix",M.matrixWorldInverse);const mn=Qe.map.cameraPosition;mn!==void 0&&mn.setValue(C,Ge.setFromMatrixPosition(M.matrixWorld)),et.logarithmicDepthBuffer&&Qe.setValue(C,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Qe.setValue(C,"isOrthographic",M.isOrthographicCamera===!0),G!==M&&(G=M,An=!0,Gn=!0)}if(Se.needsLights&&(wt.state.directionalShadowMap.length>0&&Qe.setValue(C,"directionalShadowMap",wt.state.directionalShadowMap,L),wt.state.spotShadowMap.length>0&&Qe.setValue(C,"spotShadowMap",wt.state.spotShadowMap,L),wt.state.pointShadowMap.length>0&&Qe.setValue(C,"pointShadowMap",wt.state.pointShadowMap,L)),F.isSkinnedMesh){Qe.setOptional(C,F,"bindMatrix"),Qe.setOptional(C,F,"bindMatrixInverse");const mt=F.skeleton;mt&&(mt.boneTexture===null&&mt.computeBoneTexture(),Qe.setValue(C,"boneTexture",mt.boneTexture,L))}F.isBatchedMesh&&(Qe.setOptional(C,F,"batchingTexture"),Qe.setValue(C,"batchingTexture",F._matricesTexture,L),Qe.setOptional(C,F,"batchingIdTexture"),Qe.setValue(C,"batchingIdTexture",F._indirectTexture,L),Qe.setOptional(C,F,"batchingColorTexture"),F._colorsTexture!==null&&Qe.setValue(C,"batchingColorTexture",F._colorsTexture,L));const pn=W.morphAttributes;if((pn.position!==void 0||pn.normal!==void 0||pn.color!==void 0)&&he.update(F,W,Nt),(An||Se.receiveShadow!==F.receiveShadow)&&(Se.receiveShadow=F.receiveShadow,Qe.setValue(C,"receiveShadow",F.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&I.environment!==null&&(xt.envMapIntensity.value=I.environmentIntensity),xt.dfgLUT!==void 0&&(xt.dfgLUT.value=Fp()),An&&(Qe.setValue(C,"toneMappingExposure",y.toneMappingExposure),Se.needsLights&&_l(xt,Gn),oe&&B.fog===!0&&Te.refreshFogUniforms(xt,oe),Te.refreshMaterialUniforms(xt,B,Ie,ue,R.state.transmissionRenderTarget[M.id]),us.upload(C,xa(Se),xt,L)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(us.upload(C,xa(Se),xt,L),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Qe.setValue(C,"center",F.center),Qe.setValue(C,"modelViewMatrix",F.modelViewMatrix),Qe.setValue(C,"normalMatrix",F.normalMatrix),Qe.setValue(C,"modelMatrix",F.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){const mt=B.uniformsGroups;for(let mn=0,Hn=mt.length;mn<Hn;mn++){const Ma=mt[mn];de.update(Ma,Nt),de.bind(Ma,Nt)}}return Nt}function _l(M,I){M.ambientLightColor.needsUpdate=I,M.lightProbe.needsUpdate=I,M.directionalLights.needsUpdate=I,M.directionalLightShadows.needsUpdate=I,M.pointLights.needsUpdate=I,M.pointLightShadows.needsUpdate=I,M.spotLights.needsUpdate=I,M.spotLightShadows.needsUpdate=I,M.rectAreaLights.needsUpdate=I,M.hemisphereLights.needsUpdate=I}function gl(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(M,I,W){const B=_.get(M);B.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),_.get(M.texture).__webglTexture=I,_.get(M.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,I){const W=_.get(M);W.__webglFramebuffer=I,W.__useDefaultFramebuffer=I===void 0};const xl=C.createFramebuffer();this.setRenderTarget=function(M,I=0,W=0){O=M,w=I,N=W;let B=null,F=!1,oe=!1;if(M){const le=_.get(M);if(le.__useDefaultFramebuffer!==void 0){Me.bindFramebuffer(C.FRAMEBUFFER,le.__webglFramebuffer),z.copy(M.viewport),H.copy(M.scissor),Q=M.scissorTest,Me.viewport(z),Me.scissor(H),Me.setScissorTest(Q),k=-1;return}else if(le.__webglFramebuffer===void 0)L.setupRenderTarget(M);else if(le.__hasExternalTextures)L.rebindTextures(M,_.get(M.texture).__webglTexture,_.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Pe=M.depthTexture;if(le.__boundDepthTexture!==Pe){if(Pe!==null&&_.has(Pe)&&(M.width!==Pe.image.width||M.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");L.setupDepthRenderbuffer(M)}}const ve=M.texture;(ve.isData3DTexture||ve.isDataArrayTexture||ve.isCompressedArrayTexture)&&(oe=!0);const Ee=_.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Ee[I])?B=Ee[I][W]:B=Ee[I],F=!0):M.samples>0&&L.useMultisampledRTT(M)===!1?B=_.get(M).__webglMultisampledFramebuffer:Array.isArray(Ee)?B=Ee[W]:B=Ee,z.copy(M.viewport),H.copy(M.scissor),Q=M.scissorTest}else z.copy(K).multiplyScalar(Ie).floor(),H.copy(ne).multiplyScalar(Ie).floor(),Q=re;if(W!==0&&(B=xl),Me.bindFramebuffer(C.FRAMEBUFFER,B)&&Me.drawBuffers(M,B),Me.viewport(z),Me.scissor(H),Me.setScissorTest(Q),F){const le=_.get(M.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+I,le.__webglTexture,W)}else if(oe){const le=I;for(let ve=0;ve<M.textures.length;ve++){const Ee=_.get(M.textures[ve]);C.framebufferTextureLayer(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0+ve,Ee.__webglTexture,W,le)}}else if(M!==null&&W!==0){const le=_.get(M.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,le.__webglTexture,W)}k=-1},this.readRenderTargetPixels=function(M,I,W,B,F,oe,fe,le=0){if(!(M&&M.isWebGLRenderTarget)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ve=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&fe!==void 0&&(ve=ve[fe]),ve){Me.bindFramebuffer(C.FRAMEBUFFER,ve);try{const Ee=M.textures[le],Pe=Ee.format,Be=Ee.type;if(M.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+le),!et.textureFormatReadable(Pe)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!et.textureTypeReadable(Be)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=M.width-B&&W>=0&&W<=M.height-F&&C.readPixels(I,W,B,F,se.convert(Pe),se.convert(Be),oe)}finally{const Ee=O!==null?_.get(O).__webglFramebuffer:null;Me.bindFramebuffer(C.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(M,I,W,B,F,oe,fe,le=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&fe!==void 0&&(ve=ve[fe]),ve)if(I>=0&&I<=M.width-B&&W>=0&&W<=M.height-F){Me.bindFramebuffer(C.FRAMEBUFFER,ve);const Ee=M.textures[le],Pe=Ee.format,Be=Ee.type;if(M.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+le),!et.textureFormatReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ye=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,ye),C.bufferData(C.PIXEL_PACK_BUFFER,oe.byteLength,C.STREAM_READ),C.readPixels(I,W,B,F,se.convert(Pe),se.convert(Be),0);const $e=O!==null?_.get(O).__webglFramebuffer:null;Me.bindFramebuffer(C.FRAMEBUFFER,$e);const lt=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await tc(C,lt,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,ye),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,oe),C.deleteBuffer(ye),C.deleteSync(lt),oe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,I=null,W=0){const B=Math.pow(2,-W),F=Math.floor(M.image.width*B),oe=Math.floor(M.image.height*B),fe=I!==null?I.x:0,le=I!==null?I.y:0;L.setTexture2D(M,0),C.copyTexSubImage2D(C.TEXTURE_2D,W,0,0,fe,le,F,oe),Me.unbindTexture()};const vl=C.createFramebuffer(),Ml=C.createFramebuffer();this.copyTextureToTexture=function(M,I,W=null,B=null,F=0,oe=0){let fe,le,ve,Ee,Pe,Be,ye,$e,lt;const rt=M.isCompressedTexture?M.mipmaps[oe]:M.image;if(W!==null)fe=W.max.x-W.min.x,le=W.max.y-W.min.y,ve=W.isBox3?W.max.z-W.min.z:1,Ee=W.min.x,Pe=W.min.y,Be=W.isBox3?W.min.z:0;else{const xt=Math.pow(2,-F);fe=Math.floor(rt.width*xt),le=Math.floor(rt.height*xt),M.isDataArrayTexture?ve=rt.depth:M.isData3DTexture?ve=Math.floor(rt.depth*xt):ve=1,Ee=0,Pe=0,Be=0}B!==null?(ye=B.x,$e=B.y,lt=B.z):(ye=0,$e=0,lt=0);const je=se.convert(I.format),Mt=se.convert(I.type);let Se;I.isData3DTexture?(L.setTexture3D(I,0),Se=C.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(L.setTexture2DArray(I,0),Se=C.TEXTURE_2D_ARRAY):(L.setTexture2D(I,0),Se=C.TEXTURE_2D),C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,I.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,I.unpackAlignment);const wt=C.getParameter(C.UNPACK_ROW_LENGTH),ke=C.getParameter(C.UNPACK_IMAGE_HEIGHT),Nt=C.getParameter(C.UNPACK_SKIP_PIXELS),Gt=C.getParameter(C.UNPACK_SKIP_ROWS),An=C.getParameter(C.UNPACK_SKIP_IMAGES);C.pixelStorei(C.UNPACK_ROW_LENGTH,rt.width),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,rt.height),C.pixelStorei(C.UNPACK_SKIP_PIXELS,Ee),C.pixelStorei(C.UNPACK_SKIP_ROWS,Pe),C.pixelStorei(C.UNPACK_SKIP_IMAGES,Be);const Gn=M.isDataArrayTexture||M.isData3DTexture,Qe=I.isDataArrayTexture||I.isData3DTexture;if(M.isDepthTexture){const xt=_.get(M),pn=_.get(I),mt=_.get(xt.__renderTarget),mn=_.get(pn.__renderTarget);Me.bindFramebuffer(C.READ_FRAMEBUFFER,mt.__webglFramebuffer),Me.bindFramebuffer(C.DRAW_FRAMEBUFFER,mn.__webglFramebuffer);for(let Hn=0;Hn<ve;Hn++)Gn&&(C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,_.get(M).__webglTexture,F,Be+Hn),C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,_.get(I).__webglTexture,oe,lt+Hn)),C.blitFramebuffer(Ee,Pe,fe,le,ye,$e,fe,le,C.DEPTH_BUFFER_BIT,C.NEAREST);Me.bindFramebuffer(C.READ_FRAMEBUFFER,null),Me.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else if(F!==0||M.isRenderTargetTexture||_.has(M)){const xt=_.get(M),pn=_.get(I);Me.bindFramebuffer(C.READ_FRAMEBUFFER,vl),Me.bindFramebuffer(C.DRAW_FRAMEBUFFER,Ml);for(let mt=0;mt<ve;mt++)Gn?C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,xt.__webglTexture,F,Be+mt):C.framebufferTexture2D(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,xt.__webglTexture,F),Qe?C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,pn.__webglTexture,oe,lt+mt):C.framebufferTexture2D(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,pn.__webglTexture,oe),F!==0?C.blitFramebuffer(Ee,Pe,fe,le,ye,$e,fe,le,C.COLOR_BUFFER_BIT,C.NEAREST):Qe?C.copyTexSubImage3D(Se,oe,ye,$e,lt+mt,Ee,Pe,fe,le):C.copyTexSubImage2D(Se,oe,ye,$e,Ee,Pe,fe,le);Me.bindFramebuffer(C.READ_FRAMEBUFFER,null),Me.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else Qe?M.isDataTexture||M.isData3DTexture?C.texSubImage3D(Se,oe,ye,$e,lt,fe,le,ve,je,Mt,rt.data):I.isCompressedArrayTexture?C.compressedTexSubImage3D(Se,oe,ye,$e,lt,fe,le,ve,je,rt.data):C.texSubImage3D(Se,oe,ye,$e,lt,fe,le,ve,je,Mt,rt):M.isDataTexture?C.texSubImage2D(C.TEXTURE_2D,oe,ye,$e,fe,le,je,Mt,rt.data):M.isCompressedTexture?C.compressedTexSubImage2D(C.TEXTURE_2D,oe,ye,$e,rt.width,rt.height,je,rt.data):C.texSubImage2D(C.TEXTURE_2D,oe,ye,$e,fe,le,je,Mt,rt);C.pixelStorei(C.UNPACK_ROW_LENGTH,wt),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,ke),C.pixelStorei(C.UNPACK_SKIP_PIXELS,Nt),C.pixelStorei(C.UNPACK_SKIP_ROWS,Gt),C.pixelStorei(C.UNPACK_SKIP_IMAGES,An),oe===0&&I.generateMipmaps&&C.generateMipmap(Se),Me.unbindTexture()},this.initRenderTarget=function(M){_.get(M).__webglFramebuffer===void 0&&L.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?L.setTextureCube(M,0):M.isData3DTexture?L.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?L.setTexture2DArray(M,0):L.setTexture2D(M,0),Me.unbindTexture()},this.resetState=function(){w=0,N=0,O=null,Me.reset(),te.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=He._getDrawingBufferColorSpace(e),t.unpackColorSpace=He._getUnpackColorSpace()}}export{Do as $,Co as A,Rt as B,Kp as C,Xp as D,un as E,qo as F,$p as G,kp as H,tl as I,Yp as J,Uc as K,$o as L,Nc as M,cn as N,ua as O,Ut as P,He as Q,nl as R,Vp as S,sl as T,Dc as U,Ve as V,Jp as W,Ze as X,Ao as Y,Ro as Z,wo as _,It as a,Lo as a0,Po as a1,st as a2,ut as a3,jp as a4,Op as a5,Bp as a6,hi as a7,Zp as a8,oa as a9,In as aa,zp as ab,yl as b,qp as c,Wp as d,xs as e,dn as f,Zo as g,on as h,il as i,Jt as j,Ne as k,gt as l,Zt as m,Ea as n,Gp as o,Ni as p,Hp as q,Ci as r,ca as s,el as t,U as u,Qo as v,wc as w,Ac as x,Xe as y,Kt as z};