@thinkersteps_labs/3d-viewer-react-native 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/Viewer.d.ts +5 -0
  2. package/dist/Viewer.d.ts.map +1 -0
  3. package/dist/Viewer.js +157 -0
  4. package/dist/Viewer.js.map +1 -0
  5. package/dist/bridge/ar-launcher.d.ts +6 -0
  6. package/dist/bridge/ar-launcher.d.ts.map +1 -0
  7. package/dist/bridge/ar-launcher.js +18 -0
  8. package/dist/bridge/ar-launcher.js.map +1 -0
  9. package/dist/bridge/runtime-bundle.d.ts +2 -0
  10. package/dist/bridge/runtime-bundle.d.ts.map +1 -0
  11. package/dist/bridge/runtime-bundle.js +3 -0
  12. package/dist/bridge/runtime-bundle.js.map +1 -0
  13. package/dist/bridge/runtime-entry.d.ts +2 -0
  14. package/dist/bridge/runtime-entry.d.ts.map +1 -0
  15. package/dist/bridge/runtime-entry.js +616 -0
  16. package/dist/bridge/runtime-entry.js.map +1 -0
  17. package/dist/bridge/types.d.ts +186 -0
  18. package/dist/bridge/types.d.ts.map +1 -0
  19. package/dist/bridge/types.js +2 -0
  20. package/dist/bridge/types.js.map +1 -0
  21. package/dist/hooks/useViewerBridge.d.ts +16 -0
  22. package/dist/hooks/useViewerBridge.d.ts.map +1 -0
  23. package/dist/hooks/useViewerBridge.js +565 -0
  24. package/dist/hooks/useViewerBridge.js.map +1 -0
  25. package/dist/hooks/useViewerGestureLock.d.ts +23 -0
  26. package/dist/hooks/useViewerGestureLock.d.ts.map +1 -0
  27. package/dist/hooks/useViewerGestureLock.js +49 -0
  28. package/dist/hooks/useViewerGestureLock.js.map +1 -0
  29. package/dist/index.d.ts +9 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +7 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/swatches/JewelryCustomizer.d.ts +16 -0
  34. package/dist/swatches/JewelryCustomizer.d.ts.map +1 -0
  35. package/dist/swatches/JewelryCustomizer.js +36 -0
  36. package/dist/swatches/JewelryCustomizer.js.map +1 -0
  37. package/dist/swatches/MetalSwatches.d.ts +13 -0
  38. package/dist/swatches/MetalSwatches.d.ts.map +1 -0
  39. package/dist/swatches/MetalSwatches.js +81 -0
  40. package/dist/swatches/MetalSwatches.js.map +1 -0
  41. package/dist/swatches/ShapeSelect.d.ts +15 -0
  42. package/dist/swatches/ShapeSelect.d.ts.map +1 -0
  43. package/dist/swatches/ShapeSelect.js +226 -0
  44. package/dist/swatches/ShapeSelect.js.map +1 -0
  45. package/dist/swatches/ShapeSwatches.d.ts +22 -0
  46. package/dist/swatches/ShapeSwatches.d.ts.map +1 -0
  47. package/dist/swatches/ShapeSwatches.js +144 -0
  48. package/dist/swatches/ShapeSwatches.js.map +1 -0
  49. package/dist/swatches/StoneSwatches.d.ts +13 -0
  50. package/dist/swatches/StoneSwatches.d.ts.map +1 -0
  51. package/dist/swatches/StoneSwatches.js +81 -0
  52. package/dist/swatches/StoneSwatches.js.map +1 -0
  53. package/dist/swatches/index.d.ts +7 -0
  54. package/dist/swatches/index.d.ts.map +1 -0
  55. package/dist/swatches/index.js +7 -0
  56. package/dist/swatches/index.js.map +1 -0
  57. package/dist/swatches/useJewelryCustomizer.d.ts +33 -0
  58. package/dist/swatches/useJewelryCustomizer.d.ts.map +1 -0
  59. package/dist/swatches/useJewelryCustomizer.js +43 -0
  60. package/dist/swatches/useJewelryCustomizer.js.map +1 -0
  61. package/dist/types.d.ts +103 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +2 -0
  64. package/dist/types.js.map +1 -0
  65. package/package.json +50 -6
  66. package/README.md +0 -3
@@ -0,0 +1,3 @@
1
+ // Auto-generated by scripts/bundle-runtime.mjs - DO NOT EDIT MANUALLY
2
+ export const DEFAULT_EMBEDDED_HTML = "<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n html, body { width: 100%; height: 100%; overflow: hidden; background: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }\n #viewer-container { width: 100%; height: 100%; position: relative; }\n #viewer-container canvas { width: 100% !important; height: 100% !important; display: block; touch-action: none; }\n #ar-anchor { display: none; }\n </style>\n</head>\n<body>\n <div id=\"viewer-container\">\n <a id=\"ar-anchor\" rel=\"ar\" href=\"#\"><img alt=\"AR\" /></a>\n </div>\n <script>\n(function(){\"use strict\";/**\n * @license\n * Copyright 2010-2023 Three.js Authors\n * SPDX-License-Identifier: MIT\n */const ds=\"160\",dr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},hr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wf=0,Ol=1,Af=2,Bl=1,Rf=2,ni=3,Mn=0,on=1,wt=2,ii=0,fr=1,kl=2,zl=3,Gl=4,Cf=5,Vi=100,Pf=101,Lf=102,Hl=103,Vl=104,If=200,Df=201,Nf=202,Uf=203,_o=204,vo=205,Ff=206,Of=207,Bf=208,kf=209,zf=210,Gf=211,Hf=212,Vf=213,Wf=214,jf=0,Xf=1,qf=2,Xs=3,Yf=4,Kf=5,Zf=6,$f=7,xo=0,Jf=1,Qf=2,ri=0,ep=1,tp=2,np=3,Wl=4,ip=5,rp=6,jl=\"attached\",sp=\"detached\",Xl=300,pr=301,mr=302,yo=303,Mo=304,qs=306,Si=1e3,gn=1001,hs=1002,yt=1003,Ys=1004,fs=1005,At=1006,So=1007,si=1008,In=1009,Eo=1010,ql=1011,Ks=1012,ps=1013,wn=1014,jt=1015,cn=1016,Yl=1017,Kl=1018,Wi=1020,ap=1021,kt=1023,op=1024,cp=1025,ji=1026,gr=1027,To=1028,wo=1029,Zl=1030,Zs=1031,ms=1033,Ao=33776,Ro=33777,Co=33778,Po=33779,$l=35840,Jl=35841,Ql=35842,eu=35843,tu=36196,nu=37492,iu=37496,ru=37808,su=37809,au=37810,ou=37811,cu=37812,lu=37813,uu=37814,du=37815,hu=37816,fu=37817,pu=37818,mu=37819,gu=37820,bu=37821,Lo=36492,_u=36494,vu=36495,lp=36283,xu=36284,yu=36285,Mu=36286,br=2300,Xi=2301,Io=2302,Su=2400,Eu=2401,Tu=2402,up=2500,dp=0,wu=1,Do=2,Au=3e3,qi=3001,hp=3200,fp=3201,No=0,pp=1,Sn=\"\",Mt=\"srgb\",zt=\"srgb-linear\",Uo=\"display-p3\",$s=\"display-p3-linear\",Js=\"linear\",Ct=\"srgb\",Qs=\"rec709\",ea=\"p3\",_r=7680,Ru=519,mp=512,gp=513,bp=514,Cu=515,_p=516,vp=517,xp=518,yp=519,Fo=35044,ta=\"300 es\",Oo=1035,ai=2e3,na=2001;class Yi{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){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const fn=[\"00\",\"01\",\"02\",\"03\",\"04\",\"05\",\"06\",\"07\",\"08\",\"09\",\"0a\",\"0b\",\"0c\",\"0d\",\"0e\",\"0f\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"1a\",\"1b\",\"1c\",\"1d\",\"1e\",\"1f\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"2a\",\"2b\",\"2c\",\"2d\",\"2e\",\"2f\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"36\",\"37\",\"38\",\"39\",\"3a\",\"3b\",\"3c\",\"3d\",\"3e\",\"3f\",\"40\",\"41\",\"42\",\"43\",\"44\",\"45\",\"46\",\"47\",\"48\",\"49\",\"4a\",\"4b\",\"4c\",\"4d\",\"4e\",\"4f\",\"50\",\"51\",\"52\",\"53\",\"54\",\"55\",\"56\",\"57\",\"58\",\"59\",\"5a\",\"5b\",\"5c\",\"5d\",\"5e\",\"5f\",\"60\",\"61\",\"62\",\"63\",\"64\",\"65\",\"66\",\"67\",\"68\",\"69\",\"6a\",\"6b\",\"6c\",\"6d\",\"6e\",\"6f\",\"70\",\"71\",\"72\",\"73\",\"74\",\"75\",\"76\",\"77\",\"78\",\"79\",\"7a\",\"7b\",\"7c\",\"7d\",\"7e\",\"7f\",\"80\",\"81\",\"82\",\"83\",\"84\",\"85\",\"86\",\"87\",\"88\",\"89\",\"8a\",\"8b\",\"8c\",\"8d\",\"8e\",\"8f\",\"90\",\"91\",\"92\",\"93\",\"94\",\"95\",\"96\",\"97\",\"98\",\"99\",\"9a\",\"9b\",\"9c\",\"9d\",\"9e\",\"9f\",\"a0\",\"a1\",\"a2\",\"a3\",\"a4\",\"a5\",\"a6\",\"a7\",\"a8\",\"a9\",\"aa\",\"ab\",\"ac\",\"ad\",\"ae\",\"af\",\"b0\",\"b1\",\"b2\",\"b3\",\"b4\",\"b5\",\"b6\",\"b7\",\"b8\",\"b9\",\"ba\",\"bb\",\"bc\",\"bd\",\"be\",\"bf\",\"c0\",\"c1\",\"c2\",\"c3\",\"c4\",\"c5\",\"c6\",\"c7\",\"c8\",\"c9\",\"ca\",\"cb\",\"cc\",\"cd\",\"ce\",\"cf\",\"d0\",\"d1\",\"d2\",\"d3\",\"d4\",\"d5\",\"d6\",\"d7\",\"d8\",\"d9\",\"da\",\"db\",\"dc\",\"dd\",\"de\",\"df\",\"e0\",\"e1\",\"e2\",\"e3\",\"e4\",\"e5\",\"e6\",\"e7\",\"e8\",\"e9\",\"ea\",\"eb\",\"ec\",\"ed\",\"ee\",\"ef\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"fa\",\"fb\",\"fc\",\"fd\",\"fe\",\"ff\"];let Pu=1234567;const gs=Math.PI/180,vr=180/Math.PI;function Vn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(fn[r&255]+fn[r>>8&255]+fn[r>>16&255]+fn[r>>24&255]+\"-\"+fn[e&255]+fn[e>>8&255]+\"-\"+fn[e>>16&15|64]+fn[e>>24&255]+\"-\"+fn[t&63|128]+fn[t>>8&255]+\"-\"+fn[t>>16&255]+fn[t>>24&255]+fn[n&255]+fn[n>>8&255]+fn[n>>16&255]+fn[n>>24&255]).toLowerCase()}function $t(r,e,t){return Math.max(e,Math.min(t,r))}function Bo(r,e){return(r%e+e)%e}function Mp(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Sp(r,e,t){return r!==e?(t-r)/(e-r):0}function bs(r,e,t){return(1-t)*r+t*e}function Ep(r,e,t,n){return bs(r,e,1-Math.exp(-t*n))}function Tp(r,e=1){return e-Math.abs(Bo(r,e*2)-e)}function wp(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Ap(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Rp(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Cp(r,e){return r+Math.random()*(e-r)}function Pp(r){return r*(.5-Math.random())}function Lp(r){r!==void 0&&(Pu=r);let e=Pu+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Ip(r){return r*gs}function Dp(r){return r*vr}function ko(r){return(r&r-1)===0&&r!==0}function Np(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ia(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Up(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),u=a((e+n)/2),d=s((e-n)/2),h=a((e-n)/2),f=s((n-e)/2),g=a((n-e)/2);switch(i){case\"XYX\":r.set(o*u,c*d,c*h,o*l);break;case\"YZY\":r.set(c*h,o*u,c*d,o*l);break;case\"ZXZ\":r.set(c*d,c*h,o*u,o*l);break;case\"XZX\":r.set(o*u,c*g,c*f,o*l);break;case\"YXY\":r.set(c*f,o*u,c*g,o*l);break;case\"ZYZ\":r.set(c*g,c*f,o*u,o*l);break;default:console.warn(\"THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: \"+i)}}function Jn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error(\"Invalid component type.\")}}function St(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error(\"Invalid component type.\")}}const xr={DEG2RAD:gs,RAD2DEG:vr,generateUUID:Vn,clamp:$t,euclideanModulo:Bo,mapLinear:Mp,inverseLerp:Sp,lerp:bs,damp:Ep,pingpong:Tp,smoothstep:wp,smootherstep:Ap,randInt:Rp,randFloat:Cp,randFloatSpread:Pp,seededRandom:Lp,degToRad:Ip,radToDeg:Dp,isPowerOfTwo:ko,ceilPowerOfTwo:Np,floorPowerOfTwo:ia,setQuaternionFromProperEuler:Up,normalize:St,denormalize:Jn};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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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($t(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),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+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 ct{constructor(e,t,n,i,s,a,o,c,l){ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[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,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],d=n[7],h=n[2],f=n[5],g=n[8],v=i[0],m=i[3],p=i[6],_=i[1],b=i[4],x=i[7],E=i[2],T=i[5],A=i[8];return s[0]=a*v+o*_+c*E,s[3]=a*m+o*b+c*T,s[6]=a*p+o*x+c*A,s[1]=l*v+u*_+d*E,s[4]=l*m+u*b+d*T,s[7]=l*p+u*x+d*A,s[2]=h*v+f*_+g*E,s[5]=h*m+f*b+g*T,s[8]=h*p+f*x+g*A,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],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],d=u*a-o*l,h=o*c-u*s,f=l*s-a*c,g=t*d+n*h+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=d*v,e[1]=(i*l-u*n)*v,e[2]=(o*n-i*a)*v,e[3]=h*v,e[4]=(u*t-i*c)*v,e[5]=(i*s-o*t)*v,e[6]=f*v,e[7]=(n*c-l*t)*v,e[8]=(a*t-n*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(zo.makeScale(e,t)),this}rotate(e){return this.premultiply(zo.makeRotation(-e)),this}translate(e,t){return this.premultiply(zo.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 i=0;i<9;i++)if(t[i]!==n[i])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 zo=new ct;function Lu(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function _s(r){return document.createElementNS(\"http://www.w3.org/1999/xhtml\",r)}function Fp(){const r=_s(\"canvas\");return r.style.display=\"block\",r}const Iu={};function vs(r){r in Iu||(Iu[r]=!0,console.warn(r))}const Du=new ct().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Nu=new ct().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ra={[zt]:{transfer:Js,primaries:Qs,toReference:r=>r,fromReference:r=>r},[Mt]:{transfer:Ct,primaries:Qs,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[$s]:{transfer:Js,primaries:ea,toReference:r=>r.applyMatrix3(Nu),fromReference:r=>r.applyMatrix3(Du)},[Uo]:{transfer:Ct,primaries:ea,toReference:r=>r.convertSRGBToLinear().applyMatrix3(Nu),fromReference:r=>r.applyMatrix3(Du).convertLinearToSRGB()}},Op=new Set([zt,$s]),xt={enabled:!0,_workingColorSpace:zt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!Op.has(r))throw new Error(`Unsupported working color space, \"${r}\".`);this._workingColorSpace=r},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=ra[e].toReference,i=ra[t].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this._workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this._workingColorSpace)},getPrimaries:function(r){return ra[r].primaries},getTransfer:function(r){return r===Sn?Js:ra[r].transfer}};function yr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Go(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Mr;class Uu{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>\"u\")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Mr===void 0&&(Mr=_s(\"canvas\")),Mr.width=e.width,Mr.height=e.height;const n=Mr.getContext(\"2d\");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Mr}return t.width>2048||t.height>2048?(console.warn(\"THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons\",e),t.toDataURL(\"image/jpeg\",.6)):t.toDataURL(\"image/png\")}static sRGBToLinear(e){if(typeof HTMLImageElement<\"u\"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<\"u\"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<\"u\"&&e instanceof ImageBitmap){const t=_s(\"canvas\");t.width=e.width,t.height=e.height;const n=t.getContext(\"2d\");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=yr(s[a]/255)*255;return n.putImageData(i,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(yr(t[n]/255)*255):t[n]=yr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn(\"THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.\"),e}}let Bp=0;class Ho{constructor(e=null){this.isSource=!0,Object.defineProperty(this,\"id\",{value:Bp++}),this.uuid=Vn(),this.data=e,this.version=0}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:\"\"},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Vo(i[a].image)):s.push(Vo(i[a]))}else s=Vo(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Vo(r){return typeof HTMLImageElement<\"u\"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<\"u\"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<\"u\"&&r instanceof ImageBitmap?Uu.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn(\"THREE.Texture: Unable to serialize Texture.\"),{})}let kp=0;class Xt extends Yi{constructor(e=Xt.DEFAULT_IMAGE,t=Xt.DEFAULT_MAPPING,n=gn,i=gn,s=At,a=si,o=kt,c=In,l=Xt.DEFAULT_ANISOTROPY,u=Sn){super(),this.isTexture=!0,Object.defineProperty(this,\"id\",{value:kp++}),this.uuid=Vn(),this.name=\"\",this.source=new Ho(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,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 ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u==\"string\"?this.colorSpace=u:(vs(\"THREE.Texture: Property .encoding has been replaced by .colorSpace.\"),this.colorSpace=u===qi?Mt:Sn),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.6,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!==Xl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Si:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case hs: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 Si:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case hs: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)}get encoding(){return vs(\"THREE.Texture: Property .encoding has been replaced by .colorSpace.\"),this.colorSpace===Mt?qi:Au}set encoding(e){vs(\"THREE.Texture: Property .encoding has been replaced by .colorSpace.\"),this.colorSpace=e===qi?Mt:Sn}}Xt.DEFAULT_IMAGE=null,Xt.DEFAULT_MAPPING=Xl,Xt.DEFAULT_ANISOTROPY=1;class Tt{constructor(e=0,t=0,n=0,i=1){Tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,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,i,s;const c=e.elements,l=c[0],u=c[4],d=c[8],h=c[1],f=c[5],g=c[9],v=c[2],m=c[6],p=c[10];if(Math.abs(u-h)<.01&&Math.abs(d-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+v)<.1&&Math.abs(g+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,x=(f+1)/2,E=(p+1)/2,T=(u+h)/4,A=(d+v)/4,I=(g+m)/4;return b>x&&b>E?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=T/n,s=A/n):x>E?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=T/i,s=I/i):E<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),n=A/s,i=I/s),this.set(n,i,s,t),this}let _=Math.sqrt((m-g)*(m-g)+(d-v)*(d-v)+(h-u)*(h-u));return Math.abs(_)<.001&&(_=1),this.x=(m-g)/_,this.y=(d-v)/_,this.z=(h-u)/_,this.w=Math.acos((l+f+p-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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 zp extends Yi{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Tt(0,0,e,t),this.scissorTest=!1,this.viewport=new Tt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(vs(\"THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace.\"),n.colorSpace=n.encoding===qi?Mt:Sn),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},n),this.texture=new Xt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps,this.texture.internalFormat=n.internalFormat,this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Ho(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:\"dispose\"})}}class Ki extends zp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Fu extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gp extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Dn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],u=n[i+2],d=n[i+3];const h=s[a+0],f=s[a+1],g=s[a+2],v=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;return}if(o===1){e[t+0]=h,e[t+1]=f,e[t+2]=g,e[t+3]=v;return}if(d!==v||c!==h||l!==f||u!==g){let m=1-o;const p=c*h+l*f+u*g+d*v,_=p>=0?1:-1,b=1-p*p;if(b>Number.EPSILON){const E=Math.sqrt(b),T=Math.atan2(E,p*_);m=Math.sin(m*T)/E,o=Math.sin(o*T)/E}const x=o*_;if(c=c*m+h*x,l=l*m+f*x,u=u*m+g*x,d=d*m+v*x,m===1-o){const E=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=E,l*=E,u*=E,d*=E}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],d=s[a],h=s[a+1],f=s[a+2],g=s[a+3];return e[t]=o*g+u*d+c*f-l*h,e[t+1]=c*g+u*h+l*d-o*f,e[t+2]=l*g+u*f+o*h-c*d,e[t+3]=u*g-o*d-c*h-l*f,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),d=o(s/2),h=c(n/2),f=c(i/2),g=c(s/2);switch(a){case\"XYZ\":this._x=h*u*d+l*f*g,this._y=l*f*d-h*u*g,this._z=l*u*g+h*f*d,this._w=l*u*d-h*f*g;break;case\"YXZ\":this._x=h*u*d+l*f*g,this._y=l*f*d-h*u*g,this._z=l*u*g-h*f*d,this._w=l*u*d+h*f*g;break;case\"ZXY\":this._x=h*u*d-l*f*g,this._y=l*f*d+h*u*g,this._z=l*u*g+h*f*d,this._w=l*u*d-h*f*g;break;case\"ZYX\":this._x=h*u*d-l*f*g,this._y=l*f*d+h*u*g,this._z=l*u*g-h*f*d,this._w=l*u*d+h*f*g;break;case\"YZX\":this._x=h*u*d+l*f*g,this._y=l*f*d+h*u*g,this._z=l*u*g-h*f*d,this._w=l*u*d-h*f*g;break;case\"XZY\":this._x=h*u*d-l*f*g,this._y=l*f*d-h*u*g,this._z=l*u*g+h*f*d,this._w=l*u*d+h*f*g;break;default:console.warn(\"THREE.Quaternion: .setFromEuler() encountered an unknown order: \"+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],d=t[10],h=n+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(a-i)*f}else if(n>o&&n>d){const f=2*Math.sqrt(1+n-o-d);this._w=(u-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+l)/f}else if(o>d){const f=2*Math.sqrt(1+o-n-d);this._w=(s-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+u)/f}else{const f=2*Math.sqrt(1+d-n-o);this._w=(a-i)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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($t(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-s*c,this._y=i*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-i*o,this._w=a*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),d=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=a*d+this._w*h,this._x=n*d+this._x*h,this._y=i*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}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 O{constructor(e=0,t=0,n=0){O.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(Ou.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ou.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),u=2*(o*t-s*i),d=2*(s*n-a*t);return this.x=t+c*l+a*d-o*u,this.y=n+c*u+o*l-s*d,this.z=i+c*d+s*u-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,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*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 Wo.copy(this).projectOnVector(e),this.sub(Wo)}reflect(e){return this.sub(Wo.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($t(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Wo=new O,Ou=new Dn;class bt{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Wn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Wn.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=Wn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute(\"position\");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Wn):Wn.fromBufferAttribute(s,a),Wn.applyMatrix4(e.matrixWorld),this.expandByPoint(Wn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),sa.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),sa.copy(n.boundingBox)),sa.applyMatrix4(e.matrixWorld),this.union(sa)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Wn),Wn.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(xs),aa.subVectors(this.max,xs),Sr.subVectors(e.a,xs),Er.subVectors(e.b,xs),Tr.subVectors(e.c,xs),Ei.subVectors(Er,Sr),Ti.subVectors(Tr,Er),Zi.subVectors(Sr,Tr);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Zi.z,Zi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Zi.z,0,-Zi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Zi.y,Zi.x,0];return!jo(t,Sr,Er,Tr,aa)||(t=[1,0,0,0,1,0,0,0,1],!jo(t,Sr,Er,Tr,aa))?!1:(oa.crossVectors(Ei,Ti),t=[oa.x,oa.y,oa.z],jo(t,Sr,Er,Tr,aa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wn).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:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),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)}}const oi=[new O,new O,new O,new O,new O,new O,new O,new O],Wn=new O,sa=new bt,Sr=new O,Er=new O,Tr=new O,Ei=new O,Ti=new O,Zi=new O,xs=new O,aa=new O,oa=new O,$i=new O;function jo(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){$i.fromArray(r,s);const o=i.x*Math.abs($i.x)+i.y*Math.abs($i.y)+i.z*Math.abs($i.z),c=e.dot($i),l=t.dot($i),u=n.dot($i);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const Hp=new bt,ys=new O,Xo=new O;class Nn{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Hp.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),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;ys.subVectors(e,this.center);const t=ys.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ys,i/n),this.radius+=i}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):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ys.copy(e.center).add(Xo)),this.expandByPoint(ys.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const ci=new O,qo=new O,ca=new O,wi=new O,Yo=new O,la=new O,Ko=new O;class Ji{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ci)),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=ci.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ci.copy(this.origin).addScaledVector(this.direction,t),ci.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){qo.copy(e).add(t).multiplyScalar(.5),ca.copy(t).sub(e).normalize(),wi.copy(this.origin).sub(qo);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ca),o=wi.dot(this.direction),c=-wi.dot(ca),l=wi.lengthSq(),u=Math.abs(1-a*a);let d,h,f,g;if(u>0)if(d=a*c-o,h=a*o-c,g=s*u,d>=0)if(h>=-g)if(h<=g){const v=1/u;d*=v,h*=v,f=d*(d+a*h+2*o)+h*(a*d+h+2*c)+l}else h=s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*c)+l;else h=-s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*c)+l;else h<=-g?(d=Math.max(0,-(-a*s+o)),h=d>0?-s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l):h<=g?(d=0,h=Math.min(Math.max(-s,-c),s),f=h*(h+2*c)+l):(d=Math.max(0,-(a*s+o)),h=d>0?s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l);else h=a>0?-s:s,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(qo).addScaledVector(ca,h),f}intersectSphere(e,t){ci.subVectors(e.center,this.origin);const n=ci.dot(this.direction),i=ci.dot(ci)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return 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,i,s,a,o,c;const l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),d>=0?(o=(e.min.z-h.z)*d,c=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,c=(e.min.z-h.z)*d),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ci)!==null}intersectTriangle(e,t,n,i,s){Yo.subVectors(t,e),la.subVectors(n,e),Ko.crossVectors(Yo,la);let a=this.direction.dot(Ko),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wi.subVectors(this.origin,e);const c=o*this.direction.dot(la.crossVectors(wi,la));if(c<0)return null;const l=o*this.direction.dot(Yo.cross(wi));if(l<0||c+l>a)return null;const u=-o*wi.dot(Ko);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class qe{constructor(e,t,n,i,s,a,o,c,l,u,d,h,f,g,v,m){qe.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,i,s,a,o,c,l,u,d,h,f,g,v,m)}set(e,t,n,i,s,a,o,c,l,u,d,h,f,g,v,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=s,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=u,p[10]=d,p[14]=h,p[3]=f,p[7]=g,p[11]=v,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/wr.setFromMatrixColumn(e,0).length(),s=1/wr.setFromMatrixColumn(e,1).length(),a=1/wr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),d=Math.sin(s);if(e.order===\"XYZ\"){const h=a*u,f=a*d,g=o*u,v=o*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=f+g*l,t[5]=h-v*l,t[9]=-o*c,t[2]=v-h*l,t[6]=g+f*l,t[10]=a*c}else if(e.order===\"YXZ\"){const h=c*u,f=c*d,g=l*u,v=l*d;t[0]=h+v*o,t[4]=g*o-f,t[8]=a*l,t[1]=a*d,t[5]=a*u,t[9]=-o,t[2]=f*o-g,t[6]=v+h*o,t[10]=a*c}else if(e.order===\"ZXY\"){const h=c*u,f=c*d,g=l*u,v=l*d;t[0]=h-v*o,t[4]=-a*d,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*u,t[9]=v-h*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order===\"ZYX\"){const h=a*u,f=a*d,g=o*u,v=o*d;t[0]=c*u,t[4]=g*l-f,t[8]=h*l+v,t[1]=c*d,t[5]=v*l+h,t[9]=f*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order===\"YZX\"){const h=a*c,f=a*l,g=o*c,v=o*l;t[0]=c*u,t[4]=v-h*d,t[8]=g*d+f,t[1]=d,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=f*d+g,t[10]=h-v*d}else if(e.order===\"XZY\"){const h=a*c,f=a*l,g=o*c,v=o*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=h*d+v,t[5]=a*u,t[9]=f*d-g,t[2]=g*d-f,t[6]=o*u,t[10]=v*d+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(Vp,e,Wp)}lookAt(e,t,n){const i=this.elements;return An.subVectors(e,t),An.lengthSq()===0&&(An.z=1),An.normalize(),Ai.crossVectors(n,An),Ai.lengthSq()===0&&(Math.abs(n.z)===1?An.x+=1e-4:An.z+=1e-4,An.normalize(),Ai.crossVectors(n,An)),Ai.normalize(),ua.crossVectors(An,Ai),i[0]=Ai.x,i[4]=ua.x,i[8]=An.x,i[1]=Ai.y,i[5]=ua.y,i[9]=An.y,i[2]=Ai.z,i[6]=ua.z,i[10]=An.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],d=n[5],h=n[9],f=n[13],g=n[2],v=n[6],m=n[10],p=n[14],_=n[3],b=n[7],x=n[11],E=n[15],T=i[0],A=i[4],I=i[8],S=i[12],R=i[1],F=i[5],U=i[9],V=i[13],P=i[2],z=i[6],X=i[10],re=i[14],J=i[3],te=i[7],Q=i[11],ce=i[15];return s[0]=a*T+o*R+c*P+l*J,s[4]=a*A+o*F+c*z+l*te,s[8]=a*I+o*U+c*X+l*Q,s[12]=a*S+o*V+c*re+l*ce,s[1]=u*T+d*R+h*P+f*J,s[5]=u*A+d*F+h*z+f*te,s[9]=u*I+d*U+h*X+f*Q,s[13]=u*S+d*V+h*re+f*ce,s[2]=g*T+v*R+m*P+p*J,s[6]=g*A+v*F+m*z+p*te,s[10]=g*I+v*U+m*X+p*Q,s[14]=g*S+v*V+m*re+p*ce,s[3]=_*T+b*R+x*P+E*J,s[7]=_*A+b*F+x*z+E*te,s[11]=_*I+b*U+x*X+E*Q,s[15]=_*S+b*V+x*re+E*ce,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],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],d=e[6],h=e[10],f=e[14],g=e[3],v=e[7],m=e[11],p=e[15];return g*(+s*c*d-i*l*d-s*o*h+n*l*h+i*o*f-n*c*f)+v*(+t*c*f-t*l*h+s*a*h-i*a*f+i*l*u-s*c*u)+m*(+t*l*d-t*o*f-s*a*d+n*a*f+s*o*u-n*l*u)+p*(-i*o*u-t*c*d+t*o*h+i*a*d-n*a*h+n*c*u)}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 i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],d=e[9],h=e[10],f=e[11],g=e[12],v=e[13],m=e[14],p=e[15],_=d*m*l-v*h*l+v*c*f-o*m*f-d*c*p+o*h*p,b=g*h*l-u*m*l-g*c*f+a*m*f+u*c*p-a*h*p,x=u*v*l-g*d*l+g*o*f-a*v*f-u*o*p+a*d*p,E=g*d*c-u*v*c-g*o*h+a*v*h+u*o*m-a*d*m,T=t*_+n*b+i*x+s*E;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=_*A,e[1]=(v*h*s-d*m*s-v*i*f+n*m*f+d*i*p-n*h*p)*A,e[2]=(o*m*s-v*c*s+v*i*l-n*m*l-o*i*p+n*c*p)*A,e[3]=(d*c*s-o*h*s-d*i*l+n*h*l+o*i*f-n*c*f)*A,e[4]=b*A,e[5]=(u*m*s-g*h*s+g*i*f-t*m*f-u*i*p+t*h*p)*A,e[6]=(g*c*s-a*m*s-g*i*l+t*m*l+a*i*p-t*c*p)*A,e[7]=(a*h*s-u*c*s+u*i*l-t*h*l-a*i*f+t*c*f)*A,e[8]=x*A,e[9]=(g*d*s-u*v*s-g*n*f+t*v*f+u*n*p-t*d*p)*A,e[10]=(a*v*s-g*o*s+g*n*l-t*v*l-a*n*p+t*o*p)*A,e[11]=(u*o*s-a*d*s-u*n*l+t*d*l+a*n*f-t*o*f)*A,e[12]=E*A,e[13]=(u*v*i-g*d*i+g*n*h-t*v*h-u*n*m+t*d*m)*A,e[14]=(g*o*i-a*v*i-g*n*c+t*v*c+a*n*m-t*o*m)*A,e[15]=(a*d*i-u*o*i+u*n*c-t*d*c-a*n*h+t*o*h)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}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),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*a,0,l*c-i*o,u*c+i*a,s*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,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,d=o+o,h=s*l,f=s*u,g=s*d,v=a*u,m=a*d,p=o*d,_=c*l,b=c*u,x=c*d,E=n.x,T=n.y,A=n.z;return i[0]=(1-(v+p))*E,i[1]=(f+x)*E,i[2]=(g-b)*E,i[3]=0,i[4]=(f-x)*T,i[5]=(1-(h+p))*T,i[6]=(m+_)*T,i[7]=0,i[8]=(g+b)*A,i[9]=(m-_)*A,i[10]=(1-(h+v))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=wr.set(i[0],i[1],i[2]).length();const a=wr.set(i[4],i[5],i[6]).length(),o=wr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],jn.copy(this);const l=1/s,u=1/a,d=1/o;return jn.elements[0]*=l,jn.elements[1]*=l,jn.elements[2]*=l,jn.elements[4]*=u,jn.elements[5]*=u,jn.elements[6]*=u,jn.elements[8]*=d,jn.elements[9]*=d,jn.elements[10]*=d,t.setFromRotationMatrix(jn),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=ai){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i);let f,g;if(o===ai)f=-(a+s)/(a-s),g=-2*a*s/(a-s);else if(o===na)f=-a/(a-s),g=-a*s/(a-s);else throw new Error(\"THREE.Matrix4.makePerspective(): Invalid coordinate system: \"+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=ai){const c=this.elements,l=1/(t-e),u=1/(n-i),d=1/(a-s),h=(t+e)*l,f=(n+i)*u;let g,v;if(o===ai)g=(a+s)*d,v=-2*d;else if(o===na)g=s*d,v=-1*d;else throw new Error(\"THREE.Matrix4.makeOrthographic(): Invalid coordinate system: \"+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-h,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=v,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])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 wr=new O,jn=new qe,Vp=new O(0,0,0),Wp=new O(1,1,1),Ai=new O,ua=new O,An=new O,Bu=new qe,ku=new Dn;class Ms{constructor(e=0,t=0,n=0,i=Ms.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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 i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],u=i[9],d=i[2],h=i[6],f=i[10];switch(t){case\"XYZ\":this._y=Math.asin($t(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,l),this._z=0);break;case\"YXZ\":this._x=Math.asin(-$t(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case\"ZXY\":this._x=Math.asin($t(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case\"ZYX\":this._y=Math.asin(-$t(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case\"YZX\":this._z=Math.asin($t(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,f));break;case\"XZY\":this._z=Math.asin(-$t(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn(\"THREE.Euler: .setFromRotationMatrix() encountered an unknown order: \"+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Bu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ku.setFromEuler(this),this.setFromQuaternion(ku,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}}Ms.DEFAULT_ORDER=\"XYZ\";class Zo{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 jp=0;const zu=new O,Ar=new Dn,li=new qe,da=new O,Ss=new O,Xp=new O,qp=new Dn,Gu=new O(1,0,0),Hu=new O(0,1,0),Vu=new O(0,0,1),Yp={type:\"added\"},Kp={type:\"removed\"};class Ot extends Yi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,\"id\",{value:jp++}),this.uuid=Vn(),this.name=\"\",this.type=\"Object3D\",this.parent=null,this.children=[],this.up=Ot.DEFAULT_UP.clone();const e=new O,t=new Ms,n=new Dn,i=new O(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new qe},normalMatrix:{value:new ct}}),this.matrix=new qe,this.matrixWorld=new qe,this.matrixAutoUpdate=Ot.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Zo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ar.setFromAxisAngle(e,t),this.quaternion.multiply(Ar),this}rotateOnWorldAxis(e,t){return Ar.setFromAxisAngle(e,t),this.quaternion.premultiply(Ar),this}rotateX(e){return this.rotateOnAxis(Gu,e)}rotateY(e){return this.rotateOnAxis(Hu,e)}rotateZ(e){return this.rotateOnAxis(Vu,e)}translateOnAxis(e,t){return zu.copy(e).applyQuaternion(this.quaternion),this.position.add(zu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Gu,e)}translateY(e){return this.translateOnAxis(Hu,e)}translateZ(e){return this.translateOnAxis(Vu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(li.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?da.copy(e):da.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ss.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?li.lookAt(Ss,da,this.up):li.lookAt(da,Ss,this.up),this.quaternion.setFromRotationMatrix(li),i&&(li.extractRotation(i.matrixWorld),Ar.setFromRotationMatrix(li),this.quaternion.premultiply(Ar.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error(\"THREE.Object3D.add: object can't be added as a child of itself.\",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Yp)):console.error(\"THREE.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(Kp)),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),li.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),li.multiply(e.parent.matrixWorld)),e.applyMatrix4(li),this.add(e),e.updateWorldMatrix(!1,!0),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,i=this.children.length;n<i;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 i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ss,e,Xp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ss,qp,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,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.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,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.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.6,type:\"Object\",generator:\"Object3D.toJSON\"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==\"\"&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type=\"InstancedMesh\",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type=\"BatchedMesh\",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(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,u=c.length;l<u;l++){const d=c[l];s(e.shapes,d)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.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(s(e.materials,this.material[c]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),u=a(e.images),d=a(e.shapes),h=a(e.skeletons),f=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),u.length>0&&(n.images=u),d.length>0&&(n.shapes=d),h.length>0&&(n.skeletons=h),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Ot.DEFAULT_UP=new O(0,1,0),Ot.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Xn=new O,ui=new O,$o=new O,di=new O,Rr=new O,Cr=new O,Wu=new O,Jo=new O,Qo=new O,ec=new O;let ha=!1;class ln{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Xn.subVectors(e,t),i.cross(Xn);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Xn.subVectors(i,t),ui.subVectors(n,t),$o.subVectors(e,t);const a=Xn.dot(Xn),o=Xn.dot(ui),c=Xn.dot($o),l=ui.dot(ui),u=ui.dot($o),d=a*l-o*o;if(d===0)return s.set(0,0,0),null;const h=1/d,f=(l*c-o*u)*h,g=(a*u-o*c)*h;return s.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,di)===null?!1:di.x>=0&&di.y>=0&&di.x+di.y<=1}static getUV(e,t,n,i,s,a,o,c){return ha===!1&&(console.warn(\"THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().\"),ha=!0),this.getInterpolation(e,t,n,i,s,a,o,c)}static getInterpolation(e,t,n,i,s,a,o,c){return this.getBarycoord(e,t,n,i,di)===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(s,di.x),c.addScaledVector(a,di.y),c.addScaledVector(o,di.z),c)}static isFrontFacing(e,t,n,i){return Xn.subVectors(n,t),ui.subVectors(e,t),Xn.cross(ui).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Xn.subVectors(this.c,this.b),ui.subVectors(this.a,this.b),Xn.cross(ui).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ln.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ln.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return ha===!1&&(console.warn(\"THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().\"),ha=!0),ln.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return ln.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return ln.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ln.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;Rr.subVectors(i,n),Cr.subVectors(s,n),Jo.subVectors(e,n);const c=Rr.dot(Jo),l=Cr.dot(Jo);if(c<=0&&l<=0)return t.copy(n);Qo.subVectors(e,i);const u=Rr.dot(Qo),d=Cr.dot(Qo);if(u>=0&&d<=u)return t.copy(i);const h=c*d-u*l;if(h<=0&&c>=0&&u<=0)return a=c/(c-u),t.copy(n).addScaledVector(Rr,a);ec.subVectors(e,s);const f=Rr.dot(ec),g=Cr.dot(ec);if(g>=0&&f<=g)return t.copy(s);const v=f*l-c*g;if(v<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(Cr,o);const m=u*g-f*d;if(m<=0&&d-u>=0&&f-g>=0)return Wu.subVectors(s,i),o=(d-u)/(d-u+(f-g)),t.copy(i).addScaledVector(Wu,o);const p=1/(m+v+h);return a=v*p,o=h*p,t.copy(n).addScaledVector(Rr,a).addScaledVector(Cr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ju={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},Ri={h:0,s:0,l:0},fa={h:0,s:0,l:0};function tc(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Be{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 i=e;i&&i.isColor?this.copy(i):typeof i==\"number\"?this.setHex(i):typeof i==\"string\"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=xt.workingColorSpace){return this.r=e,this.g=t,this.b=n,xt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=xt.workingColorSpace){if(e=Bo(e,1),t=$t(t,0,1),n=$t(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=tc(a,s,e+1/3),this.g=tc(a,s,e),this.b=tc(a,s,e-1/3)}return xt.toWorkingColorSpace(this,i),this}setStyle(e,t=Mt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn(\"THREE.Color: Alpha component of \"+e+\" will be ignored.\")}let i;if(i=/^(\\w+)\\(([^\\)]*)\\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case\"rgb\":case\"rgba\":if(s=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case\"hsl\":case\"hsla\":if(s=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn(\"THREE.Color: Unknown color model \"+e)}}else if(i=/^\\#([A-Fa-f\\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn(\"THREE.Color: Invalid hex color \"+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Mt){const n=ju[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn(\"THREE.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=yr(e.r),this.g=yr(e.g),this.b=yr(e.b),this}copyLinearToSRGB(e){return this.r=Go(e.r),this.g=Go(e.g),this.b=Go(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mt){return xt.fromWorkingColorSpace(pn.copy(this),e),Math.round($t(pn.r*255,0,255))*65536+Math.round($t(pn.g*255,0,255))*256+Math.round($t(pn.b*255,0,255))}getHexString(e=Mt){return(\"000000\"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xt.workingColorSpace){xt.fromWorkingColorSpace(pn.copy(this),t);const n=pn.r,i=pn.g,s=pn.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const u=(o+a)/2;if(o===a)c=0,l=0;else{const d=a-o;switch(l=u<=.5?d/(a+o):d/(2-a-o),a){case n:c=(i-s)/d+(i<s?6:0);break;case i:c=(s-n)/d+2;break;case s:c=(n-i)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=xt.workingColorSpace){return xt.fromWorkingColorSpace(pn.copy(this),t),e.r=pn.r,e.g=pn.g,e.b=pn.b,e}getStyle(e=Mt){xt.fromWorkingColorSpace(pn.copy(this),e);const t=pn.r,n=pn.g,i=pn.b;return e!==Mt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ri),this.setHSL(Ri.h+e,Ri.s+t,Ri.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(Ri),e.getHSL(fa);const n=bs(Ri.h,fa.h,t),i=bs(Ri.s,fa.s,t),s=bs(Ri.l,fa.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,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 pn=new Be;Be.NAMES=ju;let Zp=0;class Rn extends Yi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,\"id\",{value:Zp++}),this.uuid=Vn(),this.name=\"\",this.type=\"Material\",this.blending=fr,this.side=Mn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_o,this.blendDst=vo,this.blendEquation=Vi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Be(0,0,0),this.blendAlpha=0,this.depthFunc=Xs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ru,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_r,this.stencilZFail=_r,this.stencilZPass=_r,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e==\"string\";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:\"Material\",generator:\"Material.toJSON\"}};n.uuid=this.uuid,n.type=this.type,this.name!==\"\"&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.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.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!==fr&&(n.blending=this.blending),this.side!==Mn&&(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!==_o&&(n.blendSrc=this.blendSrc),this.blendDst!==vo&&(n.blendDst=this.blendDst),this.blendEquation!==Vi&&(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!==Xs&&(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!==Ru&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_r&&(n.stencilFail=this.stencilFail),this.stencilZFail!==_r&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==_r&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==\"round\"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==\"round\"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:\"dispose\"})}set needsUpdate(e){e===!0&&this.version++}}class Gt extends Rn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=\"MeshBasicMaterial\",this.color=new Be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=xo,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.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 hi=$p();function $p(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;!(l&8388608);)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Jp(r){Math.abs(r)>65504&&console.warn(\"THREE.DataUtils.toHalfFloat(): Value out of range.\"),r=$t(r,-65504,65504),hi.floatView[0]=r;const e=hi.uint32View[0],t=e>>23&511;return hi.baseTable[t]+((e&8388607)>>hi.shiftTable[t])}function Qp(r){const e=r>>10;return hi.uint32View[0]=hi.mantissaTable[hi.offsetTable[e]+(r&1023)]+hi.exponentTable[e],hi.floatView[0]}const Pr={toHalfFloat:Jp,fromHalfFloat:Qp},qt=new O,pa=new Ve;class vt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError(\"THREE.BufferAttribute: array should be a Typed Array.\");this.isBufferAttribute=!0,this.name=\"\",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Fo,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=jt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(\"THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.\"),this._updateRange}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 i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];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++)pa.fromBufferAttribute(this,t),pa.applyMatrix3(e),this.setXY(t,pa.x,pa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)qt.fromBufferAttribute(this,t),qt.applyMatrix3(e),this.setXYZ(t,qt.x,qt.y,qt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)qt.fromBufferAttribute(this,t),qt.applyMatrix4(e),this.setXYZ(t,qt.x,qt.y,qt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qt.fromBufferAttribute(this,t),qt.applyNormalMatrix(e),this.setXYZ(t,qt.x,qt.y,qt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qt.fromBufferAttribute(this,t),qt.transformDirection(e),this.setXYZ(t,qt.x,qt.y,qt.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=Jn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=St(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Jn(t,this.array)),t}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Jn(t,this.array)),t}setY(e,t){return this.normalized&&(t=St(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=Jn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=St(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=Jn(t,this.array)),t}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),n=St(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),n=St(n,this.array),i=St(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),n=St(n,this.array),i=St(i,this.array),s=St(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==\"\"&&(e.name=this.name),this.usage!==Fo&&(e.usage=this.usage),e}}class Xu extends vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class qu extends vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Yt extends vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let em=0;const Un=new qe,nc=new Ot,Lr=new O,Cn=new bt,Es=new bt,sn=new O;class mn extends Yi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,\"id\",{value:em++}),this.uuid=Vn(),this.name=\"\",this.type=\"BufferGeometry\",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Lu(e)?qu:Xu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new ct().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return nc.lookAt(e),nc.updateMatrix(),this.applyMatrix4(nc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lr).negate(),this.translate(Lr.x,Lr.y,Lr.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute(\"position\",new Yt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set \"mesh.frustumCulled\" to \"false\".',this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];Cn.setFromBufferAttribute(s),this.morphTargetsRelative?(sn.addVectors(this.boundingBox.min,Cn.min),this.boundingBox.expandByPoint(sn),sn.addVectors(this.boundingBox.max,Cn.max),this.boundingBox.expandByPoint(sn)):(this.boundingBox.expandByPoint(Cn.min),this.boundingBox.expandByPoint(Cn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set \"mesh.frustumCulled\" to \"false\".',this),this.boundingSphere.set(new O,1/0);return}if(e){const n=this.boundingSphere.center;if(Cn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Es.setFromBufferAttribute(o),this.morphTargetsRelative?(sn.addVectors(Cn.min,Es.min),Cn.expandByPoint(sn),sn.addVectors(Cn.max,Es.max),Cn.expandByPoint(sn)):(Cn.expandByPoint(Es.min),Cn.expandByPoint(Es.max))}Cn.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)sn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(sn));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)sn.fromBufferAttribute(o,l),c&&(Lr.fromBufferAttribute(e,l),sn.add(Lr)),i=Math.max(i,n.distanceToSquared(sn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(\"THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)\");return}const n=e.array,i=t.position.array,s=t.normal.array,a=t.uv.array,o=i.length/3;this.hasAttribute(\"tangent\")===!1&&this.setAttribute(\"tangent\",new vt(new Float32Array(4*o),4));const c=this.getAttribute(\"tangent\").array,l=[],u=[];for(let R=0;R<o;R++)l[R]=new O,u[R]=new O;const d=new O,h=new O,f=new O,g=new Ve,v=new Ve,m=new Ve,p=new O,_=new O;function b(R,F,U){d.fromArray(i,R*3),h.fromArray(i,F*3),f.fromArray(i,U*3),g.fromArray(a,R*2),v.fromArray(a,F*2),m.fromArray(a,U*2),h.sub(d),f.sub(d),v.sub(g),m.sub(g);const V=1/(v.x*m.y-m.x*v.y);isFinite(V)&&(p.copy(h).multiplyScalar(m.y).addScaledVector(f,-v.y).multiplyScalar(V),_.copy(f).multiplyScalar(v.x).addScaledVector(h,-m.x).multiplyScalar(V),l[R].add(p),l[F].add(p),l[U].add(p),u[R].add(_),u[F].add(_),u[U].add(_))}let x=this.groups;x.length===0&&(x=[{start:0,count:n.length}]);for(let R=0,F=x.length;R<F;++R){const U=x[R],V=U.start,P=U.count;for(let z=V,X=V+P;z<X;z+=3)b(n[z+0],n[z+1],n[z+2])}const E=new O,T=new O,A=new O,I=new O;function S(R){A.fromArray(s,R*3),I.copy(A);const F=l[R];E.copy(F),E.sub(A.multiplyScalar(A.dot(F))).normalize(),T.crossVectors(I,F);const V=T.dot(u[R])<0?-1:1;c[R*4]=E.x,c[R*4+1]=E.y,c[R*4+2]=E.z,c[R*4+3]=V}for(let R=0,F=x.length;R<F;++R){const U=x[R],V=U.start,P=U.count;for(let z=V,X=V+P;z<X;z+=3)S(n[z+0]),S(n[z+1]),S(n[z+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 vt(new Float32Array(t.count*3),3),this.setAttribute(\"normal\",n);else for(let h=0,f=n.count;h<f;h++)n.setXYZ(h,0,0,0);const i=new O,s=new O,a=new O,o=new O,c=new O,l=new O,u=new O,d=new O;if(e)for(let h=0,f=e.count;h<f;h+=3){const g=e.getX(h+0),v=e.getX(h+1),m=e.getX(h+2);i.fromBufferAttribute(t,g),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),u.subVectors(a,s),d.subVectors(i,s),u.cross(d),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),o.add(u),c.add(u),l.add(u),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)i.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),d.subVectors(i,s),u.cross(d),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)sn.fromBufferAttribute(e,t),sn.normalize(),e.setXYZ(t,sn.x,sn.y,sn.z)}toNonIndexed(){function e(o,c){const l=o.array,u=o.itemSize,d=o.normalized,h=new l.constructor(c.length*u);let f=0,g=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*u;for(let p=0;p<u;p++)h[g++]=l[f++]}return new vt(h,u,d)}if(this.index===null)return console.warn(\"THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.\"),this;const t=new mn,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let u=0,d=l.length;u<d;u++){const h=l[u],f=e(h,n);c.push(f)}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.6,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 i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let d=0,h=l.length;d<h;d++){const f=l[d];u.push(f.toJSON(e.data))}u.length>0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,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={center:o.center.toArray(),radius:o.radius}),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(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],d=s[l];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,u=a.length;l<u;l++){const d=a[l];this.addGroup(d.start,d.count,d.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\"})}}const Yu=new qe,Qi=new Ji,ma=new Nn,Ku=new O,Ir=new O,Dr=new O,Nr=new O,ic=new O,ga=new O,ba=new Ve,_a=new Ve,va=new Ve,Zu=new O,$u=new O,Ju=new O,xa=new O,ya=new O;class We extends Ot{constructor(e=new mn,t=new Gt){super(),this.isMesh=!0,this.type=\"Mesh\",this.geometry=e,this.material=t,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 i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){ga.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=o[c],d=s[c];u!==0&&(ic.fromBufferAttribute(d,e),a?ga.addScaledVector(ic,u):ga.addScaledVector(ic.sub(t),u))}t.add(ga)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ma.copy(n.boundingSphere),ma.applyMatrix4(s),Qi.copy(e.ray).recast(e.near),!(ma.containsPoint(Qi.origin)===!1&&(Qi.intersectSphere(ma,Ku)===null||Qi.origin.distanceToSquared(Ku)>(e.far-e.near)**2))&&(Yu.copy(s).invert(),Qi.copy(e.ray).applyMatrix4(Yu),!(n.boundingBox!==null&&Qi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Qi)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const m=h[g],p=a[m.materialIndex],_=Math.max(m.start,f.start),b=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let x=_,E=b;x<E;x+=3){const T=o.getX(x),A=o.getX(x+1),I=o.getX(x+2);i=Ma(this,p,e,n,l,u,d,T,A,I),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=g,p=v;m<p;m+=3){const _=o.getX(m),b=o.getX(m+1),x=o.getX(m+2);i=Ma(this,a,e,n,l,u,d,_,b,x),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const m=h[g],p=a[m.materialIndex],_=Math.max(m.start,f.start),b=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let x=_,E=b;x<E;x+=3){const T=x,A=x+1,I=x+2;i=Ma(this,p,e,n,l,u,d,T,A,I),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=g,p=v;m<p;m+=3){const _=m,b=m+1,x=m+2;i=Ma(this,a,e,n,l,u,d,_,b,x),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function tm(r,e,t,n,i,s,a,o){let c;if(e.side===on?c=n.intersectTriangle(a,s,i,!0,o):c=n.intersectTriangle(i,s,a,e.side===Mn,o),c===null)return null;ya.copy(o),ya.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(ya);return l<t.near||l>t.far?null:{distance:l,point:ya.clone(),object:r}}function Ma(r,e,t,n,i,s,a,o,c,l){r.getVertexPosition(o,Ir),r.getVertexPosition(c,Dr),r.getVertexPosition(l,Nr);const u=tm(r,e,t,n,Ir,Dr,Nr,xa);if(u){i&&(ba.fromBufferAttribute(i,o),_a.fromBufferAttribute(i,c),va.fromBufferAttribute(i,l),u.uv=ln.getInterpolation(xa,Ir,Dr,Nr,ba,_a,va,new Ve)),s&&(ba.fromBufferAttribute(s,o),_a.fromBufferAttribute(s,c),va.fromBufferAttribute(s,l),u.uv1=ln.getInterpolation(xa,Ir,Dr,Nr,ba,_a,va,new Ve),u.uv2=u.uv1),a&&(Zu.fromBufferAttribute(a,o),$u.fromBufferAttribute(a,c),Ju.fromBufferAttribute(a,l),u.normal=ln.getInterpolation(xa,Ir,Dr,Nr,Zu,$u,Ju,new O),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new O,materialIndex:0};ln.getNormal(Ir,Dr,Nr,d.normal),u.face=d}return u}class Ts extends mn{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type=\"BoxGeometry\",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],u=[],d=[];let h=0,f=0;g(\"z\",\"y\",\"x\",-1,-1,n,t,e,a,s,0),g(\"z\",\"y\",\"x\",1,-1,n,t,-e,a,s,1),g(\"x\",\"z\",\"y\",1,1,e,n,t,i,a,2),g(\"x\",\"z\",\"y\",1,-1,e,n,-t,i,a,3),g(\"x\",\"y\",\"z\",1,-1,e,t,n,i,s,4),g(\"x\",\"y\",\"z\",-1,-1,e,t,-n,i,s,5),this.setIndex(c),this.setAttribute(\"position\",new Yt(l,3)),this.setAttribute(\"normal\",new Yt(u,3)),this.setAttribute(\"uv\",new Yt(d,2));function g(v,m,p,_,b,x,E,T,A,I,S){const R=x/A,F=E/I,U=x/2,V=E/2,P=T/2,z=A+1,X=I+1;let re=0,J=0;const te=new O;for(let Q=0;Q<X;Q++){const ce=Q*F-V;for(let he=0;he<z;he++){const $=he*R-U;te[v]=$*_,te[m]=ce*b,te[p]=P,l.push(te.x,te.y,te.z),te[v]=0,te[m]=0,te[p]=T>0?1:-1,u.push(te.x,te.y,te.z),d.push(he/A),d.push(1-Q/I),re+=1}}for(let Q=0;Q<I;Q++)for(let ce=0;ce<A;ce++){const he=h+ce+z*Q,$=h+ce+z*(Q+1),ue=h+(ce+1)+z*(Q+1),Me=h+(ce+1)+z*Q;c.push(he,$,Me),c.push($,ue,Me),J+=6}o.addGroup(f,J,S),f+=J,h+=re}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ts(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ur(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn(\"UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().\"),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function bn(r){const e={};for(let t=0;t<r.length;t++){const n=Ur(r[t]);for(const i in n)e[i]=n[i]}return e}function nm(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Qu(r){return r.getRenderTarget()===null?r.outputColorSpace:xt.workingColorSpace}const im={clone:Ur,merge:bn};var rm=`void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}`,sm=`void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}`;class qn extends Rn{constructor(e){super(),this.isShaderMaterial=!0,this.type=\"ShaderMaterial\",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rm,this.fragmentShader=sm,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},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=Ur(e.uniforms),this.uniformsGroups=nm(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:\"t\",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:\"c\",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:\"v2\",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:\"v3\",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:\"v4\",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:\"m3\",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:\"m4\",value:a.toArray()}:t.uniforms[i]={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 i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ed extends Ot{constructor(){super(),this.isCamera=!0,this.type=\"Camera\",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=ai}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class un extends ed{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type=\"PerspectiveCamera\",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=vr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(gs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return vr*2*Math.atan(Math.tan(gs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(gs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*i/c,t-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Fr=-90,Or=1;class rc extends Ot{constructor(e,t,n){super(),this.type=\"CubeCamera\",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new un(Fr,Or,e,t);i.layers=this.layers,this.add(i);const s=new un(Fr,Or,e,t);s.layers=this.layers,this.add(s);const a=new un(Fr,Or,e,t);a.layers=this.layers,this.add(a);const o=new un(Fr,Or,e,t);o.layers=this.layers,this.add(o);const c=new un(Fr,Or,e,t);c.layers=this.layers,this.add(c);const l=new un(Fr,Or,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===ai)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===na)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),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:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class sc extends Xt{constructor(e,t,n,i,s,a,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:pr,super(e,t,n,i,s,a,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Br extends Ki{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(vs(\"THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.\"),t.colorSpace=t.encoding===qi?Mt:Sn),this.texture=new sc(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:At}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:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t`,fragmentShader:`\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t`},i=new Ts(5,5,5),s=new qn({name:\"CubemapFromEquirect\",uniforms:Ur(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:on,blending:ii});s.uniforms.tEquirect.value=t;const a=new We(i,s),o=t.minFilter;return t.minFilter===si&&(t.minFilter=At),new rc(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}const ac=new O,am=new O,om=new ct;class Qn{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=ac.subVectors(n,t).cross(am.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(ac),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||om.getNormalMatrix(e),i=this.coplanarPoint(ac).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const er=new Nn,Sa=new O;class oc{constructor(e=new Qn,t=new Qn,n=new Qn,i=new Qn,s=new Qn,a=new Qn){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ai){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],c=i[3],l=i[4],u=i[5],d=i[6],h=i[7],f=i[8],g=i[9],v=i[10],m=i[11],p=i[12],_=i[13],b=i[14],x=i[15];if(n[0].setComponents(c-s,h-l,m-f,x-p).normalize(),n[1].setComponents(c+s,h+l,m+f,x+p).normalize(),n[2].setComponents(c+a,h+u,m+g,x+_).normalize(),n[3].setComponents(c-a,h-u,m-g,x-_).normalize(),n[4].setComponents(c-o,h-d,m-v,x-b).normalize(),t===ai)n[5].setComponents(c+o,h+d,m+v,x+b).normalize();else if(t===na)n[5].setComponents(o,d,v,b).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(),er.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),er.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(er)}intersectsSprite(e){return er.center.set(0,0,0),er.radius=.7071067811865476,er.applyMatrix4(e.matrixWorld),this.intersectsSphere(er)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Sa.x=i.normal.x>0?e.max.x:e.min.x,Sa.y=i.normal.y>0?e.max.y:e.min.y,Sa.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Sa)<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)}}function td(){let r=null,e=!1,t=null,n=null;function i(s,a){t(s,a),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function cm(r,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const d=l.array,h=l.usage,f=d.byteLength,g=r.createBuffer();r.bindBuffer(u,g),r.bufferData(u,d,h),l.onUploadCallback();let v;if(d instanceof Float32Array)v=r.FLOAT;else if(d instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)v=r.HALF_FLOAT;else throw new Error(\"THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.\");else v=r.UNSIGNED_SHORT;else if(d instanceof Int16Array)v=r.SHORT;else if(d instanceof Uint32Array)v=r.UNSIGNED_INT;else if(d instanceof Int32Array)v=r.INT;else if(d instanceof Int8Array)v=r.BYTE;else if(d instanceof Uint8Array)v=r.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)v=r.UNSIGNED_BYTE;else throw new Error(\"THREE.WebGLAttributes: Unsupported buffer data format: \"+d);return{buffer:g,type:v,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version,size:f}}function s(l,u,d){const h=u.array,f=u._updateRange,g=u.updateRanges;if(r.bindBuffer(d,l),f.count===-1&&g.length===0&&r.bufferSubData(d,0,h),g.length!==0){for(let v=0,m=g.length;v<m;v++){const p=g[v];t?r.bufferSubData(d,p.start*h.BYTES_PER_ELEMENT,h,p.start,p.count):r.bufferSubData(d,p.start*h.BYTES_PER_ELEMENT,h.subarray(p.start,p.start+p.count))}u.clearUpdateRanges()}f.count!==-1&&(t?r.bufferSubData(d,f.offset*h.BYTES_PER_ELEMENT,h,f.offset,f.count):r.bufferSubData(d,f.offset*h.BYTES_PER_ELEMENT,h.subarray(f.offset,f.offset+f.count)),f.count=-1),u.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(r.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const h=n.get(l);(!h||h.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const d=n.get(l);if(d===void 0)n.set(l,i(l,u));else if(d.version<l.version){if(d.size!==l.array.byteLength)throw new Error(\"THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.\");s(d.buffer,l,u),d.version=l.version}}return{get:a,remove:o,update:c}}class dn extends mn{constructor(e=1,t=1,n=1,i=1){super(),this.type=\"PlaneGeometry\",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(i),l=o+1,u=c+1,d=e/o,h=t/c,f=[],g=[],v=[],m=[];for(let p=0;p<u;p++){const _=p*h-a;for(let b=0;b<l;b++){const x=b*d-s;g.push(x,-_,0),v.push(0,0,1),m.push(b/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let _=0;_<o;_++){const b=_+l*p,x=_+l*(p+1),E=_+1+l*(p+1),T=_+1+l*p;f.push(b,x,T),f.push(x,E,T)}this.setIndex(f),this.setAttribute(\"position\",new Yt(g,3)),this.setAttribute(\"normal\",new Yt(v,3)),this.setAttribute(\"uv\",new Yt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.widthSegments,e.heightSegments)}}var lm=`#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif`,um=`#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif`,dm=`#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif`,hm=`#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,fm=`#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif`,pm=`#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif`,mm=`#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif`,gm=`#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif`,bm=`#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif`,_m=`#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif`,vm=`vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif`,xm=`vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif`,ym=`float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated`,Mm=`#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif`,Sm=`#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif`,Em=`#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif`,Tm=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,wm=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,Am=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,Rm=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,Cm=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Pm=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Lm=`#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif`,Im=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,Dm=`#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif`,Nm=`vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif`,Um=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Fm=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,Om=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,Bm=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,km=\"gl_FragColor = linearToOutputTexel( gl_FragColor );\",zm=`\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}`,Gm=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif`,Hm=`#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif`,Vm=`#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif`,Wm=`#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif`,jm=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif`,Xm=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,qm=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,Ym=`#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,Km=`#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif`,Zm=`#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}`,$m=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,Jm=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,Qm=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,eg=`varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert`,tg=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif`,ng=`#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif`,ig=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,rg=`varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon`,sg=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,ag=`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong`,og=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif`,cg=`struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,lg=`\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,ug=`#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,dg=`#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif`,hg=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,fg=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,pg=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,mg=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,gg=`#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif`,bg=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,_g=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,vg=`#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,xg=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,yg=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,Mg=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif`,Sg=`#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif`,Eg=`#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif`,Tg=`#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif`,wg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;`,Ag=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,Rg=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Cg=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Pg=`#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif`,Lg=`#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif`,Ig=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif`,Dg=`#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,Ng=`#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif`,Ug=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Fg=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Og=`vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}`,Bg=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,kg=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,zg=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,Gg=`#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif`,Hg=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,Vg=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,Wg=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif`,jg=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif`,Xg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif`,qg=`float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}`,Yg=`#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,Kg=`#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif`,Zg=`#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,$g=`#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif`,Jg=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,Qg=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,e0=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,t0=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,n0=`#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif`,i0=`#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif`,r0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,s0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,a0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,o0=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif`;const st={alphahash_fragment:lm,alphahash_pars_fragment:um,alphamap_fragment:dm,alphamap_pars_fragment:hm,alphatest_fragment:fm,alphatest_pars_fragment:pm,aomap_fragment:mm,aomap_pars_fragment:gm,batching_pars_vertex:bm,batching_vertex:_m,begin_vertex:vm,beginnormal_vertex:xm,bsdfs:ym,iridescence_fragment:Mm,bumpmap_pars_fragment:Sm,clipping_planes_fragment:Em,clipping_planes_pars_fragment:Tm,clipping_planes_pars_vertex:wm,clipping_planes_vertex:Am,color_fragment:Rm,color_pars_fragment:Cm,color_pars_vertex:Pm,color_vertex:Lm,common:Im,cube_uv_reflection_fragment:Dm,defaultnormal_vertex:Nm,displacementmap_pars_vertex:Um,displacementmap_vertex:Fm,emissivemap_fragment:Om,emissivemap_pars_fragment:Bm,colorspace_fragment:km,colorspace_pars_fragment:zm,envmap_fragment:Gm,envmap_common_pars_fragment:Hm,envmap_pars_fragment:Vm,envmap_pars_vertex:Wm,envmap_physical_pars_fragment:ng,envmap_vertex:jm,fog_vertex:Xm,fog_pars_vertex:qm,fog_fragment:Ym,fog_pars_fragment:Km,gradientmap_pars_fragment:Zm,lightmap_fragment:$m,lightmap_pars_fragment:Jm,lights_lambert_fragment:Qm,lights_lambert_pars_fragment:eg,lights_pars_begin:tg,lights_toon_fragment:ig,lights_toon_pars_fragment:rg,lights_phong_fragment:sg,lights_phong_pars_fragment:ag,lights_physical_fragment:og,lights_physical_pars_fragment:cg,lights_fragment_begin:lg,lights_fragment_maps:ug,lights_fragment_end:dg,logdepthbuf_fragment:hg,logdepthbuf_pars_fragment:fg,logdepthbuf_pars_vertex:pg,logdepthbuf_vertex:mg,map_fragment:gg,map_pars_fragment:bg,map_particle_fragment:_g,map_particle_pars_fragment:vg,metalnessmap_fragment:xg,metalnessmap_pars_fragment:yg,morphcolor_vertex:Mg,morphnormal_vertex:Sg,morphtarget_pars_vertex:Eg,morphtarget_vertex:Tg,normal_fragment_begin:wg,normal_fragment_maps:Ag,normal_pars_fragment:Rg,normal_pars_vertex:Cg,normal_vertex:Pg,normalmap_pars_fragment:Lg,clearcoat_normal_fragment_begin:Ig,clearcoat_normal_fragment_maps:Dg,clearcoat_pars_fragment:Ng,iridescence_pars_fragment:Ug,opaque_fragment:Fg,packing:Og,premultiplied_alpha_fragment:Bg,project_vertex:kg,dithering_fragment:zg,dithering_pars_fragment:Gg,roughnessmap_fragment:Hg,roughnessmap_pars_fragment:Vg,shadowmap_pars_fragment:Wg,shadowmap_pars_vertex:jg,shadowmap_vertex:Xg,shadowmask_pars_fragment:qg,skinbase_vertex:Yg,skinning_pars_vertex:Kg,skinning_vertex:Zg,skinnormal_vertex:$g,specularmap_fragment:Jg,specularmap_pars_fragment:Qg,tonemapping_fragment:e0,tonemapping_pars_fragment:t0,transmission_fragment:n0,transmission_pars_fragment:i0,uv_pars_fragment:r0,uv_pars_vertex:s0,uv_vertex:a0,worldpos_vertex:o0,background_vert:`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,background_frag:`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}`,backgroundCube_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}`,cube_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,cube_frag:`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}`,depth_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}`,depth_frag:`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}`,distanceRGBA_vert:`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}`,distanceRGBA_frag:`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,equirect_vert:`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}`,equirect_frag:`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}`,linedashed_vert:`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,linedashed_frag:`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,meshbasic_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}`,meshbasic_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,meshlambert_vert:`#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,meshlambert_frag:`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,meshmatcap_vert:`#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}`,meshmatcap_frag:`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,meshnormal_vert:`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}`,meshnormal_frag:`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}`,meshphong_vert:`#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,meshphong_frag:`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,meshphysical_vert:`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}`,meshphysical_frag:`#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,meshtoon_vert:`#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,meshtoon_frag:`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,points_vert:`uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}`,points_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,shadow_vert:`#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,shadow_frag:`uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}`,sprite_vert:`uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,sprite_frag:`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}`},Te={common:{diffuse:{value:new Be(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ct},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ct},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0},uvTransform:{value:new ct}},sprite:{diffuse:{value:new Be(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ct},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0}}},ei={basic:{uniforms:bn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:bn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new Be(0)}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:bn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new Be(0)},specular:{value:new Be(1118481)},shininess:{value:30}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:bn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new Be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:bn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new Be(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:bn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:bn([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:bn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:bn([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:bn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:bn([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distanceRGBA:{uniforms:bn([Te.common,Te.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:st.distanceRGBA_vert,fragmentShader:st.distanceRGBA_frag},shadow:{uniforms:bn([Te.lights,Te.fog,{color:{value:new Be(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};ei.physical={uniforms:bn([ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ct},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ct},sheen:{value:0},sheenColor:{value:new Be(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ct},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ct},attenuationDistance:{value:0},attenuationColor:{value:new Be(0)},specularColor:{value:new Be(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ct},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ct}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};const Ea={r:0,b:0,g:0};function c0(r,e,t,n,i,s,a){const o=new Be(0);let c=s===!0?0:1,l,u,d=null,h=0,f=null;function g(m,p){let _=!1,b=p.isScene===!0?p.background:null;b&&b.isTexture&&(b=(p.backgroundBlurriness>0?t:e).get(b)),b===null?v(o,c):b&&b.isColor&&(v(b,1),_=!0);const x=r.xr.getEnvironmentBlendMode();x===\"additive\"?n.buffers.color.setClear(0,0,0,1,a):x===\"alpha-blend\"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||_)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),b&&(b.isCubeTexture||b.mapping===qs)?(u===void 0&&(u=new We(new Ts(1,1,1),new qn({name:\"BackgroundCubeMaterial\",uniforms:Ur(ei.backgroundCube.uniforms),vertexShader:ei.backgroundCube.vertexShader,fragmentShader:ei.backgroundCube.fragmentShader,side:on,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute(\"normal\"),u.geometry.deleteAttribute(\"uv\"),u.onBeforeRender=function(E,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(u.material,\"envMap\",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=b,u.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,u.material.toneMapped=xt.getTransfer(b.colorSpace)!==Ct,(d!==b||h!==b.version||f!==r.toneMapping)&&(u.material.needsUpdate=!0,d=b,h=b.version,f=r.toneMapping),u.layers.enableAll(),m.unshift(u,u.geometry,u.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new We(new dn(2,2),new qn({name:\"BackgroundMaterial\",uniforms:Ur(ei.background.uniforms),vertexShader:ei.background.vertexShader,fragmentShader:ei.background.fragmentShader,side:Mn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute(\"normal\"),Object.defineProperty(l.material,\"map\",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=xt.getTransfer(b.colorSpace)!==Ct,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(d!==b||h!==b.version||f!==r.toneMapping)&&(l.material.needsUpdate=!0,d=b,h=b.version,f=r.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null))}function v(m,p){m.getRGB(Ea,Qu(r)),n.buffers.color.setClear(Ea.r,Ea.g,Ea.b,p,a)}return{getClearColor:function(){return o},setClearColor:function(m,p=1){o.set(m),c=p,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(m){c=m,v(o,c)},render:g}}function l0(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get(\"OES_vertex_array_object\"),a=n.isWebGL2||s!==null,o={},c=m(null);let l=c,u=!1;function d(P,z,X,re,J){let te=!1;if(a){const Q=v(re,X,z);l!==Q&&(l=Q,f(l.object)),te=p(P,re,X,J),te&&_(P,re,X,J)}else{const Q=z.wireframe===!0;(l.geometry!==re.id||l.program!==X.id||l.wireframe!==Q)&&(l.geometry=re.id,l.program=X.id,l.wireframe=Q,te=!0)}J!==null&&t.update(J,r.ELEMENT_ARRAY_BUFFER),(te||u)&&(u=!1,I(P,z,X,re),J!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(J).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(P){return n.isWebGL2?r.bindVertexArray(P):s.bindVertexArrayOES(P)}function g(P){return n.isWebGL2?r.deleteVertexArray(P):s.deleteVertexArrayOES(P)}function v(P,z,X){const re=X.wireframe===!0;let J=o[P.id];J===void 0&&(J={},o[P.id]=J);let te=J[z.id];te===void 0&&(te={},J[z.id]=te);let Q=te[re];return Q===void 0&&(Q=m(h()),te[re]=Q),Q}function m(P){const z=[],X=[],re=[];for(let J=0;J<i;J++)z[J]=0,X[J]=0,re[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:X,attributeDivisors:re,object:P,attributes:{},index:null}}function p(P,z,X,re){const J=l.attributes,te=z.attributes;let Q=0;const ce=X.getAttributes();for(const he in ce)if(ce[he].location>=0){const ue=J[he];let Me=te[he];if(Me===void 0&&(he===\"instanceMatrix\"&&P.instanceMatrix&&(Me=P.instanceMatrix),he===\"instanceColor\"&&P.instanceColor&&(Me=P.instanceColor)),ue===void 0||ue.attribute!==Me||Me&&ue.data!==Me.data)return!0;Q++}return l.attributesNum!==Q||l.index!==re}function _(P,z,X,re){const J={},te=z.attributes;let Q=0;const ce=X.getAttributes();for(const he in ce)if(ce[he].location>=0){let ue=te[he];ue===void 0&&(he===\"instanceMatrix\"&&P.instanceMatrix&&(ue=P.instanceMatrix),he===\"instanceColor\"&&P.instanceColor&&(ue=P.instanceColor));const Me={};Me.attribute=ue,ue&&ue.data&&(Me.data=ue.data),J[he]=Me,Q++}l.attributes=J,l.attributesNum=Q,l.index=re}function b(){const P=l.newAttributes;for(let z=0,X=P.length;z<X;z++)P[z]=0}function x(P){E(P,0)}function E(P,z){const X=l.newAttributes,re=l.enabledAttributes,J=l.attributeDivisors;X[P]=1,re[P]===0&&(r.enableVertexAttribArray(P),re[P]=1),J[P]!==z&&((n.isWebGL2?r:e.get(\"ANGLE_instanced_arrays\"))[n.isWebGL2?\"vertexAttribDivisor\":\"vertexAttribDivisorANGLE\"](P,z),J[P]=z)}function T(){const P=l.newAttributes,z=l.enabledAttributes;for(let X=0,re=z.length;X<re;X++)z[X]!==P[X]&&(r.disableVertexAttribArray(X),z[X]=0)}function A(P,z,X,re,J,te,Q){Q===!0?r.vertexAttribIPointer(P,z,X,J,te):r.vertexAttribPointer(P,z,X,re,J,te)}function I(P,z,X,re){if(n.isWebGL2===!1&&(P.isInstancedMesh||re.isInstancedBufferGeometry)&&e.get(\"ANGLE_instanced_arrays\")===null)return;b();const J=re.attributes,te=X.getAttributes(),Q=z.defaultAttributeValues;for(const ce in te){const he=te[ce];if(he.location>=0){let $=J[ce];if($===void 0&&(ce===\"instanceMatrix\"&&P.instanceMatrix&&($=P.instanceMatrix),ce===\"instanceColor\"&&P.instanceColor&&($=P.instanceColor)),$!==void 0){const ue=$.normalized,Me=$.itemSize,xe=t.get($);if(xe===void 0)continue;const ge=xe.buffer,Ge=xe.type,Ke=xe.bytesPerElement,He=n.isWebGL2===!0&&(Ge===r.INT||Ge===r.UNSIGNED_INT||$.gpuType===ps);if($.isInterleavedBufferAttribute){const tt=$.data,W=tt.stride,ze=$.offset;if(tt.isInstancedInterleavedBuffer){for(let Le=0;Le<he.locationSize;Le++)E(he.location+Le,tt.meshPerAttribute);P.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=tt.meshPerAttribute*tt.count)}else for(let Le=0;Le<he.locationSize;Le++)x(he.location+Le);r.bindBuffer(r.ARRAY_BUFFER,ge);for(let Le=0;Le<he.locationSize;Le++)A(he.location+Le,Me/he.locationSize,Ge,ue,W*Ke,(ze+Me/he.locationSize*Le)*Ke,He)}else{if($.isInstancedBufferAttribute){for(let tt=0;tt<he.locationSize;tt++)E(he.location+tt,$.meshPerAttribute);P.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let tt=0;tt<he.locationSize;tt++)x(he.location+tt);r.bindBuffer(r.ARRAY_BUFFER,ge);for(let tt=0;tt<he.locationSize;tt++)A(he.location+tt,Me/he.locationSize,Ge,ue,Me*Ke,Me/he.locationSize*tt*Ke,He)}}else if(Q!==void 0){const ue=Q[ce];if(ue!==void 0)switch(ue.length){case 2:r.vertexAttrib2fv(he.location,ue);break;case 3:r.vertexAttrib3fv(he.location,ue);break;case 4:r.vertexAttrib4fv(he.location,ue);break;default:r.vertexAttrib1fv(he.location,ue)}}}}T()}function S(){U();for(const P in o){const z=o[P];for(const X in z){const re=z[X];for(const J in re)g(re[J].object),delete re[J];delete z[X]}delete o[P]}}function R(P){if(o[P.id]===void 0)return;const z=o[P.id];for(const X in z){const re=z[X];for(const J in re)g(re[J].object),delete re[J];delete z[X]}delete o[P.id]}function F(P){for(const z in o){const X=o[z];if(X[P.id]===void 0)continue;const re=X[P.id];for(const J in re)g(re[J].object),delete re[J];delete X[P.id]}}function U(){V(),u=!0,l!==c&&(l=c,f(l.object))}function V(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:d,reset:U,resetDefaultState:V,dispose:S,releaseStatesOfGeometry:R,releaseStatesOfProgram:F,initAttributes:b,enableAttribute:x,disableUnusedAttributes:T}}function u0(r,e,t,n){const i=n.isWebGL2;let s;function a(u){s=u}function o(u,d){r.drawArrays(s,u,d),t.update(d,s,1)}function c(u,d,h){if(h===0)return;let f,g;if(i)f=r,g=\"drawArraysInstanced\";else if(f=e.get(\"ANGLE_instanced_arrays\"),g=\"drawArraysInstancedANGLE\",f===null){console.error(\"THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.\");return}f[g](s,u,d,h),t.update(d,s,h)}function l(u,d,h){if(h===0)return;const f=e.get(\"WEBGL_multi_draw\");if(f===null)for(let g=0;g<h;g++)this.render(u[g],d[g]);else{f.multiDrawArraysWEBGL(s,u,0,d,0,h);let g=0;for(let v=0;v<h;v++)g+=d[v];t.update(g,s,1)}}this.setMode=a,this.render=o,this.renderInstances=c,this.renderMultiDraw=l}function d0(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has(\"EXT_texture_filter_anisotropic\")===!0){const A=e.get(\"EXT_texture_filter_anisotropic\");n=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(A){if(A===\"highp\"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return\"highp\";A=\"mediump\"}return A===\"mediump\"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?\"mediump\":\"lowp\"}const a=typeof WebGL2RenderingContext<\"u\"&&r.constructor.name===\"WebGL2RenderingContext\";let o=t.precision!==void 0?t.precision:\"highp\";const c=s(o);c!==o&&(console.warn(\"THREE.WebGLRenderer:\",o,\"not supported, using\",c,\"instead.\"),o=c);const l=a||e.has(\"WEBGL_draw_buffers\"),u=t.logarithmicDepthBuffer===!0,d=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),v=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),p=r.getParameter(r.MAX_VARYING_VECTORS),_=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),b=h>0,x=a||e.has(\"OES_texture_float\"),E=b&&x,T=a?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:h,maxTextureSize:f,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:m,maxVaryings:p,maxFragmentUniforms:_,vertexTextures:b,floatFragmentTextures:x,floatVertexTextures:E,maxSamples:T}}function h0(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new Qn,o=new ct,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||n!==0||i;return i=h,n=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const g=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,p=r.get(d);if(!i||g===null||g.length===0||s&&!m)s?u(null):l();else{const _=s?0:n,b=_*4;let x=p.clippingState||null;c.value=x,x=u(g,h,b,f);for(let E=0;E!==b;++E)x[E]=t[E];p.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(d,h,f,g){const v=d!==null?d.length:0;let m=null;if(v!==0){if(m=c.value,g!==!0||m===null){const p=f+v*4,_=h.matrixWorldInverse;o.getNormalMatrix(_),(m===null||m.length<p)&&(m=new Float32Array(p));for(let b=0,x=f;b!==v;++b,x+=4)a.copy(d[b]).applyMatrix4(_,o),a.normal.toArray(m,x),m[x+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}function f0(r){let e=new WeakMap;function t(a,o){return o===yo?a.mapping=pr:o===Mo&&(a.mapping=mr),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===yo||o===Mo)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new Br(c.height/2);return l.fromEquirectangularTexture(r,a),e.set(a,l),a.addEventListener(\"dispose\",i),t(l.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener(\"dispose\",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class cc extends ed{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=\"OrthographicCamera\",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem),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}}const kr=4,nd=[.125,.215,.35,.446,.526,.582],tr=20,lc=new cc,id=new Be;let uc=null,dc=0,hc=0;const nr=(1+Math.sqrt(5))/2,zr=1/nr,rd=[new O(1,1,1),new O(-1,1,1),new O(1,1,-1),new O(-1,1,-1),new O(0,nr,zr),new O(0,nr,-zr),new O(zr,0,nr),new O(-zr,0,nr),new O(nr,zr,0),new O(-nr,zr,0)];class Ta{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){uc=this._renderer.getRenderTarget(),dc=this._renderer.getActiveCubeFace(),hc=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=od(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ad(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(uc,dc,hc),e.scissorTest=!1,wa(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===pr||e.mapping===mr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),uc=this._renderer.getRenderTarget(),dc=this._renderer.getActiveCubeFace(),hc=this._renderer.getActiveMipmapLevel();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:At,minFilter:At,generateMipmaps:!1,type:cn,format:kt,colorSpace:zt,depthBuffer:!1},i=sd(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=sd(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=p0(s)),this._blurMaterial=m0(s,e,t)}return i}_compileMaterial(e){const t=new We(this._lodPlanes[0],e);this._renderer.compile(t,lc)}_sceneToCubeUV(e,t,n,i){const o=new un(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(id),u.toneMapping=ri,u.autoClear=!1;const f=new Gt({name:\"PMREM.Background\",side:on,depthWrite:!1,depthTest:!1}),g=new We(new Ts,f);let v=!1;const m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,v=!0):(f.color.copy(id),v=!0);for(let p=0;p<6;p++){const _=p%3;_===0?(o.up.set(0,c[p],0),o.lookAt(l[p],0,0)):_===1?(o.up.set(0,0,c[p]),o.lookAt(0,l[p],0)):(o.up.set(0,c[p],0),o.lookAt(0,0,l[p]));const b=this._cubeSize;wa(i,_*b,p>2?b:0,b,b),u.setRenderTarget(i),v&&u.render(g,o),u.render(e,o)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===pr||e.mapping===mr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=od()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ad());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new We(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;wa(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,lc)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=rd[(i-1)%rd.length];this._blur(e,i-1,i,s,a)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,\"latitudinal\",s),this._halfBlur(a,e,n,n,i,\"longitudinal\",s)}_halfBlur(e,t,n,i,s,a,o){const c=this._renderer,l=this._blurMaterial;a!==\"latitudinal\"&&a!==\"longitudinal\"&&console.error(\"blur direction must be either latitudinal or longitudinal!\");const u=3,d=new We(this._lodPlanes[i],l),h=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*tr-1),v=s/g,m=isFinite(s)?1+Math.floor(u*v):tr;m>tr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${tr}`);const p=[];let _=0;for(let A=0;A<tr;++A){const I=A/v,S=Math.exp(-I*I/2);p.push(S),A===0?_+=S:A<m&&(_+=2*S)}for(let A=0;A<p.length;A++)p[A]=p[A]/_;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=p,h.latitudinal.value=a===\"latitudinal\",o&&(h.poleAxis.value=o);const{_lodMax:b}=this;h.dTheta.value=g,h.mipInt.value=b-n;const x=this._sizeLods[i],E=3*x*(i>b-kr?i-b+kr:0),T=4*(this._cubeSize-x);wa(t,E,T,3*x,2*x),c.setRenderTarget(t),c.render(d,lc)}}function p0(r){const e=[],t=[],n=[];let i=r;const s=r-kr+1+nd.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>r-kr?c=nd[a-r+kr-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,d=1+l,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,g=6,v=3,m=2,p=1,_=new Float32Array(v*g*f),b=new Float32Array(m*g*f),x=new Float32Array(p*g*f);for(let T=0;T<f;T++){const A=T%3*2/3-1,I=T>2?0:-1,S=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];_.set(S,v*g*T),b.set(h,m*g*T);const R=[T,T,T,T,T,T];x.set(R,p*g*T)}const E=new mn;E.setAttribute(\"position\",new vt(_,v)),E.setAttribute(\"uv\",new vt(b,m)),E.setAttribute(\"faceIndex\",new vt(x,p)),e.push(E),i>kr&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function sd(r,e,t){const n=new Ki(r,e,t);return n.texture.mapping=qs,n.texture.name=\"PMREM.cubeUv\",n.scissorTest=!0,n}function wa(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function m0(r,e,t){const n=new Float32Array(tr),i=new O(0,1,0);return new qn({name:\"SphericalGaussianBlur\",defines:{n:tr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:fc(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t`,blending:ii,depthTest:!1,depthWrite:!1})}function ad(){return new qn({name:\"EquirectangularToCubeUV\",uniforms:{envMap:{value:null}},vertexShader:fc(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t`,blending:ii,depthTest:!1,depthWrite:!1})}function od(){return new qn({name:\"CubemapToCubeUV\",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fc(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t`,blending:ii,depthTest:!1,depthWrite:!1})}function fc(){return`\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t`}function g0(r){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===yo||c===Mo,u=c===pr||c===mr;if(l||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=e.get(o);return t===null&&(t=new Ta(r)),d=l?t.fromEquirectangular(o,d):t.fromCubemap(o,d),e.set(o,d),d.texture}else{if(e.has(o))return e.get(o).texture;{const d=o.image;if(l&&d&&d.height>0||u&&d&&i(d)){t===null&&(t=new Ta(r));const h=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,h),o.addEventListener(\"dispose\",s),h.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let u=0;u<l;u++)o[u]!==void 0&&c++;return c===l}function s(o){const c=o.target;c.removeEventListener(\"dispose\",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function b0(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case\"WEBGL_depth_texture\":i=r.getExtension(\"WEBGL_depth_texture\")||r.getExtension(\"MOZ_WEBGL_depth_texture\")||r.getExtension(\"WEBKIT_WEBGL_depth_texture\");break;case\"EXT_texture_filter_anisotropic\":i=r.getExtension(\"EXT_texture_filter_anisotropic\")||r.getExtension(\"MOZ_EXT_texture_filter_anisotropic\")||r.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\");break;case\"WEBGL_compressed_texture_s3tc\":i=r.getExtension(\"WEBGL_compressed_texture_s3tc\")||r.getExtension(\"MOZ_WEBGL_compressed_texture_s3tc\")||r.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc\");break;case\"WEBGL_compressed_texture_pvrtc\":i=r.getExtension(\"WEBGL_compressed_texture_pvrtc\")||r.getExtension(\"WEBKIT_WEBGL_compressed_texture_pvrtc\");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?(t(\"EXT_color_buffer_float\"),t(\"WEBGL_clip_cull_distance\")):(t(\"WEBGL_depth_texture\"),t(\"OES_texture_float\"),t(\"OES_texture_half_float\"),t(\"OES_texture_half_float_linear\"),t(\"OES_standard_derivatives\"),t(\"OES_element_index_uint\"),t(\"OES_vertex_array_object\"),t(\"ANGLE_instanced_arrays\")),t(\"OES_texture_float_linear\"),t(\"EXT_color_buffer_half_float\"),t(\"WEBGL_multisampled_render_to_texture\")},get:function(n){const i=t(n);return i===null&&console.warn(\"THREE.WebGLRenderer: \"+n+\" extension not supported.\"),i}}}function _0(r,e,t,n){const i={},s=new WeakMap;function a(d){const h=d.target;h.index!==null&&e.remove(h.index);for(const g in h.attributes)e.remove(h.attributes[g]);for(const g in h.morphAttributes){const v=h.morphAttributes[g];for(let m=0,p=v.length;m<p;m++)e.remove(v[m])}h.removeEventListener(\"dispose\",a),delete i[h.id];const f=s.get(h);f&&(e.remove(f),s.delete(h)),n.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(d,h){return i[h.id]===!0||(h.addEventListener(\"dispose\",a),i[h.id]=!0,t.memory.geometries++),h}function c(d){const h=d.attributes;for(const g in h)e.update(h[g],r.ARRAY_BUFFER);const f=d.morphAttributes;for(const g in f){const v=f[g];for(let m=0,p=v.length;m<p;m++)e.update(v[m],r.ARRAY_BUFFER)}}function l(d){const h=[],f=d.index,g=d.attributes.position;let v=0;if(f!==null){const _=f.array;v=f.version;for(let b=0,x=_.length;b<x;b+=3){const E=_[b+0],T=_[b+1],A=_[b+2];h.push(E,T,T,A,A,E)}}else if(g!==void 0){const _=g.array;v=g.version;for(let b=0,x=_.length/3-1;b<x;b+=3){const E=b+0,T=b+1,A=b+2;h.push(E,T,T,A,A,E)}}else return;const m=new(Lu(h)?qu:Xu)(h,1);m.version=v;const p=s.get(d);p&&e.remove(p),s.set(d,m)}function u(d){const h=s.get(d);if(h){const f=d.index;f!==null&&h.version<f.version&&l(d)}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function v0(r,e,t,n){const i=n.isWebGL2;let s;function a(f){s=f}let o,c;function l(f){o=f.type,c=f.bytesPerElement}function u(f,g){r.drawElements(s,g,o,f*c),t.update(g,s,1)}function d(f,g,v){if(v===0)return;let m,p;if(i)m=r,p=\"drawElementsInstanced\";else if(m=e.get(\"ANGLE_instanced_arrays\"),p=\"drawElementsInstancedANGLE\",m===null){console.error(\"THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.\");return}m[p](s,g,o,f*c,v),t.update(g,s,v)}function h(f,g,v){if(v===0)return;const m=e.get(\"WEBGL_multi_draw\");if(m===null)for(let p=0;p<v;p++)this.render(f[p]/c,g[p]);else{m.multiDrawElementsWEBGL(s,g,0,o,f,0,v);let p=0;for(let _=0;_<v;_++)p+=g[_];t.update(p,s,1)}}this.setMode=a,this.setIndex=l,this.render=u,this.renderInstances=d,this.renderMultiDraw=h}function x0(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:console.error(\"THREE.WebGLInfo: Unknown draw mode:\",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function y0(r,e){return r[0]-e[0]}function M0(r,e){return Math.abs(e[1])-Math.abs(r[1])}function S0(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,a=new Tt,o=[];for(let l=0;l<8;l++)o[l]=[l,0];function c(l,u,d){const h=l.morphTargetInfluences;if(e.isWebGL2===!0){const f=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,g=f!==void 0?f.length:0;let v=s.get(u);if(v===void 0||v.count!==g){let P=function(){U.dispose(),s.delete(u),u.removeEventListener(\"dispose\",P)};v!==void 0&&v.texture.dispose();const _=u.morphAttributes.position!==void 0,b=u.morphAttributes.normal!==void 0,x=u.morphAttributes.color!==void 0,E=u.morphAttributes.position||[],T=u.morphAttributes.normal||[],A=u.morphAttributes.color||[];let I=0;_===!0&&(I=1),b===!0&&(I=2),x===!0&&(I=3);let S=u.attributes.position.count*I,R=1;S>e.maxTextureSize&&(R=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const F=new Float32Array(S*R*4*g),U=new Fu(F,S,R,g);U.type=jt,U.needsUpdate=!0;const V=I*4;for(let z=0;z<g;z++){const X=E[z],re=T[z],J=A[z],te=S*R*4*z;for(let Q=0;Q<X.count;Q++){const ce=Q*V;_===!0&&(a.fromBufferAttribute(X,Q),F[te+ce+0]=a.x,F[te+ce+1]=a.y,F[te+ce+2]=a.z,F[te+ce+3]=0),b===!0&&(a.fromBufferAttribute(re,Q),F[te+ce+4]=a.x,F[te+ce+5]=a.y,F[te+ce+6]=a.z,F[te+ce+7]=0),x===!0&&(a.fromBufferAttribute(J,Q),F[te+ce+8]=a.x,F[te+ce+9]=a.y,F[te+ce+10]=a.z,F[te+ce+11]=J.itemSize===4?a.w:1)}}v={count:g,texture:U,size:new Ve(S,R)},s.set(u,v),u.addEventListener(\"dispose\",P)}let m=0;for(let _=0;_<h.length;_++)m+=h[_];const p=u.morphTargetsRelative?1:1-m;d.getUniforms().setValue(r,\"morphTargetBaseInfluence\",p),d.getUniforms().setValue(r,\"morphTargetInfluences\",h),d.getUniforms().setValue(r,\"morphTargetsTexture\",v.texture,t),d.getUniforms().setValue(r,\"morphTargetsTextureSize\",v.size)}else{const f=h===void 0?0:h.length;let g=n[u.id];if(g===void 0||g.length!==f){g=[];for(let b=0;b<f;b++)g[b]=[b,0];n[u.id]=g}for(let b=0;b<f;b++){const x=g[b];x[0]=b,x[1]=h[b]}g.sort(M0);for(let b=0;b<8;b++)b<f&&g[b][1]?(o[b][0]=g[b][0],o[b][1]=g[b][1]):(o[b][0]=Number.MAX_SAFE_INTEGER,o[b][1]=0);o.sort(y0);const v=u.morphAttributes.position,m=u.morphAttributes.normal;let p=0;for(let b=0;b<8;b++){const x=o[b],E=x[0],T=x[1];E!==Number.MAX_SAFE_INTEGER&&T?(v&&u.getAttribute(\"morphTarget\"+b)!==v[E]&&u.setAttribute(\"morphTarget\"+b,v[E]),m&&u.getAttribute(\"morphNormal\"+b)!==m[E]&&u.setAttribute(\"morphNormal\"+b,m[E]),i[b]=T,p+=T):(v&&u.hasAttribute(\"morphTarget\"+b)===!0&&u.deleteAttribute(\"morphTarget\"+b),m&&u.hasAttribute(\"morphNormal\"+b)===!0&&u.deleteAttribute(\"morphNormal\"+b),i[b]=0)}const _=u.morphTargetsRelative?1:1-p;d.getUniforms().setValue(r,\"morphTargetBaseInfluence\",_),d.getUniforms().setValue(r,\"morphTargetInfluences\",i)}}return{update:c}}function E0(r,e,t,n){let i=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,d=e.get(c,u);if(i.get(d)!==l&&(e.update(d),i.set(d,l)),c.isInstancedMesh&&(c.hasEventListener(\"dispose\",o)===!1&&c.addEventListener(\"dispose\",o),i.get(c)!==l&&(t.update(c.instanceMatrix,r.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,r.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const h=c.skeleton;i.get(h)!==l&&(h.update(),i.set(h,l))}return d}function a(){i=new WeakMap}function o(c){const l=c.target;l.removeEventListener(\"dispose\",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:a}}class cd extends Xt{constructor(e,t,n,i,s,a,o,c,l,u){if(u=u!==void 0?u:ji,u!==ji&&u!==gr)throw new Error(\"DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat\");n===void 0&&u===ji&&(n=wn),n===void 0&&u===gr&&(n=Wi),super(null,i,s,a,o,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:yt,this.minFilter=c!==void 0?c:yt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const ld=new Xt,ud=new cd(1,1);ud.compareFunction=Cu;const dd=new Fu,hd=new Gp,fd=new sc,pd=[],md=[],gd=new Float32Array(16),bd=new Float32Array(9),_d=new Float32Array(4);function Gr(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=pd[i];if(s===void 0&&(s=new Float32Array(i),pd[i]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function Jt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Qt(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Aa(r,e){let t=md[e];t===void 0&&(t=new Int32Array(e),md[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function T0(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function w0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Jt(t,e))return;r.uniform2fv(this.addr,e),Qt(t,e)}}function A0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Jt(t,e))return;r.uniform3fv(this.addr,e),Qt(t,e)}}function R0(r,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)&&(r.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(Jt(t,e))return;r.uniform4fv(this.addr,e),Qt(t,e)}}function C0(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Jt(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Qt(t,e)}else{if(Jt(t,n))return;_d.set(n),r.uniformMatrix2fv(this.addr,!1,_d),Qt(t,n)}}function P0(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Jt(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Qt(t,e)}else{if(Jt(t,n))return;bd.set(n),r.uniformMatrix3fv(this.addr,!1,bd),Qt(t,n)}}function L0(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Jt(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Qt(t,e)}else{if(Jt(t,n))return;gd.set(n),r.uniformMatrix4fv(this.addr,!1,gd),Qt(t,n)}}function I0(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function D0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Jt(t,e))return;r.uniform2iv(this.addr,e),Qt(t,e)}}function N0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Jt(t,e))return;r.uniform3iv(this.addr,e),Qt(t,e)}}function U0(r,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)&&(r.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(Jt(t,e))return;r.uniform4iv(this.addr,e),Qt(t,e)}}function F0(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function O0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Jt(t,e))return;r.uniform2uiv(this.addr,e),Qt(t,e)}}function B0(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Jt(t,e))return;r.uniform3uiv(this.addr,e),Qt(t,e)}}function k0(r,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)&&(r.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(Jt(t,e))return;r.uniform4uiv(this.addr,e),Qt(t,e)}}function z0(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);const s=this.type===r.SAMPLER_2D_SHADOW?ud:ld;t.setTexture2D(e||s,i)}function G0(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||hd,i)}function H0(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||fd,i)}function V0(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||dd,i)}function W0(r){switch(r){case 5126:return T0;case 35664:return w0;case 35665:return A0;case 35666:return R0;case 35674:return C0;case 35675:return P0;case 35676:return L0;case 5124:case 35670:return I0;case 35667:case 35671:return D0;case 35668:case 35672:return N0;case 35669:case 35673:return U0;case 5125:return F0;case 36294:return O0;case 36295:return B0;case 36296:return k0;case 35678:case 36198:case 36298:case 36306:case 35682:return z0;case 35679:case 36299:case 36307:return G0;case 35680:case 36300:case 36308:case 36293:return H0;case 36289:case 36303:case 36311:case 36292:return V0}}function j0(r,e){r.uniform1fv(this.addr,e)}function X0(r,e){const t=Gr(e,this.size,2);r.uniform2fv(this.addr,t)}function q0(r,e){const t=Gr(e,this.size,3);r.uniform3fv(this.addr,t)}function Y0(r,e){const t=Gr(e,this.size,4);r.uniform4fv(this.addr,t)}function K0(r,e){const t=Gr(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function Z0(r,e){const t=Gr(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function $0(r,e){const t=Gr(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function J0(r,e){r.uniform1iv(this.addr,e)}function Q0(r,e){r.uniform2iv(this.addr,e)}function eb(r,e){r.uniform3iv(this.addr,e)}function tb(r,e){r.uniform4iv(this.addr,e)}function nb(r,e){r.uniform1uiv(this.addr,e)}function ib(r,e){r.uniform2uiv(this.addr,e)}function rb(r,e){r.uniform3uiv(this.addr,e)}function sb(r,e){r.uniform4uiv(this.addr,e)}function ab(r,e,t){const n=this.cache,i=e.length,s=Aa(t,i);Jt(n,s)||(r.uniform1iv(this.addr,s),Qt(n,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||ld,s[a])}function ob(r,e,t){const n=this.cache,i=e.length,s=Aa(t,i);Jt(n,s)||(r.uniform1iv(this.addr,s),Qt(n,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||hd,s[a])}function cb(r,e,t){const n=this.cache,i=e.length,s=Aa(t,i);Jt(n,s)||(r.uniform1iv(this.addr,s),Qt(n,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||fd,s[a])}function lb(r,e,t){const n=this.cache,i=e.length,s=Aa(t,i);Jt(n,s)||(r.uniform1iv(this.addr,s),Qt(n,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||dd,s[a])}function ub(r){switch(r){case 5126:return j0;case 35664:return X0;case 35665:return q0;case 35666:return Y0;case 35674:return K0;case 35675:return Z0;case 35676:return $0;case 5124:case 35670:return J0;case 35667:case 35671:return Q0;case 35668:case 35672:return eb;case 35669:case 35673:return tb;case 5125:return nb;case 36294:return ib;case 36295:return rb;case 36296:return sb;case 35678:case 36198:case 36298:case 36306:case 35682:return ab;case 35679:case 36299:case 36307:return ob;case 35680:case 36300:case 36308:case 36293:return cb;case 36289:case 36303:case 36311:case 36292:return lb}}class db{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=W0(t.type)}}class hb{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=ub(t.type)}}class fb{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],n)}}}const pc=/(\\w+)(\\])?(\\[|\\.)?/g;function vd(r,e){r.seq.push(e),r.map[e.id]=e}function pb(r,e,t){const n=r.name,i=n.length;for(pc.lastIndex=0;;){const s=pc.exec(n),a=pc.lastIndex;let o=s[1];const c=s[2]===\"]\",l=s[3];if(c&&(o=o|0),l===void 0||l===\"[\"&&a+2===i){vd(t,l===void 0?new db(o,r,e):new hb(o,r,e));break}else{let d=t.map[o];d===void 0&&(d=new fb(o),vd(t,d)),t=d}}}class Ra{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);pb(s,a,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function xd(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}const mb=37297;let gb=0;function bb(r,e){const t=r.split(`\n`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a<s;a++){const o=a+1;n.push(`${o===e?\">\":\" \"} ${o}: ${t[a]}`)}return n.join(`\n`)}function _b(r){const e=xt.getPrimaries(xt.workingColorSpace),t=xt.getPrimaries(r);let n;switch(e===t?n=\"\":e===ea&&t===Qs?n=\"LinearDisplayP3ToLinearSRGB\":e===Qs&&t===ea&&(n=\"LinearSRGBToLinearDisplayP3\"),r){case zt:case $s:return[n,\"LinearTransferOETF\"];case Mt:case Uo:return[n,\"sRGBTransferOETF\"];default:return console.warn(\"THREE.WebGLProgram: Unsupported color space:\",r),[n,\"LinearTransferOETF\"]}}function yd(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i===\"\")return\"\";const s=/ERROR: 0:(\\d+)/.exec(i);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`\n\n`+i+`\n\n`+bb(r.getShaderSource(e),a)}else return i}function vb(r,e){const t=_b(e);return`vec4 ${r}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function xb(r,e){let t;switch(e){case ep:t=\"Linear\";break;case tp:t=\"Reinhard\";break;case np:t=\"OptimizedCineon\";break;case Wl:t=\"ACESFilmic\";break;case rp:t=\"AgX\";break;case ip:t=\"Custom\";break;default:console.warn(\"THREE.WebGLProgram: Unsupported toneMapping:\",e),t=\"Linear\"}return\"vec3 \"+r+\"( vec3 color ) { return \"+t+\"ToneMapping( color ); }\"}function yb(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID===\"physical\"?\"#extension GL_OES_standard_derivatives : enable\":\"\",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?\"#extension GL_EXT_frag_depth : enable\":\"\",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?\"#extension GL_EXT_draw_buffers : require\":\"\",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?\"#extension GL_EXT_shader_texture_lod : enable\":\"\"].filter(Hr).join(`\n`)}function Mb(r){return[r.extensionClipCullDistance?\"#extension GL_ANGLE_clip_cull_distance : require\":\"\"].filter(Hr).join(`\n`)}function Sb(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push(\"#define \"+t+\" \"+n)}return e.join(`\n`)}function Eb(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Hr(r){return r!==\"\"}function Md(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.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 Sd(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Tb=/^[ \\t]*#include +<([\\w\\d./]+)>/gm;function mc(r){return r.replace(Tb,Ab)}const wb=new Map([[\"encodings_fragment\",\"colorspace_fragment\"],[\"encodings_pars_fragment\",\"colorspace_pars_fragment\"],[\"output_fragment\",\"opaque_fragment\"]]);function Ab(r,e){let t=st[e];if(t===void 0){const n=wb.get(e);if(n!==void 0)t=st[n],console.warn('THREE.WebGLRenderer: Shader chunk \"%s\" has been deprecated. Use \"%s\" instead.',e,n);else throw new Error(\"Can not resolve #include <\"+e+\">\")}return mc(t)}const Rb=/#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 Ed(r){return r.replace(Rb,Cb)}function Cb(r,e,t,n){let i=\"\";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\\[\\s*i\\s*\\]/g,\"[ \"+s+\" ]\").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function Td(r){let e=\"precision \"+r.precision+` float;\nprecision `+r.precision+\" int;\";return r.precision===\"highp\"?e+=`\n#define HIGH_PRECISION`:r.precision===\"mediump\"?e+=`\n#define MEDIUM_PRECISION`:r.precision===\"lowp\"&&(e+=`\n#define LOW_PRECISION`),e}function Pb(r){let e=\"SHADOWMAP_TYPE_BASIC\";return r.shadowMapType===Bl?e=\"SHADOWMAP_TYPE_PCF\":r.shadowMapType===Rf?e=\"SHADOWMAP_TYPE_PCF_SOFT\":r.shadowMapType===ni&&(e=\"SHADOWMAP_TYPE_VSM\"),e}function Lb(r){let e=\"ENVMAP_TYPE_CUBE\";if(r.envMap)switch(r.envMapMode){case pr:case mr:e=\"ENVMAP_TYPE_CUBE\";break;case qs:e=\"ENVMAP_TYPE_CUBE_UV\";break}return e}function Ib(r){let e=\"ENVMAP_MODE_REFLECTION\";if(r.envMap)switch(r.envMapMode){case mr:e=\"ENVMAP_MODE_REFRACTION\";break}return e}function Db(r){let e=\"ENVMAP_BLENDING_NONE\";if(r.envMap)switch(r.combine){case xo:e=\"ENVMAP_BLENDING_MULTIPLY\";break;case Jf:e=\"ENVMAP_BLENDING_MIX\";break;case Qf:e=\"ENVMAP_BLENDING_ADD\";break}return e}function Nb(r){const e=r.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 Ub(r,e,t,n){const i=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Pb(t),l=Lb(t),u=Ib(t),d=Db(t),h=Nb(t),f=t.isWebGL2?\"\":yb(t),g=Mb(t),v=Sb(s),m=i.createProgram();let p,_,b=t.glslVersion?\"#version \"+t.glslVersion+`\n`:\"\";t.isRawShaderMaterial?(p=[\"#define SHADER_TYPE \"+t.shaderType,\"#define SHADER_NAME \"+t.shaderName,v].filter(Hr).join(`\n`),p.length>0&&(p+=`\n`),_=[f,\"#define SHADER_TYPE \"+t.shaderType,\"#define SHADER_NAME \"+t.shaderName,v].filter(Hr).join(`\n`),_.length>0&&(_+=`\n`)):(p=[Td(t),\"#define SHADER_TYPE \"+t.shaderType,\"#define SHADER_NAME \"+t.shaderName,v,t.extensionClipCullDistance?\"#define USE_CLIP_DISTANCE\":\"\",t.batching?\"#define USE_BATCHING\":\"\",t.instancing?\"#define USE_INSTANCING\":\"\",t.instancingColor?\"#define USE_INSTANCING_COLOR\":\"\",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 \"+u:\"\",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&&t.isWebGL2?\"#define USE_MORPHCOLORS\":\"\",t.morphTargetsCount>0&&t.isWebGL2?\"#define MORPHTARGETS_TEXTURE\":\"\",t.morphTargetsCount>0&&t.isWebGL2?\"#define MORPHTARGETS_TEXTURE_STRIDE \"+t.morphTextureStride:\"\",t.morphTargetsCount>0&&t.isWebGL2?\"#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.useLegacyLights?\"#define LEGACY_LIGHTS\":\"\",t.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?\"#define USE_LOGDEPTHBUF_EXT\":\"\",\"uniform mat4 modelMatrix;\",\"uniform mat4 modelViewMatrix;\",\"uniform mat4 projectionMatrix;\",\"uniform mat4 viewMatrix;\",\"uniform mat3 normalMatrix;\",\"uniform vec3 cameraPosition;\",\"uniform bool isOrthographic;\",\"#ifdef USE_INSTANCING\",\"\tattribute mat4 instanceMatrix;\",\"#endif\",\"#ifdef USE_INSTANCING_COLOR\",\"\tattribute vec3 instanceColor;\",\"#endif\",\"attribute vec3 position;\",\"attribute vec3 normal;\",\"attribute vec2 uv;\",\"#ifdef USE_UV1\",\"\tattribute vec2 uv1;\",\"#endif\",\"#ifdef USE_UV2\",\"\tattribute vec2 uv2;\",\"#endif\",\"#ifdef USE_UV3\",\"\tattribute vec2 uv3;\",\"#endif\",\"#ifdef USE_TANGENT\",\"\tattribute vec4 tangent;\",\"#endif\",\"#if defined( USE_COLOR_ALPHA )\",\"\tattribute vec4 color;\",\"#elif defined( USE_COLOR )\",\"\tattribute vec3 color;\",\"#endif\",\"#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )\",\"\tattribute vec3 morphTarget0;\",\"\tattribute vec3 morphTarget1;\",\"\tattribute vec3 morphTarget2;\",\"\tattribute vec3 morphTarget3;\",\"\t#ifdef USE_MORPHNORMALS\",\"\t\tattribute vec3 morphNormal0;\",\"\t\tattribute vec3 morphNormal1;\",\"\t\tattribute vec3 morphNormal2;\",\"\t\tattribute vec3 morphNormal3;\",\"\t#else\",\"\t\tattribute vec3 morphTarget4;\",\"\t\tattribute vec3 morphTarget5;\",\"\t\tattribute vec3 morphTarget6;\",\"\t\tattribute vec3 morphTarget7;\",\"\t#endif\",\"#endif\",\"#ifdef USE_SKINNING\",\"\tattribute vec4 skinIndex;\",\"\tattribute vec4 skinWeight;\",\"#endif\",`\n`].filter(Hr).join(`\n`),_=[f,Td(t),\"#define SHADER_TYPE \"+t.shaderType,\"#define SHADER_NAME \"+t.shaderName,v,t.useFog&&t.fog?\"#define USE_FOG\":\"\",t.useFog&&t.fogExp2?\"#define FOG_EXP2\":\"\",t.map?\"#define USE_MAP\":\"\",t.matcap?\"#define USE_MATCAP\":\"\",t.envMap?\"#define USE_ENVMAP\":\"\",t.envMap?\"#define \"+l:\"\",t.envMap?\"#define \"+u:\"\",t.envMap?\"#define \"+d:\"\",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.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?\"#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.useLegacyLights?\"#define LEGACY_LIGHTS\":\"\",t.decodeVideoTexture?\"#define DECODE_VIDEO_TEXTURE\":\"\",t.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?\"#define USE_LOGDEPTHBUF_EXT\":\"\",\"uniform mat4 viewMatrix;\",\"uniform vec3 cameraPosition;\",\"uniform bool isOrthographic;\",t.toneMapping!==ri?\"#define TONE_MAPPING\":\"\",t.toneMapping!==ri?st.tonemapping_pars_fragment:\"\",t.toneMapping!==ri?xb(\"toneMapping\",t.toneMapping):\"\",t.dithering?\"#define DITHERING\":\"\",t.opaque?\"#define OPAQUE\":\"\",st.colorspace_pars_fragment,vb(\"linearToOutputTexel\",t.outputColorSpace),t.useDepthPacking?\"#define DEPTH_PACKING \"+t.depthPacking:\"\",`\n`].filter(Hr).join(`\n`)),a=mc(a),a=Md(a,t),a=Sd(a,t),o=mc(o),o=Md(o,t),o=Sd(o,t),a=Ed(a),o=Ed(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(b=`#version 300 es\n`,p=[g,\"precision mediump sampler2DArray;\",\"#define attribute in\",\"#define varying out\",\"#define texture2D texture\"].join(`\n`)+`\n`+p,_=[\"precision mediump sampler2DArray;\",\"#define varying in\",t.glslVersion===ta?\"\":\"layout(location = 0) out highp vec4 pc_fragColor;\",t.glslVersion===ta?\"\":\"#define gl_FragColor pc_fragColor\",\"#define gl_FragDepthEXT gl_FragDepth\",\"#define texture2D texture\",\"#define textureCube texture\",\"#define texture2DProj textureProj\",\"#define texture2DLodEXT textureLod\",\"#define texture2DProjLodEXT textureProjLod\",\"#define textureCubeLodEXT textureLod\",\"#define texture2DGradEXT textureGrad\",\"#define texture2DProjGradEXT textureProjGrad\",\"#define textureCubeGradEXT textureGrad\"].join(`\n`)+`\n`+_);const x=b+p+a,E=b+_+o,T=xd(i,i.VERTEX_SHADER,x),A=xd(i,i.FRAGMENT_SHADER,E);i.attachShader(m,T),i.attachShader(m,A),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,\"position\"),i.linkProgram(m);function I(U){if(r.debug.checkShaderErrors){const V=i.getProgramInfoLog(m).trim(),P=i.getShaderInfoLog(T).trim(),z=i.getShaderInfoLog(A).trim();let X=!0,re=!0;if(i.getProgramParameter(m,i.LINK_STATUS)===!1)if(X=!1,typeof r.debug.onShaderError==\"function\")r.debug.onShaderError(i,m,T,A);else{const J=yd(i,T,\"vertex\"),te=yd(i,A,\"fragment\");console.error(\"THREE.WebGLProgram: Shader Error \"+i.getError()+\" - VALIDATE_STATUS \"+i.getProgramParameter(m,i.VALIDATE_STATUS)+`\n\nProgram Info Log: `+V+`\n`+J+`\n`+te)}else V!==\"\"?console.warn(\"THREE.WebGLProgram: Program Info Log:\",V):(P===\"\"||z===\"\")&&(re=!1);re&&(U.diagnostics={runnable:X,programLog:V,vertexShader:{log:P,prefix:p},fragmentShader:{log:z,prefix:_}})}i.deleteShader(T),i.deleteShader(A),S=new Ra(i,m),R=Eb(i,m)}let S;this.getUniforms=function(){return S===void 0&&I(this),S};let R;this.getAttributes=function(){return R===void 0&&I(this),R};let F=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return F===!1&&(F=i.getProgramParameter(m,mb)),F},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=gb++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=T,this.fragmentShader=A,this}let Fb=0;class Ob{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Bb(e),t.set(e,n)),n}}class Bb{constructor(e){this.id=Fb++,this.code=e,this.usedTimes=0}}function kb(r,e,t,n,i,s,a){const o=new Zo,c=new Ob,l=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,h=i.vertexTextures;let f=i.precision;const g={MeshDepthMaterial:\"depth\",MeshDistanceMaterial:\"distanceRGBA\",MeshNormalMaterial:\"normal\",MeshBasicMaterial:\"basic\",MeshLambertMaterial:\"lambert\",MeshPhongMaterial:\"phong\",MeshToonMaterial:\"toon\",MeshStandardMaterial:\"physical\",MeshPhysicalMaterial:\"physical\",MeshMatcapMaterial:\"matcap\",LineBasicMaterial:\"basic\",LineDashedMaterial:\"dashed\",PointsMaterial:\"points\",ShadowMaterial:\"shadow\",SpriteMaterial:\"sprite\"};function v(S){return S===0?\"uv\":`uv${S}`}function m(S,R,F,U,V){const P=U.fog,z=V.geometry,X=S.isMeshStandardMaterial?U.environment:null,re=(S.isMeshStandardMaterial?t:e).get(S.envMap||X),J=re&&re.mapping===qs?re.image.height:null,te=g[S.type];S.precision!==null&&(f=i.getMaxPrecision(S.precision),f!==S.precision&&console.warn(\"THREE.WebGLProgram.getParameters:\",S.precision,\"not supported, using\",f,\"instead.\"));const Q=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,ce=Q!==void 0?Q.length:0;let he=0;z.morphAttributes.position!==void 0&&(he=1),z.morphAttributes.normal!==void 0&&(he=2),z.morphAttributes.color!==void 0&&(he=3);let $,ue,Me,xe;if(te){const Dt=ei[te];$=Dt.vertexShader,ue=Dt.fragmentShader}else $=S.vertexShader,ue=S.fragmentShader,c.update(S),Me=c.getVertexShaderID(S),xe=c.getFragmentShaderID(S);const ge=r.getRenderTarget(),Ge=V.isInstancedMesh===!0,Ke=V.isBatchedMesh===!0,He=!!S.map,tt=!!S.matcap,W=!!re,ze=!!S.aoMap,Le=!!S.lightMap,Ie=!!S.bumpMap,Ue=!!S.normalMap,_t=!!S.displacementMap,nt=!!S.emissiveMap,B=!!S.metalnessMap,N=!!S.roughnessMap,se=S.anisotropy>0,_e=S.clearcoat>0,pe=S.iridescence>0,ve=S.sheen>0,Fe=S.transmission>0,we=se&&!!S.anisotropyMap,Ne=_e&&!!S.clearcoatMap,je=_e&&!!S.clearcoatNormalMap,Qe=_e&&!!S.clearcoatRoughnessMap,me=pe&&!!S.iridescenceMap,ft=pe&&!!S.iridescenceThicknessMap,rt=ve&&!!S.sheenColorMap,Ye=ve&&!!S.sheenRoughnessMap,Pe=!!S.specularMap,Ce=!!S.specularColorMap,H=!!S.specularIntensityMap,fe=Fe&&!!S.transmissionMap,Re=Fe&&!!S.thicknessMap,De=!!S.gradientMap,ee=!!S.alphaMap,j=S.alphaTest>0,ye=!!S.alphaHash,Ae=!!S.extensions,Ze=!!z.attributes.uv1,Xe=!!z.attributes.uv2,at=!!z.attributes.uv3;let ot=ri;return S.toneMapped&&(ge===null||ge.isXRRenderTarget===!0)&&(ot=r.toneMapping),{isWebGL2:u,shaderID:te,shaderType:S.type,shaderName:S.name,vertexShader:$,fragmentShader:ue,defines:S.defines,customVertexShaderID:Me,customFragmentShaderID:xe,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:f,batching:Ke,instancing:Ge,instancingColor:Ge&&V.instanceColor!==null,supportsVertexTextures:h,outputColorSpace:ge===null?r.outputColorSpace:ge.isXRRenderTarget===!0?ge.texture.colorSpace:zt,map:He,matcap:tt,envMap:W,envMapMode:W&&re.mapping,envMapCubeUVHeight:J,aoMap:ze,lightMap:Le,bumpMap:Ie,normalMap:Ue,displacementMap:h&&_t,emissiveMap:nt,normalMapObjectSpace:Ue&&S.normalMapType===pp,normalMapTangentSpace:Ue&&S.normalMapType===No,metalnessMap:B,roughnessMap:N,anisotropy:se,anisotropyMap:we,clearcoat:_e,clearcoatMap:Ne,clearcoatNormalMap:je,clearcoatRoughnessMap:Qe,iridescence:pe,iridescenceMap:me,iridescenceThicknessMap:ft,sheen:ve,sheenColorMap:rt,sheenRoughnessMap:Ye,specularMap:Pe,specularColorMap:Ce,specularIntensityMap:H,transmission:Fe,transmissionMap:fe,thicknessMap:Re,gradientMap:De,opaque:S.transparent===!1&&S.blending===fr,alphaMap:ee,alphaTest:j,alphaHash:ye,combine:S.combine,mapUv:He&&v(S.map.channel),aoMapUv:ze&&v(S.aoMap.channel),lightMapUv:Le&&v(S.lightMap.channel),bumpMapUv:Ie&&v(S.bumpMap.channel),normalMapUv:Ue&&v(S.normalMap.channel),displacementMapUv:_t&&v(S.displacementMap.channel),emissiveMapUv:nt&&v(S.emissiveMap.channel),metalnessMapUv:B&&v(S.metalnessMap.channel),roughnessMapUv:N&&v(S.roughnessMap.channel),anisotropyMapUv:we&&v(S.anisotropyMap.channel),clearcoatMapUv:Ne&&v(S.clearcoatMap.channel),clearcoatNormalMapUv:je&&v(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Qe&&v(S.clearcoatRoughnessMap.channel),iridescenceMapUv:me&&v(S.iridescenceMap.channel),iridescenceThicknessMapUv:ft&&v(S.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&v(S.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&v(S.sheenRoughnessMap.channel),specularMapUv:Pe&&v(S.specularMap.channel),specularColorMapUv:Ce&&v(S.specularColorMap.channel),specularIntensityMapUv:H&&v(S.specularIntensityMap.channel),transmissionMapUv:fe&&v(S.transmissionMap.channel),thicknessMapUv:Re&&v(S.thicknessMap.channel),alphaMapUv:ee&&v(S.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Ue||se),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,vertexUv1s:Ze,vertexUv2s:Xe,vertexUv3s:at,pointsUvs:V.isPoints===!0&&!!z.attributes.uv&&(He||ee),fog:!!P,useFog:S.fog===!0,fogExp2:P&&P.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:V.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:ce,morphTextureStride:he,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&F.length>0,shadowMapType:r.shadowMap.type,toneMapping:ot,useLegacyLights:r._useLegacyLights,decodeVideoTexture:He&&S.map.isVideoTexture===!0&&xt.getTransfer(S.map.colorSpace)===Ct,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===wt,flipSided:S.side===on,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:Ae&&S.extensions.derivatives===!0,extensionFragDepth:Ae&&S.extensions.fragDepth===!0,extensionDrawBuffers:Ae&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ae&&S.extensions.shaderTextureLOD===!0,extensionClipCullDistance:Ae&&S.extensions.clipCullDistance&&n.has(\"WEBGL_clip_cull_distance\"),rendererExtensionFragDepth:u||n.has(\"EXT_frag_depth\"),rendererExtensionDrawBuffers:u||n.has(\"WEBGL_draw_buffers\"),rendererExtensionShaderTextureLod:u||n.has(\"EXT_shader_texture_lod\"),rendererExtensionParallelShaderCompile:n.has(\"KHR_parallel_shader_compile\"),customProgramCacheKey:S.customProgramCacheKey()}}function p(S){const R=[];if(S.shaderID?R.push(S.shaderID):(R.push(S.customVertexShaderID),R.push(S.customFragmentShaderID)),S.defines!==void 0)for(const F in S.defines)R.push(F),R.push(S.defines[F]);return S.isRawShaderMaterial===!1&&(_(R,S),b(R,S),R.push(r.outputColorSpace)),R.push(S.customProgramCacheKey),R.join()}function _(S,R){S.push(R.precision),S.push(R.outputColorSpace),S.push(R.envMapMode),S.push(R.envMapCubeUVHeight),S.push(R.mapUv),S.push(R.alphaMapUv),S.push(R.lightMapUv),S.push(R.aoMapUv),S.push(R.bumpMapUv),S.push(R.normalMapUv),S.push(R.displacementMapUv),S.push(R.emissiveMapUv),S.push(R.metalnessMapUv),S.push(R.roughnessMapUv),S.push(R.anisotropyMapUv),S.push(R.clearcoatMapUv),S.push(R.clearcoatNormalMapUv),S.push(R.clearcoatRoughnessMapUv),S.push(R.iridescenceMapUv),S.push(R.iridescenceThicknessMapUv),S.push(R.sheenColorMapUv),S.push(R.sheenRoughnessMapUv),S.push(R.specularMapUv),S.push(R.specularColorMapUv),S.push(R.specularIntensityMapUv),S.push(R.transmissionMapUv),S.push(R.thicknessMapUv),S.push(R.combine),S.push(R.fogExp2),S.push(R.sizeAttenuation),S.push(R.morphTargetsCount),S.push(R.morphAttributeCount),S.push(R.numDirLights),S.push(R.numPointLights),S.push(R.numSpotLights),S.push(R.numSpotLightMaps),S.push(R.numHemiLights),S.push(R.numRectAreaLights),S.push(R.numDirLightShadows),S.push(R.numPointLightShadows),S.push(R.numSpotLightShadows),S.push(R.numSpotLightShadowsWithMaps),S.push(R.numLightProbes),S.push(R.shadowMapType),S.push(R.toneMapping),S.push(R.numClippingPlanes),S.push(R.numClipIntersection),S.push(R.depthPacking)}function b(S,R){o.disableAll(),R.isWebGL2&&o.enable(0),R.supportsVertexTextures&&o.enable(1),R.instancing&&o.enable(2),R.instancingColor&&o.enable(3),R.matcap&&o.enable(4),R.envMap&&o.enable(5),R.normalMapObjectSpace&&o.enable(6),R.normalMapTangentSpace&&o.enable(7),R.clearcoat&&o.enable(8),R.iridescence&&o.enable(9),R.alphaTest&&o.enable(10),R.vertexColors&&o.enable(11),R.vertexAlphas&&o.enable(12),R.vertexUv1s&&o.enable(13),R.vertexUv2s&&o.enable(14),R.vertexUv3s&&o.enable(15),R.vertexTangents&&o.enable(16),R.anisotropy&&o.enable(17),R.alphaHash&&o.enable(18),R.batching&&o.enable(19),S.push(o.mask),o.disableAll(),R.fog&&o.enable(0),R.useFog&&o.enable(1),R.flatShading&&o.enable(2),R.logarithmicDepthBuffer&&o.enable(3),R.skinning&&o.enable(4),R.morphTargets&&o.enable(5),R.morphNormals&&o.enable(6),R.morphColors&&o.enable(7),R.premultipliedAlpha&&o.enable(8),R.shadowMapEnabled&&o.enable(9),R.useLegacyLights&&o.enable(10),R.doubleSided&&o.enable(11),R.flipSided&&o.enable(12),R.useDepthPacking&&o.enable(13),R.dithering&&o.enable(14),R.transmission&&o.enable(15),R.sheen&&o.enable(16),R.opaque&&o.enable(17),R.pointsUvs&&o.enable(18),R.decodeVideoTexture&&o.enable(19),S.push(o.mask)}function x(S){const R=g[S.type];let F;if(R){const U=ei[R];F=im.clone(U.uniforms)}else F=S.uniforms;return F}function E(S,R){let F;for(let U=0,V=l.length;U<V;U++){const P=l[U];if(P.cacheKey===R){F=P,++F.usedTimes;break}}return F===void 0&&(F=new Ub(r,R,S,s),l.push(F)),F}function T(S){if(--S.usedTimes===0){const R=l.indexOf(S);l[R]=l[l.length-1],l.pop(),S.destroy()}}function A(S){c.remove(S)}function I(){c.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:x,acquireProgram:E,releaseProgram:T,releaseShaderCache:A,programs:l,dispose:I}}function zb(){let r=new WeakMap;function e(s){let a=r.get(s);return a===void 0&&(a={},r.set(s,a)),a}function t(s){r.delete(s)}function n(s,a,o){r.get(s)[a]=o}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function Gb(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function wd(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Ad(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(d,h,f,g,v,m){let p=r[e];return p===void 0?(p={id:d.id,object:d,geometry:h,material:f,groupOrder:g,renderOrder:d.renderOrder,z:v,group:m},r[e]=p):(p.id=d.id,p.object=d,p.geometry=h,p.material=f,p.groupOrder=g,p.renderOrder=d.renderOrder,p.z=v,p.group=m),e++,p}function o(d,h,f,g,v,m){const p=a(d,h,f,g,v,m);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):t.push(p)}function c(d,h,f,g,v,m){const p=a(d,h,f,g,v,m);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):t.unshift(p)}function l(d,h){t.length>1&&t.sort(d||Gb),n.length>1&&n.sort(h||wd),i.length>1&&i.sort(h||wd)}function u(){for(let d=e,h=r.length;d<h;d++){const f=r[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:c,finish:u,sort:l}}function Hb(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new Ad,r.set(n,[a])):i>=s.length?(a=new Ad,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function Vb(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case\"DirectionalLight\":t={direction:new O,color:new Be};break;case\"SpotLight\":t={position:new O,direction:new O,color:new Be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case\"PointLight\":t={position:new O,color:new Be,distance:0,decay:0};break;case\"HemisphereLight\":t={direction:new O,skyColor:new Be,groundColor:new Be};break;case\"RectAreaLight\":t={color:new Be,position:new O,halfWidth:new O,halfHeight:new O};break}return r[e.id]=t,t}}}function Wb(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case\"DirectionalLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case\"SpotLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case\"PointLight\":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let jb=0;function Xb(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function qb(r,e){const t=new Vb,n=Wb(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new O);const s=new O,a=new qe,o=new qe;function c(u,d){let h=0,f=0,g=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let v=0,m=0,p=0,_=0,b=0,x=0,E=0,T=0,A=0,I=0,S=0;u.sort(Xb);const R=d===!0?Math.PI:1;for(let U=0,V=u.length;U<V;U++){const P=u[U],z=P.color,X=P.intensity,re=P.distance,J=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=z.r*X*R,f+=z.g*X*R,g+=z.b*X*R;else if(P.isLightProbe){for(let te=0;te<9;te++)i.probe[te].addScaledVector(P.sh.coefficients[te],X);S++}else if(P.isDirectionalLight){const te=t.get(P);if(te.color.copy(P.color).multiplyScalar(P.intensity*R),P.castShadow){const Q=P.shadow,ce=n.get(P);ce.shadowBias=Q.bias,ce.shadowNormalBias=Q.normalBias,ce.shadowRadius=Q.radius,ce.shadowMapSize=Q.mapSize,i.directionalShadow[v]=ce,i.directionalShadowMap[v]=J,i.directionalShadowMatrix[v]=P.shadow.matrix,x++}i.directional[v]=te,v++}else if(P.isSpotLight){const te=t.get(P);te.position.setFromMatrixPosition(P.matrixWorld),te.color.copy(z).multiplyScalar(X*R),te.distance=re,te.coneCos=Math.cos(P.angle),te.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),te.decay=P.decay,i.spot[p]=te;const Q=P.shadow;if(P.map&&(i.spotLightMap[A]=P.map,A++,Q.updateMatrices(P),P.castShadow&&I++),i.spotLightMatrix[p]=Q.matrix,P.castShadow){const ce=n.get(P);ce.shadowBias=Q.bias,ce.shadowNormalBias=Q.normalBias,ce.shadowRadius=Q.radius,ce.shadowMapSize=Q.mapSize,i.spotShadow[p]=ce,i.spotShadowMap[p]=J,T++}p++}else if(P.isRectAreaLight){const te=t.get(P);te.color.copy(z).multiplyScalar(X),te.halfWidth.set(P.width*.5,0,0),te.halfHeight.set(0,P.height*.5,0),i.rectArea[_]=te,_++}else if(P.isPointLight){const te=t.get(P);if(te.color.copy(P.color).multiplyScalar(P.intensity*R),te.distance=P.distance,te.decay=P.decay,P.castShadow){const Q=P.shadow,ce=n.get(P);ce.shadowBias=Q.bias,ce.shadowNormalBias=Q.normalBias,ce.shadowRadius=Q.radius,ce.shadowMapSize=Q.mapSize,ce.shadowCameraNear=Q.camera.near,ce.shadowCameraFar=Q.camera.far,i.pointShadow[m]=ce,i.pointShadowMap[m]=J,i.pointShadowMatrix[m]=P.shadow.matrix,E++}i.point[m]=te,m++}else if(P.isHemisphereLight){const te=t.get(P);te.skyColor.copy(P.color).multiplyScalar(X*R),te.groundColor.copy(P.groundColor).multiplyScalar(X*R),i.hemi[b]=te,b++}}_>0&&(e.isWebGL2?r.has(\"OES_texture_float_linear\")===!0?(i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2):(i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2):r.has(\"OES_texture_float_linear\")===!0?(i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2):r.has(\"OES_texture_half_float_linear\")===!0?(i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2):console.error(\"THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.\")),i.ambient[0]=h,i.ambient[1]=f,i.ambient[2]=g;const F=i.hash;(F.directionalLength!==v||F.pointLength!==m||F.spotLength!==p||F.rectAreaLength!==_||F.hemiLength!==b||F.numDirectionalShadows!==x||F.numPointShadows!==E||F.numSpotShadows!==T||F.numSpotMaps!==A||F.numLightProbes!==S)&&(i.directional.length=v,i.spot.length=p,i.rectArea.length=_,i.point.length=m,i.hemi.length=b,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=T,i.spotShadowMap.length=T,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=T+A-I,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=S,F.directionalLength=v,F.pointLength=m,F.spotLength=p,F.rectAreaLength=_,F.hemiLength=b,F.numDirectionalShadows=x,F.numPointShadows=E,F.numSpotShadows=T,F.numSpotMaps=A,F.numLightProbes=S,i.version=jb++)}function l(u,d){let h=0,f=0,g=0,v=0,m=0;const p=d.matrixWorldInverse;for(let _=0,b=u.length;_<b;_++){const x=u[_];if(x.isDirectionalLight){const E=i.directional[h];E.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),h++}else if(x.isSpotLight){const E=i.spot[g];E.position.setFromMatrixPosition(x.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),g++}else if(x.isRectAreaLight){const E=i.rectArea[v];E.position.setFromMatrixPosition(x.matrixWorld),E.position.applyMatrix4(p),o.identity(),a.copy(x.matrixWorld),a.premultiply(p),o.extractRotation(a),E.halfWidth.set(x.width*.5,0,0),E.halfHeight.set(0,x.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),v++}else if(x.isPointLight){const E=i.point[f];E.position.setFromMatrixPosition(x.matrixWorld),E.position.applyMatrix4(p),f++}else if(x.isHemisphereLight){const E=i.hemi[m];E.direction.setFromMatrixPosition(x.matrixWorld),E.direction.transformDirection(p),m++}}}return{setup:c,setupView:l,state:i}}function Rd(r,e){const t=new qb(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function a(d){n.push(d)}function o(d){i.push(d)}function c(d){t.setup(n,d)}function l(d){t.setupView(n,d)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Yb(r,e){let t=new WeakMap;function n(s,a=0){const o=t.get(s);let c;return o===void 0?(c=new Rd(r,e),t.set(s,[c])):a>=o.length?(c=new Rd(r,e),o.push(c)):c=o[a],c}function i(){t=new WeakMap}return{get:n,dispose:i}}class Kb extends Rn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=\"MeshDepthMaterial\",this.depthPacking=hp,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 Zb extends Rn{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}}const $b=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Jb=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`;function Qb(r,e,t){let n=new oc;const i=new Ve,s=new Ve,a=new Tt,o=new Kb({depthPacking:fp}),c=new Zb,l={},u=t.maxTextureSize,d={[Mn]:on,[on]:Mn,[wt]:wt},h=new qn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:$b,fragmentShader:Jb}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const g=new mn;g.setAttribute(\"position\",new vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Bl;let p=this.type;this.render=function(T,A,I){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const S=r.getRenderTarget(),R=r.getActiveCubeFace(),F=r.getActiveMipmapLevel(),U=r.state;U.setBlending(ii),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const V=p!==ni&&this.type===ni,P=p===ni&&this.type!==ni;for(let z=0,X=T.length;z<X;z++){const re=T[z],J=re.shadow;if(J===void 0){console.warn(\"THREE.WebGLShadowMap:\",re,\"has no shadow.\");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const te=J.getFrameExtents();if(i.multiply(te),s.copy(J.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/te.x),i.x=s.x*te.x,J.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/te.y),i.y=s.y*te.y,J.mapSize.y=s.y)),J.map===null||V===!0||P===!0){const ce=this.type!==ni?{minFilter:yt,magFilter:yt}:{};J.map!==null&&J.map.dispose(),J.map=new Ki(i.x,i.y,ce),J.map.texture.name=re.name+\".shadowMap\",J.camera.updateProjectionMatrix()}r.setRenderTarget(J.map),r.clear();const Q=J.getViewportCount();for(let ce=0;ce<Q;ce++){const he=J.getViewport(ce);a.set(s.x*he.x,s.y*he.y,s.x*he.z,s.y*he.w),U.viewport(a),J.updateMatrices(re,ce),n=J.getFrustum(),x(A,I,J.camera,re,this.type)}J.isPointLightShadow!==!0&&this.type===ni&&_(J,I),J.needsUpdate=!1}p=this.type,m.needsUpdate=!1,r.setRenderTarget(S,R,F)};function _(T,A){const I=e.update(v);h.defines.VSM_SAMPLES!==T.blurSamples&&(h.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Ki(i.x,i.y)),h.uniforms.shadow_pass.value=T.map.texture,h.uniforms.resolution.value=T.mapSize,h.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(A,null,I,h,v,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(A,null,I,f,v,null)}function b(T,A,I,S){let R=null;const F=I.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(F!==void 0)R=F;else if(R=I.isPointLight===!0?c:o,r.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const U=R.uuid,V=A.uuid;let P=l[U];P===void 0&&(P={},l[U]=P);let z=P[V];z===void 0&&(z=R.clone(),P[V]=z,A.addEventListener(\"dispose\",E)),R=z}if(R.visible=A.visible,R.wireframe=A.wireframe,S===ni?R.side=A.shadowSide!==null?A.shadowSide:A.side:R.side=A.shadowSide!==null?A.shadowSide:d[A.side],R.alphaMap=A.alphaMap,R.alphaTest=A.alphaTest,R.map=A.map,R.clipShadows=A.clipShadows,R.clippingPlanes=A.clippingPlanes,R.clipIntersection=A.clipIntersection,R.displacementMap=A.displacementMap,R.displacementScale=A.displacementScale,R.displacementBias=A.displacementBias,R.wireframeLinewidth=A.wireframeLinewidth,R.linewidth=A.linewidth,I.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const U=r.properties.get(R);U.light=I}return R}function x(T,A,I,S,R){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&R===ni)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const V=e.update(T),P=T.material;if(Array.isArray(P)){const z=V.groups;for(let X=0,re=z.length;X<re;X++){const J=z[X],te=P[J.materialIndex];if(te&&te.visible){const Q=b(T,te,S,R);T.onBeforeShadow(r,T,A,I,V,Q,J),r.renderBufferDirect(I,null,V,Q,T,J),T.onAfterShadow(r,T,A,I,V,Q,J)}}}else if(P.visible){const z=b(T,P,S,R);T.onBeforeShadow(r,T,A,I,V,z,null),r.renderBufferDirect(I,null,V,z,T,null),T.onAfterShadow(r,T,A,I,V,z,null)}}const U=T.children;for(let V=0,P=U.length;V<P;V++)x(U[V],A,I,S,R)}function E(T){T.target.removeEventListener(\"dispose\",E);for(const I in l){const S=l[I],R=T.target.uuid;R in S&&(S[R].dispose(),delete S[R])}}}function e_(r,e,t){const n=t.isWebGL2;function i(){let j=!1;const ye=new Tt;let Ae=null;const Ze=new Tt(0,0,0,0);return{setMask:function(Xe){Ae!==Xe&&!j&&(r.colorMask(Xe,Xe,Xe,Xe),Ae=Xe)},setLocked:function(Xe){j=Xe},setClear:function(Xe,at,ot,Rt,Dt){Dt===!0&&(Xe*=Rt,at*=Rt,ot*=Rt),ye.set(Xe,at,ot,Rt),Ze.equals(ye)===!1&&(r.clearColor(Xe,at,ot,Rt),Ze.copy(ye))},reset:function(){j=!1,Ae=null,Ze.set(-1,0,0,0)}}}function s(){let j=!1,ye=null,Ae=null,Ze=null;return{setTest:function(Xe){Xe?Ke(r.DEPTH_TEST):He(r.DEPTH_TEST)},setMask:function(Xe){ye!==Xe&&!j&&(r.depthMask(Xe),ye=Xe)},setFunc:function(Xe){if(Ae!==Xe){switch(Xe){case jf:r.depthFunc(r.NEVER);break;case Xf:r.depthFunc(r.ALWAYS);break;case qf:r.depthFunc(r.LESS);break;case Xs:r.depthFunc(r.LEQUAL);break;case Yf:r.depthFunc(r.EQUAL);break;case Kf:r.depthFunc(r.GEQUAL);break;case Zf:r.depthFunc(r.GREATER);break;case $f:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Ae=Xe}},setLocked:function(Xe){j=Xe},setClear:function(Xe){Ze!==Xe&&(r.clearDepth(Xe),Ze=Xe)},reset:function(){j=!1,ye=null,Ae=null,Ze=null}}}function a(){let j=!1,ye=null,Ae=null,Ze=null,Xe=null,at=null,ot=null,Rt=null,Dt=null;return{setTest:function(pt){j||(pt?Ke(r.STENCIL_TEST):He(r.STENCIL_TEST))},setMask:function(pt){ye!==pt&&!j&&(r.stencilMask(pt),ye=pt)},setFunc:function(pt,Ut,En){(Ae!==pt||Ze!==Ut||Xe!==En)&&(r.stencilFunc(pt,Ut,En),Ae=pt,Ze=Ut,Xe=En)},setOp:function(pt,Ut,En){(at!==pt||ot!==Ut||Rt!==En)&&(r.stencilOp(pt,Ut,En),at=pt,ot=Ut,Rt=En)},setLocked:function(pt){j=pt},setClear:function(pt){Dt!==pt&&(r.clearStencil(pt),Dt=pt)},reset:function(){j=!1,ye=null,Ae=null,Ze=null,Xe=null,at=null,ot=null,Rt=null,Dt=null}}}const o=new i,c=new s,l=new a,u=new WeakMap,d=new WeakMap;let h={},f={},g=new WeakMap,v=[],m=null,p=!1,_=null,b=null,x=null,E=null,T=null,A=null,I=null,S=new Be(0,0,0),R=0,F=!1,U=null,V=null,P=null,z=null,X=null;const re=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,te=0;const Q=r.getParameter(r.VERSION);Q.indexOf(\"WebGL\")!==-1?(te=parseFloat(/^WebGL (\\d)/.exec(Q)[1]),J=te>=1):Q.indexOf(\"OpenGL ES\")!==-1&&(te=parseFloat(/^OpenGL ES (\\d)/.exec(Q)[1]),J=te>=2);let ce=null,he={};const $=r.getParameter(r.SCISSOR_BOX),ue=r.getParameter(r.VIEWPORT),Me=new Tt().fromArray($),xe=new Tt().fromArray(ue);function ge(j,ye,Ae,Ze){const Xe=new Uint8Array(4),at=r.createTexture();r.bindTexture(j,at),r.texParameteri(j,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(j,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let ot=0;ot<Ae;ot++)n&&(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)?r.texImage3D(ye,0,r.RGBA,1,1,Ze,0,r.RGBA,r.UNSIGNED_BYTE,Xe):r.texImage2D(ye+ot,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Xe);return at}const Ge={};Ge[r.TEXTURE_2D]=ge(r.TEXTURE_2D,r.TEXTURE_2D,1),Ge[r.TEXTURE_CUBE_MAP]=ge(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(Ge[r.TEXTURE_2D_ARRAY]=ge(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),Ge[r.TEXTURE_3D]=ge(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),l.setClear(0),Ke(r.DEPTH_TEST),c.setFunc(Xs),nt(!1),B(Ol),Ke(r.CULL_FACE),Ue(ii);function Ke(j){h[j]!==!0&&(r.enable(j),h[j]=!0)}function He(j){h[j]!==!1&&(r.disable(j),h[j]=!1)}function tt(j,ye){return f[j]!==ye?(r.bindFramebuffer(j,ye),f[j]=ye,n&&(j===r.DRAW_FRAMEBUFFER&&(f[r.FRAMEBUFFER]=ye),j===r.FRAMEBUFFER&&(f[r.DRAW_FRAMEBUFFER]=ye)),!0):!1}function W(j,ye){let Ae=v,Ze=!1;if(j)if(Ae=g.get(ye),Ae===void 0&&(Ae=[],g.set(ye,Ae)),j.isWebGLMultipleRenderTargets){const Xe=j.texture;if(Ae.length!==Xe.length||Ae[0]!==r.COLOR_ATTACHMENT0){for(let at=0,ot=Xe.length;at<ot;at++)Ae[at]=r.COLOR_ATTACHMENT0+at;Ae.length=Xe.length,Ze=!0}}else Ae[0]!==r.COLOR_ATTACHMENT0&&(Ae[0]=r.COLOR_ATTACHMENT0,Ze=!0);else Ae[0]!==r.BACK&&(Ae[0]=r.BACK,Ze=!0);Ze&&(t.isWebGL2?r.drawBuffers(Ae):e.get(\"WEBGL_draw_buffers\").drawBuffersWEBGL(Ae))}function ze(j){return m!==j?(r.useProgram(j),m=j,!0):!1}const Le={[Vi]:r.FUNC_ADD,[Pf]:r.FUNC_SUBTRACT,[Lf]:r.FUNC_REVERSE_SUBTRACT};if(n)Le[Hl]=r.MIN,Le[Vl]=r.MAX;else{const j=e.get(\"EXT_blend_minmax\");j!==null&&(Le[Hl]=j.MIN_EXT,Le[Vl]=j.MAX_EXT)}const Ie={[If]:r.ZERO,[Df]:r.ONE,[Nf]:r.SRC_COLOR,[_o]:r.SRC_ALPHA,[zf]:r.SRC_ALPHA_SATURATE,[Bf]:r.DST_COLOR,[Ff]:r.DST_ALPHA,[Uf]:r.ONE_MINUS_SRC_COLOR,[vo]:r.ONE_MINUS_SRC_ALPHA,[kf]:r.ONE_MINUS_DST_COLOR,[Of]:r.ONE_MINUS_DST_ALPHA,[Gf]:r.CONSTANT_COLOR,[Hf]:r.ONE_MINUS_CONSTANT_COLOR,[Vf]:r.CONSTANT_ALPHA,[Wf]:r.ONE_MINUS_CONSTANT_ALPHA};function Ue(j,ye,Ae,Ze,Xe,at,ot,Rt,Dt,pt){if(j===ii){p===!0&&(He(r.BLEND),p=!1);return}if(p===!1&&(Ke(r.BLEND),p=!0),j!==Cf){if(j!==_||pt!==F){if((b!==Vi||T!==Vi)&&(r.blendEquation(r.FUNC_ADD),b=Vi,T=Vi),pt)switch(j){case fr:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case kl:r.blendFunc(r.ONE,r.ONE);break;case zl:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Gl:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error(\"THREE.WebGLState: Invalid blending: \",j);break}else switch(j){case fr:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case kl:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case zl:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Gl:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error(\"THREE.WebGLState: Invalid blending: \",j);break}x=null,E=null,A=null,I=null,S.set(0,0,0),R=0,_=j,F=pt}return}Xe=Xe||ye,at=at||Ae,ot=ot||Ze,(ye!==b||Xe!==T)&&(r.blendEquationSeparate(Le[ye],Le[Xe]),b=ye,T=Xe),(Ae!==x||Ze!==E||at!==A||ot!==I)&&(r.blendFuncSeparate(Ie[Ae],Ie[Ze],Ie[at],Ie[ot]),x=Ae,E=Ze,A=at,I=ot),(Rt.equals(S)===!1||Dt!==R)&&(r.blendColor(Rt.r,Rt.g,Rt.b,Dt),S.copy(Rt),R=Dt),_=j,F=!1}function _t(j,ye){j.side===wt?He(r.CULL_FACE):Ke(r.CULL_FACE);let Ae=j.side===on;ye&&(Ae=!Ae),nt(Ae),j.blending===fr&&j.transparent===!1?Ue(ii):Ue(j.blending,j.blendEquation,j.blendSrc,j.blendDst,j.blendEquationAlpha,j.blendSrcAlpha,j.blendDstAlpha,j.blendColor,j.blendAlpha,j.premultipliedAlpha),c.setFunc(j.depthFunc),c.setTest(j.depthTest),c.setMask(j.depthWrite),o.setMask(j.colorWrite);const Ze=j.stencilWrite;l.setTest(Ze),Ze&&(l.setMask(j.stencilWriteMask),l.setFunc(j.stencilFunc,j.stencilRef,j.stencilFuncMask),l.setOp(j.stencilFail,j.stencilZFail,j.stencilZPass)),se(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits),j.alphaToCoverage===!0?Ke(r.SAMPLE_ALPHA_TO_COVERAGE):He(r.SAMPLE_ALPHA_TO_COVERAGE)}function nt(j){U!==j&&(j?r.frontFace(r.CW):r.frontFace(r.CCW),U=j)}function B(j){j!==wf?(Ke(r.CULL_FACE),j!==V&&(j===Ol?r.cullFace(r.BACK):j===Af?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):He(r.CULL_FACE),V=j}function N(j){j!==P&&(J&&r.lineWidth(j),P=j)}function se(j,ye,Ae){j?(Ke(r.POLYGON_OFFSET_FILL),(z!==ye||X!==Ae)&&(r.polygonOffset(ye,Ae),z=ye,X=Ae)):He(r.POLYGON_OFFSET_FILL)}function _e(j){j?Ke(r.SCISSOR_TEST):He(r.SCISSOR_TEST)}function pe(j){j===void 0&&(j=r.TEXTURE0+re-1),ce!==j&&(r.activeTexture(j),ce=j)}function ve(j,ye,Ae){Ae===void 0&&(ce===null?Ae=r.TEXTURE0+re-1:Ae=ce);let Ze=he[Ae];Ze===void 0&&(Ze={type:void 0,texture:void 0},he[Ae]=Ze),(Ze.type!==j||Ze.texture!==ye)&&(ce!==Ae&&(r.activeTexture(Ae),ce=Ae),r.bindTexture(j,ye||Ge[j]),Ze.type=j,Ze.texture=ye)}function Fe(){const j=he[ce];j!==void 0&&j.type!==void 0&&(r.bindTexture(j.type,null),j.type=void 0,j.texture=void 0)}function we(){try{r.compressedTexImage2D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function Ne(){try{r.compressedTexImage3D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function je(){try{r.texSubImage2D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function Qe(){try{r.texSubImage3D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function me(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function ft(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function rt(){try{r.texStorage2D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function Ye(){try{r.texStorage3D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function Pe(){try{r.texImage2D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function Ce(){try{r.texImage3D.apply(r,arguments)}catch(j){console.error(\"THREE.WebGLState:\",j)}}function H(j){Me.equals(j)===!1&&(r.scissor(j.x,j.y,j.z,j.w),Me.copy(j))}function fe(j){xe.equals(j)===!1&&(r.viewport(j.x,j.y,j.z,j.w),xe.copy(j))}function Re(j,ye){let Ae=d.get(ye);Ae===void 0&&(Ae=new WeakMap,d.set(ye,Ae));let Ze=Ae.get(j);Ze===void 0&&(Ze=r.getUniformBlockIndex(ye,j.name),Ae.set(j,Ze))}function De(j,ye){const Ze=d.get(ye).get(j);u.get(ye)!==Ze&&(r.uniformBlockBinding(ye,Ze,j.__bindingPointIndex),u.set(ye,Ze))}function ee(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},ce=null,he={},f={},g=new WeakMap,v=[],m=null,p=!1,_=null,b=null,x=null,E=null,T=null,A=null,I=null,S=new Be(0,0,0),R=0,F=!1,U=null,V=null,P=null,z=null,X=null,Me.set(0,0,r.canvas.width,r.canvas.height),xe.set(0,0,r.canvas.width,r.canvas.height),o.reset(),c.reset(),l.reset()}return{buffers:{color:o,depth:c,stencil:l},enable:Ke,disable:He,bindFramebuffer:tt,drawBuffers:W,useProgram:ze,setBlending:Ue,setMaterial:_t,setFlipSided:nt,setCullFace:B,setLineWidth:N,setPolygonOffset:se,setScissorTest:_e,activeTexture:pe,bindTexture:ve,unbindTexture:Fe,compressedTexImage2D:we,compressedTexImage3D:Ne,texImage2D:Pe,texImage3D:Ce,updateUBOMapping:Re,uniformBlockBinding:De,texStorage2D:rt,texStorage3D:Ye,texSubImage2D:je,texSubImage3D:Qe,compressedTexSubImage2D:me,compressedTexSubImage3D:ft,scissor:H,viewport:fe,reset:ee}}function t_(r,e,t,n,i,s,a){const o=i.isWebGL2,c=e.has(\"WEBGL_multisampled_render_to_texture\")?e.get(\"WEBGL_multisampled_render_to_texture\"):null,l=typeof navigator>\"u\"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new WeakMap;let d;const h=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<\"u\"&&new OffscreenCanvas(1,1).getContext(\"2d\")!==null}catch{}function g(B,N){return f?new OffscreenCanvas(B,N):_s(\"canvas\")}function v(B,N,se,_e){let pe=1;if((B.width>_e||B.height>_e)&&(pe=_e/Math.max(B.width,B.height)),pe<1||N===!0)if(typeof HTMLImageElement<\"u\"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<\"u\"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<\"u\"&&B instanceof ImageBitmap){const ve=N?ia:Math.floor,Fe=ve(pe*B.width),we=ve(pe*B.height);d===void 0&&(d=g(Fe,we));const Ne=se?g(Fe,we):d;return Ne.width=Fe,Ne.height=we,Ne.getContext(\"2d\").drawImage(B,0,0,Fe,we),console.warn(\"THREE.WebGLRenderer: Texture has been resized from (\"+B.width+\"x\"+B.height+\") to (\"+Fe+\"x\"+we+\").\"),Ne}else return\"data\"in B&&console.warn(\"THREE.WebGLRenderer: Image in DataTexture is too big (\"+B.width+\"x\"+B.height+\").\"),B;return B}function m(B){return ko(B.width)&&ko(B.height)}function p(B){return o?!1:B.wrapS!==gn||B.wrapT!==gn||B.minFilter!==yt&&B.minFilter!==At}function _(B,N){return B.generateMipmaps&&N&&B.minFilter!==yt&&B.minFilter!==At}function b(B){r.generateMipmap(B)}function x(B,N,se,_e,pe=!1){if(o===!1)return N;if(B!==null){if(r[B]!==void 0)return r[B];console.warn(\"THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '\"+B+\"'\")}let ve=N;if(N===r.RED&&(se===r.FLOAT&&(ve=r.R32F),se===r.HALF_FLOAT&&(ve=r.R16F),se===r.UNSIGNED_BYTE&&(ve=r.R8)),N===r.RED_INTEGER&&(se===r.UNSIGNED_BYTE&&(ve=r.R8UI),se===r.UNSIGNED_SHORT&&(ve=r.R16UI),se===r.UNSIGNED_INT&&(ve=r.R32UI),se===r.BYTE&&(ve=r.R8I),se===r.SHORT&&(ve=r.R16I),se===r.INT&&(ve=r.R32I)),N===r.RG&&(se===r.FLOAT&&(ve=r.RG32F),se===r.HALF_FLOAT&&(ve=r.RG16F),se===r.UNSIGNED_BYTE&&(ve=r.RG8)),N===r.RGBA){const Fe=pe?Js:xt.getTransfer(_e);se===r.FLOAT&&(ve=r.RGBA32F),se===r.HALF_FLOAT&&(ve=r.RGBA16F),se===r.UNSIGNED_BYTE&&(ve=Fe===Ct?r.SRGB8_ALPHA8:r.RGBA8),se===r.UNSIGNED_SHORT_4_4_4_4&&(ve=r.RGBA4),se===r.UNSIGNED_SHORT_5_5_5_1&&(ve=r.RGB5_A1)}return(ve===r.R16F||ve===r.R32F||ve===r.RG16F||ve===r.RG32F||ve===r.RGBA16F||ve===r.RGBA32F)&&e.get(\"EXT_color_buffer_float\"),ve}function E(B,N,se){return _(B,se)===!0||B.isFramebufferTexture&&B.minFilter!==yt&&B.minFilter!==At?Math.log2(Math.max(N.width,N.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?N.mipmaps.length:1}function T(B){return B===yt||B===Ys||B===fs?r.NEAREST:r.LINEAR}function A(B){const N=B.target;N.removeEventListener(\"dispose\",A),S(N),N.isVideoTexture&&u.delete(N)}function I(B){const N=B.target;N.removeEventListener(\"dispose\",I),F(N)}function S(B){const N=n.get(B);if(N.__webglInit===void 0)return;const se=B.source,_e=h.get(se);if(_e){const pe=_e[N.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&R(B),Object.keys(_e).length===0&&h.delete(se)}n.remove(B)}function R(B){const N=n.get(B);r.deleteTexture(N.__webglTexture);const se=B.source,_e=h.get(se);delete _e[N.__cacheKey],a.memory.textures--}function F(B){const N=B.texture,se=n.get(B),_e=n.get(N);if(_e.__webglTexture!==void 0&&(r.deleteTexture(_e.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(se.__webglFramebuffer[pe]))for(let ve=0;ve<se.__webglFramebuffer[pe].length;ve++)r.deleteFramebuffer(se.__webglFramebuffer[pe][ve]);else r.deleteFramebuffer(se.__webglFramebuffer[pe]);se.__webglDepthbuffer&&r.deleteRenderbuffer(se.__webglDepthbuffer[pe])}else{if(Array.isArray(se.__webglFramebuffer))for(let pe=0;pe<se.__webglFramebuffer.length;pe++)r.deleteFramebuffer(se.__webglFramebuffer[pe]);else r.deleteFramebuffer(se.__webglFramebuffer);if(se.__webglDepthbuffer&&r.deleteRenderbuffer(se.__webglDepthbuffer),se.__webglMultisampledFramebuffer&&r.deleteFramebuffer(se.__webglMultisampledFramebuffer),se.__webglColorRenderbuffer)for(let pe=0;pe<se.__webglColorRenderbuffer.length;pe++)se.__webglColorRenderbuffer[pe]&&r.deleteRenderbuffer(se.__webglColorRenderbuffer[pe]);se.__webglDepthRenderbuffer&&r.deleteRenderbuffer(se.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let pe=0,ve=N.length;pe<ve;pe++){const Fe=n.get(N[pe]);Fe.__webglTexture&&(r.deleteTexture(Fe.__webglTexture),a.memory.textures--),n.remove(N[pe])}n.remove(N),n.remove(B)}let U=0;function V(){U=0}function P(){const B=U;return B>=i.maxTextures&&console.warn(\"THREE.WebGLTextures: Trying to use \"+B+\" texture units while this GPU supports only \"+i.maxTextures),U+=1,B}function z(B){const N=[];return N.push(B.wrapS),N.push(B.wrapT),N.push(B.wrapR||0),N.push(B.magFilter),N.push(B.minFilter),N.push(B.anisotropy),N.push(B.internalFormat),N.push(B.format),N.push(B.type),N.push(B.generateMipmaps),N.push(B.premultiplyAlpha),N.push(B.flipY),N.push(B.unpackAlignment),N.push(B.colorSpace),N.join()}function X(B,N){const se=n.get(B);if(B.isVideoTexture&&_t(B),B.isRenderTargetTexture===!1&&B.version>0&&se.__version!==B.version){const _e=B.image;if(_e===null)console.warn(\"THREE.WebGLRenderer: Texture marked for update but no image data found.\");else if(_e.complete===!1)console.warn(\"THREE.WebGLRenderer: Texture marked for update but image is incomplete\");else{Me(se,B,N);return}}t.bindTexture(r.TEXTURE_2D,se.__webglTexture,r.TEXTURE0+N)}function re(B,N){const se=n.get(B);if(B.version>0&&se.__version!==B.version){Me(se,B,N);return}t.bindTexture(r.TEXTURE_2D_ARRAY,se.__webglTexture,r.TEXTURE0+N)}function J(B,N){const se=n.get(B);if(B.version>0&&se.__version!==B.version){Me(se,B,N);return}t.bindTexture(r.TEXTURE_3D,se.__webglTexture,r.TEXTURE0+N)}function te(B,N){const se=n.get(B);if(B.version>0&&se.__version!==B.version){xe(se,B,N);return}t.bindTexture(r.TEXTURE_CUBE_MAP,se.__webglTexture,r.TEXTURE0+N)}const Q={[Si]:r.REPEAT,[gn]:r.CLAMP_TO_EDGE,[hs]:r.MIRRORED_REPEAT},ce={[yt]:r.NEAREST,[Ys]:r.NEAREST_MIPMAP_NEAREST,[fs]:r.NEAREST_MIPMAP_LINEAR,[At]:r.LINEAR,[So]:r.LINEAR_MIPMAP_NEAREST,[si]:r.LINEAR_MIPMAP_LINEAR},he={[mp]:r.NEVER,[yp]:r.ALWAYS,[gp]:r.LESS,[Cu]:r.LEQUAL,[bp]:r.EQUAL,[xp]:r.GEQUAL,[_p]:r.GREATER,[vp]:r.NOTEQUAL};function $(B,N,se){if(se?(r.texParameteri(B,r.TEXTURE_WRAP_S,Q[N.wrapS]),r.texParameteri(B,r.TEXTURE_WRAP_T,Q[N.wrapT]),(B===r.TEXTURE_3D||B===r.TEXTURE_2D_ARRAY)&&r.texParameteri(B,r.TEXTURE_WRAP_R,Q[N.wrapR]),r.texParameteri(B,r.TEXTURE_MAG_FILTER,ce[N.magFilter]),r.texParameteri(B,r.TEXTURE_MIN_FILTER,ce[N.minFilter])):(r.texParameteri(B,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(B,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(B===r.TEXTURE_3D||B===r.TEXTURE_2D_ARRAY)&&r.texParameteri(B,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(N.wrapS!==gn||N.wrapT!==gn)&&console.warn(\"THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.\"),r.texParameteri(B,r.TEXTURE_MAG_FILTER,T(N.magFilter)),r.texParameteri(B,r.TEXTURE_MIN_FILTER,T(N.minFilter)),N.minFilter!==yt&&N.minFilter!==At&&console.warn(\"THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.\")),N.compareFunction&&(r.texParameteri(B,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(B,r.TEXTURE_COMPARE_FUNC,he[N.compareFunction])),e.has(\"EXT_texture_filter_anisotropic\")===!0){const _e=e.get(\"EXT_texture_filter_anisotropic\");if(N.magFilter===yt||N.minFilter!==fs&&N.minFilter!==si||N.type===jt&&e.has(\"OES_texture_float_linear\")===!1||o===!1&&N.type===cn&&e.has(\"OES_texture_half_float_linear\")===!1)return;(N.anisotropy>1||n.get(N).__currentAnisotropy)&&(r.texParameterf(B,_e.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(N.anisotropy,i.getMaxAnisotropy())),n.get(N).__currentAnisotropy=N.anisotropy)}}function ue(B,N){let se=!1;B.__webglInit===void 0&&(B.__webglInit=!0,N.addEventListener(\"dispose\",A));const _e=N.source;let pe=h.get(_e);pe===void 0&&(pe={},h.set(_e,pe));const ve=z(N);if(ve!==B.__cacheKey){pe[ve]===void 0&&(pe[ve]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,se=!0),pe[ve].usedTimes++;const Fe=pe[B.__cacheKey];Fe!==void 0&&(pe[B.__cacheKey].usedTimes--,Fe.usedTimes===0&&R(N)),B.__cacheKey=ve,B.__webglTexture=pe[ve].texture}return se}function Me(B,N,se){let _e=r.TEXTURE_2D;(N.isDataArrayTexture||N.isCompressedArrayTexture)&&(_e=r.TEXTURE_2D_ARRAY),N.isData3DTexture&&(_e=r.TEXTURE_3D);const pe=ue(B,N),ve=N.source;t.bindTexture(_e,B.__webglTexture,r.TEXTURE0+se);const Fe=n.get(ve);if(ve.version!==Fe.__version||pe===!0){t.activeTexture(r.TEXTURE0+se);const we=xt.getPrimaries(xt.workingColorSpace),Ne=N.colorSpace===Sn?null:xt.getPrimaries(N.colorSpace),je=N.colorSpace===Sn||we===Ne?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,N.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,N.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,je);const Qe=p(N)&&m(N.image)===!1;let me=v(N.image,Qe,!1,i.maxTextureSize);me=nt(N,me);const ft=m(me)||o,rt=s.convert(N.format,N.colorSpace);let Ye=s.convert(N.type),Pe=x(N.internalFormat,rt,Ye,N.colorSpace,N.isVideoTexture);$(_e,N,ft);let Ce;const H=N.mipmaps,fe=o&&N.isVideoTexture!==!0&&Pe!==tu,Re=Fe.__version===void 0||pe===!0,De=E(N,me,ft);if(N.isDepthTexture)Pe=r.DEPTH_COMPONENT,o?N.type===jt?Pe=r.DEPTH_COMPONENT32F:N.type===wn?Pe=r.DEPTH_COMPONENT24:N.type===Wi?Pe=r.DEPTH24_STENCIL8:Pe=r.DEPTH_COMPONENT16:N.type===jt&&console.error(\"WebGLRenderer: Floating point depth texture requires WebGL2.\"),N.format===ji&&Pe===r.DEPTH_COMPONENT&&N.type!==Ks&&N.type!==wn&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.\"),N.type=wn,Ye=s.convert(N.type)),N.format===gr&&Pe===r.DEPTH_COMPONENT&&(Pe=r.DEPTH_STENCIL,N.type!==Wi&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.\"),N.type=Wi,Ye=s.convert(N.type))),Re&&(fe?t.texStorage2D(r.TEXTURE_2D,1,Pe,me.width,me.height):t.texImage2D(r.TEXTURE_2D,0,Pe,me.width,me.height,0,rt,Ye,null));else if(N.isDataTexture)if(H.length>0&&ft){fe&&Re&&t.texStorage2D(r.TEXTURE_2D,De,Pe,H[0].width,H[0].height);for(let ee=0,j=H.length;ee<j;ee++)Ce=H[ee],fe?t.texSubImage2D(r.TEXTURE_2D,ee,0,0,Ce.width,Ce.height,rt,Ye,Ce.data):t.texImage2D(r.TEXTURE_2D,ee,Pe,Ce.width,Ce.height,0,rt,Ye,Ce.data);N.generateMipmaps=!1}else fe?(Re&&t.texStorage2D(r.TEXTURE_2D,De,Pe,me.width,me.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,me.width,me.height,rt,Ye,me.data)):t.texImage2D(r.TEXTURE_2D,0,Pe,me.width,me.height,0,rt,Ye,me.data);else if(N.isCompressedTexture)if(N.isCompressedArrayTexture){fe&&Re&&t.texStorage3D(r.TEXTURE_2D_ARRAY,De,Pe,H[0].width,H[0].height,me.depth);for(let ee=0,j=H.length;ee<j;ee++)Ce=H[ee],N.format!==kt?rt!==null?fe?t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ee,0,0,0,Ce.width,Ce.height,me.depth,rt,Ce.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ee,Pe,Ce.width,Ce.height,me.depth,0,Ce.data,0,0):console.warn(\"THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()\"):fe?t.texSubImage3D(r.TEXTURE_2D_ARRAY,ee,0,0,0,Ce.width,Ce.height,me.depth,rt,Ye,Ce.data):t.texImage3D(r.TEXTURE_2D_ARRAY,ee,Pe,Ce.width,Ce.height,me.depth,0,rt,Ye,Ce.data)}else{fe&&Re&&t.texStorage2D(r.TEXTURE_2D,De,Pe,H[0].width,H[0].height);for(let ee=0,j=H.length;ee<j;ee++)Ce=H[ee],N.format!==kt?rt!==null?fe?t.compressedTexSubImage2D(r.TEXTURE_2D,ee,0,0,Ce.width,Ce.height,rt,Ce.data):t.compressedTexImage2D(r.TEXTURE_2D,ee,Pe,Ce.width,Ce.height,0,Ce.data):console.warn(\"THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()\"):fe?t.texSubImage2D(r.TEXTURE_2D,ee,0,0,Ce.width,Ce.height,rt,Ye,Ce.data):t.texImage2D(r.TEXTURE_2D,ee,Pe,Ce.width,Ce.height,0,rt,Ye,Ce.data)}else if(N.isDataArrayTexture)fe?(Re&&t.texStorage3D(r.TEXTURE_2D_ARRAY,De,Pe,me.width,me.height,me.depth),t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,rt,Ye,me.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,Pe,me.width,me.height,me.depth,0,rt,Ye,me.data);else if(N.isData3DTexture)fe?(Re&&t.texStorage3D(r.TEXTURE_3D,De,Pe,me.width,me.height,me.depth),t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,rt,Ye,me.data)):t.texImage3D(r.TEXTURE_3D,0,Pe,me.width,me.height,me.depth,0,rt,Ye,me.data);else if(N.isFramebufferTexture){if(Re)if(fe)t.texStorage2D(r.TEXTURE_2D,De,Pe,me.width,me.height);else{let ee=me.width,j=me.height;for(let ye=0;ye<De;ye++)t.texImage2D(r.TEXTURE_2D,ye,Pe,ee,j,0,rt,Ye,null),ee>>=1,j>>=1}}else if(H.length>0&&ft){fe&&Re&&t.texStorage2D(r.TEXTURE_2D,De,Pe,H[0].width,H[0].height);for(let ee=0,j=H.length;ee<j;ee++)Ce=H[ee],fe?t.texSubImage2D(r.TEXTURE_2D,ee,0,0,rt,Ye,Ce):t.texImage2D(r.TEXTURE_2D,ee,Pe,rt,Ye,Ce);N.generateMipmaps=!1}else fe?(Re&&t.texStorage2D(r.TEXTURE_2D,De,Pe,me.width,me.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,rt,Ye,me)):t.texImage2D(r.TEXTURE_2D,0,Pe,rt,Ye,me);_(N,ft)&&b(_e),Fe.__version=ve.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function xe(B,N,se){if(N.image.length!==6)return;const _e=ue(B,N),pe=N.source;t.bindTexture(r.TEXTURE_CUBE_MAP,B.__webglTexture,r.TEXTURE0+se);const ve=n.get(pe);if(pe.version!==ve.__version||_e===!0){t.activeTexture(r.TEXTURE0+se);const Fe=xt.getPrimaries(xt.workingColorSpace),we=N.colorSpace===Sn?null:xt.getPrimaries(N.colorSpace),Ne=N.colorSpace===Sn||Fe===we?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,N.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,N.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ne);const je=N.isCompressedTexture||N.image[0].isCompressedTexture,Qe=N.image[0]&&N.image[0].isDataTexture,me=[];for(let ee=0;ee<6;ee++)!je&&!Qe?me[ee]=v(N.image[ee],!1,!0,i.maxCubemapSize):me[ee]=Qe?N.image[ee].image:N.image[ee],me[ee]=nt(N,me[ee]);const ft=me[0],rt=m(ft)||o,Ye=s.convert(N.format,N.colorSpace),Pe=s.convert(N.type),Ce=x(N.internalFormat,Ye,Pe,N.colorSpace),H=o&&N.isVideoTexture!==!0,fe=ve.__version===void 0||_e===!0;let Re=E(N,ft,rt);$(r.TEXTURE_CUBE_MAP,N,rt);let De;if(je){H&&fe&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,Ce,ft.width,ft.height);for(let ee=0;ee<6;ee++){De=me[ee].mipmaps;for(let j=0;j<De.length;j++){const ye=De[j];N.format!==kt?Ye!==null?H?t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j,0,0,ye.width,ye.height,Ye,ye.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j,Ce,ye.width,ye.height,0,ye.data):console.warn(\"THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()\"):H?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j,0,0,ye.width,ye.height,Ye,Pe,ye.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j,Ce,ye.width,ye.height,0,Ye,Pe,ye.data)}}}else{De=N.mipmaps,H&&fe&&(De.length>0&&Re++,t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,Ce,me[0].width,me[0].height));for(let ee=0;ee<6;ee++)if(Qe){H?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,me[ee].width,me[ee].height,Ye,Pe,me[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ce,me[ee].width,me[ee].height,0,Ye,Pe,me[ee].data);for(let j=0;j<De.length;j++){const Ae=De[j].image[ee].image;H?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j+1,0,0,Ae.width,Ae.height,Ye,Pe,Ae.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j+1,Ce,Ae.width,Ae.height,0,Ye,Pe,Ae.data)}}else{H?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Ye,Pe,me[ee]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ce,Ye,Pe,me[ee]);for(let j=0;j<De.length;j++){const ye=De[j];H?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j+1,0,0,Ye,Pe,ye.image[ee]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,j+1,Ce,Ye,Pe,ye.image[ee])}}}_(N,rt)&&b(r.TEXTURE_CUBE_MAP),ve.__version=pe.version,N.onUpdate&&N.onUpdate(N)}B.__version=N.version}function ge(B,N,se,_e,pe,ve){const Fe=s.convert(se.format,se.colorSpace),we=s.convert(se.type),Ne=x(se.internalFormat,Fe,we,se.colorSpace);if(!n.get(N).__hasExternalTextures){const Qe=Math.max(1,N.width>>ve),me=Math.max(1,N.height>>ve);pe===r.TEXTURE_3D||pe===r.TEXTURE_2D_ARRAY?t.texImage3D(pe,ve,Ne,Qe,me,N.depth,0,Fe,we,null):t.texImage2D(pe,ve,Ne,Qe,me,0,Fe,we,null)}t.bindFramebuffer(r.FRAMEBUFFER,B),Ue(N)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,_e,pe,n.get(se).__webglTexture,0,Ie(N)):(pe===r.TEXTURE_2D||pe>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,_e,pe,n.get(se).__webglTexture,ve),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Ge(B,N,se){if(r.bindRenderbuffer(r.RENDERBUFFER,B),N.depthBuffer&&!N.stencilBuffer){let _e=o===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(se||Ue(N)){const pe=N.depthTexture;pe&&pe.isDepthTexture&&(pe.type===jt?_e=r.DEPTH_COMPONENT32F:pe.type===wn&&(_e=r.DEPTH_COMPONENT24));const ve=Ie(N);Ue(N)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ve,_e,N.width,N.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,ve,_e,N.width,N.height)}else r.renderbufferStorage(r.RENDERBUFFER,_e,N.width,N.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,B)}else if(N.depthBuffer&&N.stencilBuffer){const _e=Ie(N);se&&Ue(N)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,_e,r.DEPTH24_STENCIL8,N.width,N.height):Ue(N)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,_e,r.DEPTH24_STENCIL8,N.width,N.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,N.width,N.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,B)}else{const _e=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let pe=0;pe<_e.length;pe++){const ve=_e[pe],Fe=s.convert(ve.format,ve.colorSpace),we=s.convert(ve.type),Ne=x(ve.internalFormat,Fe,we,ve.colorSpace),je=Ie(N);se&&Ue(N)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,je,Ne,N.width,N.height):Ue(N)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,je,Ne,N.width,N.height):r.renderbufferStorage(r.RENDERBUFFER,Ne,N.width,N.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Ke(B,N){if(N&&N.isWebGLCubeRenderTarget)throw new Error(\"Depth Texture with cube render targets is not supported\");if(t.bindFramebuffer(r.FRAMEBUFFER,B),!(N.depthTexture&&N.depthTexture.isDepthTexture))throw new Error(\"renderTarget.depthTexture must be an instance of THREE.DepthTexture\");(!n.get(N.depthTexture).__webglTexture||N.depthTexture.image.width!==N.width||N.depthTexture.image.height!==N.height)&&(N.depthTexture.image.width=N.width,N.depthTexture.image.height=N.height,N.depthTexture.needsUpdate=!0),X(N.depthTexture,0);const _e=n.get(N.depthTexture).__webglTexture,pe=Ie(N);if(N.depthTexture.format===ji)Ue(N)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,_e,0,pe):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,_e,0);else if(N.depthTexture.format===gr)Ue(N)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,_e,0,pe):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,_e,0);else throw new Error(\"Unknown depthTexture format\")}function He(B){const N=n.get(B),se=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!N.__autoAllocateDepthBuffer){if(se)throw new Error(\"target.depthTexture not supported in Cube render targets\");Ke(N.__webglFramebuffer,B)}else if(se){N.__webglDepthbuffer=[];for(let _e=0;_e<6;_e++)t.bindFramebuffer(r.FRAMEBUFFER,N.__webglFramebuffer[_e]),N.__webglDepthbuffer[_e]=r.createRenderbuffer(),Ge(N.__webglDepthbuffer[_e],B,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,N.__webglFramebuffer),N.__webglDepthbuffer=r.createRenderbuffer(),Ge(N.__webglDepthbuffer,B,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function tt(B,N,se){const _e=n.get(B);N!==void 0&&ge(_e.__webglFramebuffer,B,B.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),se!==void 0&&He(B)}function W(B){const N=B.texture,se=n.get(B),_e=n.get(N);B.addEventListener(\"dispose\",I),B.isWebGLMultipleRenderTargets!==!0&&(_e.__webglTexture===void 0&&(_e.__webglTexture=r.createTexture()),_e.__version=N.version,a.memory.textures++);const pe=B.isWebGLCubeRenderTarget===!0,ve=B.isWebGLMultipleRenderTargets===!0,Fe=m(B)||o;if(pe){se.__webglFramebuffer=[];for(let we=0;we<6;we++)if(o&&N.mipmaps&&N.mipmaps.length>0){se.__webglFramebuffer[we]=[];for(let Ne=0;Ne<N.mipmaps.length;Ne++)se.__webglFramebuffer[we][Ne]=r.createFramebuffer()}else se.__webglFramebuffer[we]=r.createFramebuffer()}else{if(o&&N.mipmaps&&N.mipmaps.length>0){se.__webglFramebuffer=[];for(let we=0;we<N.mipmaps.length;we++)se.__webglFramebuffer[we]=r.createFramebuffer()}else se.__webglFramebuffer=r.createFramebuffer();if(ve)if(i.drawBuffers){const we=B.texture;for(let Ne=0,je=we.length;Ne<je;Ne++){const Qe=n.get(we[Ne]);Qe.__webglTexture===void 0&&(Qe.__webglTexture=r.createTexture(),a.memory.textures++)}}else console.warn(\"THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.\");if(o&&B.samples>0&&Ue(B)===!1){const we=ve?N:[N];se.__webglMultisampledFramebuffer=r.createFramebuffer(),se.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,se.__webglMultisampledFramebuffer);for(let Ne=0;Ne<we.length;Ne++){const je=we[Ne];se.__webglColorRenderbuffer[Ne]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,se.__webglColorRenderbuffer[Ne]);const Qe=s.convert(je.format,je.colorSpace),me=s.convert(je.type),ft=x(je.internalFormat,Qe,me,je.colorSpace,B.isXRRenderTarget===!0),rt=Ie(B);r.renderbufferStorageMultisample(r.RENDERBUFFER,rt,ft,B.width,B.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ne,r.RENDERBUFFER,se.__webglColorRenderbuffer[Ne])}r.bindRenderbuffer(r.RENDERBUFFER,null),B.depthBuffer&&(se.__webglDepthRenderbuffer=r.createRenderbuffer(),Ge(se.__webglDepthRenderbuffer,B,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(pe){t.bindTexture(r.TEXTURE_CUBE_MAP,_e.__webglTexture),$(r.TEXTURE_CUBE_MAP,N,Fe);for(let we=0;we<6;we++)if(o&&N.mipmaps&&N.mipmaps.length>0)for(let Ne=0;Ne<N.mipmaps.length;Ne++)ge(se.__webglFramebuffer[we][Ne],B,N,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ne);else ge(se.__webglFramebuffer[we],B,N,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+we,0);_(N,Fe)&&b(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ve){const we=B.texture;for(let Ne=0,je=we.length;Ne<je;Ne++){const Qe=we[Ne],me=n.get(Qe);t.bindTexture(r.TEXTURE_2D,me.__webglTexture),$(r.TEXTURE_2D,Qe,Fe),ge(se.__webglFramebuffer,B,Qe,r.COLOR_ATTACHMENT0+Ne,r.TEXTURE_2D,0),_(Qe,Fe)&&b(r.TEXTURE_2D)}t.unbindTexture()}else{let we=r.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?we=B.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error(\"THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.\")),t.bindTexture(we,_e.__webglTexture),$(we,N,Fe),o&&N.mipmaps&&N.mipmaps.length>0)for(let Ne=0;Ne<N.mipmaps.length;Ne++)ge(se.__webglFramebuffer[Ne],B,N,r.COLOR_ATTACHMENT0,we,Ne);else ge(se.__webglFramebuffer,B,N,r.COLOR_ATTACHMENT0,we,0);_(N,Fe)&&b(we),t.unbindTexture()}B.depthBuffer&&He(B)}function ze(B){const N=m(B)||o,se=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let _e=0,pe=se.length;_e<pe;_e++){const ve=se[_e];if(_(ve,N)){const Fe=B.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,we=n.get(ve).__webglTexture;t.bindTexture(Fe,we),b(Fe),t.unbindTexture()}}}function Le(B){if(o&&B.samples>0&&Ue(B)===!1){const N=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],se=B.width,_e=B.height;let pe=r.COLOR_BUFFER_BIT;const ve=[],Fe=B.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,we=n.get(B),Ne=B.isWebGLMultipleRenderTargets===!0;if(Ne)for(let je=0;je<N.length;je++)t.bindFramebuffer(r.FRAMEBUFFER,we.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+je,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,we.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+je,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let je=0;je<N.length;je++){ve.push(r.COLOR_ATTACHMENT0+je),B.depthBuffer&&ve.push(Fe);const Qe=we.__ignoreDepthValues!==void 0?we.__ignoreDepthValues:!1;if(Qe===!1&&(B.depthBuffer&&(pe|=r.DEPTH_BUFFER_BIT),B.stencilBuffer&&(pe|=r.STENCIL_BUFFER_BIT)),Ne&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,we.__webglColorRenderbuffer[je]),Qe===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[Fe]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[Fe])),Ne){const me=n.get(N[je]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,me,0)}r.blitFramebuffer(0,0,se,_e,0,0,se,_e,pe,r.NEAREST),l&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,ve)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Ne)for(let je=0;je<N.length;je++){t.bindFramebuffer(r.FRAMEBUFFER,we.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+je,r.RENDERBUFFER,we.__webglColorRenderbuffer[je]);const Qe=n.get(N[je]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,we.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+je,r.TEXTURE_2D,Qe,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}}function Ie(B){return Math.min(i.maxSamples,B.samples)}function Ue(B){const N=n.get(B);return o&&B.samples>0&&e.has(\"WEBGL_multisampled_render_to_texture\")===!0&&N.__useRenderToTexture!==!1}function _t(B){const N=a.render.frame;u.get(B)!==N&&(u.set(B,N),B.update())}function nt(B,N){const se=B.colorSpace,_e=B.format,pe=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===Oo||se!==zt&&se!==Sn&&(xt.getTransfer(se)===Ct?o===!1?e.has(\"EXT_sRGB\")===!0&&_e===kt?(B.format=Oo,B.minFilter=At,B.generateMipmaps=!1):N=Uu.sRGBToLinear(N):(_e!==kt||pe!==In)&&console.warn(\"THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.\"):console.error(\"THREE.WebGLTextures: Unsupported texture color space:\",se)),N}this.allocateTextureUnit=P,this.resetTextureUnits=V,this.setTexture2D=X,this.setTexture2DArray=re,this.setTexture3D=J,this.setTextureCube=te,this.rebindTextures=tt,this.setupRenderTarget=W,this.updateRenderTargetMipmap=ze,this.updateMultisampleRenderTarget=Le,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=Ue}function n_(r,e,t){const n=t.isWebGL2;function i(s,a=Sn){let o;const c=xt.getTransfer(a);if(s===In)return r.UNSIGNED_BYTE;if(s===Yl)return r.UNSIGNED_SHORT_4_4_4_4;if(s===Kl)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Eo)return r.BYTE;if(s===ql)return r.SHORT;if(s===Ks)return r.UNSIGNED_SHORT;if(s===ps)return r.INT;if(s===wn)return r.UNSIGNED_INT;if(s===jt)return r.FLOAT;if(s===cn)return n?r.HALF_FLOAT:(o=e.get(\"OES_texture_half_float\"),o!==null?o.HALF_FLOAT_OES:null);if(s===ap)return r.ALPHA;if(s===kt)return r.RGBA;if(s===op)return r.LUMINANCE;if(s===cp)return r.LUMINANCE_ALPHA;if(s===ji)return r.DEPTH_COMPONENT;if(s===gr)return r.DEPTH_STENCIL;if(s===Oo)return o=e.get(\"EXT_sRGB\"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===To)return r.RED;if(s===wo)return r.RED_INTEGER;if(s===Zl)return r.RG;if(s===Zs)return r.RG_INTEGER;if(s===ms)return r.RGBA_INTEGER;if(s===Ao||s===Ro||s===Co||s===Po)if(c===Ct)if(o=e.get(\"WEBGL_compressed_texture_s3tc_srgb\"),o!==null){if(s===Ao)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ro)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Co)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Po)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get(\"WEBGL_compressed_texture_s3tc\"),o!==null){if(s===Ao)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ro)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Co)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Po)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===$l||s===Jl||s===Ql||s===eu)if(o=e.get(\"WEBGL_compressed_texture_pvrtc\"),o!==null){if(s===$l)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Jl)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Ql)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===eu)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===tu)return o=e.get(\"WEBGL_compressed_texture_etc1\"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===nu||s===iu)if(o=e.get(\"WEBGL_compressed_texture_etc\"),o!==null){if(s===nu)return c===Ct?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===iu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ru||s===su||s===au||s===ou||s===cu||s===lu||s===uu||s===du||s===hu||s===fu||s===pu||s===mu||s===gu||s===bu)if(o=e.get(\"WEBGL_compressed_texture_astc\"),o!==null){if(s===ru)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===su)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===au)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ou)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===cu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===lu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===uu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===du)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===hu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===fu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===pu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===mu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===bu)return c===Ct?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Lo||s===_u||s===vu)if(o=e.get(\"EXT_texture_compression_bptc\"),o!==null){if(s===Lo)return c===Ct?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===_u)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===vu)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===lp||s===xu||s===yu||s===Mu)if(o=e.get(\"EXT_texture_compression_rgtc\"),o!==null){if(s===Lo)return o.COMPRESSED_RED_RGTC1_EXT;if(s===xu)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===yu)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Mu)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Wi?n?r.UNSIGNED_INT_24_8:(o=e.get(\"WEBGL_depth_texture\"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class i_ extends un{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Pt extends Ot{constructor(){super(),this.isGroup=!0,this.type=\"Group\"}}const r_={type:\"move\"};class gc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Pt,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 Pt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Pt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}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 i=null,s=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 v of e.hand.values()){const m=t.getJointPose(v,n),p=this._getHandJoint(l,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=l.joints[\"index-finger-tip\"],d=l.joints[\"thumb-tip\"],h=u.position.distanceTo(d.position),f=.02,g=.005;l.inputState.pinching&&h>f+g?(l.inputState.pinching=!1,this.dispatchEvent({type:\"pinchend\",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:\"pinchstart\",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(r_)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Pt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class s_ extends Yi{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o=\"local-floor\",c=1,l=null,u=null,d=null,h=null,f=null,g=null;const v=t.getContextAttributes();let m=null,p=null;const _=[],b=[],x=new Ve;let E=null;const T=new un;T.layers.enable(1),T.viewport=new Tt;const A=new un;A.layers.enable(2),A.viewport=new Tt;const I=[T,A],S=new i_;S.layers.enable(1),S.layers.enable(2);let R=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ue=_[$];return ue===void 0&&(ue=new gc,_[$]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function($){let ue=_[$];return ue===void 0&&(ue=new gc,_[$]=ue),ue.getGripSpace()},this.getHand=function($){let ue=_[$];return ue===void 0&&(ue=new gc,_[$]=ue),ue.getHandSpace()};function U($){const ue=b.indexOf($.inputSource);if(ue===-1)return;const Me=_[ue];Me!==void 0&&(Me.update($.inputSource,$.frame,l||a),Me.dispatchEvent({type:$.type,data:$.inputSource}))}function V(){i.removeEventListener(\"select\",U),i.removeEventListener(\"selectstart\",U),i.removeEventListener(\"selectend\",U),i.removeEventListener(\"squeeze\",U),i.removeEventListener(\"squeezestart\",U),i.removeEventListener(\"squeezeend\",U),i.removeEventListener(\"end\",V),i.removeEventListener(\"inputsourceschange\",P);for(let $=0;$<_.length;$++){const ue=b[$];ue!==null&&(b[$]=null,_[$].disconnect(ue))}R=null,F=null,e.setRenderTarget(m),f=null,h=null,d=null,i=null,p=null,he.stop(),n.isPresenting=!1,e.setPixelRatio(E),e.setSize(x.width,x.height,!1),n.dispatchEvent({type:\"sessionend\"})}this.setFramebufferScaleFactor=function($){s=$,n.isPresenting===!0&&console.warn(\"THREE.WebXRManager: Cannot change framebuffer scale while presenting.\")},this.setReferenceSpaceType=function($){o=$,n.isPresenting===!0&&console.warn(\"THREE.WebXRManager: Cannot change reference space type while presenting.\")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function($){l=$},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function($){if(i=$,i!==null){if(m=e.getRenderTarget(),i.addEventListener(\"select\",U),i.addEventListener(\"selectstart\",U),i.addEventListener(\"selectend\",U),i.addEventListener(\"squeeze\",U),i.addEventListener(\"squeezestart\",U),i.addEventListener(\"squeezeend\",U),i.addEventListener(\"end\",V),i.addEventListener(\"inputsourceschange\",P),v.xrCompatible!==!0&&await t.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(x),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ue={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,ue),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),p=new Ki(f.framebufferWidth,f.framebufferHeight,{format:kt,type:In,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ue=null,Me=null,xe=null;v.depth&&(xe=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ue=v.stencil?gr:ji,Me=v.stencil?Wi:wn);const ge={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:s};d=new XRWebGLBinding(i,t),h=d.createProjectionLayer(ge),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),p=new Ki(h.textureWidth,h.textureHeight,{format:kt,type:In,depthTexture:new cd(h.textureWidth,h.textureHeight,Me,void 0,void 0,void 0,void 0,void 0,void 0,ue),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ge=e.properties.get(p);Ge.__ignoreDepthValues=h.ignoreDepthValues}p.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),he.setContext(i),he.start(),n.isPresenting=!0,n.dispatchEvent({type:\"sessionstart\"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function P($){for(let ue=0;ue<$.removed.length;ue++){const Me=$.removed[ue],xe=b.indexOf(Me);xe>=0&&(b[xe]=null,_[xe].disconnect(Me))}for(let ue=0;ue<$.added.length;ue++){const Me=$.added[ue];let xe=b.indexOf(Me);if(xe===-1){for(let Ge=0;Ge<_.length;Ge++)if(Ge>=b.length){b.push(Me),xe=Ge;break}else if(b[Ge]===null){b[Ge]=Me,xe=Ge;break}if(xe===-1)break}const ge=_[xe];ge&&ge.connect(Me)}}const z=new O,X=new O;function re($,ue,Me){z.setFromMatrixPosition(ue.matrixWorld),X.setFromMatrixPosition(Me.matrixWorld);const xe=z.distanceTo(X),ge=ue.projectionMatrix.elements,Ge=Me.projectionMatrix.elements,Ke=ge[14]/(ge[10]-1),He=ge[14]/(ge[10]+1),tt=(ge[9]+1)/ge[5],W=(ge[9]-1)/ge[5],ze=(ge[8]-1)/ge[0],Le=(Ge[8]+1)/Ge[0],Ie=Ke*ze,Ue=Ke*Le,_t=xe/(-ze+Le),nt=_t*-ze;ue.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(nt),$.translateZ(_t),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert();const B=Ke+_t,N=He+_t,se=Ie-nt,_e=Ue+(xe-nt),pe=tt*He/N*B,ve=W*He/N*B;$.projectionMatrix.makePerspective(se,_e,pe,ve,B,N),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}function J($,ue){ue===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ue.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(i===null)return;S.near=A.near=T.near=$.near,S.far=A.far=T.far=$.far,(R!==S.near||F!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),R=S.near,F=S.far);const ue=$.parent,Me=S.cameras;J(S,ue);for(let xe=0;xe<Me.length;xe++)J(Me[xe],ue);Me.length===2?re(S,T,A):S.projectionMatrix.copy(T.projectionMatrix),te($,S,ue)};function te($,ue,Me){Me===null?$.matrix.copy(ue.matrixWorld):($.matrix.copy(Me.matrixWorld),$.matrix.invert(),$.matrix.multiply(ue.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ue.projectionMatrix),$.projectionMatrixInverse.copy(ue.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=vr*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function($){c=$,h!==null&&(h.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)};let Q=null;function ce($,ue){if(u=ue.getViewerPose(l||a),g=ue,u!==null){const Me=u.views;f!==null&&(e.setRenderTargetFramebuffer(p,f.framebuffer),e.setRenderTarget(p));let xe=!1;Me.length!==S.cameras.length&&(S.cameras.length=0,xe=!0);for(let ge=0;ge<Me.length;ge++){const Ge=Me[ge];let Ke=null;if(f!==null)Ke=f.getViewport(Ge);else{const tt=d.getViewSubImage(h,Ge);Ke=tt.viewport,ge===0&&(e.setRenderTargetTextures(p,tt.colorTexture,h.ignoreDepthValues?void 0:tt.depthStencilTexture),e.setRenderTarget(p))}let He=I[ge];He===void 0&&(He=new un,He.layers.enable(ge),He.viewport=new Tt,I[ge]=He),He.matrix.fromArray(Ge.transform.matrix),He.matrix.decompose(He.position,He.quaternion,He.scale),He.projectionMatrix.fromArray(Ge.projectionMatrix),He.projectionMatrixInverse.copy(He.projectionMatrix).invert(),He.viewport.set(Ke.x,Ke.y,Ke.width,Ke.height),ge===0&&(S.matrix.copy(He.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),xe===!0&&S.cameras.push(He)}}for(let Me=0;Me<_.length;Me++){const xe=b[Me],ge=_[Me];xe!==null&&ge!==void 0&&ge.update(xe,ue,l||a)}Q&&Q($,ue),ue.detectedPlanes&&n.dispatchEvent({type:\"planesdetected\",data:ue}),g=null}const he=new td;he.setAnimationLoop(ce),this.setAnimationLoop=function($){Q=$},this.dispose=function(){}}}function a_(r,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Qu(r)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,_,b,x){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),d(m,p)):p.isMeshPhongMaterial?(s(m,p),u(m,p)):p.isMeshStandardMaterial?(s(m,p),h(m,p),p.isMeshPhysicalMaterial&&f(m,p,x)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),v(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?c(m,p,_,b):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===on&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===on&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const _=e.get(p).envMap;if(_&&(m.envMap.value=_,m.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap){m.lightMap.value=p.lightMap;const b=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=p.lightMapIntensity*b,t(p.lightMap,m.lightMapTransform)}p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,_,b){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*_,m.scale.value=b*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function h(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),e.get(p).envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,_){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===on&&m.clearcoatNormalScale.value.negate())),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=_.texture,m.transmissionSamplerSize.value.set(_.width,_.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const _=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(_.matrixWorld),m.nearDistance.value=_.shadow.camera.near,m.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function o_(r,e,t,n){let i={},s={},a=[];const o=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(_,b){const x=b.program;n.uniformBlockBinding(_,x)}function l(_,b){let x=i[_.id];x===void 0&&(g(_),x=u(_),i[_.id]=x,_.addEventListener(\"dispose\",m));const E=b.program;n.updateUBOMapping(_,E);const T=e.render.frame;s[_.id]!==T&&(h(_),s[_.id]=T)}function u(_){const b=d();_.__bindingPointIndex=b;const x=r.createBuffer(),E=_.__size,T=_.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,E,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,b,x),x}function d(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return console.error(\"THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.\"),0}function h(_){const b=i[_.id],x=_.uniforms,E=_.__cache;r.bindBuffer(r.UNIFORM_BUFFER,b);for(let T=0,A=x.length;T<A;T++){const I=Array.isArray(x[T])?x[T]:[x[T]];for(let S=0,R=I.length;S<R;S++){const F=I[S];if(f(F,T,S,E)===!0){const U=F.__offset,V=Array.isArray(F.value)?F.value:[F.value];let P=0;for(let z=0;z<V.length;z++){const X=V[z],re=v(X);typeof X==\"number\"||typeof X==\"boolean\"?(F.__data[0]=X,r.bufferSubData(r.UNIFORM_BUFFER,U+P,F.__data)):X.isMatrix3?(F.__data[0]=X.elements[0],F.__data[1]=X.elements[1],F.__data[2]=X.elements[2],F.__data[3]=0,F.__data[4]=X.elements[3],F.__data[5]=X.elements[4],F.__data[6]=X.elements[5],F.__data[7]=0,F.__data[8]=X.elements[6],F.__data[9]=X.elements[7],F.__data[10]=X.elements[8],F.__data[11]=0):(X.toArray(F.__data,P),P+=re.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,U,F.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(_,b,x,E){const T=_.value,A=b+\"_\"+x;if(E[A]===void 0)return typeof T==\"number\"||typeof T==\"boolean\"?E[A]=T:E[A]=T.clone(),!0;{const I=E[A];if(typeof T==\"number\"||typeof T==\"boolean\"){if(I!==T)return E[A]=T,!0}else if(I.equals(T)===!1)return I.copy(T),!0}return!1}function g(_){const b=_.uniforms;let x=0;const E=16;for(let A=0,I=b.length;A<I;A++){const S=Array.isArray(b[A])?b[A]:[b[A]];for(let R=0,F=S.length;R<F;R++){const U=S[R],V=Array.isArray(U.value)?U.value:[U.value];for(let P=0,z=V.length;P<z;P++){const X=V[P],re=v(X),J=x%E;J!==0&&E-J<re.boundary&&(x+=E-J),U.__data=new Float32Array(re.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=x,x+=re.storage}}}const T=x%E;return T>0&&(x+=E-T),_.__size=x,_.__cache={},this}function v(_){const b={boundary:0,storage:0};return typeof _==\"number\"||typeof _==\"boolean\"?(b.boundary=4,b.storage=4):_.isVector2?(b.boundary=8,b.storage=8):_.isVector3||_.isColor?(b.boundary=16,b.storage=12):_.isVector4?(b.boundary=16,b.storage=16):_.isMatrix3?(b.boundary=48,b.storage=48):_.isMatrix4?(b.boundary=64,b.storage=64):_.isTexture?console.warn(\"THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.\"):console.warn(\"THREE.WebGLRenderer: Unsupported uniform value type.\",_),b}function m(_){const b=_.target;b.removeEventListener(\"dispose\",m);const x=a.indexOf(b.__bindingPointIndex);a.splice(x,1),r.deleteBuffer(i[b.id]),delete i[b.id],delete s[b.id]}function p(){for(const _ in i)r.deleteBuffer(i[_]);a=[],i={},s={}}return{bind:c,update:l,dispose:p}}class bc{constructor(e={}){const{canvas:t=Fp(),context:n=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u=\"default\",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;n!==null?h=n.getContextAttributes().alpha:h=a;const f=new Uint32Array(4),g=new Int32Array(4);let v=null,m=null;const p=[],_=[];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._outputColorSpace=Mt,this._useLegacyLights=!1,this.toneMapping=ri,this.toneMappingExposure=1;const b=this;let x=!1,E=0,T=0,A=null,I=-1,S=null;const R=new Tt,F=new Tt;let U=null;const V=new Be(0);let P=0,z=t.width,X=t.height,re=1,J=null,te=null;const Q=new Tt(0,0,z,X),ce=new Tt(0,0,z,X);let he=!1;const $=new oc;let ue=!1,Me=!1,xe=null;const ge=new qe,Ge=new Ve,Ke=new O,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function tt(){return A===null?re:1}let W=n;function ze(y,C){for(let D=0;D<y.length;D++){const k=y[D],G=t.getContext(k,C);if(G!==null)return G}return null}try{const y={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if(\"setAttribute\"in t&&t.setAttribute(\"data-engine\",`three.js r${ds}`),t.addEventListener(\"webglcontextlost\",ee,!1),t.addEventListener(\"webglcontextrestored\",j,!1),t.addEventListener(\"webglcontextcreationerror\",ye,!1),W===null){const C=[\"webgl2\",\"webgl\",\"experimental-webgl\"];if(b.isWebGL1Renderer===!0&&C.shift(),W=ze(C,y),W===null)throw ze(C)?new Error(\"Error creating WebGL context with your selected attributes.\"):new Error(\"Error creating WebGL context.\")}typeof WebGLRenderingContext<\"u\"&&W instanceof WebGLRenderingContext&&console.warn(\"THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.\"),W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(y){throw console.error(\"THREE.WebGLRenderer: \"+y.message),y}let Le,Ie,Ue,_t,nt,B,N,se,_e,pe,ve,Fe,we,Ne,je,Qe,me,ft,rt,Ye,Pe,Ce,H,fe;function Re(){Le=new b0(W),Ie=new d0(W,Le,e),Le.init(Ie),Ce=new n_(W,Le,Ie),Ue=new e_(W,Le,Ie),_t=new x0(W),nt=new zb,B=new t_(W,Le,Ue,nt,Ie,Ce,_t),N=new f0(b),se=new g0(b),_e=new cm(W,Ie),H=new l0(W,Le,_e,Ie),pe=new _0(W,_e,_t,H),ve=new E0(W,pe,_e,_t),rt=new S0(W,Ie,B),Qe=new h0(nt),Fe=new kb(b,N,se,Le,Ie,H,Qe),we=new a_(b,nt),Ne=new Hb,je=new Yb(Le,Ie),ft=new c0(b,N,se,Ue,ve,h,c),me=new Qb(b,ve,Ie),fe=new o_(W,_t,Ie,Ue),Ye=new u0(W,Le,_t,Ie),Pe=new v0(W,Le,_t,Ie),_t.programs=Fe.programs,b.capabilities=Ie,b.extensions=Le,b.properties=nt,b.renderLists=Ne,b.shadowMap=me,b.state=Ue,b.info=_t}Re();const De=new s_(b,W);this.xr=De,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){const y=Le.get(\"WEBGL_lose_context\");y&&y.loseContext()},this.forceContextRestore=function(){const y=Le.get(\"WEBGL_lose_context\");y&&y.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(y){y!==void 0&&(re=y,this.setSize(z,X,!1))},this.getSize=function(y){return y.set(z,X)},this.setSize=function(y,C,D=!0){if(De.isPresenting){console.warn(\"THREE.WebGLRenderer: Can't change size while VR device is presenting.\");return}z=y,X=C,t.width=Math.floor(y*re),t.height=Math.floor(C*re),D===!0&&(t.style.width=y+\"px\",t.style.height=C+\"px\"),this.setViewport(0,0,y,C)},this.getDrawingBufferSize=function(y){return y.set(z*re,X*re).floor()},this.setDrawingBufferSize=function(y,C,D){z=y,X=C,re=D,t.width=Math.floor(y*D),t.height=Math.floor(C*D),this.setViewport(0,0,y,C)},this.getCurrentViewport=function(y){return y.copy(R)},this.getViewport=function(y){return y.copy(Q)},this.setViewport=function(y,C,D,k){y.isVector4?Q.set(y.x,y.y,y.z,y.w):Q.set(y,C,D,k),Ue.viewport(R.copy(Q).multiplyScalar(re).floor())},this.getScissor=function(y){return y.copy(ce)},this.setScissor=function(y,C,D,k){y.isVector4?ce.set(y.x,y.y,y.z,y.w):ce.set(y,C,D,k),Ue.scissor(F.copy(ce).multiplyScalar(re).floor())},this.getScissorTest=function(){return he},this.setScissorTest=function(y){Ue.setScissorTest(he=y)},this.setOpaqueSort=function(y){J=y},this.setTransparentSort=function(y){te=y},this.getClearColor=function(y){return y.copy(ft.getClearColor())},this.setClearColor=function(){ft.setClearColor.apply(ft,arguments)},this.getClearAlpha=function(){return ft.getClearAlpha()},this.setClearAlpha=function(){ft.setClearAlpha.apply(ft,arguments)},this.clear=function(y=!0,C=!0,D=!0){let k=0;if(y){let G=!1;if(A!==null){const Y=A.texture.format;G=Y===ms||Y===Zs||Y===wo}if(G){const Y=A.texture.type,q=Y===In||Y===wn||Y===Ks||Y===Wi||Y===Yl||Y===Kl,Z=ft.getClearColor(),ie=ft.getClearAlpha(),oe=Z.r,ae=Z.g,le=Z.b;q?(f[0]=oe,f[1]=ae,f[2]=le,f[3]=ie,W.clearBufferuiv(W.COLOR,0,f)):(g[0]=oe,g[1]=ae,g[2]=le,g[3]=ie,W.clearBufferiv(W.COLOR,0,g))}else k|=W.COLOR_BUFFER_BIT}C&&(k|=W.DEPTH_BUFFER_BIT),D&&(k|=W.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W.clear(k)},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\",ee,!1),t.removeEventListener(\"webglcontextrestored\",j,!1),t.removeEventListener(\"webglcontextcreationerror\",ye,!1),Ne.dispose(),je.dispose(),nt.dispose(),N.dispose(),se.dispose(),ve.dispose(),H.dispose(),fe.dispose(),Fe.dispose(),De.dispose(),De.removeEventListener(\"sessionstart\",Dt),De.removeEventListener(\"sessionend\",pt),xe&&(xe.dispose(),xe=null),Ut.stop()};function ee(y){y.preventDefault(),console.log(\"THREE.WebGLRenderer: Context Lost.\"),x=!0}function j(){console.log(\"THREE.WebGLRenderer: Context Restored.\"),x=!1;const y=_t.autoReset,C=me.enabled,D=me.autoUpdate,k=me.needsUpdate,G=me.type;Re(),_t.autoReset=y,me.enabled=C,me.autoUpdate=D,me.needsUpdate=k,me.type=G}function ye(y){console.error(\"THREE.WebGLRenderer: A WebGL context could not be created. Reason: \",y.statusMessage)}function Ae(y){const C=y.target;C.removeEventListener(\"dispose\",Ae),Ze(C)}function Ze(y){Xe(y),nt.remove(y)}function Xe(y){const C=nt.get(y).programs;C!==void 0&&(C.forEach(function(D){Fe.releaseProgram(D)}),y.isShaderMaterial&&Fe.releaseShaderCache(y))}this.renderBufferDirect=function(y,C,D,k,G,Y){C===null&&(C=He);const q=G.isMesh&&G.matrixWorld.determinant()<0,Z=M(y,C,D,k,G);Ue.setMaterial(k,q);let ie=D.index,oe=1;if(k.wireframe===!0){if(ie=pe.getWireframeAttribute(D),ie===void 0)return;oe=2}const ae=D.drawRange,le=D.attributes.position;let de=ae.start*oe,be=(ae.start+ae.count)*oe;Y!==null&&(de=Math.max(de,Y.start*oe),be=Math.min(be,(Y.start+Y.count)*oe)),ie!==null?(de=Math.max(de,0),be=Math.min(be,ie.count)):le!=null&&(de=Math.max(de,0),be=Math.min(be,le.count));const Se=be-de;if(Se<0||Se===1/0)return;H.setup(G,k,Z,D,ie);let $e,Oe=Ye;if(ie!==null&&($e=_e.get(ie),Oe=Pe,Oe.setIndex($e)),G.isMesh)k.wireframe===!0?(Ue.setLineWidth(k.wireframeLinewidth*tt()),Oe.setMode(W.LINES)):Oe.setMode(W.TRIANGLES);else if(G.isLine){let ke=k.linewidth;ke===void 0&&(ke=1),Ue.setLineWidth(ke*tt()),G.isLineSegments?Oe.setMode(W.LINES):G.isLineLoop?Oe.setMode(W.LINE_LOOP):Oe.setMode(W.LINE_STRIP)}else G.isPoints?Oe.setMode(W.POINTS):G.isSprite&&Oe.setMode(W.TRIANGLES);if(G.isBatchedMesh)Oe.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)Oe.renderInstances(de,Se,G.count);else if(D.isInstancedBufferGeometry){const ke=D._maxInstanceCount!==void 0?D._maxInstanceCount:1/0,it=Math.min(D.instanceCount,ke);Oe.renderInstances(de,Se,it)}else Oe.render(de,Se)};function at(y,C,D){y.transparent===!0&&y.side===wt&&y.forceSinglePass===!1?(y.side=on,y.needsUpdate=!0,et(y,C,D),y.side=Mn,y.needsUpdate=!0,et(y,C,D),y.side=wt):et(y,C,D)}this.compile=function(y,C,D=null){D===null&&(D=y),m=je.get(D),m.init(),_.push(m),D.traverseVisible(function(G){G.isLight&&G.layers.test(C.layers)&&(m.pushLight(G),G.castShadow&&m.pushShadow(G))}),y!==D&&y.traverseVisible(function(G){G.isLight&&G.layers.test(C.layers)&&(m.pushLight(G),G.castShadow&&m.pushShadow(G))}),m.setupLights(b._useLegacyLights);const k=new Set;return y.traverse(function(G){const Y=G.material;if(Y)if(Array.isArray(Y))for(let q=0;q<Y.length;q++){const Z=Y[q];at(Z,D,G),k.add(Z)}else at(Y,D,G),k.add(Y)}),_.pop(),m=null,k},this.compileAsync=function(y,C,D=null){const k=this.compile(y,C,D);return new Promise(G=>{function Y(){if(k.forEach(function(q){nt.get(q).currentProgram.isReady()&&k.delete(q)}),k.size===0){G(y);return}setTimeout(Y,10)}Le.get(\"KHR_parallel_shader_compile\")!==null?Y():setTimeout(Y,10)})};let ot=null;function Rt(y){ot&&ot(y)}function Dt(){Ut.stop()}function pt(){Ut.start()}const Ut=new td;Ut.setAnimationLoop(Rt),typeof self<\"u\"&&Ut.setContext(self),this.setAnimationLoop=function(y){ot=y,De.setAnimationLoop(y),y===null?Ut.stop():Ut.start()},De.addEventListener(\"sessionstart\",Dt),De.addEventListener(\"sessionend\",pt),this.render=function(y,C){if(C!==void 0&&C.isCamera!==!0){console.error(\"THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.\");return}if(x===!0)return;y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),C.parent===null&&C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(De.cameraAutoUpdate===!0&&De.updateCamera(C),C=De.getCamera()),y.isScene===!0&&y.onBeforeRender(b,y,C,A),m=je.get(y,_.length),m.init(),_.push(m),ge.multiplyMatrices(C.projectionMatrix,C.matrixWorldInverse),$.setFromProjectionMatrix(ge),Me=this.localClippingEnabled,ue=Qe.init(this.clippingPlanes,Me),v=Ne.get(y,p.length),v.init(),p.push(v),En(y,C,0,b.sortObjects),v.finish(),b.sortObjects===!0&&v.sort(J,te),this.info.render.frame++,ue===!0&&Qe.beginShadows();const D=m.state.shadowsArray;if(me.render(D,y,C),ue===!0&&Qe.endShadows(),this.info.autoReset===!0&&this.info.reset(),ft.render(v,y),m.setupLights(b._useLegacyLights),C.isArrayCamera){const k=C.cameras;for(let G=0,Y=k.length;G<Y;G++){const q=k[G];xi(v,y,q,q.viewport)}}else xi(v,y,C);A!==null&&(B.updateMultisampleRenderTarget(A),B.updateRenderTargetMipmap(A)),y.isScene===!0&&y.onAfterRender(b,y,C),H.resetDefaultState(),I=-1,S=null,_.pop(),_.length>0?m=_[_.length-1]:m=null,p.pop(),p.length>0?v=p[p.length-1]:v=null};function En(y,C,D,k){if(y.visible===!1)return;if(y.layers.test(C.layers)){if(y.isGroup)D=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(C);else if(y.isLight)m.pushLight(y),y.castShadow&&m.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||$.intersectsSprite(y)){k&&Ke.setFromMatrixPosition(y.matrixWorld).applyMatrix4(ge);const q=ve.update(y),Z=y.material;Z.visible&&v.push(y,q,Z,D,Ke.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||$.intersectsObject(y))){const q=ve.update(y),Z=y.material;if(k&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ke.copy(y.boundingSphere.center)):(q.boundingSphere===null&&q.computeBoundingSphere(),Ke.copy(q.boundingSphere.center)),Ke.applyMatrix4(y.matrixWorld).applyMatrix4(ge)),Array.isArray(Z)){const ie=q.groups;for(let oe=0,ae=ie.length;oe<ae;oe++){const le=ie[oe],de=Z[le.materialIndex];de&&de.visible&&v.push(y,q,de,D,Ke.z,le)}}else Z.visible&&v.push(y,q,Z,D,Ke.z,null)}}const Y=y.children;for(let q=0,Z=Y.length;q<Z;q++)En(Y[q],C,D,k)}function xi(y,C,D,k){const G=y.opaque,Y=y.transmissive,q=y.transparent;m.setupLightsView(D),ue===!0&&Qe.setGlobalState(b.clippingPlanes,D),Y.length>0&&js(G,Y,C,D),k&&Ue.viewport(R.copy(k)),G.length>0&&Gn(G,C,D),Y.length>0&&Gn(Y,C,D),q.length>0&&Gn(q,C,D),Ue.buffers.depth.setTest(!0),Ue.buffers.depth.setMask(!0),Ue.buffers.color.setMask(!0),Ue.setPolygonOffset(!1)}function js(y,C,D,k){if((D.isScene===!0?D.overrideMaterial:null)!==null)return;const Y=Ie.isWebGL2;xe===null&&(xe=new Ki(1,1,{generateMipmaps:!0,type:Le.has(\"EXT_color_buffer_half_float\")?cn:In,minFilter:si,samples:Y?4:0})),b.getDrawingBufferSize(Ge),Y?xe.setSize(Ge.x,Ge.y):xe.setSize(ia(Ge.x),ia(Ge.y));const q=b.getRenderTarget();b.setRenderTarget(xe),b.getClearColor(V),P=b.getClearAlpha(),P<1&&b.setClearColor(16777215,.5),b.clear();const Z=b.toneMapping;b.toneMapping=ri,Gn(y,D,k),B.updateMultisampleRenderTarget(xe),B.updateRenderTargetMipmap(xe);let ie=!1;for(let oe=0,ae=C.length;oe<ae;oe++){const le=C[oe],de=le.object,be=le.geometry,Se=le.material,$e=le.group;if(Se.side===wt&&de.layers.test(k.layers)){const Oe=Se.side;Se.side=on,Se.needsUpdate=!0,Hn(de,D,k,be,Se,$e),Se.side=Oe,Se.needsUpdate=!0,ie=!0}}ie===!0&&(B.updateMultisampleRenderTarget(xe),B.updateRenderTargetMipmap(xe)),b.setRenderTarget(q),b.setClearColor(V,P),b.toneMapping=Z}function Gn(y,C,D){const k=C.isScene===!0?C.overrideMaterial:null;for(let G=0,Y=y.length;G<Y;G++){const q=y[G],Z=q.object,ie=q.geometry,oe=k===null?q.material:k,ae=q.group;Z.layers.test(D.layers)&&Hn(Z,C,D,ie,oe,ae)}}function Hn(y,C,D,k,G,Y){y.onBeforeRender(b,C,D,k,G,Y),y.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),G.onBeforeRender(b,C,D,k,y,Y),G.transparent===!0&&G.side===wt&&G.forceSinglePass===!1?(G.side=on,G.needsUpdate=!0,b.renderBufferDirect(D,C,k,G,y,Y),G.side=Mn,G.needsUpdate=!0,b.renderBufferDirect(D,C,k,G,y,Y),G.side=wt):b.renderBufferDirect(D,C,k,G,y,Y),y.onAfterRender(b,C,D,k,G,Y)}function et(y,C,D){C.isScene!==!0&&(C=He);const k=nt.get(y),G=m.state.lights,Y=m.state.shadowsArray,q=G.state.version,Z=Fe.getParameters(y,G.state,Y,C,D),ie=Fe.getProgramCacheKey(Z);let oe=k.programs;k.environment=y.isMeshStandardMaterial?C.environment:null,k.fog=C.fog,k.envMap=(y.isMeshStandardMaterial?se:N).get(y.envMap||k.environment),oe===void 0&&(y.addEventListener(\"dispose\",Ae),oe=new Map,k.programs=oe);let ae=oe.get(ie);if(ae!==void 0){if(k.currentProgram===ae&&k.lightsStateVersion===q)return ne(y,Z),ae}else Z.uniforms=Fe.getUniforms(y),y.onBuild(D,Z,b),y.onBeforeCompile(Z,b),ae=Fe.acquireProgram(Z,ie),oe.set(ie,ae),k.uniforms=Z.uniforms;const le=k.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(le.clippingPlanes=Qe.uniform),ne(y,Z),k.needsLights=L(y),k.lightsStateVersion=q,k.needsLights&&(le.ambientLightColor.value=G.state.ambient,le.lightProbe.value=G.state.probe,le.directionalLights.value=G.state.directional,le.directionalLightShadows.value=G.state.directionalShadow,le.spotLights.value=G.state.spot,le.spotLightShadows.value=G.state.spotShadow,le.rectAreaLights.value=G.state.rectArea,le.ltc_1.value=G.state.rectAreaLTC1,le.ltc_2.value=G.state.rectAreaLTC2,le.pointLights.value=G.state.point,le.pointLightShadows.value=G.state.pointShadow,le.hemisphereLights.value=G.state.hemi,le.directionalShadowMap.value=G.state.directionalShadowMap,le.directionalShadowMatrix.value=G.state.directionalShadowMatrix,le.spotShadowMap.value=G.state.spotShadowMap,le.spotLightMatrix.value=G.state.spotLightMatrix,le.spotLightMap.value=G.state.spotLightMap,le.pointShadowMap.value=G.state.pointShadowMap,le.pointShadowMatrix.value=G.state.pointShadowMatrix),k.currentProgram=ae,k.uniformsList=null,ae}function K(y){if(y.uniformsList===null){const C=y.currentProgram.getUniforms();y.uniformsList=Ra.seqWithValue(C.seq,y.uniforms)}return y.uniformsList}function ne(y,C){const D=nt.get(y);D.outputColorSpace=C.outputColorSpace,D.batching=C.batching,D.instancing=C.instancing,D.instancingColor=C.instancingColor,D.skinning=C.skinning,D.morphTargets=C.morphTargets,D.morphNormals=C.morphNormals,D.morphColors=C.morphColors,D.morphTargetsCount=C.morphTargetsCount,D.numClippingPlanes=C.numClippingPlanes,D.numIntersection=C.numClipIntersection,D.vertexAlphas=C.vertexAlphas,D.vertexTangents=C.vertexTangents,D.toneMapping=C.toneMapping}function M(y,C,D,k,G){C.isScene!==!0&&(C=He),B.resetTextureUnits();const Y=C.fog,q=k.isMeshStandardMaterial?C.environment:null,Z=A===null?b.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:zt,ie=(k.isMeshStandardMaterial?se:N).get(k.envMap||q),oe=k.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,ae=!!D.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),le=!!D.morphAttributes.position,de=!!D.morphAttributes.normal,be=!!D.morphAttributes.color;let Se=ri;k.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Se=b.toneMapping);const $e=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,Oe=$e!==void 0?$e.length:0,ke=nt.get(k),it=m.state.lights;if(ue===!0&&(Me===!0||y!==S)){const Et=y===S&&k.id===I;Qe.setState(k,y,Et)}let Ee=!1;k.version===ke.__version?(ke.needsLights&&ke.lightsStateVersion!==it.state.version||ke.outputColorSpace!==Z||G.isBatchedMesh&&ke.batching===!1||!G.isBatchedMesh&&ke.batching===!0||G.isInstancedMesh&&ke.instancing===!1||!G.isInstancedMesh&&ke.instancing===!0||G.isSkinnedMesh&&ke.skinning===!1||!G.isSkinnedMesh&&ke.skinning===!0||G.isInstancedMesh&&ke.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&ke.instancingColor===!1&&G.instanceColor!==null||ke.envMap!==ie||k.fog===!0&&ke.fog!==Y||ke.numClippingPlanes!==void 0&&(ke.numClippingPlanes!==Qe.numPlanes||ke.numIntersection!==Qe.numIntersection)||ke.vertexAlphas!==oe||ke.vertexTangents!==ae||ke.morphTargets!==le||ke.morphNormals!==de||ke.morphColors!==be||ke.toneMapping!==Se||Ie.isWebGL2===!0&&ke.morphTargetsCount!==Oe)&&(Ee=!0):(Ee=!0,ke.__version=k.version);let ut=ke.currentProgram;Ee===!0&&(ut=et(k,C,G));let Nt=!1,mt=!1,lt=!1;const Je=ut.getUniforms(),Wt=ke.uniforms;if(Ue.useProgram(ut.program)&&(Nt=!0,mt=!0,lt=!0),k.id!==I&&(I=k.id,mt=!0),Nt||S!==y){Je.setValue(W,\"projectionMatrix\",y.projectionMatrix),Je.setValue(W,\"viewMatrix\",y.matrixWorldInverse);const Et=Je.map.cameraPosition;Et!==void 0&&Et.setValue(W,Ke.setFromMatrixPosition(y.matrixWorld)),Ie.logarithmicDepthBuffer&&Je.setValue(W,\"logDepthBufFC\",2/(Math.log(y.far+1)/Math.LN2)),(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)&&Je.setValue(W,\"isOrthographic\",y.isOrthographicCamera===!0),S!==y&&(S=y,mt=!0,lt=!0)}if(G.isSkinnedMesh){Je.setOptional(W,G,\"bindMatrix\"),Je.setOptional(W,G,\"bindMatrixInverse\");const Et=G.skeleton;Et&&(Ie.floatVertexTextures?(Et.boneTexture===null&&Et.computeBoneTexture(),Je.setValue(W,\"boneTexture\",Et.boneTexture,B)):console.warn(\"THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.\"))}G.isBatchedMesh&&(Je.setOptional(W,G,\"batchingTexture\"),Je.setValue(W,\"batchingTexture\",G._matricesTexture,B));const Tn=D.morphAttributes;if((Tn.position!==void 0||Tn.normal!==void 0||Tn.color!==void 0&&Ie.isWebGL2===!0)&&rt.update(G,D,ut),(mt||ke.receiveShadow!==G.receiveShadow)&&(ke.receiveShadow=G.receiveShadow,Je.setValue(W,\"receiveShadow\",G.receiveShadow)),k.isMeshGouraudMaterial&&k.envMap!==null&&(Wt.envMap.value=ie,Wt.flipEnvMap.value=ie.isCubeTexture&&ie.isRenderTargetTexture===!1?-1:1),mt&&(Je.setValue(W,\"toneMappingExposure\",b.toneMappingExposure),ke.needsLights&&w(Wt,lt),Y&&k.fog===!0&&we.refreshFogUniforms(Wt,Y),we.refreshMaterialUniforms(Wt,k,re,X,xe),Ra.upload(W,K(ke),Wt,B)),k.isShaderMaterial&&k.uniformsNeedUpdate===!0&&(Ra.upload(W,K(ke),Wt,B),k.uniformsNeedUpdate=!1),k.isSpriteMaterial&&Je.setValue(W,\"center\",G.center),Je.setValue(W,\"modelViewMatrix\",G.modelViewMatrix),Je.setValue(W,\"normalMatrix\",G.normalMatrix),Je.setValue(W,\"modelMatrix\",G.matrixWorld),k.isShaderMaterial||k.isRawShaderMaterial){const Et=k.uniformsGroups;for(let Ln=0,yi=Et.length;Ln<yi;Ln++)if(Ie.isWebGL2){const Mi=Et[Ln];fe.update(Mi,ut),fe.bind(Mi,ut)}else console.warn(\"THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.\")}return ut}function w(y,C){y.ambientLightColor.needsUpdate=C,y.lightProbe.needsUpdate=C,y.directionalLights.needsUpdate=C,y.directionalLightShadows.needsUpdate=C,y.pointLights.needsUpdate=C,y.pointLightShadows.needsUpdate=C,y.spotLights.needsUpdate=C,y.spotLightShadows.needsUpdate=C,y.rectAreaLights.needsUpdate=C,y.hemisphereLights.needsUpdate=C}function L(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(y,C,D){nt.get(y.texture).__webglTexture=C,nt.get(y.depthTexture).__webglTexture=D;const k=nt.get(y);k.__hasExternalTextures=!0,k.__hasExternalTextures&&(k.__autoAllocateDepthBuffer=D===void 0,k.__autoAllocateDepthBuffer||Le.has(\"WEBGL_multisampled_render_to_texture\")===!0&&(console.warn(\"THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided\"),k.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(y,C){const D=nt.get(y);D.__webglFramebuffer=C,D.__useDefaultFramebuffer=C===void 0},this.setRenderTarget=function(y,C=0,D=0){A=y,E=C,T=D;let k=!0,G=null,Y=!1,q=!1;if(y){const ie=nt.get(y);ie.__useDefaultFramebuffer!==void 0?(Ue.bindFramebuffer(W.FRAMEBUFFER,null),k=!1):ie.__webglFramebuffer===void 0?B.setupRenderTarget(y):ie.__hasExternalTextures&&B.rebindTextures(y,nt.get(y.texture).__webglTexture,nt.get(y.depthTexture).__webglTexture);const oe=y.texture;(oe.isData3DTexture||oe.isDataArrayTexture||oe.isCompressedArrayTexture)&&(q=!0);const ae=nt.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(ae[C])?G=ae[C][D]:G=ae[C],Y=!0):Ie.isWebGL2&&y.samples>0&&B.useMultisampledRTT(y)===!1?G=nt.get(y).__webglMultisampledFramebuffer:Array.isArray(ae)?G=ae[D]:G=ae,R.copy(y.viewport),F.copy(y.scissor),U=y.scissorTest}else R.copy(Q).multiplyScalar(re).floor(),F.copy(ce).multiplyScalar(re).floor(),U=he;if(Ue.bindFramebuffer(W.FRAMEBUFFER,G)&&Ie.drawBuffers&&k&&Ue.drawBuffers(y,G),Ue.viewport(R),Ue.scissor(F),Ue.setScissorTest(U),Y){const ie=nt.get(y.texture);W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_CUBE_MAP_POSITIVE_X+C,ie.__webglTexture,D)}else if(q){const ie=nt.get(y.texture),oe=C||0;W.framebufferTextureLayer(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,ie.__webglTexture,D||0,oe)}I=-1},this.readRenderTargetPixels=function(y,C,D,k,G,Y,q){if(!(y&&y.isWebGLRenderTarget)){console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.\");return}let Z=nt.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&q!==void 0&&(Z=Z[q]),Z){Ue.bindFramebuffer(W.FRAMEBUFFER,Z);try{const ie=y.texture,oe=ie.format,ae=ie.type;if(oe!==kt&&Ce.convert(oe)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.\");return}const le=ae===cn&&(Le.has(\"EXT_color_buffer_half_float\")||Ie.isWebGL2&&Le.has(\"EXT_color_buffer_float\"));if(ae!==In&&Ce.convert(ae)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ae===jt&&(Ie.isWebGL2||Le.has(\"OES_texture_float\")||Le.has(\"WEBGL_color_buffer_float\")))&&!le){console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.\");return}C>=0&&C<=y.width-k&&D>=0&&D<=y.height-G&&W.readPixels(C,D,k,G,Ce.convert(oe),Ce.convert(ae),Y)}finally{const ie=A!==null?nt.get(A).__webglFramebuffer:null;Ue.bindFramebuffer(W.FRAMEBUFFER,ie)}}},this.copyFramebufferToTexture=function(y,C,D=0){const k=Math.pow(2,-D),G=Math.floor(C.image.width*k),Y=Math.floor(C.image.height*k);B.setTexture2D(C,0),W.copyTexSubImage2D(W.TEXTURE_2D,D,0,0,y.x,y.y,G,Y),Ue.unbindTexture()},this.copyTextureToTexture=function(y,C,D,k=0){const G=C.image.width,Y=C.image.height,q=Ce.convert(D.format),Z=Ce.convert(D.type);B.setTexture2D(D,0),W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,D.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,D.unpackAlignment),C.isDataTexture?W.texSubImage2D(W.TEXTURE_2D,k,y.x,y.y,G,Y,q,Z,C.image.data):C.isCompressedTexture?W.compressedTexSubImage2D(W.TEXTURE_2D,k,y.x,y.y,C.mipmaps[0].width,C.mipmaps[0].height,q,C.mipmaps[0].data):W.texSubImage2D(W.TEXTURE_2D,k,y.x,y.y,q,Z,C.image),k===0&&D.generateMipmaps&&W.generateMipmap(W.TEXTURE_2D),Ue.unbindTexture()},this.copyTextureToTexture3D=function(y,C,D,k,G=0){if(b.isWebGL1Renderer){console.warn(\"THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.\");return}const Y=y.max.x-y.min.x+1,q=y.max.y-y.min.y+1,Z=y.max.z-y.min.z+1,ie=Ce.convert(k.format),oe=Ce.convert(k.type);let ae;if(k.isData3DTexture)B.setTexture3D(k,0),ae=W.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)B.setTexture2DArray(k,0),ae=W.TEXTURE_2D_ARRAY;else{console.warn(\"THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.\");return}W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,k.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,k.unpackAlignment);const le=W.getParameter(W.UNPACK_ROW_LENGTH),de=W.getParameter(W.UNPACK_IMAGE_HEIGHT),be=W.getParameter(W.UNPACK_SKIP_PIXELS),Se=W.getParameter(W.UNPACK_SKIP_ROWS),$e=W.getParameter(W.UNPACK_SKIP_IMAGES),Oe=D.isCompressedTexture?D.mipmaps[G]:D.image;W.pixelStorei(W.UNPACK_ROW_LENGTH,Oe.width),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Oe.height),W.pixelStorei(W.UNPACK_SKIP_PIXELS,y.min.x),W.pixelStorei(W.UNPACK_SKIP_ROWS,y.min.y),W.pixelStorei(W.UNPACK_SKIP_IMAGES,y.min.z),D.isDataTexture||D.isData3DTexture?W.texSubImage3D(ae,G,C.x,C.y,C.z,Y,q,Z,ie,oe,Oe.data):D.isCompressedArrayTexture?(console.warn(\"THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.\"),W.compressedTexSubImage3D(ae,G,C.x,C.y,C.z,Y,q,Z,ie,Oe.data)):W.texSubImage3D(ae,G,C.x,C.y,C.z,Y,q,Z,ie,oe,Oe),W.pixelStorei(W.UNPACK_ROW_LENGTH,le),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,de),W.pixelStorei(W.UNPACK_SKIP_PIXELS,be),W.pixelStorei(W.UNPACK_SKIP_ROWS,Se),W.pixelStorei(W.UNPACK_SKIP_IMAGES,$e),G===0&&k.generateMipmaps&&W.generateMipmap(ae),Ue.unbindTexture()},this.initTexture=function(y){y.isCubeTexture?B.setTextureCube(y,0):y.isData3DTexture?B.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?B.setTexture2DArray(y,0):B.setTexture2D(y,0),Ue.unbindTexture()},this.resetState=function(){E=0,T=0,A=null,Ue.reset(),H.reset()},typeof __THREE_DEVTOOLS__<\"u\"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(\"observe\",{detail:this}))}get coordinateSystem(){return ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Uo?\"display-p3\":\"srgb\",t.unpackColorSpace=xt.workingColorSpace===$s?\"display-p3\":\"srgb\"}get outputEncoding(){return console.warn(\"THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.\"),this.outputColorSpace===Mt?qi:Au}set outputEncoding(e){console.warn(\"THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.\"),this.outputColorSpace=e===qi?Mt:zt}get useLegacyLights(){return console.warn(\"THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.\"),this._useLegacyLights}set useLegacyLights(e){console.warn(\"THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.\"),this._useLegacyLights=e}}class c_ extends bc{}c_.prototype.isWebGL1Renderer=!0;class ir extends Ot{constructor(){super(),this.isScene=!0,this.type=\"Scene\",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,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,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}}class l_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fo,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Vn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(\"THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.\"),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Vn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const _n=new O;class _c{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name=\"\",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix4(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyNormalMatrix(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.transformDirection(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Jn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Jn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Jn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Jn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),n=St(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),n=St(n,this.array),i=St(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),n=St(n,this.array),i=St(i,this.array),s=St(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log(\"THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.\");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new vt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new _c(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(\"THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.\");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Cd=new O,Pd=new Tt,Ld=new Tt,u_=new O,Id=new qe,Ca=new O,vc=new Nn,Dd=new qe,xc=new Ji;class d_ extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=\"SkinnedMesh\",this.bindMode=jl,this.bindMatrix=new qe,this.bindMatrixInverse=new qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new bt),this.boundingBox.makeEmpty();const t=e.getAttribute(\"position\");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingBox.expandByPoint(Ca)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Nn),this.boundingSphere.makeEmpty();const t=e.getAttribute(\"position\");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingSphere.expandByPoint(Ca)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),vc.copy(this.boundingSphere),vc.applyMatrix4(i),e.ray.intersectsSphere(vc)!==!1&&(Dd.copy(i).invert(),xc.copy(e.ray).applyMatrix4(Dd),!(this.boundingBox!==null&&xc.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,xc)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Tt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===jl?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===sp?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn(\"THREE.SkinnedMesh: Unrecognized bindMode: \"+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Pd.fromBufferAttribute(i.attributes.skinIndex,e),Ld.fromBufferAttribute(i.attributes.skinWeight,e),Cd.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=Ld.getComponent(s);if(a!==0){const o=Pd.getComponent(s);Id.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(u_.copy(Cd).applyMatrix4(Id),a)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn(\"THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151.\"),this.applyBoneTransform(e,t)}}class Nd extends Ot{constructor(){super(),this.isBone=!0,this.type=\"Bone\"}}class Vr extends Xt{constructor(e=null,t=1,n=1,i,s,a,o,c,l=yt,u=yt,d,h){super(null,a,o,c,l,u,i,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ud=new qe,h_=new qe;class yc{constructor(e=[],t=[]){this.uuid=Vn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn(\"THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.\"),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:h_;Ud.multiplyMatrices(o,t[s]),Ud.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Vr(t,e,e,kt,jt);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn(\"THREE.Skeleton: No bone found with UUID:\",s),a=new Nd),this.bones.push(a),this.boneInverses.push(new qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:\"Skeleton\",generator:\"Skeleton.toJSON\"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class Mc extends vt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Wr=new qe,Fd=new qe,Pa=[],Od=new bt,f_=new qe,ws=new We,As=new Nn;class p_ extends We{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Mc(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,f_)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new bt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Wr),Od.copy(e.boundingBox).applyMatrix4(Wr),this.boundingBox.union(Od)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Nn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Wr),As.copy(e.boundingSphere).applyMatrix4(Wr),this.boundingSphere.union(As)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ws.geometry=this.geometry,ws.material=this.material,ws.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),As.copy(this.boundingSphere),As.applyMatrix4(n),e.ray.intersectsSphere(As)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Wr),Fd.multiplyMatrices(n,Wr),ws.matrixWorld=Fd,ws.raycast(e,Pa);for(let a=0,o=Pa.length;a<o;a++){const c=Pa[a];c.instanceId=s,c.object=this,t.push(c)}Pa.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Mc(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:\"dispose\"})}}class Rs extends Rn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=\"LineBasicMaterial\",this.color=new Be(16777215),this.map=null,this.linewidth=1,this.linecap=\"round\",this.linejoin=\"round\",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Bd=new O,kd=new O,zd=new qe,Sc=new Ji,La=new Nn;class Ec extends Ot{constructor(e=new mn,t=new Rs){super(),this.isLine=!0,this.type=\"Line\",this.geometry=e,this.material=t,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 i=1,s=t.count;i<s;i++)Bd.fromBufferAttribute(t,i-1),kd.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Bd.distanceTo(kd);e.setAttribute(\"lineDistance\",new Yt(n,1))}else console.warn(\"THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.\");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),La.copy(n.boundingSphere),La.applyMatrix4(i),La.radius+=s,e.ray.intersectsSphere(La)===!1)return;zd.copy(i).invert(),Sc.copy(e.ray).applyMatrix4(zd);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=new O,u=new O,d=new O,h=new O,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){const p=Math.max(0,a.start),_=Math.min(g.count,a.start+a.count);for(let b=p,x=_-1;b<x;b+=f){const E=g.getX(b),T=g.getX(b+1);if(l.fromBufferAttribute(m,E),u.fromBufferAttribute(m,T),Sc.distanceSqToSegment(l,u,h,d)>c)continue;h.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(h);I<e.near||I>e.far||t.push({distance:I,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const p=Math.max(0,a.start),_=Math.min(m.count,a.start+a.count);for(let b=p,x=_-1;b<x;b+=f){if(l.fromBufferAttribute(m,b),u.fromBufferAttribute(m,b+1),Sc.distanceSqToSegment(l,u,h,d)>c)continue;h.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(h);T<e.near||T>e.far||t.push({distance:T,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const Gd=new O,Hd=new O;class Tc extends Ec{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 i=0,s=t.count;i<s;i+=2)Gd.fromBufferAttribute(t,i),Hd.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Gd.distanceTo(Hd);e.setAttribute(\"lineDistance\",new Yt(n,1))}else console.warn(\"THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.\");return this}}class m_ extends Ec{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=\"LineLoop\"}}class jr extends Rn{constructor(e){super(),this.isPointsMaterial=!0,this.type=\"PointsMaterial\",this.color=new Be(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Vd=new qe,wc=new Ji,Ia=new Nn,Da=new O;class Na extends Ot{constructor(e=new mn,t=new jr){super(),this.isPoints=!0,this.type=\"Points\",this.geometry=e,this.material=t,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,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ia.copy(n.boundingSphere),Ia.applyMatrix4(i),Ia.radius+=s,e.ray.intersectsSphere(Ia)===!1)return;Vd.copy(i).invert(),wc.copy(e.ray).applyMatrix4(Vd);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,d=n.attributes.position;if(l!==null){const h=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let g=h,v=f;g<v;g++){const m=l.getX(g);Da.fromBufferAttribute(d,m),Wd(Da,m,c,i,e,t,this)}}else{const h=Math.max(0,a.start),f=Math.min(d.count,a.start+a.count);for(let g=h,v=f;g<v;g++)Da.fromBufferAttribute(d,g),Wd(Da,g,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Wd(r,e,t,n,i,s,a){const o=wc.distanceSqToPoint(r);if(o<t){const c=new O;wc.closestPointToPoint(r,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:a})}}class Ac extends Xt{constructor(e,t,n,i,s,a,o,c,l,u,d,h){super(null,a,o,c,l,u,i,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class jd extends Xt{constructor(e,t,n,i,s,a,o,c,l){super(e,t,n,i,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ua extends mn{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type=\"SphereGeometry\",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,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 u=[],d=new O,h=new O,f=[],g=[],v=[],m=[];for(let p=0;p<=n;p++){const _=[],b=p/n;let x=0;p===0&&a===0?x=.5/t:p===n&&c===Math.PI&&(x=-.5/t);for(let E=0;E<=t;E++){const T=E/t;d.x=-e*Math.cos(i+T*s)*Math.sin(a+b*o),d.y=e*Math.cos(a+b*o),d.z=e*Math.sin(i+T*s)*Math.sin(a+b*o),g.push(d.x,d.y,d.z),h.copy(d).normalize(),v.push(h.x,h.y,h.z),m.push(T+x,1-b),_.push(l++)}u.push(_)}for(let p=0;p<n;p++)for(let _=0;_<t;_++){const b=u[p][_+1],x=u[p][_],E=u[p+1][_],T=u[p+1][_+1];(p!==0||a>0)&&f.push(b,x,T),(p!==n-1||c<Math.PI)&&f.push(x,E,T)}this.setIndex(f),this.setAttribute(\"position\",new Yt(g,3)),this.setAttribute(\"normal\",new Yt(v,3)),this.setAttribute(\"uv\",new Yt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ua(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ci extends Rn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:\"\"},this.type=\"MeshStandardMaterial\",this.color=new Be(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=No,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.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.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 vn extends Ci{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 $t(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 Be(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Be(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Be(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._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 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.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 Xd extends Rn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=\"MeshPhongMaterial\",this.color=new Be(16777215),this.specular=new Be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=No,this.normalScale=new Ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=xo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=\"round\",this.wireframeLinejoin=\"round\",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}function Fa(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT==\"number\"?new e(r):Array.prototype.slice.call(r)}function g_(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function b_(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function qd(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[a++]=r[o+c]}return i}function Yd(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}class Cs{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let c=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=s,s=t[--n-1],e>=s)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error(\"call to abstract method\")}intervalChanged_(){}}class __ extends Cs{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Su,endingEnd:Su}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Eu:s=e,o=2*t-n;break;case Tu:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Eu:a=e,c=2*n-t;break;case Tu:a=1,c=n+i[1]-i[0];break;default:a=e-1,c=t}const l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),v=g*g,m=v*g,p=-h*m+2*h*v-h*g,_=(1+h)*m+(-1.5-2*h)*v+(-.5+h)*g+1,b=(-1-f)*m+(1.5+f)*v+.5*g,x=f*m-f*v;for(let E=0;E!==o;++E)s[E]=p*a[u+E]+_*a[l+E]+b*a[c+E]+x*a[d+E];return s}}class v_ extends Cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,u=(n-t)/(i-t),d=1-u;for(let h=0;h!==o;++h)s[h]=a[l+h]*d+a[c+h]*u;return s}}class x_ extends Cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ti{constructor(e,t,n,i){if(e===void 0)throw new Error(\"THREE.KeyframeTrack: track name is undefined\");if(t===void 0||t.length===0)throw new Error(\"THREE.KeyframeTrack: no keyframes in track named \"+e);this.name=e,this.times=Fa(t,this.TimeBufferType),this.values=Fa(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Fa(e.times,Array),values:Fa(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new x_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new v_(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new __(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case br:t=this.InterpolantFactoryMethodDiscrete;break;case Xi:t=this.InterpolantFactoryMethodLinear;break;case Io:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n=\"unsupported interpolation for \"+this.ValueTypeName+\" keyframe track named \"+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn(\"THREE.KeyframeTrack:\",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return br;case this.InterpolantFactoryMethodLinear:return Xi;case this.InterpolantFactoryMethodSmooth:return Io}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(\"THREE.KeyframeTrack: Invalid value size in track.\",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error(\"THREE.KeyframeTrack: Track is empty.\",this),e=!1);let a=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c==\"number\"&&isNaN(c)){console.error(\"THREE.KeyframeTrack: Time is not a valid number.\",this,o,c),e=!1;break}if(a!==null&&a>c){console.error(\"THREE.KeyframeTrack: Out of order keys.\",this,o,c,a),e=!1;break}a=c}if(i!==void 0&&g_(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error(\"THREE.KeyframeTrack: Value is not a valid number.\",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Io,s=e.length-1;let a=1;for(let o=1;o<s;++o){let c=!1;const l=e[o],u=e[o+1];if(l!==u&&(o!==1||l!==e[0]))if(i)c=!0;else{const d=o*n,h=d-n,f=d+n;for(let g=0;g!==n;++g){const v=t[d+g];if(v!==t[h+g]||v!==t[f+g]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const d=o*n,h=a*n;for(let f=0;f!==n;++f)t[h+f]=t[d+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ti.prototype.TimeBufferType=Float32Array,ti.prototype.ValueBufferType=Float32Array,ti.prototype.DefaultInterpolation=Xi;class Xr extends ti{}Xr.prototype.ValueTypeName=\"bool\",Xr.prototype.ValueBufferType=Array,Xr.prototype.DefaultInterpolation=br,Xr.prototype.InterpolantFactoryMethodLinear=void 0,Xr.prototype.InterpolantFactoryMethodSmooth=void 0;class Kd extends ti{}Kd.prototype.ValueTypeName=\"color\";class qr extends ti{}qr.prototype.ValueTypeName=\"number\";class y_ extends Cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let u=l+o;l!==u;l+=4)Dn.slerpFlat(s,0,a,l-o,a,l,c);return s}}class rr extends ti{InterpolantFactoryMethodLinear(e){return new y_(this.times,this.values,this.getValueSize(),e)}}rr.prototype.ValueTypeName=\"quaternion\",rr.prototype.DefaultInterpolation=Xi,rr.prototype.InterpolantFactoryMethodSmooth=void 0;class Yr extends ti{}Yr.prototype.ValueTypeName=\"string\",Yr.prototype.ValueBufferType=Array,Yr.prototype.DefaultInterpolation=br,Yr.prototype.InterpolantFactoryMethodLinear=void 0,Yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Kr extends ti{}Kr.prototype.ValueTypeName=\"vector\";class M_{constructor(e,t=-1,n,i=up){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Vn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(E_(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(ti.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const u=b_(c);c=qd(c,1,u),l=qd(l,1,u),!i&&c[0]===0&&(c.push(s),l.push(l[0])),a.push(new qr(\".morphTargetInfluences[\"+t[o].name+\"]\",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\\w-]*?)([\\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],u=l.name.match(s);if(u&&u.length>1){const d=u[1];let h=i[d];h||(i[d]=h=[]),h.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error(\"THREE.AnimationClip: No animation in JSONLoader data.\"),null;const n=function(d,h,f,g,v){if(f.length!==0){const m=[],p=[];Yd(f,m,p,g),m.length!==0&&v.push(new d(h,m,p))}},i=[],s=e.name||\"default\",a=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let d=0;d<l.length;d++){const h=l[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const f={};let g;for(g=0;g<h.length;g++)if(h[g].morphTargets)for(let v=0;v<h[g].morphTargets.length;v++)f[h[g].morphTargets[v]]=-1;for(const v in f){const m=[],p=[];for(let _=0;_!==h[g].morphTargets.length;++_){const b=h[g];m.push(b.time),p.push(b.morphTarget===v?1:0)}i.push(new qr(\".morphTargetInfluence[\"+v+\"]\",m,p))}c=f.length*a}else{const f=\".bones[\"+t[d].name+\"]\";n(Kr,f+\".position\",h,\"pos\",i),n(rr,f+\".quaternion\",h,\"rot\",i),n(Kr,f+\".scale\",h,\"scl\",i)}}return i.length===0?null:new this(s,c,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function S_(r){switch(r.toLowerCase()){case\"scalar\":case\"double\":case\"float\":case\"number\":case\"integer\":return qr;case\"vector\":case\"vector2\":case\"vector3\":case\"vector4\":return Kr;case\"color\":return Kd;case\"quaternion\":return rr;case\"bool\":case\"boolean\":return Xr;case\"string\":return Yr}throw new Error(\"THREE.KeyframeTrack: Unsupported typeName: \"+r)}function E_(r){if(r.type===void 0)throw new Error(\"THREE.KeyframeTrack: track type undefined, can not parse\");const e=S_(r.type);if(r.times===void 0){const t=[],n=[];Yd(r.keys,t,n,\"value\"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const Pi={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class T_{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){o++,s===!1&&i.onStart!==void 0&&i.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,i.onProgress!==void 0&&i.onProgress(u,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,d){return l.push(u,d),this},this.removeHandler=function(u){const d=l.indexOf(u);return d!==-1&&l.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=l.length;d<h;d+=2){const f=l[d],g=l[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return g}return null}}}const Zd=new T_;class Yn{constructor(e){this.manager=e!==void 0?e:Zd,this.crossOrigin=\"anonymous\",this.withCredentials=!1,this.path=\"\",this.resourcePath=\"\",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Yn.DEFAULT_MATERIAL_NAME=\"__DEFAULT\";const fi={};class w_ extends Error{constructor(e,t){super(e),this.response=t}}class Li extends Yn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=\"\"),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Pi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(fi[e]!==void 0){fi[e].push({onLoad:t,onProgress:n,onError:i});return}fi[e]=[],fi[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?\"include\":\"same-origin\"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn(\"THREE.FileLoader: HTTP Status 0 received.\"),typeof ReadableStream>\"u\"||l.body===void 0||l.body.getReader===void 0)return l;const u=fi[e],d=l.body.getReader(),h=l.headers.get(\"Content-Length\")||l.headers.get(\"X-File-Size\"),f=h?parseInt(h):0,g=f!==0;let v=0;const m=new ReadableStream({start(p){_();function _(){d.read().then(({done:b,value:x})=>{if(b)p.close();else{v+=x.byteLength;const E=new ProgressEvent(\"progress\",{lengthComputable:g,loaded:v,total:f});for(let T=0,A=u.length;T<A;T++){const I=u[T];I.onProgress&&I.onProgress(E)}p.enqueue(x),_()}})}}});return new Response(m)}else throw new w_(`fetch for \"${l.url}\" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case\"arraybuffer\":return l.arrayBuffer();case\"blob\":return l.blob();case\"document\":return l.text().then(u=>new DOMParser().parseFromString(u,o));case\"json\":return l.json();default:if(o===void 0)return l.text();{const d=/charset=\"?([^;\"\\s]*)\"?/i.exec(o),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(g=>f.decode(g))}}}).then(l=>{Pi.add(e,l);const u=fi[e];delete fi[e];for(let d=0,h=u.length;d<h;d++){const f=u[d];f.onLoad&&f.onLoad(l)}}).catch(l=>{const u=fi[e];if(u===void 0)throw this.manager.itemError(e),l;delete fi[e];for(let d=0,h=u.length;d<h;d++){const f=u[d];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class A_ extends Yn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Pi.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=_s(\"img\");function c(){u(),Pi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(d){u(),i&&i(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener(\"load\",c,!1),o.removeEventListener(\"error\",l,!1)}return o.addEventListener(\"load\",c,!1),o.addEventListener(\"error\",l,!1),e.slice(0,5)!==\"data:\"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class $d extends Yn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Vr,o=new Li(this.manager);return o.setResponseType(\"arraybuffer\"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}l.image!==void 0?a.image=l.image:l.data!==void 0&&(a.image.width=l.width,a.image.height=l.height,a.image.data=l.data),a.wrapS=l.wrapS!==void 0?l.wrapS:gn,a.wrapT=l.wrapT!==void 0?l.wrapT:gn,a.magFilter=l.magFilter!==void 0?l.magFilter:At,a.minFilter=l.minFilter!==void 0?l.minFilter:At,a.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0?a.colorSpace=l.colorSpace:l.encoding!==void 0&&(a.encoding=l.encoding),l.flipY!==void 0&&(a.flipY=l.flipY),l.format!==void 0&&(a.format=l.format),l.type!==void 0&&(a.type=l.type),l.mipmaps!==void 0&&(a.mipmaps=l.mipmaps,a.minFilter=si),l.mipmapCount===1&&(a.minFilter=At),l.generateMipmaps!==void 0&&(a.generateMipmaps=l.generateMipmaps),a.needsUpdate=!0,t&&t(a,l)},n,i),a}}class Jd extends Yn{constructor(e){super(e)}load(e,t,n,i){const s=new Xt,a=new A_(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Rc extends Ot{constructor(e,t=1){super(),this.isLight=!0,this.type=\"Light\",this.color=new Be(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const Cc=new qe,Qd=new O,eh=new O;class Pc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ve(512,512),this.map=null,this.mapPass=null,this.matrix=new qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oc,this._frameExtents=new Ve(1,1),this._viewportCount=1,this._viewports=[new Tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Qd.setFromMatrixPosition(e.matrixWorld),t.position.copy(Qd),eh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(eh),t.updateMatrixWorld(),Cc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cc),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cc)}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.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return 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}}class R_ extends Pc{constructor(){super(new un(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=vr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class C_ extends Rc{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type=\"SpotLight\",this.position.copy(Ot.DEFAULT_UP),this.updateMatrix(),this.target=new Ot,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new R_}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const th=new qe,Ps=new O,Lc=new O;class P_ extends Pc{constructor(){super(new un(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ve(4,2),this._viewportCount=6,this._viewports=[new Tt(2,1,1,1),new Tt(0,1,1,1),new Tt(3,1,1,1),new Tt(1,1,1,1),new Tt(3,0,1,1),new Tt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ps.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ps),Lc.copy(n.position),Lc.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Lc),n.updateMatrixWorld(),i.makeTranslation(-Ps.x,-Ps.y,-Ps.z),th.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(th)}}class L_ extends Rc{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type=\"PointLight\",this.distance=n,this.decay=i,this.shadow=new P_}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class I_ extends Pc{constructor(){super(new cc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ic extends Rc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=\"DirectionalLight\",this.position.copy(Ot.DEFAULT_UP),this.updateMatrix(),this.target=new Ot,this.shadow=new I_}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Zr{static decodeText(e){if(typeof TextDecoder<\"u\")return new TextDecoder().decode(e);let t=\"\";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf(\"/\");return t===-1?\"./\":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!=\"string\"||e===\"\"?\"\":(/^https?:\\/\\//i.test(t)&&/^\\//.test(e)&&(t=t.replace(/(^https?:\\/\\/[^\\/]+).*/i,\"$1\")),/^(https?:)?\\/\\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class D_ extends Yn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>\"u\"&&console.warn(\"THREE.ImageBitmapLoader: createImageBitmap() not supported.\"),typeof fetch>\"u\"&&console.warn(\"THREE.ImageBitmapLoader: fetch() not supported.\"),this.options={premultiplyAlpha:\"none\"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=\"\"),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Pi.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin===\"anonymous\"?\"same-origin\":\"include\",o.headers=this.requestHeader;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:\"none\"}))}).then(function(l){return Pi.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){i&&i(l),Pi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Pi.add(e,c),s.manager.itemStart(e)}}const Dc=\"\\\\[\\\\]\\\\.:\\\\/\",N_=new RegExp(\"[\"+Dc+\"]\",\"g\"),Nc=\"[^\"+Dc+\"]\",U_=\"[^\"+Dc.replace(\"\\\\.\",\"\")+\"]\",F_=/((?:WC+[\\/:])*)/.source.replace(\"WC\",Nc),O_=/(WCOD+)?/.source.replace(\"WCOD\",U_),B_=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace(\"WC\",Nc),k_=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace(\"WC\",Nc),z_=new RegExp(\"^\"+F_+O_+B_+k_+\"$\"),G_=[\"material\",\"materials\",\"bones\",\"map\"];class H_{constructor(e,t,n){const i=n||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class gt{constructor(e,t,n){this.path=t,this.parsedPath=n||gt.parseTrackName(t),this.node=gt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new gt.Composite(e,t,n):new gt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\\s/g,\"_\").replace(N_,\"\")}static parseTrackName(e){const t=z_.exec(e);if(t===null)throw new Error(\"PropertyBinding: Cannot parse trackName: \"+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(\".\");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);G_.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error(\"PropertyBinding: can not parse propertyName from trackName: \"+e);return n}static findNode(e,t){if(t===void 0||t===\"\"||t===\".\"||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=gt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn(\"THREE.PropertyBinding: No target node found for track: \"+this.path+\".\");return}if(n){let l=t.objectIndex;switch(n){case\"materials\":if(!e.material){console.error(\"THREE.PropertyBinding: Can not bind to material as node does not have a material.\",this);return}if(!e.material.materials){console.error(\"THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.\",this);return}e=e.material.materials;break;case\"bones\":if(!e.skeleton){console.error(\"THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.\",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case\"map\":if(\"map\"in e){e=e.map;break}if(!e.material){console.error(\"THREE.PropertyBinding: Can not bind to material as node does not have a material.\",this);return}if(!e.material.map){console.error(\"THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.\",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error(\"THREE.PropertyBinding: Can not bind to objectName of node undefined.\",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error(\"THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.\",this,e);return}e=e[l]}}const a=e[i];if(a===void 0){const l=t.nodeName;console.error(\"THREE.PropertyBinding: Trying to update property for track: \"+l+\".\"+i+\" but it wasn't found.\",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(i===\"morphTargetInfluences\"){if(!e.geometry){console.error(\"THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.\",this);return}if(!e.geometry.morphAttributes){console.error(\"THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.\",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}gt.Composite=H_,gt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},gt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},gt.prototype.GetterByBindingType=[gt.prototype._getValue_direct,gt.prototype._getValue_array,gt.prototype._getValue_arrayElement,gt.prototype._getValue_toArray],gt.prototype.SetterByBindingTypeAndVersioning=[[gt.prototype._setValue_direct,gt.prototype._setValue_direct_setNeedsUpdate,gt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_array,gt.prototype._setValue_array_setNeedsUpdate,gt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_arrayElement,gt.prototype._setValue_arrayElement_setNeedsUpdate,gt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_fromArray,gt.prototype._setValue_fromArray_setNeedsUpdate,gt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Uc{constructor(e){this.value=e}clone(){return new Uc(this.value.clone===void 0?this.value:this.value.clone())}}class V_{constructor(e,t,n=0,i=1/0){this.ray=new Ji(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Zo,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error(\"THREE.Raycaster: Unsupported camera type: \"+t.type)}intersectObject(e,t=!0,n=[]){return Fc(e,this,n,t),n.sort(nh),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Fc(e[i],this,n,t);return n.sort(nh),n}}function nh(r,e){return r.distance-e.distance}function Fc(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,a=i.length;s<a;s++)Fc(i[s],e,t,!0)}}class ih{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}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=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),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($t(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const rh=new O,Oa=new O;class pi{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){rh.subVectors(e,this.start),Oa.subVectors(this.end,this.start);const n=Oa.dot(Oa);let s=Oa.dot(rh)/n;return t&&(s=$t(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<\"u\"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(\"register\",{detail:{revision:ds}})),typeof window<\"u\"&&(window.__THREE__?console.warn(\"WARNING: Multiple instances of Three.js being imported.\"):window.__THREE__=ds);function sh(r,e){if(e===dp)return console.warn(\"THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.\"),r;if(e===Do||e===wu){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute(\"position\");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);r.setIndex(a),t=r.getIndex()}else return console.error(\"THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.\"),r}const n=t.count-2,i=[];if(e===Do)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error(\"THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.\");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error(\"THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:\",e),r}class W_ extends Yn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new K_(t)}),this.register(function(t){return new rv(t)}),this.register(function(t){return new sv(t)}),this.register(function(t){return new av(t)}),this.register(function(t){return new $_(t)}),this.register(function(t){return new J_(t)}),this.register(function(t){return new Q_(t)}),this.register(function(t){return new ev(t)}),this.register(function(t){return new Y_(t)}),this.register(function(t){return new tv(t)}),this.register(function(t){return new Z_(t)}),this.register(function(t){return new iv(t)}),this.register(function(t){return new nv(t)}),this.register(function(t){return new X_(t)}),this.register(function(t){return new ov(t)}),this.register(function(t){return new cv(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!==\"\")a=this.resourcePath;else if(this.path!==\"\"){const l=Zr.extractUrlBase(e);a=Zr.resolveURL(l,this.path)}else a=Zr.extractUrlBase(e);this.manager.itemStart(e);const o=function(l){i?i(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Li(this.manager);c.setPath(this.path),c.setResponseType(\"arraybuffer\"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,a,function(u){t(u),s.manager.itemEnd(e)},o)}catch(u){o(u)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: \"MSFT_texture_dds\" no longer supported. Please update to \"KHR_texture_basisu\".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const a={},o={},c=new TextDecoder;if(typeof e==\"string\")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===ah){try{a[dt.KHR_BINARY_GLTF]=new lv(e)}catch(d){i&&i(d);return}s=JSON.parse(a[dt.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error(\"THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.\"));return}const l=new Mv(s,{path:t||this.resourcePath||\"\",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](l);d.name||console.error(\"THREE.GLTFLoader: Invalid plugin found: missing name\"),o[d.name]=d,a[d.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){const d=s.extensionsUsed[u],h=s.extensionsRequired||[];switch(d){case dt.KHR_MATERIALS_UNLIT:a[d]=new q_;break;case dt.KHR_DRACO_MESH_COMPRESSION:a[d]=new uv(s,this.dracoLoader);break;case dt.KHR_TEXTURE_TRANSFORM:a[d]=new dv;break;case dt.KHR_MESH_QUANTIZATION:a[d]=new hv;break;default:h.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension \"'+d+'\".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function j_(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const dt={KHR_BINARY_GLTF:\"KHR_binary_glTF\",KHR_DRACO_MESH_COMPRESSION:\"KHR_draco_mesh_compression\",KHR_LIGHTS_PUNCTUAL:\"KHR_lights_punctual\",KHR_MATERIALS_CLEARCOAT:\"KHR_materials_clearcoat\",KHR_MATERIALS_IOR:\"KHR_materials_ior\",KHR_MATERIALS_SHEEN:\"KHR_materials_sheen\",KHR_MATERIALS_SPECULAR:\"KHR_materials_specular\",KHR_MATERIALS_TRANSMISSION:\"KHR_materials_transmission\",KHR_MATERIALS_IRIDESCENCE:\"KHR_materials_iridescence\",KHR_MATERIALS_ANISOTROPY:\"KHR_materials_anisotropy\",KHR_MATERIALS_UNLIT:\"KHR_materials_unlit\",KHR_MATERIALS_VOLUME:\"KHR_materials_volume\",KHR_TEXTURE_BASISU:\"KHR_texture_basisu\",KHR_TEXTURE_TRANSFORM:\"KHR_texture_transform\",KHR_MESH_QUANTIZATION:\"KHR_mesh_quantization\",KHR_MATERIALS_EMISSIVE_STRENGTH:\"KHR_materials_emissive_strength\",EXT_MATERIALS_BUMP:\"EXT_materials_bump\",EXT_TEXTURE_WEBP:\"EXT_texture_webp\",EXT_TEXTURE_AVIF:\"EXT_texture_avif\",EXT_MESHOPT_COMPRESSION:\"EXT_meshopt_compression\",EXT_MESH_GPU_INSTANCING:\"EXT_mesh_gpu_instancing\"};class X_{constructor(e){this.parser=e,this.name=dt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n=\"light:\"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let l;const u=new Be(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],zt);const d=c.range!==void 0?c.range:0;switch(c.type){case\"directional\":l=new Ic(u),l.target.position.set(0,0,-1),l.add(l.target);break;case\"point\":l=new L_(u),l.distance=d;break;case\"spot\":l=new C_(u),l.distance=d,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error(\"THREE.GLTFLoader: Unexpected light type: \"+c.type)}return l.position.set(0,0,0),l.decay=2,Di(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||\"light_\"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e===\"light\")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}let q_=class{constructor(){this.name=dt.KHR_MATERIALS_UNLIT}getMaterialType(){return Gt}extendParams(e,t,n){const i=[];e.color=new Be(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],zt),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,\"map\",s.baseColorTexture,Mt))}return Promise.all(i)}},Y_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},K_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,\"clearcoatMap\",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,\"clearcoatRoughnessMap\",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,\"clearcoatNormalMap\",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ve(o,o)}return Promise.all(s)}},Z_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,\"iridescenceMap\",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,\"iridescenceThicknessMap\",a.iridescenceThicknessTexture)),Promise.all(s)}},$_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new Be(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],zt)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,\"sheenColorMap\",a.sheenColorTexture,Mt)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,\"sheenRoughnessMap\",a.sheenRoughnessTexture)),Promise.all(s)}},J_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(t,\"transmissionMap\",a.transmissionTexture)),Promise.all(s)}},Q_=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(t,\"thicknessMap\",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new Be().setRGB(o[0],o[1],o[2],zt),Promise.all(s)}},ev=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},tv=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(t,\"specularIntensityMap\",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new Be().setRGB(o[0],o[1],o[2],zt),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,\"specularColorMap\",a.specularColorTexture,Mt)),Promise.all(s)}},nv=class{constructor(e){this.parser=e,this.name=dt.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(t,\"bumpMap\",a.bumpTexture)),Promise.all(s)}},iv=class{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:vn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,\"anisotropyMap\",a.anisotropyTexture)),Promise.all(s)}};class rv{constructor(e){this.parser=e,this.name=dt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error(\"THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures\");return null}return t.loadTextureImage(e,s.source,a)}}class sv{constructor(e){this.parser=e,this.name=dt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,a.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error(\"THREE.GLTFLoader: WebP required by asset but unsupported.\");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src=\"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA\",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class av{constructor(e){this.parser=e,this.name=dt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,a.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error(\"THREE.GLTFLoader: AVIF required by asset but unsupported.\");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src=\"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=\",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ov{constructor(e){this.name=dt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency(\"buffer\",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error(\"THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files\");return null}return s.then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,u=i.count,d=i.byteStride,h=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(u,d,h,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(u*d);return a.decodeGltfBuffer(new Uint8Array(f),u,d,h,i.mode,i.filter),f})})}else return null}}let cv=class{constructor(e){this.name=dt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Fn.TRIANGLES&&l.mode!==Fn.TRIANGLE_STRIP&&l.mode!==Fn.TRIANGLE_FAN&&l.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency(\"accessor\",a[l]).then(u=>(c[l]=u,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const u=l.pop(),d=u.isGroup?u.children:[u],h=l[0].count,f=[];for(const g of d){const v=new qe,m=new O,p=new Dn,_=new O(1,1,1),b=new p_(g.geometry,g.material,h);for(let x=0;x<h;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&_.fromBufferAttribute(c.SCALE,x),b.setMatrixAt(x,v.compose(m,p,_));for(const x in c)if(x===\"_COLOR_0\"){const E=c[x];b.instanceColor=new Mc(E.array,E.itemSize,E.normalized)}else x!==\"TRANSLATION\"&&x!==\"ROTATION\"&&x!==\"SCALE\"&&g.geometry.setAttribute(x,c[x]);Ot.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),f.push(b)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}};const ah=\"glTF\",Ls=12,oh={JSON:1313821514,BIN:5130562};class lv{constructor(e){this.name=dt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ls),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ah)throw new Error(\"THREE.GLTFLoader: Unsupported glTF-Binary header.\");if(this.header.version<2)throw new Error(\"THREE.GLTFLoader: Legacy binary file detected.\");const i=this.header.length-Ls,s=new DataView(e,Ls);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const c=s.getUint32(a,!0);if(a+=4,c===oh.JSON){const l=new Uint8Array(e,Ls+a,o);this.content=n.decode(l)}else if(c===oh.BIN){const l=Ls+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error(\"THREE.GLTFLoader: JSON content not found.\")}}class uv{constructor(e,t){if(!t)throw new Error(\"THREE.GLTFLoader: No DRACOLoader instance provided.\");this.name=dt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},c={},l={};for(const u in a){const d=Bc[u]||u.toLowerCase();o[d]=a[u]}for(const u in e.attributes){const d=Bc[u]||u.toLowerCase();if(a[u]!==void 0){const h=n.accessors[e.attributes[u]],f=$r[h.componentType];l[d]=f.name,c[d]=h.normalized===!0}}return t.getDependency(\"bufferView\",s).then(function(u){return new Promise(function(d,h){i.decodeDracoFile(u,function(f){for(const g in f.attributes){const v=f.attributes[g],m=c[g];m!==void 0&&(v.normalized=m)}d(f)},o,l,zt,h)})})}}class dv{constructor(){this.name=dt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class hv{constructor(){this.name=dt.KHR_MESH_QUANTIZATION}}class ch extends Cs{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,u=i-t,d=(n-t)/u,h=d*d,f=h*d,g=e*l,v=g-l,m=-2*f+3*h,p=f-h,_=1-m,b=p-h+d;for(let x=0;x!==o;x++){const E=a[v+x+o],T=a[v+x+c]*u,A=a[g+x+o],I=a[g+x]*u;s[x]=_*E+b*T+m*A+p*I}return s}}const fv=new Dn;class pv extends ch{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return fv.fromArray(s).normalize().toArray(s),s}}const Fn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},$r={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},lh={9728:yt,9729:At,9984:Ys,9985:So,9986:fs,9987:si},uh={33071:gn,33648:hs,10497:Si},Oc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Bc={POSITION:\"position\",NORMAL:\"normal\",TANGENT:\"tangent\",TEXCOORD_0:\"uv\",TEXCOORD_1:\"uv1\",TEXCOORD_2:\"uv2\",TEXCOORD_3:\"uv3\",COLOR_0:\"color\",WEIGHTS_0:\"skinWeight\",JOINTS_0:\"skinIndex\"},Ii={scale:\"scale\",translation:\"position\",rotation:\"quaternion\",weights:\"morphTargetInfluences\"},mv={CUBICSPLINE:void 0,LINEAR:Xi,STEP:br},kc={OPAQUE:\"OPAQUE\",MASK:\"MASK\",BLEND:\"BLEND\"};function gv(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Ci({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Mn})),r.DefaultMaterial}function sr(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Di(r,e){e.extras!==void 0&&(typeof e.extras==\"object\"?Object.assign(r.userData,e.extras):console.warn(\"THREE.GLTFLoader: Ignoring primitive type .extras, \"+e.extras))}function bv(r,e,t){let n=!1,i=!1,s=!1;for(let l=0,u=e.length;l<u;l++){const d=e[l];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const a=[],o=[],c=[];for(let l=0,u=e.length;l<u;l++){const d=e[l];if(n){const h=d.POSITION!==void 0?t.getDependency(\"accessor\",d.POSITION):r.attributes.position;a.push(h)}if(i){const h=d.NORMAL!==void 0?t.getDependency(\"accessor\",d.NORMAL):r.attributes.normal;o.push(h)}if(s){const h=d.COLOR_0!==void 0?t.getDependency(\"accessor\",d.COLOR_0):r.attributes.color;c.push(h)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){const u=l[0],d=l[1],h=l[2];return n&&(r.morphAttributes.position=u),i&&(r.morphAttributes.normal=d),s&&(r.morphAttributes.color=h),r.morphTargetsRelative=!0,r})}function _v(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn(\"THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.\")}}function vv(r){let e;const t=r.extensions&&r.extensions[dt.KHR_DRACO_MESH_COMPRESSION];if(t?e=\"draco:\"+t.bufferView+\":\"+t.indices+\":\"+zc(t.attributes):e=r.indices+\":\"+zc(r.attributes)+\":\"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=\":\"+zc(r.targets[n]);return e}function zc(r){let e=\"\";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+\":\"+r[t[n]]+\";\";return e}function Gc(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error(\"THREE.GLTFLoader: Unsupported normalized accessor component type.\")}}function xv(r){return r.search(/\\.jpe?g($|\\?)/i)>0||r.search(/^data\\:image\\/jpeg/)===0?\"image/jpeg\":r.search(/\\.webp($|\\?)/i)>0||r.search(/^data\\:image\\/webp/)===0?\"image/webp\":\"image/png\"}const yv=new qe;class Mv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new j_,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<\"u\"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf(\"Firefox\")>-1,s=i?navigator.userAgent.match(/Firefox\\/([0-9]+)\\./)[1]:-1),typeof createImageBitmap>\"u\"||n||i&&s<98?this.textureLoader=new Jd(this.options.manager):this.textureLoader=new D_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Li(this.options.manager),this.fileLoader.setResponseType(\"arraybuffer\"),this.options.crossOrigin===\"use-credentials\"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(\"scene\"),n.getDependencies(\"animation\"),n.getDependencies(\"camera\")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return sr(s,o,i),Di(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const a=t[i].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,u]of a.children.entries())s(u,o.children[l])};return s(n,i),i.name+=\"_instance_\"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+\":\"+t;let i=this.cache.get(n);if(!i){switch(e){case\"scene\":i=this.loadScene(t);break;case\"node\":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case\"mesh\":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case\"accessor\":i=this.loadAccessor(t);break;case\"bufferView\":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case\"buffer\":i=this.loadBuffer(t);break;case\"material\":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case\"texture\":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case\"skin\":i=this.loadSkin(t);break;case\"animation\":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case\"camera\":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error(\"Unknown type: \"+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e===\"mesh\"?\"es\":\"s\")]||[];t=Promise.all(i.map(function(s,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==\"arraybuffer\")throw new Error(\"THREE.GLTFLoader: \"+t.type+\" buffer type is not supported.\");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[dt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){n.load(Zr.resolveURL(t.uri,i.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer \"'+t.uri+'\".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency(\"buffer\",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Oc[i.type],o=$r[i.componentType],c=i.normalized===!0,l=new o(i.count*a);return Promise.resolve(new vt(l,a,c))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency(\"bufferView\",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency(\"bufferView\",i.sparse.indices.bufferView)),s.push(this.getDependency(\"bufferView\",i.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],c=Oc[i.type],l=$r[i.componentType],u=l.BYTES_PER_ELEMENT,d=u*c,h=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let v,m;if(f&&f!==d){const p=Math.floor(h/f),_=\"InterleavedBuffer:\"+i.bufferView+\":\"+i.componentType+\":\"+p+\":\"+i.count;let b=t.cache.get(_);b||(v=new l(o,p*f,i.count*f/u),b=new l_(v,f/u),t.cache.add(_,b)),m=new _c(b,c,h%f/u,g)}else o===null?v=new l(i.count*c):v=new l(o,h,i.count*c),m=new vt(v,c,g);if(i.sparse!==void 0){const p=Oc.SCALAR,_=$r[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,E=new _(a[1],b,i.sparse.count*p),T=new l(a[2],x,i.sparse.count*c);o!==null&&(m=new vt(m.array.slice(),m.itemSize,m.normalized));for(let A=0,I=E.length;A<I;A++){const S=E[A];if(m.setX(S,T[A*c]),c>=2&&m.setY(S,T[A*c+1]),c>=3&&m.setZ(S,T[A*c+2]),c>=4&&m.setW(S,T[A*c+3]),c>=5)throw new Error(\"THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.\")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,a=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+\":\"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=a.name||o.name||\"\",u.name===\"\"&&typeof o.uri==\"string\"&&o.uri.startsWith(\"data:image/\")===!1&&(u.name=o.uri);const h=(s.samplers||{})[a.sampler]||{};return u.magFilter=lh[h.magFilter]||At,u.minFilter=lh[h.minFilter]||si,u.wrapS=uh[h.wrapS]||Si,u.wrapT=uh[h.wrapT]||Si,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const a=i.images[e],o=self.URL||self.webkitURL;let c=a.uri||\"\",l=!1;if(a.bufferView!==void 0)c=n.getDependency(\"bufferView\",a.bufferView).then(function(d){l=!0;const h=new Blob([d],{type:a.mimeType});return c=o.createObjectURL(h),c});else if(a.uri===void 0)throw new Error(\"THREE.GLTFLoader: Image \"+e+\" is missing URI and bufferView\");const u=Promise.resolve(c).then(function(d){return new Promise(function(h,f){let g=h;t.isImageBitmapLoader===!0&&(g=function(v){const m=new Xt(v);m.needsUpdate=!0,h(m)}),t.load(Zr.resolveURL(d,s.path),g,void 0,f)})}).then(function(d){return l===!0&&o.revokeObjectURL(c),d.userData.mimeType=a.mimeType||xv(a.uri),d}).catch(function(d){throw console.error(\"THREE.GLTFLoader: Couldn't load texture\",c),d});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency(\"texture\",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[dt.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[dt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(a);a=s.extensions[dt.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,c)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o=\"PointsMaterial:\"+n.uuid;let c=this.cache.get(o);c||(c=new jr,Rn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o=\"LineBasicMaterial:\"+n.uuid;let c=this.cache.get(o);c||(c=new Rs,Rn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(i||s||a){let o=\"ClonedMaterial:\"+n.uuid+\":\";i&&(o+=\"derivative-tangents:\"),s&&(o+=\"vertex-colors:\"),a&&(o+=\"flat-shading:\");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),a&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Ci}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let a;const o={},c=s.extensions||{},l=[];if(c[dt.KHR_MATERIALS_UNLIT]){const d=i[dt.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),l.push(d.extendParams(o,s,t))}else{const d=s.pbrMetallicRoughness||{};if(o.color=new Be(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const h=d.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],zt),o.opacity=h[3]}d.baseColorTexture!==void 0&&l.push(t.assignTexture(o,\"map\",d.baseColorTexture,Mt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,\"metalnessMap\",d.metallicRoughnessTexture)),l.push(t.assignTexture(o,\"roughnessMap\",d.metallicRoughnessTexture))),a=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=wt);const u=s.alphaMode||kc.OPAQUE;if(u===kc.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===kc.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Gt&&(l.push(t.assignTexture(o,\"normalMap\",s.normalTexture)),o.normalScale=new Ve(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;o.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&a!==Gt&&(l.push(t.assignTexture(o,\"aoMap\",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Gt){const d=s.emissiveFactor;o.emissive=new Be().setRGB(d[0],d[1],d[2],zt)}return s.emissiveTexture!==void 0&&a!==Gt&&l.push(t.assignTexture(o,\"emissiveMap\",s.emissiveTexture,Mt)),Promise.all(l).then(function(){const d=new a(o);return s.name&&(d.name=s.name),Di(d,s),t.associations.set(d,{materials:e}),s.extensions&&sr(i,d,s),d})}createUniqueName(e){const t=gt.sanitizeNodeName(e||\"\");return t in this.nodeNamesUsed?t+\"_\"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[dt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return dh(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],u=vv(l),d=i[u];if(d)a.push(d.promise);else{let h;l.extensions&&l.extensions[dt.KHR_DRACO_MESH_COMPRESSION]?h=s(l):h=dh(new mn,l,t),i[u]={primitive:l,promise:h},a.push(h)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const u=a[c].material===void 0?gv(this.cache):this.getDependency(\"material\",a[c].material);o.push(u)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),u=c[c.length-1],d=[];for(let f=0,g=u.length;f<g;f++){const v=u[f],m=a[f];let p;const _=l[f];if(m.mode===Fn.TRIANGLES||m.mode===Fn.TRIANGLE_STRIP||m.mode===Fn.TRIANGLE_FAN||m.mode===void 0)p=s.isSkinnedMesh===!0?new d_(v,_):new We(v,_),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===Fn.TRIANGLE_STRIP?p.geometry=sh(p.geometry,wu):m.mode===Fn.TRIANGLE_FAN&&(p.geometry=sh(p.geometry,Do));else if(m.mode===Fn.LINES)p=new Tc(v,_);else if(m.mode===Fn.LINE_STRIP)p=new Ec(v,_);else if(m.mode===Fn.LINE_LOOP)p=new m_(v,_);else if(m.mode===Fn.POINTS)p=new Na(v,_);else throw new Error(\"THREE.GLTFLoader: Primitive mode unsupported: \"+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&_v(p,s),p.name=t.createUniqueName(s.name||\"mesh_\"+e),Di(p,s),m.extensions&&sr(i,p,m),t.assignFinalMaterial(p),d.push(p)}for(let f=0,g=d.length;f<g;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return s.extensions&&sr(i,d[0],s),d[0];const h=new Pt;s.extensions&&sr(i,h,s),t.associations.set(h,{meshes:e});for(let f=0,g=d.length;f<g;f++)h.add(d[f]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn(\"THREE.GLTFLoader: Missing camera parameters.\");return}return n.type===\"perspective\"?t=new un(xr.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type===\"orthographic\"&&(t=new cc(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Di(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency(\"accessor\",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),a=i,o=[],c=[];for(let l=0,u=a.length;l<u;l++){const d=a[l];if(d){o.push(d);const h=new qe;s!==null&&h.fromArray(s.array,l*16),c.push(h)}else console.warn('THREE.GLTFLoader: Joint \"%s\" could not be found.',t.joints[l])}return new yc(o,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:\"animation_\"+e,a=[],o=[],c=[],l=[],u=[];for(let d=0,h=i.channels.length;d<h;d++){const f=i.channels[d],g=i.samplers[f.sampler],v=f.target,m=v.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,_=i.parameters!==void 0?i.parameters[g.output]:g.output;v.node!==void 0&&(a.push(this.getDependency(\"node\",m)),o.push(this.getDependency(\"accessor\",p)),c.push(this.getDependency(\"accessor\",_)),l.push(g),u.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(d){const h=d[0],f=d[1],g=d[2],v=d[3],m=d[4],p=[];for(let _=0,b=h.length;_<b;_++){const x=h[_],E=f[_],T=g[_],A=v[_],I=m[_];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const S=n._createAnimationTracks(x,E,T,A,I);if(S)for(let R=0;R<S.length;R++)p.push(S[R])}return new M_(s,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency(\"mesh\",i.mesh).then(function(s){const a=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let c=0,l=i.weights.length;c<l;c++)o.morphTargetInfluences[c]=i.weights[c]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=i.children||[];for(let l=0,u=o.length;l<u;l++)a.push(n.getDependency(\"node\",o[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency(\"skin\",i.skin);return Promise.all([s,Promise.all(a),c]).then(function(l){const u=l[0],d=l[1],h=l[2];h!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(h,yv)});for(let f=0,g=d.length;f<g;f++)u.add(d[f]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?i.createUniqueName(s.name):\"\",o=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),s.camera!==void 0&&o.push(i.getDependency(\"camera\",s.camera).then(function(l){return i._getNodeRef(i.cameraCache,s.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let u;if(s.isBone===!0?u=new Nd:l.length>1?u=new Pt:l.length===1?u=l[0]:u=new Ot,u!==l[0])for(let d=0,h=l.length;d<h;d++)u.add(l[d]);if(s.name&&(u.userData.name=s.name,u.name=a),Di(u,s),s.extensions&&sr(n,u,s),s.matrix!==void 0){const d=new qe;d.fromArray(s.matrix),u.applyMatrix4(d)}else s.translation!==void 0&&u.position.fromArray(s.translation),s.rotation!==void 0&&u.quaternion.fromArray(s.rotation),s.scale!==void 0&&u.scale.fromArray(s.scale);return i.associations.has(u)||i.associations.set(u,{}),i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new Pt;n.name&&(s.name=i.createUniqueName(n.name)),Di(s,n),n.extensions&&sr(t,s,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(i.getDependency(\"node\",a[c]));return Promise.all(o).then(function(c){for(let u=0,d=c.length;u<d;u++)s.add(c[u]);const l=u=>{const d=new Map;for(const[h,f]of i.associations)(h instanceof Rn||h instanceof Xt)&&d.set(h,f);return u.traverse(h=>{const f=i.associations.get(h);f!=null&&d.set(h,f)}),d};return i.associations=l(s),s})}_createAnimationTracks(e,t,n,i,s){const a=[],o=e.name?e.name:e.uuid,c=[];Ii[s.path]===Ii.weights?e.traverse(function(h){h.morphTargetInfluences&&c.push(h.name?h.name:h.uuid)}):c.push(o);let l;switch(Ii[s.path]){case Ii.weights:l=qr;break;case Ii.rotation:l=rr;break;case Ii.position:case Ii.scale:l=Kr;break;default:switch(n.itemSize){case 1:l=qr;break;case 2:case 3:default:l=Kr;break}break}const u=i.interpolation!==void 0?mv[i.interpolation]:Xi,d=this._getArrayFromAccessor(n);for(let h=0,f=c.length;h<f;h++){const g=new l(c[h]+\".\"+Ii[s.path],t.array,d,u);i.interpolation===\"CUBICSPLINE\"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Gc(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof rr?pv:ch;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Sv(r,e,t){const n=e.attributes,i=new bt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(i.set(new O(c[0],c[1],c[2]),new O(l[0],l[1],l[2])),o.normalized){const u=Gc($r[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn(\"THREE.GLTFLoader: Missing min/max properties for accessor POSITION.\");return}}else return;const s=e.targets;if(s!==void 0){const o=new O,c=new O;for(let l=0,u=s.length;l<u;l++){const d=s[l];if(d.POSITION!==void 0){const h=t.json.accessors[d.POSITION],f=h.min,g=h.max;if(f!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),h.normalized){const v=Gc($r[h.componentType]);c.multiplyScalar(v)}o.max(c)}else console.warn(\"THREE.GLTFLoader: Missing min/max properties for accessor POSITION.\")}}i.expandByVector(o)}r.boundingBox=i;const a=new Nn;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function dh(r,e,t){const n=e.attributes,i=[];function s(a,o){return t.getDependency(\"accessor\",a).then(function(c){r.setAttribute(o,c)})}for(const a in n){const o=Bc[a]||a.toLowerCase();o in r.attributes||i.push(s(n[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency(\"accessor\",e.indices).then(function(o){r.setIndex(o)});i.push(a)}return xt.workingColorSpace!==zt&&\"COLOR_0\"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from \"srgb-linear\" to \"${xt.workingColorSpace}\" not supported.`),Di(r,e),Sv(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?bv(r,e.targets,t):r})}const Hc=new WeakMap;class Ev extends Yn{constructor(e){super(e),this.decoderPath=\"\",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL=\"\",this.defaultAttributeIDs={position:\"POSITION\",normal:\"NORMAL\",color:\"COLOR\",uv:\"TEX_COORD\"},this.defaultAttributeTypes={position:\"Float32Array\",normal:\"Float32Array\",color:\"Float32Array\",uv:\"Float32Array\"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Li(this.manager);s.setPath(this.path),s.setResponseType(\"arraybuffer\"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.parse(a,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Mt).catch(n)}decodeDracoFile(e,t,n,i,s=zt,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Hc.has(e)){const c=Hc.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error(\"THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.\")}let i;const s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(c=>(i=c,new Promise((l,u)=>{i._callbacks[s]={resolve:l,reject:u},i.postMessage({type:\"decode\",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Hc.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new mn;e.index&&t.setIndex(new vt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],s=i.name,a=i.array,o=i.itemSize,c=new vt(a,o);s===\"color\"&&(this._assignVertexColorSpace(c,i.vertexColorSpace),c.normalized=!(a instanceof Float32Array)),t.setAttribute(s,c)}return t}_assignVertexColorSpace(e,t){if(t!==Mt)return;const n=new Be;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i).convertSRGBToLinear(),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Li(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!=\"object\"||this.decoderConfig.type===\"js\",t=[];return e?t.push(this._loadLibrary(\"draco_decoder.js\",\"text\")):(t.push(this._loadLibrary(\"draco_wasm_wrapper.js\",\"text\")),t.push(this._loadLibrary(\"draco_decoder.wasm\",\"arraybuffer\"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=Tv.toString(),a=[\"/* draco decoder */\",i,\"\",\"/* worker */\",s.substring(s.indexOf(\"{\")+1,s.lastIndexOf(\"}\"))].join(`\n`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:\"init\",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const a=s.data;switch(a.type){case\"decode\":i._callbacks[a.id].resolve(a);break;case\"error\":i._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, \"'+a.type+'\"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log(\"Task load: \",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==\"\"&&URL.revokeObjectURL(this.workerSourceURL),this}}function Tv(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case\"init\":r=o.decoderConfig,e=new Promise(function(u){r.onModuleLoaded=function(d){u({draco:d})},DracoDecoderModule(r)});break;case\"decode\":const c=o.buffer,l=o.taskConfig;e.then(u=>{const d=u.draco,h=new d.Decoder;try{const f=t(d,h,new Int8Array(c),l),g=f.attributes.map(v=>v.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:\"decode\",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:\"error\",id:o.id,error:f.message})}finally{d.destroy(h)}});break}};function t(a,o,c,l){const u=l.attributeIDs,d=l.attributeTypes;let h,f;const g=o.GetEncodedGeometryType(c);if(g===a.TRIANGULAR_MESH)h=new a.Mesh,f=o.DecodeArrayToMesh(c,c.byteLength,h);else if(g===a.POINT_CLOUD)h=new a.PointCloud,f=o.DecodeArrayToPointCloud(c,c.byteLength,h);else throw new Error(\"THREE.DRACOLoader: Unexpected geometry type.\");if(!f.ok()||h.ptr===0)throw new Error(\"THREE.DRACOLoader: Decoding failed: \"+f.error_msg());const v={index:null,attributes:[]};for(const m in u){const p=self[d[m]];let _,b;if(l.useUniqueIDs)b=u[m],_=o.GetAttributeByUniqueId(h,b);else{if(b=o.GetAttributeId(h,a[u[m]]),b===-1)continue;_=o.GetAttribute(h,b)}const x=i(a,o,h,m,p,_);m===\"color\"&&(x.vertexColorSpace=l.vertexColorSpace),v.attributes.push(x)}return g===a.TRIANGULAR_MESH&&(v.index=n(a,o,h)),a.destroy(h),v}function n(a,o,c){const u=c.num_faces()*3,d=u*4,h=a._malloc(d);o.GetTrianglesUInt32Array(c,d,h);const f=new Uint32Array(a.HEAPF32.buffer,h,u).slice();return a._free(h),{array:f,itemSize:1}}function i(a,o,c,l,u,d){const h=d.num_components(),g=c.num_points()*h,v=g*u.BYTES_PER_ELEMENT,m=s(a,u),p=a._malloc(v);o.GetAttributeDataArrayForAllPoints(c,d,m,v,p);const _=new u(a.HEAPF32.buffer,p,g).slice();return a._free(p),{name:l,array:_,itemSize:h}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var wv=function(){var r=\"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb\",e=\"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb\",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=\"object\")return{supported:!1};var i=WebAssembly.validate(t)?e:r,s,a=WebAssembly.instantiate(o(i),{}).then(function(p){s=p.instance,s.exports.__wasm_call_ctors()});function o(p){for(var _=new Uint8Array(p.length),b=0;b<p.length;++b){var x=p.charCodeAt(b);_[b]=x>96?x-97:x>64?x-39:x+4}for(var E=0,b=0;b<p.length;++b)_[E++]=_[b]<60?n[_[b]]:(_[b]-60)*64+_[++b];return _.buffer.slice(0,E)}function c(p,_,b,x,E,T){var A=s.exports.sbrk,I=b+3&-4,S=A(I*x),R=A(E.length),F=new Uint8Array(s.exports.memory.buffer);F.set(E,R);var U=p(S,b,x,R,E.length);if(U==0&&T&&T(S,I,x),_.set(F.subarray(S,S+b*x)),A(S-A(0)),U!=0)throw new Error(\"Malformed buffer data: \"+U)}var l={NONE:\"\",OCTAHEDRAL:\"meshopt_decodeFilterOct\",QUATERNION:\"meshopt_decodeFilterQuat\",EXPONENTIAL:\"meshopt_decodeFilterExp\"},u={ATTRIBUTES:\"meshopt_decodeVertexBuffer\",TRIANGLES:\"meshopt_decodeIndexBuffer\",INDICES:\"meshopt_decodeIndexSequence\"},d=[],h=0;function f(p){var _={object:new Worker(p),pending:0,requests:{}};return _.object.onmessage=function(b){var x=b.data;_.pending-=x.count,_.requests[x.id][x.action](x.value),delete _.requests[x.id]},_}function g(p){for(var _=\"var instance; var ready = WebAssembly.instantiate(new Uint8Array([\"+new Uint8Array(o(i))+\"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;\"+c.toString()+m.toString(),b=new Blob([_],{type:\"text/javascript\"}),x=URL.createObjectURL(b),E=0;E<p;++E)d[E]=f(x);URL.revokeObjectURL(x)}function v(p,_,b,x,E){for(var T=d[0],A=1;A<d.length;++A)d[A].pending<T.pending&&(T=d[A]);return new Promise(function(I,S){var R=new Uint8Array(b),F=h++;T.pending+=p,T.requests[F]={resolve:I,reject:S},T.object.postMessage({id:F,count:p,size:_,source:R,mode:x,filter:E},[R.buffer])})}function m(p){a.then(function(){var _=p.data;try{var b=new Uint8Array(_.count*_.size);c(s.exports[_.mode],b,_.count,_.size,_.source,s.exports[_.filter]),self.postMessage({id:_.id,count:_.count,action:\"resolve\",value:b},[b.buffer])}catch(x){self.postMessage({id:_.id,count:_.count,action:\"reject\",value:x})}})}return{ready:a,supported:!0,useWorkers:function(p){g(p)},decodeVertexBuffer:function(p,_,b,x,E){c(s.exports.meshopt_decodeVertexBuffer,p,_,b,x,s.exports[l[E]])},decodeIndexBuffer:function(p,_,b,x){c(s.exports.meshopt_decodeIndexBuffer,p,_,b,x)},decodeIndexSequence:function(p,_,b,x){c(s.exports.meshopt_decodeIndexSequence,p,_,b,x)},decodeGltfBuffer:function(p,_,b,x,E,T){c(s.exports[u[E]],p,_,b,x,s.exports[l[T]])},decodeGltfBufferAsync:function(p,_,b,x,E){return d.length>0?v(p,_,b,u[x],l[E]):a.then(function(){var T=new Uint8Array(p*_);return c(s.exports[u[x]],T,p,_,b,s.exports[l[E]]),T})}}}();class hh extends $d{constructor(e){super(e),this.type=cn}parse(e){const a=function(I,S){switch(I){case 1:throw new Error(\"THREE.RGBELoader: Read Error: \"+(S||\"\"));case 2:throw new Error(\"THREE.RGBELoader: Write Error: \"+(S||\"\"));case 3:throw new Error(\"THREE.RGBELoader: Bad File Format: \"+(S||\"\"));default:case 4:throw new Error(\"THREE.RGBELoader: Memory Error: \"+(S||\"\"))}},u=`\n`,d=function(I,S,R){S=S||1024;let U=I.pos,V=-1,P=0,z=\"\",X=String.fromCharCode.apply(null,new Uint16Array(I.subarray(U,U+128)));for(;0>(V=X.indexOf(u))&&P<S&&U<I.byteLength;)z+=X,P+=X.length,U+=128,X+=String.fromCharCode.apply(null,new Uint16Array(I.subarray(U,U+128)));return-1<V?(I.pos+=P+V+1,z+X.slice(0,V)):!1},h=function(I){const S=/^#\\?(\\S+)/,R=/^\\s*GAMMA\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,F=/^\\s*EXPOSURE\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,U=/^\\s*FORMAT=(\\S+)\\s*$/,V=/^\\s*\\-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/,P={valid:0,string:\"\",comments:\"\",programtype:\"RGBE\",format:\"\",gamma:1,exposure:1,width:0,height:0};let z,X;for((I.pos>=I.byteLength||!(z=d(I)))&&a(1,\"no header found\"),(X=z.match(S))||a(3,\"bad initial token\"),P.valid|=1,P.programtype=X[1],P.string+=z+`\n`;z=d(I),z!==!1;){if(P.string+=z+`\n`,z.charAt(0)===\"#\"){P.comments+=z+`\n`;continue}if((X=z.match(R))&&(P.gamma=parseFloat(X[1])),(X=z.match(F))&&(P.exposure=parseFloat(X[1])),(X=z.match(U))&&(P.valid|=2,P.format=X[1]),(X=z.match(V))&&(P.valid|=4,P.height=parseInt(X[1],10),P.width=parseInt(X[2],10)),P.valid&2&&P.valid&4)break}return P.valid&2||a(3,\"missing format specifier\"),P.valid&4||a(3,\"missing image size specifier\"),P},f=function(I,S,R){const F=S;if(F<8||F>32767||I[0]!==2||I[1]!==2||I[2]&128)return new Uint8Array(I);F!==(I[2]<<8|I[3])&&a(3,\"wrong scanline width\");const U=new Uint8Array(4*S*R);U.length||a(4,\"unable to allocate buffer space\");let V=0,P=0;const z=4*F,X=new Uint8Array(4),re=new Uint8Array(z);let J=R;for(;J>0&&P<I.byteLength;){P+4>I.byteLength&&a(1),X[0]=I[P++],X[1]=I[P++],X[2]=I[P++],X[3]=I[P++],(X[0]!=2||X[1]!=2||(X[2]<<8|X[3])!=F)&&a(3,\"bad rgbe scanline format\");let te=0,Q;for(;te<z&&P<I.byteLength;){Q=I[P++];const he=Q>128;if(he&&(Q-=128),(Q===0||te+Q>z)&&a(3,\"bad scanline data\"),he){const $=I[P++];for(let ue=0;ue<Q;ue++)re[te++]=$}else re.set(I.subarray(P,P+Q),te),te+=Q,P+=Q}const ce=F;for(let he=0;he<ce;he++){let $=0;U[V]=re[he+$],$+=F,U[V+1]=re[he+$],$+=F,U[V+2]=re[he+$],$+=F,U[V+3]=re[he+$],V+=4}J--}return U},g=function(I,S,R,F){const U=I[S+3],V=Math.pow(2,U-128)/255;R[F+0]=I[S+0]*V,R[F+1]=I[S+1]*V,R[F+2]=I[S+2]*V,R[F+3]=1},v=function(I,S,R,F){const U=I[S+3],V=Math.pow(2,U-128)/255;R[F+0]=Pr.toHalfFloat(Math.min(I[S+0]*V,65504)),R[F+1]=Pr.toHalfFloat(Math.min(I[S+1]*V,65504)),R[F+2]=Pr.toHalfFloat(Math.min(I[S+2]*V,65504)),R[F+3]=Pr.toHalfFloat(1)},m=new Uint8Array(e);m.pos=0;const p=h(m),_=p.width,b=p.height,x=f(m.subarray(m.pos),_,b);let E,T,A;switch(this.type){case jt:A=x.length/4;const I=new Float32Array(A*4);for(let R=0;R<A;R++)g(x,R*4,I,R*4);E=I,T=jt;break;case cn:A=x.length/4;const S=new Uint16Array(A*4);for(let R=0;R<A;R++)v(x,R*4,S,R*4);E=S,T=cn;break;default:throw new Error(\"THREE.RGBELoader: Unsupported type: \"+this.type)}return{width:_,height:b,data:E,header:p.string,gamma:p.gamma,exposure:p.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(a,o){switch(a.type){case jt:case cn:a.colorSpace=zt,a.minFilter=At,a.magFilter=At,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,s,n,i)}}/*!\nfflate - fast JavaScript compression/decompression\n<https://101arrowz.github.io/fflate>\nLicensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE\nversion 0.6.9\n*/var fh=function(r){return URL.createObjectURL(new Blob([r],{type:\"text/javascript\"}))};try{URL.revokeObjectURL(fh(\"\"))}catch{fh=function(e){return\"data:application/javascript;charset=UTF-8,\"+encodeURI(e)}}var On=Uint8Array,Ni=Uint16Array,Vc=Uint32Array,ph=new On([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),mh=new On([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Av=new On([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gh=function(r,e){for(var t=new Ni(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new Vc(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return[t,i]},bh=gh(ph,2),_h=bh[0],Rv=bh[1];_h[28]=258,Rv[258]=28;for(var Cv=gh(mh,0),Pv=Cv[0],Wc=new Ni(32768),Lt=0;Lt<32768;++Lt){var Ui=(Lt&43690)>>>1|(Lt&21845)<<1;Ui=(Ui&52428)>>>2|(Ui&13107)<<2,Ui=(Ui&61680)>>>4|(Ui&3855)<<4,Wc[Lt]=((Ui&65280)>>>8|(Ui&255)<<8)>>>1}for(var Is=function(r,e,t){for(var n=r.length,i=0,s=new Ni(e);i<n;++i)++s[r[i]-1];var a=new Ni(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(t){o=new Ni(1<<e);var c=15-e;for(i=0;i<n;++i)if(r[i])for(var l=i<<4|r[i],u=e-r[i],d=a[r[i]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[Wc[d]>>>c]=l}else for(o=new Ni(n),i=0;i<n;++i)r[i]&&(o[i]=Wc[a[r[i]-1]++]>>>15-r[i]);return o},Ds=new On(288),Lt=0;Lt<144;++Lt)Ds[Lt]=8;for(var Lt=144;Lt<256;++Lt)Ds[Lt]=9;for(var Lt=256;Lt<280;++Lt)Ds[Lt]=7;for(var Lt=280;Lt<288;++Lt)Ds[Lt]=8;for(var vh=new On(32),Lt=0;Lt<32;++Lt)vh[Lt]=5;var Lv=Is(Ds,9,1),Iv=Is(vh,5,1),jc=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Kn=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Xc=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Dv=function(r){return(r/8|0)+(r&7&&1)},Nv=function(r,e,t){(t==null||t>r.length)&&(t=r.length);var n=new(r instanceof Ni?Ni:r instanceof Vc?Vc:On)(t-e);return n.set(r.subarray(e,t)),n},Uv=function(r,e,t){var n=r.length;if(!n||t&&!t.l&&n<5)return e||new On(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new On(n*3));var a=function(xe){var ge=e.length;if(xe>ge){var Ge=new On(Math.max(ge*2,xe));Ge.set(e),e=Ge}},o=t.f||0,c=t.p||0,l=t.b||0,u=t.l,d=t.d,h=t.m,f=t.n,g=n*8;do{if(!u){t.f=o=Kn(r,c,1);var v=Kn(r,c+1,3);if(c+=3,v)if(v==1)u=Lv,d=Iv,h=9,f=5;else if(v==2){var b=Kn(r,c,31)+257,x=Kn(r,c+10,15)+4,E=b+Kn(r,c+5,31)+1;c+=14;for(var T=new On(E),A=new On(19),I=0;I<x;++I)A[Av[I]]=Kn(r,c+I*3,7);c+=x*3;for(var S=jc(A),R=(1<<S)-1,F=Is(A,S,1),I=0;I<E;){var U=F[Kn(r,c,R)];c+=U&15;var m=U>>>4;if(m<16)T[I++]=m;else{var V=0,P=0;for(m==16?(P=3+Kn(r,c,3),c+=2,V=T[I-1]):m==17?(P=3+Kn(r,c,7),c+=3):m==18&&(P=11+Kn(r,c,127),c+=7);P--;)T[I++]=V}}var z=T.subarray(0,b),X=T.subarray(b);h=jc(z),f=jc(X),u=Is(z,h,1),d=Is(X,f,1)}else throw\"invalid block type\";else{var m=Dv(c)+4,p=r[m-4]|r[m-3]<<8,_=m+p;if(_>n){if(s)throw\"unexpected EOF\";break}i&&a(l+p),e.set(r.subarray(m,_),l),t.b=l+=p,t.p=c=_*8;continue}if(c>g){if(s)throw\"unexpected EOF\";break}}i&&a(l+131072);for(var re=(1<<h)-1,J=(1<<f)-1,te=c;;te=c){var V=u[Xc(r,c)&re],Q=V>>>4;if(c+=V&15,c>g){if(s)throw\"unexpected EOF\";break}if(!V)throw\"invalid length/literal\";if(Q<256)e[l++]=Q;else if(Q==256){te=c,u=null;break}else{var ce=Q-254;if(Q>264){var I=Q-257,he=ph[I];ce=Kn(r,c,(1<<he)-1)+_h[I],c+=he}var $=d[Xc(r,c)&J],ue=$>>>4;if(!$)throw\"invalid distance\";c+=$&15;var X=Pv[ue];if(ue>3){var he=mh[ue];X+=Xc(r,c)&(1<<he)-1,c+=he}if(c>g){if(s)throw\"unexpected EOF\";break}i&&a(l+131072);for(var Me=l+ce;l<Me;l+=4)e[l]=e[l-X],e[l+1]=e[l+1-X],e[l+2]=e[l+2-X],e[l+3]=e[l+3-X];l=Me}}t.l=u,t.p=te,t.b=l,u&&(o=1,t.m=h,t.d=d,t.n=f)}while(!o);return l==e.length?e:Nv(e,0,l)},Fv=new On(0),Ov=function(r){if((r[0]&15)!=8||r[0]>>>4>7||(r[0]<<8|r[1])%31)throw\"invalid zlib data\";if(r[1]&32)throw\"invalid zlib data: preset dictionaries not supported\"};function Ba(r,e){return Uv((Ov(r),r.subarray(2,-4)),e)}var Bv=typeof TextDecoder<\"u\"&&new TextDecoder,kv=0;try{Bv.decode(Fv,{stream:!0}),kv=1}catch{}class xh extends $d{constructor(e){super(e),this.type=cn}parse(e){const S=Math.pow(2.7182818,2.2);function R(M,w){let L=0;for(let C=0;C<65536;++C)(C==0||M[C>>3]&1<<(C&7))&&(w[L++]=C);const y=L-1;for(;L<65536;)w[L++]=0;return y}function F(M){for(let w=0;w<16384;w++)M[w]={},M[w].len=0,M[w].lit=0,M[w].p=null}const U={l:0,c:0,lc:0};function V(M,w,L,y,C){for(;L<M;)w=w<<8|Ce(y,C),L+=8;L-=M,U.l=w>>L&(1<<M)-1,U.c=w,U.lc=L}const P=new Array(59);function z(M){for(let L=0;L<=58;++L)P[L]=0;for(let L=0;L<65537;++L)P[M[L]]+=1;let w=0;for(let L=58;L>0;--L){const y=w+P[L]>>1;P[L]=w,w=y}for(let L=0;L<65537;++L){const y=M[L];y>0&&(M[L]=y|P[y]++<<6)}}function X(M,w,L,y,C,D){const k=w;let G=0,Y=0;for(;y<=C;y++){if(k.value-w.value>L)return!1;V(6,G,Y,M,k);const q=U.l;if(G=U.c,Y=U.lc,D[y]=q,q==63){if(k.value-w.value>L)throw new Error(\"Something wrong with hufUnpackEncTable\");V(8,G,Y,M,k);let Z=U.l+6;if(G=U.c,Y=U.lc,y+Z>C+1)throw new Error(\"Something wrong with hufUnpackEncTable\");for(;Z--;)D[y++]=0;y--}else if(q>=59){let Z=q-59+2;if(y+Z>C+1)throw new Error(\"Something wrong with hufUnpackEncTable\");for(;Z--;)D[y++]=0;y--}}z(D)}function re(M){return M&63}function J(M){return M>>6}function te(M,w,L,y){for(;w<=L;w++){const C=J(M[w]),D=re(M[w]);if(C>>D)throw new Error(\"Invalid table entry\");if(D>14){const k=y[C>>D-14];if(k.len)throw new Error(\"Invalid table entry\");if(k.lit++,k.p){const G=k.p;k.p=new Array(k.lit);for(let Y=0;Y<k.lit-1;++Y)k.p[Y]=G[Y]}else k.p=new Array(1);k.p[k.lit-1]=w}else if(D){let k=0;for(let G=1<<14-D;G>0;G--){const Y=y[(C<<14-D)+k];if(Y.len||Y.p)throw new Error(\"Invalid table entry\");Y.len=D,Y.lit=w,k++}}}return!0}const Q={c:0,lc:0};function ce(M,w,L,y){M=M<<8|Ce(L,y),w+=8,Q.c=M,Q.lc=w}const he={c:0,lc:0};function $(M,w,L,y,C,D,k,G,Y){if(M==w){y<8&&(ce(L,y,C,D),L=Q.c,y=Q.lc),y-=8;let q=L>>y;if(q=new Uint8Array([q])[0],G.value+q>Y)return!1;const Z=k[G.value-1];for(;q-- >0;)k[G.value++]=Z}else if(G.value<Y)k[G.value++]=M;else return!1;he.c=L,he.lc=y}function ue(M){return M&65535}function Me(M){const w=ue(M);return w>32767?w-65536:w}const xe={a:0,b:0};function ge(M,w){const L=Me(M),C=Me(w),D=L+(C&1)+(C>>1),k=D,G=D-C;xe.a=k,xe.b=G}function Ge(M,w){const L=ue(M),y=ue(w),C=L-(y>>1)&65535,D=y+C-32768&65535;xe.a=D,xe.b=C}function Ke(M,w,L,y,C,D,k){const G=k<16384,Y=L>C?C:L;let q=1,Z,ie;for(;q<=Y;)q<<=1;for(q>>=1,Z=q,q>>=1;q>=1;){ie=0;const oe=ie+D*(C-Z),ae=D*q,le=D*Z,de=y*q,be=y*Z;let Se,$e,Oe,ke;for(;ie<=oe;ie+=le){let it=ie;const Ee=ie+y*(L-Z);for(;it<=Ee;it+=be){const ut=it+de,Nt=it+ae,mt=Nt+de;G?(ge(M[it+w],M[Nt+w]),Se=xe.a,Oe=xe.b,ge(M[ut+w],M[mt+w]),$e=xe.a,ke=xe.b,ge(Se,$e),M[it+w]=xe.a,M[ut+w]=xe.b,ge(Oe,ke),M[Nt+w]=xe.a,M[mt+w]=xe.b):(Ge(M[it+w],M[Nt+w]),Se=xe.a,Oe=xe.b,Ge(M[ut+w],M[mt+w]),$e=xe.a,ke=xe.b,Ge(Se,$e),M[it+w]=xe.a,M[ut+w]=xe.b,Ge(Oe,ke),M[Nt+w]=xe.a,M[mt+w]=xe.b)}if(L&q){const ut=it+ae;G?ge(M[it+w],M[ut+w]):Ge(M[it+w],M[ut+w]),Se=xe.a,M[ut+w]=xe.b,M[it+w]=Se}}if(C&q){let it=ie;const Ee=ie+y*(L-Z);for(;it<=Ee;it+=be){const ut=it+de;G?ge(M[it+w],M[ut+w]):Ge(M[it+w],M[ut+w]),Se=xe.a,M[ut+w]=xe.b,M[it+w]=Se}}Z=q,q>>=1}return ie}function He(M,w,L,y,C,D,k,G,Y){let q=0,Z=0;const ie=k,oe=Math.trunc(y.value+(C+7)/8);for(;y.value<oe;)for(ce(q,Z,L,y),q=Q.c,Z=Q.lc;Z>=14;){const le=q>>Z-14&16383,de=w[le];if(de.len)Z-=de.len,$(de.lit,D,q,Z,L,y,G,Y,ie),q=he.c,Z=he.lc;else{if(!de.p)throw new Error(\"hufDecode issues\");let be;for(be=0;be<de.lit;be++){const Se=re(M[de.p[be]]);for(;Z<Se&&y.value<oe;)ce(q,Z,L,y),q=Q.c,Z=Q.lc;if(Z>=Se&&J(M[de.p[be]])==(q>>Z-Se&(1<<Se)-1)){Z-=Se,$(de.p[be],D,q,Z,L,y,G,Y,ie),q=he.c,Z=he.lc;break}}if(be==de.lit)throw new Error(\"hufDecode issues\")}}const ae=8-C&7;for(q>>=ae,Z-=ae;Z>0;){const le=w[q<<14-Z&16383];if(le.len)Z-=le.len,$(le.lit,D,q,Z,L,y,G,Y,ie),q=he.c,Z=he.lc;else throw new Error(\"hufDecode issues\")}return!0}function tt(M,w,L,y,C,D){const k={value:0},G=L.value,Y=Pe(w,L),q=Pe(w,L);L.value+=4;const Z=Pe(w,L);if(L.value+=4,Y<0||Y>=65537||q<0||q>=65537)throw new Error(\"Something wrong with HUF_ENCSIZE\");const ie=new Array(65537),oe=new Array(16384);F(oe);const ae=y-(L.value-G);if(X(M,L,ae,Y,q,ie),Z>8*(y-(L.value-G)))throw new Error(\"Something wrong with hufUncompress\");te(ie,Y,q,oe),He(ie,oe,M,L,Z,q,D,C,k)}function W(M,w,L){for(let y=0;y<L;++y)w[y]=M[w[y]]}function ze(M){for(let w=1;w<M.length;w++){const L=M[w-1]+M[w]-128;M[w]=L}}function Le(M,w){let L=0,y=Math.floor((M.length+1)/2),C=0;const D=M.length-1;for(;!(C>D||(w[C++]=M[L++],C>D));)w[C++]=M[y++]}function Ie(M){let w=M.byteLength;const L=new Array;let y=0;const C=new DataView(M);for(;w>0;){const D=C.getInt8(y++);if(D<0){const k=-D;w-=k+1;for(let G=0;G<k;G++)L.push(C.getUint8(y++))}else{const k=D;w-=2;const G=C.getUint8(y++);for(let Y=0;Y<k+1;Y++)L.push(G)}}return L}function Ue(M,w,L,y,C,D){let k=new DataView(D.buffer);const G=L[M.idx[0]].width,Y=L[M.idx[0]].height,q=3,Z=Math.floor(G/8),ie=Math.ceil(G/8),oe=Math.ceil(Y/8),ae=G-(ie-1)*8,le=Y-(oe-1)*8,de={value:0},be=new Array(q),Se=new Array(q),$e=new Array(q),Oe=new Array(q),ke=new Array(q);for(let Ee=0;Ee<q;++Ee)ke[Ee]=w[M.idx[Ee]],be[Ee]=Ee<1?0:be[Ee-1]+ie*oe,Se[Ee]=new Float32Array(64),$e[Ee]=new Uint16Array(64),Oe[Ee]=new Uint16Array(ie*64);for(let Ee=0;Ee<oe;++Ee){let ut=8;Ee==oe-1&&(ut=le);let Nt=8;for(let lt=0;lt<ie;++lt){lt==ie-1&&(Nt=ae);for(let Je=0;Je<q;++Je)$e[Je].fill(0),$e[Je][0]=C[be[Je]++],_t(de,y,$e[Je]),nt($e[Je],Se[Je]),B(Se[Je]);N(Se);for(let Je=0;Je<q;++Je)se(Se[Je],Oe[Je],lt*64)}let mt=0;for(let lt=0;lt<q;++lt){const Je=L[M.idx[lt]].type;for(let Wt=8*Ee;Wt<8*Ee+ut;++Wt){mt=ke[lt][Wt];for(let Tn=0;Tn<Z;++Tn){const Et=Tn*64+(Wt&7)*8;k.setUint16(mt+0*2*Je,Oe[lt][Et+0],!0),k.setUint16(mt+1*2*Je,Oe[lt][Et+1],!0),k.setUint16(mt+2*2*Je,Oe[lt][Et+2],!0),k.setUint16(mt+3*2*Je,Oe[lt][Et+3],!0),k.setUint16(mt+4*2*Je,Oe[lt][Et+4],!0),k.setUint16(mt+5*2*Je,Oe[lt][Et+5],!0),k.setUint16(mt+6*2*Je,Oe[lt][Et+6],!0),k.setUint16(mt+7*2*Je,Oe[lt][Et+7],!0),mt+=8*2*Je}}if(Z!=ie)for(let Wt=8*Ee;Wt<8*Ee+ut;++Wt){const Tn=ke[lt][Wt]+8*Z*2*Je,Et=Z*64+(Wt&7)*8;for(let Ln=0;Ln<Nt;++Ln)k.setUint16(Tn+Ln*2*Je,Oe[lt][Et+Ln],!0)}}}const it=new Uint16Array(G);k=new DataView(D.buffer);for(let Ee=0;Ee<q;++Ee){L[M.idx[Ee]].decoded=!0;const ut=L[M.idx[Ee]].type;if(L[Ee].type==2)for(let Nt=0;Nt<Y;++Nt){const mt=ke[Ee][Nt];for(let lt=0;lt<G;++lt)it[lt]=k.getUint16(mt+lt*2*ut,!0);for(let lt=0;lt<G;++lt)k.setFloat32(mt+lt*2*ut,ee(it[lt]),!0)}}}function _t(M,w,L){let y,C=1;for(;C<64;)y=w[M.value],y==65280?C=64:y>>8==255?C+=y&255:(L[C]=y,C++),M.value++}function nt(M,w){w[0]=ee(M[0]),w[1]=ee(M[1]),w[2]=ee(M[5]),w[3]=ee(M[6]),w[4]=ee(M[14]),w[5]=ee(M[15]),w[6]=ee(M[27]),w[7]=ee(M[28]),w[8]=ee(M[2]),w[9]=ee(M[4]),w[10]=ee(M[7]),w[11]=ee(M[13]),w[12]=ee(M[16]),w[13]=ee(M[26]),w[14]=ee(M[29]),w[15]=ee(M[42]),w[16]=ee(M[3]),w[17]=ee(M[8]),w[18]=ee(M[12]),w[19]=ee(M[17]),w[20]=ee(M[25]),w[21]=ee(M[30]),w[22]=ee(M[41]),w[23]=ee(M[43]),w[24]=ee(M[9]),w[25]=ee(M[11]),w[26]=ee(M[18]),w[27]=ee(M[24]),w[28]=ee(M[31]),w[29]=ee(M[40]),w[30]=ee(M[44]),w[31]=ee(M[53]),w[32]=ee(M[10]),w[33]=ee(M[19]),w[34]=ee(M[23]),w[35]=ee(M[32]),w[36]=ee(M[39]),w[37]=ee(M[45]),w[38]=ee(M[52]),w[39]=ee(M[54]),w[40]=ee(M[20]),w[41]=ee(M[22]),w[42]=ee(M[33]),w[43]=ee(M[38]),w[44]=ee(M[46]),w[45]=ee(M[51]),w[46]=ee(M[55]),w[47]=ee(M[60]),w[48]=ee(M[21]),w[49]=ee(M[34]),w[50]=ee(M[37]),w[51]=ee(M[47]),w[52]=ee(M[50]),w[53]=ee(M[56]),w[54]=ee(M[59]),w[55]=ee(M[61]),w[56]=ee(M[35]),w[57]=ee(M[36]),w[58]=ee(M[48]),w[59]=ee(M[49]),w[60]=ee(M[57]),w[61]=ee(M[58]),w[62]=ee(M[62]),w[63]=ee(M[63])}function B(M){const w=.5*Math.cos(.7853975),L=.5*Math.cos(3.14159/16),y=.5*Math.cos(3.14159/8),C=.5*Math.cos(3*3.14159/16),D=.5*Math.cos(5*3.14159/16),k=.5*Math.cos(3*3.14159/8),G=.5*Math.cos(7*3.14159/16),Y=new Array(4),q=new Array(4),Z=new Array(4),ie=new Array(4);for(let oe=0;oe<8;++oe){const ae=oe*8;Y[0]=y*M[ae+2],Y[1]=k*M[ae+2],Y[2]=y*M[ae+6],Y[3]=k*M[ae+6],q[0]=L*M[ae+1]+C*M[ae+3]+D*M[ae+5]+G*M[ae+7],q[1]=C*M[ae+1]-G*M[ae+3]-L*M[ae+5]-D*M[ae+7],q[2]=D*M[ae+1]-L*M[ae+3]+G*M[ae+5]+C*M[ae+7],q[3]=G*M[ae+1]-D*M[ae+3]+C*M[ae+5]-L*M[ae+7],Z[0]=w*(M[ae+0]+M[ae+4]),Z[3]=w*(M[ae+0]-M[ae+4]),Z[1]=Y[0]+Y[3],Z[2]=Y[1]-Y[2],ie[0]=Z[0]+Z[1],ie[1]=Z[3]+Z[2],ie[2]=Z[3]-Z[2],ie[3]=Z[0]-Z[1],M[ae+0]=ie[0]+q[0],M[ae+1]=ie[1]+q[1],M[ae+2]=ie[2]+q[2],M[ae+3]=ie[3]+q[3],M[ae+4]=ie[3]-q[3],M[ae+5]=ie[2]-q[2],M[ae+6]=ie[1]-q[1],M[ae+7]=ie[0]-q[0]}for(let oe=0;oe<8;++oe)Y[0]=y*M[16+oe],Y[1]=k*M[16+oe],Y[2]=y*M[48+oe],Y[3]=k*M[48+oe],q[0]=L*M[8+oe]+C*M[24+oe]+D*M[40+oe]+G*M[56+oe],q[1]=C*M[8+oe]-G*M[24+oe]-L*M[40+oe]-D*M[56+oe],q[2]=D*M[8+oe]-L*M[24+oe]+G*M[40+oe]+C*M[56+oe],q[3]=G*M[8+oe]-D*M[24+oe]+C*M[40+oe]-L*M[56+oe],Z[0]=w*(M[oe]+M[32+oe]),Z[3]=w*(M[oe]-M[32+oe]),Z[1]=Y[0]+Y[3],Z[2]=Y[1]-Y[2],ie[0]=Z[0]+Z[1],ie[1]=Z[3]+Z[2],ie[2]=Z[3]-Z[2],ie[3]=Z[0]-Z[1],M[0+oe]=ie[0]+q[0],M[8+oe]=ie[1]+q[1],M[16+oe]=ie[2]+q[2],M[24+oe]=ie[3]+q[3],M[32+oe]=ie[3]-q[3],M[40+oe]=ie[2]-q[2],M[48+oe]=ie[1]-q[1],M[56+oe]=ie[0]-q[0]}function N(M){for(let w=0;w<64;++w){const L=M[0][w],y=M[1][w],C=M[2][w];M[0][w]=L+1.5747*C,M[1][w]=L-.1873*y-.4682*C,M[2][w]=L+1.8556*y}}function se(M,w,L){for(let y=0;y<64;++y)w[L+y]=Pr.toHalfFloat(_e(M[y]))}function _e(M){return M<=1?Math.sign(M)*Math.pow(Math.abs(M),2.2):Math.sign(M)*Math.pow(S,Math.abs(M)-1)}function pe(M){return new DataView(M.array.buffer,M.offset.value,M.size)}function ve(M){const w=M.viewer.buffer.slice(M.offset.value,M.offset.value+M.size),L=new Uint8Array(Ie(w)),y=new Uint8Array(L.length);return ze(L),Le(L,y),new DataView(y.buffer)}function Fe(M){const w=M.array.slice(M.offset.value,M.offset.value+M.size),L=Ba(w),y=new Uint8Array(L.length);return ze(L),Le(L,y),new DataView(y.buffer)}function we(M){const w=M.viewer,L={value:M.offset.value},y=new Uint16Array(M.width*M.scanlineBlockSize*(M.channels*M.type)),C=new Uint8Array(8192);let D=0;const k=new Array(M.channels);for(let le=0;le<M.channels;le++)k[le]={},k[le].start=D,k[le].end=k[le].start,k[le].nx=M.width,k[le].ny=M.lines,k[le].size=M.type,D+=k[le].nx*k[le].ny*k[le].size;const G=j(w,L),Y=j(w,L);if(Y>=8192)throw new Error(\"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE\");if(G<=Y)for(let le=0;le<Y-G+1;le++)C[le+G]=H(w,L);const q=new Uint16Array(65536),Z=R(C,q),ie=Pe(w,L);tt(M.array,w,L,ie,y,D);for(let le=0;le<M.channels;++le){const de=k[le];for(let be=0;be<k[le].size;++be)Ke(y,de.start+be,de.nx,de.size,de.ny,de.nx*de.size,Z)}W(q,y,D);let oe=0;const ae=new Uint8Array(y.buffer.byteLength);for(let le=0;le<M.lines;le++)for(let de=0;de<M.channels;de++){const be=k[de],Se=be.nx*be.size,$e=new Uint8Array(y.buffer,be.end*2,Se*2);ae.set($e,oe),oe+=Se*2,be.end+=Se}return new DataView(ae.buffer)}function Ne(M){const w=M.array.slice(M.offset.value,M.offset.value+M.size),L=Ba(w),y=M.lines*M.channels*M.width,C=M.type==1?new Uint16Array(y):new Uint32Array(y);let D=0,k=0;const G=new Array(4);for(let Y=0;Y<M.lines;Y++)for(let q=0;q<M.channels;q++){let Z=0;switch(M.type){case 1:G[0]=D,G[1]=G[0]+M.width,D=G[1]+M.width;for(let ie=0;ie<M.width;++ie){const oe=L[G[0]++]<<8|L[G[1]++];Z+=oe,C[k]=Z,k++}break;case 2:G[0]=D,G[1]=G[0]+M.width,G[2]=G[1]+M.width,D=G[2]+M.width;for(let ie=0;ie<M.width;++ie){const oe=L[G[0]++]<<24|L[G[1]++]<<16|L[G[2]++]<<8;Z+=oe,C[k]=Z,k++}break}}return new DataView(C.buffer)}function je(M){const w=M.viewer,L={value:M.offset.value},y=new Uint8Array(M.width*M.lines*(M.channels*M.type*2)),C={version:fe(w,L),unknownUncompressedSize:fe(w,L),unknownCompressedSize:fe(w,L),acCompressedSize:fe(w,L),dcCompressedSize:fe(w,L),rleCompressedSize:fe(w,L),rleUncompressedSize:fe(w,L),rleRawSize:fe(w,L),totalAcUncompressedCount:fe(w,L),totalDcUncompressedCount:fe(w,L),acCompression:fe(w,L)};if(C.version<2)throw new Error(\"EXRLoader.parse: \"+Hn.compression+\" version \"+C.version+\" is unsupported\");const D=new Array;let k=j(w,L)-2;for(;k>0;){const de=Qe(w.buffer,L),be=H(w,L),Se=be>>2&3,$e=(be>>4)-1,Oe=new Int8Array([$e])[0],ke=H(w,L);D.push({name:de,index:Oe,type:ke,compression:Se}),k-=de.length+3}const G=Hn.channels,Y=new Array(M.channels);for(let de=0;de<M.channels;++de){const be=Y[de]={},Se=G[de];be.name=Se.name,be.compression=0,be.decoded=!1,be.type=Se.pixelType,be.pLinear=Se.pLinear,be.width=M.width,be.height=M.lines}const q={idx:new Array(3)};for(let de=0;de<M.channels;++de){const be=Y[de];for(let Se=0;Se<D.length;++Se){const $e=D[Se];be.name==$e.name&&(be.compression=$e.compression,$e.index>=0&&(q.idx[$e.index]=de),be.offset=de)}}let Z,ie,oe;if(C.acCompressedSize>0)switch(C.acCompression){case 0:Z=new Uint16Array(C.totalAcUncompressedCount),tt(M.array,w,L,C.acCompressedSize,Z,C.totalAcUncompressedCount);break;case 1:const de=M.array.slice(L.value,L.value+C.totalAcUncompressedCount),be=Ba(de);Z=new Uint16Array(be.buffer),L.value+=C.totalAcUncompressedCount;break}if(C.dcCompressedSize>0){const de={array:M.array,offset:L,size:C.dcCompressedSize};ie=new Uint16Array(Fe(de).buffer),L.value+=C.dcCompressedSize}if(C.rleRawSize>0){const de=M.array.slice(L.value,L.value+C.rleCompressedSize),be=Ba(de);oe=Ie(be.buffer),L.value+=C.rleCompressedSize}let ae=0;const le=new Array(Y.length);for(let de=0;de<le.length;++de)le[de]=new Array;for(let de=0;de<M.lines;++de)for(let be=0;be<Y.length;++be)le[be].push(ae),ae+=Y[be].width*M.type*2;Ue(q,le,Y,Z,ie,y);for(let de=0;de<Y.length;++de){const be=Y[de];if(!be.decoded)switch(be.compression){case 2:let Se=0,$e=0;for(let Oe=0;Oe<M.lines;++Oe){let ke=le[de][Se];for(let it=0;it<be.width;++it){for(let Ee=0;Ee<2*be.type;++Ee)y[ke++]=oe[$e+Ee*be.width*be.height];$e++}Se++}break;case 1:default:throw new Error(\"EXRLoader.parse: unsupported channel compression\")}}return new DataView(y.buffer)}function Qe(M,w){const L=new Uint8Array(M);let y=0;for(;L[w.value+y]!=0;)y+=1;const C=new TextDecoder().decode(L.slice(w.value,w.value+y));return w.value=w.value+y+1,C}function me(M,w,L){const y=new TextDecoder().decode(new Uint8Array(M).slice(w.value,w.value+L));return w.value=w.value+L,y}function ft(M,w){const L=Ye(M,w),y=Pe(M,w);return[L,y]}function rt(M,w){const L=Pe(M,w),y=Pe(M,w);return[L,y]}function Ye(M,w){const L=M.getInt32(w.value,!0);return w.value=w.value+4,L}function Pe(M,w){const L=M.getUint32(w.value,!0);return w.value=w.value+4,L}function Ce(M,w){const L=M[w.value];return w.value=w.value+1,L}function H(M,w){const L=M.getUint8(w.value);return w.value=w.value+1,L}const fe=function(M,w){let L;return\"getBigInt64\"in DataView.prototype?L=Number(M.getBigInt64(w.value,!0)):L=M.getUint32(w.value+4,!0)+Number(M.getUint32(w.value,!0)<<32),w.value+=8,L};function Re(M,w){const L=M.getFloat32(w.value,!0);return w.value+=4,L}function De(M,w){return Pr.toHalfFloat(Re(M,w))}function ee(M){const w=(M&31744)>>10,L=M&1023;return(M>>15?-1:1)*(w?w===31?L?NaN:1/0:Math.pow(2,w-15)*(1+L/1024):6103515625e-14*(L/1024))}function j(M,w){const L=M.getUint16(w.value,!0);return w.value+=2,L}function ye(M,w){return ee(j(M,w))}function Ae(M,w,L,y){const C=L.value,D=[];for(;L.value<C+y-1;){const k=Qe(w,L),G=Ye(M,L),Y=H(M,L);L.value+=3;const q=Ye(M,L),Z=Ye(M,L);D.push({name:k,pixelType:G,pLinear:Y,xSampling:q,ySampling:Z})}return L.value+=1,D}function Ze(M,w){const L=Re(M,w),y=Re(M,w),C=Re(M,w),D=Re(M,w),k=Re(M,w),G=Re(M,w),Y=Re(M,w),q=Re(M,w);return{redX:L,redY:y,greenX:C,greenY:D,blueX:k,blueY:G,whiteX:Y,whiteY:q}}function Xe(M,w){const L=[\"NO_COMPRESSION\",\"RLE_COMPRESSION\",\"ZIPS_COMPRESSION\",\"ZIP_COMPRESSION\",\"PIZ_COMPRESSION\",\"PXR24_COMPRESSION\",\"B44_COMPRESSION\",\"B44A_COMPRESSION\",\"DWAA_COMPRESSION\",\"DWAB_COMPRESSION\"],y=H(M,w);return L[y]}function at(M,w){const L=Pe(M,w),y=Pe(M,w),C=Pe(M,w),D=Pe(M,w);return{xMin:L,yMin:y,xMax:C,yMax:D}}function ot(M,w){const L=[\"INCREASING_Y\"],y=H(M,w);return L[y]}function Rt(M,w){const L=Re(M,w),y=Re(M,w);return[L,y]}function Dt(M,w){const L=Re(M,w),y=Re(M,w),C=Re(M,w);return[L,y,C]}function pt(M,w,L,y,C){if(y===\"string\"||y===\"stringvector\"||y===\"iccProfile\")return me(w,L,C);if(y===\"chlist\")return Ae(M,w,L,C);if(y===\"chromaticities\")return Ze(M,L);if(y===\"compression\")return Xe(M,L);if(y===\"box2i\")return at(M,L);if(y===\"lineOrder\")return ot(M,L);if(y===\"float\")return Re(M,L);if(y===\"v2f\")return Rt(M,L);if(y===\"v3f\")return Dt(M,L);if(y===\"int\")return Ye(M,L);if(y===\"rational\")return ft(M,L);if(y===\"timecode\")return rt(M,L);if(y===\"preview\")return L.value+=C,\"skipped\";L.value+=C}function Ut(M,w,L){const y={};if(M.getUint32(0,!0)!=20000630)throw new Error(\"THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.\");y.version=M.getUint8(4);const C=M.getUint8(5);y.spec={singleTile:!!(C&2),longName:!!(C&4),deepFormat:!!(C&8),multiPart:!!(C&16)},L.value=8;let D=!0;for(;D;){const k=Qe(w,L);if(k==0)D=!1;else{const G=Qe(w,L),Y=Pe(M,L),q=pt(M,w,L,G,Y);q===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${G}'.`):y[k]=q}}if(C&-5)throw console.error(\"THREE.EXRHeader:\",y),new Error(\"THREE.EXRLoader: Provided file is currently unsupported.\");return y}function En(M,w,L,y,C){const D={size:0,viewer:w,array:L,offset:y,width:M.dataWindow.xMax-M.dataWindow.xMin+1,height:M.dataWindow.yMax-M.dataWindow.yMin+1,channels:M.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:M.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:zt};switch(M.compression){case\"NO_COMPRESSION\":D.lines=1,D.uncompress=pe;break;case\"RLE_COMPRESSION\":D.lines=1,D.uncompress=ve;break;case\"ZIPS_COMPRESSION\":D.lines=1,D.uncompress=Fe;break;case\"ZIP_COMPRESSION\":D.lines=16,D.uncompress=Fe;break;case\"PIZ_COMPRESSION\":D.lines=32,D.uncompress=we;break;case\"PXR24_COMPRESSION\":D.lines=16,D.uncompress=Ne;break;case\"DWAA_COMPRESSION\":D.lines=32,D.uncompress=je;break;case\"DWAB_COMPRESSION\":D.lines=256,D.uncompress=je;break;default:throw new Error(\"EXRLoader.parse: \"+M.compression+\" is unsupported\")}if(D.scanlineBlockSize=D.lines,D.type==1)switch(C){case jt:D.getter=ye,D.inputSize=2;break;case cn:D.getter=j,D.inputSize=2;break}else if(D.type==2)switch(C){case jt:D.getter=Re,D.inputSize=4;break;case cn:D.getter=De,D.inputSize=4}else throw new Error(\"EXRLoader.parse: unsupported pixelType \"+D.type+\" for \"+M.compression+\".\");D.blockCount=(M.dataWindow.yMax+1)/D.scanlineBlockSize;for(let G=0;G<D.blockCount;G++)fe(w,y);D.outputChannels=D.channels==3?4:D.channels;const k=D.width*D.height*D.outputChannels;switch(C){case jt:D.byteArray=new Float32Array(k),D.channels<D.outputChannels&&D.byteArray.fill(1,0,k);break;case cn:D.byteArray=new Uint16Array(k),D.channels<D.outputChannels&&D.byteArray.fill(15360,0,k);break;default:console.error(\"THREE.EXRLoader: unsupported type: \",C);break}return D.bytesPerLine=D.width*D.inputSize*D.channels,D.outputChannels==4?(D.format=kt,D.colorSpace=zt):(D.format=To,D.colorSpace=Sn),D}const xi=new DataView(e),js=new Uint8Array(e),Gn={value:0},Hn=Ut(xi,e,Gn),et=En(Hn,xi,js,Gn,this.type),K={value:0},ne={R:0,G:1,B:2,A:3,Y:0};for(let M=0;M<et.height/et.scanlineBlockSize;M++){const w=Pe(xi,Gn);et.size=Pe(xi,Gn),et.lines=w+et.scanlineBlockSize>et.height?et.height-w:et.scanlineBlockSize;const y=et.size<et.lines*et.bytesPerLine?et.uncompress(et):pe(et);Gn.value+=et.size;for(let C=0;C<et.scanlineBlockSize;C++){const D=C+M*et.scanlineBlockSize;if(D>=et.height)break;for(let k=0;k<et.channels;k++){const G=ne[Hn.channels[k].name];for(let Y=0;Y<et.width;Y++){K.value=(C*(et.channels*et.width)+k*et.width+Y)*et.inputSize;const q=(et.height-1-D)*(et.width*et.outputChannels)+Y*et.outputChannels+G;et.byteArray[q]=et.getter(y,K)}}}}return{header:Hn,width:et.width,height:et.height,data:et.byteArray,format:et.format,colorSpace:et.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(a,o){a.colorSpace=o.colorSpace,a.minFilter=At,a.magFilter=At,a.generateMipmaps=!1,a.flipY=!1,t&&t(a,o)}return super.load(e,s,n,i)}}const yh={type:\"change\"},qc={type:\"start\"},Mh={type:\"end\"},ka=new Ji,Sh=new Qn,zv=Math.cos(70*xr.DEG2RAD);class Gv extends Yi{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction=\"none\",this.enabled=!0,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:\"ArrowLeft\",UP:\"ArrowUp\",RIGHT:\"ArrowRight\",BOTTOM:\"ArrowDown\"},this.mouseButtons={LEFT:dr.ROTATE,MIDDLE:dr.DOLLY,RIGHT:dr.PAN},this.touches={ONE:hr.ROTATE,TWO:hr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener(\"keydown\",je),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener(\"keydown\",je),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(yh),n.update(),s=i.NONE},this.update=function(){const H=new O,fe=new Dn().setFromUnitVectors(e.up,new O(0,1,0)),Re=fe.clone().invert(),De=new O,ee=new Dn,j=new O,ye=2*Math.PI;return function(Ze=null){const Xe=n.object.position;H.copy(Xe).sub(n.target),H.applyQuaternion(fe),o.setFromVector3(H),n.autoRotate&&s===i.NONE&&U(R(Ze)),n.enableDamping?(o.theta+=c.theta*n.dampingFactor,o.phi+=c.phi*n.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let at=n.minAzimuthAngle,ot=n.maxAzimuthAngle;isFinite(at)&&isFinite(ot)&&(at<-Math.PI?at+=ye:at>Math.PI&&(at-=ye),ot<-Math.PI?ot+=ye:ot>Math.PI&&(ot-=ye),at<=ot?o.theta=Math.max(at,Math.min(ot,o.theta)):o.theta=o.theta>(at+ot)/2?Math.max(at,o.theta):Math.min(ot,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&T||n.object.isOrthographicCamera?o.radius=Q(o.radius):o.radius=Q(o.radius*l),H.setFromSpherical(o),H.applyQuaternion(Re),Xe.copy(n.target).add(H),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0));let Rt=!1;if(n.zoomToCursor&&T){let Dt=null;if(n.object.isPerspectiveCamera){const pt=H.length();Dt=Q(pt*l);const Ut=pt-Dt;n.object.position.addScaledVector(x,Ut),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const pt=new O(E.x,E.y,0);pt.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),Rt=!0;const Ut=new O(E.x,E.y,0);Ut.unproject(n.object),n.object.position.sub(Ut).add(pt),n.object.updateMatrixWorld(),Dt=H.length()}else console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.\"),n.zoomToCursor=!1;Dt!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(Dt).add(n.object.position):(ka.origin.copy(n.object.position),ka.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(ka.direction))<zv?e.lookAt(n.target):(Sh.setFromNormalAndCoplanarPoint(n.object.up,n.target),ka.intersectPlane(Sh,n.target))))}else n.object.isOrthographicCamera&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),Rt=!0);return l=1,T=!1,Rt||De.distanceToSquared(n.object.position)>a||8*(1-ee.dot(n.object.quaternion))>a||j.distanceToSquared(n.target)>0?(n.dispatchEvent(yh),De.copy(n.object.position),ee.copy(n.object.quaternion),j.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener(\"contextmenu\",ft),n.domElement.removeEventListener(\"pointerdown\",B),n.domElement.removeEventListener(\"pointercancel\",se),n.domElement.removeEventListener(\"wheel\",ve),n.domElement.removeEventListener(\"pointermove\",N),n.domElement.removeEventListener(\"pointerup\",se),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener(\"keydown\",je),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const a=1e-6,o=new ih,c=new ih;let l=1;const u=new O,d=new Ve,h=new Ve,f=new Ve,g=new Ve,v=new Ve,m=new Ve,p=new Ve,_=new Ve,b=new Ve,x=new O,E=new Ve;let T=!1;const A=[],I={};let S=!1;function R(H){return H!==null?2*Math.PI/60*n.autoRotateSpeed*H:2*Math.PI/60/60*n.autoRotateSpeed}function F(H){const fe=Math.abs(H*.01);return Math.pow(.95,n.zoomSpeed*fe)}function U(H){c.theta-=H}function V(H){c.phi-=H}const P=function(){const H=new O;return function(Re,De){H.setFromMatrixColumn(De,0),H.multiplyScalar(-Re),u.add(H)}}(),z=function(){const H=new O;return function(Re,De){n.screenSpacePanning===!0?H.setFromMatrixColumn(De,1):(H.setFromMatrixColumn(De,0),H.crossVectors(n.object.up,H)),H.multiplyScalar(Re),u.add(H)}}(),X=function(){const H=new O;return function(Re,De){const ee=n.domElement;if(n.object.isPerspectiveCamera){const j=n.object.position;H.copy(j).sub(n.target);let ye=H.length();ye*=Math.tan(n.object.fov/2*Math.PI/180),P(2*Re*ye/ee.clientHeight,n.object.matrix),z(2*De*ye/ee.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(P(Re*(n.object.right-n.object.left)/n.object.zoom/ee.clientWidth,n.object.matrix),z(De*(n.object.top-n.object.bottom)/n.object.zoom/ee.clientHeight,n.object.matrix)):(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.\"),n.enablePan=!1)}}();function re(H){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=H:(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.\"),n.enableZoom=!1)}function J(H){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=H:(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.\"),n.enableZoom=!1)}function te(H,fe){if(!n.zoomToCursor)return;T=!0;const Re=n.domElement.getBoundingClientRect(),De=H-Re.left,ee=fe-Re.top,j=Re.width,ye=Re.height;E.x=De/j*2-1,E.y=-(ee/ye)*2+1,x.set(E.x,E.y,1).unproject(n.object).sub(n.object.position).normalize()}function Q(H){return Math.max(n.minDistance,Math.min(n.maxDistance,H))}function ce(H){d.set(H.clientX,H.clientY)}function he(H){te(H.clientX,H.clientX),p.set(H.clientX,H.clientY)}function $(H){g.set(H.clientX,H.clientY)}function ue(H){h.set(H.clientX,H.clientY),f.subVectors(h,d).multiplyScalar(n.rotateSpeed);const fe=n.domElement;U(2*Math.PI*f.x/fe.clientHeight),V(2*Math.PI*f.y/fe.clientHeight),d.copy(h),n.update()}function Me(H){_.set(H.clientX,H.clientY),b.subVectors(_,p),b.y>0?re(F(b.y)):b.y<0&&J(F(b.y)),p.copy(_),n.update()}function xe(H){v.set(H.clientX,H.clientY),m.subVectors(v,g).multiplyScalar(n.panSpeed),X(m.x,m.y),g.copy(v),n.update()}function ge(H){te(H.clientX,H.clientY),H.deltaY<0?J(F(H.deltaY)):H.deltaY>0&&re(F(H.deltaY)),n.update()}function Ge(H){let fe=!1;switch(H.code){case n.keys.UP:H.ctrlKey||H.metaKey||H.shiftKey?V(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):X(0,n.keyPanSpeed),fe=!0;break;case n.keys.BOTTOM:H.ctrlKey||H.metaKey||H.shiftKey?V(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):X(0,-n.keyPanSpeed),fe=!0;break;case n.keys.LEFT:H.ctrlKey||H.metaKey||H.shiftKey?U(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):X(n.keyPanSpeed,0),fe=!0;break;case n.keys.RIGHT:H.ctrlKey||H.metaKey||H.shiftKey?U(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):X(-n.keyPanSpeed,0),fe=!0;break}fe&&(H.preventDefault(),n.update())}function Ke(H){if(A.length===1)d.set(H.pageX,H.pageY);else{const fe=Ce(H),Re=.5*(H.pageX+fe.x),De=.5*(H.pageY+fe.y);d.set(Re,De)}}function He(H){if(A.length===1)g.set(H.pageX,H.pageY);else{const fe=Ce(H),Re=.5*(H.pageX+fe.x),De=.5*(H.pageY+fe.y);g.set(Re,De)}}function tt(H){const fe=Ce(H),Re=H.pageX-fe.x,De=H.pageY-fe.y,ee=Math.sqrt(Re*Re+De*De);p.set(0,ee)}function W(H){n.enableZoom&&tt(H),n.enablePan&&He(H)}function ze(H){n.enableZoom&&tt(H),n.enableRotate&&Ke(H)}function Le(H){if(A.length==1)h.set(H.pageX,H.pageY);else{const Re=Ce(H),De=.5*(H.pageX+Re.x),ee=.5*(H.pageY+Re.y);h.set(De,ee)}f.subVectors(h,d).multiplyScalar(n.rotateSpeed);const fe=n.domElement;U(2*Math.PI*f.x/fe.clientHeight),V(2*Math.PI*f.y/fe.clientHeight),d.copy(h)}function Ie(H){if(A.length===1)v.set(H.pageX,H.pageY);else{const fe=Ce(H),Re=.5*(H.pageX+fe.x),De=.5*(H.pageY+fe.y);v.set(Re,De)}m.subVectors(v,g).multiplyScalar(n.panSpeed),X(m.x,m.y),g.copy(v)}function Ue(H){const fe=Ce(H),Re=H.pageX-fe.x,De=H.pageY-fe.y,ee=Math.sqrt(Re*Re+De*De);_.set(0,ee),b.set(0,Math.pow(_.y/p.y,n.zoomSpeed)),re(b.y),p.copy(_);const j=(H.pageX+fe.x)*.5,ye=(H.pageY+fe.y)*.5;te(j,ye)}function _t(H){n.enableZoom&&Ue(H),n.enablePan&&Ie(H)}function nt(H){n.enableZoom&&Ue(H),n.enableRotate&&Le(H)}function B(H){n.enabled!==!1&&(A.length===0&&(n.domElement.setPointerCapture(H.pointerId),n.domElement.addEventListener(\"pointermove\",N),n.domElement.addEventListener(\"pointerup\",se)),rt(H),H.pointerType===\"touch\"?Qe(H):_e(H))}function N(H){n.enabled!==!1&&(H.pointerType===\"touch\"?me(H):pe(H))}function se(H){Ye(H),A.length===0&&(n.domElement.releasePointerCapture(H.pointerId),n.domElement.removeEventListener(\"pointermove\",N),n.domElement.removeEventListener(\"pointerup\",se)),n.dispatchEvent(Mh),s=i.NONE}function _e(H){let fe;switch(H.button){case 0:fe=n.mouseButtons.LEFT;break;case 1:fe=n.mouseButtons.MIDDLE;break;case 2:fe=n.mouseButtons.RIGHT;break;default:fe=-1}switch(fe){case dr.DOLLY:if(n.enableZoom===!1)return;he(H),s=i.DOLLY;break;case dr.ROTATE:if(H.ctrlKey||H.metaKey||H.shiftKey){if(n.enablePan===!1)return;$(H),s=i.PAN}else{if(n.enableRotate===!1)return;ce(H),s=i.ROTATE}break;case dr.PAN:if(H.ctrlKey||H.metaKey||H.shiftKey){if(n.enableRotate===!1)return;ce(H),s=i.ROTATE}else{if(n.enablePan===!1)return;$(H),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(qc)}function pe(H){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;ue(H);break;case i.DOLLY:if(n.enableZoom===!1)return;Me(H);break;case i.PAN:if(n.enablePan===!1)return;xe(H);break}}function ve(H){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(H.preventDefault(),n.dispatchEvent(qc),ge(Fe(H)),n.dispatchEvent(Mh))}function Fe(H){const fe=H.deltaMode,Re={clientX:H.clientX,clientY:H.clientY,deltaY:H.deltaY};switch(fe){case 1:Re.deltaY*=16;break;case 2:Re.deltaY*=100;break}return H.ctrlKey&&!S&&(Re.deltaY*=10),Re}function we(H){H.key===\"Control\"&&(S=!0,document.addEventListener(\"keyup\",Ne,{passive:!0,capture:!0}))}function Ne(H){H.key===\"Control\"&&(S=!1,document.removeEventListener(\"keyup\",Ne,{passive:!0,capture:!0}))}function je(H){n.enabled===!1||n.enablePan===!1||Ge(H)}function Qe(H){switch(Pe(H),A.length){case 1:switch(n.touches.ONE){case hr.ROTATE:if(n.enableRotate===!1)return;Ke(H),s=i.TOUCH_ROTATE;break;case hr.PAN:if(n.enablePan===!1)return;He(H),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case hr.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;W(H),s=i.TOUCH_DOLLY_PAN;break;case hr.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ze(H),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(qc)}function me(H){switch(Pe(H),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Le(H),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;Ie(H),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;_t(H),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;nt(H),n.update();break;default:s=i.NONE}}function ft(H){n.enabled!==!1&&H.preventDefault()}function rt(H){A.push(H.pointerId)}function Ye(H){delete I[H.pointerId];for(let fe=0;fe<A.length;fe++)if(A[fe]==H.pointerId){A.splice(fe,1);return}}function Pe(H){let fe=I[H.pointerId];fe===void 0&&(fe=new Ve,I[H.pointerId]=fe),fe.set(H.pageX,H.pageY)}function Ce(H){const fe=H.pointerId===A[0]?A[1]:A[0];return I[fe]}n.domElement.addEventListener(\"contextmenu\",ft),n.domElement.addEventListener(\"pointerdown\",B),n.domElement.addEventListener(\"pointercancel\",se),n.domElement.addEventListener(\"wheel\",ve,{passive:!1}),document.addEventListener(\"keydown\",we,{passive:!0,capture:!0}),this.update()}}var Hv=Object.defineProperty,Vv=(r,e,t)=>e in r?Hv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,xn=(r,e,t)=>Vv(r,typeof e!=\"symbol\"?e+\"\":e,t);class Yc extends Error{constructor(e){super(`Unsupported format: \"${e}\"`),xn(this,\"format\"),this.name=\"UnsupportedFormatError\",this.format=e,Object.setPrototypeOf(this,Yc.prototype)}}class Fi extends Error{constructor(e,t){super(e),xn(this,\"cause\"),this.name=\"CorruptFileError\",this.cause=t,Object.setPrototypeOf(this,Fi.prototype)}}class za extends Error{constructor(e,t,n){super(e),xn(this,\"status\"),xn(this,\"url\"),this.name=\"NetworkError\",this.status=t,this.url=n,Object.setPrototypeOf(this,za.prototype)}}function Ga(r){r.position.set(0,0,0),r.scale.set(1,1,1),r.updateMatrixWorld(!0);const e=new bt().setFromObject(r),t=e.getCenter(new O),n=e.getSize(new O),i=Math.max(n.x,n.y,n.z),s=i>0?1/i:1;r.scale.setScalar(s),r.position.sub(t.multiplyScalar(s)),r.updateMatrixWorld(!0),r.userData.normalizedScale=s,r.userData.originalMaxDim=i}const Kc=\"https://www.gstatic.com/draco/versioned/decoders/1.5.6/\";if(typeof globalThis.FileReader>\"u\"){class r{constructor(){xn(this,\"result\",null),xn(this,\"onloadend\",null),xn(this,\"onload\",null),xn(this,\"onerror\",null)}readAsArrayBuffer(t){t.arrayBuffer().then(n=>{var i,s;this.result=n,(i=this.onload)==null||i.call(this),(s=this.onloadend)==null||s.call(this)},n=>{var i,s;(i=this.onerror)==null||i.call(this,n),(s=this.onloadend)==null||s.call(this)})}readAsDataURL(t){t.arrayBuffer().then(n=>{var i,s;const a=globalThis.Buffer,o=a?a.from(n).toString(\"base64\"):\"\";this.result=`data:${t.type};base64,${o}`,(i=this.onload)==null||i.call(this),(s=this.onloadend)==null||s.call(this)},n=>{var i,s;(i=this.onerror)==null||i.call(this,n),(s=this.onloadend)==null||s.call(this)})}}globalThis.FileReader=r}const Wv=50*1024*1024;async function jv(r,e,t){const n=[];switch(r.data.byteLength>Wv&&n.push(\"File exceeds 50 MB; performance may be affected\"),r.format){case\"glb\":case\"gltf\":return Xv(r,n,e,(t==null?void 0:t.normalize)??!0);case\"stl\":return qv(r,n);case\"obj\":return Yv(r,n)}}function Eh(r){const e=new W_,t=new Ev;return t.setDecoderPath((r==null?void 0:r.dracoDecoderPath)??Kc),e.setDRACOLoader(t),e.setMeshoptDecoder(wv),{loader:e,dispose:()=>{t.dispose()}}}async function Xv(r,e,t,n=!0){const{loader:i,dispose:s}=Eh({dracoDecoderPath:t});try{const a=await new Promise((o,c)=>{i.parse(r.data,\"\",o,c)});return n&&Ga(a.scene),{scene:a.scene,animations:a.animations,warnings:e}}catch(a){throw new Fi(\"Failed to parse GLTF/GLB\",a)}finally{s()}}async function qv(r,e){let t;try{t=(await Promise.resolve().then(()=>Hy)).STLLoader}catch(c){throw new Fi(\"Failed to load STL parser module. Please check your network connection.\",c)}const n=new t;let i;try{i=n.parse(r.data)}catch(c){throw new Fi(\"Failed to parse STL\",c)}const s=new vn({name:\"metal\",color:12632256,metalness:1,roughness:.1,envMapIntensity:1}),a=new We(i,s);a.name=\"metal\";const o=new Pt;return o.add(a),Ga(o),{scene:o,warnings:e}}async function Yv(r,e){let t,n;try{const[o,c]=await Promise.all([Promise.resolve().then(()=>Ky),Promise.resolve().then(()=>Jy)]);t=o.OBJLoader,n=c.MTLLoader}catch(o){throw new Fi(\"Failed to load OBJ parser module. Please check your network connection.\",o)}r.mtlData||e.push(\"No material file provided; default material applied\");let i;if(r.mtlData){const o=new n,c=new TextDecoder().decode(r.mtlData);try{i=o.parse(c,\"\"),i.preload()}catch{e.push(\"Failed to parse MTL file; default material applied\"),i=void 0}}const s=new t;i&&s.setMaterials(i);let a;try{const o=new TextDecoder().decode(r.data);a=s.parse(o)}catch(o){throw new Fi(\"Failed to parse OBJ\",o)}return Ga(a),{scene:a,warnings:e}}async function Kv(r){let e;try{e=(await Promise.resolve().then(()=>yM)).GLTFExporter}catch(n){throw new Fi(\"Failed to load GLTFExporter module. Please check your network connection.\",n)}const t=new e;return new Promise((n,i)=>{t.parse(r,s=>{if(s instanceof ArrayBuffer)n(s);else{const a=JSON.stringify(s),o=new TextEncoder().encode(a);n(o.buffer)}},i,{binary:!0})})}class Zv{constructor(){xn(this,\"_listeners\",new Map)}on(e,t){return this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){var n;(n=this._listeners.get(e))==null||n.delete(t)}emit(e,t){var n;(n=this._listeners.get(e))==null||n.forEach(i=>{try{i(t)}catch(s){console.error(`[3d-viewer] uncaught listener error on \"${String(e)}\":`,s)}})}clear(){this._listeners.clear()}}const $v={\"model/gltf-binary\":\"glb\",\"model/gltf+json\":\"gltf\",\"model/stl\":\"stl\",\"application/sla\":\"stl\",\"application/vnd.ms-pki.stl\":\"stl\",\"application/x-stl\":\"stl\",\"model/x.stl-binary\":\"stl\",\"model/x.stl-ascii\":\"stl\",\"model/obj\":\"obj\",\"text/plain\":\"obj\"},Jv={glb:\"glb\",gltf:\"gltf\",stl:\"stl\",obj:\"obj\"};function Qv(r){try{const e=new URL(r,\"http://dummy\").pathname.match(/\\.([a-zA-Z0-9]+)$/);if(!e)return null;const t=e[1].toLowerCase();return Jv[t]??null}catch{return null}}function ex(r){const e=r.split(\";\")[0].trim().toLowerCase();return $v[e]??null}function Zc(r){if(r.byteLength<4)return!1;const e=new Uint8Array(r,0,4);return e[0]===103&&e[1]===108&&e[2]===84&&e[3]===70}function $c(r){if(r.byteLength<1)return!1;const e=new Uint8Array(r,0,Math.min(r.byteLength,256));for(let t=0;t<e.length;t++){const n=e[t];if(!(n===32||n===9||n===10||n===13||n===0))return n===123}return!1}function Th(r){if(r.byteLength<4)return null;if(Zc(r))return\"glb\";if($c(r))return\"gltf\";const e=new Uint8Array(r,0,Math.min(r.byteLength,128)),t=String.fromCharCode(...e).toLowerCase();if(t.startsWith(\"solid\")||t.slice(0,80).includes(\"rhinoceros\"))return\"stl\";if(r.byteLength>=84){const n=new DataView(r).getUint32(80,!0),i=84+n*50;if(n>0&&Math.abs(r.byteLength-i)<50)return\"stl\"}return/^\\s*(#|v\\s|vn\\s|vt\\s|f\\s|mtllib\\s|o\\s|g\\s)/.test(t)?\"obj\":null}async function wh(r){const e=new Uint8Array(r);if(e.length>=2&&e[0]===31&&e[1]===139&&typeof DecompressionStream<\"u\")try{const t=new DecompressionStream(\"gzip\"),n=new Blob([r]).stream().pipeThrough(t),i=await new Response(n).arrayBuffer();if(i.byteLength>0)return i}catch(t){console.warn(\"[fetchSource] Decompression failed, proceeding with original buffer:\",t)}return r}async function tx(r,e){const t=typeof r==\"string\"?{url:r}:r;if(t&&typeof t==\"object\"&&\"data\"in t){let c=t.data instanceof Blob?await t.data.arrayBuffer():t.data;c=await wh(c);const l=t.mtlData instanceof Blob?await t.mtlData.arrayBuffer():t.mtlData,u=Th(c);let d=t.format||u||\"glb\";return(d===\"glb\"||d===\"gltf\")&&!Zc(c)&&!$c(c)&&u&&(d=u),{data:c,mtlData:l,format:d}}let n=t.format??Qv(t.url);const i=await fetch(t.url,{headers:t.headers,signal:e}).catch(c=>{throw c.name===\"AbortError\"?c:new za(`Fetch failed: ${c.message}`,void 0,t.url)});if(!i.ok)throw new za(`HTTP ${i.status}`,i.status,t.url);if(!n){const c=i.headers.get(\"content-type\")??\"\";n=ex(c)}let s=await i.arrayBuffer();s=await wh(s);const a=Th(s);if((n===\"glb\"||n===\"gltf\")&&!Zc(s)&&!$c(s)&&a&&(n=a),n||(n=a),!n)throw new Yc(\"unknown\");let o;if(t.mtlUrl){const c=await fetch(t.mtlUrl,{headers:t.headers,signal:e});c.ok&&(o=await c.arrayBuffer())}return{data:s,mtlData:o,format:n}}async function nx(r,e,t,n){t==null||t(0);const i=await tx(r,e);t==null||t(.3);const{scene:s,animations:a,warnings:o}=await jv(i,n==null?void 0:n.dracoDecoderPath,{normalize:(n==null?void 0:n.normalize)??!0});t==null||t(.7);const c=i.format===\"glb\"?i.data:await Kv(s);t==null||t(1);let l=0;return s.traverse(u=>{u.isMesh&&l++}),{glb:c,scene:s,animations:a,sourceFormat:i.format,meshCount:l,warnings:o}}const ix=[\"stone\",\"diamond\",\"gem\",\"jewel\",\"crystal\"],rx=[\"metal\",\"gold\",\"silver\",\"platinum\",\"band\",\"ring\",\"prong\",\"shank\"];function Ah(r,e){const t=r.toLowerCase();return e.some(n=>t.includes(n))}function Rh(r){return r.trim().replace(/[^a-zA-Z0-9_-]/g,\"_\")}function sx(r,e,t){var n,i;if(typeof((n=r.userData)==null?void 0:n.partId)==\"string\"&&r.userData.partId.trim()){const l=r.userData.partId.trim();return t.add(l),l}if(typeof((i=r.userData)==null?void 0:i.id)==\"string\"&&r.userData.id.trim()){const l=r.userData.id.trim();return t.add(l),l}if(r.name&&r.name.trim()){const l=r.name.trim();if(!t.has(l))return t.add(l),l}let s=r.name?r.name.trim():\"mesh\",a=r.parent;for(;a&&a!==e;)a.name&&a.name.trim()&&(s=`${a.name.trim()}/${s}`),a=a.parent;let o=s,c=1;for(;t.has(o);)o=`${s}_${c++}`;return t.add(o),o}function ax(r){var e,t,n;if(Array.isArray((e=r.userData)==null?void 0:e.originalSlots)&&r.userData.originalSlots.length>0)return r.userData.originalSlots;if(Array.isArray(r.material))return r.material.map((a,o)=>{var c,l;const u=((c=a==null?void 0:a.name)==null?void 0:c.trim())||`Material_${o}`;return{slotId:typeof((l=a==null?void 0:a.userData)==null?void 0:l.slotId)==\"string\"&&a.userData.slotId||`slot_${o}_${Rh(u)}`,materialName:u,index:o}});const i=r.material,s=((t=i==null?void 0:i.name)==null?void 0:t.trim())||(r.name?`${r.name}_mat`:\"default\");return[{slotId:typeof((n=i==null?void 0:i.userData)==null?void 0:n.slotId)==\"string\"&&i.userData.slotId||`slot_0_${Rh(s)}`,materialName:s,index:0}]}function ox(r,e){const t=`${r} ${e}`,n=Ah(t,ix);return Ah(t,rx),n?\"stone\":\"metal\"}function Ha(r,e){const t=[],n=new Set;return r.traverse(i=>{var s;if(!(i instanceof We))return;const a=i,o=sx(a,r,n);a.userData.partId=o;const c=ax(a);a.userData.originalSlots=c;const l=((s=c[0])==null?void 0:s.materialName)??\"\";a.userData.originalMaterialName=l;const u=c.map(f=>f.materialName).join(\" \"),d=a.uuid in e||o in e,h=e[o]??e[a.uuid];d&&h?t.push({meshId:a.uuid,partId:o,meshName:a.name,materialName:l,slots:c,type:h,overridden:!0}):t.push({meshId:a.uuid,partId:o,meshName:a.name,materialName:l,slots:c,type:ox(a.name,u),overridden:!1})}),t}function Ch(r){const e=new Map;for(const t of r)for(const n of t.slots){const i=e.get(n.slotId);i?(i.partIds.includes(t.partId)||i.partIds.push(t.partId),i.meshIds.includes(t.meshId)||i.meshIds.push(t.meshId),i.type!==\"stone\"&&t.type===\"stone\"&&(i.type=\"stone\")):e.set(n.slotId,{slotId:n.slotId,name:n.materialName,type:t.type,partIds:[t.partId],meshIds:[t.meshId]})}return Array.from(e.values())}const Ns=[{id:\"rose-gold-18k\",label:\"Rose Gold\",hex:\"#e8927c\",metalness:1,roughness:.04,category:\"gold\",specularColor:\"#ffd7cb\",density:15400,thumbnail:\"/thumbnails/rose-gold-18k.svg\"},{id:\"rmj-custom-yellow-gold\",label:\"Custom Yellow Gold\",hex:\"#ffc766\",metalness:1,roughness:0,category:\"gold\",specularColor:\"#ffffff\",ior:1.5,source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-custom-yellow-gold.svg\"},{id:\"rmj-white-gold-polished\",label:\"White Gold Polished\",hex:\"#c2c2c3\",metalness:1,roughness:0,category:\"gold\",specularColor:\"#ffffff\",ior:1.5,source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-white-gold-polished.svg\"},{id:\"rmj-platinum-polished\",label:\"Platinum Polished\",hex:\"#b9bbbc\",metalness:1,roughness:0,category:\"platinum-silver\",specularColor:\"#ffffff\",ior:1.5,source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-platinum-polished.svg\"}],Oi=[{id:\"rmj-diamond-d-colorless\",label:\"Diamond D Colorless\",hex:\"#ececec\",ior:2.4,transmission:.98,roughness:0,category:\"diamond\",dispersion:.004,absorptionFactor:1,boostFactors:[2,2,2],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-diamond-d-colorless.svg\"},{id:\"rmj-ruby-1\",label:\"Ruby 1\",hex:\"#e14276\",ior:1.77,transmission:.88,roughness:0,category:\"gemstone\",dispersion:0,absorptionFactor:1.6,boostFactors:[1.3,.16,.9],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-ruby-1.svg\"},{id:\"rmj-emerald-1\",label:\"Emerald 1\",hex:\"#20cc95\",ior:1.577,transmission:.9,roughness:0,category:\"gemstone\",dispersion:.012,absorptionFactor:1,boostFactors:[.892,.892,.986],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-emerald-1.svg\"},{id:\"rmj-sapphire-cabachon-2\",label:\"Sapphire Cabochon 2\",hex:\"#45b1e1\",ior:1.66,transmission:.88,roughness:0,category:\"gemstone\",dispersion:0,absorptionFactor:2.51,boostFactors:[1,1,1],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-sapphire-cabachon-2.svg\"},{id:\"rmj-diamond-pink-2\",label:\"Diamond Pink 2\",hex:\"#f1bcd5\",ior:2.6,transmission:.94,roughness:0,category:\"diamond\",dispersion:.012,absorptionFactor:1,boostFactors:[1.3,1,1],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-diamond-pink-2.svg\"},{id:\"rmj-diamond-yellow-2\",label:\"Diamond Yellow 2\",hex:\"#fce88c\",ior:2.6,transmission:.94,roughness:0,category:\"diamond\",dispersion:.012,absorptionFactor:1.3,boostFactors:[1,1,1],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-diamond-yellow-2.svg\"},{id:\"rmj-diamond-blue-2\",label:\"Diamond Blue 2\",hex:\"#80c9fc\",ior:2.6,transmission:.94,roughness:0,category:\"diamond\",dispersion:.013,absorptionFactor:1,boostFactors:[.9,1,1],source:\"app.rendermyjewelry.com\",thumbnail:\"/thumbnails/rmj-diamond-blue-2.svg\"}];Ns.filter(r=>!r.id.startsWith(\"rmj-\")),Ns.filter(r=>r.id.startsWith(\"rmj-\")),Oi.filter(r=>r.category===\"diamond\"),Oi.filter(r=>r.category===\"gemstone\"),Oi.filter(r=>r.id.startsWith(\"rmj-\"));const Ph=new WeakMap;function cx(r){var e,t;r.boundingSphere||r.computeBoundingSphere();const n=(e=r.boundingSphere)!=null&&e.center?r.boundingSphere.center.clone():new O,i=((t=r.boundingSphere)==null?void 0:t.radius)??1,s=Math.max(i,.01),a=r.getAttribute(\"position\");if(!a||a.count===0)return{centroid:n,radius:s,triangleCount:0,starConvexFailureArea:1,isBakeable:!1,flippedWinding:!1};const o=r.getIndex(),c=o?o.count/3:a.count/3;let l=0,u=0,d=0;const h=new O,f=new O,g=new O,v=new O,m=new O,p=new O,_=new O;for(let E=0;E<c;E++){const T=o?o.getX(E*3):E*3,A=o?o.getX(E*3+1):E*3+1,I=o?o.getX(E*3+2):E*3+2;h.fromBufferAttribute(a,T).sub(n).divideScalar(s),f.fromBufferAttribute(a,A).sub(n).divideScalar(s),g.fromBufferAttribute(a,I).sub(n).divideScalar(s),v.subVectors(f,h),m.subVectors(g,h),p.crossVectors(v,m);const S=p.length();if(S<1e-12)continue;const R=S*.5;l+=R,p.divideScalar(S);const F=h.dot(p);_.crossVectors(f,g),d+=h.dot(_)/6,F<=1e-4&&(u+=R)}const b=l>0?u/l:1,x=d<0;return{centroid:n,radius:s,triangleCount:c,starConvexFailureArea:b,isBakeable:b<=.005&&!isNaN(l)&&l>0,flippedWinding:x}}function lx(r,e){const t=r.getIndex()!==null,n=t?r.toNonIndexed():r;try{const i=n.getAttribute(\"position\");if(!i)return new Float32Array(0);const s=i.count,a=new Float32Array(s*4),o=new O,c=new O,l=new O,u=new O,d=new O,h=new O,f=e.flippedWinding?-1:1;for(let g=0;g<s;g+=3){o.fromBufferAttribute(i,g).sub(e.centroid).divideScalar(e.radius),c.fromBufferAttribute(i,g+1).sub(e.centroid).divideScalar(e.radius),l.fromBufferAttribute(i,g+2).sub(e.centroid).divideScalar(e.radius),u.subVectors(c,o),d.subVectors(l,o),h.crossVectors(u,d).multiplyScalar(f);const v=h.length();v>1e-12?h.divideScalar(v):h.set(0,1,0);const m=o.dot(h);for(let p=0;p<3;p++){const _=(g+p)*4;a[_]=h.x,a[_+1]=h.y,a[_+2]=h.z,a[_+3]=m}}return a}finally{t&&n.dispose()}}function ux(r,e){const t=Ph.get(r);if(t)return t;const n=r.getAttribute(\"position\"),i=r.getIndex();let s=2166136261;const a=l=>{s^=l&255,s=Math.imul(s,16777619),s^=l>>8&255,s=Math.imul(s,16777619),s^=l>>16&255,s=Math.imul(s,16777619),s^=l>>24&255,s=Math.imul(s,16777619)};if(a(e.triangleCount),i)for(let l=0;l<i.count;l++)a(i.getX(l));const o=new O;for(let l=0;l<n.count;l++)o.fromBufferAttribute(n,l).sub(e.centroid).divideScalar(e.radius),a(Math.round(o.x*1e4)),a(Math.round(o.y*1e4)),a(Math.round(o.z*1e4));const c=(s>>>0).toString(16);return Ph.set(r,c),c}const Lh=0,dx=1,Ih=2,Dh=2,Jc=1.25,Nh=1,an=6*4+4+4,en=an/4,Qc=65535,hx=Qc<<16,Va=Math.pow(2,-24),el=Symbol(\"SKIP_GENERATION\"),Uh={strategy:Lh,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[el]:!1};function Ht(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function tl(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Fh(r,e){e.set(r)}function Oh(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function Wa(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Us(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function Vt(r,e){return e[r+15]===Qc}function tn(r,e){return e[r+6]}function hn(r,e){return e[r+14]}function nn(r){return r+en}function rn(r,e){const t=e[r+6];return r+t*en}function ja(r,e){return e[r+7]}function nl(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,h=1/0,f=1/0,g=-1/0,v=-1/0,m=-1/0;const p=r.offset||0;for(let _=(e-p)*6,b=(e+t-p)*6;_<b;_+=6){const x=r[_+0],E=r[_+1],T=x-E,A=x+E;T<s&&(s=T),A>c&&(c=A),x<d&&(d=x),x>g&&(g=x);const I=r[_+2],S=r[_+3],R=I-S,F=I+S;R<a&&(a=R),F>l&&(l=F),I<h&&(h=I),I>v&&(v=I);const U=r[_+4],V=r[_+5],P=U-V,z=U+V;P<o&&(o=P),z>u&&(u=z),U<f&&(f=U),U>m&&(m=U)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=d,i[1]=h,i[2]=f,i[3]=g,i[4]=v,i[5]=m}const mi=32,fx=(r,e)=>r.candidate-e.candidate,Bi=new Array(mi).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Xa=new Float32Array(6);function px(r,e,t,n,i,s){let a=-1,o=0;if(s===Lh)a=tl(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===dx)a=tl(r),a!==-1&&(o=mx(t,n,i,a));else if(s===Ih){const c=Us(r);let l=Jc*i;const u=t.offset||0,d=(n-u)*6,h=(n+i-u)*6;for(let f=0;f<3;f++){const g=e[f],v=(e[f+3]-g)/mi;if(i<mi/4){const m=[...Bi];m.length=i;let p=0;for(let b=d;b<h;b+=6,p++){const x=m[p];x.candidate=t[b+2*f],x.count=0;const{bounds:E,leftCacheBounds:T,rightCacheBounds:A}=x;for(let I=0;I<3;I++)A[I]=1/0,A[I+3]=-1/0,T[I]=1/0,T[I+3]=-1/0,E[I]=1/0,E[I+3]=-1/0;Wa(b,t,E)}m.sort(fx);let _=i;for(let b=0;b<_;b++){const x=m[b];for(;b+1<_&&m[b+1].candidate===x.candidate;)m.splice(b+1,1),_--}for(let b=d;b<h;b+=6){const x=t[b+2*f];for(let E=0;E<_;E++){const T=m[E];x>=T.candidate?Wa(b,t,T.rightCacheBounds):(Wa(b,t,T.leftCacheBounds),T.count++)}}for(let b=0;b<_;b++){const x=m[b],E=x.count,T=i-x.count,A=x.leftCacheBounds,I=x.rightCacheBounds;let S=0;E!==0&&(S=Us(A)/c);let R=0;T!==0&&(R=Us(I)/c);const F=Nh+Jc*(S*E+R*T);F<l&&(a=f,l=F,o=x.candidate)}}else{for(let _=0;_<mi;_++){const b=Bi[_];b.count=0,b.candidate=g+v+_*v;const x=b.bounds;for(let E=0;E<3;E++)x[E]=1/0,x[E+3]=-1/0}for(let _=d;_<h;_+=6){let b=~~((t[_+2*f]-g)/v);b>=mi&&(b=mi-1);const x=Bi[b];x.count++,Wa(_,t,x.bounds)}const m=Bi[mi-1];Fh(m.bounds,m.rightCacheBounds);for(let _=mi-2;_>=0;_--){const b=Bi[_],x=Bi[_+1];Oh(b.bounds,x.rightCacheBounds,b.rightCacheBounds)}let p=0;for(let _=0;_<mi-1;_++){const b=Bi[_],x=b.count,E=b.bounds,T=Bi[_+1].rightCacheBounds;x!==0&&(p===0?Fh(E,Xa):Oh(E,Xa,Xa)),p+=x;let A=0,I=0;p!==0&&(A=Us(Xa)/c);const S=i-p;S!==0&&(I=Us(T)/c);const R=Nh+Jc*(A*p+I*S);R<l&&(a=f,l=R,o=b.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function mx(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class il{constructor(){this.boundingData=new Float32Array(6)}}function gx(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let d=0;d<e;d++){let h=r[a*e+d];r[a*e+d]=r[o*e+d],r[o*e+d]=h}for(let d=0;d<6;d++){const h=a-u,f=o-u,g=t[h*6+d];t[h*6+d]=t[f*6+d],t[f*6+d]=g}a++,o--}else return a}}let Bh,qa,rl,kh;const bx=Math.pow(2,32);function sl(r){return\"count\"in r?1:1+sl(r.left)+sl(r.right)}function _x(r,e,t){return Bh=new Float32Array(t),qa=new Uint32Array(t),rl=new Uint16Array(t),kh=new Uint8Array(t),al(r,e)}function al(r,e){const t=r/4,n=r/2,i=\"count\"in e,s=e.boundingData;for(let a=0;a<6;a++)Bh[t+a]=s[a];if(i)return e.buffer?(kh.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(qa[t+6]=e.offset,rl[n+14]=e.count,rl[n+15]=Qc,r+an);{const{left:a,right:o,splitAxis:c}=e,l=r+an;let u=al(l,a);const d=r/an,h=u/an-d;if(h>bx)throw new Error(\"MeshBVH: Cannot store relative child node offset greater than 32 bits.\");return qa[t+6]=h,qa[t+7]=c,al(u,o)}}function vx(r,e,t,n,i,s){const{maxDepth:a,verbose:o,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:d}=i,h=r.primitiveBuffer,f=r.primitiveBufferStride,g=new Float32Array(6);let v=!1;const m=new il;return nl(e,t,n,m.boundingData,g),_(m,t,n,g),m;function p(b){d&&d((b-s.offset)/s.count)}function _(b,x,E,T=null,A=0){!v&&A>=a&&(v=!0,o&&console.warn(`BVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`));const I=E>l;if(E<=c&&!I||A>=a)return p(x+E),b.offset=x,b.count=E,b;const S=px(b.boundingData,T,e,x,E,u);let R=S.axis===-1?-1:gx(h,f,e,x,E,S);if(S.axis===-1||R===x||R===x+E){if(!I)return p(x+E),b.offset=x,b.count=E,b;S.axis=Math.max(0,tl(b.boundingData)),R=x+Math.max(1,Math.floor(E/2))}b.splitAxis=S.axis;const F=new il,U=x,V=R-x;b.left=F,nl(e,U,V,F.boundingData,g),_(F,U,V,g,A+1);const P=new il,z=R,X=E-V;return b.right=P,nl(e,z,X,P.boundingData,g),_(P,z,X,g,A+1),b}}function xx(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=vx(r,o,c.offset,c.count,e,a),u=sl(l),d=new t(an*u);return _x(0,l,d),d})}class ol{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class yx{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const It=new yx;let ki,Jr;const Qr=[],Ya=new ol(()=>new bt);function Mx(r,e,t,n,i,s){ki=Ya.getPrimitive(),Jr=Ya.getPrimitive(),Qr.push(ki,Jr),It.setBuffer(r._roots[e]);const a=cl(0,r.geometry,t,n,i,s);It.clearBuffer(),Ya.releasePrimitive(ki),Ya.releasePrimitive(Jr),Qr.pop(),Qr.pop();const o=Qr.length;return o>0&&(Jr=Qr[o-1],ki=Qr[o-2]),a}function cl(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=It;let u=r*2;if(Vt(u,c)){const d=tn(r,l),h=hn(u,c);return Ht(r,o,ki),n(d,h,!1,a,s+r/en,ki)}else{let d=function(F){const{uint16Array:U,uint32Array:V}=It;let P=F*2;for(;!Vt(P,U);)F=nn(F),P=F*2;return tn(F,V)},h=function(F){const{uint16Array:U,uint32Array:V}=It;let P=F*2;for(;!Vt(P,U);)F=rn(F,V),P=F*2;return tn(F,V)+hn(P,U)};const f=nn(r),g=rn(r,l);let v=f,m=g,p,_,b,x;if(i&&(b=ki,x=Jr,Ht(v,o,b),Ht(m,o,x),p=i(b),_=i(x),_<p)){v=g,m=f;const F=p;p=_,_=F,b=x}b||(b=ki,Ht(v,o,b));const E=Vt(v*2,c),T=t(b,E,p,a+1,s+v/en);let A;if(T===Dh){const F=d(v),U=h(v)-F;A=n(F,U,!0,a+1,s+v/en,b)}else A=T&&cl(v,e,t,n,i,s,a+1);if(A)return!0;x=Jr,Ht(m,o,x);const I=Vt(m*2,c),S=t(x,I,_,a+1,s+m/en);let R;if(S===Dh){const F=d(m),U=h(m)-F;R=n(F,U,!0,a+1,s+m/en,x)}else R=S&&cl(m,e,t,n,i,s,a+1);return!!R}}const Fs=new It.constructor,Ka=new It.constructor,zi=new ol(()=>new bt),es=new bt,ts=new bt,ll=new bt,ul=new bt;let dl=!1;function Sx(r,e,t,n){if(dl)throw new Error(\"MeshBVH: Recursive calls to bvhcast not supported.\");dl=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new qe().copy(t).invert();for(let u=0,d=i.length;u<d;u++){Fs.setBuffer(i[u]),c=0;const h=zi.getPrimitive();Ht(0,Fs.float32Array,h),h.applyMatrix4(l);for(let f=0,g=s.length;f<g&&(Ka.setBuffer(s[f]),a=Zn(0,0,t,l,n,o,c,0,0,h),Ka.clearBuffer(),c+=s[f].byteLength/an,!a);f++);if(zi.releasePrimitive(h),Fs.clearBuffer(),o+=i[u].byteLength/an,a)break}return dl=!1,a}function Zn(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let d,h;u?(d=Ka,h=Fs):(d=Fs,h=Ka);const f=d.float32Array,g=d.uint32Array,v=d.uint16Array,m=h.float32Array,p=h.uint32Array,_=h.uint16Array,b=r*2,x=e*2,E=Vt(b,v),T=Vt(x,_);let A=!1;if(T&&E)u?A=i(tn(e,p),hn(e*2,_),tn(r,g),hn(r*2,v),c,a+e/en,o,s+r/en):A=i(tn(r,g),hn(r*2,v),tn(e,p),hn(e*2,_),o,s+r/en,c,a+e/en);else if(T){const I=zi.getPrimitive();Ht(e,m,I),I.applyMatrix4(t);const S=nn(r),R=rn(r,g);Ht(S,f,es),Ht(R,f,ts);const F=I.intersectsBox(es),U=I.intersectsBox(ts);A=F&&Zn(e,S,n,t,i,a,s,c,o+1,I,!u)||U&&Zn(e,R,n,t,i,a,s,c,o+1,I,!u),zi.releasePrimitive(I)}else{const I=nn(e),S=rn(e,p);Ht(I,m,ll),Ht(S,m,ul);const R=l.intersectsBox(ll),F=l.intersectsBox(ul);if(R&&F)A=Zn(r,I,t,n,i,s,a,o,c+1,l,u)||Zn(r,S,t,n,i,s,a,o,c+1,l,u);else if(R)if(E)A=Zn(r,I,t,n,i,s,a,o,c+1,l,u);else{const U=zi.getPrimitive();U.copy(ll).applyMatrix4(t);const V=nn(r),P=rn(r,g);Ht(V,f,es),Ht(P,f,ts);const z=U.intersectsBox(es),X=U.intersectsBox(ts);A=z&&Zn(I,V,n,t,i,a,s,c,o+1,U,!u)||X&&Zn(I,P,n,t,i,a,s,c,o+1,U,!u),zi.releasePrimitive(U)}else if(F)if(E)A=Zn(r,S,t,n,i,s,a,o,c+1,l,u);else{const U=zi.getPrimitive();U.copy(ul).applyMatrix4(t);const V=nn(r),P=rn(r,g);Ht(V,f,es),Ht(P,f,ts);const z=U.intersectsBox(es),X=U.intersectsBox(ts);A=z&&Zn(S,V,n,t,i,a,s,c,o+1,U,!u)||X&&Zn(S,P,n,t,i,a,s,c,o+1,U,!u),zi.releasePrimitive(U)}}return A}const hl=new class{constructor(){let r=null,e=null,t=null,n=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(s,a)=>{if(n)throw new Error(\"BVHTraversalHelper: cannot call setBVH during an active traversal.\");this.root=a,this.buffer=r=s._roots[a],this.uint16Array=t=new Uint16Array(r),this.uint32Array=e=new Uint32Array(r)},this.reset=()=>{this.root=null,this.buffer=r=null,this.uint16Array=t=null,this.uint32Array=e=null},this.getRangeStart=s=>{let a=s*2;for(;!Vt(a,t);)s=nn(s),a=s*2;return tn(s,e)},this.getRangeEnd=s=>{let a=s*2;for(;!Vt(a,t);)s=rn(s,e),a=s*2;return tn(s,e)+hn(a,t)};const i=(s,a,o)=>{const c=a*2,l=Vt(c,t);if(!s(o,l,a)&&!l){const u=nn(a),d=rn(a,e);i(s,u,o+1),i(s,d,o+1)}};this.traverseBuffer=s=>{if(n)throw new Error(\"BVHTraversalHelper: cannot start a traversal during an active traversal.\");n=!0;try{i(s,0,0)}finally{n=!1}},this.traverse=s=>{this.traverseBuffer((a,o,c)=>{if(o){const l=c*2,u=e[c+6],d=t[l+14];return s(a,o,new Float32Array(r,c*4,6),u,d)}else{const l=ja(c,e);return s(a,o,new Float32Array(r,c*4,6),l)}})}}},zh=new bt,ns=new Float32Array(6);class Ex{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Uh,...e},\"maxLeafSize\"in e&&(console.warn('BVH: \"maxLeafSize\" option has been deprecated. Use \"targetLeafSize\", instead.'),e={...e,targetLeafSize:e.maxLeafSize}),xx(this,e)}getRootRanges(){throw new Error(\"BVH: getRootRanges() not implemented\")}writePrimitiveBounds(){throw new Error(\"BVH: writePrimitiveBounds() not implemented\")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=e,h=e+t;d<h;d++){this.writePrimitiveBounds(d,ns,0);const[f,g,v,m,p,_]=ns;f<s&&(s=f),m>c&&(c=m),g<a&&(a=g),p>l&&(l=p),v<o&&(o=v),_>u&&(u=_)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,ns,0);const[o,c,l,u,d,h]=ns,f=(o+u)/2,g=(c+d)/2,v=(l+h)/2,m=(u-o)/2,p=(d-c)/2,_=(h-l)/2,b=(s-i)*6;n[b+0]=f,n[b+1]=m+(Math.abs(f)+m)*Va,n[b+2]=g,n[b+3]=p+(Math.abs(g)+p)*Va,n[b+4]=v,n[b+5]=_+(Math.abs(v)+_)*Va}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/an;for(let l=0;l<c;l++){const u=en*l,d=2*u;Vt(d,o)&&(a[u+6]+=e)}}}}traverse(e,t=0){hl.setBVH(this,t),hl.traverse(e),hl.reset()}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/an;for(let l=c-1;l>=0;l--){const u=l*en,d=u*2;if(Vt(d,a)){const h=tn(u,s),f=hn(d,a);this.writePrimitiveRangeBounds(h,f,ns,0),o.set(ns,u)}else{const h=nn(u),f=rn(u,s);for(let g=0;g<3;g++){const v=o[h+g],m=o[h+g+3],p=o[f+g],_=o[f+g+3];o[u+g]=v<p?v:p,o[u+g+3]=m>_?m:_}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ht(0,new Float32Array(t),zh),e.union(zh)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const d=i;i=(h,f,g,v,m)=>d(h,f,g,v,m)?!0:o(h,f,this,s,g,v,a)}else i||(s?i=(d,h,f,g)=>o(d,h,this,s,f,g,a):i=(d,h,f)=>f);let c=!1,l=0;const u=this._roots;for(let d=0,h=u.length;d<h;d++){const f=u[d];if(c=Mx(this,d,n,i,t,l),c)break;l+=f.byteLength/an}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Sx(this,e,t,i)}}function Tx(){return typeof SharedArrayBuffer<\"u\"}function Za(r){return r.index?r.index.count:r.attributes.position.count}function $a(r){return Za(r)/3}function Gh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function wx(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Gh(t,n);r.setIndex(new vt(i,1));for(let s=0;s<t;s++)i[s]=s}}function Ax(r,e,t){const n=Za(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function Rx(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Hh(r,e,t){const n=Ax(r,e,t),i=Rx(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=Za(r)/t,l=[];for(const h of i){const{offset:f,count:g}=h,v=f,m=isFinite(g)?g:c-f,p=f+m;v<o&&p>a&&(l.push({pos:Math.max(a,v),isStart:!0}),l.push({pos:Math.min(o,p),isStart:!1}))}l.sort((h,f)=>h.pos!==f.pos?h.pos-f.pos:h.type===\"end\"?-1:1);let u=0,d=null;for(const h of l){const f=h.pos;u!==0&&f!==d&&s.push({offset:d,count:f-d}),u+=h.isStart?1:-1,d=f}return s}function Cx(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:u,count:d}=r[l];for(let h=0;h<d;h++)o[c+h]=u+h;c+=d}return o}class Px extends Ex{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error(\"BVH: InterleavedBufferAttribute is not supported for the index attribute.\")}else throw new Error(\"BVH: Only BufferGeometries are supported.\");if(t.useSharedArrayBuffer&&!Tx())throw new Error(\"BVH: SharedArrayBuffer is not available.\");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Uh,...t},t[el]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Hh(t,e.range,n),s=Cx(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else wx(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new bt))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Hh(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error(\"BVH: raycastObject3D() not implemented\")}}class gi{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}gi.prototype.setFromBox=function(){const r=new O;return function(e,t){const n=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){r.x=n.x*o+i.x*(1-o),r.y=n.y*c+i.y*(1-c),r.z=n.z*l+i.z*(1-l);const u=e.dot(r);s=Math.min(u,s),a=Math.max(u,a)}this.min=s,this.max=a}}();const Lx=function(){const r=new O,e=new O,t=new O;return function(n,i,s){const a=n.start,o=r,c=i.start,l=e;t.subVectors(a,c),r.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const u=t.dot(l),d=l.dot(o),h=l.dot(l),f=t.dot(o),g=o.dot(o)*h-d*d;let v,m;g!==0?v=(u*d-f*h)/g:v=0,m=(u+v*d)/h,s.x=v,s.y=m}}(),fl=function(){const r=new Ve,e=new O,t=new O;return function(n,i,s,a){Lx(n,i,r);let o=r.x,c=r.y;if(o>=0&&o<=1&&c>=0&&c<=1){n.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?n.at(0,s):n.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=n.start:l=n.end;let u;c<0?u=i.start:u=i.end;const d=e,h=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),d.distanceToSquared(u)<=h.distanceToSquared(l)){s.copy(d),a.copy(u);return}else{s.copy(l),a.copy(h);return}}}}(),Ix=function(){const r=new O,e=new O,t=new Qn,n=new pi;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:u}=s;if(n.start=c,n.end=l,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a||(n.start=c,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a)||(n.start=l,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a))return!0;const d=s.getPlane(t);if(Math.abs(d.distanceToPoint(o))<=a){const h=d.projectPoint(o,e);if(s.containsPoint(h))return!0}return!1}}(),Dx=[\"x\",\"y\",\"z\"],bi=1e-15,Vh=bi*bi;function Bn(r){return Math.abs(r)<bi}class $n extends ln{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new O),this.satBounds=new Array(4).fill().map(()=>new gi),this.points=[this.a,this.b,this.c],this.plane=new Qn,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new pi,this.needsUpdate=!0}intersectsSphere(e){return Ix(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const d=s[2],h=a[2];d.subVectors(t,n),h.setFromPoints(d,i);const f=s[3],g=a[3];f.subVectors(n,e),g.setFromPoints(f,i);const v=l.length(),m=d.length(),p=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,v<bi?m<bi||p<bi?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):m<bi?p<bi?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):p<bi&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}$n.prototype.closestPointToSegment=function(){const r=new O,e=new O,t=new pi;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let d=0;d<3;d++){const h=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[h]),fl(t,n,r,e),l=r.distanceToSquared(e),l<u&&(u=l,i&&i.copy(r),s&&s.copy(e))}return this.closestPointToPoint(a,r),l=a.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(a)),this.closestPointToPoint(o,r),l=o.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(o)),Math.sqrt(u)}}(),$n.prototype.intersectsTriangle=function(){const r=new $n,e=new gi,t=new gi,n=new O,i=new O,s=new O,a=new O,o=new pi,c=new pi,l=new O,u=new Ve,d=new Ve;function h(b,x,E,T){const A=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?A.copy(b.plane.normal):A.copy(x.plane.normal);const I=b.satBounds,S=b.satAxes;for(let U=1;U<4;U++){const V=I[U],P=S[U];if(e.setFromPoints(P,x.points),V.isSeparated(e)||(a.copy(A).cross(P),e.setFromPoints(a,b.points),t.setFromPoints(a,x.points),e.isSeparated(t)))return!1}const R=x.satBounds,F=x.satAxes;for(let U=1;U<4;U++){const V=R[U],P=F[U];if(e.setFromPoints(P,b.points),V.isSeparated(e)||(a.crossVectors(A,P),e.setFromPoints(a,b.points),t.setFromPoints(a,x.points),e.isSeparated(t)))return!1}return E&&(T||console.warn(\"ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.\"),E.start.set(0,0,0),E.end.set(0,0,0)),!0}function f(b,x,E,T,A,I,S,R,F,U,V){let P=S/(S-R);U.x=T+(A-T)*P,V.start.subVectors(x,b).multiplyScalar(P).add(b),P=S/(S-F),U.y=T+(I-T)*P,V.end.subVectors(E,b).multiplyScalar(P).add(b)}function g(b,x,E,T,A,I,S,R,F,U,V){if(A>0)f(b.c,b.a,b.b,T,x,E,F,S,R,U,V);else if(I>0)f(b.b,b.a,b.c,E,x,T,R,S,F,U,V);else if(R*F>0||S!=0)f(b.a,b.b,b.c,x,E,T,S,R,F,U,V);else if(R!=0)f(b.b,b.a,b.c,E,x,T,R,S,F,U,V);else if(F!=0)f(b.c,b.a,b.b,T,x,E,F,S,R,U,V);else return!0;return!1}function v(b,x,E,T){const A=x.degenerateSegment,I=b.plane.distanceToPoint(A.start),S=b.plane.distanceToPoint(A.end);return Bn(I)?Bn(S)?h(b,x,E,T):(E&&(E.start.copy(A.start),E.end.copy(A.start)),b.containsPoint(A.start)):Bn(S)?(E&&(E.start.copy(A.end),E.end.copy(A.end)),b.containsPoint(A.end)):b.plane.intersectLine(A,n)!=null?(E&&(E.start.copy(n),E.end.copy(n)),b.containsPoint(n)):!1}function m(b,x,E){const T=x.a;return Bn(b.plane.distanceToPoint(T))&&b.containsPoint(T)?(E&&(E.start.copy(T),E.end.copy(T)),!0):!1}function p(b,x,E){const T=b.degenerateSegment,A=x.a;return T.closestPointToPoint(A,!0,n),A.distanceToSquared(n)<Vh?(E&&(E.start.copy(A),E.end.copy(A)),!0):!1}function _(b,x,E,T){if(b.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const A=b.degenerateSegment,I=x.degenerateSegment,S=i,R=s;A.delta(S),I.delta(R);const F=n.subVectors(I.start,A.start),U=S.x*R.y-S.y*R.x;if(Bn(U))return!1;const V=(F.x*R.y-F.y*R.x)/U,P=-(S.x*F.y-S.y*F.x)/U;if(V<0||V>1||P<0||P>1)return!1;const z=A.start.z+S.z*V,X=I.start.z+R.z*P;return Bn(z-X)?(E&&(E.start.copy(A.start).addScaledVector(S,V),E.end.copy(A.start).addScaledVector(S,V)),!0):!1}else return x.isDegenerateIntoPoint?p(b,x,E):v(x,b,E,T);else{if(b.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(b.a)<Vh?(E&&(E.start.copy(b.a),E.end.copy(b.a)),!0):!1:x.isDegenerateIntoSegment?p(x,b,E):m(x,b,E);if(x.isDegenerateIntoPoint)return m(b,x,E);if(x.isDegenerateIntoSegment)return v(b,x,E,T)}}return function(b,x=null,E=!1){this.needsUpdate&&this.update(),b.isExtendedTriangle?b.needsUpdate&&b.update():(r.copy(b),r.update(),b=r);const T=_(this,b,x,E);if(T!==void 0)return T;const A=this.plane,I=b.plane;let S=I.distanceToPoint(this.a),R=I.distanceToPoint(this.b),F=I.distanceToPoint(this.c);Bn(S)&&(S=0),Bn(R)&&(R=0),Bn(F)&&(F=0);const U=S*R,V=S*F;if(U>0&&V>0)return!1;let P=A.distanceToPoint(b.a),z=A.distanceToPoint(b.b),X=A.distanceToPoint(b.c);Bn(P)&&(P=0),Bn(z)&&(z=0),Bn(X)&&(X=0);const re=P*z,J=P*X;if(re>0&&J>0)return!1;i.copy(A.normal),s.copy(I.normal);const te=i.cross(s);let Q=0,ce=Math.abs(te.x);const he=Math.abs(te.y);he>ce&&(ce=he,Q=1),Math.abs(te.z)>ce&&(Q=2);const $=Dx[Q],ue=this.a[$],Me=this.b[$],xe=this.c[$],ge=b.a[$],Ge=b.b[$],Ke=b.c[$];if(g(this,ue,Me,xe,U,V,S,R,F,u,o))return h(this,b,x,E);if(g(b,ge,Ge,Ke,re,J,P,z,X,d,c))return h(this,b,x,E);if(u.y<u.x){const He=u.y;u.y=u.x,u.x=He,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(d.y<d.x){const He=d.y;d.y=d.x,d.x=He,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(x&&(d.x>u.x?x.start.copy(c.start):x.start.copy(o.start),d.y<u.y?x.end.copy(c.end):x.end.copy(o.end)),!0)}}(),$n.prototype.distanceToPoint=function(){const r=new O;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),$n.prototype.distanceToTriangle=function(){const r=new O,e=new O,t=[\"a\",\"b\",\"c\"],n=new pi,i=new pi;return function(s,a=null,o=null){const c=a||o?n:null;if(this.intersectsTriangle(s,c,!0))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let u=0;u<3;u++){let d;const h=t[u],f=s[h];this.closestPointToPoint(f,r),d=f.distanceToSquared(r),d<l&&(l=d,a&&a.copy(r),o&&o.copy(f));const g=this[h];s.closestPointToPoint(g,r),d=g.distanceToSquared(r),d<l&&(l=d,a&&a.copy(g),o&&o.copy(r))}for(let u=0;u<3;u++){const d=t[u],h=t[(u+1)%3];n.set(this[d],this[h]);for(let f=0;f<3;f++){const g=t[f],v=t[(f+1)%3];i.set(s[g],s[v]),fl(n,i,r,e);const m=r.distanceToSquared(e);m<l&&(l=m,a&&a.copy(r),o&&o.copy(e))}}return Math.sqrt(l)}}();class yn{constructor(e,t,n){this.isOrientedBox=!0,this.min=new O,this.max=new O,this.matrix=new qe,this.invMatrix=new qe,this.points=new Array(8).fill().map(()=>new O),this.satAxes=new Array(3).fill().map(()=>new O),this.satBounds=new Array(3).fill().map(()=>new gi),this.alignedSatBounds=new Array(3).fill().map(()=>new gi),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}yn.prototype.update=function(){return function(){const r=this.matrix,e=this.min,t=this.max,n=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){const d=1*c|2*l|4*u,h=n[d];h.x=c?t.x:e.x,h.y=l?t.y:e.y,h.z=u?t.z:e.z,h.applyMatrix4(r)}const i=this.satBounds,s=this.satAxes,a=n[0];for(let c=0;c<3;c++){const l=s[c],u=i[c],d=1<<c,h=n[d];l.subVectors(a,h),u.setFromPoints(l,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,\"x\"),o[1].setFromPointsField(n,\"y\"),o[2].setFromPointsField(n,\"z\"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),yn.prototype.intersectsBox=function(){const r=new gi;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(r.min=t.x,r.max=n.x,a[0].isSeparated(r)||(r.min=t.y,r.max=n.y,a[1].isSeparated(r))||(r.min=t.z,r.max=n.z,a[2].isSeparated(r)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(r.setFromBox(c,e),l.isSeparated(r))return!1}return!0}}(),yn.prototype.intersectsTriangle=function(){const r=new $n,e=new Array(3),t=new gi,n=new gi,i=new O;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(r.copy(s),r.update(),s=r);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let d=0;d<3;d++){const h=a[d],f=o[d];if(t.setFromPoints(f,e),h.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let d=0;d<3;d++){const h=c[d],f=l[d];if(t.setFromPoints(f,u),h.isSeparated(t))return!1}for(let d=0;d<3;d++){const h=o[d];for(let f=0;f<4;f++){const g=l[f];if(i.crossVectors(h,g),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),yn.prototype.closestPointToPoint=function(){return function(r,e){return this.needsUpdate&&this.update(),e.copy(r).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),yn.prototype.distanceToPoint=function(){const r=new O;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),yn.prototype.distanceToBox=function(){const r=[\"x\",\"y\",\"z\"],e=new Array(12).fill().map(()=>new pi),t=new Array(12).fill().map(()=>new pi),n=new O,i=new O;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,n),s.closestPointToPoint(n,i),o&&o.copy(n),c&&c.copy(i)),0;const l=a*a,u=s.min,d=s.max,h=this.points;let f=1/0;for(let v=0;v<8;v++){const m=h[v];i.copy(m).clamp(u,d);const p=m.distanceToSquared(i);if(p<f&&(f=p,o&&o.copy(m),c&&c.copy(i),p<l))return Math.sqrt(p)}let g=0;for(let v=0;v<3;v++)for(let m=0;m<=1;m++)for(let p=0;p<=1;p++){const _=(v+1)%3,b=(v+2)%3,x=m<<_|p<<b,E=1<<v|m<<_|p<<b,T=h[x],A=h[E];e[g].set(T,A);const I=r[v],S=r[_],R=r[b],F=t[g],U=F.start,V=F.end;U[I]=u[I],U[S]=m?u[S]:d[S],U[R]=p?u[R]:d[S],V[I]=d[I],V[S]=m?u[S]:d[S],V[R]=p?u[R]:d[S],g++}for(let v=0;v<=1;v++)for(let m=0;m<=1;m++)for(let p=0;p<=1;p++){i.x=v?d.x:u.x,i.y=m?d.y:u.y,i.z=p?d.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<f&&(f=_,o&&o.copy(n),c&&c.copy(i),_<l))return Math.sqrt(_)}for(let v=0;v<12;v++){const m=e[v];for(let p=0;p<12;p++){const _=t[p];fl(m,_,n,i);const b=n.distanceToSquared(i);if(b<f&&(f=b,o&&o.copy(n),c&&c.copy(i),b<l))return Math.sqrt(b)}}return Math.sqrt(f)}}();class Nx extends ol{constructor(){super(()=>new $n)}}const kn=new Nx,Os=new O,pl=new O;function Ux(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(Os.copy(e).clamp(u.min,u.max),Os.distanceToSquared(e)),intersectsBounds:(u,d,h)=>h<o&&h<a,intersectsTriangle:(u,d)=>{u.closestPointToPoint(e,Os);const h=e.distanceToSquared(Os);return h<o&&(pl.copy(Os),o=h,c=d),h<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(pl):t.point=pl.clone(),t.distance=l,t.faceIndex=c,t}const Ja=parseInt(ds)>=169,Fx=parseInt(ds)<=161,ar=new O,or=new O,cr=new O,Qa=new Ve,eo=new Ve,to=new Ve,Wh=new O,jh=new O,Xh=new O,Bs=new O;function Ox(r,e,t,n,i,s,a,o){let c;if(s===on?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==wt,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function qh(r,e,t,n,i,s,a,o,c,l,u){ar.fromBufferAttribute(e,s),or.fromBufferAttribute(e,a),cr.fromBufferAttribute(e,o);const d=Ox(r,ar,or,cr,Bs,c,l,u);if(d){if(n){Qa.fromBufferAttribute(n,s),eo.fromBufferAttribute(n,a),to.fromBufferAttribute(n,o),d.uv=new Ve;const f=ln.getInterpolation(Bs,ar,or,cr,Qa,eo,to,d.uv);Ja||(d.uv=f)}if(i){Qa.fromBufferAttribute(i,s),eo.fromBufferAttribute(i,a),to.fromBufferAttribute(i,o),d.uv1=new Ve;const f=ln.getInterpolation(Bs,ar,or,cr,Qa,eo,to,d.uv1);Ja||(d.uv1=f),Fx&&(d.uv2=d.uv1)}if(t){Wh.fromBufferAttribute(t,s),jh.fromBufferAttribute(t,a),Xh.fromBufferAttribute(t,o),d.normal=new O;const f=ln.getInterpolation(Bs,ar,or,cr,Wh,jh,Xh,d.normal);d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1),Ja||(d.normal=f)}const h={a:s,b:a,c:o,normal:new O,materialIndex:0};if(ln.getNormal(ar,or,cr,h.normal),d.face=h,d.faceIndex=s,Ja){const f=new O;ln.getBarycoord(Bs,ar,or,cr,f),d.barycoord=f}}return d}function Yh(r){return r&&r.isMaterial?r.side:r}function no(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:d,groups:h}=r;r.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));const{position:f,normal:g,uv:v,uv1:m}=r.attributes;if(Array.isArray(e)){const p=n*3;for(let _=0,b=h.length;_<b;_++){const{start:x,count:E,materialIndex:T}=h[_];if(p>=x&&p<x+E){const A=Yh(e[T]),I=qh(t,f,g,v,m,c,l,u,A,s,a);if(I)if(I.faceIndex=n,I.face.materialIndex=T,i)i.push(I);else return I}}}else{const p=Yh(e),_=qh(t,f,g,v,m,c,l,u,p,s,a);if(_)if(_.faceIndex=n,_.face.materialIndex=0,i)i.push(_);else return _}return null}function Kt(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Bx(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++)no(c,e,t,u,s,a,o)}function kx(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,h=n+i;d<h;d++){let f;f=no(o,e,t,d,null,s,a),f&&f.distance<l&&(u=f,l=f.distance)}return u}function zx(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let h;if(h=u,Kt(a,h*3,c,l),a.needsUpdate=!0,n(a,h,i,s))return!0}return!1}function Gx(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let h=0,f=u.length;h<f;h++)s=u[h],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(h,f,g=!1){const v=h*2;if(Vt(v,o)){const m=tn(h,a),p=hn(v,o);let _=1/0,b=1/0,x=1/0,E=-1/0,T=-1/0,A=-1/0;for(let I=3*m,S=3*(m+p);I<S;I++){let R=n[I];const F=i.getX(R),U=i.getY(R),V=i.getZ(R);F<_&&(_=F),F>E&&(E=F),U<b&&(b=U),U>T&&(T=U),V<x&&(x=V),V>A&&(A=V)}return c[h+0]!==_||c[h+1]!==b||c[h+2]!==x||c[h+3]!==E||c[h+4]!==T||c[h+5]!==A?(c[h+0]=_,c[h+1]=b,c[h+2]=x,c[h+3]=E,c[h+4]=T,c[h+5]=A,!0):!1}else{const m=nn(h),p=rn(h,a);let _=g,b=!1,x=!1;if(e){if(!_){const R=m/en+f/an,F=p/en+f/an;b=e.has(R),x=e.has(F),_=!b&&!x}}else b=!0,x=!0;const E=_||b,T=_||x;let A=!1;E&&(A=d(m,f,_));let I=!1;T&&(I=d(p,f,_));const S=A||I;if(S)for(let R=0;R<3;R++){const F=m+R,U=p+R,V=c[F],P=c[F+3],z=c[U],X=c[U+3];c[h+R]=V<z?V:z,c[h+R+3]=P>X?P:X}return S}}}function Gi(r,e,t,n,i){let s,a,o,c,l,u;const d=1/t.direction.x,h=1/t.direction.y,f=1/t.direction.z,g=t.origin.x,v=t.origin.y,m=t.origin.z;let p=e[r],_=e[r+3],b=e[r+1],x=e[r+3+1],E=e[r+2],T=e[r+3+2];return d>=0?(s=(p-g)*d,a=(_-g)*d):(s=(_-g)*d,a=(p-g)*d),h>=0?(o=(b-v)*h,c=(x-v)*h):(o=(x-v)*h,c=(b-v)*h),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),f>=0?(l=(E-m)*f,u=(T-m)*f):(l=(T-m)*f,u=(E-m)*f),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function Hx(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++){let h=l?l[u]:u;no(c,e,t,h,s,a,o)}}function Vx(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,h=n+i;d<h;d++){let f;f=no(o,e,t,c?c[d]:d,null,s,a),f&&f.distance<l&&(u=f,l=f.distance)}return u}function Wx(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let h;if(h=t.resolveTriangleIndex(u),Kt(a,h*3,c,l),a.needsUpdate=!0,n(a,h,i,s))return!0}return!1}function jx(r,e,t,n,i,s,a){It.setBuffer(r._roots[e]),ml(0,r,t,n,i,s,a),It.clearBuffer()}function ml(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=It,u=r*2;if(Vt(u,c)){const d=tn(r,l),h=hn(u,c);Bx(e,t,n,d,h,i,s,a)}else{const d=nn(r);Gi(d,o,n,s,a)&&ml(d,e,t,n,i,s,a);const h=rn(r,l);Gi(h,o,n,s,a)&&ml(h,e,t,n,i,s,a)}}const Xx=[\"x\",\"y\",\"z\"];function qx(r,e,t,n,i,s){It.setBuffer(r._roots[e]);const a=gl(0,r,t,n,i,s);return It.clearBuffer(),a}function gl(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=It;let l=r*2;if(Vt(l,o)){const u=tn(r,c),d=hn(l,o);return kx(e,t,n,u,d,i,s)}else{const u=ja(r,c),d=Xx[u],h=n.direction[d]>=0;let f,g;h?(f=nn(r),g=rn(r,c)):(f=rn(r,c),g=nn(r));const v=Gi(f,a,n,i,s)?gl(f,e,t,n,i,s):null;if(v){const p=v.point[d];if(h?p<=a[g+u]:p>=a[g+u+3])return v}const m=Gi(g,a,n,i,s)?gl(g,e,t,n,i,s):null;return v&&m?v.distance<=m.distance?v:m:v||m||null}}const io=new bt,is=new $n,rs=new $n,ks=new qe,Kh=new yn,ro=new yn;function Yx(r,e,t,n){It.setBuffer(r._roots[e]);const i=bl(0,r,t,n);return It.clearBuffer(),i}function bl(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=It;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Kh.set(t.boundingBox.min,t.boundingBox.max,n),i=Kh),Vt(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,h=t.index,f=t.attributes.position,g=tn(r,o),v=hn(c,a);if(ks.copy(n).invert(),t.boundsTree)return Ht(r,s,ro),ro.matrix.copy(ks),ro.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:m=>ro.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let p=g*3,_=(v+g)*3;p<_;p+=3)if(Kt(rs,p,u,d),rs.needsUpdate=!0,m.intersectsTriangle(rs))return!0;return!1}});{const m=$a(t);for(let p=g*3,_=(v+g)*3;p<_;p+=3){Kt(is,p,u,d),is.a.applyMatrix4(ks),is.b.applyMatrix4(ks),is.c.applyMatrix4(ks),is.needsUpdate=!0;for(let b=0,x=m*3;b<x;b+=3)if(Kt(rs,b,h,f),rs.needsUpdate=!0,is.intersectsTriangle(rs))return!0}}}else{const l=nn(r),u=rn(r,o);return Ht(l,s,io),!!(i.intersectsBox(io)&&bl(l,e,t,n,i)||(Ht(u,s,io),i.intersectsBox(io)&&bl(u,e,t,n,i)))}}const so=new qe,_l=new yn,zs=new yn,Kx=new O,Zx=new O,$x=new O,Jx=new O;function Qx(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),_l.set(e.boundingBox.min,e.boundingBox.max,t),_l.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,d=e.index,h=kn.getPrimitive(),f=kn.getPrimitive();let g=Kx,v=Zx,m=null,p=null;i&&(m=$x,p=Jx);let _=1/0,b=null,x=null;return so.copy(t).invert(),zs.matrix.copy(so),r.shapecast({boundsTraverseOrder:E=>_l.distanceToBox(E),intersectsBounds:(E,T,A)=>A<_&&A<a?(T&&(zs.min.copy(E.min),zs.max.copy(E.max),zs.needsUpdate=!0),!0):!1,intersectsRange:(E,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>zs.distanceToBox(A),intersectsBounds:(A,I,S)=>S<_&&S<a,intersectsRange:(A,I)=>{for(let S=A,R=A+I;S<R;S++){Kt(f,3*S,d,u),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let F=E,U=E+T;F<U;F++){Kt(h,3*F,l,c),h.needsUpdate=!0;const V=h.distanceToTriangle(f,g,m);if(V<_&&(v.copy(g),p&&p.copy(m),_=V,b=F,x=S),V<s)return!0}}}});{const A=$a(e);for(let I=0,S=A;I<S;I++){Kt(f,3*I,d,u),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let R=E,F=E+T;R<F;R++){Kt(h,3*R,l,c),h.needsUpdate=!0;const U=h.distanceToTriangle(f,g,m);if(U<_&&(v.copy(g),p&&p.copy(m),_=U,b=R,x=I),U<s)return!0}}}}}),kn.releasePrimitive(h),kn.releasePrimitive(f),_===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(p):i.point=p.clone(),i.point.applyMatrix4(so),v.applyMatrix4(so),i.distance=v.sub(i.point).length(),i.faceIndex=x),n)}function ey(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let h=0,f=u.length;h<f;h++)s=u[h],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(h,f,g=!1){const v=h*2;if(Vt(v,o)){const m=tn(h,a),p=hn(v,o);let _=1/0,b=1/0,x=1/0,E=-1/0,T=-1/0,A=-1/0;for(let I=m,S=m+p;I<S;I++){const R=3*r.resolveTriangleIndex(I);for(let F=0;F<3;F++){let U=R+F;U=n?n[U]:U;const V=i.getX(U),P=i.getY(U),z=i.getZ(U);V<_&&(_=V),V>E&&(E=V),P<b&&(b=P),P>T&&(T=P),z<x&&(x=z),z>A&&(A=z)}}return c[h+0]!==_||c[h+1]!==b||c[h+2]!==x||c[h+3]!==E||c[h+4]!==T||c[h+5]!==A?(c[h+0]=_,c[h+1]=b,c[h+2]=x,c[h+3]=E,c[h+4]=T,c[h+5]=A,!0):!1}else{const m=nn(h),p=rn(h,a);let _=g,b=!1,x=!1;if(e){if(!_){const R=m/en+f/an,F=p/en+f/an;b=e.has(R),x=e.has(F),_=!b&&!x}}else b=!0,x=!0;const E=_||b,T=_||x;let A=!1;E&&(A=d(m,f,_));let I=!1;T&&(I=d(p,f,_));const S=A||I;if(S)for(let R=0;R<3;R++){const F=m+R,U=p+R,V=c[F],P=c[F+3],z=c[U],X=c[U+3];c[h+R]=V<z?V:z,c[h+R+3]=P>X?P:X}return S}}}function ty(r,e,t,n,i,s,a){It.setBuffer(r._roots[e]),vl(0,r,t,n,i,s,a),It.clearBuffer()}function vl(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=It,u=r*2;if(Vt(u,c)){const d=tn(r,l),h=hn(u,c);Hx(e,t,n,d,h,i,s,a)}else{const d=nn(r);Gi(d,o,n,s,a)&&vl(d,e,t,n,i,s,a);const h=rn(r,l);Gi(h,o,n,s,a)&&vl(h,e,t,n,i,s,a)}}const ny=[\"x\",\"y\",\"z\"];function iy(r,e,t,n,i,s){It.setBuffer(r._roots[e]);const a=xl(0,r,t,n,i,s);return It.clearBuffer(),a}function xl(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=It;let l=r*2;if(Vt(l,o)){const u=tn(r,c),d=hn(l,o);return Vx(e,t,n,u,d,i,s)}else{const u=ja(r,c),d=ny[u],h=n.direction[d]>=0;let f,g;h?(f=nn(r),g=rn(r,c)):(f=rn(r,c),g=nn(r));const v=Gi(f,a,n,i,s)?xl(f,e,t,n,i,s):null;if(v){const p=v.point[d];if(h?p<=a[g+u]:p>=a[g+u+3])return v}const m=Gi(g,a,n,i,s)?xl(g,e,t,n,i,s):null;return v&&m?v.distance<=m.distance?v:m:v||m||null}}const ao=new bt,ss=new $n,as=new $n,Gs=new qe,Zh=new yn,oo=new yn;function ry(r,e,t,n){It.setBuffer(r._roots[e]);const i=yl(0,r,t,n);return It.clearBuffer(),i}function yl(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=It;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Zh.set(t.boundingBox.min,t.boundingBox.max,n),i=Zh),Vt(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,h=t.index,f=t.attributes.position,g=tn(r,o),v=hn(c,a);if(Gs.copy(n).invert(),t.boundsTree)return Ht(r,s,oo),oo.matrix.copy(Gs),oo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:m=>oo.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(n),m.b.applyMatrix4(n),m.c.applyMatrix4(n),m.needsUpdate=!0;for(let p=g,_=v+g;p<_;p++)if(Kt(as,3*e.resolveTriangleIndex(p),u,d),as.needsUpdate=!0,m.intersectsTriangle(as))return!0;return!1}});{const m=$a(t);for(let p=g,_=v+g;p<_;p++){const b=e.resolveTriangleIndex(p);Kt(ss,3*b,u,d),ss.a.applyMatrix4(Gs),ss.b.applyMatrix4(Gs),ss.c.applyMatrix4(Gs),ss.needsUpdate=!0;for(let x=0,E=m*3;x<E;x+=3)if(Kt(as,x,h,f),as.needsUpdate=!0,ss.intersectsTriangle(as))return!0}}}else{const l=nn(r),u=rn(r,o);return Ht(l,s,ao),!!(i.intersectsBox(ao)&&yl(l,e,t,n,i)||(Ht(u,s,ao),i.intersectsBox(ao)&&yl(u,e,t,n,i)))}}const co=new qe,Ml=new yn,Hs=new yn,sy=new O,ay=new O,oy=new O,cy=new O;function ly(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ml.set(e.boundingBox.min,e.boundingBox.max,t),Ml.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,d=e.index,h=kn.getPrimitive(),f=kn.getPrimitive();let g=sy,v=ay,m=null,p=null;i&&(m=oy,p=cy);let _=1/0,b=null,x=null;return co.copy(t).invert(),Hs.matrix.copy(co),r.shapecast({boundsTraverseOrder:E=>Ml.distanceToBox(E),intersectsBounds:(E,T,A)=>A<_&&A<a?(T&&(Hs.min.copy(E.min),Hs.max.copy(E.max),Hs.needsUpdate=!0),!0):!1,intersectsRange:(E,T)=>{if(e.boundsTree){const A=e.boundsTree;return A.shapecast({boundsTraverseOrder:I=>Hs.distanceToBox(I),intersectsBounds:(I,S,R)=>R<_&&R<a,intersectsRange:(I,S)=>{for(let R=I,F=I+S;R<F;R++){const U=A.resolveTriangleIndex(R);Kt(f,3*U,d,u),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let V=E,P=E+T;V<P;V++){const z=r.resolveTriangleIndex(V);Kt(h,3*z,l,c),h.needsUpdate=!0;const X=h.distanceToTriangle(f,g,m);if(X<_&&(v.copy(g),p&&p.copy(m),_=X,b=V,x=R),X<s)return!0}}}})}else{const A=$a(e);for(let I=0,S=A;I<S;I++){Kt(f,3*I,d,u),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let R=E,F=E+T;R<F;R++){const U=r.resolveTriangleIndex(R);Kt(h,3*U,l,c),h.needsUpdate=!0;const V=h.distanceToTriangle(f,g,m);if(V<_&&(v.copy(g),p&&p.copy(m),_=V,b=R,x=I),V<s)return!0}}}}}),kn.releasePrimitive(h),kn.releasePrimitive(f),_===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(p):i.point=p.clone(),i.point.applyMatrix4(co),v.applyMatrix4(co),i.distance=v.sub(i.point).length(),i.faceIndex=x),n)}function $h(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const lo=new yn,uo=new Ji,Jh=new O,Qh=new qe,ef=new O,Sl=[\"getX\",\"getY\",\"getZ\"];class ho extends Px{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn(\"MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data.\"),c(s));const o=new ho(t,{...n,[el]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new vt(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const d=l[u],h=new Uint32Array(d),f=new Uint16Array(d);for(let g=0,v=d.byteLength/an;g<v;g++){const m=en*g,p=2*m;Vt(p,f)||(h[m+6]=h[m+6]/en-g)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: \"maxLeafTris\" option has been deprecated. Use \"targetLeafSize\", instead.'),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=(s?s[e]:e)*3;let l=c+0,u=c+1,d=c+2;o&&(l=o[l],u=o[u],d=o[d]);for(let h=0;h<3;h++){const f=a[Sl[h]](l),g=a[Sl[h]](u),v=a[Sl[h]](d);let m=f;g<m&&(m=g),v<m&&(m=v);let p=f;g>p&&(p=g),v>p&&(p=v),t[n+h]=m,t[n+h+3]=p}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error(\"MeshBVH: compute triangle bounds range is invalid.\");const l=a.array,u=a.offset||0;let d=3;a.isInterleavedBufferAttribute&&(d=a.data.stride);const h=[\"getX\",\"getY\",\"getZ\"],f=n.offset;for(let g=e,v=e+t;g<v;g++){const m=(s?s[g]:g)*3,p=(g-f)*6;let _=m+0,b=m+1,x=m+2;o&&(_=o[_],b=o[b],x=o[x]),c||(_=_*d+u,b=b*d+u,x=x*d+u);for(let E=0;E<3;E++){let T,A,I;c?(T=a[h[E]](_),A=a[h[E]](b),I=a[h[E]](x)):(T=l[_+E],A=l[b+E],I=l[x+E]);let S=T;A<S&&(S=A),I<S&&(S=I);let R=T;A>R&&(R=A),I>R&&(R=I);const F=(R-S)/2,U=E*2;n[p+U+0]=S+F,n[p+U+1]=F+(Math.abs(S)+F)*Va}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;Qh.copy(e.matrixWorld).invert(),uo.copy(t.ray).applyMatrix4(Qh),ef.setFromMatrixScale(e.matrixWorld),Jh.copy(uo.direction).multiply(ef);const s=Jh.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(uo,i,a,o);c=$h(c,e,t),c&&n.push(c)}else{const c=this.raycast(uo,i,a,o);for(let l=0,u=c.length;l<u;l++){const d=$h(c[l],e,t);d&&n.push(d)}}return n}refit(e=null){return(this.indirect?ey:Gx)(this,e)}raycast(e,t=Mn,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?ty:jx;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=Mn,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?iy:qx;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?ry:Yx;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=kn.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?Wx:zx});return kn.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=kn.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?g=>{const v=this.resolveTriangleIndex(g);Kt(a,v*3,o,c)}:g=>{Kt(a,g*3,o,c)},u=kn.getPrimitive(),d=e.geometry.index,h=e.geometry.attributes.position,f=e.indirect?g=>{const v=e.resolveTriangleIndex(g);Kt(u,v*3,d,h)}:g=>{Kt(u,g*3,d,h)};if(s){if(!(e instanceof ho))throw new Error('MeshBVH: \"intersectsTriangles\" callback can only be used with another MeshBVH.');const g=(v,m,p,_,b,x,E,T)=>{for(let A=p,I=p+_;A<I;A++){f(A),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let S=v,R=v+m;S<R;S++)if(l(S),a.needsUpdate=!0,s(a,u,S,A,b,x,E,T))return!0}return!1};if(i){const v=i;i=function(m,p,_,b,x,E,T,A){return v(m,p,_,b,x,E,T,A)?!0:g(m,p,_,b,x,E,T,A)}}else i=g}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return lo.set(e.min,e.max,t),lo.needsUpdate=!0,this.shapecast({intersectsBounds:n=>lo.intersectsBox(n),intersectsTriangle:n=>lo.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?ly:Qx)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Ux(this,e,t,n,i)}}function uy(r){switch(r){case 1:return\"R\";case 2:return\"RG\";case 3:return\"RGBA\";case 4:return\"RGBA\"}throw new Error}function dy(r){switch(r){case 1:return To;case 2:return Zl;case 3:return kt;case 4:return kt}}function tf(r){switch(r){case 1:return wo;case 2:return Zs;case 3:return ms;case 4:return ms}}class nf extends Vr{constructor(){super(),this.minFilter=yt,this.magFilter=yt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,n=e.itemSize,i=e.count;if(t!==null){if(n*i%t!==0)throw new Error(\"VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.\");e.itemSize=t,e.count=i*n/t}const s=e.itemSize,a=e.count,o=e.normalized,c=e.array.constructor,l=c.BYTES_PER_ELEMENT;let u=this._forcedType,d=s;if(u===null)switch(c){case Float32Array:u=jt;break;case Uint8Array:case Uint16Array:case Uint32Array:u=wn;break;case Int8Array:case Int16Array:case Int32Array:u=ps;break}let h,f,g,v,m=uy(s);switch(u){case jt:g=1,f=dy(s),o&&l===1?(v=c,m+=\"8\",c===Uint8Array?h=In:(h=Eo,m+=\"_SNORM\")):(v=Float32Array,m+=\"32F\",h=jt);break;case ps:m+=l*8+\"I\",g=o?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,f=tf(s),l===1?(v=Int8Array,h=Eo):l===2?(v=Int16Array,h=ql):(v=Int32Array,h=ps);break;case wn:m+=l*8+\"UI\",g=o?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,f=tf(s),l===1?(v=Uint8Array,h=In):l===2?(v=Uint16Array,h=Ks):(v=Uint32Array,h=wn);break}d===3&&(f===kt||f===ms)&&(d=4);const p=Math.ceil(Math.sqrt(a))||1,_=d*p*p,b=new v(_),x=e.normalized;e.normalized=!1;for(let E=0;E<a;E++){const T=d*E;b[T]=e.getX(E)/g,s>=2&&(b[T+1]=e.getY(E)/g),s>=3&&(b[T+2]=e.getZ(E)/g,d===4&&(b[T+3]=1)),s>=4&&(b[T+3]=e.getW(E)/g)}e.normalized=x,this.internalFormat=m,this.format=f,this.type=h,this.image.width=p,this.image.height=p,this.image.data=b,this.needsUpdate=!0,this.dispose(),e.itemSize=n,e.count=i}}class hy extends nf{constructor(){super(),this._forcedType=wn}}class fy extends nf{constructor(){super(),this._forcedType=jt}}class rf{constructor(){this.index=new hy,this.position=new fy,this.bvhBounds=new Vr,this.bvhContents=new Vr,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(my(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const n=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==n.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const i=Gh(Za(t));this._cachedIndexAttr=new vt(i,1,!1)}py(t,n,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:n,bvhContents:i}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),i&&i.dispose()}}function py(r,e,t){const n=t.array,i=r.index?r.index.array:null;for(let s=0,a=e.length;s<a;s++){const o=3*s,c=3*e[s];for(let l=0;l<3;l++)n[o+l]=i?i[c+l]:c+l}}function my(r,e,t){const n=r._roots;if(n.length!==1)throw new Error(\"MeshBVHUniformStruct: Multi-root BVHs not supported.\");const i=n[0],s=new Uint16Array(i),a=new Uint32Array(i),o=new Float32Array(i),c=i.byteLength/an,l=2*Math.ceil(Math.sqrt(c/2)),u=new Float32Array(4*l*l),d=Math.ceil(Math.sqrt(c)),h=new Uint32Array(2*d*d);for(let f=0;f<c;f++){const g=f*an/4,v=g*2,m=g;for(let p=0;p<3;p++)u[8*f+0+p]=o[m+0+p],u[8*f+4+p]=o[m+3+p];if(Vt(v,s)){const p=hn(v,s),_=tn(g,a),b=hx|p;h[f*2+0]=b,h[f*2+1]=_}else{const p=a[g+6],_=ja(g,a);h[f*2+0]=_,h[f*2+1]=p}}e.image.data=u,e.image.width=l,e.image.height=l,e.format=kt,e.type=jt,e.internalFormat=\"RGBA32F\",e.minFilter=yt,e.magFilter=yt,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose(),t.image.data=h,t.image.width=d,t.image.height=d,t.format=Zs,t.type=wn,t.internalFormat=\"RG32UI\",t.minFilter=yt,t.magFilter=yt,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose()}const gy=`\n\n// A stack of uint32 indices can can store the indices for\n// a perfectly balanced tree with a depth up to 31. Lower stack\n// depth gets higher performance.\n//\n// However not all trees are balanced. Best value to set this to\n// is the trees max depth.\n#ifndef BVH_STACK_DEPTH\n#define BVH_STACK_DEPTH 60\n#endif\n\n#ifndef INFINITY\n#define INFINITY 1e20\n#endif\n\n// Utilities\nuvec4 uTexelFetch1D( usampler2D tex, uint index ) {\n\n\tuint width = uint( textureSize( tex, 0 ).x );\n\tuvec2 uv;\n\tuv.x = index % width;\n\tuv.y = index / width;\n\n\treturn texelFetch( tex, ivec2( uv ), 0 );\n\n}\n\nivec4 iTexelFetch1D( isampler2D tex, uint index ) {\n\n\tuint width = uint( textureSize( tex, 0 ).x );\n\tuvec2 uv;\n\tuv.x = index % width;\n\tuv.y = index / width;\n\n\treturn texelFetch( tex, ivec2( uv ), 0 );\n\n}\n\nvec4 texelFetch1D( sampler2D tex, uint index ) {\n\n\tuint width = uint( textureSize( tex, 0 ).x );\n\tuvec2 uv;\n\tuv.x = index % width;\n\tuv.y = index / width;\n\n\treturn texelFetch( tex, ivec2( uv ), 0 );\n\n}\n\nvec4 textureSampleBarycoord( sampler2D tex, vec3 barycoord, uvec3 faceIndices ) {\n\n\treturn\n\t\tbarycoord.x * texelFetch1D( tex, faceIndices.x ) +\n\t\tbarycoord.y * texelFetch1D( tex, faceIndices.y ) +\n\t\tbarycoord.z * texelFetch1D( tex, faceIndices.z );\n\n}\n\nvoid ndcToCameraRay(\n\tvec2 coord, mat4 cameraWorld, mat4 invProjectionMatrix,\n\tout vec3 rayOrigin, out vec3 rayDirection\n) {\n\n\t// get camera look direction and near plane for camera clipping\n\tvec4 lookDirection = cameraWorld * vec4( 0.0, 0.0, - 1.0, 0.0 );\n\tvec4 nearVector = invProjectionMatrix * vec4( 0.0, 0.0, - 1.0, 1.0 );\n\tfloat near = abs( nearVector.z / nearVector.w );\n\n\t// get the camera direction and position from camera matrices\n\tvec4 origin = cameraWorld * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec4 direction = invProjectionMatrix * vec4( coord, 0.5, 1.0 );\n\tdirection /= direction.w;\n\tdirection = cameraWorld * direction - origin;\n\n\t// slide the origin along the ray until it sits at the near clip plane position\n\torigin.xyz += direction.xyz * near / dot( direction, lookDirection );\n\n\trayOrigin = origin.xyz;\n\trayDirection = direction.xyz;\n\n}\n`,by=`\n\n#ifndef TRI_INTERSECT_EPSILON\n#define TRI_INTERSECT_EPSILON 1e-5\n#endif\n\n// Raycasting\nbool intersectsBounds( vec3 rayOrigin, vec3 rayDirection, vec3 boundsMin, vec3 boundsMax, out float dist ) {\n\n\t// https://www.reddit.com/r/opengl/comments/8ntzz5/fast_glsl_ray_box_intersection/\n\t// https://tavianator.com/2011/ray_box.html\n\tvec3 invDir = 1.0 / rayDirection;\n\n\t// find intersection distances for each plane\n\tvec3 tMinPlane = invDir * ( boundsMin - rayOrigin );\n\tvec3 tMaxPlane = invDir * ( boundsMax - rayOrigin );\n\n\t// get the min and max distances from each intersection\n\tvec3 tMinHit = min( tMaxPlane, tMinPlane );\n\tvec3 tMaxHit = max( tMaxPlane, tMinPlane );\n\n\t// get the furthest hit distance\n\tvec2 t = max( tMinHit.xx, tMinHit.yz );\n\tfloat t0 = max( t.x, t.y );\n\n\t// get the minimum hit distance\n\tt = min( tMaxHit.xx, tMaxHit.yz );\n\tfloat t1 = min( t.x, t.y );\n\n\t// set distance to 0.0 if the ray starts inside the box\n\tdist = max( t0, 0.0 );\n\n\treturn t1 >= dist;\n\n}\n\nbool intersectsTriangle(\n\tvec3 rayOrigin, vec3 rayDirection, vec3 a, vec3 b, vec3 c,\n\tout vec3 barycoord, out vec3 norm, out float dist, out float side\n) {\n\n\t// https://stackoverflow.com/questions/42740765/intersection-between-line-and-triangle-in-3d\n\tvec3 edge1 = b - a;\n\tvec3 edge2 = c - a;\n\tnorm = cross( edge1, edge2 );\n\n\tfloat det = - dot( rayDirection, norm );\n\tfloat invdet = 1.0 / det;\n\n\tvec3 AO = rayOrigin - a;\n\tvec3 DAO = cross( AO, rayDirection );\n\n\tvec4 uvt;\n\tuvt.x = dot( edge2, DAO ) * invdet;\n\tuvt.y = - dot( edge1, DAO ) * invdet;\n\tuvt.z = dot( AO, norm ) * invdet;\n\tuvt.w = 1.0 - uvt.x - uvt.y;\n\n\t// set the hit information\n\tbarycoord = uvt.wxy; // arranged in A, B, C order\n\tdist = uvt.z;\n\tside = sign( det );\n\tnorm = side * normalize( norm );\n\n\t// add an epsilon to avoid misses between triangles\n\tuvt += vec4( TRI_INTERSECT_EPSILON );\n\n\treturn all( greaterThanEqual( uvt, vec4( 0.0 ) ) );\n\n}\n\nbool intersectTriangles(\n\t// geometry info and triangle range\n\tsampler2D positionAttr, usampler2D indexAttr, uint offset, uint count,\n\n\t// ray\n\tvec3 rayOrigin, vec3 rayDirection,\n\n\t// outputs\n\tinout float minDistance, inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord,\n\tinout float side, inout float dist\n) {\n\n\tbool found = false;\n\tvec3 localBarycoord, localNormal;\n\tfloat localDist, localSide;\n\tfor ( uint i = offset, l = offset + count; i < l; i ++ ) {\n\n\t\tuvec3 indices = uTexelFetch1D( indexAttr, i ).xyz;\n\t\tvec3 a = texelFetch1D( positionAttr, indices.x ).rgb;\n\t\tvec3 b = texelFetch1D( positionAttr, indices.y ).rgb;\n\t\tvec3 c = texelFetch1D( positionAttr, indices.z ).rgb;\n\n\t\tif (\n\t\t\tintersectsTriangle( rayOrigin, rayDirection, a, b, c, localBarycoord, localNormal, localDist, localSide )\n\t\t\t&& localDist < minDistance\n\t\t) {\n\n\t\t\tfound = true;\n\t\t\tminDistance = localDist;\n\n\t\t\tfaceIndices = uvec4( indices.xyz, i );\n\t\t\tfaceNormal = localNormal;\n\n\t\t\tside = localSide;\n\t\t\tbarycoord = localBarycoord;\n\t\t\tdist = localDist;\n\n\t\t}\n\n\t}\n\n\treturn found;\n\n}\n\nbool intersectsBVHNodeBounds( vec3 rayOrigin, vec3 rayDirection, sampler2D bvhBounds, uint currNodeIndex, out float dist ) {\n\n\tuint cni2 = currNodeIndex * 2u;\n\tvec3 boundsMin = texelFetch1D( bvhBounds, cni2 ).xyz;\n\tvec3 boundsMax = texelFetch1D( bvhBounds, cni2 + 1u ).xyz;\n\treturn intersectsBounds( rayOrigin, rayDirection, boundsMin, boundsMax, dist );\n\n}\n\n// use a macro to hide the fact that we need to expand the struct into separate fields\n#define\tbvhIntersectFirstHit(\t\tbvh,\t\trayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist\t)\t_bvhIntersectFirstHit(\t\tbvh.position, bvh.index, bvh.bvhBounds, bvh.bvhContents,\t\trayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist\t)\n\nbool _bvhIntersectFirstHit(\n\t// bvh info\n\tsampler2D bvh_position, usampler2D bvh_index, sampler2D bvh_bvhBounds, usampler2D bvh_bvhContents,\n\n\t// ray\n\tvec3 rayOrigin, vec3 rayDirection,\n\n\t// output variables split into separate variables due to output precision\n\tinout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord,\n\tinout float side, inout float dist\n) {\n\n\t// stack needs to be twice as long as the deepest tree we expect because\n\t// we push both the left and right child onto the stack every traversal\n\tint pointer = 0;\n\tuint stack[ BVH_STACK_DEPTH ];\n\tstack[ 0 ] = 0u;\n\n\tfloat triangleDistance = INFINITY;\n\tbool found = false;\n\twhile ( pointer > - 1 && pointer < BVH_STACK_DEPTH ) {\n\n\t\tuint currNodeIndex = stack[ pointer ];\n\t\tpointer --;\n\n\t\t// check if we intersect the current bounds\n\t\tfloat boundsHitDistance;\n\t\tif (\n\t\t\t! intersectsBVHNodeBounds( rayOrigin, rayDirection, bvh_bvhBounds, currNodeIndex, boundsHitDistance )\n\t\t\t|| boundsHitDistance > triangleDistance\n\t\t) {\n\n\t\t\tcontinue;\n\n\t\t}\n\n\t\tuvec2 boundsInfo = uTexelFetch1D( bvh_bvhContents, currNodeIndex ).xy;\n\t\tbool isLeaf = bool( boundsInfo.x & 0xffff0000u );\n\n\t\tif ( isLeaf ) {\n\n\t\t\tuint count = boundsInfo.x & 0x0000ffffu;\n\t\t\tuint offset = boundsInfo.y;\n\n\t\t\tfound = intersectTriangles(\n\t\t\t\tbvh_position, bvh_index, offset, count,\n\t\t\t\trayOrigin, rayDirection, triangleDistance,\n\t\t\t\tfaceIndices, faceNormal, barycoord, side, dist\n\t\t\t) || found;\n\n\t\t} else {\n\n\t\t\tuint leftIndex = currNodeIndex + 1u;\n\t\t\tuint splitAxis = boundsInfo.x & 0x0000ffffu;\n\t\t\tuint rightIndex = currNodeIndex + boundsInfo.y;\n\n\t\t\tbool leftToRight = rayDirection[ splitAxis ] >= 0.0;\n\t\t\tuint c1 = leftToRight ? leftIndex : rightIndex;\n\t\t\tuint c2 = leftToRight ? rightIndex : leftIndex;\n\n\t\t\t// set c2 in the stack so we traverse it later. We need to keep track of a pointer in\n\t\t\t// the stack while we traverse. The second pointer added is the one that will be\n\t\t\t// traversed first\n\t\t\tpointer ++;\n\t\t\tstack[ pointer ] = c2;\n\n\t\t\tpointer ++;\n\t\t\tstack[ pointer ] = c1;\n\n\t\t}\n\n\t}\n\n\treturn found;\n\n}\n`,_y=`\nstruct BVH {\n\n\tusampler2D index;\n\tsampler2D position;\n\n\tsampler2D bvhBounds;\n\tusampler2D bvhContents;\n\n};\n`,vy=_y,xy=`\n\t${gy}\n\t${by}\n`,yy=`\nuniform vec3 uCentroid;\nuniform float uRadius;\nattribute vec4 aFacet;\nvarying vec4 vFacet;\n\nvoid main() {\n vFacet = aFacet;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n`,My=`\nvarying vec4 vFacet;\n\nvoid main() {\n #ifdef GEM_NORMALS_UNORM\n // Map normal from [-1, 1] into [0, 1] range to prevent unsigned byte clamping\n vec3 encodedNormal = normalize(vFacet.xyz) * 0.5 + 0.5;\n gl_FragColor = vec4(encodedNormal, vFacet.w);\n #else\n gl_FragColor = vFacet;\n #endif\n}\n`,Sy=`\nvarying vec3 vWorldPos;\nvarying vec3 vLocalPos;\nvarying vec3 vLocalNormal;\nvarying vec3 vLocalCameraPos;\nvarying mat3 vModelRotation;\n\nuniform vec3 cameraPos;\n\nvoid main() {\n vLocalPos = position;\n #ifdef USE_NORMAL\n vLocalNormal = normal;\n #else\n vLocalNormal = vec3(0.0, 1.0, 0.0);\n #endif\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPos = worldPosition.xyz;\n vModelRotation = mat3(modelMatrix);\n vLocalCameraPos = (inverse(modelMatrix) * vec4(cameraPos, 1.0)).xyz;\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n}\n`,Ey=`\nprecision highp float;\nprecision highp int;\nprecision highp usampler2D;\nprecision highp isampler2D;\n\nout highp vec4 pc_fragColor;\n#define gl_FragColor pc_fragColor\n\n#ifdef USE_CUBE_ENV\n uniform samplerCube envMap;\n#else\n uniform sampler2D envMap;\n#endif\n\nuniform mat3 envRotationMatrix;\nuniform vec3 cameraPos;\nuniform float ior;\nuniform float dispersion;\nuniform float absorption;\nuniform float envIntensity;\nuniform float gamma;\nuniform vec3 color;\nuniform vec3 rgbBoost;\nuniform float transmission;\nuniform float reflectivity;\nuniform float facetSharpness;\nuniform int rayBounces;\nuniform float uRadius;\n\n${vy}\n${xy}\nuniform BVH bvh;\n\nvarying vec3 vWorldPos;\nvarying vec3 vLocalPos;\nvarying vec3 vLocalNormal;\nvarying vec3 vLocalCameraPos;\nvarying mat3 vModelRotation;\n\n#define PI 3.14159265359\n\nvec3 aces(vec3 col) {\n const float a = 2.51;\n const float b = 0.03;\n const float c = 2.43;\n const float d = 0.59;\n const float e = 0.14;\n return clamp((col * (a * col + b)) / (col * (c * col + d) + e), 0.0, 1.0);\n}\n\nfloat schlick(float cosTheta, float f0) {\n return clamp(f0 + (1.0 - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0), 0.0, 0.95);\n}\n\nvec3 sampleEnv(vec3 direction) {\n vec3 dir = normalize(envRotationMatrix * direction);\n #ifdef USE_CUBE_ENV\n return texture(envMap, dir).rgb;\n #else\n float v = asin(clamp(dir.y, -0.9999, 0.9999)) / PI + 0.5;\n float u = fract(atan(dir.z, dir.x) / (2.0 * PI) + 0.5);\n return textureLod(envMap, vec2(u, v), 0.0).rgb;\n #endif\n}\n\nvec3 sampleChromaticEnv(vec3 localR, vec3 localG, vec3 localB) {\n vec3 worldR = normalize(vModelRotation * localR);\n vec3 worldG = normalize(vModelRotation * localG);\n vec3 worldB = normalize(vModelRotation * localB);\n return vec3(sampleEnv(worldR).r, sampleEnv(worldG).g, sampleEnv(worldB).b);\n}\n\nvec3 traceDiamondBVH(vec3 localIncident, vec3 localNormal, float baseIor, float fire, int bounces) {\n vec3 entryRay = refract(localIncident, localNormal, 1.0 / baseIor);\n if (length(entryRay) < 0.001) entryRay = reflect(localIncident, localNormal);\n\n vec3 ray = normalize(entryRay);\n vec3 position = vLocalPos + ray * 0.0001;\n float weight = 1.0;\n float totalDistance = 0.0;\n float normRadius = max(uRadius, 0.01);\n\n vec3 targetColor = clamp(color, vec3(0.005), vec3(1.0));\n float density = max(absorption, 0.5);\n vec3 sigma = -log(targetColor) * density;\n\n // Dispersion per-channel refractive indices\n float delta = fire * 1.5;\n#ifdef CORRECT_DISPERSION_SIGN\n // Physical: red lower IOR, blue higher IOR\n float iorR = baseIor - delta;\n float iorG = baseIor;\n float iorB = baseIor + delta;\n#else\n // Reference quirk: inverted dispersion (red higher IOR, blue lower IOR)\n float iorR = baseIor + delta;\n float iorG = baseIor;\n float iorB = baseIor - delta;\n#endif\n\n // Critical angle for Total Internal Reflection (gem -> air)\n float critSinSq = max(0.0, 1.0 - 1.0 / (baseIor * baseIor));\n vec3 accumulated = vec3(0.0);\n\n for (int bounce = 0; bounce < 8; bounce++) {\n if (bounce >= bounces) break;\n\n uvec4 faceIndices;\n vec3 faceNormal;\n vec3 barycoord;\n float side;\n float distance;\n bool hit = bvhIntersectFirstHit(bvh, position, ray, faceIndices, faceNormal, barycoord, side, distance);\n if (!hit) break;\n\n vec3 hitPosition = position + ray * distance;\n totalDistance += distance;\n if (dot(faceNormal, ray) > 0.0) faceNormal = -faceNormal;\n\n float cosI = clamp(dot(-ray, faceNormal), 0.0, 1.0);\n float cosSq = cosI * cosI;\n\n if (cosSq <= critSinSq) {\n // Total Internal Reflection (TIR) — 100% of ray energy bounces internally\n#ifdef ACCUMULATE_TIR\n vec3 worldRay = normalize(vModelRotation * ray);\n vec3 envVal = sampleEnv(worldRay);\n vec3 beer = exp(-sigma * (totalDistance / normRadius));\n accumulated += weight * envVal * beer;\n#endif\n ray = reflect(ray, faceNormal);\n position = hitPosition + ray * 0.0001;\n } else {\n // Partial transmission and reflection via Snell & Fresnel\n float sinTransSq = baseIor * baseIor * (1.0 - cosSq);\n float cosT = sqrt(max(1.0 - sinTransSq, 0.0));\n float rParallel = (cosI - baseIor * cosT) / (cosI + baseIor * cosT);\n float rPerp = (baseIor * cosI - cosT) / (baseIor * cosI + cosT);\n float R = clamp(0.5 * (rParallel * rParallel + rPerp * rPerp), 0.0, 0.96);\n float T = 1.0 - R;\n\n // Chromatic exit refraction for each wavelength\n vec3 exitR = refract(ray, faceNormal, iorR);\n vec3 exitG = refract(ray, faceNormal, iorG);\n vec3 exitB = refract(ray, faceNormal, iorB);\n\n if (length(exitG) > 0.001 && weight * T > 0.002) {\n vec3 eR = length(exitR) > 0.001 ? exitR : exitG;\n vec3 eB = length(exitB) > 0.001 ? exitB : exitG;\n vec3 envVal = sampleChromaticEnv(eR, exitG, eB);\n vec3 beer = exp(-sigma * (totalDistance / normRadius));\n accumulated += weight * T * envVal * beer;\n }\n\n // Continue internal reflection with remaining weight\n ray = reflect(ray, faceNormal);\n position = hitPosition + ray * 0.0001;\n weight *= R;\n }\n\n if (weight < 0.005) break;\n }\n\n // Smooth exhaustion tail: sample final escaped direction\n if (weight > 0.005) {\n vec3 worldRay = normalize(vModelRotation * ray);\n vec3 envVal = sampleEnv(worldRay);\n vec3 beer = exp(-sigma * (totalDistance / normRadius));\n accumulated += weight * envVal * beer * 0.6;\n }\n\n return accumulated;\n}\n\nvoid main() {\n vec3 flatFacetNormal = normalize(cross(dFdx(vLocalPos), dFdy(vLocalPos)));\n #ifdef USE_NORMAL\n if (dot(flatFacetNormal, vLocalNormal) < 0.0) flatFacetNormal = -flatFacetNormal;\n vec3 localNormal = normalize(mix(vLocalNormal, flatFacetNormal, clamp(facetSharpness, 0.0, 1.0)));\n #else\n vec3 localNormal = flatFacetNormal;\n #endif\n\n vec3 localView = normalize(vLocalCameraPos - vLocalPos);\n vec3 localIncident = -localView;\n if (dot(localNormal, localIncident) > 0.0) localNormal = -localNormal;\n\n vec3 worldNormal = normalize(vModelRotation * localNormal);\n vec3 view = normalize(cameraPos - vWorldPos);\n vec3 incident = -view;\n if (dot(worldNormal, incident) > 0.0) worldNormal = -worldNormal;\n\n // External Fresnel (dielectric surface reflection)\n float cosTheta = clamp(dot(view, worldNormal), 0.0, 1.0);\n float r0 = pow((ior - 1.0) / (ior + 1.0), 2.0);\n#ifdef USE_CORRECT_FRESNEL\n // Physical: cosI from incident angle (DIAMOND_PLAN §3 physics fix)\n float fresnel = schlick(abs(dot(-incident, worldNormal)), r0);\n#else\n // Reference quirk: cosT (transmitted angle) — reproduces RMJ visual\n vec3 entryRefracted = refract(incident, worldNormal, 1.0 / ior);\n float fresnel = schlick(abs(dot(entryRefracted, -worldNormal)), r0);\n#endif\n vec3 externalReflection = sampleEnv(reflect(incident, worldNormal));\n\n // BVH ray-traced internal transmission with true multi-channel dispersion\n vec3 internalTransmission = traceDiamondBVH(localIncident, localNormal, ior, dispersion, rayBounces);\n internalTransmission = pow(max(internalTransmission, vec3(0.0)), vec3(max(gamma, 0.01)));\n internalTransmission *= rgbBoost * envIntensity;\n\n float bvhMaxC = max(max(color.r, color.g), color.b);\n float bvhMinC = min(min(color.r, color.g), color.b);\n float bvhChroma = bvhMaxC - bvhMinC;\n float bvhLum = dot(color, vec3(0.299, 0.587, 0.114));\n\n // External surface reflection:\n // For black/dark stones, provide full adamantine luster & ambient reflection so 3D faceting is never lost\n // For colored stones, tint specular highlight with gem color to prevent washed out white blowout\n vec3 bvhReflTint = (bvhChroma >= 0.05 && bvhLum >= 0.15 && bvhMaxC > 0.001)\n ? mix(vec3(1.0), color / bvhMaxC, 0.70)\n : vec3(1.0);\n float reflScale = (bvhLum < 0.2) ? 1.3 : 0.45;\n vec3 surfaceReflection = externalReflection * (fresnel * reflectivity * envIntensity * reflScale) * bvhReflTint;\n if (bvhLum < 0.2) {\n surfaceReflection += externalReflection * r0 * 0.45;\n }\n\n // Subtle inner facet-edge accents at grazing angles\n float innerGlintAngle = 1.0 - cosTheta;\n float innerGlint = pow(clamp(innerGlintAngle * 1.4, 0.0, 1.0), 6.0) * 0.35;\n vec3 innerGlintColor = externalReflection * bvhReflTint * innerGlint * envIntensity * reflectivity;\n\n vec3 hdrColor = internalTransmission * (1.0 - fresnel * reflectivity * 0.25)\n + surfaceReflection\n + innerGlintColor;\n\n if (transmission > 0.001) {\n vec3 directTransmission = refract(incident, worldNormal, 1.0 / ior);\n if (length(directTransmission) < 0.001) directTransmission = reflect(incident, worldNormal);\n vec3 tColor = clamp(color, vec3(0.005), vec3(1.0));\n vec3 sigma2 = -log(tColor) * max(absorption, 0.5);\n vec3 directTransBeer = exp(-sigma2 * 0.5);\n hdrColor = mix(hdrColor, sampleEnv(directTransmission) * envIntensity * directTransBeer, transmission);\n }\n\n pc_fragColor = vec4(aces(hdrColor), 1.0);\n}\n`;class Ty{constructor(){xn(this,\"cache\",new Map)}get cacheSize(){return this.cache.size}getEntry(e){return this.cache.get(e)}acquire(e,t,n){const i=cx(e);if(!i.isBakeable)return null;const s=(n==null?void 0:n.resolution)??256,a=`${ux(e,i)}_${s}`,o=this.cache.get(a);return o?(o.disposalTimer!==null&&(clearTimeout(o.disposalTimer),o.disposalTimer=null),o.refCount++,o.handle):this.bake(e,i,a,t,s)}bake(e,t,n,i,s){var a;const o=!((a=i.capabilities)!=null&&a.isWebGL2),c=new Br(s,{type:o?In:cn,format:kt,depthBuffer:!0,generateMipmaps:!1,minFilter:yt,magFilter:yt});this.renderToTarget(e,t,i,c,o);const l={key:n,texture:c.texture,centroid:t.centroid.clone(),radius:t.radius,encoding:o?\"unorm\":\"signed\"};return this.cache.set(n,{handle:l,renderTarget:c,refCount:1,disposalTimer:null,geometryRef:new WeakRef(e),resolution:s,analysis:t}),l}renderToTarget(e,t,n,i,s){var a;const o=e.getIndex()?e.toNonIndexed():e.clone(),c=lx(o,t);o.setAttribute(\"aFacet\",new vt(c,4));const l=new qn({vertexShader:yy,fragmentShader:My,side:wt,blending:ii,transparent:!1,depthTest:!0,depthWrite:!0,toneMapped:!1,defines:s?{GEM_NORMALS_UNORM:1}:{},uniforms:{uCentroid:{value:t.centroid},uRadius:{value:t.radius}}});try{const u=new ir,d=new We(o,l);u.add(d);const h=Math.max(.001,t.radius*.001),f=Math.max(2.5,t.radius*3),g=new rc(h,f,i);g.position.copy(t.centroid);const v=((a=n.getRenderTarget)==null?void 0:a.call(n))??null,m=n.autoClear,p=n.toneMapping,_=new Be;n.getClearColor&&n.getClearColor(_);const b=n.getClearAlpha?n.getClearAlpha():1;n.toneMapping=ri,n.autoClear=!0,n.setClearColor&&n.setClearColor(0,0);try{g.update(n,u)}finally{n.setRenderTarget&&n.setRenderTarget(v),n.autoClear=m,n.toneMapping=p,n.setClearColor&&n.setClearColor(_,b)}}finally{o.dispose(),l.dispose()}}release(e){const t=this.cache.get(e.key);t&&(t.refCount--,t.refCount<=0&&(t.refCount=0,t.disposalTimer!==null&&clearTimeout(t.disposalTimer),t.disposalTimer=setTimeout(()=>{t.renderTarget.dispose(),this.cache.delete(e.key)},1e3)))}clearCache(){for(const e of this.cache.values())e.disposalTimer!==null&&(clearTimeout(e.disposalTimer),e.disposalTimer=null),e.renderTarget.dispose();this.cache.clear()}onContextRestored(e){var t;for(const[n,i]of this.cache.entries()){const s=i.geometryRef.deref();if(!s){i.disposalTimer!==null&&(clearTimeout(i.disposalTimer),i.disposalTimer=null),i.renderTarget.dispose(),this.cache.delete(n);continue}const a=!((t=e.capabilities)!=null&&t.isWebGL2);i.renderTarget.dispose();const o=new Br(i.resolution,{type:a?In:cn,format:kt,depthBuffer:!0,generateMipmaps:!1,minFilter:yt,magFilter:yt});i.renderTarget=o,i.handle.texture=o.texture,i.handle.encoding=a?\"unorm\":\"signed\",this.renderToTarget(s,i.analysis,e,o,a)}}}const lr=new Ty,sf=new qe;class os extends qn{constructor(e,t,n,i={}){const s=e.bvh??new rf;super({vertexShader:Sy,fragmentShader:Ey,glslVersion:ta,defines:{USE_CUBE_ENV:1,MAX_BOUNCES:5,...e.encoding===\"unorm\"?{GEM_NORMALS_UNORM:1}:{},...i.useCorrectFresnel?{USE_CORRECT_FRESNEL:1}:{},...i.correctDispersionSign?{CORRECT_DISPERSION_SIGN:1}:{},...i.accumulateTIR?{ACCUMULATE_TIR:1}:{}},uniforms:{bvh:{value:s},envMap:{value:t},envRotationMatrix:{value:new ct},cameraPos:{value:new O},ior:{value:n.ior??2.417},dispersion:{value:n.dispersion??.012},absorption:{value:1+(n.absorptionFactor??0)*2},envIntensity:{value:n.envMapIntensity??2.2},gamma:{value:1},color:{value:new Be(n.hex)},rgbBoost:{value:new O(...n.boostFactors??[1.3,1.3,1.3])},transmission:{value:0},reflectivity:{value:.46},facetSharpness:{value:1},rayBounces:{value:8},tCubeMapNormals:{value:e.texture},uEnvFlip:{value:t!=null&&t.isRenderTargetTexture?1:-1},uCentroid:{value:e.centroid?e.centroid.clone():new O},uRadius:{value:e.radius??1},uCamLocal:{value:new O},refractiveIndex:{value:n.ior??2.417},rIndexDelta:{value:n.dispersion??.012},absorptionFactor:{value:n.absorptionFactor??0},gemColor:{value:new Be(n.hex)},uExhaustionResidual:{value:.5},bounces:{value:5},uSplitBounces:{value:2},uDebugMode:{value:0}},side:Mn,transparent:!1,depthTest:!0,depthWrite:!0,toneMapped:!0,extensions:{derivatives:!0}}),xn(this,\"bakeHandle\"),xn(this,\"onBeforeRender\"),this.bakeHandle=e,this.onBeforeRender=(a,o,c,l,u)=>{this.uniforms.cameraPos.value.copy(c.position),sf.copy(u.matrixWorld).invert(),this.uniforms.uCamLocal.value.copy(c.position).applyMatrix4(sf)}}updatePreset(e){if(this.uniforms.color&&this.uniforms.color.value.set(e.hex),this.uniforms.gemColor&&this.uniforms.gemColor.value.set(e.hex),this.uniforms.ior&&(this.uniforms.ior.value=e.ior??2.417),this.uniforms.refractiveIndex&&(this.uniforms.refractiveIndex.value=e.ior??2.417),this.uniforms.dispersion&&(this.uniforms.dispersion.value=e.dispersion??.012),this.uniforms.rIndexDelta&&(this.uniforms.rIndexDelta.value=e.dispersion??.012),this.uniforms.absorption&&(this.uniforms.absorption.value=1+(e.absorptionFactor??0)*2),this.uniforms.absorptionFactor&&(this.uniforms.absorptionFactor.value=e.absorptionFactor??0),this.uniforms.rgbBoost){const[t,n,i]=e.boostFactors??[2,2,2];this.uniforms.rgbBoost.value.set(t,n,i)}this.uniformsNeedUpdate=!0}}const fo=new Map;function af(r,e,t,n={}){var i;const s=`${n.useCorrectFresnel?\"_cf\":\"\"}${n.correctDispersionSign?\"_cd\":\"\"}${n.accumulateTIR?\"_at\":\"\"}`,a=`${r.key}_${t.id}_${t.hex}${s}`,o=fo.get(a);if(o)return o.refCount++,e&&((i=o.material.uniforms.envMap)==null?void 0:i.value)!==e&&(o.material.uniforms.envMap.value=e,o.material.uniformsNeedUpdate=!0),o.material;const c=new os(r,e,t,n);return fo.set(a,{material:c,refCount:1}),c}function El(r){for(const[e,t]of fo.entries())if(t.material===r){t.refCount--,t.refCount<=0&&(r.dispose(),fo.delete(e));return}}class wy extends ir{constructor(){super();const e=new Ua(30,32,16),t=new Gt({color:9476262,side:on}),n=new We(e,t);this.add(n);const i=new dn(16,16),s=new Gt({color:16777215,side:wt});s.color.setScalar(4);const a=new We(i,s);a.position.set(0,14,0),a.rotation.x=Math.PI/2,this.add(a);const o=new dn(12,16),c=new Gt({color:16777215,side:wt});c.color.setScalar(3);const l=new We(o,c);l.position.set(-10,8,10),l.lookAt(0,0,0),this.add(l);const u=new dn(12,16),d=new Gt({color:16777215,side:wt});d.color.setScalar(2.8);const h=new We(u,d);h.position.set(10,8,10),h.lookAt(0,0,0),this.add(h);const f=new dn(2,22),g=new Gt({color:16777215,side:wt});g.color.setScalar(4.5);const v=new We(f,g);v.position.set(-14,2,-2),v.lookAt(0,0,0),this.add(v);const m=new We(f,g);m.position.set(14,2,-2),m.lookAt(0,0,0),this.add(m);const p=new dn(24,24),_=new Gt({color:16119802,side:wt});_.color.setScalar(1.2);const b=new We(p,_);b.position.set(0,-12,0),b.rotation.x=-Math.PI/2,this.add(b);const x=new dn(1.2,16),E=new Gt({color:1184278,side:wt}),T=new We(x,E);T.position.set(-5,4,-9),T.lookAt(0,0,0),this.add(T);const A=new We(x,E);A.position.set(5,4,-9),A.lookAt(0,0,0),this.add(A)}dispose(){const e=new Set;this.traverse(t=>{t instanceof We&&(t.geometry&&e.add(t.geometry),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>e.add(n)):e.add(t.material)))});for(const t of e)t.dispose();this.clear()}}function Ay(r,e){const t=new Ta(e);t.compileEquirectangularShader();const n=new wy,i=t.fromScene(n).texture;return r.environment=i,n.dispose(),t.dispose(),i}class of extends ir{constructor(){super();const e=new Ua(30,32,16),t=new Gt({color:10528949,side:on}),n=new We(e,t);this.add(n);const i=[{pos:[0,15,8],size:[10,8],intensity:4.5},{pos:[0,15,-8],size:[10,8],intensity:4},{pos:[-9,14,0],size:[8,10],intensity:4},{pos:[9,14,0],size:[8,10],intensity:4}];for(const m of i){const p=new dn(m.size[0],m.size[1]),_=new Gt({color:16777215,side:wt});_.color.setScalar(m.intensity);const b=new We(p,_);b.position.set(m.pos[0],m.pos[1],m.pos[2]),b.lookAt(0,0,0),this.add(b)}const s=[{pos:[-13,8,6],size:[8,9],intensity:3.5},{pos:[13,8,6],size:[8,9],intensity:3.5},{pos:[0,8,14],size:[10,7],intensity:3.8},{pos:[0,8,-14],size:[10,7],intensity:3.2}];for(const m of s){const p=new dn(m.size[0],m.size[1]),_=new Gt({color:16777215,side:wt});_.color.setScalar(m.intensity);const b=new We(p,_);b.position.set(m.pos[0],m.pos[1],m.pos[2]),b.lookAt(0,0,0),this.add(b)}const a=new dn(5,5),o=new Gt({color:4212048,side:wt}),c=new We(a,o);c.position.set(0,18,0),c.rotation.x=Math.PI/2,this.add(c);const l=new dn(24,24),u=new Gt({color:5264994,side:wt}),d=new We(l,u);d.position.set(0,-12,0),d.rotation.x=-Math.PI/2,this.add(d);const h=new dn(1.4,15),f=new Gt({color:3685962,side:wt}),g=[[7,11,7],[-7,11,7],[7,11,-7],[-7,11,-7]];for(const[m,p,_]of g){const b=new We(h,f);b.position.set(m,p,_),b.lookAt(0,0,0),this.add(b)}const v=[[10,13,7],[-10,13,7],[10,13,-7],[-10,13,-7],[14,6,9],[-14,6,9],[14,6,-9],[-14,6,-9],[0,6,17],[7,-6,8]];for(const[m,p,_]of v){const b=new dn(2.6,2.6),x=new Gt({color:16777215,side:wt});x.color.setScalar(45);const E=new We(b,x);E.position.set(m,p,_),E.lookAt(0,0,0),this.add(E)}}dispose(){const e=new Set;this.traverse(t=>{t instanceof We&&(t.geometry&&e.add(t.geometry),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>e.add(n)):e.add(t.material)))});for(const t of e)t.dispose();this.clear()}}function Tl(r,e,t=512){const n=new Br(t,{format:kt,type:cn,generateMipmaps:!1,minFilter:At,magFilter:At}),i=new rc(.1,100,n),s=new of,a=r!=null&&r.getRenderTarget?r.getRenderTarget():null;return i.update(r,s),r!=null&&r.setRenderTarget&&r.setRenderTarget(a),s instanceof of&&s.dispose(),n.texture}async function cf(r,e){const t=new Ta(e);t.compileEquirectangularShader();function n(s){const a=t.fromEquirectangular(s);let o,c=s;try{o=new Br(512,{format:kt,type:cn,generateMipmaps:!1,minFilter:At,magFilter:At}),o.fromEquirectangularTexture(e,s),c=o.texture}catch{o==null||o.dispose(),o=void 0,c=s}return t.dispose(),{renderTarget:a,texture:a.texture,gemRenderTarget:o,gemTexture:c,dispose:()=>{a.dispose(),o==null||o.dispose(),s.dispose()}}}const i=typeof r==\"string\"?r.toLowerCase().includes(\".exr\"):r instanceof ArrayBuffer&&r.byteLength>=4&&new Uint8Array(r,0,4)[0]===118&&new Uint8Array(r,0,4)[1]===47;if(r instanceof ArrayBuffer)try{if(i){const s=new xh().parse(r),a=new Vr(s.data,s.width,s.height,s.format,s.type);return a.needsUpdate=!0,n(a)}else{const s=new hh().parse(r);return n(s)}}catch(s){throw t.dispose(),s}return new Promise((s,a)=>{i?new xh().load(r,o=>{try{s(n(o))}catch(c){o.dispose(),t.dispose(),a(c)}},void 0,o=>{t.dispose(),a(o)}):new hh().load(r,o=>{try{s(n(o))}catch(c){o.dispose(),t.dispose(),a(c)}},void 0,o=>{t.dispose(),a(o)})})}const lf=new WeakMap;function Ry(r){const e=lf.get(r);if(e)return e;let t=r;r.groups&&r.groups.length>1&&(t=r.clone(),t.clearGroups());const n=t.boundsTree??new ho(t,{strategy:Ih,setBoundingBox:!1});t.boundsTree=n;const i=new rf;return i.updateFrom(n),lf.set(r,i),i}const Cy=`\nprecision highp float;\n\nout vec3 vWorldNormal;\nout vec3 vWorldPosition;\n\nvoid main() {\n vec4 worldPos = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPos.xyz;\n vWorldNormal = normalize(mat3(modelMatrix) * normal);\n gl_Position = projectionMatrix * viewMatrix * worldPos;\n}\n`,Py=`\nprecision highp float;\nprecision highp sampler2D;\nprecision highp samplerCube;\n\nuniform mat4 modelOffsetMatrix;\nuniform mat4 modelOffsetMatrixInv;\nuniform mat4 viewMatrixUniform;\n\nuniform samplerCube tCubeMapNormals;\nuniform float radius;\nuniform vec3 centerOffset;\n\n#if ENV_MAP_TYPE == 0\n uniform samplerCube envMap;\n#else\n uniform sampler2D envMap;\n#endif\nuniform float envMapRotation;\nuniform float envMapIntensity;\n\nuniform float refractiveIndex;\nuniform float rIndexDelta;\nuniform float absorptionFactor;\nuniform float squashFactor;\nuniform float geometryFactor;\nuniform float gammaFactor;\nuniform float ambientFloor;\nuniform float reflectivity;\nuniform vec3 boostFactors;\nuniform vec3 color;\nuniform vec3 colorCorrection;\nuniform float transmission;\nuniform bool clampHDR;\nuniform bool useInclusion;\n\nin vec3 vWorldNormal;\nin vec3 vWorldPosition;\nout vec4 fragColor;\n\n// Lazarov/Karis 2014 BRDF (Siggraph, published constants — safe to reproduce)\nvec3 brdfGGXEnv(vec3 viewDir, vec3 normal, vec3 f0, float roughness) {\n float dotNV = abs(dot(normal, viewDir));\n vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;\n vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\n return f0 * AB.x + AB.y;\n}\n\nvec3 rotateY(vec3 d, float a) {\n float c = cos(a), s = sin(a);\n return vec3(c*d.x + s*d.z, d.y, -s*d.x + c*d.z);\n}\n\nvec4 sampleEnvMap(vec3 dir, float roughness) {\n dir = rotateY(dir, envMapRotation);\n dir = -dir; // full negate per reference algorithm (DIAMOND_PLAN §3.4 step 6)\n#if ENV_MAP_TYPE == 0\n return envMapIntensity * textureLod(envMap, dir, roughness * 8.0);\n#else\n vec2 uv;\n uv.x = atan(dir.z, dir.x) / (2.0 * 3.14159265359) + 0.5;\n uv.y = asin(clamp(dir.y, -1.0, 1.0)) / 3.14159265359 + 0.5;\n return envMapIntensity * textureLod(envMap, uv, roughness * 8.0);\n#endif\n}\n\n// Internal bounce: apply modelOffset + view-space + xz-flip (DIAMOND_PLAN §3.4)\nvec4 sampleInternalEnv(vec3 dir, float roughness) {\n#if DIA_ORIENT_ENVMAP < 1\n dir = mat3(modelOffsetMatrix) * dir;\n#endif\n dir = (viewMatrixUniform * vec4(dir, 0.0)).xyz;\n dir = normalize(dir);\n dir.x *= -1.0;\n dir.z *= -1.0;\n vec4 sharpLight = sampleEnvMap(dir, roughness);\n vec4 envColor = sharpLight;\n if (ambientFloor > 0.0) {\n vec4 diffuseLight = sampleEnvMap(dir, 0.85);\n envColor = max(sharpLight, diffuseLight * ambientFloor);\n }\n return envColor;\n}\n\n// Front surface: only viewMatrix (DIAMOND_PLAN §10.6)\nvec4 sampleFrontEnv(vec3 dir, float roughness) {\n dir = (viewMatrixUniform * vec4(dir, 0.0)).xyz;\n return sampleEnvMap(dir, roughness);\n}\n\n// Line-plane intersection with divide-by-zero guard (DIAMOND_PLAN §10.1)\nvec3 linePlaneIntersect(vec3 p, vec3 d, vec3 pp, vec3 pn) {\n float denom = dot(pn, d);\n if (abs(denom) < 1e-6) return p; // ray parallel to plane\n return p + d * (dot(pn, pp - p) / denom);\n}\n\n// Sphere intersect with squash and sphere-miss guard (DIAMOND_PLAN §2.2, §6)\n// Returns vec3(0) on miss — caller checks length < 1e-6\nvec3 intersectSphere(vec3 origin, vec3 dir) {\n vec3 o = origin - centerOffset;\n // Determine which local axis corresponds to the world +Y (setting) axis\n vec3 localUpAxis = normalize(mat3(modelOffsetMatrixInv) * vec3(0.0, 1.0, 0.0));\n float upProj = dot(dir, localUpAxis);\n vec3 squashedDir = dir + localUpAxis * (upProj / squashFactor - upProj);\n\n float A = dot(squashedDir, squashedDir);\n float B = 2.0 * dot(o, squashedDir);\n float C = dot(o, o) - radius * radius;\n float disc = B * B - 4.0 * A * C;\n if (disc <= 0.0) return vec3(0.0); // miss\n float sqrtDisc = sqrt(disc);\n float t = max((-B + sqrtDisc) * geometryFactor / A,\n (-B - sqrtDisc) * geometryFactor / A);\n return origin + dir * t; // origin + dir * t (rayOrigin preserved)\n}\n\nstruct HitResult { vec3 point; vec3 normal; };\n\n// Facet normal decoding respecting GEM_NORMALS_UNORM define\nvec3 decodeFacetNormal(vec3 raw) {\n#if GEM_NORMALS_UNORM == 1\n return -normalize(raw * 2.0 - 1.0);\n#else\n return -normalize(raw);\n#endif\n}\n\nHitResult doIntersect(vec3 origin, vec3 dir) {\n vec3 sphereHit = intersectSphere(origin, dir);\n if (length(sphereHit) < 1e-6) {\n return HitResult(origin, vec3(0.0, 1.0, 0.0)); // miss sentinel\n }\n // Stage 2: first facet (nd.a is perpendicular plane distance D in radius units; pn is -normal)\n vec3 d1 = normalize(sphereHit - centerOffset);\n vec4 nd1 = texture(tCubeMapNormals, d1);\n vec3 pn1 = decodeFacetNormal(nd1.rgb);\n vec3 hp1 = linePlaneIntersect(origin, dir, centerOffset - pn1 * (nd1.a * radius), pn1);\n // Stage 3: second facet\n vec3 d2 = normalize(hp1 - centerOffset);\n vec4 nd2 = texture(tCubeMapNormals, d2);\n vec3 pn2 = decodeFacetNormal(nd2.rgb);\n vec3 hp2 = linePlaneIntersect(origin, dir, centerOffset - pn2 * (nd2.a * radius), pn2);\n return HitResult(hp2, pn2);\n}\n\nvec3 getRefractionColor(vec3 worldOrigin, vec3 viewDir, vec3 surfaceNormal, vec3 f0) {\n float ior = refractiveIndex;\n vec3 entryRefracted = refract(viewDir, surfaceNormal, 1.0 / ior);\n if (dot(entryRefracted, entryRefracted) < 1e-4) return vec3(0.0);\n\n vec3 brdfEntry = brdfGGXEnv(entryRefracted, -surfaceNormal, f0, 0.0);\n vec3 attenuation = vec3(1.0) - brdfEntry;\n\n vec3 origin = (modelOffsetMatrixInv * vec4(worldOrigin, 1.0)).xyz;\n vec3 dir = normalize((modelOffsetMatrixInv * vec4(entryRefracted, 0.0)).xyz);\n\n vec3 outColor = vec3(0.0);\n\n for (int i = 0; i < RAY_BOUNCES; i++) {\n HitResult hit = doIntersect(origin, dir);\n // Sphere-miss: hit.point == origin (sentinel) — break after first iteration\n if (i > 0 && length(hit.point - origin) < 1e-6) break;\n\n // Third cube lookup for mapped normal (DIAMOND_PLAN §2.3)\n vec3 d3 = normalize(hit.point - centerOffset);\n vec4 nd3 = texture(tCubeMapNormals, d3);\n vec3 mappedNormal = decodeFacetNormal(nd3.rgb);\n\n // Beer-Lambert (DIAMOND_PLAN §2.4)\n float r = length(hit.point - origin) / radius * absorptionFactor;\n attenuation *= exp(-r * (vec3(1.0) - color));\n\n origin = hit.point;\n vec3 oldDir = dir;\n dir = refract(oldDir, mappedNormal, ior / 1.0);\n\n if (dot(dir, dir) < 1e-4) {\n // TIR — DIAMOND_PLAN §2.7 + §10.5 correction: use -oldDir for BRDF\n dir = reflect(oldDir, mappedNormal);\n if (i == RAY_BOUNCES - 1) {\n vec3 brdfTIR = brdfGGXEnv(-oldDir, mappedNormal, f0, 0.0);\n vec4 envS = sampleInternalEnv(oldDir, 0.0);\n outColor += envS.rgb * (vec3(1.0) - brdfTIR) * attenuation * colorCorrection * boostFactors;\n }\n } else {\n // Exit — dispersed RGB (wavelength-dependent refraction)\n vec3 dir0 = dir;\n vec3 dir1 = refract(oldDir, mappedNormal, (ior + rIndexDelta) / 1.0);\n vec3 dir2 = refract(oldDir, mappedNormal, (ior - rIndexDelta) / 1.0);\n\n vec3 brdfExit = vec3(1.0) - min(vec3(1.0), brdfGGXEnv(dir0, -mappedNormal, f0, 0.0));\n vec3 envRGB = vec3(\n dot(dir1, dir1) > 1e-4 ? sampleInternalEnv(dir1, 0.0).r : 0.0,\n dot(dir0, dir0) > 1e-4 ? sampleInternalEnv(dir0, 0.0).g : 0.0,\n dot(dir2, dir2) > 1e-4 ? sampleInternalEnv(dir2, 0.0).b : 0.0\n );\n outColor += envRGB * brdfExit * attenuation * colorCorrection * boostFactors;\n\n dir = reflect(oldDir, mappedNormal);\n attenuation *= brdfGGXEnv(dir, mappedNormal, f0, 0.0) * boostFactors; // §2.8 compounding\n }\n }\n return outColor;\n}\n\nvoid main() {\n vec3 N = normalize(vWorldNormal);\n vec3 V = normalize(vWorldPosition - cameraPosition);\n float ior = refractiveIndex;\n float f0s = pow((ior - 1.0) / (ior + 1.0), 2.0);\n vec3 f0 = vec3(f0s);\n\n vec3 reflDir = reflect(V, N);\n vec3 brdfFront = brdfGGXEnv(reflDir, N, f0, 0.0);\n\n // Tint specular shine for colored gems, keep pure white for black & colorless stones\n float maxC = max(max(color.r, color.g), color.b);\n float minC = min(min(color.r, color.g), color.b);\n float chroma = maxC - minC;\n float lum = dot(color, vec3(0.299, 0.587, 0.114));\n\n vec3 reflTint = vec3(1.0);\n if (chroma >= 0.05 && lum >= 0.15 && maxC > 0.001) {\n vec3 gemHue = color / maxC;\n reflTint = mix(vec3(1.0), gemHue, 0.70);\n }\n\n vec3 rawEnv = sampleFrontEnv(reflDir, 0.0).rgb;\n vec3 reflectionColor = rawEnv * brdfFront * reflectivity * 2.0 * reflTint;\n\n // Subtle ambient surface luster so facets never drop to harsh pitch black\n if (ambientFloor > 0.0 || lum < 0.2) {\n vec3 ambientEnv = sampleFrontEnv(reflDir, 0.7).rgb;\n float luster = (lum < 0.2) ? 0.6 : (ambientFloor * 2.0);\n reflectionColor += ambientEnv * f0 * luster;\n }\n\n vec3 refractionColor = getRefractionColor(vWorldPosition, V, N, f0);\n vec3 outColor = reflectionColor + refractionColor;\n\n if (gammaFactor != 1.0) {\n outColor = pow(max(outColor, vec3(0.0)), vec3(gammaFactor));\n }\n if (clampHDR) outColor = min(outColor, vec3(1.0));\n\n fragColor = vec4(outColor, 1.0);\n#define gl_FragColor fragColor\n #include <colorspace_fragment>\n}\n`;function uf(r){switch(r){case\"low\":return{rayBounces:3,cubeResolution:128};case\"medium\":return{rayBounces:5,cubeResolution:256};case\"high\":return{rayBounces:6,cubeResolution:256};case\"ultra\":return{rayBounces:8,cubeResolution:512}}}const df=new qe;class _i extends qn{constructor(e,t,n,i={}){const s=i.quality?uf(i.quality).rayBounces:i.rayBounces??5,a=t.isCubeTexture===!0,o=n.boostFactors??[1,1,1],[c,l,u]=o;super({vertexShader:Cy,fragmentShader:Py,glslVersion:ta,defines:{RAY_BOUNCES:s,ENV_MAP_TYPE:a?0:1,DIA_ORIENT_ENVMAP:i.orientEnvMap?1:0,HAS_GEM_INCLUSIONS:0,GEM_NORMALS_UNORM:e.encoding===\"unorm\"?1:0},uniforms:{modelOffsetMatrix:{value:new qe},modelOffsetMatrixInv:{value:new qe},viewMatrixUniform:{value:new qe},cameraPosition:{value:new O},tCubeMapNormals:{value:e.texture},radius:{value:e.radius??1},centerOffset:{value:e.centroid?e.centroid.clone():new O},envMap:{value:t},envMapRotation:{value:0},envMapIntensity:{value:n.envMapIntensity??1},refractiveIndex:{value:n.ior??2.6},rIndexDelta:{value:n.dispersion??.012},absorptionFactor:{value:n.absorptionFactor??1},squashFactor:{value:n.squashFactor??.98},geometryFactor:{value:n.geometryFactor??.5},gammaFactor:{value:n.gammaFactor??1},ambientFloor:{value:n.ambientFloor??.05},reflectivity:{value:.5},boostFactors:{value:new O(c,l,u)},color:{value:new Be(n.hex)},colorCorrection:{value:new O(1,1,1)},transmission:{value:0},clampHDR:{value:!1},useInclusion:{value:!1}},side:Mn,transparent:!1,depthTest:!0,depthWrite:!0,toneMapped:!0}),xn(this,\"bakeHandle\"),xn(this,\"preset\"),xn(this,\"onBeforeRender\"),this.bakeHandle=e,this.preset={...n},this.onBeforeRender=(d,h,f,g,v)=>{f.getWorldPosition(this.uniforms.cameraPosition.value),this.uniforms.modelOffsetMatrix.value.copy(v.matrixWorld),df.copy(v.matrixWorld).invert(),this.uniforms.modelOffsetMatrixInv.value.copy(df),this.uniforms.viewMatrixUniform.value.copy(f.matrixWorldInverse)}}updatePreset(e){if(this.preset={...this.preset,...e},this.uniforms.refractiveIndex.value=e.ior??2.6,this.uniforms.rIndexDelta.value=e.dispersion??.012,this.uniforms.absorptionFactor.value=e.absorptionFactor??1,this.uniforms.color.value.set(e.hex),e.squashFactor!==void 0&&(this.uniforms.squashFactor.value=e.squashFactor),e.geometryFactor!==void 0&&(this.uniforms.geometryFactor.value=e.geometryFactor),e.gammaFactor!==void 0&&(this.uniforms.gammaFactor.value=e.gammaFactor),e.envMapIntensity!==void 0&&(this.uniforms.envMapIntensity.value=e.envMapIntensity),e.ambientFloor!==void 0&&(this.uniforms.ambientFloor.value=e.ambientFloor),e.boostFactors){const[t,n,i]=e.boostFactors;this.uniforms.boostFactors.value.set(t,n,i)}this.uniformsNeedUpdate=!0}setEnvMap(e){this.uniforms.envMap.value=e;const t=e.isCubeTexture===!0?0:1;this.defines.ENV_MAP_TYPE!==t&&(this.defines.ENV_MAP_TYPE=t,this.needsUpdate=!0)}clone(){var e;const t=new _i(this.bakeHandle,this.uniforms.envMap.value,this.preset,{orientEnvMap:this.defines.DIA_ORIENT_ENVMAP===1,rayBounces:this.defines.RAY_BOUNCES});return t.name=this.name,(e=this.uniforms.color)!=null&&e.value&&t.uniforms.color.value.copy(this.uniforms.color.value),t}}const po=new Map;function hf(r,e,t,n={}){const i=n.quality??`b${n.rayBounces??5}`,s=n.orientEnvMap?\"_o1\":\"_o0\",a=`ref_${r.key}_${t.id}_${t.hex}_${i}${s}`,o=po.get(a);if(o)return o.refCount++,e&&o.material.uniforms.envMap.value!==e&&o.material.setEnvMap(e),o.material;const c=new _i(r,e,t,n);return po.set(a,{material:c,refCount:1}),c}function wl(r){for(const[e,t]of po.entries())if(t.material===r){t.refCount--,t.refCount<=0&&(r.dispose(),po.delete(e));return}}function cs(r,e,t){const n=Ns.find(s=>s.id===e),i=Array.isArray(r.material)?t!==void 0?r.material[t]?[r.material[t]]:[]:r.material:t===void 0||t===0?r.material?[r.material]:[]:[];for(const s of i)s&&s instanceof Ci&&(s.color.set(n?n.hex:e),s.metalness=(n==null?void 0:n.metalness)??s.metalness??1,s.roughness=(n==null?void 0:n.roughness)??s.roughness,s.envMapIntensity=1.2,s instanceof vn&&(s.clearcoat>0&&(s.clearcoat=0,s.needsUpdate=!0),n!=null&&n.specularColor&&(s.specularColor?s.specularColor.set(n.specularColor):s.specularColor=new Be(n.specularColor)),(n==null?void 0:n.ior)!==void 0&&(s.ior=n.ior)))}function ls(r,e,t){const n=Oi.find(s=>s.id===e),i=Array.isArray(r.material)?t!==void 0?r.material[t]?[r.material[t]]:[]:r.material:t===void 0||t===0?r.material?[r.material]:[]:[];for(const s of i)if(s){if(s instanceof _i)n?s.updatePreset(n):(s.uniforms.color.value.set(e),s.uniformsNeedUpdate=!0);else if(s instanceof os)if(n){const a=s.bakeHandle,o=af(a,s.uniforms.envMap.value,n);if(o!==s)if(El(s),Array.isArray(r.material)){const c=r.material.indexOf(s);c!==-1&&(r.material[c]=o)}else r.material=o;else s.updatePreset(n)}else s.uniforms.color.value.set(e),s.uniformsNeedUpdate=!0;else if(s instanceof vn){s.color.set(n?n.hex:e),n&&(s.ior=n.ior,s.roughness=n.roughness,n.specularColor&&(s.specularColor?s.specularColor.set(n.specularColor):s.specularColor=new Be(n.specularColor)),n.attenuationColor&&(s.attenuationColor?s.attenuationColor.set(n.attenuationColor):s.attenuationColor=new Be(n.attenuationColor),s.attenuationDistance=n.attenuationDistance??.5));const a=s.transmission>0,o=s.transparent!==!1;s.transmission=0,s.transparent=!1,s.envMapIntensity=3,(a||o)&&(s.needsUpdate=!0)}}}function ff(r,e,t,n,i=\"reference\"){var s,a,o;const c=Array.isArray(r.material)?r.material[0]:r.material,l=c instanceof vn,u=c instanceof os,d=l&&c.metalness>.5;if(e===\"metal\"){if(!l||!d){const f=c,g=new vn({color:f instanceof Ci?f.color.clone():new Be(\"#C0C0C0\"),metalness:1,roughness:0,clearcoat:0,envMapIntensity:1,side:wt});c instanceof os?El(c):c instanceof _i?wl(c):f==null||f.dispose(),f!=null&&f.name&&(g.name=f.name),f!=null&&f.userData&&(g.userData={...f.userData,...g.userData}),r.material=g}return}const h=c instanceof _i;if(u||h){n&&(h?c.setEnvMap(n):c.uniforms.envMap.value=n);return}if(t){let f=lr.acquire(r.geometry,t);if(!f&&(r.geometry.index?r.geometry.index.count:((s=r.geometry.attributes.position)==null?void 0:s.count)??0)/3<5e3){r.geometry.boundingSphere||r.geometry.computeBoundingSphere();const g=Ry(r.geometry),v=n??Tl(t);f={key:`bvh_${r.geometry.id}`,texture:v instanceof sc?v:new Br(1).texture,centroid:(a=r.geometry.boundingSphere)!=null&&a.center?r.geometry.boundingSphere.center.clone():new O,radius:((o=r.geometry.boundingSphere)==null?void 0:o.radius)??1,encoding:\"signed\",bvh:g}}if(f){const g=n??Tl(t);let v;i===\"reference\"&&!f.key.startsWith(\"bvh_\")?v=hf(f,g,Oi[0]):v=af(f,g,Oi[0]);const m=c;m==null||m.dispose(),m!=null&&m.name&&(v.name=m.name),m!=null&&m.userData&&(v.userData={...m.userData,...v.userData}),r.material=v;return}}if(!l||d){const f=c,g=new vn({color:f instanceof Ci?f.color.clone():new Be(\"#FFFFFF\"),metalness:0,transmission:0,ior:2.417,roughness:0,thickness:.5,envMapIntensity:3,transparent:!1});f==null||f.dispose(),f!=null&&f.name&&(g.name=f.name),f!=null&&f.userData&&(g.userData={...f.userData,...g.userData}),r.material=g}}function Ly(r,e,t=!0){let n,i=!0,s=!1,a=\"high\",o;e instanceof un?(n=e,typeof t==\"boolean\"?i=t:t&&typeof t==\"object\"&&(i=t.antialias??!0,s=t.alpha??t.background===\"transparent\",t.quality&&(a=t.quality),o=t.onResize)):typeof e==\"boolean\"?i=e:e&&typeof e==\"object\"&&(i=e.antialias??!0,s=e.alpha??e.background===\"transparent\",e.quality&&(a=e.quality),o=e.onResize);const c=new bc({antialias:i,alpha:s,powerPreference:\"high-performance\"});c.outputColorSpace=Mt,c.toneMapping=Wl,c.toneMappingExposure=1,c.setSize(r.clientWidth,r.clientHeight),c.shadowMap.enabled=!1,r.appendChild(c.domElement);let l=!1;function u(h){const f=typeof window<\"u\"?window.devicePixelRatio:1;let g=1;h===\"low\"?g=1:h===\"medium\"?g=Math.min(f,1.5):h===\"high\"&&(g=Math.min(f,2)),c.setPixelRatio(g),l&&(o==null||o())}u(a),l=!0;let d=null;return typeof ResizeObserver<\"u\"&&(d=new ResizeObserver(()=>{const h=r.clientWidth,f=r.clientHeight;c.setSize(h,f),n&&(n.aspect=f>0?h/f:1,n.updateProjectionMatrix()),o==null||o()}),d.observe(r)),{renderer:c,setQuality:u,dispose:()=>{d==null||d.disconnect(),c.dispose(),c.domElement.remove()}}}function Iy(r=1710618,e=25){const t=new ir;if(r===\"transparent\")t.background=null;else{const a=r===\"studio\"?1447448:r;t.background=new Be(a)}const n=new un(e,1,.01,1e3);n.position.set(0,0,3);const i=new Ic(\"#ffffff\",1);i.position.set(5,8,5),t.add(i);const s=new Ic(\"#e0e8ff\",.4);return s.position.set(-5,3,-5),t.add(s),{scene:t,camera:n,dispose:()=>{t.clear()}}}function Dy(r,e,t){r.aspect=t>0?e/t:1,r.updateProjectionMatrix()}function Ny(r,e,t={}){const n=new Gv(r,e);n.enableDamping=!0,n.dampingFactor=.05,n.screenSpacePanning=!1,n.autoRotate=t.autoRotate??!1,n.autoRotateSpeed=t.autoRotateSpeed??2;const i=r.position.clone(),s=n.target.clone();function a(){r.position.copy(i),n.target.copy(s),n.update()}return{controls:n,initialPosition:i,initialTarget:s,resetCamera:a,dispose:()=>{n.dispose()}}}function Al(r,e,t,n={},i=!1){const s=\"controls\"in t?t.controls:t,a=new bt().setFromObject(r).getBoundingSphere(new Nn),o=a.radius>0?a.radius:1,c=xr.degToRad(e.fov),l=o/Math.tan(c/2)*1.15,u=new O;i?(u.subVectors(e.position,s.target).normalize(),(u.lengthSq()<.001||!Number.isFinite(u.x))&&u.set(0,.45,1).normalize()):u.set(0,0,1),s.target.copy(a.center),e.position.copy(a.center).addScaledVector(u,l),e.near=o*.01,e.far=o*100,e.updateProjectionMatrix(),s.minDistance=n.minZoom??o*.3,s.maxDistance=n.maxZoom??o*8,s.update()}function Uy(r,e,t,n,i,s=()=>[],a){const o=new V_,c=new Ve;let l=null,u;const d=new Be;let h=0,f=!1,g={x:0,y:0},v=null,m=0;const p=(a==null?void 0:a.hoverHighlight)??!1;function _(){v=null}function b(){if(v!==null)return v;const P=[];return e.traverse(z=>{z.isMesh&&P.push(z)}),v=P,v}function x(P){const z=Array.isArray(P.material)?P.material[0]:P.material;return z instanceof Ci?z:null}function E(P,z){var X,re;if(!(P===l&&z===u)){if(l&&p){const J=x(l);J&&(J.emissive.copy(d),J.emissiveIntensity=h)}if(l=P,u=z,P){if(p){const te=x(P);te&&(d.copy(te.emissive),h=te.emissiveIntensity,te.emissive.set(16777215),te.emissiveIntensity=.3)}(X=r.domElement)!=null&&X.style&&(r.domElement.style.cursor=\"pointer\");const J=s().find(te=>te.meshId===P.uuid);if(J){const te=z!==void 0&&J.slots[z]!==void 0?z:0,Q=J.slots[te];i.emit(\"partHover\",{meshId:J.meshId,partId:J.partId,type:J.type,slotIndex:te,slotId:Q==null?void 0:Q.slotId,materialName:(Q==null?void 0:Q.materialName)??J.materialName})}else i.emit(\"partHover\",null)}else(re=r.domElement)!=null&&re.style&&(r.domElement.style.cursor=\"default\"),i.emit(\"partHover\",null)}}function T(){var P;if(m=0,f)return;o.setFromCamera(c,t);const z=o.intersectObjects(b(),!1)[0];E(z?z.object:null,(P=z==null?void 0:z.face)==null?void 0:P.materialIndex)}function A(P){if(f)return;const z=r.domElement.getBoundingClientRect();z.width===0||z.height===0||(c.x=(P.clientX-z.left)/z.width*2-1,c.y=-((P.clientY-z.top)/z.height)*2+1,typeof requestAnimationFrame<\"u\"?m===0&&(m=requestAnimationFrame(T)):T())}function I(){m!==0&&typeof cancelAnimationFrame<\"u\"&&(cancelAnimationFrame(m),m=0),E(null,void 0)}function S(P){g={x:P.clientX,y:P.clientY}}function R(P){var z;const X=P.clientX-g.x,re=P.clientY-g.y;if(Math.sqrt(X*X+re*re)<4){let J=l,te=u;if(!J){const Q=r.domElement.getBoundingClientRect();if(Q.width>0&&Q.height>0){c.x=(P.clientX-Q.left)/Q.width*2-1,c.y=-((P.clientY-Q.top)/Q.height)*2+1,o.setFromCamera(c,t);const ce=o.intersectObjects(b(),!1);ce.length>0&&(J=ce[0].object,te=(z=ce[0].face)==null?void 0:z.materialIndex)}}if(J){const Q=s().find(ce=>ce.meshId===J.uuid);if(Q){const ce=te!==void 0&&Q.slots[te]!==void 0?te:0,he=Q.slots[ce];i.emit(\"partSelected\",{meshId:Q.meshId,partId:Q.partId,type:Q.type,slotIndex:ce,slotId:he==null?void 0:he.slotId,materialName:(he==null?void 0:he.materialName)??Q.materialName})}}}}function F(){f=!0,m!==0&&typeof cancelAnimationFrame<\"u\"&&(cancelAnimationFrame(m),m=0)}function U(){f=!1}const V=r.domElement;return V.addEventListener(\"pointermove\",A),V.addEventListener(\"pointerdown\",S),V.addEventListener(\"pointerup\",R),V.addEventListener(\"pointerleave\",I),n.addEventListener(\"start\",F),n.addEventListener(\"end\",U),{dispose:()=>{m!==0&&typeof cancelAnimationFrame<\"u\"&&(cancelAnimationFrame(m),m=0),v=null,V.removeEventListener(\"pointermove\",A),V.removeEventListener(\"pointerdown\",S),V.removeEventListener(\"pointerup\",R),V.removeEventListener(\"pointerleave\",I),n.removeEventListener(\"start\",F),n.removeEventListener(\"end\",U),E(null),V!=null&&V.style&&(V.style.cursor=\"default\")},invalidateMeshes:_}}function Fy(r,e,t,n,i,s,a,o){const c={metalColor:r,stoneColor:e,parts:{...t},cameraState:{position:n.position.toArray(),target:i.target.toArray()}};return s&&Object.keys(s).length>0&&(c.materialColors={...s}),a&&Object.keys(a).length>0&&(c.partColors={...a}),c}function Oy(r,e,t,n,i,s,a){var o,c;const l=[],u=[],d=[];(!(a!=null&&a.currentColor)||a.currentColor.metalColor!==r.metalColor)&&e(r.metalColor),(!(a!=null&&a.currentColor)||a.currentColor.stoneColor!==r.stoneColor)&&t(r.stoneColor);for(const[h,f]of Object.entries(r.parts||{}))a!=null&&a.availablePartIds&&!a.availablePartIds.has(h)&&(l.push(h),d.push(`Part type override target '${h}' not found in model`),console.warn(`[3d-viewer] Part type override target '${h}' not found in loaded model`)),n(h,f);if(r.materialColors&&a!=null&&a.setMaterialColor)for(const[h,f]of Object.entries(r.materialColors))!a.availableSlotIds&&!a.availableMaterialNames||(o=a.availableSlotIds)!=null&&o.has(h)||(c=a.availableMaterialNames)!=null&&c.has(h)||(u.push(h),d.push(`Material slot '${h}' not found in model`),console.warn(`[3d-viewer] Material slot '${h}' not found in loaded model`)),a.setMaterialColor(h,f);if(r.partColors&&a!=null&&a.setPartColor)for(const[h,f]of Object.entries(r.partColors)){let g=h,v;const m=h.lastIndexOf(\":\");m>0&&!isNaN(Number(h.slice(m+1)))&&(g=h.slice(0,m),v=Number(h.slice(m+1))),a.availablePartIds&&!a.availablePartIds.has(g)&&(l.push(g),d.push(`Part '${g}' not found in model`),console.warn(`[3d-viewer] Part '${g}' not found in loaded model`)),a.setPartColor(g,f,v)}return r.cameraState&&(i.position.fromArray(r.cameraState.position),s.target.fromArray(r.cameraState.target),s.update()),{success:!0,unresolvedParts:l.length>0?l:void 0,unresolvedMaterials:u.length>0?u:void 0,warnings:d.length>0?d:void 0}}let vi=null,mo=0;function By(r,e=1.2){let t;const n=typeof document<\"u\"&&typeof document.createElement==\"function\";if(n){if(!vi){const c=document.createElement(\"canvas\");c.width=256,c.height=256;const l=c.getContext?c.getContext(\"2d\"):null;if(l){const u=l.createRadialGradient(128,128,0,128,128,128);u.addColorStop(0,\"rgba(0, 0, 0, 0.65)\"),u.addColorStop(.3,\"rgba(0, 0, 0, 0.4)\"),u.addColorStop(.7,\"rgba(0, 0, 0, 0.15)\"),u.addColorStop(1,\"rgba(0, 0, 0, 0)\"),l.fillStyle=u,l.fillRect(0,0,256,256)}vi=new jd(c),vi.colorSpace=Mt,vi.needsUpdate=!0}mo++,t=vi}else t=new Xt,t.needsUpdate=!0;const i=new dn(e*2,e*2);i.rotateX(-Math.PI/2);const s=new Gt({map:t,transparent:!0,opacity:.85,depthWrite:!1}),a=new We(i,s);a.position.y=-.5,a.renderOrder=-1,r.add(a);let o=!1;return{mesh:a,setVisible:c=>{a.visible=c},setScale:c=>{a.scale.setScalar(c)},dispose:()=>{o||(o=!0,r.remove(a),i.dispose(),s.dispose(),n&&t===vi?(mo--,mo<=0&&(vi==null||vi.dispose(),vi=null,mo=0)):t.dispose())}}}function ky(r){r.updateMatrixWorld(!0);let e=[];try{e=Ha(r,{})}catch{e=[]}const t=new Set(e.filter(o=>o.type===\"stone\").map(o=>o.meshId));let n=-1/0,i=-1/0,s=-1/0;const a=new O;return r.traverse(o=>{if(!(o instanceof We)||!o.geometry||t.has(o.uuid))return;const c=o.geometry.getAttribute(\"position\");if(!c)return;const l=c.count,u=l>15e3?Math.ceil(l/7500):1;for(let d=0;d<l;d+=u)a.fromBufferAttribute(c,d).applyMatrix4(o.matrixWorld),a.y>s&&(s=a.y),a.y>0&&(Math.abs(a.x)<=.85&&Math.abs(a.z)<=1.25&&a.y>n&&(n=a.y),Math.hypot(a.x,a.z)<=2.2&&a.y>i&&(i=a.y))}),Number.isFinite(n)&&n>4?n:Number.isFinite(i)&&i>4?i:s}function Hi(r){r.traverse(e=>{var t;e instanceof We&&((t=e.geometry)==null||t.dispose(),(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{var i,s,a,o,c;if(n){if(n instanceof _i){lr.release(n.bakeHandle),wl(n);return}if(n instanceof os){n.bakeHandle.key.startsWith(\"bvh_\")||lr.release(n.bakeHandle),El(n);return}n instanceof Ci&&((i=n.map)==null||i.dispose(),(s=n.normalMap)==null||s.dispose(),(a=n.roughnessMap)==null||a.dispose(),(o=n.metalnessMap)==null||o.dispose(),(c=n.envMap)==null||c.dispose()),n.dispose()}}))})}function zy(r,e={}){var t,n;const i=new Zv,s=Iy(e.background??16777215,e.fov??25),{scene:a,camera:o,dispose:c}=s,l=Ly(r,o,{...e,onResize:()=>ge()}),{renderer:u}=l,d=Ny(o,u.domElement,e),h=d.controls,f=By(a);e.shadows===!1&&f.setVisible(!1),Ay(a,u);let g;try{g=Tl(u)}catch{}let v=null,m=null;function p(K){if(!(typeof navigator<\"u\"&&/Mobi|Android/i.test(navigator.userAgent)))return K;const ne=\"medium\",M=[\"low\",\"medium\",\"high\",\"ultra\"];return M.indexOf(K)<=M.indexOf(ne)?K:ne}let _=p(e.diamondQuality??\"medium\"),b=null,x=!!e.gemEnvUrl,E=null,T=null;function A(K,ne){K&&K.traverse(M=>{if(!(M instanceof We))return;const w=Array.isArray(M.material)?M.material:[M.material];for(const L of w)L&&(L instanceof _i?L.setEnvMap(ne):L instanceof os&&(L.uniforms.envMap.value=ne,L.uniformsNeedUpdate=!0))})}async function I(K){try{if(E===K&&v){a.environment=v.texture,ge();return}E=K;const ne=await cf(K,u);v==null||v.dispose(),v=ne,a.environment=ne.texture,!x&&!e.gemEnvUrl&&!m&&(g=ne.gemTexture??ne.texture,A(U,g)),ge()}catch(ne){throw i.emit(\"error\",ne instanceof Error?ne:new Error(String(ne))),ne}}async function S(K){x=!0;try{if(T===K&&m){g=m.gemTexture??m.texture,A(U,g),ge();return}T=K;const ne=await cf(K,u);m==null||m.dispose(),m=ne,g=ne.gemTexture??ne.texture,A(U,g),ge()}catch(ne){throw i.emit(\"error\",ne instanceof Error?ne:new Error(String(ne))),ne}}e.metalEnvUrl&&I(e.metalEnvUrl).catch(()=>{}),e.gemEnvUrl&&S(e.gemEnvUrl).catch(()=>{});const R=u.domElement,F=()=>{lr.onContextRestored(u)};(t=R.addEventListener)==null||t.call(R,\"webglcontextrestored\",F);let U=null;const V=new Map;let P=[],z=[],X={},re={},J={},te=Ns[0].hex,Q=Oi[0].hex,ce=null,he=null,$=null,ue=0,Me=!1,xe=!1;function ge(){xe=!0,ue===0&&!Me&&typeof requestAnimationFrame<\"u\"&&(ue=requestAnimationFrame(Ge))}function Ge(){if(ue=0,Me)return;const K=!!h.update(),ne=h.autoRotate===!0;(xe||K||ne)&&(xe=!1,u.render(a,o)),(K||ne)&&ue===0&&!Me&&typeof requestAnimationFrame<\"u\"&&(ue=requestAnimationFrame(Ge))}function Ke(){Me=typeof document<\"u\"?document.hidden:!1,Me||ge()}typeof document<\"u\"&&document.addEventListener(\"visibilitychange\",Ke);const He=()=>{ge()};(n=h.addEventListener)==null||n.call(h,\"change\",He),ge();const tt=Uy(u,a,o,h,i,()=>P,{hoverHighlight:e.hoverHighlight??!1});function W(){if(typeof(et==null?void 0:et.__getCurrentModel)==\"function\"){const K=et.__getCurrentModel();if(K)return K}return U}function ze(K,ne,M){const w=`${K.partId}:${ne}`;if(J[w])return{color:J[w],isOverridden:!0};const L=`${K.meshId}:${ne}`;return J[L]?{color:J[L],isOverridden:!0}:J[K.partId]?{color:J[K.partId],isOverridden:!0}:J[K.meshId]?{color:J[K.meshId],isOverridden:!0}:M!=null&&M.slotId&&re[M.slotId]?{color:re[M.slotId],isOverridden:!0}:M!=null&&M.materialName&&re[M.materialName]?{color:re[M.materialName],isOverridden:!0}:K.materialName&&re[K.materialName]?{color:re[K.materialName],isOverridden:!0}:{color:K.type===\"metal\"?te:Q,isOverridden:!1}}function Le(K,ne){if(Array.isArray(K.material))K.material=K.material.map(M=>{let w=0;if(ne.traverse(L=>{L instanceof We&&(Array.isArray(L.material)?L.material.includes(M):L.material===M)&&w++}),w>1&&typeof M.clone==\"function\"){const L=M.clone();return L.name=M.name,L}return M});else if(K.material){let M=0;if(ne.traverse(w=>{w instanceof We&&(Array.isArray(w.material)?w.material.includes(K.material):w.material===K.material)&&M++}),M>1&&typeof K.material.clone==\"function\"){const w=K.material.clone();w.name=K.material.name,K.material=w}}}function Ie(K,ne){const M=W();if(M){let w=!1;if(Array.isArray(K.material))K.material.forEach((L,y)=>{const C=ne.slots[y];ze(ne,y,C).isOverridden&&(w=!0)});else{const L=ne.slots[0];ze(ne,0,L).isOverridden&&(w=!0)}w&&Le(K,M)}if(Array.isArray(K.material))K.material.forEach((w,L)=>{const y=ne.slots[L],{color:C}=ze(ne,L,y);ne.type===\"metal\"?cs(K,C,L):ls(K,C,L)});else{const w=ne.slots[0],{color:L}=ze(ne,0,w);ne.type===\"metal\"?cs(K,L):ls(K,L)}}async function Ue(K,ne,M,w,L=!0){const y=typeof K==\"string\"?{url:K}:K,C=M??e.dracoDecoderPath??Kc,D=await nx(y,ne,w,{dracoDecoderPath:C,normalize:L});if(D.scene)return D.scene;const{loader:k,dispose:G}=Eh({dracoDecoderPath:C});try{const Y=await new Promise((q,Z)=>{k.parse(D.glb,\"\",q,Z)});return L&&Ga(Y.scene),Y.scene}finally{G()}}function _t(K={}){var ne;if(!U)return;P=Ha(U,X),z=Ch(P),U.traverse(y=>{if(!(y instanceof We))return;const C=P.find(k=>k.meshId===y.uuid),D=(C==null?void 0:C.type)??\"metal\";ff(y,D,u,g,e.diamondMode??\"reference\"),C?Ie(y,C):D===\"metal\"?cs(y,te):ls(y,Q)}),_!==\"medium\"&&Hn(_);const M=new bt().setFromObject(U),w=M.getBoundingSphere(new Nn),L=w.radius>0?w.radius:1;if(K.preserveCamera?(h.minDistance=e.minZoom??L*.3,h.maxDistance=e.maxZoom??L*8,o.near=L*.01,o.far=L*100,o.updateProjectionMatrix(),h.update()):Al(U,o,h,e),Dy(o,r.clientWidth,r.clientHeight),f.mesh.position.y=M.min.y,V.has(\"shank\")&&V.has(\"head\")){const y=V.get(\"shank\"),C=V.get(\"head\"),D=new bt().setFromObject(C).getCenter(new O),k=new bt,G=new O;y.traverse(Y=>{if(!(Y instanceof We))return;const q=P.find(ae=>ae.meshId===Y.uuid);if((q==null?void 0:q.type)!==\"stone\")return;k.setFromObject(Y),k.getCenter(G);const Z=Math.hypot(G.x-D.x,G.z-D.z),ie=(Y.name||\"\").toLowerCase(),oe=ie.includes(\"solitaire\")||ie.includes(\"center\")||ie.includes(\"main\");Z<2.5&&G.y>4||oe?Y.visible=!1:Y.visible=!0})}i.emit(\"loading\",{progress:1}),i.emit(\"loaded\",{parts:P,materials:z}),tt.invalidateMeshes(),ce=null,he=null,(ne=performance==null?void 0:performance.mark)==null||ne.call(performance,\"3d-viewer:load-end\"),ge()}function nt(K,ne){var M,w,L,y;if((ne==null?void 0:ne.isIntactRing)===!0||(ne==null?void 0:ne.normalize)===!1)return!0;if((ne==null?void 0:ne.isIntactRing)===!1)return!1;if(((M=K.userData)==null?void 0:M.isIntactRing)===!0||((w=K.userData)==null?void 0:w.type)===\"intact_ring\")return!0;if(((L=K.userData)==null?void 0:L.isIntactRing)===!1||((y=K.userData)==null?void 0:y.type)===\"shank\")return!1;let C=!1;return K.traverse(D=>{var k,G,Y;if(D instanceof We){if(((k=D.userData)==null?void 0:k.isCenterStone)===!0||((G=D.userData)==null?void 0:G.isIntactRing)===!0||((Y=D.userData)==null?void 0:Y.type)===\"center_stone\"){C=!0;return}const q=(D.name||\"\").toLowerCase(),Z=Array.isArray(D.material)?D.material[0]:D.material,ie=((Z==null?void 0:Z.name)||\"\").toLowerCase(),oe=q.includes(\"diamond\")||q.includes(\"stone\")||q.includes(\"gem\")||q.includes(\"cs_\")||ie.includes(\"diamond\")||ie.includes(\"gem\")||ie.includes(\"cs_\");(q.includes(\"cs_\")||q.includes(\"cs-\")||q.includes(\"center_stone\")||q.includes(\"centerstone\")||q.includes(\"center_diamond\")||q.includes(\"main_stone\")||oe&&(q.includes(\"center\")||q.includes(\"solitaire\")))&&(C=!0)}}),C}function B(K,ne){if(nt(K,ne))return;K.traverse(Y=>{if(Y===K)return;const q=Y.scale.x,Z=Y.quaternion,ie=q>.15&&q<.85,oe=Math.abs(Z.x)>.9&&Math.abs(Z.w)>.1&&Math.abs(Z.w)<.35||Math.abs(Z.z)>.9&&Math.abs(Z.y)>.1&&Math.abs(Z.y)<.35;ie&&oe&&(Y.parent===K&&Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.quaternion.set(0,0,0,1),Y.scale.set(1,1,1))}),K.updateMatrixWorld(!0);const M=new bt().setFromObject(K).getSize(new O),w=Math.max(M.x,M.y,M.z);let L=1;w>0&&w<.1?L=1e3:w>=.5&&w<1.6?L=25.4:w>=1.6&&w<6&&(L=10),L!==1&&(K.scale.multiplyScalar(L),K.updateMatrixWorld(!0));const y=[],C=[];K.traverse(Y=>{if(Y instanceof We&&Y.geometry){const q=(Y.name||\"\").toLowerCase(),Z=Array.isArray(Y.material)?Y.material[0]:Y.material,ie=((Z==null?void 0:Z.name)||\"\").toLowerCase();q.includes(\"diamond\")||q.includes(\"stone\")||q.includes(\"gem\")||ie.includes(\"diamond\")||ie.includes(\"gem\")?y.push(Y):C.push(Y)}});const D=N(K),k=D.getSize(new O);let G=\"Y\";if(k.z<=k.x*.75&&k.z<=k.y*.75&&k.x>10&&k.y>10?G=\"Z\":k.x<=k.y*.75&&k.x<=k.z*.75&&k.y>10&&k.z>10&&(G=\"X\"),G===\"Z\"){const Y=D.min.y,q=D.max.y,Z=q-Y;let ie=!0;if(y.length>0){const Ft=new bt;y.forEach(Zt=>Ft.expandByObject(Zt)),ie=Ft.getCenter(new O).y<0}const oe=ie?Y+Z*.18:q-Z*.18,ae=ie?q-Z*.18:Y+Z*.18;let le=0,de=0,be=0,Se=0,$e=0,Oe=0,ke=0,it=0;const Ee=new O;K.traverse(Ft=>{if(!(Ft instanceof We)||!Ft.geometry||C.length>0&&y.includes(Ft))return;const Zt=Ft.geometry.getAttribute(\"position\");if(!Zt)return;const Nl=Zt.count>1e4?Math.ceil(Zt.count/5e3):1;for(let ur=0;ur<Zt.count;ur+=Nl){Ee.fromBufferAttribute(Zt,ur).applyMatrix4(Ft.matrixWorld);const Ul=ie?Ee.y<=oe:Ee.y>=oe,Fl=ie?Ee.y>=ae:Ee.y<=ae;Ul?(le+=Ee.x,de+=Ee.y,be+=Ee.z,Se++):Fl&&($e+=Ee.x,Oe+=Ee.y,ke+=Ee.z,it++)}});const ut=new O(Se>0?le/Se:0,Se>0?de/Se:ie?Y:q,Se>0?be/Se:0),Nt=new O(it>0?$e/it:0,it>0?Oe/it:ie?q:Y,it>0?ke/it:0),mt=new O().subVectors(ut,Nt),lt=ie?-mt.y:mt.y,Je=Math.atan2(mt.z,lt),Wt=Math.atan2(mt.x,lt),Tn=(ut.x+Nt.x)/2,Et=(ut.y+Nt.y)/2,Ln=(ut.z+Nt.z)/2,yi=new Pt;yi.name=\"shank_cad_aligner\";const Mi=new Pt;for(Mi.name=\"shank_recenter\",Mi.position.set(-Tn,-Et,-Ln);K.children.length>0;)Mi.add(K.children[0]);yi.rotation.z=-Wt,yi.rotation.x=ie?-Math.PI/2+Je:Math.PI/2-Je,yi.add(Mi),K.add(yi),K.updateMatrixWorld(!0)}else if(G===\"X\"){const Y=new Pt;Y.name=\"shank_cad_aligner\";const q=new Pt;q.name=\"shank_recenter\";const Z=D.getCenter(new O);for(q.position.set(-Z.x,-Z.y,-Z.z);K.children.length>0;)q.add(K.children[0]);Y.rotation.z=Math.PI/2,Y.add(q),K.add(Y)}else{const Y=D.min.z,q=D.max.z,Z=q-Y;let ie=!1;if(y.length>0){const Ft=new bt;y.forEach(Zt=>Ft.expandByObject(Zt)),ie=Ft.getCenter(new O).z<0}const oe=ie?Y+Z*.18:q-Z*.18,ae=ie?q-Z*.18:Y+Z*.18;let le=0,de=0,be=0,Se=0,$e=0,Oe=0,ke=0,it=0;const Ee=new O;K.traverse(Ft=>{if(!(Ft instanceof We)||!Ft.geometry||C.length>0&&y.includes(Ft))return;const Zt=Ft.geometry.getAttribute(\"position\");if(!Zt)return;const Nl=Zt.count>1e4?Math.ceil(Zt.count/5e3):1;for(let ur=0;ur<Zt.count;ur+=Nl){Ee.fromBufferAttribute(Zt,ur).applyMatrix4(Ft.matrixWorld);const Ul=ie?Ee.z<=oe:Ee.z>=oe,Fl=ie?Ee.z>=ae:Ee.z<=ae;Ul?(le+=Ee.x,de+=Ee.y,be+=Ee.z,Se++):Fl&&($e+=Ee.x,Oe+=Ee.y,ke+=Ee.z,it++)}});const ut=new O(Se>0?le/Se:0,Se>0?de/Se:0,Se>0?be/Se:ie?Y:q),Nt=new O(it>0?$e/it:0,it>0?Oe/it:0,it>0?ke/it:ie?q:Y),mt=new O().subVectors(ut,Nt),lt=ie?-mt.z:mt.z,Je=Math.atan2(mt.y,lt),Wt=Math.atan2(mt.x,lt),Tn=(ut.x+Nt.x)/2,Et=(ut.y+Nt.y)/2,Ln=(ut.z+Nt.z)/2,yi=Math.abs(Tn)>.1||Math.abs(Et)>.1||Math.abs(Ln)>.1,Mi=Math.abs(Je)>.01||Math.abs(Wt)>.01;if(yi||Mi||ie){const Ft=new Pt;Ft.name=\"shank_cad_aligner\";const Zt=new Pt;for(Zt.name=\"shank_recenter\",Zt.position.set(-Tn,-Et,-Ln);K.children.length>0;)Zt.add(K.children[0]);ie&&(Ft.rotation.y=Math.PI),Ft.rotation.x=-Je,Ft.rotation.y+=-Wt,Ft.add(Zt),K.add(Ft),K.updateMatrixWorld(!0)}}}function N(K){K.updateMatrixWorld(!0);let ne=[];try{ne=Ha(K,{})}catch{ne=[]}const M=new Set(ne.filter(y=>y.type===\"stone\").map(y=>y.meshId)),w=new bt,L=new bt;return K.traverse(y=>{!(y instanceof We)||!y.geometry||(L.expandByObject(y),M.has(y.uuid)||w.expandByObject(y))}),w.isEmpty()?L:w}const se=10.238,_e=.25;function pe(K){const ne=ky(K);if(Number.isFinite(ne)&&ne>-1/0)return ne;const M=new bt().setFromObject(K);return M.isEmpty()?se:M.max.y}function ve(K,ne){const M=pe(K);if(!Number.isFinite(M))return 0;if(ne){ne.updateMatrixWorld(!0);const w=new bt().setFromObject(ne).min.y;if(Number.isFinite(w))return M-_e-w}return M-se}function Fe(K,ne,M,w){var L,y,C;K.updateMatrixWorld(!0),ne.updateMatrixWorld(!0),M.updateMatrixWorld(!0);const D=K.getObjectByName(\"SOCKET_Head_Mount\")??K.getObjectByName(\"socket_head\")??K.getObjectByName(\"head_socket\")??K.getObjectByName(\"attach_point\"),k=M.getObjectByName(\"ANCHOR_Head_Base\")??M.getObjectByName(\"anchor_base\")??M.getObjectByName(\"head_anchor\")??M.getObjectByName(\"mount_point\");if(D&&k&&ne.parent){const Y=new qe().identity();w!=null&&w.rotation&&Y.makeRotationFromEuler(new Ms(...w.rotation)),w!=null&&w.position&&Y.setPosition(w.position[0],w.position[1],w.position[2]),w!=null&&w.scale&&Y.scale(new O().setScalar(w.scale));const q=D.matrixWorld.clone().multiply(Y),Z=k.matrixWorld.clone().invert(),ie=ne.matrixWorld.clone(),oe=ne.parent.matrixWorld.clone().invert().multiply(q).multiply(Z).multiply(ie),ae=new O,le=new Dn,de=new O;oe.decompose(ae,le,de);const be=new qe().compose(ae,le,de);let Se=0;for(let $e=0;$e<16;$e++){const Oe=oe.elements[$e]-be.elements[$e];Se+=Oe*Oe}Math.sqrt(Se)>1e-5?(ne.matrixAutoUpdate=!1,ne.matrix.copy(oe)):(ne.matrixAutoUpdate=!0,ne.position.copy(ae),ne.quaternion.copy(le),ne.scale.copy(de)),ne.updateMatrixWorld(!0);return}const G=ve(K,M);ne.matrixAutoUpdate=!0,ne.position.set(((L=w==null?void 0:w.position)==null?void 0:L[0])??0,G+(((y=w==null?void 0:w.position)==null?void 0:y[1])??0),((C=w==null?void 0:w.position)==null?void 0:C[2])??0),w!=null&&w.scale&&ne.scale.setScalar(w.scale),w!=null&&w.rotation&&ne.rotation.set(...w.rotation),ne.updateMatrixWorld(!0)}async function we(K,ne={}){var M,w,L,y,C,D,k,G;$==null||$.abort(),$=new AbortController;const Y=$.signal;i.emit(\"loading\",{progress:.1});try{U&&(a.remove(U),Hi(U),U=null),V.clear();const q=new Pt;q.name=\"ring_root\",a.add(q),U=q;const Z=ne.cadUpAxis===\"Y\"?0:-Math.PI/2,ie=new Pt;ie.name=\"assembly_root\",ie.rotation.x=Z,q.add(ie);const oe=Object.entries(K).filter(([le,de])=>!!de);oe.sort(([le],[de])=>le===\"shank\"?-1:de===\"shank\"?1:0);let ae=0;for(const[le,de]of oe){if(!de)continue;const be=await Ue(de,Y,ne.dracoDecoderPath,void 0,!1);if(be.name=`slot_${le}`,le===\"shank\"){const Se={...ne,isIntactRing:(de==null?void 0:de.isIntactRing)??ne.isIntactRing};B(be,Se)}if(ne.useAnchor??(le!==\"shank\"&&(le===\"head\"||!!ne.transform))){const Se=le===\"head\"?\"head_anchor\":`${le}_anchor`,$e=le===\"head\"?\"head_cad_rotator\":`${le}_cad_rotator`,Oe=new Pt;Oe.name=Se;const ke=new Pt;ke.name=$e,ke.rotation.x=Z,ke.add(be),Oe.add(ke),q.add(Oe),le===\"head\"&&V.has(\"shank\")?Fe(V.get(\"shank\"),Oe,ke,ne.transform):(Oe.position.set(((w=(M=ne.transform)==null?void 0:M.position)==null?void 0:w[0])??0,((y=(L=ne.transform)==null?void 0:L.position)==null?void 0:y[1])??0,((D=(C=ne.transform)==null?void 0:C.position)==null?void 0:D[2])??0),(k=ne.transform)!=null&&k.scale&&Oe.scale.setScalar(ne.transform.scale),(G=ne.transform)!=null&&G.rotation&&Oe.rotation.set(...ne.transform.rotation))}else ie.add(be);V.set(le,be),ae++,i.emit(\"loading\",{progress:.1+ae/Math.max(1,oe.length)*.7})}_t(ne)}catch(q){if(q.name===\"AbortError\"||Y.aborted)return;i.emit(\"error\",q instanceof Error?q:new Error(String(q)))}}async function Ne(K,ne,M={}){var w,L,y,C,D,k,G,Y,q,Z;try{if(ne===null){if(V.has(K)){const ae=V.get(K);V.delete(K);const le=K===\"head\"?\"head_anchor\":`${K}_anchor`,de=(U==null?void 0:U.getObjectByName(le))??(U==null?void 0:U.getObjectByName(`${K}_anchor`));if(de)U==null||U.remove(de),Hi(de);else{const be=U==null?void 0:U.getObjectByName(\"assembly_root\");be?be.remove(ae):U==null||U.remove(ae),Hi(ae)}}U&&_t(M);return}const ie=M.cadUpAxis===\"Y\"?0:-Math.PI/2;if(U){if(V.size===0){const ae=U;if(typeof((w=ae.userData)==null?void 0:w.normalizedScale)==\"number\"&&ae.userData.normalizedScale>0){const Oe=1/ae.userData.normalizedScale;ae.scale.multiplyScalar(Oe),ae.position.multiplyScalar(Oe),ae.updateMatrixWorld(!0)}const le=new bt().setFromObject(ae).getSize(new O),de=Math.max(le.x,le.y,le.z)>3,be=nt(ae,M),Se=new Pt;Se.name=\"ring_root\";const $e=new Pt;$e.name=\"assembly_root\",$e.rotation.x=be?0:de?ie:0,de&&!be&&B(ae,M),$e.add(ae),Se.add($e),a.remove(ae),a.add(Se),V.set(\"shank\",ae),U=Se}}else{const ae=new Pt;ae.name=\"ring_root\",a.add(ae);const le=new Pt;le.name=\"assembly_root\",le.rotation.x=ie,ae.add(le),U=ae}i.emit(\"loading\",{progress:.2});const oe=await Ue(ne,M.signal,M.dracoDecoderPath,ae=>{i.emit(\"loading\",{progress:.2+ae*.6})},!1);if(oe.name=`slot_${K}`,K===\"shank\"&&B(oe),V.has(K)){const ae=V.get(K);V.delete(K);const le=K===\"head\"?\"head_anchor\":`${K}_anchor`,de=U.getObjectByName(le)??U.getObjectByName(`${K}_anchor`);if(de)U.remove(de),Hi(de);else{const be=U.getObjectByName(\"assembly_root\");be?be.remove(ae):U.remove(ae),Hi(ae)}}if(M.useAnchor??(K!==\"shank\"&&(K===\"head\"||!!M.transform))){const ae=K===\"head\"?\"head_anchor\":`${K}_anchor`,le=K===\"head\"?\"head_cad_rotator\":`${K}_cad_rotator`,de=new Pt;de.name=ae;const be=new Pt;be.name=le,be.rotation.x=ie,be.add(oe),de.add(be),U.add(de),K===\"head\"&&V.has(\"shank\")?Fe(V.get(\"shank\"),de,be,M.transform):(de.position.set(((y=(L=M.transform)==null?void 0:L.position)==null?void 0:y[0])??0,((D=(C=M.transform)==null?void 0:C.position)==null?void 0:D[1])??0,((G=(k=M.transform)==null?void 0:k.position)==null?void 0:G[2])??0),(Y=M.transform)!=null&&Y.scale&&de.scale.setScalar(M.transform.scale),(q=M.transform)!=null&&q.rotation&&de.rotation.set(...M.transform.rotation))}else{const ae=U.getObjectByName(\"assembly_root\");ae?ae.add(oe):U.add(oe)}if(V.set(K,oe),K===\"shank\"&&V.has(\"head\")){const ae=U.getObjectByName(\"head_anchor\")??U.getObjectByName(\"slot_head_anchor\"),le=U.getObjectByName(\"head_cad_rotator\");ae&&le&&Fe(oe,ae,le,M.transform)}_t(M)}catch(ie){if(ie.name===\"AbortError\"||(Z=M.signal)!=null&&Z.aborted)return;i.emit(\"error\",ie instanceof Error?ie:new Error(String(ie)))}}function je(K){return V.get(K)??null}function Qe(K){return V.has(K)}async function me(K,ne={}){var M;const w=typeof K==\"string\"?{url:K}:K;if(w&&typeof w==\"object\"&&\"modular\"in w&&w.modular){const C=w,D={};for(const[k,G]of Object.entries(C))k!==\"modular\"&&G&&(D[k]=G);return we(D,ne)}$==null||$.abort(),$=new AbortController;const L=$;ne.signal&&(ne.signal.aborted?L.abort():ne.signal.addEventListener(\"abort\",()=>L.abort(),{once:!0}));const y=L.signal;(M=performance==null?void 0:performance.mark)==null||M.call(performance,\"3d-viewer:load-start\"),i.emit(\"loading\",{progress:0});try{const C=ne.dracoDecoderPath??e.dracoDecoderPath??Kc,D=await Ue(w,y,C,k=>{i.emit(\"loading\",{progress:k*.8})});if(y.aborted)return;i.emit(\"loading\",{progress:.85}),i.emit(\"loading\",{progress:.9}),U&&(a.remove(U),Hi(U),U=null),ne.preserveComponents||V.clear(),U=D,a.add(U),_t(ne)}catch(C){if(C.name===\"AbortError\"||y.aborted)return;i.emit(\"error\",C instanceof Error?C:new Error(String(C)))}}function ft(K){var ne;te=((ne=Ns.find(w=>w.id===K))==null?void 0:ne.hex)??K,ce=te;const M=W();M&&(M.traverse(w=>{if(!(w instanceof We))return;const L=P.find(y=>y.meshId===w.uuid);if(((L==null?void 0:L.type)??\"metal\")===\"metal\")if(L)if(Array.isArray(w.material))w.material.forEach((y,C)=>{const D=L.slots[C],{isOverridden:k}=ze(L,C,D);k||cs(w,te,C)});else{const y=L.slots[0],{isOverridden:C}=ze(L,0,y);C||cs(w,te)}else cs(w,te)}),i.emit(\"change\",j()),ge())}function rt(K){var ne;Q=((ne=Oi.find(w=>w.id===K))==null?void 0:ne.hex)??K,he=Q;const M=W();M&&(M.traverse(w=>{if(!(w instanceof We))return;const L=P.find(y=>y.meshId===w.uuid);if((L==null?void 0:L.type)===\"stone\")if(L)if(Array.isArray(w.material))w.material.forEach((y,C)=>{const D=L.slots[C],{isOverridden:k}=ze(L,C,D);k||ls(w,Q,C)});else{const y=L.slots[0],{isOverridden:C}=ze(L,0,y);C||ls(w,Q)}else ls(w,Q)}),i.emit(\"change\",j()),ge())}function Ye(K,ne){const M=P.find(y=>y.meshId===K||y.partId===K),w=M?M.partId:K;X[w]=ne;const L=W();L&&(P=Ha(L,X),z=Ch(P),L.traverse(y=>{if(!(y instanceof We))return;const C=P.find(D=>D.meshId===y.uuid);!C||C.partId!==w&&C.meshId!==K||(ff(y,ne,u,g,e.diamondMode??\"reference\"),Ie(y,C))}),ne===\"stone\"&&_!==\"medium\"&&Hn(_)),i.emit(\"change\",j()),ge()}function Pe(K,ne){const M=z.filter(L=>L.slotId===K||L.name===K);if(M.length>0)for(const L of M)re[L.slotId]=ne;re[K]=ne;const w=W();w&&w.traverse(L=>{if(!(L instanceof We))return;const y=P.find(C=>C.meshId===L.uuid);y&&Ie(L,y)}),i.emit(\"change\",j()),ge()}function Ce(K,ne,M){const w=M!==void 0?`${K}:${M}`:K;J[w]=ne;const L=W();L&&L.traverse(y=>{if(!(y instanceof We))return;const C=P.find(D=>D.meshId===y.uuid);C&&(C.partId===K||C.meshId===K)&&Ie(y,C)}),i.emit(\"change\",j()),ge()}function H(K){delete re[K];for(const M of z)(M.slotId===K||M.name===K)&&(delete re[M.slotId],delete re[M.name]);const ne=W();ne&&ne.traverse(M=>{if(!(M instanceof We))return;const w=P.find(L=>L.meshId===M.uuid);w&&Ie(M,w)}),i.emit(\"change\",j()),ge()}function fe(K,ne){if(ne!==void 0)delete J[`${K}:${ne}`];else{delete J[K];for(const w of Object.keys(J))w.startsWith(`${K}:`)&&delete J[w]}const M=W();M&&M.traverse(w=>{if(!(w instanceof We))return;const L=P.find(y=>y.meshId===w.uuid);L&&(L.partId===K||L.meshId===K)&&Ie(w,L)}),i.emit(\"change\",j()),ge()}function Re(){re={},J={};const K=W();K&&K.traverse(ne=>{if(!(ne instanceof We))return;const M=P.find(w=>w.meshId===ne.uuid);M&&Ie(ne,M)}),i.emit(\"change\",j()),ge()}function De(){return[...z]}function ee(){return[...P]}function j(){return Fy(te,Q,X,o,h,re,J)}function ye(K){X={},re={},J={};const ne=new Set(P.map(y=>y.partId)),M=new Set(z.map(y=>y.slotId)),w=new Set(z.map(y=>y.name)),L=Oy(K,ft,rt,Ye,o,h,{setMaterialColor:Pe,setPartColor:Ce,availablePartIds:ne,availableSlotIds:M,availableMaterialNames:w,currentColor:{metalColor:ce??void 0,stoneColor:he??void 0}});return ce=K.metalColor,he=K.stoneColor,ge(),L}e.initialState&&(ye(e.initialState),d.initialPosition.copy(o.position),d.initialTarget.copy(h.target));function Ae(K,ne){return i.on(K,ne)}function Ze(){var K,ne;b!==null&&(clearTimeout(b),b=null),$==null||$.abort(),ue!==0&&typeof cancelAnimationFrame<\"u\"&&(cancelAnimationFrame(ue),ue=0),typeof document<\"u\"&&document.removeEventListener(\"visibilitychange\",Ke),(K=h.removeEventListener)==null||K.call(h,\"change\",He),(ne=R.removeEventListener)==null||ne.call(R,\"webglcontextrestored\",F),lr.clearCache(),f.dispose(),tt.dispose(),d.dispose(),U&&(a.remove(U),Hi(U),U=null),V.clear(),v==null||v.dispose(),m==null||m.dispose(),c(),l.dispose(),i.clear()}function Xe(K){return K!==void 0&&(h.autoRotateSpeed=K),h.autoRotate=!h.autoRotate,h.autoRotate&&ge(),h.autoRotate}function at(K){K!==void 0&&(h.autoRotateSpeed=K),h.autoRotate=!0,ge()}function ot(){h.autoRotate=!1}function Rt(){return h.autoRotate}function Dt(){U?Al(U,o,h,e):d.resetCamera(),ge()}function pt(){U&&(Al(U,o,h,e),ge())}function Ut(K,ne){o.position.set(K[0],K[1],K[2]),h.target.set(ne[0],ne[1],ne[2]),h.update(),ge()}async function En(K){const ne=(K==null?void 0:K.format)??\"image/png\",M=(K==null?void 0:K.quality)??.95;return u.render(a,o),u.domElement.toDataURL(ne,M)}function xi(K){l.setQuality(K)}function js(K){f.setVisible(K),ge()}function Gn(){$==null||$.abort(),U&&(a.remove(U),Hi(U),U=null),V.clear(),P=[],X={},z=[],re={},J={},ce=null,he=null,f.mesh.position.y=0,f.setScale(1),tt.invalidateMeshes(),ge()}function Hn(K){const ne=p(K);b!==null&&clearTimeout(b),b=setTimeout(()=>{if(b=null,_=ne,!U)return;const{rayBounces:M,cubeResolution:w}=uf(ne);U.traverse(L=>{var y;if(!(L instanceof We))return;const C=P.find(Z=>Z.meshId===L.uuid);if((C==null?void 0:C.type)!==\"stone\")return;const D=L.material;if(!(D instanceof _i))return;const k=D.bakeHandle,G=lr.acquire(L.geometry,u,{resolution:w});if(!G)return;lr.release(k);const Y=((y=D.uniforms.envMap)==null?void 0:y.value)??g,q=hf(G,Y,D.preset,{rayBounces:M,quality:ne,orientEnvMap:D.defines.DIA_ORIENT_ENVMAP===1});wl(D),L.material=q}),ge()},300)}const et={load:me,loadComponent:Ne,loadModular:we,getComponent:je,hasComponent:Qe,unload:Gn,setMetalColor:ft,setStoneColor:rt,setPartType:Ye,setMaterialColor:Pe,setPartColor:Ce,clearMaterialColor:H,clearPartColor:fe,clearOverrides:Re,getMaterials:De,getParts:ee,getState:j,setState:ye,on:Ae,dispose:Ze,toggleRotation:Xe,startRotation:at,stopRotation:ot,isRotating:Rt,resetCamera:Dt,fitToScene:pt,setCameraPosition:Ut,captureSnapshot:En,setQuality:xi,setShadowsEnabled:js,setMetalEnvironment:I,setGemEnvironment:S,setDiamondQuality:Hn,requestRender:ge};return typeof window<\"u\"&&(et.__scene=a,et.__getCurrentModel=()=>U),et}function Bt(r){var t;const e=JSON.stringify(r);typeof window<\"u\"&&((t=window.ReactNativeWebView)!=null&&t.postMessage)?window.ReactNativeWebView.postMessage(e):typeof window<\"u\"&&window.parent&&window.parent!==window&&window.parent.postMessage(e,\"*\")}function pf(){var p;const r=document.getElementById(\"viewer-container\");if(!r){console.error(\"[Viewer Runtime] #viewer-container not found\");return}let e=null;try{const _=typeof window<\"u\"&&((p=window.location)!=null&&p.search)?new URLSearchParams(window.location.search):null,b={};_&&(_.get(\"diamondMode\")&&(b.diamondMode=_.get(\"diamondMode\")),_.get(\"diamondQuality\")&&(b.diamondQuality=_.get(\"diamondQuality\")),_.get(\"minZoom\")&&(b.minZoom=parseFloat(_.get(\"minZoom\"))),_.get(\"maxZoom\")&&(b.maxZoom=parseFloat(_.get(\"maxZoom\"))),_.get(\"autoRotateSpeed\")&&(b.autoRotateSpeed=parseFloat(_.get(\"autoRotateSpeed\")))),e=zy(r,{antialias:!0,alpha:!0,background:\"transparent\",...b}),window.__viewer=e,console.log(\"[Viewer Runtime] 3D engine initialized successfully\"),e.on(\"loading\",x=>{Bt({type:\"VIEWER_PROGRESS\",progress:x.progress})}),e.on(\"loaded\",x=>{var E,T,A;console.log(\"[Viewer Runtime] Model loaded into 3D scene:\",((E=x.parts)==null?void 0:E.length)??0,\"parts\"),Bt({type:\"VIEWER_LOADED\",parts:x.parts||((T=e.getParts)==null?void 0:T.call(e))||[],materials:x.materials||((A=e.getMaterials)==null?void 0:A.call(e))||[]})}),e.on(\"partSelected\",x=>{Bt({type:\"PART_SELECTED\",meshId:x.meshId,partId:x.partId,partType:x.type||x.partType,slotIndex:x.slotIndex,slotId:x.slotId,materialName:x.materialName})}),e.on(\"change\",x=>{Bt({type:\"VIEWER_CHANGE\",state:x})}),e.on(\"error\",x=>{console.error(\"[Viewer Runtime] Viewer error:\",x),Bt({type:\"VIEWER_ERROR\",code:\"MODEL_LOAD_FAILED\",message:(x==null?void 0:x.message)||String(x)})})}catch(_){console.error(\"[Viewer Runtime] WebGL init failure:\",_),Bt({type:\"VIEWER_ERROR\",code:\"WEBGL_UNSUPPORTED\",message:(_==null?void 0:_.message)||\"Failed to initialize 3D viewer WebGL canvas\"});return}r.addEventListener(\"pointerdown\",()=>{Bt({type:\"INTERACTION_START\"})}),window.addEventListener(\"pointerup\",()=>{Bt({type:\"INTERACTION_END\"})}),r.addEventListener(\"touchstart\",()=>{Bt({type:\"INTERACTION_START\"})},{passive:!0}),window.addEventListener(\"touchend\",()=>{Bt({type:\"INTERACTION_END\"})},{passive:!0}),window.addEventListener(\"pagehide\",()=>{if(e&&typeof e.dispose==\"function\")try{e.dispose()}catch{}}),window.addEventListener(\"beforeunload\",()=>{if(e&&typeof e.dispose==\"function\")try{e.dispose()}catch{}}),document.addEventListener(\"visibilitychange\",()=>{if(document.hidden&&e&&typeof e.stopRotation==\"function\")try{e.stopRotation()}catch{}});let t=!1,n,i,s=null,a=null;function o(_){var b;if(!(!_||typeof _!=\"string\")){if(_.startsWith(\"/\")&&typeof window<\"u\")try{if(window.parent&&((b=window.parent.location)!=null&&b.origin)&&window.parent.location.origin!==\"null\")return window.parent.location.origin+_;if(window.location.origin&&window.location.origin!==\"null\")return window.location.origin+_}catch{}return _}}let c=null;function l(_,b=[0,0,0],x=5){const[E,T,A]=b;switch(_){case\"crown\":return{position:[E,T+x,A+.001],target:[E,T,A]};case\"profile\":return{position:[E+x,T,A],target:[E,T,A]};case\"macro\":{const I=x*.45,S=Math.PI/4;return{position:[E+I*Math.cos(S),T+I*.7,A+I*Math.sin(S)],target:[E,T+x*.05,A]}}case\"hero\":default:{const I=Math.PI/4,S=x*.6,R=x*.8;return{position:[E+R*Math.sin(I),T+S,A+R*Math.cos(I)],target:[E,T,A]}}}}function u(_,b=600){var P,z,X;if(!e)return;c!==null&&(cancelAnimationFrame(c),c=null);const x=(P=e.getState)==null?void 0:P.call(e),E=((z=x==null?void 0:x.cameraState)==null?void 0:z.position)||[0,2,5],T=((X=x==null?void 0:x.cameraState)==null?void 0:X.target)||[0,0,0],A=E[0]-T[0],I=E[1]-T[1],S=E[2]-T[2],R=Math.hypot(A,I,S)||4,F=l(_,T,R),U=performance.now(),V=re=>{var $;const J=re-U,te=Math.min(J/b,1),Q=1-Math.pow(1-te,3),ce=[E[0]+(F.position[0]-E[0])*Q,E[1]+(F.position[1]-E[1])*Q,E[2]+(F.position[2]-E[2])*Q],he=[T[0]+(F.target[0]-T[0])*Q,T[1]+(F.target[1]-T[1])*Q,T[2]+(F.target[2]-T[2])*Q];($=e.setCameraPosition)==null||$.call(e,ce,he),te<1?c=requestAnimationFrame(V):c=null};c=requestAnimationFrame(V)}function d(_){var b;if(!_||typeof _!=\"string\")return _;if(_.startsWith(\"/\")&&typeof window<\"u\")try{const x=window.parent&&((b=window.parent.location)!=null&&b.origin)&&window.parent.location.origin!==\"null\"?window.parent.location.origin:window.location.origin&&window.location.origin!==\"null\"?window.location.origin:\"\";return x?`${x}${_}`:_}catch{return _}return _}function h(_){if(!_)return null;if(typeof _==\"string\")return{url:d(_),format:\"glb\"};if(typeof _==\"object\"){const b=_.url||_.uri;return{..._,url:d(b),format:_.format||\"glb\"}}return _}async function f(){(s||a)&&await Promise.allSettled([s,a]),i&&e.setGemEnvironment&&e.setGemEnvironment(i).catch(()=>{}),n&&e.setMetalEnvironment&&e.setMetalEnvironment(n).catch(()=>{})}function g(_){var b,x,E,T,A,I,S,R,F,U,V,P,z,X,re,J,te,Q,ce,he,$,ue,Me,xe,ge,Ge,Ke,He,tt;if(!(!_||!_.type))switch(t=!0,_.type){case\"PING\":{Bt({type:\"VIEWER_READY\"});break}case\"LOAD_MODEL\":{if(!e)return;const W=_.source;if(W&&typeof W==\"object\"&&W.modular){const Le={};for(const[Ie,Ue]of Object.entries(W))Ie!==\"modular\"&&(Le[Ie]=h(Ue));console.log(\"[Viewer Runtime] Loading modular model:\",Le),e.loadModular(Le,{preserveCamera:!0}).then(f).catch(Ie=>{console.error(\"[Viewer Runtime] Failed to load modular model:\",Ie),Bt({type:\"VIEWER_ERROR\",code:\"MODEL_LOAD_FAILED\",message:(Ie==null?void 0:Ie.message)||\"Failed to load modular model\"})});break}let ze=(W==null?void 0:W.uri)||(W==null?void 0:W.url)||(typeof W==\"string\"?W:null);if(console.log(\"[Viewer Runtime] LOAD_MODEL received:\",ze),ze){ze=d(ze);const Le=W&&typeof W==\"object\"&&W.format?{url:ze,format:W.format}:ze;console.log(\"[Viewer Runtime] Loading 3D model from resolved URL:\",Le),e.load(Le).then(f).catch(Ie=>{console.error(\"[Viewer Runtime] Failed to load 3D model:\",Ie),Bt({type:\"VIEWER_ERROR\",code:\"MODEL_LOAD_FAILED\",message:(Ie==null?void 0:Ie.message)||\"Failed to load 3D model\"})})}break}case\"LOAD_MODULAR\":{if(!e||!_.components)return;const W={};for(const[ze,Le]of Object.entries(_.components))W[ze]=h(Le);console.log(\"[Viewer Runtime] LOAD_MODULAR received:\",W),e.loadModular(W,_.options||{preserveCamera:!0}).then(f).catch(ze=>{console.error(\"[Viewer Runtime] Failed to load modular components:\",ze),Bt({type:\"VIEWER_ERROR\",code:\"MODEL_LOAD_FAILED\",message:(ze==null?void 0:ze.message)||\"Failed to load modular components\"})});break}case\"LOAD_COMPONENT\":{if(!e||!_.slot)return;const W=h(_.source);console.log(`[Viewer Runtime] LOAD_COMPONENT '${_.slot}':`,W),e.loadComponent(_.slot,W,_.options||{preserveCamera:!0}).then(f).catch(ze=>{console.error(`[Viewer Runtime] Failed to load component '${_.slot}':`,ze),Bt({type:\"VIEWER_ERROR\",code:\"MODEL_LOAD_FAILED\",message:(ze==null?void 0:ze.message)||`Failed to load component '${_.slot}'`})});break}case\"APPLY_CONFIG\":{if(!e||!_.config)return;const W=_.config;if(W.gemEnvUrl){const ze=o(W.gemEnvUrl);ze&&ze!==i&&(i=ze,s=(b=e.setGemEnvironment)==null?void 0:b.call(e,ze).catch(Le=>{console.error(\"[Viewer Runtime] Failed to set gem environment:\",Le)}))}if(W.metalEnvUrl){const ze=o(W.metalEnvUrl);ze&&ze!==n&&(n=ze,a=(x=e.setMetalEnvironment)==null?void 0:x.call(e,ze).catch(Le=>{console.error(\"[Viewer Runtime] Failed to set metal environment:\",Le)}))}W.metalColor&&((E=e.setMetalColor)==null||E.call(e,W.metalColor)),W.stoneColor&&((T=e.setStoneColor)==null||T.call(e,W.stoneColor)),W.shape&&(typeof e.switchShape==\"function\"?e.switchShape(W.shape):typeof e.setShape==\"function\"&&e.setShape(W.shape)),W.quality&&((A=e.setQuality)==null||A.call(e,W.quality)),W.diamondQuality&&((I=e.setDiamondQuality)==null||I.call(e,W.diamondQuality)),W.autoRotate!==void 0&&(W.autoRotate?(S=e.startRotation)==null||S.call(e,W.autoRotateSpeed):(R=e.stopRotation)==null||R.call(e));break}case\"SET_METAL\":{_.color&&e&&((F=e.setMetalColor)==null||F.call(e,_.color));break}case\"SET_STONE\":{_.color&&e&&((U=e.setStoneColor)==null||U.call(e,_.color));break}case\"SET_SHAPE\":{_.shape&&e&&(typeof e.switchShape==\"function\"?e.switchShape(_.shape):typeof e.setShape==\"function\"&&e.setShape(_.shape));break}case\"SET_MATERIAL_COLOR\":{_.slotId&&_.color&&e&&((V=e.setMaterialColor)==null||V.call(e,_.slotId,_.color));break}case\"CLEAR_MATERIAL_COLOR\":{_.slotId&&e&&((P=e.clearMaterialColor)==null||P.call(e,_.slotId));break}case\"SET_PART_COLOR\":{_.partId&&_.color&&e&&((z=e.setPartColor)==null||z.call(e,_.partId,_.color,_.slotIndex));break}case\"CLEAR_PART_COLOR\":{_.partId&&e&&((X=e.clearPartColor)==null||X.call(e,_.partId,_.slotIndex));break}case\"SET_AUTO_ROTATE\":{e&&(_.enabled?(re=e.startRotation)==null||re.call(e,_.speed):(J=e.stopRotation)==null||J.call(e));break}case\"SET_DIAMOND_QUALITY\":{_.quality&&e&&((te=e.setDiamondQuality)==null||te.call(e,_.quality));break}case\"FIT_TO_SCENE\":{e&&((Q=e.fitToScene)==null||Q.call(e));break}case\"UNLOAD\":{e&&((ce=e.unload)==null||ce.call(e));break}case\"SET_PART_TYPE\":{_.meshId&&_.partType&&e&&((he=e.setPartType)==null||he.call(e,_.meshId,_.partType));break}case\"GET_PARTS\":{const W=(($=e==null?void 0:e.getParts)==null?void 0:$.call(e))||[];Bt({type:\"PARTS_READY\",reqId:_.reqId,parts:W});break}case\"GET_MATERIALS\":{const W=((ue=e==null?void 0:e.getMaterials)==null?void 0:ue.call(e))||[];Bt({type:\"MATERIALS_READY\",reqId:_.reqId,materials:W});break}case\"SET_QUALITY\":{_.quality&&e&&((Me=e.setQuality)==null||Me.call(e,_.quality));break}case\"SET_METAL_ENVIRONMENT\":{const W=o(_.url);W&&e&&(n=W,a=(xe=e.setMetalEnvironment)==null?void 0:xe.call(e,W).catch(ze=>{console.error(\"[Viewer Runtime] Failed to set metal environment:\",ze)}));break}case\"SET_GEM_ENVIRONMENT\":{const W=o(_.url);W&&e&&(i=W,s=(ge=e.setGemEnvironment)==null?void 0:ge.call(e,W).catch(ze=>{console.error(\"[Viewer Runtime] Failed to set gem environment:\",ze)}));break}case\"RESET_CAMERA\":{c!==null&&(cancelAnimationFrame(c),c=null),e&&((Ge=e.resetCamera)==null||Ge.call(e));break}case\"SET_CAMERA_PRESET\":{_.preset&&u(_.preset);break}case\"SET_CAMERA_POSITION\":{c!==null&&(cancelAnimationFrame(c),c=null),e&&_.position&&_.target&&((Ke=e.setCameraPosition)==null||Ke.call(e,_.position,_.target));break}case\"CLEAR_OVERRIDES\":{e&&((He=e.clearOverrides)==null||He.call(e));break}case\"GET_STATE\":{if(e&&typeof e.getState==\"function\"){const W=e.getState();Bt({type:\"STATE_READY\",reqId:_.reqId,state:W})}break}case\"SET_STATE\":{e&&_.state&&((tt=e.setState)==null||tt.call(e,_.state));break}case\"CAPTURE_SNAPSHOT\":{e&&typeof e.captureSnapshot==\"function\"&&e.captureSnapshot(_.options).then(W=>{Bt({type:\"SNAPSHOT_READY\",reqId:_.reqId,dataUrl:W})}).catch(W=>{Bt({type:\"VIEWER_ERROR\",code:\"SNAPSHOT_FAILED\",message:(W==null?void 0:W.message)||\"Snapshot capture failed\",reqId:_.reqId})});break}case\"EXPORT_AR_PAYLOAD\":{if(_.platform===\"ios\"&&_.usdzUrl){const W=document.getElementById(\"ar-anchor\");W&&(W.setAttribute(\"href\",_.usdzUrl),W.click(),Bt({type:\"AR_PAYLOAD_READY\",reqId:_.reqId,url:_.usdzUrl,launchedInWebView:!0}))}break}}}function v(_){let b;try{b=typeof _.data==\"string\"?JSON.parse(_.data):_.data}catch{return}g(b)}window.addEventListener(\"message\",v),document.addEventListener(\"message\",v),Bt({type:\"VIEWER_READY\"});const m=setInterval(()=>{t?clearInterval(m):Bt({type:\"VIEWER_READY\"})},250)}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",pf):pf();class Gy extends Yn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Li(this.manager);a.setPath(this.path),a.setResponseType(\"arraybuffer\"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){function t(l){const u=new DataView(l),d=32/8*3+32/8*3*3+16/8,h=u.getUint32(80,!0);if(80+32/8+h*d===u.byteLength)return!0;const g=[115,111,108,105,100];for(let v=0;v<5;v++)if(n(g,u,v))return!1;return!0}function n(l,u,d){for(let h=0,f=l.length;h<f;h++)if(l[h]!==u.getUint8(d+h))return!1;return!0}function i(l){const u=new DataView(l),d=u.getUint32(80,!0);let h,f,g,v=!1,m,p,_,b,x;for(let F=0;F<70;F++)u.getUint32(F,!1)==1129270351&&u.getUint8(F+4)==82&&u.getUint8(F+5)==61&&(v=!0,m=new Float32Array(d*3*3),p=u.getUint8(F+6)/255,_=u.getUint8(F+7)/255,b=u.getUint8(F+8)/255,x=u.getUint8(F+9)/255);const E=84,T=12*4+2,A=new mn,I=new Float32Array(d*3*3),S=new Float32Array(d*3*3),R=new Be;for(let F=0;F<d;F++){const U=E+F*T,V=u.getFloat32(U,!0),P=u.getFloat32(U+4,!0),z=u.getFloat32(U+8,!0);if(v){const X=u.getUint16(U+48,!0);X&32768?(h=p,f=_,g=b):(h=(X&31)/31,f=(X>>5&31)/31,g=(X>>10&31)/31)}for(let X=1;X<=3;X++){const re=U+X*12,J=F*3*3+(X-1)*3;I[J]=u.getFloat32(re,!0),I[J+1]=u.getFloat32(re+4,!0),I[J+2]=u.getFloat32(re+8,!0),S[J]=V,S[J+1]=P,S[J+2]=z,v&&(R.set(h,f,g).convertSRGBToLinear(),m[J]=R.r,m[J+1]=R.g,m[J+2]=R.b)}}return A.setAttribute(\"position\",new vt(I,3)),A.setAttribute(\"normal\",new vt(S,3)),v&&(A.setAttribute(\"color\",new vt(m,3)),A.hasColors=!0,A.alpha=x),A}function s(l){const u=new mn,d=/solid([\\s\\S]*?)endsolid/g,h=/facet([\\s\\S]*?)endfacet/g,f=/solid\\s(.+)/;let g=0;const v=/[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)/.source,m=new RegExp(\"vertex\"+v+v+v,\"g\"),p=new RegExp(\"normal\"+v+v+v,\"g\"),_=[],b=[],x=[],E=new O;let T,A=0,I=0,S=0;for(;(T=d.exec(l))!==null;){I=S;const R=T[0],F=(T=f.exec(R))!==null?T[1]:\"\";for(x.push(F);(T=h.exec(R))!==null;){let P=0,z=0;const X=T[0];for(;(T=p.exec(X))!==null;)E.x=parseFloat(T[1]),E.y=parseFloat(T[2]),E.z=parseFloat(T[3]),z++;for(;(T=m.exec(X))!==null;)_.push(parseFloat(T[1]),parseFloat(T[2]),parseFloat(T[3])),b.push(E.x,E.y,E.z),P++,S++;z!==1&&console.error(\"THREE.STLLoader: Something isn't right with the normal of face number \"+g),P!==3&&console.error(\"THREE.STLLoader: Something isn't right with the vertices of face number \"+g),g++}const U=I,V=S-I;u.userData.groupNames=x,u.addGroup(U,V,A),A++}return u.setAttribute(\"position\",new Yt(_,3)),u.setAttribute(\"normal\",new Yt(b,3)),u}function a(l){return typeof l!=\"string\"?new TextDecoder().decode(l):l}function o(l){if(typeof l==\"string\"){const u=new Uint8Array(l.length);for(let d=0;d<l.length;d++)u[d]=l.charCodeAt(d)&255;return u.buffer||u}else return l}const c=o(e);return t(c)?i(c):s(a(e))}}const Hy=Object.freeze(Object.defineProperty({__proto__:null,STLLoader:Gy},Symbol.toStringTag,{value:\"Module\"})),Vy=/^[og]\\s*(.+)?/,Wy=/^mtllib /,jy=/^usemtl /,Xy=/^usemap /,mf=/\\s+/,gf=new O,Rl=new O,bf=new O,_f=new O,zn=new O,go=new Be;function qy(){const r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial==\"function\"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==\"function\"&&this.object._finalize(!0),this.object={name:e||\"\",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(i,s){const a=this._finalize(!1);a&&(a.inherited||a.groupCount<=0)&&this.materials.splice(a.index,1);const o={index:this.materials.length,name:i||\"\",mtllib:Array.isArray(s)&&s.length>0?s[s.length-1]:\"\",smooth:a!==void 0?a.smooth:this.smooth,groupStart:a!==void 0?a.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c==\"number\"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),i&&this.materials.length>1)for(let a=this.materials.length-1;a>=0;a--)this.materials[a].groupCount<=0&&this.materials.splice(a,1);return i&&this.materials.length===0&&this.materials.push({name:\"\",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone==\"function\"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==\"function\"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,s=this.object.geometry.vertices;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,s=this.object.geometry.normals;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,s=this.object.geometry.normals;gf.fromArray(i,e),Rl.fromArray(i,t),bf.fromArray(i,n),zn.subVectors(bf,Rl),_f.subVectors(gf,Rl),zn.cross(_f),zn.normalize(),s.push(zn.x,zn.y,zn.z),s.push(zn.x,zn.y,zn.z),s.push(zn.x,zn.y,zn.z)},addColor:function(e,t,n){const i=this.colors,s=this.object.geometry.colors;i[e]!==void 0&&s.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&s.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&s.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,s=this.object.geometry.uvs;s.push(i[e+0],i[e+1]),s.push(i[t+0],i[t+1]),s.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,s,a,o,c,l){const u=this.vertices.length;let d=this.parseVertexIndex(e,u),h=this.parseVertexIndex(t,u),f=this.parseVertexIndex(n,u);if(this.addVertex(d,h,f),this.addColor(d,h,f),o!==void 0&&o!==\"\"){const g=this.normals.length;d=this.parseNormalIndex(o,g),h=this.parseNormalIndex(c,g),f=this.parseNormalIndex(l,g),this.addNormal(d,h,f)}else this.addFaceNormal(d,h,f);if(i!==void 0&&i!==\"\"){const g=this.uvs.length;d=this.parseUVIndex(i,g),h=this.parseUVIndex(s,g),f=this.parseUVIndex(a,g),this.addUV(d,h,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=\"Points\";const t=this.vertices.length;for(let n=0,i=e.length;n<i;n++){const s=this.parseVertexIndex(e[n],t);this.addVertexPoint(s),this.addColor(s)}},addLineGeometry:function(e,t){this.object.geometry.type=\"Line\";const n=this.vertices.length,i=this.uvs.length;for(let s=0,a=e.length;s<a;s++)this.addVertexLine(this.parseVertexIndex(e[s],n));for(let s=0,a=t.length;s<a;s++)this.addUVLine(this.parseUVIndex(t[s],i))}};return r.startObject(\"\",!1),r}class Yy extends Yn{constructor(e){super(e),this.materials=null}load(e,t,n,i){const s=this,a=new Li(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(o))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new qy;e.indexOf(`\\r\n`)!==-1&&(e=e.replace(/\\r\\n/g,`\n`)),e.indexOf(`\\\\\n`)!==-1&&(e=e.replace(/\\\\\\n/g,\"\"));const n=e.split(`\n`);let i=[];for(let o=0,c=n.length;o<c;o++){const l=n[o].trimStart();if(l.length===0)continue;const u=l.charAt(0);if(u!==\"#\")if(u===\"v\"){const d=l.split(mf);switch(d[0]){case\"v\":t.vertices.push(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3])),d.length>=7?(go.setRGB(parseFloat(d[4]),parseFloat(d[5]),parseFloat(d[6])).convertSRGBToLinear(),t.colors.push(go.r,go.g,go.b)):t.colors.push(void 0,void 0,void 0);break;case\"vn\":t.normals.push(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]));break;case\"vt\":t.uvs.push(parseFloat(d[1]),parseFloat(d[2]));break}}else if(u===\"f\"){const h=l.slice(1).trim().split(mf),f=[];for(let v=0,m=h.length;v<m;v++){const p=h[v];if(p.length>0){const _=p.split(\"/\");f.push(_)}}const g=f[0];for(let v=1,m=f.length-1;v<m;v++){const p=f[v],_=f[v+1];t.addFace(g[0],p[0],_[0],g[1],p[1],_[1],g[2],p[2],_[2])}}else if(u===\"l\"){const d=l.substring(1).trim().split(\" \");let h=[];const f=[];if(l.indexOf(\"/\")===-1)h=d;else for(let g=0,v=d.length;g<v;g++){const m=d[g].split(\"/\");m[0]!==\"\"&&h.push(m[0]),m[1]!==\"\"&&f.push(m[1])}t.addLineGeometry(h,f)}else if(u===\"p\"){const h=l.slice(1).trim().split(\" \");t.addPointGeometry(h)}else if((i=Vy.exec(l))!==null){const d=(\" \"+i[0].slice(1).trim()).slice(1);t.startObject(d)}else if(jy.test(l))t.object.startMaterial(l.substring(7).trim(),t.materialLibraries);else if(Wy.test(l))t.materialLibraries.push(l.substring(7).trim());else if(Xy.test(l))console.warn('THREE.OBJLoader: Rendering identifier \"usemap\" not supported. Textures must be defined in MTL files.');else if(u===\"s\"){if(i=l.split(\" \"),i.length>1){const h=i[1].trim().toLowerCase();t.object.smooth=h!==\"0\"&&h!==\"off\"}else t.object.smooth=!0;const d=t.object.currentMaterial();d&&(d.smooth=t.object.smooth)}else{if(l===\"\\0\")continue;console.warn('THREE.OBJLoader: Unexpected line: \"'+l+'\"')}}t.finalize();const s=new Pt;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o<c;o++){const l=t.objects[o],u=l.geometry,d=l.materials,h=u.type===\"Line\",f=u.type===\"Points\";let g=!1;if(u.vertices.length===0)continue;const v=new mn;v.setAttribute(\"position\",new Yt(u.vertices,3)),u.normals.length>0&&v.setAttribute(\"normal\",new Yt(u.normals,3)),u.colors.length>0&&(g=!0,v.setAttribute(\"color\",new Yt(u.colors,3))),u.hasUVIndices===!0&&v.setAttribute(\"uv\",new Yt(u.uvs,2));const m=[];for(let _=0,b=d.length;_<b;_++){const x=d[_],E=x.name+\"_\"+x.smooth+\"_\"+g;let T=t.materials[E];if(this.materials!==null){if(T=this.materials.create(x.name),h&&T&&!(T instanceof Rs)){const A=new Rs;Rn.prototype.copy.call(A,T),A.color.copy(T.color),T=A}else if(f&&T&&!(T instanceof jr)){const A=new jr({size:10,sizeAttenuation:!1});Rn.prototype.copy.call(A,T),A.color.copy(T.color),A.map=T.map,T=A}}T===void 0&&(h?T=new Rs:f?T=new jr({size:1,sizeAttenuation:!1}):T=new Xd,T.name=x.name,T.flatShading=!x.smooth,T.vertexColors=g,t.materials[E]=T),m.push(T)}let p;if(m.length>1){for(let _=0,b=d.length;_<b;_++){const x=d[_];v.addGroup(x.groupStart,x.groupCount,_)}h?p=new Tc(v,m):f?p=new Na(v,m):p=new We(v,m)}else h?p=new Tc(v,m[0]):f?p=new Na(v,m[0]):p=new We(v,m[0]);p.name=l.name,s.add(p)}else if(t.vertices.length>0){const o=new jr({size:1,sizeAttenuation:!1}),c=new mn;c.setAttribute(\"position\",new Yt(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute(\"color\",new Yt(t.colors,3)),o.vertexColors=!0);const l=new Na(c,o);s.add(l)}return s}}const Ky=Object.freeze(Object.defineProperty({__proto__:null,OBJLoader:Yy},Symbol.toStringTag,{value:\"Module\"}));class Zy extends Yn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=this.path===\"\"?Zr.extractUrlBase(e):this.path,o=new Li(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{t(s.parse(c,a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){const n=e.split(`\n`);let i={};const s=/\\s+/,a={};for(let c=0;c<n.length;c++){let l=n[c];if(l=l.trim(),l.length===0||l.charAt(0)===\"#\")continue;const u=l.indexOf(\" \");let d=u>=0?l.substring(0,u):l;d=d.toLowerCase();let h=u>=0?l.substring(u+1):\"\";if(h=h.trim(),d===\"newmtl\")i={name:h},a[h]=i;else if(d===\"ka\"||d===\"kd\"||d===\"ks\"||d===\"ke\"){const f=h.split(s,3);i[d]=[parseFloat(f[0]),parseFloat(f[1]),parseFloat(f[2])]}else i[d]=h}const o=new $y(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(a),o}}class $y{constructor(e=\"\",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin=\"anonymous\",this.side=this.options.side!==void 0?this.options.side:Mn,this.wrap=this.options.wrap!==void 0?this.options.wrap:Si}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const a in i){let o=!0,c=i[a];const l=a.toLowerCase();switch(l){case\"kd\":case\"ka\":case\"ks\":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,c){return typeof c!=\"string\"||c===\"\"?\"\":/^https?:\\/\\//i.test(c)?c:o+c}function a(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o===\"map\"||o===\"emissiveMap\")&&(u.colorSpace=Mt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!==\"\")switch(o.toLowerCase()){case\"kd\":i.color=new Be().fromArray(c).convertSRGBToLinear();break;case\"ks\":i.specular=new Be().fromArray(c).convertSRGBToLinear();break;case\"ke\":i.emissive=new Be().fromArray(c).convertSRGBToLinear();break;case\"map_kd\":a(\"map\",c);break;case\"map_ks\":a(\"specularMap\",c);break;case\"map_ke\":a(\"emissiveMap\",c);break;case\"norm\":a(\"normalMap\",c);break;case\"map_bump\":case\"bump\":a(\"bumpMap\",c);break;case\"map_d\":a(\"alphaMap\",c),i.transparent=!0;break;case\"ns\":i.shininess=parseFloat(c);break;case\"d\":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case\"tr\":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Xd(i),this.materials[e]}getTextureParams(e,t){const n={scale:new Ve(1,1),offset:new Ve(0,0)},i=e.split(/\\s+/);let s;return s=i.indexOf(\"-bm\"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf(\"-s\"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf(\"-o\"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(\" \").trim(),n}loadTexture(e,t,n,i,s){const a=this.manager!==void 0?this.manager:Zd;let o=a.getHandler(e);o===null&&(o=new Jd(a)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const Jy=Object.freeze(Object.defineProperty({__proto__:null,MTLLoader:Zy},Symbol.toStringTag,{value:\"Module\"}));let Vs,Cl,us,bo;function Pl(r,e=1/0,t=null){Cl||(Cl=new dn(2,2,1,1)),us||(us=new qn({uniforms:{blitTexture:new Uc(r)},vertexShader:`\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}`,fragmentShader:`\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}`})),us.uniforms.blitTexture.value=r,us.defines.IS_SRGB=r.colorSpace==Mt,us.needsUpdate=!0,bo||(bo=new We(Cl,us),bo.frustrumCulled=!1);const n=new un,i=new ir;i.add(bo),t===null&&(t=Vs=new bc({antialias:!1}));const s=Math.min(r.image.width,e),a=Math.min(r.image.height,e);t.setSize(s,a),t.clear(),t.render(i,n);const o=document.createElement(\"canvas\"),c=o.getContext(\"2d\");o.width=s,o.height=a,c.drawImage(t.domElement,0,0,s,a);const l=new jd(o);return l.minFilter=r.minFilter,l.magFilter=r.magFilter,l.wrapS=r.wrapS,l.wrapT=r.wrapT,l.name=r.name,Vs&&(Vs.forceContextLoss(),Vs.dispose(),Vs=null),l}const vf={POSITION:[\"byte\",\"byte normalized\",\"unsigned byte\",\"unsigned byte normalized\",\"short\",\"short normalized\",\"unsigned short\",\"unsigned short normalized\"],NORMAL:[\"byte normalized\",\"short normalized\"],TANGENT:[\"byte normalized\",\"short normalized\"],TEXCOORD:[\"byte\",\"byte normalized\",\"unsigned byte\",\"short\",\"short normalized\",\"unsigned short\"]};class Ll{constructor(){this.pluginCallbacks=[],this.register(function(e){return new cM(e)}),this.register(function(e){return new lM(e)}),this.register(function(e){return new hM(e)}),this.register(function(e){return new fM(e)}),this.register(function(e){return new pM(e)}),this.register(function(e){return new mM(e)}),this.register(function(e){return new uM(e)}),this.register(function(e){return new dM(e)}),this.register(function(e){return new gM(e)}),this.register(function(e){return new bM(e)}),this.register(function(e){return new _M(e)}),this.register(function(e){return new vM(e)}),this.register(function(e){return new xM(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){const s=new oM,a=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)a.push(this.pluginCallbacks[o](s));s.setPlugins(a),s.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,i,s,t)})}}const ht={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Il=\"KHR_mesh_quantization\",Pn={};Pn[yt]=ht.NEAREST,Pn[Ys]=ht.NEAREST_MIPMAP_NEAREST,Pn[fs]=ht.NEAREST_MIPMAP_LINEAR,Pn[At]=ht.LINEAR,Pn[So]=ht.LINEAR_MIPMAP_NEAREST,Pn[si]=ht.LINEAR_MIPMAP_LINEAR,Pn[gn]=ht.CLAMP_TO_EDGE,Pn[Si]=ht.REPEAT,Pn[hs]=ht.MIRRORED_REPEAT;const xf={scale:\"scale\",position:\"translation\",quaternion:\"rotation\",morphTargetInfluences:\"weights\"},Qy=new Be,yf=12,eM=1179937895,tM=2,Mf=8,nM=1313821514,iM=5130562;function Ws(r,e){return r.length===e.length&&r.every(function(t,n){return t===e[n]})}function rM(r){return new TextEncoder().encode(r).buffer}function sM(r){return Ws(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function aM(r,e,t){const n={min:new Array(r.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(r.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+t;i++)for(let s=0;s<r.itemSize;s++){let a;r.itemSize>4?a=r.array[i*r.itemSize+s]:(s===0?a=r.getX(i):s===1?a=r.getY(i):s===2?a=r.getZ(i):s===3&&(a=r.getW(i)),r.normalized===!0&&(a=xr.normalize(a,r.array))),n.min[s]=Math.min(n.min[s],a),n.max[s]=Math.max(n.max[s],a)}return n}function Sf(r){return Math.ceil(r/4)*4}function Dl(r,e=0){const t=Sf(r.byteLength);if(t!==r.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(r)),e!==0)for(let i=r.byteLength;i<t;i++)n[i]=e;return n.buffer}return r}function Ef(){return typeof document>\"u\"&&typeof OffscreenCanvas<\"u\"?new OffscreenCanvas(1,1):document.createElement(\"canvas\")}function Tf(r,e){if(r.toBlob!==void 0)return new Promise(n=>r.toBlob(n,e));let t;return e===\"image/jpeg\"?t=.92:e===\"image/webp\"&&(t=.8),r.convertToBlob({type:e,quality:t})}class oM{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:\"2.0\",generator:\"THREE.GLTFExporter\"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,s=i.buffers,a=i.json;n=i.options;const o=i.extensionsUsed,c=i.extensionsRequired,l=new Blob(s,{type:\"application/octet-stream\"}),u=Object.keys(o),d=Object.keys(c);if(u.length>0&&(a.extensionsUsed=u),d.length>0&&(a.extensionsRequired=d),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=l.size),n.binary===!0){const h=new FileReader;h.readAsArrayBuffer(l),h.onloadend=function(){const f=Dl(h.result),g=new DataView(new ArrayBuffer(Mf));g.setUint32(0,f.byteLength,!0),g.setUint32(4,iM,!0);const v=Dl(rM(JSON.stringify(a)),32),m=new DataView(new ArrayBuffer(Mf));m.setUint32(0,v.byteLength,!0),m.setUint32(4,nM,!0);const p=new ArrayBuffer(yf),_=new DataView(p);_.setUint32(0,eM,!0),_.setUint32(4,tM,!0);const b=yf+m.byteLength+v.byteLength+g.byteLength+f.byteLength;_.setUint32(8,b,!0);const x=new Blob([p,m,v,g,f],{type:\"application/octet-stream\"}),E=new FileReader;E.readAsArrayBuffer(x),E.onloadend=function(){t(E.result)}}}else if(a.buffers&&a.buffers.length>0){const h=new FileReader;h.readAsDataURL(l),h.onloadend=function(){const f=h.result;a.buffers[0].uri=f,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,i=this.extensionsUsed;try{const s=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const a in s.gltfExtensions)t.extensions[a]=s.gltfExtensions[a],i[a]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn(\"THREE.GLTFExporter: userData of '\"+e.name+\"' won't be serialized because of JSON.stringify error - \"+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new O;for(let i=0,s=e.count;i<s;i++)if(Math.abs(n.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),i=new O;for(let s=0,a=n.count;s<a;s++)i.fromBufferAttribute(n,s),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),n.setXYZ(s,i.x,i.y,i.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const i={};(t.offset.x!==0||t.offset.y!==0)&&(i.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(i.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(f){return f.colorSpace===Mt?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}console.warn(\"THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.\"),e instanceof Ac&&(e=Pl(e)),t instanceof Ac&&(t=Pl(t));const i=e?e.image:null,s=t?t.image:null,a=Math.max(i?i.width:0,s?s.width:0),o=Math.max(i?i.height:0,s?s.height:0),c=Ef();c.width=a,c.height=o;const l=c.getContext(\"2d\");l.fillStyle=\"#00ffff\",l.fillRect(0,0,a,o);const u=l.getImageData(0,0,a,o);if(i){l.drawImage(i,0,0,a,o);const f=n(e),g=l.getImageData(0,0,a,o).data;for(let v=2;v<g.length;v+=4)u.data[v]=f(g[v]/256)*256}if(s){l.drawImage(s,0,0,a,o);const f=n(t),g=l.getImageData(0,0,a,o).data;for(let v=1;v<g.length;v+=4)u.data[v]=f(g[v]/256)*256}l.putImageData(u,0,0);const h=(e||t).clone();return h.source=new Ho(c),h.colorSpace=Sn,h.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn(\"THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.\"),h}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,s){const a=this.json;a.bufferViews||(a.bufferViews=[]);let o;switch(t){case ht.BYTE:case ht.UNSIGNED_BYTE:o=1;break;case ht.SHORT:case ht.UNSIGNED_SHORT:o=2;break;default:o=4}const c=Sf(i*e.itemSize*o),l=new DataView(new ArrayBuffer(c));let u=0;for(let f=n;f<n+i;f++)for(let g=0;g<e.itemSize;g++){let v;e.itemSize>4?v=e.array[f*e.itemSize+g]:(g===0?v=e.getX(f):g===1?v=e.getY(f):g===2?v=e.getZ(f):g===3&&(v=e.getW(f)),e.normalized===!0&&(v=xr.normalize(v,e.array))),t===ht.FLOAT?l.setFloat32(u,v,!0):t===ht.INT?l.setInt32(u,v,!0):t===ht.UNSIGNED_INT?l.setUint32(u,v,!0):t===ht.SHORT?l.setInt16(u,v,!0):t===ht.UNSIGNED_SHORT?l.setUint16(u,v,!0):t===ht.BYTE?l.setInt8(u,v):t===ht.UNSIGNED_BYTE&&l.setUint8(u,v),u+=o}const d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:c};return s!==void 0&&(d.target=s),s===ht.ARRAY_BUFFER&&(d.byteStride=e.itemSize*o),this.byteOffset+=c,a.bufferViews.push(d),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(i){const s=new FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){const a=Dl(s.result),o={buffer:t.processBuffer(a),byteOffset:t.byteOffset,byteLength:a.byteLength};t.byteOffset+=a.byteLength,i(n.bufferViews.push(o)-1)}})}processAccessor(e,t,n,i){const s=this.json,a={1:\"SCALAR\",2:\"VEC2\",3:\"VEC3\",4:\"VEC4\",9:\"MAT3\",16:\"MAT4\"};let o;if(e.array.constructor===Float32Array)o=ht.FLOAT;else if(e.array.constructor===Int32Array)o=ht.INT;else if(e.array.constructor===Uint32Array)o=ht.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=ht.SHORT;else if(e.array.constructor===Uint16Array)o=ht.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=ht.BYTE;else if(e.array.constructor===Uint8Array)o=ht.UNSIGNED_BYTE;else throw new Error(\"THREE.GLTFExporter: Unsupported bufferAttribute component type: \"+e.array.constructor.name);if(n===void 0&&(n=0),(i===void 0||i===1/0)&&(i=e.count),i===0)return null;const c=aM(e,n,i);let l;t!==void 0&&(l=e===t.index?ht.ELEMENT_ARRAY_BUFFER:ht.ARRAY_BUFFER);const u=this.processBufferView(e,o,n,i,l),d={bufferView:u.id,byteOffset:u.byteOffset,componentType:o,count:i,max:c.max,min:c.min,type:a[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(d)-1}processImage(e,t,n,i=\"image/png\"){if(e!==null){const s=this,a=s.cache,o=s.json,c=s.options,l=s.pending;a.images.has(e)||a.images.set(e,{});const u=a.images.get(e),d=i+\":flipY/\"+n.toString();if(u[d]!==void 0)return u[d];o.images||(o.images=[]);const h={mimeType:i},f=Ef();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);const g=f.getContext(\"2d\");if(n===!0&&(g.translate(0,f.height),g.scale(1,-1)),e.data!==void 0){t!==kt&&console.error(\"GLTFExporter: Only RGBAFormat is supported.\",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn(\"GLTFExporter: Image size is bigger than maxTextureSize\",e);const m=new Uint8ClampedArray(e.height*e.width*4);for(let p=0;p<m.length;p+=4)m[p+0]=e.data[p+0],m[p+1]=e.data[p+1],m[p+2]=e.data[p+2],m[p+3]=e.data[p+3];g.putImageData(new ImageData(m,e.width,e.height),0,0)}else g.drawImage(e,0,0,f.width,f.height);c.binary===!0?l.push(Tf(f,i).then(m=>s.processBufferViewImage(m)).then(m=>{h.bufferView=m})):f.toDataURL!==void 0?h.uri=f.toDataURL(i):l.push(Tf(f,i).then(m=>new FileReader().readAsDataURL(m)).then(m=>{h.uri=m}));const v=o.images.push(h)-1;return u[d]=v,v}else throw new Error(\"THREE.GLTFExporter: No valid image data found. Unable to process texture.\")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:Pn[e.magFilter],minFilter:Pn[e.minFilter],wrapS:Pn[e.wrapS],wrapT:Pn[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,i=this.cache,s=this.json;if(i.textures.has(e))return i.textures.get(e);s.textures||(s.textures=[]),e instanceof Ac&&(e=Pl(e,n.maxTextureSize));let a=e.userData.mimeType;a===\"image/webp\"&&(a=\"image/png\");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,a)};e.name&&(o.name=e.name),this._invokeAll(function(l){l.writeTexture&&l.writeTexture(e,o)});const c=s.textures.push(o)-1;return i.textures.set(e,c),c}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn(\"GLTFExporter: THREE.ShaderMaterial not supported.\"),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(\"GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.\");const s=e.color.toArray().concat([e.opacity]);if(Ws(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const o=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(o),channel:o.channel};this.applyTextureTransform(c,o),i.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const o={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),i.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),i.emissiveTexture=l}}if(e.normalMap){const o={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),i.normalTexture=o}if(e.aoMap){const o={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),i.occlusionTexture=o}e.transparent?i.alphaMode=\"BLEND\":e.alphaTest>0&&(i.alphaMode=\"MASK\",i.alphaCutoff=e.alphaTest),e.side===wt&&(i.doubleSided=!0),e.name!==\"\"&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(o){o.writeMaterial&&o.writeMaterial(e,i)});const a=n.materials.push(i)-1;return t.materials.set(e,a),a}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,E=e.material.length;x<E;x++)i.push(e.material[x].uuid);else i.push(e.material.uuid);const s=i.join(\":\");if(t.meshes.has(s))return t.meshes.get(s);const a=e.geometry;let o;e.isLineSegments?o=ht.LINES:e.isLineLoop?o=ht.LINE_LOOP:e.isLine?o=ht.LINE_STRIP:e.isPoints?o=ht.POINTS:o=e.material.wireframe?ht.LINES:ht.TRIANGLES;const c={},l={},u=[],d=[],h={uv:\"TEXCOORD_0\",uv1:\"TEXCOORD_1\",uv2:\"TEXCOORD_2\",uv3:\"TEXCOORD_3\",color:\"COLOR_0\",skinWeight:\"WEIGHTS_0\",skinIndex:\"JOINTS_0\"},f=a.getAttribute(\"normal\");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn(\"THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.\"),a.setAttribute(\"normal\",this.createNormalizedNormalAttribute(f)));let g=null;for(let x in a.attributes){if(x.slice(0,5)===\"morph\")continue;const E=a.attributes[x];if(x=h[x]||x.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\\d+|COLOR_\\d+|JOINTS_\\d+|WEIGHTS_\\d+)$/.test(x)||(x=\"_\"+x),t.attributes.has(this.getUID(E))){l[x]=t.attributes.get(this.getUID(E));continue}g=null;const A=E.array;x===\"JOINTS_0\"&&!(A instanceof Uint16Array)&&!(A instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute \"skinIndex\" converted to type UNSIGNED_SHORT.'),g=new vt(new Uint16Array(A),E.itemSize,E.normalized));const I=this.processAccessor(g||E,a);I!==null&&(x.startsWith(\"_\")||this.detectMeshQuantization(x,E),l[x]=I,t.attributes.set(this.getUID(E),I))}if(f!==void 0&&a.setAttribute(\"normal\",f),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const x=[],E=[],T={};if(e.morphTargetDictionary!==void 0)for(const A in e.morphTargetDictionary)T[e.morphTargetDictionary[A]]=A;for(let A=0;A<e.morphTargetInfluences.length;++A){const I={};let S=!1;for(const R in a.morphAttributes){if(R!==\"position\"&&R!==\"normal\"){S||(console.warn(\"GLTFExporter: Only POSITION and NORMAL morph are supported.\"),S=!0);continue}const F=a.morphAttributes[R][A],U=R.toUpperCase(),V=a.attributes[R];if(t.attributes.has(this.getUID(F,!0))){I[U]=t.attributes.get(this.getUID(F,!0));continue}const P=F.clone();if(!a.morphTargetsRelative)for(let z=0,X=F.count;z<X;z++)for(let re=0;re<F.itemSize;re++)re===0&&P.setX(z,F.getX(z)-V.getX(z)),re===1&&P.setY(z,F.getY(z)-V.getY(z)),re===2&&P.setZ(z,F.getZ(z)-V.getZ(z)),re===3&&P.setW(z,F.getW(z)-V.getW(z));I[U]=this.processAccessor(P,a),t.attributes.set(this.getUID(V,!0),I[U])}d.push(I),x.push(e.morphTargetInfluences[A]),e.morphTargetDictionary!==void 0&&E.push(T[A])}c.weights=x,E.length>0&&(c.extras={},c.extras.targetNames=E)}const v=Array.isArray(e.material);if(v&&a.groups.length===0)return null;let m=!1;if(v&&a.index===null){const x=[];for(let E=0,T=a.attributes.position.count;E<T;E++)x[E]=E;a.setIndex(x),m=!0}const p=v?e.material:[e.material],_=v?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,E=_.length;x<E;x++){const T={mode:o,attributes:l};if(this.serializeUserData(a,T),d.length>0&&(T.targets=d),a.index!==null){let I=this.getUID(a.index);(_[x].start!==void 0||_[x].count!==void 0)&&(I+=\":\"+_[x].start+\":\"+_[x].count),t.attributes.has(I)?T.indices=t.attributes.get(I):(T.indices=this.processAccessor(a.index,a,_[x].start,_[x].count),t.attributes.set(I,T.indices)),T.indices===null&&delete T.indices}const A=this.processMaterial(p[_[x].materialIndex]);A!==null&&(T.material=A),u.push(T)}m===!0&&a.setIndex(null),c.primitives=u,n.meshes||(n.meshes=[]),this._invokeAll(function(x){x.writeMesh&&x.writeMesh(e,c)});const b=n.meshes.push(c)-1;return t.meshes.set(s,b),b}detectMeshQuantization(e,t){if(this.extensionsUsed[Il])return;let n;switch(t.array.constructor){case Int8Array:n=\"byte\";break;case Uint8Array:n=\"unsigned byte\";break;case Int16Array:n=\"short\";break;case Uint16Array:n=\"unsigned short\";break;default:return}t.normalized&&(n+=\" normalized\");const i=e.split(\"_\",1)[0];vf[i]&&vf[i].includes(n)&&(this.extensionsUsed[Il]=!0,this.extensionsRequired[Il]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?\"orthographic\":\"perspective\"};return n?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:xr.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==\"\"&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]),e=Ll.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,a=[],o=[];for(let c=0;c<s.length;++c){const l=s[c],u=gt.parseTrackName(l.name);let d=gt.findNode(t,u.nodeName);const h=xf[u.propertyName];if(u.objectName===\"bones\"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(u.objectIndex):d=void 0),!d||!h)return console.warn('THREE.GLTFExporter: Could not export animation track \"%s\".',l.name),null;const f=1;let g=l.values.length/l.times.length;h===xf.morphTargetInfluences&&(g/=d.morphTargetInfluences.length);let v;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(v=\"CUBICSPLINE\",g/=3):l.getInterpolation()===br?v=\"STEP\":v=\"LINEAR\",o.push({input:this.processAccessor(new vt(l.times,f)),output:this.processAccessor(new vt(l.values,g)),interpolation:v}),a.push({sampler:o.length-1,target:{node:i.get(d),path:h}})}return n.animations.push({name:e.name||\"clip_\"+n.animations.length,samplers:o,channels:a}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],s=e.skeleton;if(s===void 0)return null;const a=e.skeleton.bones[0];if(a===void 0)return null;const o=[],c=new Float32Array(s.bones.length*16),l=new qe;for(let d=0;d<s.bones.length;++d)o.push(n.get(s.bones[d])),l.copy(s.boneInverses[d]),l.multiply(e.bindMatrix).toArray(c,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new vt(c,16)),joints:o,skeleton:n.get(a)}),i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const s={};if(n.trs){const o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();Ws(o,[0,0,0,1])||(s.rotation=o),Ws(c,[0,0,0])||(s.translation=c),Ws(l,[1,1,1])||(s.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),sM(e.matrix)===!1&&(s.matrix=e.matrix.elements);if(e.name!==\"\"&&(s.name=String(e.name)),this.serializeUserData(e,s),e.isMesh||e.isLine||e.isPoints){const o=this.processMesh(e);o!==null&&(s.mesh=o)}else e.isCamera&&(s.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const o=[];for(let c=0,l=e.children.length;c<l;c++){const u=e.children[c];if(u.visible||n.onlyVisible===!1){const d=this.processNode(u);d!==null&&o.push(d)}}o.length>0&&(s.children=o)}this._invokeAll(function(o){o.writeNode&&o.writeNode(e,s)});const a=t.nodes.push(s)-1;return i.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==\"\"&&(i.name=e.name),t.scenes.push(i);const s=[];for(let a=0,o=e.children.length;a<o;a++){const c=e.children[a];if(c.visible||n.onlyVisible===!1){const l=this.processNode(c);l!==null&&s.push(l)}}s.length>0&&(i.nodes=s),this.serializeUserData(e,i)}processObjects(e){const t=new ir;t.name=\"AuxScene\";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(i){i.beforeParse&&i.beforeParse(e)});const n=[];for(let i=0;i<e.length;i++)e[i]instanceof ir?this.processScene(e[i]):n.push(e[i]);n.length>0&&this.processObjects(n);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i],e[0]);this._invokeAll(function(i){i.afterParse&&i.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class cM{constructor(e){this.writer=e,this.name=\"KHR_lights_punctual\"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(\"THREE.GLTFExporter: Only directional, point, and spot lights are supported.\",e);return}const n=this.writer,i=n.json,s=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=\"directional\":e.isPointLight?(a.type=\"point\",e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=\"spot\",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(\"THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.\"),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(\"THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.\"),s[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},s[this.name]=!0);const o=i.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class lM{constructor(e){this.writer=e,this.name=\"KHR_materials_unlit\"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class uM{constructor(e){this.writer=e,this.name=\"KHR_materials_clearcoat\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,i=n.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){const a={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(a,e.clearcoatMap),s.clearcoatTexture=a}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const a={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(a,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=a}if(e.clearcoatNormalMap){const a={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(a,e.clearcoatNormalMap),s.clearcoatNormalTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class dM{constructor(e){this.writer=e,this.name=\"KHR_materials_iridescence\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,i=n.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){const a={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(a,e.iridescenceMap),s.iridescenceTexture=a}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],s.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const a={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(a,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class hM{constructor(e){this.writer=e,this.name=\"KHR_materials_transmission\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,i=n.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){const a={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(a,e.transmissionMap),s.transmissionTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class fM{constructor(e){this.writer=e,this.name=\"KHR_materials_volume\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,i=n.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){const a={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(a,e.thicknessMap),s.thicknessTexture=a}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class pM{constructor(e){this.writer=e,this.name=\"KHR_materials_ior\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const i=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class mM{constructor(e){this.writer=e,this.name=\"KHR_materials_specular\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Qy)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,s={};if(e.specularIntensityMap){const a={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(a,e.specularIntensityMap),s.specularTexture=a}if(e.specularColorMap){const a={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(a,e.specularColorMap),s.specularColorTexture=a}s.specularFactor=e.specularIntensity,s.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class gM{constructor(e){this.writer=e,this.name=\"KHR_materials_sheen\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,i=n.extensionsUsed,s={};if(e.sheenRoughnessMap){const a={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(a,e.sheenRoughnessMap),s.sheenRoughnessTexture=a}if(e.sheenColorMap){const a={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(a,e.sheenColorMap),s.sheenColorTexture=a}s.sheenRoughnessFactor=e.sheenRoughness,s.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class bM{constructor(e){this.writer=e,this.name=\"KHR_materials_anisotropy\"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,i=n.extensionsUsed,s={};if(e.anisotropyMap){const a={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(a,e.anisotropyMap),s.anisotropyTexture=a}s.anisotropyStrength=e.anisotropy,s.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class _M{constructor(e){this.writer=e,this.name=\"KHR_materials_emissive_strength\"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const i=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class vM{constructor(e){this.writer=e,this.name=\"EXT_materials_bump\"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,i=n.extensionsUsed,s={};if(e.bumpMap){const a={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(a,e.bumpMap),s.bumpTexture=a}s.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}}class xM{constructor(e){this.writer=e,this.name=\"EXT_mesh_gpu_instancing\"}writeNode(e,t){if(!e.isInstancedMesh)return;const n=this.writer,i=e,s=new Float32Array(i.count*3),a=new Float32Array(i.count*4),o=new Float32Array(i.count*3),c=new qe,l=new O,u=new Dn,d=new O;for(let f=0;f<i.count;f++)i.getMatrixAt(f,c),c.decompose(l,u,d),l.toArray(s,f*3),u.toArray(a,f*4),d.toArray(o,f*3);const h={TRANSLATION:n.processAccessor(new vt(s,3)),ROTATION:n.processAccessor(new vt(a,4)),SCALE:n.processAccessor(new vt(o,3))};i.instanceColor&&(h._COLOR_0=n.processAccessor(i.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:h},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}}Ll.Utils={insertKeyframe:function(r,e){const n=r.getValueSize(),i=new r.TimeBufferType(r.times.length+1),s=new r.ValueBufferType(r.values.length+n),a=r.createInterpolant(new r.ValueBufferType(n));let o;if(r.times.length===0){i[0]=e;for(let c=0;c<n;c++)s[c]=0;o=0}else if(e<r.times[0]){if(Math.abs(r.times[0]-e)<.001)return 0;i[0]=e,i.set(r.times,1),s.set(a.evaluate(e),0),s.set(r.values,n),o=0}else if(e>r.times[r.times.length-1]){if(Math.abs(r.times[r.times.length-1]-e)<.001)return r.times.length-1;i[i.length-1]=e,i.set(r.times,0),s.set(r.values,0),s.set(a.evaluate(e),r.values.length),o=i.length-1}else for(let c=0;c<r.times.length;c++){if(Math.abs(r.times[c]-e)<.001)return c;if(r.times[c]<e&&r.times[c+1]>e){i.set(r.times.slice(0,c+1),0),i[c+1]=e,i.set(r.times.slice(c+1),c+2),s.set(r.values.slice(0,(c+1)*n),0),s.set(a.evaluate(e),(c+1)*n),s.set(r.values.slice((c+1)*n),(c+2)*n),o=c+1;break}}return r.times=i,r.values=s,o},mergeMorphTargetTracks:function(r,e){const t=[],n={},i=r.tracks;for(let s=0;s<i.length;++s){let a=i[s];const o=gt.parseTrackName(a.name),c=gt.findNode(e,o.nodeName);if(o.propertyName!==\"morphTargetInfluences\"||o.propertyIndex===void 0){t.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error(\"THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.\");console.warn(\"THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.\"),a=a.clone(),a.setInterpolation(Xi)}const l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[o.propertyIndex];if(u===void 0)throw new Error(\"THREE.GLTFExporter: Morph target name not found: \"+o.propertyIndex);let d;if(n[c.uuid]===void 0){d=a.clone();const f=new d.ValueBufferType(l*d.times.length);for(let g=0;g<d.times.length;g++)f[g*l+u]=d.values[g];d.name=(o.nodeName||\"\")+\".morphTargetInfluences\",d.values=f,n[c.uuid]=d,t.push(d);continue}const h=a.createInterpolant(new a.ValueBufferType(1));d=n[c.uuid];for(let f=0;f<d.times.length;f++)d.values[f*l+u]=h.evaluate(d.times[f]);for(let f=0;f<a.times.length;f++){const g=this.insertKeyframe(d,a.times[f]);d.values[g*l+u]=a.values[f]}}return r.tracks=t,r}};const yM=Object.freeze(Object.defineProperty({__proto__:null,GLTFExporter:Ll},Symbol.toStringTag,{value:\"Module\"}))})();\n\n </script>\n</body>\n</html>";
3
+ //# sourceMappingURL=runtime-bundle.js.map