diff --git "a/bundle/App-Brc9n012.js" "b/bundle/App-Brc9n012.js" new file mode 100644--- /dev/null +++ "b/bundle/App-Brc9n012.js" @@ -0,0 +1,4106 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["bundle/mujoco-C26UsmAO.js","bundle/rolldown-runtime-Dd_uD5pT.js","bundle/index-B9vMHx-X.js","bundle/jsx-runtime-BpzPEenQ.js","bundle/ort.wasm.bundle.min-DQoiApJc.js"])))=>i.map(i=>d[i]); +import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{n as r,t as i}from"./jsx-runtime-BpzPEenQ.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,y as w}from"./index-B9vMHx-X.js";import{_ as T,a as E,b as D,c as O,d as k,f as ee,g as te,h as ne,i as A,l as j,m as re,n as ie,o as ae,p as oe,r as se,s as M,t as ce,u as le,v as N,y as ue}from"./audio-Dg-eNv2r.js";var P=e=>e,de=(()=>{let e=P;return{configure(t){e=t},generate(t){return e(t)},reset(){e=P}}})(),F=e(r(),1),I=i();function L(e={}){let{themeId:t,defaultTheme:n,defaultClassName:r=`MuiBox-root`,generateClassName:i}=e,o=a(`div`,{shouldForwardProp:e=>e!==`theme`&&e!==`sx`&&e!==`as`})(l);return F.forwardRef(function(e,a){let s=m(n),{className:l,component:u=`div`,...d}=e;return(0,I.jsx)(o,{as:u,ref:a,className:c(l,i?i(r):r),theme:t&&s[t]||s,...d})})}var fe={active:`active`,checked:`checked`,completed:`completed`,disabled:`disabled`,error:`error`,expanded:`expanded`,focused:`focused`,focusVisible:`focusVisible`,open:`open`,readOnly:`readOnly`,required:`required`,selected:`selected`};function R(e,t,n=`Mui`){let r=fe[t];return r?`${n}-${r}`:`${de.generate(e)}-${t}`}function pe(e,t,n=`Mui`){let r={};return t.forEach(t=>{r[t]=R(e,t,n)}),r}function me(e){let{variants:t,...n}=e,r={variants:t,style:d(n),isProcessed:!0};return r.style===n||t&&t.forEach(e=>{typeof e.style!=`function`&&(e.style=d(e.style))}),r}var he=S();function ge(e){return e!==`ownerState`&&e!==`theme`&&e!==`sx`&&e!==`as`}function _e(e,t){return t&&e&&typeof e==`object`&&e.styles&&!e.styles.startsWith(`@layer`)&&(e.styles=`@layer ${t}{${String(e.styles)}}`),e}function ve(e){return e?(t,n)=>n[e]:null}function ye(e,t,n){e.theme=v(e.theme)?n:e.theme[t]||e.theme}function z(e,t,n){let r=typeof t==`function`?t(e):t;if(Array.isArray(r))return r.flatMap(t=>z(e,t,n));if(Array.isArray(r?.variants)){let t;if(r.isProcessed)t=n?_e(r.style,n):r.style;else{let{variants:e,...i}=r;t=n?_e(d(i),n):i}return be(e,r.variants,[t],n)}return r?.isProcessed?n?_e(d(r.style),n):r.style:n?_e(d(r),n):r}function be(e,t,n=[],r=void 0){let i;variantLoop:for(let a=0;a{f(e,e=>e.filter(e=>e!==l));let{name:n,slot:s,skipVariantsResolver:c,skipSx:u,overridesResolver:d=ve(Ce(s)),...p}=t,m=n&&n.startsWith(`Mui`)||s?`components`:`custom`,g=c===void 0?s&&s!==`Root`&&s!==`root`||!1:c,_=u||!1,v=ge;s===`Root`||s===`root`?v=r:s?v=i:Se(e)&&(v=void 0);let y=a(e,{shouldForwardProp:v,label:void 0,...p}),b=e=>{if(e.__emotion_real===e)return e;if(typeof e==`function`)return function(t){return z(t,e,t.theme.modularCssLayers?m:void 0)};if(h(e)){let t=me(e);return function(e){return t.variants?z(e,t,e.theme.modularCssLayers?m:void 0):e.theme.modularCssLayers?_e(t.style,m):t.style}}return e},x=(...t)=>{let r=[],i=t.map(b),a=[];if(r.push(o),n&&d&&a.push(function(e){let t=e.theme.components?.[n]?.styleOverrides;if(!t)return null;let r={};for(let n in t)r[n]=z(e,t[n],e.theme.modularCssLayers?`theme`:void 0);return d(e,r)}),n&&!g&&a.push(function(e){let t=e.theme?.components?.[n]?.variants;return t?be(e,t,[],e.theme.modularCssLayers?`theme`:void 0):null}),_||a.push(l),Array.isArray(i[0])){let e=i.shift(),t=Array(r.length).fill(``),n=Array(a.length).fill(``),o;o=[...t,...e,...n],o.raw=[...t,...e.raw,...n],r.unshift(o)}let s=[...r,...i,...a],c=y(...s);return e.muiName&&(c.muiName=e.muiName),c};return y.withConfig&&(x.withConfig=y.withConfig),x}}function Se(e){return typeof e==`string`&&e.charCodeAt(0)>96}function Ce(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}var we={theme:void 0};function Te(e){let t,n;return function(r){let i=t;return(i===void 0||r.theme!==n)&&(we.theme=r.theme,i=me(e(we)),t=i,n=r.theme),i}}function Ee(e,t,n=void 0){let r={};for(let i in e){let a=e[i],o=``,s=!0;for(let e=0;eDe(e)&&e!==`classes`}),ke=Te,Ae=u,je=t({ACESFilmicToneMapping:()=>4,AddEquation:()=>100,AddOperation:()=>2,AdditiveAnimationBlendMode:()=>sn,AdditiveBlending:()=>2,AgXToneMapping:()=>6,AlphaFormat:()=>ot,AlwaysCompare:()=>519,AlwaysDepth:()=>1,AlwaysStencilFunc:()=>519,AmbientLight:()=>am,AnimationAction:()=>$m,AnimationClip:()=>Op,AnimationLoader:()=>Rp,AnimationMixer:()=>th,AnimationObjectGroup:()=>Qm,AnimationUtils:()=>hp,ArcCurve:()=>md,ArrayCamera:()=>ml,ArrowHelper:()=>qh,AttachedBindMode:()=>Pe,Audio:()=>Mm,AudioAnalyser:()=>Rm,AudioContext:()=>ym,AudioListener:()=>jm,AudioLoader:()=>bm,AxesHelper:()=>Jh,BackSide:()=>1,BasicDepthPacking:()=>cn,BasicShadowMap:()=>0,BatchedMesh:()=>Ru,Bone:()=>cu,BooleanKeyframeTrack:()=>xp,Box2:()=>mh,Box3:()=>Hr,Box3Helper:()=>Hh,BoxGeometry:()=>qa,BoxHelper:()=>Vh,BufferAttribute:()=>K,BufferGeometry:()=>Y,BufferGeometryLoader:()=>fm,ByteType:()=>Ye,Cache:()=>jp,Camera:()=>no,CameraHelper:()=>Rh,CanvasTexture:()=>dd,CapsuleGeometry:()=>Hd,CatmullRomCurve3:()=>bd,CineonToneMapping:()=>3,CircleGeometry:()=>Ud,ClampToEdgeWrapping:()=>Le,Clock:()=>Tm,Color:()=>G,ColorKeyframeTrack:()=>Sp,ColorManagement:()=>Sr,CompressedArrayTexture:()=>ld,CompressedCubeTexture:()=>ud,CompressedTexture:()=>cd,CompressedTextureLoader:()=>zp,ConeGeometry:()=>Gd,ConstantAlphaFactor:()=>213,ConstantColorFactor:()=>211,CubeCamera:()=>lo,CubeReflectionMapping:()=>301,CubeRefractionMapping:()=>302,CubeTexture:()=>uo,CubeTextureLoader:()=>Vp,CubeUVReflectionMapping:()=>306,CubicBezierCurve:()=>jd,CubicBezierCurve3:()=>Md,CubicInterpolant:()=>_p,CullFaceBack:()=>1,CullFaceFront:()=>2,CullFaceFrontBack:()=>3,CullFaceNone:()=>0,Curve:()=>fd,CurvePath:()=>zd,CustomBlending:()=>5,CustomToneMapping:()=>5,CylinderGeometry:()=>Wd,Cylindrical:()=>fh,Data3DTexture:()=>Lr,DataArrayTexture:()=>Fr,DataTexture:()=>lu,DataTextureLoader:()=>Hp,DataUtils:()=>da,DecrementStencilOp:()=>yn,DecrementWrapStencilOp:()=>xn,DefaultLoadingManager:()=>Np,DepthFormat:()=>dt,DepthStencilFormat:()=>ft,DepthTexture:()=>cs,DetachedBindMode:()=>Fe,DirectionalLight:()=>im,DirectionalLightHelper:()=>Fh,DiscreteInterpolant:()=>yp,DisplayP3ColorSpace:()=>dn,DodecahedronGeometry:()=>qd,DoubleSide:()=>2,DstAlphaFactor:()=>206,DstColorFactor:()=>208,DynamicCopyUsage:()=>An,DynamicDrawUsage:()=>wn,DynamicReadUsage:()=>Dn,EdgesGeometry:()=>Qd,EllipseCurve:()=>pd,EqualCompare:()=>514,EqualDepth:()=>4,EqualStencilFunc:()=>514,EquirectangularReflectionMapping:()=>303,EquirectangularRefractionMapping:()=>304,Euler:()=>wi,EventDispatcher:()=>Fn,ExtrudeGeometry:()=>If,FileLoader:()=>Lp,Float16BufferAttribute:()=>xa,Float32BufferAttribute:()=>q,FloatType:()=>et,Fog:()=>Ol,FogExp2:()=>Dl,FramebufferTexture:()=>sd,FrontSide:()=>0,Frustum:()=>yo,GLBufferAttribute:()=>oh,GLSL1:()=>`100`,GLSL3:()=>Mn,GreaterCompare:()=>516,GreaterDepth:()=>6,GreaterEqualCompare:()=>518,GreaterEqualDepth:()=>5,GreaterEqualStencilFunc:()=>518,GreaterStencilFunc:()=>516,GridHelper:()=>Ah,Group:()=>hl,HalfFloatType:()=>tt,HemisphereLight:()=>Gp,HemisphereLightHelper:()=>kh,IcosahedronGeometry:()=>zf,ImageBitmapLoader:()=>_m,ImageLoader:()=>Bp,ImageUtils:()=>Er,IncrementStencilOp:()=>vn,IncrementWrapStencilOp:()=>bn,InstancedBufferAttribute:()=>pu,InstancedBufferGeometry:()=>dm,InstancedInterleavedBuffer:()=>ah,InstancedMesh:()=>xu,Int16BufferAttribute:()=>_a,Int32BufferAttribute:()=>ya,Int8BufferAttribute:()=>ma,IntType:()=>Qe,InterleavedBuffer:()=>Al,InterleavedBufferAttribute:()=>Ml,Interpolant:()=>gp,InterpolateDiscrete:()=>$t,InterpolateLinear:()=>en,InterpolateSmooth:()=>tn,InvertStencilOp:()=>Sn,KeepStencilOp:()=>gn,KeyframeTrack:()=>bp,LOD:()=>Zl,LatheGeometry:()=>Vd,Layers:()=>Ti,LessCompare:()=>513,LessDepth:()=>2,LessEqualCompare:()=>515,LessEqualDepth:()=>3,LessEqualStencilFunc:()=>515,LessStencilFunc:()=>513,Light:()=>Wp,LightProbe:()=>cm,Line:()=>qu,Line3:()=>_h,LineBasicMaterial:()=>zu,LineCurve:()=>Nd,LineCurve3:()=>Pd,LineDashedMaterial:()=>sp,LineLoop:()=>Qu,LineSegments:()=>Zu,LinearDisplayP3ColorSpace:()=>fn,LinearFilter:()=>Ue,LinearInterpolant:()=>vp,LinearMipMapLinearFilter:()=>qe,LinearMipMapNearestFilter:()=>Ge,LinearMipmapLinearFilter:()=>Ke,LinearMipmapNearestFilter:()=>We,LinearSRGBColorSpace:()=>V,LinearToneMapping:()=>1,LinearTransfer:()=>pn,Loader:()=>Pp,LoaderUtils:()=>um,LoadingManager:()=>Mp,LoopOnce:()=>Xt,LoopPingPong:()=>Qt,LoopRepeat:()=>Zt,LuminanceAlphaFormat:()=>ut,LuminanceFormat:()=>lt,MOUSE:()=>Me,Material:()=>aa,MaterialLoader:()=>lm,MathUtils:()=>cr,Matrix3:()=>lr,Matrix4:()=>W,MaxEquation:()=>104,Mesh:()=>Wa,MeshBasicMaterial:()=>oa,MeshDepthMaterial:()=>ol,MeshDistanceMaterial:()=>sl,MeshLambertMaterial:()=>ap,MeshMatcapMaterial:()=>op,MeshNormalMaterial:()=>ip,MeshPhongMaterial:()=>np,MeshPhysicalMaterial:()=>tp,MeshStandardMaterial:()=>ep,MeshToonMaterial:()=>rp,MinEquation:()=>103,MirroredRepeatWrapping:()=>Re,MixOperation:()=>1,MultiplyBlending:()=>4,MultiplyOperation:()=>0,NearestFilter:()=>ze,NearestMipMapLinearFilter:()=>He,NearestMipMapNearestFilter:()=>Be,NearestMipmapLinearFilter:()=>Ve,NearestMipmapNearestFilter:()=>B,NeutralToneMapping:()=>7,NeverCompare:()=>512,NeverDepth:()=>0,NeverStencilFunc:()=>512,NoBlending:()=>0,NoColorSpace:()=>``,NoToneMapping:()=>0,NormalAnimationBlendMode:()=>on,NormalBlending:()=>1,NotEqualCompare:()=>517,NotEqualDepth:()=>7,NotEqualStencilFunc:()=>517,NumberKeyframeTrack:()=>Cp,Object3D:()=>Vi,ObjectLoader:()=>pm,ObjectSpaceNormalMap:()=>1,OctahedronGeometry:()=>Bf,OneFactor:()=>201,OneMinusConstantAlphaFactor:()=>214,OneMinusConstantColorFactor:()=>212,OneMinusDstAlphaFactor:()=>207,OneMinusDstColorFactor:()=>209,OneMinusSrcAlphaFactor:()=>205,OneMinusSrcColorFactor:()=>203,OrthographicCamera:()=>Po,P3Primaries:()=>`p3`,PCFShadowMap:()=>1,PCFSoftShadowMap:()=>2,PMREMGenerator:()=>qo,Path:()=>Bd,PerspectiveCamera:()=>oo,Plane:()=>go,PlaneGeometry:()=>So,PlaneHelper:()=>Uh,PointLight:()=>nm,PointLightHelper:()=>Th,Points:()=>id,PointsMaterial:()=>$u,PolarGridHelper:()=>jh,PolyhedronGeometry:()=>Kd,PositionalAudio:()=>Lm,PropertyBinding:()=>Zm,PropertyMixer:()=>zm,QuadraticBezierCurve:()=>Fd,QuadraticBezierCurve3:()=>Id,Quaternion:()=>zr,QuaternionKeyframeTrack:()=>Tp,QuaternionLinearInterpolant:()=>wp,RED_GREEN_RGTC2_Format:()=>Jt,RED_RGTC1_Format:()=>Kt,REVISION:()=>`164`,RGBADepthPacking:()=>ln,RGBAFormat:()=>ct,RGBAIntegerFormat:()=>_t,RGBA_ASTC_10x10_Format:()=>Bt,RGBA_ASTC_10x5_Format:()=>Lt,RGBA_ASTC_10x6_Format:()=>Rt,RGBA_ASTC_10x8_Format:()=>zt,RGBA_ASTC_12x10_Format:()=>Vt,RGBA_ASTC_12x12_Format:()=>Ht,RGBA_ASTC_4x4_Format:()=>kt,RGBA_ASTC_5x4_Format:()=>At,RGBA_ASTC_5x5_Format:()=>jt,RGBA_ASTC_6x5_Format:()=>Mt,RGBA_ASTC_6x6_Format:()=>Nt,RGBA_ASTC_8x5_Format:()=>Pt,RGBA_ASTC_8x6_Format:()=>Ft,RGBA_ASTC_8x8_Format:()=>It,RGBA_BPTC_Format:()=>Ut,RGBA_ETC2_EAC_Format:()=>Ot,RGBA_PVRTC_2BPPV1_Format:()=>Tt,RGBA_PVRTC_4BPPV1_Format:()=>wt,RGBA_S3TC_DXT1_Format:()=>yt,RGBA_S3TC_DXT3_Format:()=>bt,RGBA_S3TC_DXT5_Format:()=>xt,RGBFormat:()=>st,RGB_BPTC_SIGNED_Format:()=>Wt,RGB_BPTC_UNSIGNED_Format:()=>Gt,RGB_ETC1_Format:()=>Et,RGB_ETC2_Format:()=>Dt,RGB_PVRTC_2BPPV1_Format:()=>Ct,RGB_PVRTC_4BPPV1_Format:()=>St,RGB_S3TC_DXT1_Format:()=>vt,RGFormat:()=>ht,RGIntegerFormat:()=>gt,RawShaderMaterial:()=>$f,Ray:()=>mi,Raycaster:()=>ch,Rec709Primaries:()=>hn,RectAreaLight:()=>om,RedFormat:()=>pt,RedIntegerFormat:()=>mt,ReinhardToneMapping:()=>2,RenderTarget:()=>Nr,RepeatWrapping:()=>Ie,ReplaceStencilOp:()=>_n,ReverseSubtractEquation:()=>102,RingGeometry:()=>Vf,SIGNED_RED_GREEN_RGTC2_Format:()=>Yt,SIGNED_RED_RGTC1_Format:()=>qt,SRGBColorSpace:()=>un,SRGBTransfer:()=>mn,Scene:()=>kl,ShaderChunk:()=>Co,ShaderLib:()=>wo,ShaderMaterial:()=>to,ShadowMaterial:()=>Qf,Shape:()=>$d,ShapeGeometry:()=>Hf,ShapePath:()=>Yh,ShapeUtils:()=>Nf,ShortType:()=>Xe,Skeleton:()=>fu,SkeletonHelper:()=>Ch,SkinnedMesh:()=>su,Source:()=>Or,Sphere:()=>oi,SphereGeometry:()=>Wf,Spherical:()=>dh,SphericalHarmonics3:()=>sm,SplineCurve:()=>Ld,SpotLight:()=>Zp,SpotLightHelper:()=>yh,Sprite:()=>ql,SpriteMaterial:()=>Nl,SrcAlphaFactor:()=>204,SrcAlphaSaturateFactor:()=>210,SrcColorFactor:()=>202,StaticCopyUsage:()=>kn,StaticDrawUsage:()=>Cn,StaticReadUsage:()=>En,StereoCamera:()=>wm,StreamCopyUsage:()=>jn,StreamDrawUsage:()=>Tn,StreamReadUsage:()=>On,StringKeyframeTrack:()=>Ep,SubtractEquation:()=>101,SubtractiveBlending:()=>3,TOUCH:()=>Ne,TangentSpaceNormalMap:()=>0,TetrahedronGeometry:()=>Gf,Texture:()=>jr,TextureLoader:()=>Up,TorusGeometry:()=>Kf,TorusKnotGeometry:()=>qf,Triangle:()=>Qi,TriangleFanDrawMode:()=>2,TriangleStripDrawMode:()=>1,TrianglesDrawMode:()=>0,TubeGeometry:()=>Jf,UVMapping:()=>300,Uint16BufferAttribute:()=>va,Uint32BufferAttribute:()=>ba,Uint8BufferAttribute:()=>ha,Uint8ClampedBufferAttribute:()=>ga,Uniform:()=>nh,UniformsGroup:()=>ih,UniformsLib:()=>Z,UniformsUtils:()=>Qa,UnsignedByteType:()=>Je,UnsignedInt248Type:()=>it,UnsignedInt5999Type:()=>at,UnsignedIntType:()=>$e,UnsignedShort4444Type:()=>nt,UnsignedShort5551Type:()=>rt,UnsignedShortType:()=>Ze,VSMShadowMap:()=>3,Vector2:()=>H,Vector3:()=>U,Vector4:()=>Mr,VectorKeyframeTrack:()=>Dp,VideoTexture:()=>od,WebGL3DRenderTarget:()=>Rr,WebGLArrayRenderTarget:()=>Ir,WebGLCoordinateSystem:()=>Nn,WebGLCubeRenderTarget:()=>fo,WebGLMultipleRenderTargets:()=>Xh,WebGLRenderTarget:()=>Pr,WebGLRenderer:()=>El,WebGLUtils:()=>pl,WebGPUCoordinateSystem:()=>Pn,WireframeGeometry:()=>Yf,WrapAroundEnding:()=>an,ZeroCurvatureEnding:()=>nn,ZeroFactor:()=>200,ZeroSlopeEnding:()=>rn,ZeroStencilOp:()=>0,createCanvasElement:()=>hr}),Me={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ne={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Pe=`attached`,Fe=`detached`,Ie=1e3,Le=1001,Re=1002,ze=1003,B=1004,Be=1004,Ve=1005,He=1005,Ue=1006,We=1007,Ge=1007,Ke=1008,qe=1008,Je=1009,Ye=1010,Xe=1011,Ze=1012,Qe=1013,$e=1014,et=1015,tt=1016,nt=1017,rt=1018,it=1020,at=35902,ot=1021,st=1022,ct=1023,lt=1024,ut=1025,dt=1026,ft=1027,pt=1028,mt=1029,ht=1030,gt=1031,_t=1033,vt=33776,yt=33777,bt=33778,xt=33779,St=35840,Ct=35841,wt=35842,Tt=35843,Et=36196,Dt=37492,Ot=37496,kt=37808,At=37809,jt=37810,Mt=37811,Nt=37812,Pt=37813,Ft=37814,It=37815,Lt=37816,Rt=37817,zt=37818,Bt=37819,Vt=37820,Ht=37821,Ut=36492,Wt=36494,Gt=36495,Kt=36283,qt=36284,Jt=36285,Yt=36286,Xt=2200,Zt=2201,Qt=2202,$t=2300,en=2301,tn=2302,nn=2400,rn=2401,an=2402,on=2500,sn=2501,cn=3200,ln=3201,un=`srgb`,V=`srgb-linear`,dn=`display-p3`,fn=`display-p3-linear`,pn=`linear`,mn=`srgb`,hn=`rec709`,gn=7680,_n=7681,vn=7682,yn=7683,bn=34055,xn=34056,Sn=5386,Cn=35044,wn=35048,Tn=35040,En=35045,Dn=35049,On=35041,kn=35046,An=35050,jn=35042,Mn=`300 es`,Nn=2e3,Pn=2001,Fn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t>8&255]+In[e>>16&255]+In[e>>24&255]+`-`+In[t&255]+In[t>>8&255]+`-`+In[t>>16&15|64]+In[t>>24&255]+`-`+In[n&63|128]+In[n>>8&255]+`-`+In[n>>16&255]+In[n>>24&255]+In[r&255]+In[r>>8&255]+In[r>>16&255]+In[r>>24&255]).toLowerCase()}function Vn(e,t,n){return Math.max(t,Math.min(n,e))}function Hn(e,t){return(e%t+t)%t}function Un(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Wn(e,t,n){return e===t?0:(n-e)/(t-e)}function Gn(e,t,n){return(1-n)*e+n*t}function Kn(e,t,n,r){return Gn(e,t,1-Math.exp(-n*r))}function qn(e,t=1){return t-Math.abs(Hn(e,t*2)-t)}function Jn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Yn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Xn(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Zn(e,t){return e+Math.random()*(t-e)}function Qn(e){return e*(.5-Math.random())}function $n(e){e!==void 0&&(Ln=e);let t=Ln+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function er(e){return e*Rn}function tr(e){return e*zn}function nr(e){return!(e&e-1)&&e!==0}function rr(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function ir(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function ar(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function or(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function sr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var cr={DEG2RAD:Rn,RAD2DEG:zn,generateUUID:Bn,clamp:Vn,euclideanModulo:Hn,mapLinear:Un,inverseLerp:Wn,lerp:Gn,damp:Kn,pingpong:qn,smoothstep:Jn,smootherstep:Yn,randInt:Xn,randFloat:Zn,randFloatSpread:Qn,seededRandom:$n,degToRad:er,radToDeg:tr,isPowerOfTwo:nr,ceilPowerOfTwo:rr,floorPowerOfTwo:ir,setQuaternionFromProperEuler:ar,normalize:sr,denormalize:or},H=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}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 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 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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=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){let 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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Vn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},lr=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ur.makeScale(e,t)),this}rotate(e){return this.premultiply(ur.makeRotation(-e)),this}translate(e,t){return this.premultiply(ur.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ur=new lr;function dr(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var fr={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function pr(e,t){return new fr[e](t)}function mr(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function hr(){let e=mr(`canvas`);return e.style.display=`block`,e}var gr={};function _r(e){e in gr||(gr[e]=!0,console.warn(e))}var vr=new lr().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),yr=new lr().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),br={[V]:{transfer:pn,primaries:hn,toReference:e=>e,fromReference:e=>e},[un]:{transfer:mn,primaries:hn,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[fn]:{transfer:pn,primaries:`p3`,toReference:e=>e.applyMatrix3(yr),fromReference:e=>e.applyMatrix3(vr)},[dn]:{transfer:mn,primaries:`p3`,toReference:e=>e.convertSRGBToLinear().applyMatrix3(yr),fromReference:e=>e.applyMatrix3(vr).convertLinearToSRGB()}},xr=new Set([V,fn]),Sr={enabled:!0,_workingColorSpace:V,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!xr.has(e))throw Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(this.enabled===!1||t===n||!t||!n)return e;let r=br[t].toReference,i=br[n].fromReference;return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return br[e].primaries},getTransfer:function(e){return e===``?pn:br[e].transfer}};function Cr(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function wr(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Tr,Er=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Tr===void 0&&(Tr=mr(`canvas`)),Tr.width=e.width,Tr.height=e.height;let n=Tr.getContext(`2d`);e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Tr}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){let t=mr(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ie:e.x-=Math.floor(e.x);break;case Le:e.x=e.x<0?0:1;break;case Re:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Ie:e.y-=Math.floor(e.y);break;case Le:e.y=e.y<0?0:1;break;case Re:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};jr.DEFAULT_IMAGE=null,jr.DEFAULT_MAPPING=300,jr.DEFAULT_ANISOTROPY=1;var Mr=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,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,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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 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?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(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(Vn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*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=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},U=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}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 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 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(Vr.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Vr.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=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){let 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){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Br.copy(this).projectOnVector(e),this.sub(Br)}reflect(e){return this.sub(Br.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Vn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Br=new U,Vr=new zr,Hr=class{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Wr),Wr.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(Qr),$r.subVectors(this.max,Qr),Kr.subVectors(e.a,Qr),qr.subVectors(e.b,Qr),Jr.subVectors(e.c,Qr),Yr.subVectors(qr,Kr),Xr.subVectors(Jr,qr),Zr.subVectors(Kr,Jr);let t=[0,-Yr.z,Yr.y,0,-Xr.z,Xr.y,0,-Zr.z,Zr.y,Yr.z,0,-Yr.x,Xr.z,0,-Xr.x,Zr.z,0,-Zr.x,-Yr.y,Yr.x,0,-Xr.y,Xr.x,0,-Zr.y,Zr.x,0];return!ni(t,Kr,qr,Jr,$r)||(t=[1,0,0,0,1,0,0,0,1],!ni(t,Kr,qr,Jr,$r))?!1:(ei.crossVectors(Yr,Xr),t=[ei.x,ei.y,ei.z],ni(t,Kr,qr,Jr,$r))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wr).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:(Ur[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ur[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ur[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ur[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ur[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ur[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ur[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ur[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ur),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)}},Ur=[new U,new U,new U,new U,new U,new U,new U,new U],Wr=new U,Gr=new Hr,Kr=new U,qr=new U,Jr=new U,Yr=new U,Xr=new U,Zr=new U,Qr=new U,$r=new U,ei=new U,ti=new U;function ni(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){ti.fromArray(e,a);let o=i.x*Math.abs(ti.x)+i.y*Math.abs(ti.y)+i.z*Math.abs(ti.z),s=t.dot(ti),c=n.dot(ti),l=r.dot(ti);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var ri=new Hr,ii=new U,ai=new U,oi=class{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?ri.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;tthis.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*=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;ii.subVectors(e,this.center);let t=ii.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(ii,n/e),this.radius+=n}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):(ai.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ii.copy(e.center).add(ai)),this.expandByPoint(ii.copy(e.center).sub(ai))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},si=new U,ci=new U,li=new U,ui=new U,di=new U,fi=new U,pi=new U,mi=class{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,si)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=si.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(si.copy(this.origin).addScaledVector(this.direction,t),si.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ci.copy(e).add(t).multiplyScalar(.5),li.copy(t).sub(e).normalize(),ui.copy(this.origin).sub(ci);let i=e.distanceTo(t)*.5,a=-this.direction.dot(li),o=ui.dot(this.direction),s=-ui.dot(li),c=ui.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(ci).addScaledVector(li,d),f}intersectSphere(e,t){si.subVectors(e.center,this.origin);let n=si.dot(this.direction),r=si.dot(si)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,si)!==null}intersectTriangle(e,t,n,r,i){di.subVectors(t,e),fi.subVectors(n,e),pi.crossVectors(di,fi);let a=this.direction.dot(pi),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ui.subVectors(this.origin,e);let s=o*this.direction.dot(fi.crossVectors(ui,fi));if(s<0)return null;let c=o*this.direction.dot(di.cross(ui));if(c<0||s+c>a)return null;let l=-o*ui.dot(pi);return l<0?null:this.at(l/a,i)}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)}},W=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return 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){let t=this.elements,n=e.elements,r=1/hi.setFromMatrixColumn(e,0).length(),i=1/hi.setFromMatrixColumn(e,1).length(),a=1/hi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,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){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}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(_i,e,vi)}lookAt(e,t,n){let r=this.elements;return xi.subVectors(e,t),xi.lengthSq()===0&&(xi.z=1),xi.normalize(),yi.crossVectors(n,xi),yi.lengthSq()===0&&(Math.abs(n.z)===1?xi.x+=1e-4:xi.z+=1e-4,xi.normalize(),yi.crossVectors(n,xi)),yi.normalize(),bi.crossVectors(xi,yi),r[0]=yi.x,r[4]=bi.x,r[8]=xi.x,r[1]=yi.y,r[5]=bi.y,r[9]=xi.y,r[2]=yi.z,r[6]=bi.z,r[10]=xi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],ee=r[6],te=r[10],ne=r[14],A=r[3],j=r[7],re=r[11],ie=r[15];return i[0]=a*x+o*T+s*k+c*A,i[4]=a*S+o*E+s*ee+c*j,i[8]=a*C+o*D+s*te+c*re,i[12]=a*w+o*O+s*ne+c*ie,i[1]=l*x+u*T+d*k+f*A,i[5]=l*S+u*E+d*ee+f*j,i[9]=l*C+u*D+d*te+f*re,i[13]=l*w+u*O+d*ne+f*ie,i[2]=p*x+m*T+h*k+g*A,i[6]=p*S+m*E+h*ee+g*j,i[10]=p*C+m*D+h*te+g*re,i[14]=p*w+m*O+h*ne+g*ie,i[3]=_*x+v*T+y*k+b*A,i[7]=_*S+v*E+y*ee+b*j,i[11]=_*C+v*D+y*te+b*re,i[15]=_*w+v*O+y*ne+b*ie,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=hi.set(r[0],r[1],r[2]).length(),a=hi.set(r[4],r[5],r[6]).length(),o=hi.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],gi.copy(this);let s=1/i,c=1/a,l=1/o;return gi.elements[0]*=s,gi.elements[1]*=s,gi.elements[2]*=s,gi.elements[4]*=c,gi.elements[5]*=c,gi.elements[6]*=c,gi.elements[8]*=l,gi.elements[9]*=l,gi.elements[10]*=l,t.setFromRotationMatrix(gi),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Nn){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===2e3)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===2001)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Nn){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===2e3)p=(a+i)*u,m=-2*u;else if(o===2001)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},hi=new U,gi=new W,_i=new U(0,0,0),vi=new U(1,1,1),yi=new U,bi=new U,xi=new U,Si=new W,Ci=new zr,wi=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(Vn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-Vn(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(Vn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-Vn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(Vn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-Vn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,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 Si.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Si,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ci.setFromEuler(this),this.setFromQuaternion(Ci,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}};wi.DEFAULT_ORDER=`XYZ`;var Ti=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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 t=0;t0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Hi.subVectors(r,t),Ui.subVectors(n,t),Wi.subVectors(e,t);let a=Hi.dot(Hi),o=Hi.dot(Ui),s=Hi.dot(Wi),c=Ui.dot(Ui),l=Ui.dot(Wi),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Gi)!==null&&Gi.x>=0&&Gi.y>=0&&Gi.x+Gi.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Gi)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Gi.x),s.addScaledVector(a,Gi.y),s.addScaledVector(o,Gi.z),s)}static isFrontFacing(e,t,n,r){return Hi.subVectors(n,t),Ui.subVectors(e,t),Hi.cross(Ui).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Hi.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Hi.cross(Ui).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Ki.subVectors(r,n),qi.subVectors(i,n),Yi.subVectors(e,n);let s=Ki.dot(Yi),c=qi.dot(Yi);if(s<=0&&c<=0)return t.copy(n);Xi.subVectors(e,r);let l=Ki.dot(Xi),u=qi.dot(Xi);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Ki,a);Zi.subVectors(e,i);let f=Ki.dot(Zi),p=qi.dot(Zi);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(qi,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ji.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ji,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Ki,a).addScaledVector(qi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},$i={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},ea={h:0,s:0,l:0},ta={h:0,s:0,l:0};function na(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var G=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=un){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Sr.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Sr.workingColorSpace){return this.r=e,this.g=t,this.b=n,Sr.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Sr.workingColorSpace){if(e=Hn(e,1),t=Vn(t,0,1),n=Vn(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=na(i,r,e+1/3),this.g=na(i,r,e),this.b=na(i,r,e-1/3)}return Sr.toWorkingColorSpace(this,r),this}setStyle(e,t=un){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,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=un){let n=$i[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),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=Cr(e.r),this.g=Cr(e.g),this.b=Cr(e.b),this}copyLinearToSRGB(e){return this.r=wr(e.r),this.g=wr(e.g),this.b=wr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=un){return Sr.fromWorkingColorSpace(ra.copy(this),e),Math.round(Vn(ra.r*255,0,255))*65536+Math.round(Vn(ra.g*255,0,255))*256+Math.round(Vn(ra.b*255,0,255))}getHexString(e=un){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Sr.workingColorSpace){Sr.fromWorkingColorSpace(ra.copy(this),t);let n=ra.r,r=ra.g,i=ra.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(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.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(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!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(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!==3&&(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!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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++}},oa=class extends aa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new G(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new wi,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},sa=ca();function ca(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function la(e){Math.abs(e)>65504&&console.warn(`THREE.DataUtils.toHalfFloat(): Value out of range.`),e=Vn(e,-65504,65504),sa.floatView[0]=e;let t=sa.uint32View[0],n=t>>23&511;return sa.baseTable[n]+((t&8388607)>>sa.shiftTable[n])}function ua(e){let t=e>>10;return sa.uint32View[0]=sa.mantissaTable[sa.offsetTable[t]+(e&1023)]+sa.exponentTable[t],sa.floatView[0]}var da={toHalfFloat:la,fromHalfFloat:ua},fa=new U,pa=new H,K=class{constructor(e,t,n=!1){if(Array.isArray(e))throw 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?0:e.length/t,this.normalized=n,this.usage=Cn,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=et,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return _r(`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 r=0,i=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let 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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Oa.copy(i).invert(),ka.copy(e.ray).applyMatrix4(Oa),(n.boundingBox===null||ka.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,ka)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:Ua.clone(),object:e}}function Ka(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Ma),e.getVertexPosition(c,Na),e.getVertexPosition(l,Pa);let u=Ga(e,t,n,r,Ma,Na,Pa,X);if(u){i&&(La.fromBufferAttribute(i,s),Ra.fromBufferAttribute(i,c),za.fromBufferAttribute(i,l),u.uv=Qi.getInterpolation(X,Ma,Na,Pa,La,Ra,za,new H)),a&&(La.fromBufferAttribute(a,s),Ra.fromBufferAttribute(a,c),za.fromBufferAttribute(a,l),u.uv1=Qi.getInterpolation(X,Ma,Na,Pa,La,Ra,za,new H)),o&&(Ba.fromBufferAttribute(o,s),Va.fromBufferAttribute(o,c),Ha.fromBufferAttribute(o,l),u.normal=Qi.getInterpolation(X,Ma,Na,Pa,Ba,Va,Ha,new U),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let e={a:s,b:c,c:l,normal:new U,materialIndex:0};Qi.getNormal(Ma,Na,Pa,e.normal),u.face=e}return u}var qa=class e extends Y{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new q(c,3)),this.setAttribute(`normal`,new q(l,3)),this.setAttribute(`uv`,new q(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new U;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},no=class extends Vi{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new W,this.projectionMatrix=new W,this.projectionMatrixInverse=new W,this.coordinateSystem=Nn}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)}},ro=new U,io=new H,ao=new H,oo=class extends no{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=zn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Rn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return zn*2*Math.atan(Math.tan(Rn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ro.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ro.x,ro.y).multiplyScalar(-e/ro.z),ro.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ro.x,ro.y).multiplyScalar(-e/ro.z)}getViewSize(e,t){return this.getViewBounds(e,io,ao),t.subVectors(ao,io)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Rn*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},so=-90,co=1,lo=class extends Vi{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new oo(so,co,e,t);r.layers=this.layers,this.add(r);let i=new oo(so,co,e,t);i.layers=this.layers,this.add(i);let a=new oo(so,co,e,t);a.layers=this.layers,this.add(a);let o=new oo(so,co,e,t);o.layers=this.layers,this.add(o);let s=new oo(so,co,e,t);s.layers=this.layers,this.add(s);let c=new oo(so,co,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.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),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.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),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,s),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},uo=class extends jr{constructor(e,t,n,r,i,a,o,s,c,l){e=e===void 0?[]:e,t=t===void 0?301:t,super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},fo=class extends Pr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new uo(r,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,this.texture.minFilter=t.minFilter===void 0?Ue:t.minFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new qa(5,5,5),i=new to({name:`CubemapFromEquirect`,uniforms:Ja(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Wa(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=Ue),new lo(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},po=new U,mo=new U,ho=new lr,go=class{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=po.subVectors(n,t).cross(mo.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(po),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ho.getNormalMatrix(e),r=this.coplanarPoint(po).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},_o=new oi,vo=new U,yo=class{constructor(e=new go,t=new go,n=new go,r=new go,i=new go,a=new go){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Nn){let n=this.planes,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=r[8],p=r[9],m=r[10],h=r[11],g=r[12],_=r[13],v=r[14],y=r[15];if(n[0].setComponents(s-i,d-c,h-f,y-g).normalize(),n[1].setComponents(s+i,d+c,h+f,y+g).normalize(),n[2].setComponents(s+a,d+l,h+p,y+_).normalize(),n[3].setComponents(s-a,d-l,h-p,y-_).normalize(),n[4].setComponents(s-o,d-u,h-m,y-v).normalize(),t===2e3)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===2001)n[5].setComponents(o,u,m,v).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),_o.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),_o.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_o)}intersectsSprite(e){return _o.center.set(0,0,0),_o.radius=.7071067811865476,_o.applyMatrix4(e.matrixWorld),this.intersectsSphere(_o)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,vo.y=r.normal.y>0?e.max.y:e.min.y,vo.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(vo)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function bo(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function xo(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n._updateRange,o=n.updateRanges;if(e.bindBuffer(r,t),a.count===-1&&o.length===0&&e.bufferSubData(r,0,i),o.length!==0){for(let t=0,n=o.length;t 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`,common:`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`,envmap_fragment:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,envmap_vertex:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[MORPHTARGETS_COUNT]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + #endif + #ifdef MORPHTARGETS_TEXTURE + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return shadow; + } +#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,skinning_vertex:`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,skinnormal_vertex:`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + + #else + + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,distanceRGBA_vert:`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distanceRGBA_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},Z={common:{diffuse:{value:new G(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new lr},alphaMap:{value:null},alphaMapTransform:{value:new lr},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new lr}},envmap:{envMap:{value:null},envMapRotation:{value:new lr},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new lr}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new lr}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new lr},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new lr},normalScale:{value:new H(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new lr},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new lr}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new lr}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new lr}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new G(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 G(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new lr},alphaTest:{value:0},uvTransform:{value:new lr}},sprite:{diffuse:{value:new G(16777215)},opacity:{value:1},center:{value:new H(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new lr},alphaMap:{value:null},alphaMapTransform:{value:new lr},alphaTest:{value:0}}},wo={basic:{uniforms:Ya([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.fog]),vertexShader:Co.meshbasic_vert,fragmentShader:Co.meshbasic_frag},lambert:{uniforms:Ya([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,Z.lights,{emissive:{value:new G(0)}}]),vertexShader:Co.meshlambert_vert,fragmentShader:Co.meshlambert_frag},phong:{uniforms:Ya([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,Z.lights,{emissive:{value:new G(0)},specular:{value:new G(1118481)},shininess:{value:30}}]),vertexShader:Co.meshphong_vert,fragmentShader:Co.meshphong_frag},standard:{uniforms:Ya([Z.common,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.roughnessmap,Z.metalnessmap,Z.fog,Z.lights,{emissive:{value:new G(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Co.meshphysical_vert,fragmentShader:Co.meshphysical_frag},toon:{uniforms:Ya([Z.common,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.gradientmap,Z.fog,Z.lights,{emissive:{value:new G(0)}}]),vertexShader:Co.meshtoon_vert,fragmentShader:Co.meshtoon_frag},matcap:{uniforms:Ya([Z.common,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,{matcap:{value:null}}]),vertexShader:Co.meshmatcap_vert,fragmentShader:Co.meshmatcap_frag},points:{uniforms:Ya([Z.points,Z.fog]),vertexShader:Co.points_vert,fragmentShader:Co.points_frag},dashed:{uniforms:Ya([Z.common,Z.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Co.linedashed_vert,fragmentShader:Co.linedashed_frag},depth:{uniforms:Ya([Z.common,Z.displacementmap]),vertexShader:Co.depth_vert,fragmentShader:Co.depth_frag},normal:{uniforms:Ya([Z.common,Z.bumpmap,Z.normalmap,Z.displacementmap,{opacity:{value:1}}]),vertexShader:Co.meshnormal_vert,fragmentShader:Co.meshnormal_frag},sprite:{uniforms:Ya([Z.sprite,Z.fog]),vertexShader:Co.sprite_vert,fragmentShader:Co.sprite_frag},background:{uniforms:{uvTransform:{value:new lr},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Co.background_vert,fragmentShader:Co.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new lr}},vertexShader:Co.backgroundCube_vert,fragmentShader:Co.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Co.cube_vert,fragmentShader:Co.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Co.equirect_vert,fragmentShader:Co.equirect_frag},distanceRGBA:{uniforms:Ya([Z.common,Z.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Co.distanceRGBA_vert,fragmentShader:Co.distanceRGBA_frag},shadow:{uniforms:Ya([Z.lights,Z.fog,{color:{value:new G(0)},opacity:{value:1}}]),vertexShader:Co.shadow_vert,fragmentShader:Co.shadow_frag}};wo.physical={uniforms:Ya([wo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new lr},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new lr},clearcoatNormalScale:{value:new H(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new lr},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new lr},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new lr},sheen:{value:0},sheenColor:{value:new G(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new lr},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new lr},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new lr},transmissionSamplerSize:{value:new H},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new lr},attenuationDistance:{value:0},attenuationColor:{value:new G(0)},specularColor:{value:new G(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new lr},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new lr},anisotropyVector:{value:new H},anisotropyMap:{value:null},anisotropyMapTransform:{value:new lr}}]),vertexShader:Co.meshphysical_vert,fragmentShader:Co.meshphysical_frag};var To={r:0,b:0,g:0},Eo=new wi,Do=new W;function Oo(e,t,n,r,i,a,o){let s=new G(0),c=a===!0?0:1,l,u,d=null,f=0,p=null;function m(e){let r=e.isScene===!0?e.background:null;return r&&r.isTexture&&(r=(e.backgroundBlurriness>0?n:t).get(r)),r}function h(t){let n=!1,i=m(t);i===null?_(s,c):i&&i.isColor&&(_(i,1),n=!0);let a=e.xr.getEnvironmentBlendMode();a===`additive`?r.buffers.color.setClear(0,0,0,1,o):a===`alpha-blend`&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||n)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function g(t,n){let r=m(n);r&&(r.isCubeTexture||r.mapping===306)?(u===void 0&&(u=new Wa(new qa(1,1,1),new to({name:`BackgroundCubeMaterial`,uniforms:Ja(wo.backgroundCube.uniforms),vertexShader:wo.backgroundCube.vertexShader,fragmentShader:wo.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute(`normal`),u.geometry.deleteAttribute(`uv`),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Eo.copy(n.backgroundRotation),Eo.x*=-1,Eo.y*=-1,Eo.z*=-1,r.isCubeTexture&&r.isRenderTargetTexture===!1&&(Eo.y*=-1,Eo.z*=-1),u.material.uniforms.envMap.value=r,u.material.uniforms.flipEnvMap.value=r.isCubeTexture&&r.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Do.makeRotationFromEuler(Eo)),u.material.toneMapped=Sr.getTransfer(r.colorSpace)!==mn,(d!==r||f!==r.version||p!==e.toneMapping)&&(u.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),u.layers.enableAll(),t.unshift(u,u.geometry,u.material,0,0,null)):r&&r.isTexture&&(l===void 0&&(l=new Wa(new So(2,2),new to({name:`BackgroundMaterial`,uniforms:Ja(wo.background.uniforms),vertexShader:wo.background.vertexShader,fragmentShader:wo.background.fragmentShader,side:0,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=r,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Sr.getTransfer(r.colorSpace)!==mn,r.matrixAutoUpdate===!0&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),(d!==r||f!==r.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))}function _(t,n){t.getRGB(To,Za(e)),r.buffers.color.setClear(To.r,To.g,To.b,n,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,_(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,_(s,c)},render:h,addToRenderList:g}}function ko(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n){let i=n.wireframe===!0,a=r[e.id];a===void 0&&(a={},r[e.id]=a);let o=a[t.id];o===void 0&&(o={},a[t.id]=o);let s=o[i];return s===void 0&&(s=f(c()),o[i]=s),s}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(console.warn(`THREE.WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_TEXTURE_SIZE),h=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),_=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=p>0,x=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:h,maxAttributes:g,maxVertexUniforms:_,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:b,maxSamples:x}}function Mo(e){let t=this,n=null,r=0,i=!1,a=!1,o=new go,s=new lr,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0){let o=new fo(a.height);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener(`dispose`,i),n(o.texture,r.mapping)}return null}}}return r}function i(e){let n=e.target;n.removeEventListener(`dispose`,i);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var Po=class extends no{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Fo=4,Io=[.125,.215,.35,.446,.526,.582],Lo=20,Ro=new Po,zo=new G,Bo=null,Vo=0,Ho=0,Uo=!1,Wo=(1+Math.sqrt(5))/2,Go=1/Wo,Ko=[new U(-Wo,Go,0),new U(Wo,Go,0),new U(-Go,0,Wo),new U(Go,0,Wo),new U(0,Wo,-Go),new U(0,Wo,Go),new U(-1,1,-1),new U(1,1,-1),new U(-1,1,1),new U(1,1,1)],qo=class{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,r=100){Bo=this._renderer.getRenderTarget(),Vo=this._renderer.getActiveCubeFace(),Ho=this._renderer.getActiveMipmapLevel(),Uo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$o(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Qo(),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=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?c:0,c,c),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=$o()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Qo());let i=r?this._cubemapMaterial:this._equirectMaterial,a=new Wa(this._lodPlanes[0],i),o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;Xo(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Ro)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;tLo&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Lo}`);let h=[],g=0;for(let e=0;e_-Fo?r-_+Fo:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Ro)}};function Jo(e){let t=[],n=[],r=[],i=e,a=e-Fo+1+Io.length;for(let o=0;oe-Fo?s=Io[o-e+Fo-1]:o===0&&(s=0),r.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Y;h.setAttribute(`position`,new K(f,3)),h.setAttribute(`uv`,new K(p,2)),h.setAttribute(`faceIndex`,new K(m,1)),t.push(h),i>Fo&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}function Yo(e,t,n){let r=new Pr(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function Xo(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Zo(e,t,n){let r=new Float32Array(Lo),i=new U(0,1,0);return new to({name:`SphericalGaussianBlur`,defines:{n:Lo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:es(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function Qo(){return new to({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:es(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function $o(){return new to({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:es(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function es(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function ts(e){let t=new WeakMap,n=null;function r(r){if(r&&r.isTexture){let o=r.mapping,s=o===303||o===304,c=o===301||o===302;if(s||c){let o=t.get(r),l=o===void 0?0:o.texture.pmremVersion;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return n===null&&(n=new qo(e)),o=s?n.fromEquirectangular(r,o):n.fromCubemap(r,o),o.texture.pmremVersion=r.pmremVersion,t.set(r,o),o.texture;if(o!==void 0)return o.texture;{let l=r.image;return s&&l&&l.height>0||c&&l&&i(l)?(n===null&&(n=new qo(e)),o=s?n.fromEquirectangular(r):n.fromCubemap(r),o.texture.pmremVersion=r.pmremVersion,t.set(r,o),r.addEventListener(`dispose`,a),o.texture):null}}}return r}function i(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function a(e){let n=e.target;n.removeEventListener(`dispose`,a);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function o(){t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function ns(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r;switch(n){case`WEBGL_depth_texture`:r=e.getExtension(`WEBGL_depth_texture`)||e.getExtension(`MOZ_WEBGL_depth_texture`)||e.getExtension(`WEBKIT_WEBGL_depth_texture`);break;case`EXT_texture_filter_anisotropic`:r=e.getExtension(`EXT_texture_filter_anisotropic`)||e.getExtension(`MOZ_EXT_texture_filter_anisotropic`)||e.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`);break;case`WEBGL_compressed_texture_s3tc`:r=e.getExtension(`WEBGL_compressed_texture_s3tc`)||e.getExtension(`MOZ_WEBGL_compressed_texture_s3tc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_s3tc`);break;case`WEBGL_compressed_texture_pvrtc`:r=e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`);break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&console.warn(`THREE.WebGLRenderer: `+e+` extension not supported.`),t}}}function rs(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);for(let e in s.morphAttributes){let n=s.morphAttributes[e];for(let e=0,r=n.length;et.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Fr(h,p,m,u);g.type=et,g.needsUpdate=!0;let _=f*4;for(let t=0;t0)return e;let i=t*n,a=ms[i];if(a===void 0&&(a=new Float32Array(i),ms[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function bs(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}function bc(e){let t=Sr.getPrimaries(Sr.workingColorSpace),n=Sr.getPrimaries(e),r;switch(t===n?r=``:t===`p3`&&n===`rec709`?r=`LinearDisplayP3ToLinearSRGB`:t===`rec709`&&n===`p3`&&(r=`LinearSRGBToLinearDisplayP3`),e){case V:case fn:return[r,`LinearTransferOETF`];case un:case dn:return[r,`sRGBTransferOETF`];default:return console.warn(`THREE.WebGLProgram: Unsupported color space:`,e),[r,`LinearTransferOETF`]}}function xc(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+yc(e.getShaderSource(t),r)}return i}function Sc(e,t){let n=bc(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Cc(e,t){let n;switch(t){case 1:n=`Linear`;break;case 2:n=`Reinhard`;break;case 3:n=`OptimizedCineon`;break;case 4:n=`ACESFilmic`;break;case 6:n=`AgX`;break;case 7:n=`Neutral`;break;case 5:n=`Custom`;break;default:console.warn(`THREE.WebGLProgram: Unsupported toneMapping:`,t),n=`Linear`}return`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}function wc(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(Dc).join(` +`)}function Tc(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function Ec(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function jc(e){return e.replace(Ac,Nc)}var Mc=new Map;function Nc(e,t){let n=Co[t];if(n===void 0){let e=Mc.get(t);if(e!==void 0)n=Co[e],console.warn(`THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return jc(n)}var Pc=/#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 Fc(e){return e.replace(Pc,Ic)}function Ic(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Dc).join(` +`),_.length>0&&(_+=` +`)):(g=[Lc(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )`,` attribute vec3 morphTarget0;`,` attribute vec3 morphTarget1;`,` attribute vec3 morphTarget2;`,` attribute vec3 morphTarget3;`,` #ifdef USE_MORPHNORMALS`,` attribute vec3 morphNormal0;`,` attribute vec3 morphNormal1;`,` attribute vec3 morphNormal2;`,` attribute vec3 morphNormal3;`,` #else`,` attribute vec3 morphTarget4;`,` attribute vec3 morphTarget5;`,` attribute vec3 morphTarget6;`,` attribute vec3 morphTarget7;`,` #endif`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(Dc).join(` +`),_=[Lc(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Co.tonemapping_pars_fragment,n.toneMapping===0?``:Cc(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Co.colorspace_pars_fragment,Sc(`linearToOutputTexel`,n.outputColorSpace),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(Dc).join(` +`)),o=jc(o),o=Oc(o,n),o=kc(o,n),s=jc(s),s=Oc(s,n),s=kc(s,n),o=Fc(o),s=Fc(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#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(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=gc(i,i.VERTEX_SHADER,y),S=gc(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h).trim(),r=i.getShaderInfoLog(x).trim(),a=i.getShaderInfoLog(S).trim(),o=!0,s=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1){if(o=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=xc(i,x,`vertex`),r=xc(i,S,`fragment`);console.error(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+n+` +`+e+` +`+r)}}else n===``?(r===``||a===``)&&(s=!1):console.warn(`THREE.WebGLProgram: Program Info Log:`,n);s&&(t.diagnostics={runnable:o,programLog:n,vertexShader:{log:r,prefix:g},fragmentShader:{log:a,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new hc(i,h),T=Ec(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,_c)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=vc++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var Wc=0,Gc=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.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){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Kc(e),t.set(e,n)),n}},Kc=class{constructor(e){this.id=Wc++,this.code=e,this.usedTimes=0}};function qc(e,t,n,r,i,a,o){let s=new Ti,c=new Gc,l=new Set,u=[],d=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,m={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 h(e){return l.add(e),e===0?`uv`:`uv${e}`}function g(a,s,u,g,_){let v=g.fog,y=_.geometry,b=a.isMeshStandardMaterial?g.environment:null,x=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),S=x&&x.mapping===306?x.image.height:null,C=m[a.type];a.precision!==null&&(p=i.getMaxPrecision(a.precision),p!==a.precision&&console.warn(`THREE.WebGLProgram.getParameters:`,a.precision,`not supported, using`,p,`instead.`));let w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=w===void 0?0:w.length,E=0;y.morphAttributes.position!==void 0&&(E=1),y.morphAttributes.normal!==void 0&&(E=2),y.morphAttributes.color!==void 0&&(E=3);let D,O,k,ee;if(C){let e=wo[C];D=e.vertexShader,O=e.fragmentShader}else D=a.vertexShader,O=a.fragmentShader,c.update(a),k=c.getVertexShaderID(a),ee=c.getFragmentShaderID(a);let te=e.getRenderTarget(),ne=_.isInstancedMesh===!0,A=_.isBatchedMesh===!0,j=!!a.map,re=!!a.matcap,ie=!!x,ae=!!a.aoMap,oe=!!a.lightMap,se=!!a.bumpMap,M=!!a.normalMap,ce=!!a.displacementMap,le=!!a.emissiveMap,N=!!a.metalnessMap,ue=!!a.roughnessMap,P=a.anisotropy>0,de=a.clearcoat>0,F=a.dispersion>0,I=a.iridescence>0,L=a.sheen>0,fe=a.transmission>0,R=P&&!!a.anisotropyMap,pe=de&&!!a.clearcoatMap,me=de&&!!a.clearcoatNormalMap,he=de&&!!a.clearcoatRoughnessMap,ge=I&&!!a.iridescenceMap,_e=I&&!!a.iridescenceThicknessMap,ve=L&&!!a.sheenColorMap,ye=L&&!!a.sheenRoughnessMap,z=!!a.specularMap,be=!!a.specularColorMap,xe=!!a.specularIntensityMap,Se=fe&&!!a.transmissionMap,Ce=fe&&!!a.thicknessMap,we=!!a.gradientMap,Te=!!a.alphaMap,Ee=a.alphaTest>0,De=!!a.alphaHash,Oe=!!a.extensions,ke=0;a.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(ke=e.toneMapping);let Ae={shaderID:C,shaderType:a.type,shaderName:a.name,vertexShader:D,fragmentShader:O,defines:a.defines,customVertexShaderID:k,customFragmentShaderID:ee,isRawShaderMaterial:a.isRawShaderMaterial===!0,glslVersion:a.glslVersion,precision:p,batching:A,instancing:ne,instancingColor:ne&&_.instanceColor!==null,instancingMorph:ne&&_.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:te===null?e.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:V,alphaToCoverage:!!a.alphaToCoverage,map:j,matcap:re,envMap:ie,envMapMode:ie&&x.mapping,envMapCubeUVHeight:S,aoMap:ae,lightMap:oe,bumpMap:se,normalMap:M,displacementMap:f&&ce,emissiveMap:le,normalMapObjectSpace:M&&a.normalMapType===1,normalMapTangentSpace:M&&a.normalMapType===0,metalnessMap:N,roughnessMap:ue,anisotropy:P,anisotropyMap:R,clearcoat:de,clearcoatMap:pe,clearcoatNormalMap:me,clearcoatRoughnessMap:he,dispersion:F,iridescence:I,iridescenceMap:ge,iridescenceThicknessMap:_e,sheen:L,sheenColorMap:ve,sheenRoughnessMap:ye,specularMap:z,specularColorMap:be,specularIntensityMap:xe,transmission:fe,transmissionMap:Se,thicknessMap:Ce,gradientMap:we,opaque:a.transparent===!1&&a.blending===1&&a.alphaToCoverage===!1,alphaMap:Te,alphaTest:Ee,alphaHash:De,combine:a.combine,mapUv:j&&h(a.map.channel),aoMapUv:ae&&h(a.aoMap.channel),lightMapUv:oe&&h(a.lightMap.channel),bumpMapUv:se&&h(a.bumpMap.channel),normalMapUv:M&&h(a.normalMap.channel),displacementMapUv:ce&&h(a.displacementMap.channel),emissiveMapUv:le&&h(a.emissiveMap.channel),metalnessMapUv:N&&h(a.metalnessMap.channel),roughnessMapUv:ue&&h(a.roughnessMap.channel),anisotropyMapUv:R&&h(a.anisotropyMap.channel),clearcoatMapUv:pe&&h(a.clearcoatMap.channel),clearcoatNormalMapUv:me&&h(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:he&&h(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ge&&h(a.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&h(a.iridescenceThicknessMap.channel),sheenColorMapUv:ve&&h(a.sheenColorMap.channel),sheenRoughnessMapUv:ye&&h(a.sheenRoughnessMap.channel),specularMapUv:z&&h(a.specularMap.channel),specularColorMapUv:be&&h(a.specularColorMap.channel),specularIntensityMapUv:xe&&h(a.specularIntensityMap.channel),transmissionMapUv:Se&&h(a.transmissionMap.channel),thicknessMapUv:Ce&&h(a.thicknessMap.channel),alphaMapUv:Te&&h(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(M||P),vertexColors:a.vertexColors,vertexAlphas:a.vertexColors===!0&&!!y.attributes.color&&y.attributes.color.itemSize===4,pointsUvs:_.isPoints===!0&&!!y.attributes.uv&&(j||Te),fog:!!v,useFog:a.fog===!0,fogExp2:!!v&&v.isFogExp2,flatShading:a.flatShading===!0,sizeAttenuation:a.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:_.isSkinnedMesh===!0,morphTargets:y.morphAttributes.position!==void 0,morphNormals:y.morphAttributes.normal!==void 0,morphColors:y.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:ke,useLegacyLights:e._useLegacyLights,decodeVideoTexture:j&&a.map.isVideoTexture===!0&&Sr.getTransfer(a.map.colorSpace)===`srgb`,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===2,flipSided:a.side===1,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:Oe&&a.extensions.clipCullDistance===!0&&r.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:Oe&&a.extensions.multiDraw===!0&&r.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:r.has(`KHR_parallel_shader_compile`),customProgramCacheKey:a.customProgramCacheKey()};return Ae.vertexUv1s=l.has(1),Ae.vertexUv2s=l.has(2),Ae.vertexUv3s=l.has(3),l.clear(),Ae}function _(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(v(n,t),y(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function v(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function y(e,t){s.disableAll(),t.supportsVertexTextures&&s.enable(0),t.instancing&&s.enable(1),t.instancingColor&&s.enable(2),t.instancingMorph&&s.enable(3),t.matcap&&s.enable(4),t.envMap&&s.enable(5),t.normalMapObjectSpace&&s.enable(6),t.normalMapTangentSpace&&s.enable(7),t.clearcoat&&s.enable(8),t.iridescence&&s.enable(9),t.alphaTest&&s.enable(10),t.vertexColors&&s.enable(11),t.vertexAlphas&&s.enable(12),t.vertexUv1s&&s.enable(13),t.vertexUv2s&&s.enable(14),t.vertexUv3s&&s.enable(15),t.vertexTangents&&s.enable(16),t.anisotropy&&s.enable(17),t.alphaHash&&s.enable(18),t.batching&&s.enable(19),t.dispersion&&s.enable(20),e.push(s.mask),s.disableAll(),t.fog&&s.enable(0),t.useFog&&s.enable(1),t.flatShading&&s.enable(2),t.logarithmicDepthBuffer&&s.enable(3),t.skinning&&s.enable(4),t.morphTargets&&s.enable(5),t.morphNormals&&s.enable(6),t.morphColors&&s.enable(7),t.premultipliedAlpha&&s.enable(8),t.shadowMapEnabled&&s.enable(9),t.useLegacyLights&&s.enable(10),t.doubleSided&&s.enable(11),t.flipSided&&s.enable(12),t.useDepthPacking&&s.enable(13),t.dithering&&s.enable(14),t.transmission&&s.enable(15),t.sheen&&s.enable(16),t.opaque&&s.enable(17),t.pointsUvs&&s.enable(18),t.decodeVideoTexture&&s.enable(19),t.alphaToCoverage&&s.enable(20),e.push(s.mask)}function b(e){let t=m[e.type],n;if(t){let e=wo[t];n=Qa.clone(e.uniforms)}else n=e.uniforms;return n}function x(t,n){let r;for(let e=0,t=u.length;e0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function c(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function l(e,t){n.length>1&&n.sort(e||Yc),r.length>1&&r.sort(t||Xc),i.length>1&&i.sort(t||Xc)}function u(){for(let n=t,r=e.length;n=r.length?(i=new Zc,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function $c(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new U,color:new G};break;case`SpotLight`:n={position:new U,direction:new U,color:new G,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new U,color:new G,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new U,skyColor:new G,groundColor:new G};break;case`RectAreaLight`:n={color:new G,position:new U,halfWidth:new U,halfHeight:new U}}return e[t.id]=n,n}}}function el(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new H};break;case`SpotLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new H};break;case`PointLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new H,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var tl=0;function nl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function rl(e){let t=new $c,n=el(),r={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 e=0;e<9;e++)r.probe.push(new U);let i=new U,a=new W,o=new W;function s(i,a){let o=0,s=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;i.sort(nl);let b=a===!0?Math.PI:1;for(let e=0,a=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=Z.LTC_FLOAT_1,r.rectAreaLTC2=Z.LTC_FLOAT_2):(r.rectAreaLTC1=Z.LTC_HALF_1,r.rectAreaLTC2=Z.LTC_HALF_2)),r.ambient[0]=o,r.ambient[1]=s,r.ambient[2]=c;let x=r.hash;(x.directionalLength!==l||x.pointLength!==u||x.spotLength!==d||x.rectAreaLength!==f||x.hemiLength!==p||x.numDirectionalShadows!==m||x.numPointShadows!==h||x.numSpotShadows!==g||x.numSpotMaps!==_||x.numLightProbes!==y)&&(r.directional.length=l,r.spot.length=d,r.rectArea.length=f,r.point.length=u,r.hemi.length=p,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=h,r.pointShadowMap.length=h,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=h,r.spotLightMatrix.length=g+_-v,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=v,r.numLightProbes=y,x.directionalLength=l,x.pointLength=u,x.spotLength=d,x.rectAreaLength=f,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=h,x.numSpotShadows=g,x.numSpotMaps=_,x.numLightProbes=y,r.version=tl++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new il(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var ol=class extends aa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=cn,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}},sl=class extends aa{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}},cl=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,ll=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function ul(e,t,n){let r=new yo,i=new H,a=new H,o=new Mr,s=new ol({depthPacking:ln}),c=new sl,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new to({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new H},radius:{value:4}},vertexShader:cl,fragmentShader:ll}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Y;m.setAttribute(`position`,new K(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Wa(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==3&&this.type===3,m=_===3&&this.type!==3;for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/h.x),i.x=a.x*h.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/h.y),i.y=a.y*h.y,d.mapSize.y=a.y)),d.map===null||p===!0||m===!0){let e=this.type===3?{}:{minFilter:ze,magFilter:ze};d.map!==null&&d.map.dispose(),d.map=new Pr(i.x,i.y,e),d.map.texture.name=l.name+`.shadowMap`,d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let g=d.getViewportCount();for(let e=0;e0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(ne=parseFloat(/^WebGL (\d)/.exec(A)[1]),te=ne>=1);let j=null,re={},ie=e.getParameter(e.SCISSOR_BOX),ae=e.getParameter(e.VIEWPORT),oe=new Mr().fromArray(ie),se=new Mr().fromArray(ae);function M(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new H,u=new WeakMap,d,f=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function m(e,t){return p?new OffscreenCanvas(e,t):mr(`canvas`)}function h(e,t,n){let r=1,i=he(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);d===void 0&&(d=m(n,a));let o=t?m(n,a):d;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),console.warn(`THREE.WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&console.warn(`THREE.WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function g(e){return e.generateMipmaps&&e.minFilter!==1003&&e.minFilter!==1006}function _(t){e.generateMipmap(t)}function v(n,r,i,a,o=!1){if(n!==null){if(e[n]!==void 0)return e[n];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let s=r;if(r===e.RED&&(i===e.FLOAT&&(s=e.R32F),i===e.HALF_FLOAT&&(s=e.R16F),i===e.UNSIGNED_BYTE&&(s=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.R8UI),i===e.UNSIGNED_SHORT&&(s=e.R16UI),i===e.UNSIGNED_INT&&(s=e.R32UI),i===e.BYTE&&(s=e.R8I),i===e.SHORT&&(s=e.R16I),i===e.INT&&(s=e.R32I)),r===e.RG&&(i===e.FLOAT&&(s=e.RG32F),i===e.HALF_FLOAT&&(s=e.RG16F),i===e.UNSIGNED_BYTE&&(s=e.RG8)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RG8UI),i===e.UNSIGNED_SHORT&&(s=e.RG16UI),i===e.UNSIGNED_INT&&(s=e.RG32UI),i===e.BYTE&&(s=e.RG8I),i===e.SHORT&&(s=e.RG16I),i===e.INT&&(s=e.RG32I)),r===e.RGB&&i===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5),r===e.RGBA){let t=o?pn:Sr.getTransfer(a);i===e.FLOAT&&(s=e.RGBA32F),i===e.HALF_FLOAT&&(s=e.RGBA16F),i===e.UNSIGNED_BYTE&&(s=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}return(s===e.R16F||s===e.R32F||s===e.RG16F||s===e.RG32F||s===e.RGBA16F||s===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),s}function y(e,t){return g(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(e){let t=e.target;t.removeEventListener(`dispose`,b),S(t),t.isVideoTexture&&u.delete(t)}function x(e){let t=e.target;t.removeEventListener(`dispose`,x),w(t)}function S(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=f.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&C(e),Object.keys(i).length===0&&f.delete(n)}r.remove(e)}function C(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=f.get(i);delete a[n.__cacheKey],o.memory.textures--}function w(t){let n=r.get(t);if(t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&console.warn(`THREE.WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),T+=1,e}function O(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function k(t,i){let a=r.get(t);if(t.isVideoTexture&&pe(t),t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){let e=t.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{oe(a,t,i);return}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function ee(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){oe(a,t,i);return}n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function te(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){oe(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ne(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){se(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let A={[Ie]:e.REPEAT,[Le]:e.CLAMP_TO_EDGE,[Re]:e.MIRRORED_REPEAT},j={[ze]:e.NEAREST,[B]:e.NEAREST_MIPMAP_NEAREST,[Ve]:e.NEAREST_MIPMAP_LINEAR,[Ue]:e.LINEAR,[We]:e.LINEAR_MIPMAP_NEAREST,[Ke]:e.LINEAR_MIPMAP_LINEAR},re={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ie(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&console.warn(`THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,A[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,A[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,A[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,j[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,j[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,re[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function ae(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,b));let i=n.source,a=f.get(i);a===void 0&&(a={},f.set(i,a));let s=O(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&C(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function oe(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=ae(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let d=r.get(u);if(u.version!==d.__version||l===!0){n.activeTexture(e.TEXTURE0+s);let t=Sr.getPrimaries(Sr.workingColorSpace),r=o.colorSpace===``?null:Sr.getPrimaries(o.colorSpace),f=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let p=h(o.image,!1,i.maxTextureSize);p=me(o,p);let m=a.convert(o.format,o.colorSpace),b=a.convert(o.type),x=v(o.internalFormat,m,b,o.colorSpace,o.isVideoTexture);ie(c,o);let S,C=o.mipmaps,w=o.isVideoTexture!==!0,T=d.__version===void 0||l===!0,E=u.dataReady,D=y(o,p);if(o.isDepthTexture)x=e.DEPTH_COMPONENT16,o.type===1015?x=e.DEPTH_COMPONENT32F:o.type===1014?x=e.DEPTH_COMPONENT24:o.type===1020&&(x=e.DEPTH24_STENCIL8),T&&(w?n.texStorage2D(e.TEXTURE_2D,1,x,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,x,p.width,p.height,0,m,b,null));else if(o.isDataTexture){if(C.length>0){w&&T&&n.texStorage2D(e.TEXTURE_2D,D,x,C[0].width,C[0].height);for(let t=0,r=C.length;t>=1,r>>=1}}}else if(C.length>0){if(w&&T){let t=he(C[0]);n.texStorage2D(e.TEXTURE_2D,D,x,t.width,t.height)}for(let t=0,r=C.length;t0&&D++;let t=he(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,x,S,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,x,S,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),R(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,r.get(o).__webglTexture,0,fe(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,r.get(o).__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ce(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let i=e.DEPTH_COMPONENT24;if(r||R(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===1015?i=e.DEPTH_COMPONENT32F:t.type===1014&&(i=e.DEPTH_COMPONENT24));let r=fe(n);R(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,i,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,i,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,i,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let i=fe(n);r&&R(n)===!1?e.renderbufferStorageMultisample(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):R(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&R(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(R(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function pe(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function me(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Sr.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&console.warn(`THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):console.error(`THREE.WebGLTextures: Unsupported texture color space:`,n)),t}function he(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=D,this.resetTextureUnits=E,this.setTexture2D=k,this.setTexture2DArray=ee,this.setTexture3D=te,this.setTextureCube=ne,this.rebindTextures=ue,this.setupRenderTarget=P,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=L,this.setupDepthRenderbuffer=N,this.setupFrameBufferTexture=M,this.useMultisampledRTT=R}function pl(e,t){function n(n,r=``){let i,a=Sr.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1024)return e.LUMINANCE;if(n===1025)return e.LUMINANCE_ALPHA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779){if(a===`srgb`){if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(n===35840||n===35841||n===35842||n===35843){if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(n===36196||n===37492||n===37496){if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(n===36492||n===36494||n===36495){if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(n===36283||n===36284||n===36285||n===36286){if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36492)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var ml=class extends oo{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},hl=class extends Vi{constructor(){super(),this.isGroup=!0,this.type=`Group`}},gl={type:`move`},_l=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new hl,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 hl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new hl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(gl)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new hl;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},vl=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,yl=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,bl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let r=new jr,i=e.properties.get(r);i.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let e=t.cameras[0].viewport,n=new to({vertexShader:vl,fragmentShader:yl,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Wa(new So(20,20),n)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},xl=class extends Fn{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=new bl,h=t.getContextAttributes(),g=null,_=null,v=[],y=[],b=new H,x=null,S=new oo;S.layers.enable(1),S.viewport=new Mr;let C=new oo;C.layers.enable(2),C.viewport=new Mr;let w=[S,C],T=new ml;T.layers.enable(1),T.layers.enable(2);let E=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return t===void 0&&(t=new _l,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return t===void 0&&(t=new _l,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return t===void 0&&(t=new _l,v[e]=t),t.getHandSpace()};function O(e){let t=y.indexOf(e.inputSource);if(t===-1)return;let n=v[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function k(){r.removeEventListener(`select`,O),r.removeEventListener(`selectstart`,O),r.removeEventListener(`selectend`,O),r.removeEventListener(`squeeze`,O),r.removeEventListener(`squeezestart`,O),r.removeEventListener(`squeezeend`,O),r.removeEventListener(`end`,k),r.removeEventListener(`inputsourceschange`,ee);for(let e=0;e=0&&(y[r]=null,v[r].disconnect(n))}for(let t=0;t=y.length){y.push(n),r=e;break}else if(y[e]===null){y[e]=n,r=e;break}if(r===-1)break}let i=v[r];i&&i.connect(n)}}let te=new U,ne=new U;function A(e,t,n){te.setFromMatrixPosition(t.matrixWorld),ne.setFromMatrixPosition(n.matrixWorld);let r=te.distanceTo(ne),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=o+m,_=s+m,v=f-h,y=p+(r-h),b=c*s/_*g,x=l*s/_*g;e.projectionMatrix.makePerspective(v,y,b,x,g,_),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}function j(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;m.texture!==null&&(e.near=m.depthNear,e.far=m.depthFar),T.near=C.near=S.near=e.near,T.far=C.far=S.far=e.far,(E!==T.near||D!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,D=T.far,S.near=E,S.far=D,C.near=E,C.far=D,S.updateProjectionMatrix(),C.updateProjectionMatrix(),e.updateProjectionMatrix());let t=e.parent,n=T.cameras;j(T,t);for(let e=0;e0&&(r.alphaTest.value=i.alphaTest);let a=t.get(i),o=a.envMap,s=a.envMapRotation;if(o&&(r.envMap.value=o,Sl.copy(s),Sl.x*=-1,Sl.y*=-1,Sl.z*=-1,o.isCubeTexture&&o.isRenderTargetTexture===!1&&(Sl.y*=-1,Sl.z*=-1),r.envMapRotation.value.setFromMatrix4(Cl.makeRotationFromEuler(Sl)),r.flipEnvMap.value=o.isCubeTexture&&o.isRenderTargetTexture===!1?-1:1,r.reflectivity.value=i.reflectivity,r.ior.value=i.ior,r.refractionRatio.value=i.refractionRatio),i.lightMap){r.lightMap.value=i.lightMap;let t=e._useLegacyLights===!0?Math.PI:1;r.lightMapIntensity.value=i.lightMapIntensity*t,n(i.lightMap,r.lightMapTransform)}i.aoMap&&(r.aoMap.value=i.aoMap,r.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,r.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Tl(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var El=class{constructor(e={}){let{canvas:t=hr(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);d=n.getContextAttributes().alpha}else d=a;let f=new Uint32Array(4),p=new Int32Array(4),m=null,h=null,g=[],_=[];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=un,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;let v=this,y=!1,b=0,x=0,S=null,C=-1,w=null,T=new Mr,E=new Mr,D=null,O=new G(0),k=0,ee=t.width,te=t.height,ne=1,A=null,j=null,re=new Mr(0,0,ee,te),ie=new Mr(0,0,ee,te),ae=!1,oe=new yo,se=!1,M=!1,ce=new W,le=new U,N={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ue(){return S===null?ne:1}let P=n;function de(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r164`),t.addEventListener(`webglcontextlost`,Ne,!1),t.addEventListener(`webglcontextrestored`,Pe,!1),t.addEventListener(`webglcontextcreationerror`,Fe,!1),P===null){let t=`webgl2`;if(P=de(t,e),P===null)throw de(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw console.error(`THREE.WebGLRenderer: `+e.message),e}let F,I,L,fe,R,pe,me,he,ge,_e,ve,ye,z,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae;function je(){F=new ns(P),F.init(),Oe=new pl(P,F),I=new jo(P,F,e,Oe),L=new dl(P),fe=new as(P),R=new Jc,pe=new fl(P,F,L,R,I,Oe,fe),me=new No(v),he=new ts(v),ge=new xo(P),ke=new ko(P,ge),_e=new rs(P,ge,fe,ke),ve=new ss(P,_e,ge,fe),Te=new os(P,I,pe),Se=new Mo(R),ye=new qc(v,me,he,F,I,ke,Se),z=new wl(v,R),be=new Qc,xe=new al(F),we=new Oo(v,me,he,L,ve,d,s),Ce=new ul(v,ve,I),Ae=new Tl(P,fe,I,L),Ee=new Ao(P,F,fe),De=new is(P,F,fe),fe.programs=ye.programs,v.capabilities=I,v.extensions=F,v.properties=R,v.renderLists=be,v.shadowMap=Ce,v.state=L,v.info=fe}je();let Me=new xl(v,P);this.xr=Me,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let e=F.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=F.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(e){e!==void 0&&(ne=e,this.setSize(ee,te,!1))},this.getSize=function(e){return e.set(ee,te)},this.setSize=function(e,n,r=!0){if(Me.isPresenting){console.warn(`THREE.WebGLRenderer: Can't change size while VR device is presenting.`);return}ee=e,te=n,t.width=Math.floor(e*ne),t.height=Math.floor(n*ne),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ee*ne,te*ne).floor()},this.setDrawingBufferSize=function(e,n,r){ee=e,te=n,ne=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(T)},this.getViewport=function(e){return e.copy(re)},this.setViewport=function(e,t,n,r){e.isVector4?re.set(e.x,e.y,e.z,e.w):re.set(e,t,n,r),L.viewport(T.copy(re).multiplyScalar(ne).round())},this.getScissor=function(e){return e.copy(ie)},this.setScissor=function(e,t,n,r){e.isVector4?ie.set(e.x,e.y,e.z,e.w):ie.set(e,t,n,r),L.scissor(E.copy(ie).multiplyScalar(ne).round())},this.getScissorTest=function(){return ae},this.setScissorTest=function(e){L.setScissorTest(ae=e)},this.setOpaqueSort=function(e){A=e},this.setTransparentSort=function(e){j=e},this.getClearColor=function(e){return e.copy(we.getClearColor())},this.setClearColor=function(){we.setClearColor.apply(we,arguments)},this.getClearAlpha=function(){return we.getClearAlpha()},this.setClearAlpha=function(){we.setClearAlpha.apply(we,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(S!==null){let t=S.texture.format;e=t===1033||t===1031||t===1029}if(e){let e=S.texture.type,t=e===1009||e===1014||e===1012||e===1020||e===1017||e===1018,n=we.getClearColor(),r=we.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(f[0]=i,f[1]=a,f[2]=o,f[3]=r,P.clearBufferuiv(P.COLOR,0,f)):(p[0]=i,p[1]=a,p[2]=o,p[3]=r,P.clearBufferiv(P.COLOR,0,p))}else r|=P.COLOR_BUFFER_BIT}t&&(r|=P.DEPTH_BUFFER_BIT),n&&(r|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(r)},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`,Ne,!1),t.removeEventListener(`webglcontextrestored`,Pe,!1),t.removeEventListener(`webglcontextcreationerror`,Fe,!1),be.dispose(),xe.dispose(),R.dispose(),me.dispose(),he.dispose(),ve.dispose(),ke.dispose(),Ae.dispose(),ye.dispose(),Me.dispose(),Me.removeEventListener(`sessionstart`,Ve),Me.removeEventListener(`sessionend`,He),Ue.stop()};function Ne(e){e.preventDefault(),console.log(`THREE.WebGLRenderer: Context Lost.`),y=!0}function Pe(){console.log(`THREE.WebGLRenderer: Context Restored.`),y=!1;let e=fe.autoReset,t=Ce.enabled,n=Ce.autoUpdate,r=Ce.needsUpdate,i=Ce.type;je(),fe.autoReset=e,Ce.enabled=t,Ce.autoUpdate=n,Ce.needsUpdate=r,Ce.type=i}function Fe(e){console.error(`THREE.WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Ie(e){let t=e.target;t.removeEventListener(`dispose`,Ie),Le(t)}function Le(e){Re(e),R.remove(e)}function Re(e){let t=R.get(e).programs;t!==void 0&&(t.forEach(function(e){ye.releaseProgram(e)}),e.isShaderMaterial&&ye.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=N);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=et(e,t,n,r,i);L.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=_e.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;ke.setup(i,r,s,n,c);let h,g=Ee;if(c!==null&&(h=ge.get(c),g=De,g.setIndex(h)),i.isMesh)r.wireframe===!0?(L.setLineWidth(r.wireframeLinewidth*ue()),g.setMode(P.LINES)):g.setMode(P.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),L.setLineWidth(e*ue()),i.isLineSegments?g.setMode(P.LINES):i.isLineLoop?g.setMode(P.LINE_LOOP):g.setMode(P.LINE_STRIP)}else i.isPoints?g.setMode(P.POINTS):i.isSprite&&g.setMode(P.TRIANGLES);if(i.isBatchedMesh)i._multiDrawInstances===null?g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount):g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function ze(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,Ze(e,t,n),e.side=0,e.needsUpdate=!0,Ze(e,t,n),e.side=2):Ze(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),h=xe.get(n),h.init(t),_.push(h),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(h.pushLight(e),e.castShadow&&h.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(h.pushLight(e),e.castShadow&&h.pushShadow(e))}),h.setupLights(v._useLegacyLights);let r=new Set;return e.traverse(function(e){let t=e.material;if(t){if(Array.isArray(t))for(let i=0;i{function n(){if(r.forEach(function(e){R.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}F.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let B=null;function Be(e){B&&B(e)}function Ve(){Ue.stop()}function He(){Ue.start()}let Ue=new bo;Ue.setAnimationLoop(Be),typeof self<`u`&&Ue.setContext(self),this.setAnimationLoop=function(e){B=e,Me.setAnimationLoop(e),e===null?Ue.stop():Ue.start()},Me.addEventListener(`sessionstart`,Ve),Me.addEventListener(`sessionend`,He),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(y===!0)return;e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(t),t=Me.getCamera()),e.isScene===!0&&e.onBeforeRender(v,e,t,S),h=xe.get(e,_.length),h.init(t),_.push(h),ce.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),oe.setFromProjectionMatrix(ce),M=this.localClippingEnabled,se=Se.init(this.clippingPlanes,M),m=be.get(e,g.length),m.init(),g.push(m),We(e,t,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(A,j);let n=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1;n&&we.addToRenderList(m,e),this.info.render.frame++,se===!0&&Se.beginShadows();let r=h.state.shadowsArray;Ce.render(r,e,t),se===!0&&Se.endShadows(),this.info.autoReset===!0&&this.info.reset();let i=m.opaque,a=m.transmissive;if(h.setupLights(v._useLegacyLights),t.isArrayCamera){let r=t.cameras;if(a.length>0)for(let t=0,n=r.length;t0&&qe(i,a,e,t),n&&we.render(e),Ge(m,e,t);S!==null&&(pe.updateMultisampleRenderTarget(S),pe.updateRenderTargetMipmap(S)),e.isScene===!0&&e.onAfterRender(v,e,t),ke.resetDefaultState(),C=-1,w=null,_.pop(),_.length>0?(h=_[_.length-1],se===!0&&Se.setGlobalState(v.clippingPlanes,h.state.camera)):h=null,g.pop(),m=g.length>0?g[g.length-1]:null};function We(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)h.pushLight(e),e.castShadow&&h.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||oe.intersectsSprite(e)){r&&le.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ce);let t=ve.update(e),i=e.material;i.visible&&m.push(e,t,i,n,le.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||oe.intersectsObject(e))){let t=ve.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),le.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),le.copy(e.boundingSphere.center)),le.applyMatrix4(e.matrixWorld).applyMatrix4(ce)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Ye(i,t,n),a.length>0&&Ye(a,t,n),o.length>0&&Ye(o,t,n),L.buffers.depth.setTest(!0),L.buffers.depth.setMask(!0),L.buffers.color.setMask(!0),L.setPolygonOffset(!1)}function qe(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;h.state.transmissionRenderTarget[r.id]===void 0&&(h.state.transmissionRenderTarget[r.id]=new Pr(1,1,{generateMipmaps:!0,type:F.has(`EXT_color_buffer_half_float`)||F.has(`EXT_color_buffer_float`)?tt:Je,minFilter:Ke,samples:4,stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let a=h.state.transmissionRenderTarget[r.id],o=r.viewport||T;a.setSize(o.z,o.w);let s=v.getRenderTarget();v.setRenderTarget(a),v.getClearColor(O),k=v.getClearAlpha(),k<1&&v.setClearColor(16777215,.5),v.clear();let c=v.toneMapping;v.toneMapping=0;let l=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),h.setupLightsView(r),se===!0&&Se.setGlobalState(v.clippingPlanes,r),Ye(e,n,r),pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a),F.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(S===null||S.isXRRenderTarget===!0)&&(m=v.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,y=R.get(r),b=h.state.lights;if(se===!0&&(M===!0||e!==w)){let t=e===w&&r.id===C;Se.setState(r,e,t)}let x=!1;r.version===y.__version?y.needsLights&&y.lightsStateVersion!==b.state.version?x=!0:y.outputColorSpace===s?i.isBatchedMesh&&y.batching===!1||!i.isBatchedMesh&&y.batching===!0||i.isInstancedMesh&&y.instancing===!1||!i.isInstancedMesh&&y.instancing===!0||i.isSkinnedMesh&&y.skinning===!1||!i.isSkinnedMesh&&y.skinning===!0||i.isInstancedMesh&&y.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&y.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&y.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&y.instancingMorph===!1&&i.morphTexture!==null?x=!0:y.envMap===c?r.fog===!0&&y.fog!==a||y.numClippingPlanes!==void 0&&(y.numClippingPlanes!==Se.numPlanes||y.numIntersection!==Se.numIntersection)?x=!0:y.vertexAlphas===l&&y.vertexTangents===u&&y.morphTargets===d&&y.morphNormals===f&&y.morphColors===p&&y.toneMapping===m?y.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,y.__version=r.version);let T=y.currentProgram;x===!0&&(T=Ze(r,t,i));let E=!1,D=!1,O=!1,k=T.getUniforms(),ee=y.uniforms;if(L.useProgram(T.program)&&(E=!0,D=!0,O=!0),r.id!==C&&(C=r.id,D=!0),E||w!==e){k.setValue(P,`projectionMatrix`,e.projectionMatrix),k.setValue(P,`viewMatrix`,e.matrixWorldInverse);let t=k.map.cameraPosition;t!==void 0&&t.setValue(P,le.setFromMatrixPosition(e.matrixWorld)),I.logarithmicDepthBuffer&&k.setValue(P,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&k.setValue(P,`isOrthographic`,e.isOrthographicCamera===!0),w!==e&&(w=e,D=!0,O=!0)}if(i.isSkinnedMesh){k.setOptional(P,i,`bindMatrix`),k.setOptional(P,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),k.setValue(P,`boneTexture`,e.boneTexture,pe))}i.isBatchedMesh&&(k.setOptional(P,i,`batchingTexture`),k.setValue(P,`batchingTexture`,i._matricesTexture,pe));let A=n.morphAttributes;if((A.position!==void 0||A.normal!==void 0||A.color!==void 0)&&Te.update(i,n,T),(D||y.receiveShadow!==i.receiveShadow)&&(y.receiveShadow=i.receiveShadow,k.setValue(P,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(ee.envMap.value=c,ee.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),r.isMeshStandardMaterial&&r.envMap===null&&t.environment!==null&&(ee.envMapIntensity.value=t.environmentIntensity),D&&(k.setValue(P,`toneMappingExposure`,v.toneMappingExposure),y.needsLights&&nt(ee,O),a&&r.fog===!0&&z.refreshFogUniforms(ee,a),z.refreshMaterialUniforms(ee,r,ne,te,h.state.transmissionRenderTarget[e.id]),hc.upload(P,Qe(y),ee,pe)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(hc.upload(P,Qe(y),ee,pe),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&k.setValue(P,`center`,i.center),k.setValue(P,`modelViewMatrix`,i.modelViewMatrix),k.setValue(P,`normalMatrix`,i.normalMatrix),k.setValue(P,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&pe.useMultisampledRTT(e)===!1?R.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,T.copy(e.viewport),E.copy(e.scissor),D=e.scissorTest}else T.copy(re).multiplyScalar(ne).floor(),E.copy(ie).multiplyScalar(ne).floor(),D=ae;if(L.bindFramebuffer(P.FRAMEBUFFER,i)&&r&&L.drawBuffers(e,i),L.viewport(T),L.scissor(E),L.setScissorTest(D),a){let r=R.get(e.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=R.get(e.texture),i=t||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}C=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let s=R.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){L.bindFramebuffer(P.FRAMEBUFFER,s);try{let o=e.texture,s=o.format,c=o.type;if(!I.textureFormatReadable(s)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!I.textureTypeReadable(c)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&P.readPixels(t,n,r,i,Oe.convert(s),Oe.convert(c),a)}finally{let e=S===null?null:R.get(S).__webglFramebuffer;L.bindFramebuffer(P.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let r=2**-n,i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);pe.setTexture2D(t,0),P.copyTexSubImage2D(P.TEXTURE_2D,n,0,0,e.x,e.y,i,a),L.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){let i=t.image.width,a=t.image.height,o=Oe.convert(n.format),s=Oe.convert(n.type);pe.setTexture2D(n,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,n.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):P.texSubImage2D(P.TEXTURE_2D,r,e.x,e.y,o,s,t.image),r===0&&n.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),L.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){let a=e.max.x-e.min.x,o=e.max.y-e.min.y,s=e.max.z-e.min.z,c=Oe.convert(r.format),l=Oe.convert(r.type),u;if(r.isData3DTexture)pe.setTexture3D(r,0),u=P.TEXTURE_3D;else if(r.isDataArrayTexture||r.isCompressedArrayTexture)pe.setTexture2DArray(r,0),u=P.TEXTURE_2D_ARRAY;else{console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.`);return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,r.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,r.unpackAlignment);let d=P.getParameter(P.UNPACK_ROW_LENGTH),f=P.getParameter(P.UNPACK_IMAGE_HEIGHT),p=P.getParameter(P.UNPACK_SKIP_PIXELS),m=P.getParameter(P.UNPACK_SKIP_ROWS),h=P.getParameter(P.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[i]:n.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,g.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,g.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,e.min.x),P.pixelStorei(P.UNPACK_SKIP_ROWS,e.min.y),P.pixelStorei(P.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?P.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g.data):r.isCompressedArrayTexture?P.compressedTexSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,g.data):P.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g),P.pixelStorei(P.UNPACK_ROW_LENGTH,d),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,f),P.pixelStorei(P.UNPACK_SKIP_PIXELS,p),P.pixelStorei(P.UNPACK_SKIP_ROWS,m),P.pixelStorei(P.UNPACK_SKIP_IMAGES,h),i===0&&r.generateMipmaps&&P.generateMipmap(u),L.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?pe.setTextureCube(e,0):e.isData3DTexture?pe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?pe.setTexture2DArray(e,0):pe.setTexture2D(e,0),L.unbindTexture()},this.resetState=function(){b=0,x=0,S=null,L.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Nn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===`display-p3`?`display-p3`:`srgb`,t.unpackColorSpace=Sr.workingColorSpace===`display-p3-linear`?`display-p3`:`srgb`}get useLegacyLights(){return console.warn(`THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.`),this._useLegacyLights}set useLegacyLights(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}},Dl=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new G(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Ol=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new G(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},kl=class extends Vi{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new wi,this.environmentIntensity=1,this.environmentRotation=new wi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Al=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Cn,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return _r(`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 r=0,i=this.stride;re.far||t.push({distance:s,point:Fl.clone(),uv:Qi.getInterpolation(Fl,Vl,Hl,Ul,Wl,Gl,Kl,new H),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Jl(e,t,n,r,i,a){Rl.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?zl.copy(Rl):(zl.x=a*Rl.x-i*Rl.y,zl.y=i*Rl.x+a*Rl.y),e.copy(t),e.x+=zl.x,e.y+=zl.y,e.applyMatrix4(Bl)}var Yl=new U,Xl=new U,Zl=class extends Vi{constructor(){super(),this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e0){let n,r;for(n=1,r=t.length;n0){Yl.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(Yl);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Yl.setFromMatrixPosition(e.matrixWorld),Xl.setFromMatrixPosition(this.matrixWorld);let n=Yl.distanceTo(Xl)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r=n.length&&n.push({start:-1,count:-1,z:-1});let i=n[this.index];r.push(i),this.index++,i.start=e.start,i.count=e.count,i.z=t}reset(){this.list.length=0,this.index=0}},Tu=`batchId`,Eu=new W,Du=new W,Ou=new W,ku=new W,Au=new yo,ju=new Hr,Mu=new oi,Nu=new U,Pu=new wu,Fu=new Wa,Iu=[];function Lu(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a65536?new Uint32Array(i):new Uint16Array(i);t.setIndex(new K(e,1))}let a=r>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(Tu,new K(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Tu))throw Error(`BatchedMesh: Geometry cannot use attribute "${Tu}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(n===Tu)continue;if(!e.hasAttribute(n))throw Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hr);let e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},i=null,a=this._reservedRanges,o=this._drawRanges,s=this._bounds;this._geometryCount!==0&&(i=a[a.length-1]),r.vertexCount=t===-1?e.getAttribute(`position`).count:t,r.vertexStart=i===null?0:i.vertexStart+i.vertexCount;let c=e.getIndex(),l=c!==null;if(l&&(r.indexCount=n===-1?c.count:n,r.indexStart=i===null?0:i.indexStart+i.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw Error(`BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let u=this._visibility,d=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;u.push(!0),d.push(!0);let m=this._geometryCount;this._geometryCount++,Ou.toArray(p,m*16),f.needsUpdate=!0,a.push(r),o.push({start:l?r.indexStart:r.vertexStart,count:-1}),s.push({boxInitialized:!1,box:new Hr,sphereInitialized:!1,sphere:new oi});let h=this.geometry.getAttribute(Tu);for(let e=0;e=this._geometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw Error(`BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.vertexCount;for(let e in n.attributes){if(e===Tu)continue;let r=t.getAttribute(e),i=n.getAttribute(e);Lu(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let n=this._bounds[e],r=n.box,i=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();let t=i.index,a=i.attributes.position,o=this._drawRanges[e];for(let e=o.start,n=o.start+o.count;e=this._geometryCount||n[e]===!1?this:(t.toArray(i,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let n=this._active,r=this._matricesTexture.image.data;return e>=this._geometryCount||n[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let n=this._visibility,r=this._active;return e>=this._geometryCount||r[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,n=this._active;return e>=this._geometryCount||n[e]===!1?!1:t[e]}raycast(e,t){let n=this._visibility,r=this._active,i=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,s=this.geometry;Fu.material=this.material,Fu.geometry.index=s.index,Fu.geometry.attributes=s.attributes,Fu.geometry.boundingBox===null&&(Fu.geometry.boundingBox=new Hr),Fu.geometry.boundingSphere===null&&(Fu.geometry.boundingSphere=new oi);for(let s=0;s({...e})),this._reservedRanges=e._reservedRanges.map(e=>({...e})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=this._active,c=this._visibility,l=this._multiDrawStarts,u=this._multiDrawCounts,d=this._drawRanges,f=this.perObjectFrustumCulled;f&&(ku.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Au.setFromProjectionMatrix(ku,e.coordinateSystem));let p=0;if(this.sortObjects){Du.copy(this.matrixWorld).invert(),Nu.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Du);for(let e=0,t=c.length;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;Gu.applyMatrix4(e.matrixWorld);let s=t.ray.origin.distanceTo(Gu);if(!(st.far))return{distance:s,point:Ku.clone().applyMatrix4(e.matrixWorld),index:i,face:null,faceIndex:null,object:e}}var Yu=new U,Xu=new U,Zu=class extends qu{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}var od=class extends jr{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.minFilter=a===void 0?Ue:a,this.magFilter=i===void 0?Ue:i,this.generateMipmaps=!1;let l=this;function u(){l.needsUpdate=!0,e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},sd=class extends jr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=ze,this.minFilter=ze,this.generateMipmaps=!1,this.needsUpdate=!0}},cd=class extends jr{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},ld=class extends cd{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Le}},ud=class extends cd{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},dd=class extends jr{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},fd=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200}getPoint(){return console.warn(`THREE.Curve: .getPoint() not implemented.`),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new H:new U);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new U,r=[],i=[],a=[],o=new U,s=new W;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new U)}i[0]=new U,a[0]=new U;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(Vn(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(Vn(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},pd=class extends fd{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new H){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},md=class extends pd{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function hd(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var gd=new U,_d=new hd,vd=new hd,yd=new hd,bd=class extends fd{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new U){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(gd.subVectors(r[0],r[1]).add(r[0]),c=gd);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(xd(o,s.x,c.x,l.x,u.x),xd(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Vd=class e extends Y{constructor(e=[new H(0,-.5),new H(.5,0),new H(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type=`LatheGeometry`,this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Vn(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new U,d=new H,f=new U,p=new U,m=new U,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new q(u,3)),this.setAttribute(`normal`,new q(d,3)),this.setAttribute(`uv`,new q(f,2));function _(){let a=new U,_=new U,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let e=0;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new U,t=new U,n=new U,r=new U,o=new H,s=new H,c=new H;for(let l=0,u=0;l80*n){s=l=e[0],c=u=e[1];for(let t=n;tl&&(l=d),f>u&&(u=f);p=Math.max(l-s,u-c),p=p===0?0:32767/p}return rf(a,o,n,s,c,p,0),o}};function tf(e,t,n,r,i){let a,o;if(i===Mf(e,t,n,r)>0)for(a=t;a=t;a-=r)o=kf(a,e[a],e[a+1],o);return o&&xf(o,o.next)&&(Af(o),o=o.next),o}function nf(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(xf(n,n.next)||bf(n.prev,n,n.next)===0)){if(Af(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function rf(e,t,n,r,i,a,o){if(!e)return;!o&&a&&mf(e,r,i,a);let s=e,c,l;for(;e.prev!==e.next;){if(c=e.prev,l=e.next,a?of(e,r,i,a):af(e)){t.push(c.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Af(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=sf(nf(e),t,n),rf(e,t,n,r,i,a,2)):o===2&&cf(e,t,n,r,i,a):rf(nf(e),t,n,r,i,a,1);break}}}function af(e){let t=e.prev,n=e,r=e.next;if(bf(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=ia?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&vf(i,s,a,c,o,l,m.x,m.y)&&bf(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function of(e,t,n,r){let i=e.prev,a=e,o=e.next;if(bf(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=sc?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,_=gf(p,m,t,n,r),v=gf(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&vf(s,u,c,d,l,f,y.x,y.y)&&bf(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&vf(s,u,c,d,l,f,b.x,b.y)&&bf(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&vf(s,u,c,d,l,f,y.x,y.y)&&bf(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&vf(s,u,c,d,l,f,b.x,b.y)&&bf(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function sf(e,t,n){let r=e;do{let i=r.prev,a=r.next.next;!xf(i,a)&&Sf(i,r,r.next,a)&&Ef(i,a)&&Ef(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),Af(r),Af(r.next),r=e=a),r=r.next}while(r!==e);return nf(r)}function cf(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&yf(o,e)){let s=Of(o,e);o=nf(o,o.next),s=nf(s,s.next),rf(o,t,n,r,i,a,0),rf(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function lf(e,t,n,r){let i=[],a,o,s,c,l;for(a=0,o=t.length;a=n.next.y&&n.next.y!==n.y){let e=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=a&&e>r&&(r=e,i=n.x=n.x&&n.x>=c&&a!==n.x&&vf(oi.x||n.x===i.x&&pf(i,n)))&&(i=n,u=d)),n=n.next;while(n!==s);return i}function pf(e,t){return bf(e.prev,e,t.prev)<0&&bf(t.next,e,e.next)<0}function mf(e,t,n,r){let i=e;do i.z===0&&(i.z=gf(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,hf(i)}function hf(e){let t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function gf(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function _f(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function yf(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Tf(e,t)&&(Ef(e,t)&&Ef(t,e)&&Df(e,t)&&(bf(e.prev,e,t.prev)||bf(e,t.prev,t))||xf(e,t)&&bf(e.prev,e,e.next)>0&&bf(t.prev,t,t.next)>0)}function bf(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function xf(e,t){return e.x===t.x&&e.y===t.y}function Sf(e,t,n,r){let i=wf(bf(e,t,n)),a=wf(bf(e,t,r)),o=wf(bf(n,r,e)),s=wf(bf(n,r,t));return!!(i!==a&&o!==s||i===0&&Cf(e,n,t)||a===0&&Cf(e,r,t)||o===0&&Cf(n,e,r)||s===0&&Cf(n,t,r))}function Cf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function wf(e){return e>0?1:e<0?-1:0}function Tf(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Sf(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ef(e,t){return bf(e.prev,e,e.next)<0?bf(e,t,e.next)>=0&&bf(e,e.prev,t)>=0:bf(e,t,e.prev)<0||bf(e,e.next,t)<0}function Df(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Of(e,t){let n=new jf(e.i,e.x,e.y),r=new jf(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function kf(e,t,n,r){let i=new jf(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Af(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function jf(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Mf(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function Ff(e,t){for(let n=0;n2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new H(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new H(r/a,i/a)}let te=[];for(let e=0,t=E.length,n=t-1,r=e+1;e=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e0)&&f.push(t,i,c),(e!==n-1||s0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},np=class extends aa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new G(16777215),this.specular=new G(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new H(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new wi,this.combine=0,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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},rp=class extends aa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new G(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new H(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ip=class extends aa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new H(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},ap=class extends aa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new G(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new H(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new wi,this.combine=0,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.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.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}},op=class extends aa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new G(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new H(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:``},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},sp=class extends zu{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function cp(e,t,n){return!e||!n&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function lp(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function up(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function dp(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function fp(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push.apply(n,o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}function pp(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e=r)){c.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=e.resultBuffer.slice(t,n)}i===`quaternion`&&new zr().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&lp(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===tn,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};bp.prototype.TimeBufferType=Float32Array,bp.prototype.ValueBufferType=Float32Array,bp.prototype.DefaultInterpolation=en;var xp=class extends bp{};xp.prototype.ValueTypeName=`bool`,xp.prototype.ValueBufferType=Array,xp.prototype.DefaultInterpolation=$t,xp.prototype.InterpolantFactoryMethodLinear=void 0,xp.prototype.InterpolantFactoryMethodSmooth=void 0;var Sp=class extends bp{};Sp.prototype.ValueTypeName=`color`;var Cp=class extends bp{};Cp.prototype.ValueTypeName=`number`;var wp=class extends gp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)zr.slerpFlat(i,0,a,c-o,a,c,s);return i}},Tp=class extends bp{InterpolantFactoryMethodLinear(e){return new wp(this.times,this.values,this.getValueSize(),e)}};Tp.prototype.ValueTypeName=`quaternion`,Tp.prototype.DefaultInterpolation=en,Tp.prototype.InterpolantFactoryMethodSmooth=void 0;var Ep=class extends bp{};Ep.prototype.ValueTypeName=`string`,Ep.prototype.ValueBufferType=Array,Ep.prototype.DefaultInterpolation=$t,Ep.prototype.InterpolantFactoryMethodLinear=void 0,Ep.prototype.InterpolantFactoryMethodSmooth=void 0;var Dp=class extends bp{};Dp.prototype.ValueTypeName=`vector`;var Op=class{constructor(e=``,t=-1,n=[],r=on){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Bn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(Ap(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(bp.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error(`THREE.AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];fp(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e{t&&t(i),this.manager.itemEnd(e)},0),i;if(Fp[e]!==void 0){Fp[e].push({onLoad:t,onProgress:n,onError:r});return}Fp[e]=[],Fp[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&console.warn(`THREE.FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=Fp[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===void 0)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{jp.add(e,t);let n=Fp[e];delete Fp[e];for(let e=0,r=n.length;e{let n=Fp[e];if(n===void 0)throw this.manager.itemError(e),t;delete Fp[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Rp=class extends Pp{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new Lp(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n0:t.vertexColors),t.uniforms!==void 0)for(let e in t.uniforms){let n=t.uniforms[e];switch(i.uniforms[e]={},n.type){case`t`:i.uniforms[e].value=r(n.value);break;case`c`:i.uniforms[e].value=new G().setHex(n.value);break;case`v2`:i.uniforms[e].value=new H().fromArray(n.value);break;case`v3`:i.uniforms[e].value=new U().fromArray(n.value);break;case`v4`:i.uniforms[e].value=new Mr().fromArray(n.value);break;case`m3`:i.uniforms[e].value=new lr().fromArray(n.value);break;case`m4`:i.uniforms[e].value=new W().fromArray(n.value);break;default:i.uniforms[e].value=n.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let e in t.extensions)i.extensions[e]=t.extensions[e];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=r(t.map)),t.matcap!==void 0&&(i.matcap=r(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=r(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=r(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=r(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let e=t.normalScale;Array.isArray(e)===!1&&(e=[e,e]),i.normalScale=new H().fromArray(e)}return t.displacementMap!==void 0&&(i.displacementMap=r(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=r(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=r(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=r(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=r(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=r(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=r(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=r(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=r(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=r(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=r(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=r(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=r(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=r(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new H().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=r(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=r(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=r(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=r(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=r(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=r(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=r(t.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Qf,SpriteMaterial:Nl,RawShaderMaterial:$f,ShaderMaterial:to,PointsMaterial:$u,MeshPhysicalMaterial:tp,MeshStandardMaterial:ep,MeshPhongMaterial:np,MeshToonMaterial:rp,MeshNormalMaterial:ip,MeshLambertMaterial:ap,MeshDepthMaterial:ol,MeshDistanceMaterial:sl,MeshBasicMaterial:oa,MeshMatcapMaterial:op,LineDashedMaterial:sp,LineBasicMaterial:zu,Material:aa}[e]}},um=class{static decodeText(e){if(typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``;for(let n=0,r=e.length;n0){i=new Bp(new Mp(t)),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){r=new Bp(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t{let t=new Hr;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);let n=new oi;return n.radius=e.sphereRadius,n.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:n}}),a._maxGeometryCount=e.maxGeometryCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid);break;case`LOD`:a=new Zl;break;case`Line`:a=new qu(o(e.geometry),s(e.material));break;case`LineLoop`:a=new Qu(o(e.geometry),s(e.material));break;case`LineSegments`:a=new Zu(o(e.geometry),s(e.material));break;case`PointCloud`:case`Points`:a=new id(o(e.geometry),s(e.material));break;case`Sprite`:a=new ql(s(e.material));break;case`Group`:a=new hl;break;case`Bone`:a=new cu;break;default:a=new Vi}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix===void 0?(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)):(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let o=e.children;for(let e=0;e`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,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=jp.get(e);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{t&&t(n),i.manager.itemEnd(e)}).catch(e=>{r&&r(e)});return}return setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:`none`}))}).then(function(n){return jp.add(e,n),t&&t(n),i.manager.itemEnd(e),n}).catch(function(t){r&&r(t),jp.remove(e),i.manager.itemError(e),i.manager.itemEnd(e)});jp.add(e,s),i.manager.itemStart(e)}},vm,ym=class{static getContext(){return vm===void 0&&(vm=new(window.AudioContext||window.webkitAudioContext)),vm}static setContext(e){vm=e}},bm=class extends Pp{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new Lp(this.manager);a.setResponseType(`arraybuffer`),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{let n=e.slice(0);ym.getContext().decodeAudioData(n,function(e){t(e)}).catch(o)}catch(e){o(e)}},n,r);function o(t){r?r(t):console.error(t),i.manager.itemError(e)}}},xm=new W,Sm=new W,Cm=new W,wm=class{constructor(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new oo,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new oo,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Cm.copy(e.projectionMatrix);let n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(Rn*t.fov*.5)/t.zoom,a,o;Sm.elements[12]=-n,xm.elements[12]=n,a=-i*t.aspect+r,o=i*t.aspect+r,Cm.elements[0]=2*t.near/(o-a),Cm.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Cm),a=-i*t.aspect-r,o=i*t.aspect-r,Cm.elements[0]=2*t.near/(o-a),Cm.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Cm)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Sm),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(xm)}},Tm=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Em(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Em();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Em(){return(typeof performance>`u`?Date:performance).now()}var Dm=new U,Om=new zr,km=new U,Am=new U,jm=class extends Vi{constructor(){super(),this.type=`AudioListener`,this.context=ym.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Tm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter===null?this.gain.disconnect(this.context.destination):(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Dm,Om,km),Am.set(0,0,-1).applyQuaternion(Om),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Dm.x,e),t.positionY.linearRampToValueAtTime(Dm.y,e),t.positionZ.linearRampToValueAtTime(Dm.z,e),t.forwardX.linearRampToValueAtTime(Am.x,e),t.forwardY.linearRampToValueAtTime(Am.y,e),t.forwardZ.linearRampToValueAtTime(Am.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Dm.x,Dm.y,Dm.z),t.setOrientation(Am.x,Am.y,Am.z,n.x,n.y,n.z)}},Mm=class extends Vi{constructor(e){super(),this.type=`Audio`,this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType=`empty`,this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType=`audioNode`,this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaNode`,this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaStreamNode`,this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType=`buffer`,this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn(`THREE.Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress%=this.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){zr.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;zr.multiplyQuaternionsFlat(e,a,e,t,e,n),zr.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},Bm=`\\[\\]\\.:\\/`,Vm=RegExp(`[\\[\\]\\.:\\/]`,`g`),Hm=`[^\\[\\]\\.:\\/]`,Um=`[^`+Bm.replace(`\\.`,``)+`]`,Wm=`((?:WC+[\\/:])*)`.replace(`WC`,Hm),Gm=`(WCOD+)?`.replace(`WCOD`,Um),Km=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Hm),qm=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Hm),Jm=RegExp(`^`+Wm+Gm+Km+qm+`$`),Ym=[`material`,`materials`,`bones`,`map`],Xm=class{constructor(e,t,n){let r=n||Zm.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Zm=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(Vm,``)}static parseTrackName(e){let t=Jm.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);Ym.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw 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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0){if(delete t[s],c0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}}this.nCachedObjects_=i}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new Zm(r,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}},$m=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:nn,endingEnd:nn};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Zt,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let r=(e-i)*n;r<0||n===0?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case sn:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case on:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===Qt;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=rn,r.endingEnd=rn):(r.endingStart=e?this.zeroSlopeAtStart?rn:nn:an,r.endingEnd=t?this.zeroSlopeAtEnd?rn:nn:an)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},eh=new Float32Array(1),th=class extends Fn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new zm(Zm.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}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}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))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ph).distanceTo(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}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)}},hh=new U,gh=new U,_h=class{constructor(e=new U,t=new U){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){hh.subVectors(e,this.start),gh.subVectors(this.end,this.start);let n=gh.dot(gh),r=gh.dot(hh)/n;return t&&(r=Vn(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).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)}},vh=new U,yh=class extends Vi{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type=`SpotLightHelper`;let n=new Y,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){let n=e/32*Math.PI*2,i=t/32*Math.PI*2;r.push(Math.cos(n),Math.sin(n),1,Math.cos(i),Math.sin(i),1)}n.setAttribute(`position`,new q(r,3));let i=new zu({fog:!1,toneMapped:!1});this.cone=new Zu(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),vh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(vh),this.color===void 0?this.cone.material.color.copy(this.light.color):this.cone.material.color.set(this.color)}},bh=new U,xh=new W,Sh=new W,Ch=class extends Zu{constructor(e){let t=wh(e),n=new Y,r=[],i=[],a=new G(0,0,1),o=new G(0,1,0);for(let e=0;e1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Wh.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Wh,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Jh=class extends Zu{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Y;r.setAttribute(`position`,new q(t,3)),r.setAttribute(`color`,new q(n,3));let i=new zu({vertexColors:!0,toneMapped:!1});super(r,i),this.type=`AxesHelper`}setColors(e,t,n){let r=new G,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Yh=class{constructor(){this.type=`ShapePath`,this.color=new G,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Bd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e){let t=[];for(let n=0,r=e.length;n2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.yo.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=c*(e.x-n.x)-s*(e.y-n.y);if(t===0)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}let r=Nf.isClockWise,i=this.subPaths;if(i.length===0)return[];let a,o,s,c=[];if(i.length===1)return o=i[0],s=new $d,s.curves=o.curves,c.push(s),c;let l=!r(i[0].getPoints());l=e?!l:l;let u=[],d=[],f=[],p=0,m;d[p]=void 0,f[p]=[];for(let t=0,n=i.length;t1){let e=!1,t=0;for(let e=0,t=d.length;e0&&e===!1&&(f=u)}let h;for(let e=0,t=d.length;e{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Qh=n(((e,t)=>{t.exports=Zh()})),$h=n((e=>{var t=r(),n=Qh();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),eg=e(n(((e,t)=>{t.exports=$h()}))(),1),tg=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ng=(e=>e?tg(e):tg),{useSyncExternalStoreWithSelector:rg}=eg.default,ig=e=>e;function ag(e,t=ig,n){let r=rg(e.subscribe,e.getState,e.getInitialState,t,n);return F.useDebugValue(r),r}var og=(e,t)=>{let n=ng(e),r=(e,r=t)=>ag(n,e,r);return Object.assign(r,n),r},sg=((e,t)=>e?og(e,t):og),cg=e(s());typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?F.useLayoutEffect:F.useEffect;function lg(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=lg(r,t,n);if(e)return e;r=t?null:r.sibling}}function ug(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var dg=ug(F.createContext(null)),fg=class extends F.Component{render(){return F.createElement(dg.Provider,{value:this._reactInternals},this.props.children)}};function pg(){let e=F.useContext(dg);if(e===null)throw Error(`its-fine: useFiber must be called within a !`);let t=F.useId();return F.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=lg(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var mg=Symbol.for(`react.context`),hg=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===mg;function gg(){let e=pg(),[t]=F.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;hg(e)&&e!==dg&&!t.has(e)&&t.set(e,F.use(ug(e))),n=n.return}return t}function _g(){let e=gg();return F.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>F.createElement(t,null,F.createElement(n.Provider,{...r,value:e.get(n)})),e=>F.createElement(fg,{...e})),[e])}function vg(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}var yg=e=>e&&e.isOrthographicCamera,bg=e=>e&&e.hasOwnProperty(`current`),xg=e=>e!=null&&(typeof e==`string`||typeof e==`number`||e.isColor),Sg=((e,t)=>typeof window<`u`&&((e=window.document)?.createElement||(t=window.navigator)?.product===`ReactNative`))()?F.useLayoutEffect:F.useEffect;function Cg(e){let t=F.useRef(e);return Sg(()=>void(t.current=e),[e]),t}function wg(){let e=pg(),t=_g();return F.useMemo(()=>({children:n})=>{let r=lg(e,!0,e=>e.type===F.StrictMode)?F.StrictMode:F.Fragment;return(0,I.jsx)(r,{children:(0,I.jsx)(t,{children:n})})},[e,t])}function Tg({set:e}){return Sg(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}var Eg=(e=>(e=class extends F.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}},e.getDerivedStateFromError=()=>({error:!0}),e))();function Dg(e){let t=typeof window<`u`?window.devicePixelRatio??2:1;return Array.isArray(e)?Math.min(Math.max(e[0],t),e[1]):e}function Og(e){return e.__r3f?.root.getState()}var kg={obj:e=>e===Object(e)&&!kg.arr(e)&&typeof e!=`function`,fun:e=>typeof e==`function`,str:e=>typeof e==`string`,num:e=>typeof e==`number`,boo:e=>typeof e==`boolean`,und:e=>e===void 0,nul:e=>e===null,arr:e=>Array.isArray(e),equ(e,t,{arrays:n=`shallow`,objects:r=`reference`,strict:i=!0}={}){if(typeof e!=typeof t||!!e!=!!t)return!1;if(kg.str(e)||kg.num(e)||kg.boo(e))return e===t;let a=kg.obj(e);if(a&&r===`reference`)return e===t;let o=kg.arr(e);if(o&&n===`reference`)return e===t;if((o||a)&&e===t)return!0;let s;for(s in e)if(!(s in t))return!1;if(a&&n===`shallow`&&r===`shallow`){for(s in i?t:e)if(!kg.equ(e[s],t[s],{strict:i,objects:`reference`}))return!1}else for(s in i?t:e)if(e[s]!==t[s])return!1;if(kg.und(s)){if(o&&e.length===0&&t.length===0||a&&Object.keys(e).length===0&&Object.keys(t).length===0)return!0;if(e!==t)return!1}return!0}};function Ag(e){e.type!==`Scene`&&(e.dispose==null||e.dispose());for(let t in e){let n=e[t];n?.type!==`Scene`&&(n==null||n.dispose==null||n.dispose())}}var jg=[`children`,`key`,`ref`];function Mg(e){let t={};for(let n in e)jg.includes(n)||(t[n]=e[n]);return t}function Ng(e,t,n,r){let i=e,a=i?.__r3f;return a||(a={root:t,type:n,parent:null,children:[],props:Mg(r),object:i,eventCount:0,handlers:{},isHidden:!1},i&&(i.__r3f=a)),a}function Pg(e,t){if(!t.includes(`-`)||t in e)return{root:e,key:t,target:e[t]};let n=e,r=t.split(`-`);for(let i of r){if(typeof n!=`object`||!n){if(n!==void 0){let e=r.slice(r.indexOf(i)).join(`-`);return{root:n,key:e,target:void 0}}return{root:e,key:t,target:void 0}}t=i,e=n,n=n[t]}return{root:e,key:t,target:n}}var Fg=/-\d+$/;function Ig(e,t){if(kg.str(t.props.attach)){if(Fg.test(t.props.attach)){let n=t.props.attach.replace(Fg,``),{root:r,key:i}=Pg(e.object,n);Array.isArray(r[i])||(r[i]=[])}let{root:n,key:r}=Pg(e.object,t.props.attach);t.previousAttach=n[r],n[r]=t.object}else kg.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function Lg(e,t){if(kg.str(t.props.attach)){let{root:n,key:r}=Pg(e.object,t.props.attach),i=t.previousAttach;i===void 0?delete n[r]:n[r]=i}else t.previousAttach==null||t.previousAttach(e.object,t.object);delete t.previousAttach}var Rg=[...jg,`args`,`dispose`,`attach`,`object`,`onUpdate`,`dispose`],zg=new Map;function Bg(e){let t=zg.get(e.constructor);try{t||(t=new e.constructor,zg.set(e.constructor,t))}catch{}return t}function Vg(e,t){let n={};for(let r in t)if(!Rg.includes(r)&&!kg.equ(t[r],e.props[r])){n[r]=t[r];for(let e in t)e.startsWith(`${r}-`)&&(n[e]=t[e])}for(let r in e.props){if(Rg.includes(r)||t.hasOwnProperty(r))continue;let{root:i,key:a}=Pg(e.object,r);if(i.constructor&&i.constructor.length===0){let e=Bg(i);kg.und(e)||(n[r]=e[a])}else n[r]=0}return n}var Hg=[`map`,`emissiveMap`,`sheenColorMap`,`specularColorMap`,`envMap`],Ug=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Wg(e,t){var n;let r=e.__r3f,i=r&&vg(r).getState(),a=r?.eventCount;for(let n in t){let a=t[n];if(Rg.includes(n))continue;if(r&&Ug.test(n)){typeof a==`function`?r.handlers[n]=a:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(a===void 0)continue;let{root:s,key:c,target:l}=Pg(e,n);if(l===void 0&&(typeof s!=`object`||!s))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${c}".`);if(l instanceof Ti&&a instanceof Ti)l.mask=a.mask;else if(l instanceof G&&xg(a))l.set(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof l.copy==`function`&&a!=null&&a.constructor&&l.constructor===a.constructor)l.copy(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&Array.isArray(a))typeof l.fromArray==`function`?l.fromArray(a):l.set(...a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof a==`number`)typeof l.setScalar==`function`?l.setScalar(a):l.set(a);else if(s instanceof to&&c===`uniforms`&&kg.obj(a)){kg.obj(s.uniforms)||(s.uniforms={});let e=s.uniforms,t=a;for(let n in t){let r=t[n],i=e[n];i?Object.assign(i,r):e[n]={...r}}}else{var o;s[c]=a,i&&!i.linear&&Hg.includes(c)&&(o=s[c])!=null&&o.isTexture&&s[c].format===1023&&s[c].type===1009&&(s[c].colorSpace=un)}}if(r!=null&&r.parent&&i!=null&&i.internal&&(n=r.object)!=null&&n.isObject3D&&a!==r.eventCount){let e=r.object,t=i.internal.interaction.indexOf(e);t>-1&&i.internal.interaction.splice(t,1),r.eventCount&&e.raycast!==null&&i.internal.interaction.push(e)}return r&&r.props.attach===void 0&&(r.object.isBufferGeometry?r.props.attach=`geometry`:r.object.isMaterial&&(r.props.attach=`material`)),r&&Gg(r),e}function Gg(e){var t;if(!e.parent)return;e.props.onUpdate==null||e.props.onUpdate(e.object);let n=(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function Kg(e,t){e.manual||(yg(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix())}var qg=e=>e?.isObject3D;function Jg(e){return(e.eventObject||e.object).uuid+`/`+e.index+e.instanceId}function Yg(e,t,n,r){let i=n.get(t);i&&(n.delete(t),n.size===0&&(e.delete(r),i.target.releasePointerCapture(r)))}function Xg(e,t,n){let{internal:r}=e.getState();for(let e=0;e{if(e.eventObject===t||e.object===t){r.hovered.delete(i);let a={...e,eventObject:e.eventObject===t?n:e.eventObject,object:e.object===t?n:e.object};r.hovered.set(Jg(a),a)}}),r.capturedMap.forEach(e=>{let r=e.get(t);r&&(e.delete(t),e.set(n,r))})}function Zg(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,r)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(r)}),n.capturedMap.forEach((e,r)=>{Yg(n.capturedMap,t,e,r)})}function Qg(e){function t(t){let{internal:n}=e.getState(),r=t.offsetX-n.initialClick[0],i=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(r*r+i*i))}function n(e){return e.filter(e=>[`Move`,`Over`,`Enter`,`Out`,`Leave`].some(t=>e.__r3f?.handlers[`onPointer`+t]))}function r(t,n){let r=e.getState(),i=new Set,a=[],o=n?n(r.internal.interaction):r.internal.interaction;for(let e=0;e{let n=Og(e.object),r=Og(t.object);return!n||!r?e.distance-t.distance:r.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=Jg(e);return!i.has(t)&&(i.add(t),!0)});r.events.filter&&(c=r.events.filter(c,r));for(let e of c){let t=e.object;for(;t;){var l;(l=t.__r3f)!=null&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if(`pointerId`in t&&r.internal.capturedMap.has(t.pointerId))for(let e of r.internal.capturedMap.get(t.pointerId).values())i.has(Jg(e.intersection))||a.push(e.intersection);return a}function i(e,t,n,r){if(e.length){let i={stopped:!1};for(let o of e){let s=Og(o.object);if(s||o.object.traverseAncestors(e=>{let t=Og(e);if(t)return s=t,!1}),s){let{raycaster:c,pointer:l,camera:u,internal:d}=s,f=new U(l.x,l.y,0).unproject(u),p=e=>d.capturedMap.get(e)?.has(o.eventObject)??!1,m=e=>{let n={intersection:o,target:t.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,n):d.capturedMap.set(e,new Map([[o.eventObject,n]])),t.target.setPointerCapture(e)},h=e=>{let t=d.capturedMap.get(e);t&&Yg(d.capturedMap,o.eventObject,t,e)},g={};for(let e in t){let n=t[e];typeof n!=`function`&&(g[e]=n)}let _={...o,...g,pointer:l,intersections:e,stopped:i.stopped,delta:n,unprojectedPoint:f,ray:c.ray,camera:u,stopPropagation(){let n=`pointerId`in t&&d.capturedMap.get(t.pointerId);(!n||n.has(o.eventObject))&&(_.stopped=i.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(e=>e.eventObject===o.eventObject)&&a([...e.slice(0,e.indexOf(o)),o]))},target:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},currentTarget:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},nativeEvent:t};if(r(_),i.stopped===!0)break}}}return e}function a(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let r=e.eventObject.__r3f;if(n.hovered.delete(Jg(e)),r!=null&&r.eventCount){let n=r.handlers,i={...e,intersections:t};n.onPointerOut==null||n.onPointerOut(i),n.onPointerLeave==null||n.onPointerLeave(i)}}}function o(e,t){for(let n=0;na([]);case`onLostPointerCapture`:return t=>{let{internal:n}=e.getState();`pointerId`in t&&n.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),a([]))})}}return function(c){let{onPointerMissed:l,internal:u}=e.getState();u.lastEvent.current=c;let d=s===`onPointerMove`,f=s===`onClick`||s===`onContextMenu`||s===`onDoubleClick`,p=r(c,d?n:void 0),m=f?t(c):0;s===`onPointerDown`&&(u.initialClick=[c.offsetX,c.offsetY],u.initialHits=p.map(e=>e.eventObject)),f&&!p.length&&m<=2&&(o(c,u.interaction),l&&l(c)),d&&a(p);function h(e){let t=e.eventObject,n=t.__r3f;if(!(n!=null&&n.eventCount))return;let r=n.handlers;if(d){if(r.onPointerOver||r.onPointerEnter||r.onPointerOut||r.onPointerLeave){let t=Jg(e),n=u.hovered.get(t);n?n.stopped&&e.stopPropagation():(u.hovered.set(t,e),r.onPointerOver==null||r.onPointerOver(e),r.onPointerEnter==null||r.onPointerEnter(e))}r.onPointerMove==null||r.onPointerMove(e)}else{let n=r[s];n?(!f||u.initialHits.includes(t))&&(o(c,u.interaction.filter(e=>!u.initialHits.includes(e))),n(e)):f&&u.initialHits.includes(t)&&o(c,u.interaction.filter(e=>!u.initialHits.includes(e)))}}i(p,c,m,h)}}return{handlePointer:s}}var $g=e=>!!(e!=null&&e.render),e_=F.createContext(null),t_=(e,t)=>{let n=sg((n,r)=>{let i=new U,a=new U,o=new U;function s(e=r().camera,t=a,n=r().size){let{width:s,height:c,top:l,left:u}=n,d=s/c;t.isVector3?o.copy(t):o.set(...t);let f=e.getWorldPosition(i).distanceTo(o);if(yg(e))return{width:s/e.zoom,height:c/e.zoom,top:l,left:u,factor:1,distance:f,aspect:d};{let t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*f,r=s/c*n;return{width:r,height:n,top:l,left:u,factor:s/r,distance:f,aspect:d}}}let c,l=e=>n(t=>({performance:{...t.performance,current:e}})),u=new H;return{set:n,get:r,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(t=1)=>e(r(),t),advance:(e,n)=>t(e,n,r()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Tm,pointer:u,mouse:u,frameloop:`always`,onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=r();c&&clearTimeout(c),e.performance.current!==e.performance.min&&l(e.performance.min),c=setTimeout(()=>l(r().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:e=>n(t=>({...t,events:{...t.events,...e}})),setSize:(e,t,i=0,o=0)=>{let c=r().camera,l={width:e,height:t,top:i,left:o};n(e=>({size:l,viewport:{...e.viewport,...s(c,a,l)}}))},setDpr:e=>n(t=>{let n=Dg(e);return{viewport:{...t.viewport,dpr:n,initialDpr:t.viewport.initialDpr||n}}}),setFrameloop:(e=`always`)=>{let t=r().clock;t.stop(),t.elapsedTime=0,e!==`never`&&(t.start(),t.elapsedTime=0),n(()=>({frameloop:e}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:F.createRef(),active:!1,frames:0,priority:0,subscribe:(e,t,n)=>{let i=r().internal;return i.priority+=+(t>0),i.subscribers.push({ref:e,priority:t,store:n}),i.subscribers=i.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let n=r().internal;n!=null&&n.subscribers&&(n.priority-=+(t>0),n.subscribers=n.subscribers.filter(t=>t.ref!==e))}}}}}),r=n.getState(),i=r.size,a=r.viewport.dpr,o=r.camera;return n.subscribe(()=>{let{camera:e,size:t,viewport:r,gl:s,set:c}=n.getState();if(t.width!==i.width||t.height!==i.height||r.dpr!==a){i=t,a=r.dpr,Kg(e,t),r.dpr>0&&s.setPixelRatio(r.dpr);let n=typeof HTMLCanvasElement<`u`&&s.domElement instanceof HTMLCanvasElement;s.setSize(t.width,t.height,n)}e!==o&&(o=e,c(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),n.subscribe(t=>e(t)),n};function n_(){let e=F.useContext(e_);if(!e)throw Error(`R3F: Hooks can only be used within the Canvas component!`);return e}function r_(e=e=>e,t){return n_()(e,t)}function i_(e,t=0){let n=n_(),r=n.getState().internal.subscribe,i=Cg(e);return Sg(()=>r(i,t,n),[t,r,n]),null}var a_=1,o_=8,s_=32,c_=2,l_=268435456,u_={name:`@react-three/fiber`,version:`9.7.0`,description:`A React renderer for Threejs`,keywords:[`react`,`renderer`,`fiber`,`three`,`threejs`],author:`Paul Henschel (https://github.com/drcmda)`,license:`MIT`,maintainers:[`Josh Ellis (https://github.com/joshuaellis)`,`Cody Bennett (https://github.com/codyjasonbennett)`,`Kris Baumgarter (https://github.com/krispya)`],bugs:{url:`https://github.com/pmndrs/react-three-fiber/issues`},homepage:`https://github.com/pmndrs/react-three-fiber#readme`,repository:{type:`git`,url:`git+https://github.com/pmndrs/react-three-fiber.git`},collective:{type:`opencollective`,url:`https://opencollective.com/react-three-fiber`},main:`dist/react-three-fiber.cjs.js`,module:`dist/react-three-fiber.esm.js`,types:`dist/react-three-fiber.cjs.d.ts`,"react-native":`native/dist/react-three-fiber-native.cjs.js`,sideEffects:!1,preconstruct:{entrypoints:[`index.tsx`,`native.tsx`]},scripts:{prebuild:`cp ../../readme.md readme.md`},devDependencies:{"@types/react-reconciler":`^0.32.3`,"react-reconciler":`^0.33.0`},dependencies:{"@babel/runtime":`^7.17.8`,"@types/webxr":`*`,"base64-js":`^1.5.1`,buffer:`^6.0.3`,"its-fine":`^2.0.0`,"react-use-measure":`^2.1.7`,scheduler:`^0.27.0`,"suspend-react":`^0.1.3`,"use-sync-external-store":`^1.4.0`,zustand:`^5.0.3`},peerDependencies:{expo:`>=43.0`,"expo-asset":`>=8.4`,"expo-file-system":`>=11.0`,"expo-gl":`>=11.0`,react:`>=19 <19.3`,"react-dom":`>=19 <19.3`,"react-native":`>=0.78`,three:`>=0.156`},peerDependenciesMeta:{"react-dom":{optional:!0},"react-native":{optional:!0},expo:{optional:!0},"expo-asset":{optional:!0},"expo-file-system":{optional:!0},"expo-gl":{optional:!0}}};function d_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var f_={exports:{}},p_={exports:{}};p_.exports;var m_;function h_(){return m_||(m_=1,function(e){e.exports=function(e){function t(e,t,n,r){return new la(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1sc||(e.current=oc[sc],oc[sc]=null,sc--)}function p(e,t){sc++,oc[sc]=e.current,e.current=t}function m(e){return e>>>=0,e===0?32:31-(uc(e)/dc|0)|0}function h(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function g(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=h(n))):i=h(o):i=h(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=h(n))):i=h(o)):i=h(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function _(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function v(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function y(){var e=mc;return mc<<=1,!(mc&62914560)&&(mc=4194304),e}function b(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function x(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function S(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Nc=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ee(n):``}function ne(e,t){switch(e.tag){case 26:case 27:case 5:return ee(e.type);case 16:return ee(`Lazy`);case 13:return e.child!==t&&t!==null?ee(`Suspense Fallback`):ee(`Suspense`);case 19:return ee(`SuspenseList`);case 0:case 15:return te(e.type,!1);case 11:return te(e.type.render,!1);case 1:return te(e.type,!0);case 31:return ee(`Activity`);default:return``}}function A(e){try{var t=``,n=null;do t+=ne(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}function j(e,t){if(typeof e==`object`&&e){var n=Pc.get(e);return n===void 0?(t={value:e,source:t,stack:A(t)},Pc.set(e,t),t):n}return{value:e,source:t,stack:A(t)}}function re(e,t){Fc[Ic++]=Rc,Fc[Ic++]=Lc,Lc=e,Rc=t}function ie(e,t,n){zc[Bc++]=Hc,zc[Bc++]=Uc,zc[Bc++]=Vc,Vc=e;var r=Hc;e=Uc;var i=32-lc(r)-1;r&=~(1<>=o,i-=o,Hc=1<<32-lc(t)+i|n<f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),Xc&&re(t,f),l;if(d===null){for(;fp?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),Xc&&re(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return Xc&&re(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&v.alternate!==null&&f.delete(v.key===null?p:v.key),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),Xc&&re(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===Oa&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case Da:e:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===Oa){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),s.return=e,e=s;break e}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===La&&He(u)===t.type){i(e,t.sibling),s=o(t,a.props),Ke(s,a),s.return=e,e=s;break e}i(e,t);break}n(e,t),t=t.sibling}a.type===Oa?(s=K(a.props.children,e.mode,s,a.key),s.return=e,e=s):(s=pa(a.type,a.key,a.props,null,e.mode,s),Ke(s,a),s.return=e,e=s)}return c(e);case Y:e:{for(u=a.key;t!==null;){if(t.key===u){if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break e}i(e,t);break}n(e,t),t=t.sibling}s=ga(a,e.mode,s),s.return=e,e=s}return c(e);case La:return a=He(a),y(e,t,a,s)}if(Ha(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,Ge(a),s);if(a.$$typeof===Ma)return y(e,t,be(e,a),s);qe(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=ma(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{Tl=0;var a=y(e,n,r,i);return wl=null,a}catch(n){if(n===yl||n===xl)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function Ye(){for(var e=kl,t=Al=kl=0;ta?a:8);var o=X.T,s={};X.T=s,jn(e,!1,t,n);try{var c=i(),l=X.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?An(e,t,Ie(c,r),Ti(e)):An(e,t,r,Ti(e))}catch(n){An(e,t,{then:function(){},status:`rejected`,reason:n},Ti())}finally{fo(a),o!==null&&s.types!==null&&(o.types=s.types),X.T=o}}function Cn(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:Z},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function wn(){return z(wo)}function Tn(){return At().memoizedState}function En(){return At().memoizedState}function Dn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ti();e=rt(n);var r=it(t,e,n);r!==null&&(Di(r,t,n),at(r,t,n)),t={cache:Se()},e.payload=t;return}t=t.return}}function On(e,t,n){var r=Ti();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Mn(e)?Nn(t,n):(n=Ze(e,t,n,r),n!==null&&(Di(n,e,r),Pn(n,t,r)))}function kn(e,t,n){An(e,t,n,Ti())}function An(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Mn(e))Nn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Oc(s,o))return Xe(e,t,i,0),xu===null&&Ye(),!1}catch{}if(n=Ze(e,t,i,r),n!==null)return Di(n,e,r),Pn(n,t,r),!0}return!1}function jn(e,t,n,i){if(i={lane:2,revertLane:Ne(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Mn(e)){if(t)throw Error(r(479))}else t=Ze(e,n,i,2),t!==null&&Di(t,e,2)}function Mn(e){var t=e.alternate;return e===zl||t!==null&&t===zl}function Nn(e,t){Ul=Hl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Pn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,w(e,n)}}function Fn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ta({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function In(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!B(n,r)||!B(i,a):!0}function Ln(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&$l.enqueueReplaceState(t,t.state,null)}function Rn(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=Ta({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Bn(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Vn(e,t,n){return n=rt(n),n.tag=3,n.payload={element:null},n.callback=function(){zn(e,t)},n}function Hn(e){return e=rt(e),e.tag=3,e}function Un(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Bn(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Bn(t,n,r),typeof i!=`function`&&(Uu===null?Uu=new Set([this]):Uu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Wn(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&_e(t,n,a,!0),n=Fl.current,n!==null){switch(n.tag){case 31:case 13:return Il===null?zi():n.alternate===null&&Au===0&&(Au=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===Sl?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),ra(e,i,a)),!1;case 22:return n.flags|=65536,i===Sl?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),ra(e,i,a)),!1}throw Error(r(435,n.tag))}return ra(e,i,a),zi(),!1}if(Xc)return t=Fl.current,t===null?(i!==$c&&(t=Error(r(423),{cause:i}),R(j(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=j(i,n),a=Vn(e.stateNode,i,a),ot(e,a),Au!==4&&(Au=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==$c&&(e=Error(r(422),{cause:i}),R(j(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=j(o,n),Iu===null?Iu=[o]:Iu.push(o),Au!==4&&(Au=2),t===null)return!0;i=j(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Vn(n.stateNode,i,e),ot(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Uu===null||!Uu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Hn(a),Un(a,e,n,i),ot(n,a),!1}n=n.return}while(n!==null);return!1}function Gn(e,t,n,r){t.child=e===null?Dl(t,null,n,r):El(t,e.child,n,r)}function Kn(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ye(t),r=St(e,t,n,o,a,i),s=Et(),e!==null&&!tu?(Dt(e,t,i),mr(e,t,i)):(Xc&&s&&ae(t),t.flags|=1,Gn(e,t,r,i),t.child)}function qn(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ua(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Jn(e,t,a,r,i)):(e=pa(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!hr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?B:n,n(o,r)&&e.ref===t.ref)return mr(e,t,i)}return t.flags|=1,e=da(a,r),e.ref=t.ref,e.return=t,t.child=e}function Jn(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(B(a,r)&&e.ref===t.ref){if(tu=!1,t.pendingProps=r=a,hr(e,i))e.flags&131072&&(tu=!0);else return t.lanes=e.lanes,mr(e,t,i)}}return nr(e,t,n,r,i)}function Yn(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Zn(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Re(t,a===null?null:a.cachePool),a===null?ft():dt(t,a),gt(t);else return r=t.lanes=536870912,Zn(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Re(t,null),ft(),_t()):(Re(t,a.cachePool),dt(t,a),_t(),t.memoizedState=null);return Gn(e,t,i,n),t.child}function Xn(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Zn(e,t,n,r,i){var a=Le();return a=a===null?null:{parent:ao?ol._currentValue:ol._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Re(t,null),ft(),gt(t),e!==null&&_e(e,t,r,!0),t.childLanes=i,null}function Qn(e,t){return t=lr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function $n(e,t,n){return El(t,e.child,null,n),e=Qn(t,t.pendingProps),e.flags|=2,vt(t),t.memoizedState=null,e}function er(e,t,n){var i=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(Xc){if(i.mode===`hidden`)return e=Qn(t,i),t.lanes=536870912,Xn(null,e);if(ht(t),(e=Yc)?(e=ys(e,Qc),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Vc===null?null:{id:Hc,overflow:Uc},retryLane:536870912,hydrationErrors:null},n=ha(e),n.return=t,t.child=n,Jc=t,Yc=null)):e=null,e===null)throw ue(t);return t.lanes=536870912,null}return Qn(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(ht(t),a){if(t.flags&256)t.flags&=-257,t=$n(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558))}else if(tu||_e(e,t,n,!1),a=(n&e.childLanes)!==0,tu||a){if(i=xu,i!==null&&(s=T(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Qe(e,s),Di(i,e,s),eu;zi(),t=$n(e,t,n)}else e=o.treeContext,co&&(Yc=ms(s),Jc=t,Xc=!0,Zc=null,Qc=!1,e!==null&&se(t,e)),t=Qn(t,i),t.flags|=4096;return t}return e=da(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function tr(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function nr(e,t,n,r,i){return ye(t),n=St(e,t,n,r,void 0,i),r=Et(),e!==null&&!tu?(Dt(e,t,i),mr(e,t,i)):(Xc&&r&&ae(t),t.flags|=1,Gn(e,t,n,i),t.child)}function rr(e,t,n,r,i,a){return ye(t),t.updateQueue=null,n=wt(t,r,n,i),Ct(e),r=Et(),e!==null&&!tu?(Dt(e,t,a),mr(e,t,a)):(Xc&&r&&ae(t),t.flags|=1,Gn(e,t,n,a),t.child)}function ir(e,t,n,r,i){if(ye(t),t.stateNode===null){var a=cc,o=n.contextType;typeof o==`object`&&o&&(a=z(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=$l,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},tt(t),o=n.contextType,a.context=typeof o==`object`&&o?z(o):cc,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Fn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&$l.enqueueReplaceState(a,a.state,null),ct(t,r,a,i),st(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rn(n,s);a.props=c;var l=a.context,u=n.contextType;o=cc,typeof u==`object`&&u&&(o=z(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ln(t,a,r,o),jl=!1;var f=t.memoizedState;a.state=f,ct(t,r,a,i),st(),l=t.memoizedState,s||f!==l||jl?(typeof d==`function`&&(Fn(t,n,d,r),l=t.memoizedState),(c=jl||In(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,nt(e,t),o=t.memoizedProps,u=Rn(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=cc,typeof l==`object`&&l&&(c=z(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ln(t,a,r,c),jl=!1,f=t.memoizedState,a.state=f,ct(t,r,a,i),st();var p=t.memoizedState;o!==d||f!==p||jl||e!==null&&e.dependencies!==null&&ve(e.dependencies)?(typeof s==`function`&&(Fn(t,n,s,r),p=t.memoizedState),(u=jl||In(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ve(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,tr(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=El(t,e.child,null,i),t.child=El(t,null,n,i)):Gn(e,t,n,i),t.memoizedState=a.state,e=t.child):e=mr(e,t,i),e}function ar(e,t,n,r){return L(),t.flags|=256,Gn(e,t,n,r),t.child}function or(e){return{baseLanes:e,cachePool:ze()}}function sr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Pu),e}function cr(e,t,n){var i=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(Ll.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(Xc){if(a?mt(t):_t(),(e=Yc)?(e=bs(e,Qc),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Vc===null?null:{id:Hc,overflow:Uc},retryLane:536870912,hydrationErrors:null},n=ha(e),n.return=t,t.child=n,Jc=t,Yc=null)):e=null,e===null)throw ue(t);return as(e)?t.lanes=32:t.lanes=536870912,null}var c=i.children;return i=i.fallback,a?(_t(),a=t.mode,c=lr({mode:`hidden`,children:c},a),i=K(i,a,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,i=t.child,i.memoizedState=or(n),i.childLanes=sr(e,s,n),t.memoizedState=nu,Xn(null,i)):(mt(t),H(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(mt(t),t.flags&=-257,t=ur(e,t,n)):t.memoizedState===null?(_t(),c=i.fallback,a=t.mode,i=lr({mode:`visible`,children:i.children},a),c=K(c,a,n,null),c.flags|=2,i.return=t,c.return=t,i.sibling=c,t.child=i,El(t,e.child,null,n),i=t.child,i.memoizedState=or(n),i.childLanes=sr(e,s,n),t.memoizedState=nu,t=Xn(null,i)):(_t(),t.child=e.child,t.flags|=128,t=null);else if(mt(t),as(c))s=os(c).digest,i=Error(r(419)),i.stack=``,i.digest=s,R({value:i,source:null,stack:null}),t=ur(e,t,n);else if(tu||_e(e,t,n,!1),s=(n&e.childLanes)!==0,tu||s){if(s=xu,s!==null&&(i=T(s,n),i!==0&&i!==l.retryLane))throw l.retryLane=i,Qe(e,i),Di(s,e,i),eu;is(c)||zi(),t=ur(e,t,n)}else is(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,co&&(Yc=hs(c),Jc=t,Xc=!0,Zc=null,Qc=!1,e!==null&&se(t,e)),t=H(t,i.children),t.flags|=4096);return t}return a?(_t(),c=i.fallback,a=t.mode,l=e.child,o=l.sibling,i=da(l,{mode:`hidden`,children:i.children}),i.subtreeFlags=l.subtreeFlags&65011712,o===null?(c=K(c,a,n,null),c.flags|=2):c=da(o,c),c.return=t,i.return=t,i.sibling=c,t.child=i,Xn(null,i),i=t.child,c=e.child.memoizedState,c===null?c=or(n):(a=c.cachePool,a===null?a=ze():(l=ao?ol._currentValue:ol._currentValue2,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),i.memoizedState=c,i.childLanes=sr(e,s,n),t.memoizedState=nu,Xn(e.child,i)):(mt(t),n=e.child,e=n.sibling,n=da(n,{mode:`visible`,children:i.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function H(e,t){return t=lr({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function lr(e,n){return e=t(22,e,null,n),e.lanes=0,e}function ur(e,t,n){return El(t,e.child,null,n),e=H(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function dr(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),he(e.return,t,n)}function fr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function pr(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Ll.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,p(Ll,o),Gn(e,t,r,n),r=Xc?Rc:0,!s&&e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&dr(e,n,t);else if(e.tag===19)dr(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&yt(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),fr(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&yt(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}fr(t,!0,n,null,a,r);break;case`together`:fr(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function mr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ju|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(_e(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=da(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=da(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function hr(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ve(e)))}function gr(e,t,n){switch(t.tag){case 3:M(t,t.stateNode.containerInfo),pe(t,ol,e.memoizedState.cache),L();break;case 27:case 5:le(t);break;case 4:M(t,t.stateNode.containerInfo);break;case 10:pe(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ht(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(mt(t),e=mr(e,t,n),e===null?null:e.sibling):cr(e,t,n):(mt(t),t.flags|=128,null);mt(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(_e(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return pr(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),p(Ll,Ll.current),r)break;return null;case 22:return t.lanes=0,Yn(e,t,n,t.pendingProps);case 24:pe(t,ol,e.memoizedState.cache)}return mr(e,t,n)}function _r(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)tu=!0;else{if(!hr(e,n)&&!(t.flags&128))return tu=!1,gr(e,t,n);tu=!!(e.flags&131072)}}else tu=!1,Xc&&t.flags&1048576&&ie(t,Rc,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=He(t.elementType),t.type=e,typeof e==`function`)ua(e)?(i=Rn(e,i),t.tag=1,t=ir(null,t,e,i,n)):(t.tag=0,t=nr(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Na){t.tag=11,t=Kn(null,t,e,i,n);break e}if(a===Ia){t.tag=14,t=qn(null,t,e,i,n);break e}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return nr(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=Rn(i,t.pendingProps),ir(e,t,i,a,n);case 3:e:{if(M(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,nt(e,t),ct(t,o,null,n);var s=t.memoizedState;if(o=s.cache,pe(t,ol,o),o!==a.cache&&ge(t,[ol],n,!0),st(),o=s.element,co&&a.isDehydrated){if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=ar(e,t,o,n);break e}if(o!==i){i=j(Error(r(424)),t),R(i),t=ar(e,t,o,n);break e}for(co&&(Yc=ps(t.stateNode.containerInfo),Jc=t,Xc=!0,Zc=null,Qc=!0),n=Dl(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(L(),o===i){t=mr(e,t,n);break e}Gn(e,t,o,n)}t=t.child}return t;case 26:if(Bs)return tr(e,t),e===null?(n=Us(t.type,null,t.pendingProps,null))?t.memoizedState=n:Xc||(t.stateNode=Ys(t.type,t.pendingProps,Kc.current,t)):t.memoizedState=Us(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(ec)return le(t),e===null&&ec&&Xc&&(i=t.stateNode=tc(t.type,t.pendingProps,Kc.current,Wc.current,!1),Jc=t,Qc=!0,Yc=gs(t.type,i,Yc)),Gn(e,t,t.pendingProps.children,n),tr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Xc&&(Rs(t.type,t.pendingProps,Wc.current),(a=i=Yc)&&(i=_s(i,t.type,t.pendingProps,Qc),i===null?a=!1:(t.stateNode=i,Jc=t,Yc=fs(i),Qc=!1,a=!0)),a||ue(t)),le(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,eo(a,o)?i=null:s!==null&&eo(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=St(e,t,Tt,null,null,n),ao?wo._currentValue=a:wo._currentValue2=a),tr(e,t),Gn(e,t,i,n),t.child;case 6:return e===null&&Xc&&(zs(t.pendingProps,Wc.current),(e=n=Yc)&&(n=vs(n,t.pendingProps,Qc),n===null?e=!1:(t.stateNode=n,Jc=t,Yc=null,e=!0)),e||ue(t)),null;case 13:return cr(e,t,n);case 4:return M(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=El(t,null,i,n):Gn(e,t,i,n),t.child;case 11:return Kn(e,t,t.type,t.pendingProps,n);case 7:return Gn(e,t,t.pendingProps,n),t.child;case 8:return Gn(e,t,t.pendingProps.children,n),t.child;case 12:return Gn(e,t,t.pendingProps.children,n),t.child;case 10:return i=t.pendingProps,pe(t,t.type,i.value),Gn(e,t,i.children,n),t.child;case 9:return a=t.type._context,i=t.pendingProps.children,ye(t),a=z(a),i=i(a),t.flags|=1,Gn(e,t,i,n),t.child;case 14:return qn(e,t,t.type,t.pendingProps,n);case 15:return Jn(e,t,t.type,t.pendingProps,n);case 19:return pr(e,t,n);case 31:return er(e,t,n);case 22:return Yn(e,t,n,t.pendingProps);case 24:return ye(t),i=z(ol),e===null?(a=Le(),a===null&&(a=xu,o=Se(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},tt(t),pe(t,ol,a)):((e.lanes&n)!==0&&(nt(e,t),ct(t,null,null,n),st()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,pe(t,ol,i),i!==a.cache&&ge(t,[ol],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),pe(t,ol,i))),Gn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function vr(e){e.flags|=4}function yr(e){so&&(e.flags|=8)}function br(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function xr(e,t,n,r){if(oo)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)Qa(e,n.stateNode);else if(!(n.tag===4||ec&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(so)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=ns(a,i.type,i.memoizedProps)),Qa(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=rs(a,i.memoizedProps)),Qa(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),xr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function Sr(e,t,n,r){var i=!1;if(so)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=ns(o,a.type,a.memoizedProps)),$o(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=rs(o,a.memoizedProps)),$o(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),Sr(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function Cr(e,t){if(so&&br(e,t)){e=t.stateNode;var n=e.containerInfo,r=Qo();Sr(r,t,!1,!1),e.pendingChildren=r,vr(t),es(n,r)}}function wr(e,t,n,r){if(oo)e.memoizedProps!==r&&vr(t);else if(so){var i=e.stateNode,a=e.memoizedProps;if((e=br(e,t))||a!==r){var o=Wc.current;a=Zo(i,n,a,r,!e,null),a===i?t.stateNode=i:(yr(t),$a(a,n,r,o)&&vr(t),t.stateNode=a,e&&xr(a,t,!1,!1))}else t.stateNode=i}}function Tr(e,t,n,r,i){if(e.mode&32&&(n===null?_o(t,r):vo(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||yo(t,r)){if(bo(e.stateNode,t,r))e.flags|=8192;else if(Ii())e.flags|=8192;else throw Cl=Sl,bl}}else e.flags&=-16777217}function Er(e,t){if(Zs(t)){if(e.flags|=16777216,!Qs(t)){if(Ii())e.flags|=8192;else throw Cl=Sl,bl}}else e.flags&=-16777217}function Dr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:y(),e.lanes|=t,Fu|=t)}function Or(e,t){if(!Xc)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function kr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ar(e,t,n){var i=t.pendingProps;switch(oe(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return kr(t),null;case 1:return kr(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),me(ol),ce(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(I(t)?vr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,fe())),Cr(e,t),kr(t),null;case 26:if(Bs){var a=t.type,o=t.memoizedState;return e===null?(vr(t),o===null?(kr(t),Tr(t,a,null,i,n)):(kr(t),Er(t,o))):o?o===e.memoizedState?(kr(t),t.flags&=-16777217):(vr(t),kr(t),Er(t,o)):(o=e.memoizedProps,oo?o!==i&&vr(t):wr(e,t,a,i),kr(t),Tr(t,a,o,i,n)),null}case 27:if(ec){if(N(t),n=Kc.current,a=t.type,e!==null&&t.stateNode!=null)oo?e.memoizedProps!==i&&vr(t):wr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return kr(t),null}e=Wc.current,I(t)?P(t,e):(e=tc(a,i,n,e,!0),t.stateNode=e,vr(t))}return kr(t),null}case 5:if(N(t),a=t.type,e!==null&&t.stateNode!=null)wr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return kr(t),null}if(o=Wc.current,I(t))P(t,o),js(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=Za(a,i,Kc.current,o,t);yr(t),xr(s,t,!1,!1),t.stateNode=s,$a(s,a,i,o)&&vr(t)}}return kr(t),Tr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,oo?n!==i&&vr(t):so&&(n===i?t.stateNode=e.stateNode:(e=Kc.current,n=Wc.current,yr(t),t.stateNode=to(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=Kc.current,n=Wc.current,I(t)){if(!co)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=Jc,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Ss(e,n,t,i)||ue(t,!0)}else yr(t),t.stateNode=to(i,e,n,t)}return kr(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=I(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!co)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Cs(e,t)}else L(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kr(t),e=!1}else n=fe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(vt(t),t):(vt(t),null);if(t.flags&128)throw Error(r(558))}return kr(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=I(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!co)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));ws(a,t)}else L(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kr(t),a=!1}else a=fe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(vt(t),t):(vt(t),null)}return vt(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Dr(t,t.updateQueue),kr(t),null);case 4:return ce(),Cr(e,t),e===null&&uo(t.stateNode.containerInfo),kr(t),null;case 10:return me(t.type),kr(t),null;case 19:if(f(Ll),i=t.memoizedState,i===null)return kr(t),null;if(a=!!(t.flags&128),o=i.rendering,o===null){if(a)Or(i,!1);else{if(Au!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=yt(e),o!==null){for(t.flags|=128,Or(i,!1),e=o.updateQueue,t.updateQueue=e,Dr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)fa(n,e),n=n.sibling;return p(Ll,Ll.current&1|2),Xc&&re(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&yc()>Vu&&(t.flags|=128,a=!0,Or(i,!1),t.lanes=4194304)}}else{if(!a){if(e=yt(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Dr(t,e),Or(i,!0),i.tail===null&&i.tailMode===`hidden`&&!o.alternate&&!Xc)return kr(t),null}else 2*yc()-i.renderingStartTime>Vu&&n!==536870912&&(t.flags|=128,a=!0,Or(i,!1),t.lanes=4194304)}i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}return i.tail===null?(kr(t),null):(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=yc(),e.sibling=null,n=Ll.current,p(Ll,a?n&1|2:n&1),Xc&&re(t,i.treeForkCount),e);case 22:case 23:return vt(t),pt(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(kr(t),t.subtreeFlags&6&&(t.flags|=8192)):kr(t),n=t.updateQueue,n!==null&&Dr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&f(vl),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),me(ol),kr(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function jr(e,t){switch(oe(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return me(ol),ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return N(t),null;case 31:if(t.memoizedState!==null){if(vt(t),t.alternate===null)throw Error(r(340));L()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(vt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));L()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return f(Ll),null;case 4:return ce(),null;case 10:return me(t.type),null;case 22:case 23:return vt(t),pt(),e!==null&&f(vl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return me(ol),null;case 25:return null;default:return null}}function Mr(e,t){switch(oe(t),t.tag){case 3:me(ol),ce();break;case 26:case 27:case 5:N(t);break;case 4:ce();break;case 31:t.memoizedState!==null&&vt(t);break;case 13:vt(t);break;case 19:f(Ll);break;case 10:me(t.type);break;case 22:case 23:vt(t),pt(),e!==null&&f(vl);break;case 24:me(ol)}}function Nr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){G(t,t.return,e)}}function Pr(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){G(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){G(t,t.return,e)}}function Fr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ut(t,n)}catch(t){G(e,e.return,t)}}}function Ir(e,t,n){n.props=Rn(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){G(e,t,n)}}function Lr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=Ka(e.stateNode);break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){G(e,t,n)}}function Rr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){G(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){G(e,t,n)}else n.current=null}}function zr(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{zo(r,t,n,e)}catch(t){G(e,e.return,t)}}function U(e,t,n){try{Bo(e.stateNode,e.type,n,t,e)}catch(t){G(e,e.return,t)}}function Br(e){return e.tag===5||e.tag===3||(Bs?e.tag===26:!1)||(ec?e.tag===27&&ac(e.type):!1)||e.tag===4}function Vr(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Br(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(ec&&e.tag===27&&ac(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hr(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Ho(n,e,t):Lo(n,e);else if(r!==4&&(ec&&r===27&&ac(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Hr(e,t,n),e=e.sibling;e!==null;)Hr(e,t,n),e=e.sibling}function Ur(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Vo(n,e,t):Io(n,e);else if(r!==4&&(ec&&r===27&&ac(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Ur(e,t,n),e=e.sibling;e!==null;)Ur(e,t,n),e=e.sibling}function Wr(e,t,n){e=e.containerInfo;try{ts(e,n)}catch(e){G(t,t.return,e)}}function Gr(e){var t=e.stateNode,n=e.memoizedProps;try{nc(e.type,n,t,e)}catch(t){G(e,e.return,t)}}function Kr(e,t){for(Ya(e.containerInfo),su=t;su!==null;)if(e=su,t=e.child,e.subtreeFlags&1028&&t!==null)t.return=e,su=t;else for(;su!==null;){e=su;var n=e.alternate;switch(t=e.flags,e.tag){case 0:if(t&4&&(t=e.updateQueue,t=t===null?null:t.events,t!==null))for(var i=0;i`;case mu:return`:has(`+(Si(e)||``)+`)`;case hu:return`[role="`+e.value+`"]`;case _u:return`"`+e.value+`"`;case gu:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function Ci(e,t){var n=[];e=[e,0];for(var r=0;rn?32:n;n=X.T;var a=po();try{fo(i),X.T=null,i=Yu,Yu=null;var o=Gu,s=qu;if(Wu=0,Ku=Gu=null,qu=0,bu&6)throw Error(r(331));var c=bu;if(bu|=4,_i(o.current),di(o,o.current,s,i),bu=c,Ee(0,!1),Dc&&typeof Dc.onPostCommitFiberRoot==`function`)try{Dc.onPostCommitFiberRoot(Ec,o)}catch{}return!0}finally{fo(a),X.T=n,$i(e,t)}}function na(e,t,n){t=j(n,t),t=Vn(e.stateNode,t,2),e=it(e,t,2),e!==null&&(x(e,2),Te(e))}function G(e,t,n){if(e.tag===3)na(e,e,n);else for(;t!==null;){if(t.tag===3){na(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Uu===null||!Uu.has(r))){e=j(n,e),n=Hn(2),r=it(t,n,2),r!==null&&(Un(n,r,t,e),x(r,2),Te(r));break}}t=t.return}}function ra(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new yu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ou=!0,i.add(n),e=ia.bind(null,e,t,n),t.then(e,e))}function ia(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,xu===e&&(Cu&n)===n&&(Au===4||Au===3&&(Cu&62914560)===Cu&&300>yc()-zu?!(bu&2)&&Pi(e,0):Nu|=n,Fu===Cu&&(Fu=0)),Te(e)}function aa(e,t){t===0&&(t=y()),e=Qe(e,t),e!==null&&(x(e,t),Te(e))}function oa(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),aa(e,n)}function sa(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),aa(e,n)}function ca(e,t){return hc(e,t)}function la(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ua(e){return e=e.prototype,!(!e||!e.isReactComponent)}function da(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function fa(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function pa(e,n,i,a,o,s){var c=0;if(a=e,typeof e==`function`)ua(e)&&(c=1);else if(typeof e==`string`)c=Bs&&ec?Vs(e,i,Wc.current)?26:ic(e)?27:5:Bs?Vs(e,i,Wc.current)?26:5:ec&&ic(e)?27:5;else e:switch(e){case Ra:return e=t(31,i,n,o),e.elementType=Ra,e.lanes=s,e;case Oa:return K(i.children,o,s,n);case ka:c=8,o|=24;break;case Aa:return e=t(12,i,n,o|2),e.elementType=Aa,e.lanes=s,e;case Pa:return e=t(13,i,n,o),e.elementType=Pa,e.lanes=s,e;case Fa:return e=t(19,i,n,o),e.elementType=Fa,e.lanes=s,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case Ma:c=10;break e;case ja:c=9;break e;case Na:c=11;break e;case Ia:c=14;break e;case La:c=16,a=null;break e}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function K(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function ma(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function ha(e){var n=t(18,null,null,0);return n.stateNode=e,n}function ga(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function _a(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=io,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=b(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=b(0),this.hiddenUpdates=b(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function va(e,n,r,i,a,o,s,c,l,u,d,f){return e=new _a(e,n,r,s,l,u,d,f,c),n=1,o===!0&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=Se(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},tt(o),e}function ya(e){return e?(e=cc,e):cc}function ba(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:Ka(e.stateNode)}function xa(e,t,n,r,i,a){i=ya(i),r.context===null?r.context=i:r.pendingContext=i,r=rt(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=it(e,r,t),n!==null&&(Di(n,e,t),at(n,e,t))}function q(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}if(i!==u||n.width!==l.width||ps){if(!(o!==f||n.height!==l.height||da)){u>i&&(l.width+=u-i,l.x=i),do&&(l.height+=f-o,l.y=o),pn&&(n=c)),c `)+` + +No matching component was found for: + `)+e.join(` > `)}return null},J.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return Ka(e.child.stateNode);default:return e.child.stateNode}},J.injectIntoDevTools=function(){var e={bundleType:0,version:Ua,rendererPackageName:Wa,currentDispatcherRef:X,reconcilerVersion:`19.2.0`};if(Ga!==null&&(e.rendererConfig=Ga),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Ec=t.inject(e),Dc=t}catch{}e=!!t.checkDCE}}return e},J.isAlreadyRendering=function(){return!!(bu&6)},J.observeVisibleRects=function(e,t,n,i){if(!Oo)throw Error(r(363));e=wi(e,t);var a=Fo(e,n,i).disconnect;return{disconnect:function(){a()}}},J.shouldError=function(){return null},J.shouldSuspend=function(){return!1},J.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=Cn(e).queue;Sn(e,o,t,Z,i===null?n:function(){var t=Cn(e);return t.next===null&&(t=e.alternate.memoizedState),An(e,t.next.queue,{},Ti()),i(a)})},J.updateContainer=function(e,t,n,r){var i=t.current,a=Ti();return xa(i,a,e,t,n,r),a},J.updateContainerSync=function(e,t,n,r){return xa(t.current,2,e,t,n,r),2},J},e.exports.default=e.exports,Object.defineProperty(e.exports,"__esModule",{value:!0})}(p_)),p_.exports}({exports:{}}).exports;var g_;function __(){return g_||(g_=1,f_.exports=h_()),f_.exports}var v_=d_(__());function y_(e){let t=v_(e);return t.injectIntoDevTools(),t}var b_=0,x_={},S_=/^three(?=[A-Z])/,C_=e=>`${e[0].toUpperCase()}${e.slice(1)}`,w_=0,T_=e=>typeof e==`function`;function E_(e){if(T_(e)){let t=`${w_++}`;return x_[t]=e,t}Object.assign(x_,e)}function D_(e,t){let n=C_(e),r=x_[n];if(e!==`primitive`&&!r)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(e===`primitive`&&!t.object)throw Error(`R3F: Primitives without 'object' are invalid!`);if(t.args!==void 0&&!Array.isArray(t.args))throw Error(`R3F: The args prop must be an array!`)}function O_(e,t,n){var r;return e=C_(e)in x_?e:e.replace(S_,``),D_(e,t),e===`primitive`&&(r=t.object)!=null&&r.__r3f&&delete t.object.__r3f,Ng(t.object,n,e,t)}function k_(e){if(!e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?Lg(e.parent,e):qg(e.object)&&(e.object.visible=!1),e.isHidden=!0,Gg(e)}}function A_(e){if(e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?Ig(e.parent,e):qg(e.object)&&e.props.visible!==!1&&(e.object.visible=!0),e.isHidden=!1,Gg(e)}}function j_(e,t,n){let r=t.root.getState();if(!(!e.parent&&e.object!==r.scene)){if(!t.object){let e=x_[C_(t.type)];t.object=t.props.object??new e(...t.props.args??[]),t.object.__r3f=t}if(Wg(t.object,t.props),t.props.attach)Ig(e,t);else if(qg(t.object)&&qg(e.object)){let r=e.object.children.indexOf(n?.object);if(n&&r!==-1){let n=e.object.children.indexOf(t.object);if(n!==-1){e.object.children.splice(n,1);let i=n{try{e.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<`u`?t():(0,cg.unstable_scheduleCallback)(cg.unstable_IdlePriority,t)}}function F_(e,t,n){if(!t)return;t.parent=null;let r=e.children.indexOf(t);r!==-1&&e.children.splice(r,1),t.props.attach?Lg(e,t):qg(t.object)&&qg(e.object)&&(e.object.remove(t.object),Zg(vg(t),t.object));let i=t.props.dispose!==null&&n!==!1;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];F_(t,n,i)}t.children.length=0,delete t.object.__r3f,i&&t.type!==`primitive`&&t.object.type!==`Scene`&&P_(t.object),n===void 0&&Gg(t)}function I_(e,t){for(let n of[e,e.alternate])if(n!==null){if(typeof n.ref==`function`){n.refCleanup==null||n.refCleanup();let e=n.ref(t);typeof e==`function`&&(n.refCleanup=e)}else n.ref&&(n.ref.current=t)}}var L_=[];function R_(){if(L_.length!==0)try{z_()}finally{L_.length=0}}function z_(){for(let[e]of L_){let t=e.parent;if(t){e.props.attach?Lg(t,e):qg(e.object)&&qg(t.object)&&t.object.remove(e.object);for(let t of e.children)t.props.attach?Lg(e,t):qg(t.object)&&qg(e.object)&&e.object.remove(t.object)}e.isHidden&&A_(e),e.object.__r3f&&delete e.object.__r3f,e.type!==`primitive`&&P_(e.object)}for(let[e,t,n]of L_){e.props=t;let r=e.parent;if(r){let t=x_[C_(e.type)],i=e.object;e.object=e.props.object??new t(...e.props.args??[]),e.object.__r3f=e,I_(n,e.object),Xg(vg(e),i,e.object),Wg(e.object,e.props),e.props.attach?Ig(r,e):qg(e.object)&&qg(r.object)&&r.object.add(e.object);for(let t of e.children)t.props.attach?Ig(e,t):qg(t.object)&&qg(e.object)&&e.object.add(t.object);Gg(e)}}}var B_=()=>{},V_={},H_=b_;function U_(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return c_;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return o_;case`message`:switch((0,cg.unstable_getCurrentPriorityLevel)()){case cg.unstable_ImmediatePriority:return c_;case cg.unstable_UserBlockingPriority:return o_;case cg.unstable_NormalPriority:case cg.unstable_LowPriority:return s_;case cg.unstable_IdlePriority:return l_;default:return s_}default:return s_}}function W_(e){typeof queueMicrotask==`function`?queueMicrotask(e):typeof Promise<`u`?Promise.resolve().then(e).catch(e=>{setTimeout(()=>{throw e})}):setTimeout(e)}var G_=y_({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:O_,removeChild:F_,appendChild:M_,appendInitialChild:M_,insertBefore:N_,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||M_(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||F_(n,t)},insertInContainerBefore(e,t,n){let r=e.getState().scene.__r3f;!t||!n||!r||N_(r,t,n)},getRootHostContext:()=>V_,getChildHostContext:()=>V_,commitUpdate(e,t,n,r,i){var a;D_(t,r);let o=!1;if(e.type===`primitive`&&n.object!==r.object?o=!0:r.args?.length===n.args?.length?(a=r.args)!=null&&a.some((e,t)=>e!==n.args?.[t])&&(o=!0):o=!0,o)L_.push([e,Mg(r),i]);else{let t=Vg(e,r),n=e.props.attach;e.props=Mg(r),n===void 0?delete e.props.attach:e.props.attach=n,Object.keys(t).length&&Wg(e.object,t)}},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>e?.object,prepareForCommit:()=>null,preparePortalMount:e=>Ng(e.getState().scene,e,``,{}),resetAfterCommit:R_,shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:k_,unhideInstance:A_,createTextInstance:B_,hideTextInstance:B_,unhideTextInstance:B_,supportsMicrotasks:!0,scheduleMicrotask:W_,scheduleTimeout:typeof setTimeout==`function`?setTimeout:void 0,cancelTimeout:typeof clearTimeout==`function`?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:F.createContext(null),setCurrentUpdatePriority(e){H_=e},getCurrentUpdatePriority(){return H_},resolveUpdatePriority(){if(H_!==b_)return H_;let e=typeof window<`u`?window.event?.type:void 0;return e===void 0?s_:U_(e)},resetFormInstance(){},rendererPackageName:`@react-three/fiber`,rendererVersion:u_.version,applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error(`startGestureTransition is not yet supported in react-three-fiber.`)},cloneMutableInstance(e,t){return e},cloneMutableTextInstance(e){return e},cloneRootViewTransitionContainer(e){throw Error(`Not implemented.`)},removeRootViewTransitionClone(e,t){throw Error(`Not implemented.`)},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null}),K_=new Map,q_={objects:`shallow`,strict:!1};function J_(e,t){if(!t&&typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:r,left:i}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:r,left:i}}return!t&&typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...t}}function Y_(e){let t=K_.get(e),n=t?.fiber,r=t?.store;t&&console.warn(`R3F.createRoot should only be called once!`);let i=typeof reportError==`function`?reportError:console.error,a=r||t_(fv,pv),o=n||G_.createContainer(a,a_,null,!1,null,``,i,i,i,null);t||K_.set(e,{fiber:o,store:a});let s,c,l=!1,u=null;return{async configure(t={}){let n;u=new Promise(e=>n=e);let{gl:r,size:i,scene:o,events:d,onCreated:f,shadows:p=!1,linear:m=!1,flat:h=!1,legacy:g=!1,orthographic:_=!1,frameloop:v=`always`,dpr:y=[1,2],performance:b,raycaster:x,camera:S,onPointerMissed:C}=t,w=a.getState(),T=w.gl;if(!w.gl){let t={canvas:e,powerPreference:`high-performance`,antialias:!0,alpha:!0},n=typeof r==`function`?await r(t):r;T=$g(n)?n:new El({...t,...r}),w.set({gl:T})}let E=w.raycaster;E||w.set({raycaster:E=new ch});let{params:D,...O}=x||{};if(kg.equ(O,E,q_)||Wg(E,{...O}),kg.equ(D,E.params,q_)||Wg(E,{params:{...E.params,...D}}),!w.camera||w.camera===c&&!kg.equ(c,S,q_)){c=S;let e=S?.isCamera,t=e?S:_?new Po(0,0,0,0,.1,1e3):new oo(75,0,.1,1e3);e||(t.position.z=5,S&&(Wg(t,S),t.manual||(`aspect`in S||`left`in S||`right`in S||`bottom`in S||`top`in S)&&(t.manual=!0,t.updateProjectionMatrix())),!w.camera&&!(S!=null&&S.rotation)&&t.lookAt(0,0,0)),w.set({camera:t}),E.camera=t}if(!w.scene){let e;o!=null&&o.isScene?(e=o,Ng(e,a,``,{})):(e=new kl,Ng(e,a,``,{}),o&&Wg(e,o)),w.set({scene:e})}d&&!w.events.handlers&&w.set({events:d(a)});let k=J_(e,i);if(kg.equ(k,w.size,q_)||w.setSize(k.width,k.height,k.top,k.left),y&&w.viewport.dpr!==Dg(y)&&w.setDpr(y),w.frameloop!==v&&w.setFrameloop(v),w.onPointerMissed||w.set({onPointerMissed:C}),b&&!kg.equ(b,w.performance,q_)&&w.set(e=>({performance:{...e.performance,...b}})),!w.xr){let e=(e,t)=>{let n=a.getState();n.frameloop!==`never`&&pv(e,!0,n,t)},t=()=>{let t=a.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||fv(t)},n={connect(){let e=a.getState().gl;e.xr.addEventListener(`sessionstart`,t),e.xr.addEventListener(`sessionend`,t)},disconnect(){let e=a.getState().gl;e.xr.removeEventListener(`sessionstart`,t),e.xr.removeEventListener(`sessionend`,t)}};typeof T.xr?.addEventListener==`function`&&n.connect(),w.set({xr:n})}if(T.shadowMap){let e=T.shadowMap.enabled,t=T.shadowMap.type;if(T.shadowMap.enabled=!!p,kg.boo(p))T.shadowMap.type=2;else if(kg.str(p)){let e={basic:0,percentage:1,soft:2,variance:3};T.shadowMap.type=e[p]??2}else kg.obj(p)&&Object.assign(T.shadowMap,p);(e!==T.shadowMap.enabled||t!==T.shadowMap.type)&&(T.shadowMap.needsUpdate=!0)}return Sr.enabled=!g,l||(T.outputColorSpace=m?V:un,T.toneMapping=h?0:4),w.legacy!==g&&w.set(()=>({legacy:g})),w.linear!==m&&w.set(()=>({linear:m})),w.flat!==h&&w.set(()=>({flat:h})),r&&!kg.fun(r)&&!$g(r)&&!kg.equ(r,T,q_)&&Wg(T,r),s=f,l=!0,n(),this},render(t){return!l&&!u&&this.configure(),u.then(()=>{G_.updateContainer((0,I.jsx)(X_,{store:a,children:t,onCreated:s,rootElement:e}),o,null,()=>void 0)}),a},unmount(){Z_(e)}}}function X_({store:e,children:t,onCreated:n,rootElement:r}){return Sg(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||t.events.connect==null||t.events.connect(r)},[]),(0,I.jsx)(e_.Provider,{value:e,children:t})}function Z_(e,t){let n=K_.get(e),r=n?.fiber;if(r){let i=n?.store.getState();i&&(i.internal.active=!1),G_.updateContainer(null,r,null,()=>{i&&setTimeout(()=>{try{var n,r,a,o;i.events.disconnect==null||i.events.disconnect(),(n=i.gl)==null||(r=n.renderLists)==null||r.dispose==null||r.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(o=i.gl)!=null&&o.xr&&i.xr.disconnect(),Ag(i.scene),K_.delete(e),t&&t(e)}catch{}},500)})}}var Q_=new Set,$_=new Set,ev=new Set;function tv(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function nv(e,t){switch(e){case`before`:return tv(Q_,t);case`after`:return tv($_,t);case`tail`:return tv(ev,t)}}var rv,iv;function av(e,t,n){let r=t.clock.getDelta();t.frameloop===`never`&&typeof e==`number`&&(r=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),rv=t.internal.subscribers;for(let e=0;e0)&&!((t=uv.gl.xr)!=null&&t.isPresenting)&&(cv+=av(e,uv))}if(sv=!1,nv(`after`,e),cv===0)return nv(`tail`,e),ov=!1,cancelAnimationFrame(lv)}function fv(e,t=1){var n;if(!e)return K_.forEach(e=>fv(e.store.getState(),t));(n=e.gl.xr)!=null&&n.isPresenting||!e.internal.active||e.frameloop===`never`||(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):sv?e.internal.frames=2:e.internal.frames=1,ov||(ov=!0,requestAnimationFrame(dv)))}function pv(e,t=!0,n,r){if(t&&nv(`before`,e),n)av(e,n,r);else for(let t of K_.values())av(e,t.store.getState());t&&nv(`after`,e)}var mv={onClick:[`click`,!1],onContextMenu:[`contextmenu`,!1],onDoubleClick:[`dblclick`,!1],onWheel:[`wheel`,!0],onPointerDown:[`pointerdown`,!0],onPointerUp:[`pointerup`,!0],onPointerLeave:[`pointerleave`,!0],onPointerMove:[`pointermove`,!0],onPointerCancel:[`pointercancel`,!0],onLostPointerCapture:[`lostpointercapture`,!0]};function hv(e){let{handlePointer:t}=Qg(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(e.offsetY/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(mv).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:r}=e.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{let{set:n,events:r}=e.getState();if(r.disconnect==null||r.disconnect(),n(e=>({events:{...e.events,connected:t}})),r.handlers)for(let e in r.handlers){let n=r.handlers[e],[i,a]=mv[e];t.addEventListener(i,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[r]=mv[e];n.connected.removeEventListener(r,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}function gv(e,t){let n;return(...r)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...r),t)}}function _v({debounce:e,scroll:t,polyfill:n,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){let i=n||(typeof window>`u`?class{}:window.ResizeObserver);if(!i)throw Error(`This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills`);let[a,o]=(0,F.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),s=(0,F.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),c=e?typeof e==`number`?e:e.scroll:null,l=e?typeof e==`number`?e:e.resize:null,u=(0,F.useRef)(!1);(0,F.useEffect)(()=>(u.current=!0,()=>void(u.current=!1)));let[d,f,p]=(0,F.useMemo)(()=>{let e=()=>{if(!s.current.element)return;let{left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d}=s.current.element.getBoundingClientRect(),f={left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d};s.current.element instanceof HTMLElement&&r&&(f.height=s.current.element.offsetHeight,f.width=s.current.element.offsetWidth),Object.freeze(f),u.current&&!Sv(s.current.lastBounds,f)&&o(s.current.lastBounds=f)};return[e,l?gv(e,l):e,c?gv(e,c):e]},[o,r,c,l]);function m(){s.current.scrollContainers&&(s.current.scrollContainers.forEach(e=>e.removeEventListener(`scroll`,p,!0)),s.current.scrollContainers=null),s.current.resizeObserver&&(s.current.resizeObserver.disconnect(),s.current.resizeObserver=null),s.current.orientationHandler&&(`orientation`in screen&&`removeEventListener`in screen.orientation?screen.orientation.removeEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.removeEventListener(`orientationchange`,s.current.orientationHandler))}function h(){s.current.element&&(s.current.resizeObserver=new i(p),s.current.resizeObserver.observe(s.current.element),t&&s.current.scrollContainers&&s.current.scrollContainers.forEach(e=>e.addEventListener(`scroll`,p,{capture:!0,passive:!0})),s.current.orientationHandler=()=>{p()},`orientation`in screen&&`addEventListener`in screen.orientation?screen.orientation.addEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.addEventListener(`orientationchange`,s.current.orientationHandler))}return yv(p,!!t),vv(f),(0,F.useEffect)(()=>{m(),h()},[t,p,f]),(0,F.useEffect)(()=>m,[]),[e=>{!e||e===s.current.element||(m(),s.current.element=e,s.current.scrollContainers=bv(e),h())},a,d]}function vv(e){(0,F.useEffect)(()=>{let t=e;return window.addEventListener(`resize`,t),()=>void window.removeEventListener(`resize`,t)},[e])}function yv(e,t){(0,F.useEffect)(()=>{if(t){let t=e;return window.addEventListener(`scroll`,t,{capture:!0,passive:!0}),()=>void window.removeEventListener(`scroll`,t,!0)}},[e,t])}function bv(e){let t=[];if(!e||e===document.body)return t;let{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some(e=>e===`auto`||e===`scroll`)&&t.push(e),[...t,...bv(e.parentElement)]}var xv=[`x`,`y`,`top`,`bottom`,`left`,`right`,`width`,`height`],Sv=(e,t)=>xv.every(n=>e[n]===t[n]);function Cv({ref:e,children:t,fallback:n,resize:r,style:i,gl:a,events:o=hv,eventSource:s,eventPrefix:c,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:v,scene:y,onPointerMissed:b,onCreated:x,...S}){F.useMemo(()=>E_(je),[]);let C=wg(),[w,T]=_v({scroll:!0,debounce:{scroll:50,resize:0},...r}),E=F.useRef(null),D=F.useRef(null);F.useImperativeHandle(e,()=>E.current);let O=Cg(b),[k,ee]=F.useState(!1),[te,ne]=F.useState(!1);if(k)throw k;if(te)throw te;let A=F.useRef(null);return Sg(()=>{let e=E.current;if(T.width>0&&T.height>0&&e){A.current||=Y_(e);async function n(){await A.current.configure({gl:a,scene:y,events:o,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:v,size:T,onPointerMissed:(...e)=>O.current==null?void 0:O.current(...e),onCreated:e=>{e.events.connect==null||e.events.connect(s?bg(s)?s.current:s:D.current),c&&e.setEvents({compute:(e,t)=>{let n=e[c+`X`],r=e[c+`Y`];t.pointer.set(n/t.size.width*2-1,-(r/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),x?.(e)}}),A.current.render((0,I.jsx)(C,{children:(0,I.jsx)(Eg,{set:ne,children:(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(Tg,{set:ee}),children:t??null})})}))}n()}}),F.useEffect(()=>{let e=E.current;if(e)return()=>Z_(e)},[]),(0,I.jsx)(`div`,{ref:D,style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,pointerEvents:s?`none`:`auto`,...i},...S,children:(0,I.jsx)(`div`,{ref:w,style:{width:`100%`,height:`100%`},children:(0,I.jsx)(`canvas`,{ref:E,style:{display:`block`},children:n})})})}function wv(e){return(0,I.jsx)(fg,{children:(0,I.jsx)(Cv,{...e})})}var Tv=class extends kl{constructor(e=null){super();let t=new qa;t.deleteAttribute(`uv`);let n=new ep({side:1}),r=new ep,i=5;e!==null&&e._useLegacyLights===!1&&(i=900);let a=new nm(16777215,i,28,2);a.position.set(.418,16.199,.3),this.add(a);let o=new Wa(t,n);o.position.set(-.757,13.219,.717),o.scale.set(31.713,28.305,28.591),this.add(o);let s=new Wa(t,r);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);let c=new Wa(t,r);c.position.set(-5.607,-.754,-.758),c.rotation.set(0,.994,0),c.scale.set(1.97,1.534,3.955),this.add(c);let l=new Wa(t,r);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);let u=new Wa(t,r);u.position.set(-2.017,.018,6.124),u.rotation.set(0,.333,0),u.scale.set(2.002,4.566,2.064),this.add(u);let d=new Wa(t,r);d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),this.add(d);let f=new Wa(t,r);f.position.set(-2.193,-.369,-5.547),f.rotation.set(0,.516,0),f.scale.set(3.875,3.487,2.986),this.add(f);let p=new Wa(t,Ev(50));p.position.set(-16.116,14.37,8.208),p.scale.set(.1,2.428,2.739),this.add(p);let m=new Wa(t,Ev(50));m.position.set(-16.109,18.021,-8.207),m.scale.set(.1,2.425,2.751),this.add(m);let h=new Wa(t,Ev(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);let g=new Wa(t,Ev(43));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),this.add(g);let _=new Wa(t,Ev(20));_.position.set(3.235,11.486,-12.541),_.scale.set(2.5,2,.1),this.add(_);let v=new Wa(t,Ev(100));v.position.set(0,20,0),v.scale.set(1,.1,1),this.add(v)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function Ev(e){let t=new oa;return t.color.setScalar(e),t}var Dv=`reachy/`,Ov=[-.35,0,0],kv=`reachy/reachy_mini.xml`;async function Av(){let e=await fetch(D(`./robot/reachy/reachy_mini.xml`));if(!e.ok)throw Error(`Reachy MJCF: HTTP ${e.status}`);let t=await e.text(),n=new DOMParser().parseFromString(t,`text/xml`);if(n.querySelector(`parsererror`))throw Error(`Invalid Reachy MJCF`);let r=new Map;await Promise.all([...n.querySelectorAll(`asset > mesh`)].map(async e=>{let t=e.getAttribute(`file`),n=await fetch(D(`./robot/reachy/assets/${t}`));if(!n.ok)throw Error(`Reachy mesh ${t}: HTTP ${n.status}`);let i=new Uint8Array(await n.arrayBuffer());if(new TextDecoder().decode(i.subarray(0,40)).startsWith(`version https://git-lfs`))throw Error(`Reachy mesh ${t} is a Git LFS pointer; run git lfs pull`);r.set(t,i)}));let i=await fetch(D(`./robot/reachy/kinematics_data.json`));if(!i.ok)throw Error(`Reachy calibration could not be loaded`);return{xml:t,document:n,meshes:r,calibration:await i.json()}}function jv(e,t){e.addBuffer(kv,new TextEncoder().encode(t.xml));for(let[n,r]of t.meshes)e.addBuffer(`reachy/assets/${n}`,r)}function Mv(e){let t=e.createElement(`model`);t.setAttribute(`name`,`reachy_model`),t.setAttribute(`file`,kv),e.querySelector(`asset`).appendChild(t);let n=e.createElement(`frame`);n.setAttribute(`pos`,Ov.join(` `));let r=e.createElement(`attach`);r.setAttribute(`model`,`reachy_model`),r.setAttribute(`body`,`body_foot_3dprint`),r.setAttribute(`prefix`,Dv),n.appendChild(r),e.querySelector(`worldbody`).appendChild(n)}function Nv(e,t,n){let r=[];for(let i=0;i>5&31)/31,a=(e>>10&31)/31)}for(let c=1;c<=3;c++){let l=n+c*12,u=e*3*3+(c-1)*3;p[u]=t.getFloat32(l,!0),p[u+1]=t.getFloat32(l+4,!0),p[u+2]=t.getFloat32(l+8,!0),m[u]=d,m[u+1]=f,m[u+2]=g,o&&(h.set(r,i,a).convertSRGBToLinear(),s[u]=h.r,s[u+1]=h.g,s[u+2]=h.b)}}return f.setAttribute(`position`,new K(p,3)),f.setAttribute(`normal`,new K(m,3)),o&&(f.setAttribute(`color`,new K(s,3)),f.hasColors=!0,f.alpha=d),f}function i(e){let t=new Y,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,i=/solid\s(.+)/,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=[],f=new U,p,m=0,h=0,g=0;for(;(p=n.exec(e))!==null;){h=g;let e=p[0],n=(p=i.exec(e))===null?``:p[1];for(d.push(n);(p=r.exec(e))!==null;){let e=0,t=0,n=p[0];for(;(p=c.exec(n))!==null;)f.x=parseFloat(p[1]),f.y=parseFloat(p[2]),f.z=parseFloat(p[3]),t++;for(;(p=s.exec(n))!==null;)l.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),u.push(f.x,f.y,f.z),e++,g++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let o=h,_=g-h;t.userData.groupNames=d,t.addGroup(o,_,m),m++}return t.setAttribute(`position`,new q(l,3)),t.setAttribute(`normal`,new q(u,3)),t}function a(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function o(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;ne.hasAttribute(t)?e.getAttribute(t).trim().split(/\s+/).map(Number):n;function Lv(e){let t=new hl;t.name=`Reachy Mini`,t.rotation.x=-Math.PI/2;let n=new Map,r=new Map,i=[],a=new Fv;for(let t of e.document.querySelectorAll(`asset > mesh`)){let r=t.getAttribute(`file`),i=t.getAttribute(`name`)??r.split(`/`).pop().replace(/\.stl$/i,``),o=e.meshes.get(r);n.set(i,a.parse(o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)))}for(let t of e.document.querySelectorAll(`asset > material`)){let e=Iv(t,`rgba`,[1,1,1,1]),n=new G(...e.slice(0,3));n.r>.82&&n.g>.82&&n.b>.82?n.multiplyScalar(.72):n.r<.75&&n.g<.75&&n.b<.75&&Math.max(n.r,n.g,n.b)>.02&&n.multiplyScalar(.62),r.set(t.getAttribute(`name`),new ep({color:n,roughness:.4,transparent:e[3]<1,opacity:e[3]}))}for(let a of e.document.querySelectorAll(`worldbody body`)){if(!a.hasAttribute(`name`))continue;let e=new hl,o=Dv+a.getAttribute(`name`);e.name=o,t.add(e),i.push({name:o,group:e,id:-1});for(let t of[...a.children].filter(e=>e.tagName===`geom`&&e.getAttribute(`class`)===`visual`)){let i=new Wa(n.get(t.getAttribute(`mesh`)),r.get(t.getAttribute(`material`)));i.position.fromArray(Iv(t,`pos`,[0,0,0]));let[a,o,s,c]=Iv(t,`quat`,[1,0,0,0]);i.quaternion.set(o,s,c,a).normalize(),e.add(i)}}let o;return{root:t,sync(e,t,n){if(t!==o){for(let n of i)if(n.id=e.mj_name2id(t,e.mjtObj.mjOBJ_BODY.value,n.name),n.id<0)throw Error(`Missing shared-world body ${n.name}`);o=t}let r=n.xpos,a=n.xquat;for(let{id:e,group:t}of i){t.position.fromArray(r,e*3);let n=e*4;t.quaternion.set(a[n+1],a[n+2],a[n+3],a[n])}},dispose(){t.removeFromParent();for(let e of n.values())e.dispose();for(let e of r.values())e.dispose()}}}var Rv=Object.freeze({x:0,y:0,z:0,roll:0,pitch:0,yaw:0,leftAntenna:0,rightAntenna:0,bodyYaw:0}),zv=Object.freeze([0,.6265471361608501,-.6265425506844697,.6265402507582232,-.6265361796605959,.6265371961549003,-.6265392354557596,-.1745,.1745]),Bv=[`yaw_body`,`stewart_1`,`stewart_2`,`stewart_3`,`stewart_4`,`stewart_5`,`stewart_6`,`right_antenna`,`left_antenna`],Vv=Math.PI/180,Hv=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Uv=(e,t,n)=>Math.max(t,Math.min(n,e));function Wv(e){let t={...Rv,...e};if(!Object.values(t).every(Number.isFinite))throw Error(`Pose values must be finite numbers`);let n=new W().makeRotationFromEuler(new wi(t.roll*Vv,t.pitch*Vv,t.yaw*Vv,`ZYX`));return n.setPosition(t.x/1e3,t.y/1e3,t.z/1e3),{head:n,antennas:[t.rightAntenna*Vv,t.leftAntenna*Vv],bodyYaw:t.bodyYaw*Vv}}function Gv(e,t,n){let r=new U,i=new U,a=new zr,o=new zr,s=new U;return e.head.decompose(r,a,s),t.head.decompose(i,o,s),{head:new W().compose(r.lerp(i,n),a.slerp(o,n),new U(1,1,1)),antennas:e.antennas.map((e,r)=>e+(t.antennas[r]-e)*n),bodyYaw:e.bodyYaw+(t.bodyYaw-e.bodyYaw)*n}}function Kv(e){let t=e.motors.map(e=>({...e,transform:new W().set(...e.T_motor_world.flat())})),n=e.motor_arm_length,r=e.rod_length;return function(i){let a=i.head.clone();a.elements[14]+=e.head_z_offset;let o=a.elements,s=Math.atan2(o[4],o[0]),c=-i.bodyYaw;c=s+Uv(c-s,-65*Vv,65*Vv),c=-Uv(c,-160*Vv,160*Vv),a.premultiply(new W().makeRotationZ(-c));let l=t.map(e=>{let t=new U(...e.branch_position).applyMatrix4(a).applyMatrix4(e.transform),i=t.x,o=t.y,s=t.z,c=i**2+2*i*n+o**2+s**2-r**2+n**2,l=-(i**4)-2*i**2*o**2-2*i**2*s**2+2*i**2*r**2+2*i**2*n**2-o**4-2*o**2*s**2+2*o**2*r**2+2*o**2*n**2-s**4+2*s**2*r**2-2*s**2*n**2-r**4+2*r**2*n**2-n**4,u=2*o*n+(e.solution?1:-1)*Math.sqrt(Math.max(0,l));return Hv(2*Math.atan2(u,c))}),u=[c,...l,...i.antennas];if(!u.every(Number.isFinite))throw Error(`Invalid Reachy kinematics result`);return u}}var qv=()=>new DOMException(`Playback stopped`,`AbortError`);function Jv(){let e=new Set;function t({duration:t,update:n=()=>{},until:r,maxDuration:i=1/0,signal:a}){return a?.aborted?Promise.reject(qv()):new Promise((o,s)=>{let c={elapsed:0,duration:t,update:n,until:r,maxDuration:i},l=t=>{e.delete(c),a?.removeEventListener(`abort`,u),t?s(t):o()},u=()=>l(qv());c.finish=l,a?.addEventListener(`abort`,u,{once:!0}),e.add(c)})}return{run:t,wait:(e,n)=>t({duration:e,signal:n}),until:(e,n,r)=>t({until:e,maxDuration:n,signal:r}),tick(t){for(let n of[...e])try{n.elapsed+=t;let e=n.duration===void 0?n.elapsed:Math.min(n.elapsed,n.duration);n.update(e),(n.until?n.until(n.elapsed):n.elapsed+1e-9>=n.duration)?n.finish():n.elapsed>=n.maxDuration&&n.finish(Error(`Robot did not finish its movement`))}catch(e){n.finish(e)}},cancel(){for(let t of[...e])t.finish(qv())}}}function Yv({mujoco:e,getWorld:t,calibration:n,timeline:r,onState:i=()=>{},isLocked:a=()=>!1}){let o=Kv(n),s=Wv(Rv),c=[...zv],l,u=[],d=null,f=[],p=1,m=new Set,h=(e={})=>i({playing:!!d,queue:f.map(e=>e.label),speed:p,...e});function g(e){let t=o(e);s=e,c=t}function _(){let{model:n,data:r}=t();l!==n&&(u=Bv.map(t=>{let r=e.mj_name2id(n,e.mjtObj.mjOBJ_ACTUATOR.value,Dv+t);if(r<0)throw Error(`Missing Reachy actuator ${t}`);return r}),l=n);let i=c;if(m.size){let e={...s,head:s.head.clone().multiply(new W().makeRotationZ(Math.sin(performance.now()*.012)*.055))};i=o(e)}u.forEach((e,t)=>{r.ctrl[e]=i[t]})}async function v(e,t,n,i=p){if(!Number.isFinite(t)||t<=0)throw Error(`Duration must be positive`);o(e);let a=s,c=t/i;await r.run({duration:c,signal:n,update(t){let n=Math.min(1,t/c),r=10*n**3-15*n**4+6*n**5;g(Gv(a,e,r))}})}async function y(e,t){if(d)throw Error(`Reachy is already playing`);if(t?.aborted)throw qv();let n=new AbortController;d=n;let r=()=>n.abort();t?.addEventListener(`abort`,r,{once:!0}),h({error:null});try{await e(n.signal)}catch(e){throw e.name!==`AbortError`&&h({error:e.message}),e}finally{t?.removeEventListener(`abort`,r),d=null,h()}}let b={write:_,get busy(){return!!d},setWobbler(e,t=`default`){e?m.add(t):m.delete(t)},get target(){return s},get motorTargets(){return[...c]},stop(){d?.abort()},clear(){d?.abort(),f=[],h()},setSpeed(e){if(!a()){if(!Number.isFinite(e)||e<.25||e>2)throw Error(`Playback speed must be 0.25–2`);p=e,h()}},enqueue(e,t,n=`Custom pose`){if(!a()){if(o(Wv(e)),!Number.isFinite(t)||t<=0)throw Error(`Duration must be positive`);f.push({pose:{...e},duration:t,label:n}),h()}},playQueue(){return a()?Promise.reject(Error(`Emotion playback owns the controls`)):y(async e=>{for(;f.length;){let t=f.shift();h(),await v(Wv(t.pose),t.duration,e)}})},playSequence(e){return a()?Promise.reject(Error(`Emotion playback owns the controls`)):y(async t=>{for(let n of e)await v(Wv(n.pose),n.duration,t)})},playMotion(e,t){return y(async t=>{await v(e.sample(0),.7,t,1),await r.run({duration:e.duration,signal:t,update:t=>g(e.sample(t))})},t)}};return h(),b}var Xv=Object.freeze({joy:3.24,sadness:9.02,anger:5.08});async function Zv(e,t,n){let{timeline:r}=t;if(n?.aborted)throw qv();try{if(e===`joy`)t.mode(`walk`),await r.run({duration:Xv.joy,signal:n,update(e){t.drive(.22,Math.sin(e*3.1)*.22),t.head([Math.sin(e*2.2)*.16,Math.sin(e*1.7)*.1,Math.sin(e*2.2)*.3,0]),Math.floor(e*2.4)!==Math.floor((e-1/50)*2.4)&&t.quack()}}),t.drive(0,0),t.head([0,0,0,0]);else if(e===`sadness`){t.drive(0,0),t.mode(`sit`);let e=performance.now();await r.until(()=>t.sitFlag===1,3,n);let i=Math.max(.1,Xv.sadness-(performance.now()-e)/1e3),a=-1;await r.run({duration:i,signal:n,update(e){t.head([-.62,-.48,Math.sin(e*1.35)*.36,0]);let n=Math.floor(e/(i/3));n<3&&n!==a&&(a=n,t.quack())}}),t.head([-.62,-.48,0,0])}else if(e===`anger`)t.mode(`walk`),await r.run({duration:Xv.anger,signal:n,update(e){let n=Math.floor(e*5.5),r=n%2==0?.18:-.14,i=n%2==0?1.15:-1.15;t.drive(r,i),t.head([0,0,n%2==0?.42:-.42,0]),Math.floor(e*3.2)!==Math.floor((e-1/50)*3.2)&&t.quack()}}),t.drive(0,0),t.head([0,0,0,0]);else throw Error(`Unknown emotion: ${e}`)}finally{t.drive(0,0),e!==`sadness`&&t.head([0,0,0,0])}}var Qv=Object.freeze({joy:{sentence:`Oh, you're happy! Me too!`,motion:`dance1`},sadness:{sentence:`Oh, you're sad! Me too!`,motion:`sad1`},anger:{sentence:`Oh, you're angry! Me too!`,motion:`rage1`}}),$v=e=>new W().set(...e.flat());async function ey(e){let t=await fetch(`./robot/reachy/emotions/${e}.json`);if(!t.ok)throw Error(`Unable to load Reachy emotion ${e}`);let n=await t.json(),r=n.time.map((e,t)=>{let r=n.set_target_data[t];return{time:e,target:{head:$v(r.head),antennas:[...r.antennas],bodyYaw:r.body_yaw}}}),i=r.at(-1)?.time??0;return{duration:i,sample(t){if(!r.length)throw Error(`Empty Reachy emotion ${e}`);if(t<=r[0].time)return r[0].target;if(t>=i)return r.at(-1).target;let n=1;for(;n{let r=!1,i=()=>{if(r)return;r=!0;let i=new SpeechSynthesisUtterance(e);i.lang=`en-US`;let a=speechSynthesis.getVoices?.()??[],o=/david|mark|guy|daniel|alex|arthur|thomas|george|ryan|google uk english male|microsoft (david|mark|ryan)/i,s=ty??a.find(e=>o.test(e.name)&&/^en[-_]gb/i.test(e.lang))??a.find(e=>o.test(e.name)&&/^en[-_]/i.test(e.lang))??a.find(e=>/^en[-_]gb/i.test(e.lang))??a.find(e=>/^en[-_]/i.test(e.lang));s&&(ty=s,i.voice=ty),i.pitch=1.28,i.rate=1.02;let c=()=>{t?.setWobbler?.(!1,`speech`),n()};i.onend=c,i.onerror=c,speechSynthesis.cancel(),speechSynthesis.speak(i)};(speechSynthesis.getVoices?.()??[]).length?i():(speechSynthesis.addEventListener?.(`voiceschanged`,i,{once:!0}),setTimeout(i,250))}))}function ry({runtime:e,reachy:t,setState:n}){let r=new Map,i=(t,i,a=!1)=>{if(r.has(t))return r.get(t);let o=(async()=>{n({emotionBusy:!0,emotionError:null}),a&&e.start();try{await i()}catch(e){throw n({emotionError:e?.message||String(e)}),e}finally{a&&e.finish(),r.delete(t),n({emotionBusy:r.size>0,emotionStage:r.size?`active`:null})}})();return r.set(t,o),o};return{get busy(){return!!r},play(t){let r=Qv[t];if(!r)throw Error(`Unknown emotion: ${t}`);return i(`sequence`,async()=>{n({emotionStage:`microduck`}),await Zv(t,e),n({emotionStage:`reachy`}),await a(t,r)},!0)},playMicroduck(t){return Qv[t]?i(`microduck`,async()=>{n({emotionStage:`microduck`}),await Zv(t,e)},!0):Promise.reject(Error(`Unknown emotion: ${t}`))},playReachy(e){let t=Qv[e];return t?i(`reachy`,async()=>{n({emotionStage:`reachy`}),await a(e,t)}):Promise.reject(Error(`Unknown emotion: ${e}`))},say:e=>ny(e,t)};async function a(e,n){let r=await ey(n.motion);ee(D(`./robot/reachy/emotions/${n.motion}.ogg`),{gain:.9}),t.setWobbler(!0,`emotion`);try{await t.playMotion(r)}finally{t.setWobbler(!1,`emotion`)}}}function iy({setState:e}){let t=[],n=new Map,r=!1,i=!1,a=null,o=()=>e({scriptRecording:r,scriptPlaying:i,scriptActions:t.map((e,t)=>({id:e.id,label:e.label,index:t,parallel:e.parallel,parallelGroup:e.parallelGroup,delay:e.delay||0})),savedScripts:[...n.keys()]}),s={get recording(){return r},get playing(){return i},start(){i||(r=!0,o())},stop(){r=!1,o()},toggle(){r?s.stop():s.start()},add(e,n,i={}){return!r||typeof n!=`function`?!1:(t.push({id:crypto.randomUUID(),label:e,run:n,parallel:!!i.parallel,delay:Math.max(0,Number(i.delay)||0)}),o(),!0)},toggleParallel(e){t[e]&&(t[e].parallelGroup&&(t[e].parallelGroup=null),t[e].parallel=!t[e].parallel,o())},setDelay(e,n){t[e]&&(t[e].delay=Math.max(0,Number(n)||0),o())},remove(e){t.splice(e,1),o()},clear(){t=[],o()},save(e){let r=String(e||``).trim();return!r||!t.length?!1:(n.set(r,t.slice()),o(),!0)},async run(e=null){let a=e?n.get(e):t;if(!(!a?.length||i)){i=!0,r=!1,o();try{for(let e=0;e(e.delay&&await c(e.delay),e.run())))}}finally{i=!1,o()}}},runSaved(e){return s.run(e)},wait(e){return c(e)},load(e){if(!a)throw Error(`Script loader is not ready`);let n=typeof e==`string`?JSON.parse(e):e,r=Array.isArray(n)?n:n?.actions;if(!Array.isArray(r)||!r.length)throw Error(`Script must contain an actions array`);return t=r.map(e=>{let t=a(e);if(!t?.run)throw Error(`Unknown script action: ${e?.action||e?.type||`?`}`);return{id:crypto.randomUUID(),label:t.label||e.label||e.action,run:t.run,parallel:!!e.parallel,parallelGroup:e.parallelGroup||null,delay:Math.max(0,Number(e.delay??e.startAfter)||0)}}),o(),!0}},c=e=>new Promise(t=>setTimeout(t,e*1e3));return s.bindWait=e=>{c=e},s.bindResolver=e=>{a=e},o(),s}var ay={type:`change`},oy={type:`start`},sy={type:`end`},cy=new mi,ly=new go,uy=Math.cos(70*cr.DEG2RAD),dy=class extends Fn{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction=`none`,this.enabled=!0,this.target=new U,this.cursor=new U,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:Me.ROTATE,MIDDLE:Me.DOLLY,RIGHT:Me.PAN},this.touches={ONE:Ne.ROTATE,TWO:Ne.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(e){e.addEventListener(`keydown`,Ce),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener(`keydown`,Ce),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(ay),n.update(),i=r.NONE},this.update=function(){let t=new U,u=new zr().setFromUnitVectors(e.up,new U(0,1,0)),d=u.clone().invert(),f=new U,p=new zr,m=new U,h=2*Math.PI;return function(g=null){let _=n.object.position;t.copy(_).sub(n.target),t.applyQuaternion(u),o.setFromVector3(t),n.autoRotate&&i===r.NONE&&D(T(g)),n.enableDamping?(o.theta+=s.theta*n.dampingFactor,o.phi+=s.phi*n.dampingFactor):(o.theta+=s.theta,o.phi+=s.phi);let v=n.minAzimuthAngle,S=n.maxAzimuthAngle;isFinite(v)&&isFinite(S)&&(v<-Math.PI?v+=h:v>Math.PI&&(v-=h),S<-Math.PI?S+=h:S>Math.PI&&(S-=h),v<=S?o.theta=Math.max(v,Math.min(S,o.theta)):o.theta=o.theta>(v+S)/2?Math.max(v,o.theta):Math.min(S,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(l,n.dampingFactor):n.target.add(l),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let C=!1;if(n.zoomToCursor&&x||n.object.isOrthographicCamera)o.radius=re(o.radius);else{let e=o.radius;o.radius=re(o.radius*c),C=e!=o.radius}if(t.setFromSpherical(o),t.applyQuaternion(d),_.copy(n.target).add(t),n.object.lookAt(n.target),n.enableDamping===!0?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,l.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),l.set(0,0,0)),n.zoomToCursor&&x){let r=null;if(n.object.isPerspectiveCamera){let e=t.length();r=re(e*c);let i=e-r;n.object.position.addScaledVector(y,i),n.object.updateMatrixWorld(),C=!!i}else if(n.object.isOrthographicCamera){let e=new U(b.x,b.y,0);e.unproject(n.object);let i=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),C=i!==n.object.zoom;let a=new U(b.x,b.y,0);a.unproject(n.object),n.object.position.sub(a).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),n.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(cy.origin.copy(n.object.position),cy.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(cy.direction))a||8*(1-p.dot(n.object.quaternion))>a||m.distanceToSquared(n.target)>a?(n.dispatchEvent(ay),f.copy(n.object.position),p.copy(n.object.quaternion),m.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener(`contextmenu`,Ee),n.domElement.removeEventListener(`pointerdown`,he),n.domElement.removeEventListener(`pointercancel`,_e),n.domElement.removeEventListener(`wheel`,z),n.domElement.removeEventListener(`pointermove`,ge),n.domElement.removeEventListener(`pointerup`,_e),n.domElement.getRootNode().removeEventListener(`keydown`,xe,{capture:!0}),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener(`keydown`,Ce),n._domElementKeyEvents=null)};let n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},i=r.NONE,a=1e-6,o=new dh,s=new dh,c=1,l=new U,u=new H,d=new H,f=new H,p=new H,m=new H,h=new H,g=new H,_=new H,v=new H,y=new U,b=new H,x=!1,S=[],C={},w=!1;function T(e){return e===null?2*Math.PI/60/60*n.autoRotateSpeed:2*Math.PI/60*n.autoRotateSpeed*e}function E(e){let t=Math.abs(e*.01);return .95**(n.zoomSpeed*t)}function D(e){s.theta-=e}function O(e){s.phi-=e}let k=function(){let e=new U;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),l.add(e)}}(),ee=function(){let e=new U;return function(t,r){n.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),l.add(e)}}(),te=function(){let e=new U;return function(t,r){let i=n.domElement;if(n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),k(2*t*o/i.clientHeight,n.object.matrix),ee(2*r*o/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(k(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),ee(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}}();function ne(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function A(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function j(e,t){if(!n.zoomToCursor)return;x=!0;let r=n.domElement.getBoundingClientRect(),i=e-r.left,a=t-r.top,o=r.width,s=r.height;b.x=i/o*2-1,b.y=-(a/s)*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function re(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function ie(e){u.set(e.clientX,e.clientY)}function ae(e){j(e.clientX,e.clientX),g.set(e.clientX,e.clientY)}function oe(e){p.set(e.clientX,e.clientY)}function se(e){d.set(e.clientX,e.clientY),f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;D(2*Math.PI*f.x/t.clientHeight),O(2*Math.PI*f.y/t.clientHeight),u.copy(d),n.update()}function M(e){_.set(e.clientX,e.clientY),v.subVectors(_,g),v.y>0?ne(E(v.y)):v.y<0&&A(E(v.y)),g.copy(_),n.update()}function ce(e){m.set(e.clientX,e.clientY),h.subVectors(m,p).multiplyScalar(n.panSpeed),te(h.x,h.y),p.copy(m),n.update()}function le(e){j(e.clientX,e.clientY),e.deltaY<0?A(E(e.deltaY)):e.deltaY>0&&ne(E(e.deltaY)),n.update()}function N(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):te(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):te(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?D(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):te(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?D(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):te(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}function ue(e){if(S.length===1)u.set(e.pageX,e.pageY);else{let t=je(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);u.set(n,r)}}function P(e){if(S.length===1)p.set(e.pageX,e.pageY);else{let t=je(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);p.set(n,r)}}function de(e){let t=je(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);g.set(0,i)}function F(e){n.enableZoom&&de(e),n.enablePan&&P(e)}function I(e){n.enableZoom&&de(e),n.enableRotate&&ue(e)}function L(e){if(S.length==1)d.set(e.pageX,e.pageY);else{let t=je(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);d.set(n,r)}f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;D(2*Math.PI*f.x/t.clientHeight),O(2*Math.PI*f.y/t.clientHeight),u.copy(d)}function fe(e){if(S.length===1)m.set(e.pageX,e.pageY);else{let t=je(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}h.subVectors(m,p).multiplyScalar(n.panSpeed),te(h.x,h.y),p.copy(m)}function R(e){let t=je(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);_.set(0,a),v.set(0,(_.y/g.y)**+n.zoomSpeed),ne(v.y),g.copy(_),j((e.pageX+t.x)*.5,(e.pageY+t.y)*.5)}function pe(e){n.enableZoom&&R(e),n.enablePan&&fe(e)}function me(e){n.enableZoom&&R(e),n.enableRotate&&L(e)}function he(e){n.enabled!==!1&&(S.length===0&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener(`pointermove`,ge),n.domElement.addEventListener(`pointerup`,_e)),!ke(e)&&(De(e),e.pointerType===`touch`?we(e):ve(e)))}function ge(e){n.enabled!==!1&&(e.pointerType===`touch`?Te(e):ye(e))}function _e(e){switch(Oe(e),S.length){case 0:n.domElement.releasePointerCapture(e.pointerId),n.domElement.removeEventListener(`pointermove`,ge),n.domElement.removeEventListener(`pointerup`,_e),n.dispatchEvent(sy),i=r.NONE;break;case 1:let t=S[0],a=C[t];we({pointerId:t,pageX:a.x,pageY:a.y})}}function ve(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Me.DOLLY:if(n.enableZoom===!1)return;ae(e),i=r.DOLLY;break;case Me.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enablePan===!1)return;oe(e),i=r.PAN}else{if(n.enableRotate===!1)return;ie(e),i=r.ROTATE}break;case Me.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enableRotate===!1)return;ie(e),i=r.ROTATE}else{if(n.enablePan===!1)return;oe(e),i=r.PAN}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(oy)}function ye(e){switch(i){case r.ROTATE:if(n.enableRotate===!1)return;se(e);break;case r.DOLLY:if(n.enableZoom===!1)return;M(e);break;case r.PAN:if(n.enablePan===!1)return;ce(e)}}function z(e){n.enabled!==!1&&n.enableZoom!==!1&&i===r.NONE&&(e.preventDefault(),n.dispatchEvent(oy),le(be(e)),n.dispatchEvent(sy))}function be(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return e.ctrlKey&&!w&&(n.deltaY*=10),n}function xe(e){e.key===`Control`&&(w=!0,n.domElement.getRootNode().addEventListener(`keyup`,Se,{passive:!0,capture:!0}))}function Se(e){e.key===`Control`&&(w=!1,n.domElement.getRootNode().removeEventListener(`keyup`,Se,{passive:!0,capture:!0}))}function Ce(e){n.enabled!==!1&&n.enablePan!==!1&&N(e)}function we(e){switch(Ae(e),S.length){case 1:switch(n.touches.ONE){case Ne.ROTATE:if(n.enableRotate===!1)return;ue(e),i=r.TOUCH_ROTATE;break;case Ne.PAN:if(n.enablePan===!1)return;P(e),i=r.TOUCH_PAN;break;default:i=r.NONE}break;case 2:switch(n.touches.TWO){case Ne.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;F(e),i=r.TOUCH_DOLLY_PAN;break;case Ne.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;I(e),i=r.TOUCH_DOLLY_ROTATE;break;default:i=r.NONE}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(oy)}function Te(e){switch(Ae(e),i){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;L(e),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;fe(e),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;pe(e),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;me(e),n.update();break;default:i=r.NONE}}function Ee(e){n.enabled!==!1&&e.preventDefault()}function De(e){S.push(e.pointerId)}function Oe(e){delete C[e.pointerId];for(let t=0;tn&&c.add(t)}c.normalize(),p.setXYZ(t+e,c.x,c.y,c.z)}}return u.setAttribute(`normal`,p),u}var hy=class extends Pp{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new xy(e)}),this.register(function(e){return new Sy(e)}),this.register(function(e){return new jy(e)}),this.register(function(e){return new My(e)}),this.register(function(e){return new Ny(e)}),this.register(function(e){return new wy(e)}),this.register(function(e){return new Ty(e)}),this.register(function(e){return new Ey(e)}),this.register(function(e){return new Dy(e)}),this.register(function(e){return new by(e)}),this.register(function(e){return new Oy(e)}),this.register(function(e){return new Cy(e)}),this.register(function(e){return new Ay(e)}),this.register(function(e){return new ky(e)}),this.register(function(e){return new vy(e)}),this.register(function(e){return new Py(e)}),this.register(function(e){return new Fy(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=um.extractUrlBase(e);a=um.resolveURL(t,this.path)}else a=um.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Lp(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw 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,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===Iy){try{a[_y.KHR_BINARY_GLTF]=new zy(e)}catch(e){r&&r(e);return}i=JSON.parse(a[_y.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new db(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function gy(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var _y={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_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},vy=class{constructor(e){this.parser=e,this.name=_y.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},My=class{constructor(e){this.parser=e,this.name=_y.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,a.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error(`THREE.GLTFLoader: WebP required by asset but unsupported.`);return n.loadTexture(e)})}detectSupport(){return this.isSupported||=new Promise(function(e){let t=new Image;t.src=`data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA`,t.onload=t.onerror=function(){e(t.height===1)}}),this.isSupported}},Ny=class{constructor(e){this.parser=e,this.name=_y.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,a.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error(`THREE.GLTFLoader: AVIF required by asset but unsupported.`);return n.loadTexture(e)})}detectSupport(){return this.isSupported||=new Promise(function(e){let t=new Image;t.src=`data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=`,t.onload=t.onerror=function(){e(t.height===1)}}),this.isSupported}},Py=class{constructor(e){this.name=_y.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},Fy=class{constructor(e){this.name=_y.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==Ky.TRIANGLES&&e.mode!==Ky.TRIANGLE_STRIP&&e.mode!==Ky.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new W,n=new U,a=new zr,s=new U(1,1,1),c=new xu(e.geometry,e.material,r);for(let e=0;e0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:`image/png`}var ub=new W,db=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gy,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,r=!1,i=-1;typeof navigator<`u`&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf(`Firefox`)>-1,i=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),this.textureLoader=typeof createImageBitmap>`u`||n||r&&i<98?new Up(this.options.manager):new _m(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Lp(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){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return nb(i,a,r),rb(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=Jy[n.magFilter]||1006,t.minFilter=Jy[n.minFilter]||1008,t.wrapS=Yy[n.wrapS]||1e3,t.wrapT=Yy[n.wrapT]||1e3,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new jr(e);t.needsUpdate=!0,n(t)}),t.load(um.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),e.userData.mimeType=a.mimeType||lb(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=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),i.extensions[_y.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[_y.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[_y.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new $u,aa.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new zu,aa.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return ep}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[_y.KHR_MATERIALS_UNLIT]){let e=r[_y.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new G(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],V),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,un)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||eb.OPAQUE;if(l===eb.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===eb.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==oa&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new H(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==oa&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==oa){let e=i.emissiveFactor;o.emissive=new G().setRGB(e[0],e[1],e[2],V)}return i.emissiveTexture!==void 0&&a!==oa&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,un)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),rb(n,i),t.associations.set(n,{materials:e}),i.extensions&&nb(r,n,i),n})}createUniqueName(e){let t=Zm.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[_y.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return pb(n,e,t)})}let a=[];for(let n=0,o=e.length;n0&&ab(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),rb(d,i),u.extensions&&nb(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n1?new hl:t.length===1?t[0]:new Vi,o!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof aa||e instanceof jr)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];Qy[i.path]===Qy.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(Qy[i.path]){case Qy.weights:c=Cp;break;case Qy.rotation:c=Tp;break;case Qy.position:case Qy.scale:c=Dp;break;default:switch(n.itemSize){case 1:c=Cp;break;default:c=Dp}}let l=r.interpolation===void 0?en:$y[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e({pos:[zb[0]+e*.357*Math.cos(Bb),-zb[1]+e*.357*Math.sin(Bb),.138],size:[.038,.15,.022],euler:[0,0,Bb]}))],zb[0],-zb[1],Math.PI/2;function Vb(){return[]}async function Hb({THREE:e,GLTFLoader:t,signed:n,scene:r,camera:i,renderer:a,fx:o,ceremony:s}){return{}}var Ub=`./robot/mjlab`,Wb=new Set([]);async function Gb(e){let t=await fetch(D(`${e}?v=11`),{cache:`force-cache`});if(!t.ok)throw Error(`kinematics fetch ${t.status}`);let n=await t.json();return new URLSearchParams(location.search).get(`lite`)===`1`&&(n.mesh_dir=n.mesh_dir.replace(/\/meshes$/,`/meshes-lite`)),n}var Kb=`${Ub}/microduck.glb`,qb=Math.PI/5,Jb=null;function Yb(){return Jb||=new hy().loadAsync(D(`${Kb}?v=11`)).then(e=>{let t=new Map;return e.scene.traverse(e=>{if(!e.isMesh||!e.geometry)return;let n=e.userData.meshFile||e.name||e.geometry.name;if(!n||t.has(n))return;let r=e.geometry;r.deleteAttribute(`normal`);let i=r.clone();i.scale(1e3,1e3,1e3);let a=my(i,qb);a.scale(.001,.001,.001);let o={display:a,welded:r};t.set(n,o),e.name&&e.name!==n&&t.set(e.name,o)}),t}),Jb}function Xb(e){let t=e.attributes.position,n=e.index,r=(n?n.count:t.count)/3,i=new ArrayBuffer(84+r*50),a=new DataView(i);a.setUint32(80,r,!0);let o=84,s=e=>{let r=n?n.getX(e):e;return[t.getX(r),t.getY(r),t.getZ(r)]};for(let e=0;e{let n=o.get(t);return n?Promise.resolve(n):(s.has(t)||s.set(t,new Fv().loadAsync(D(`${e.mesh_dir}/${t}?v=11`)).then(e=>{e.deleteAttribute(`normal`);let t=fy(e,1e-4);t.scale(1e3,1e3,1e3);let n=my(t,qb);return n.scale(.001,.001,.001),t.scale(.001,.001,.001),{display:n,welded:t}})),s.get(t))};for(let t of e.bodies){let e=new hl;e.name=t.name,e.position.set(t.pos[0],t.pos[1],t.pos[2]),e.quaternion.set(t.quat[1],t.quat[2],t.quat[3],t.quat[0]),i.set(t.name,e)}for(let t of e.bodies){let e=i.get(t.name);t.parent&&i.has(t.parent)?i.get(t.parent).add(e):r.add(e)}for(let t of e.bodies){if(!t.joint||t.joint.type&&t.joint.type!==`hinge`)continue;let e=i.get(t.name);a.set(t.joint.name,{body:e,axis:new U(...t.joint.axis).normalize(),baseQuat:e.quaternion.clone(),range:t.joint.range??null})}let l=new Map,u=t.materialForMesh??null,d=e=>{let t=e.color,n=e.roughness??.5,r=e.metalness??0,i=e.opacity??1,a=`${t.join(`,`)}|${n}|${r}|${i}`,o=l.get(a);if(o)return o;let s=new ep({color:new G(...t),roughness:n,metalness:r,transparent:i<1,opacity:i});return l.set(a,s),s},f=(e,t)=>e?Array.isArray(e)?{color:e.slice(0,3),opacity:e[3]??1}:e:{color:t.slice(0,3),opacity:t[3]??1},p=t.inkEdges??null,m=p?new zu({color:p.color??657934,transparent:!0,opacity:p.opacity??.55}):null,h=new Map,g=(e,t)=>(h.has(e)||h.set(e,new Qd(t,p.threshold??40)),h.get(e)),_=[],v=new URLSearchParams(location.search).get(`all`)===`1`,y=new Set;for(let t of e.bodies){let e=i.get(t.name);if(e)for(let n of t.geoms){if(n.type&&n.type!==`mesh`||!n.mesh||!v&&Wb.has(n.mesh))continue;let r=`${t.name}|${n.mesh}|${n.pos}|${n.quat}`;y.has(r)||(y.add(r),_.push(c(n.mesh).then(({display:r,welded:i})=>{let a=n.color?[n.color[0],n.color[1],n.color[2],n.color[3]??1]:[.85,.85,.85,1],o=f(u?.(n.mesh,t.name,a),a),s=new Wa(r,d(o));if(s.userData.meshName=n.mesh,n.pos&&s.position.set(...n.pos),n.quat&&s.quaternion.set(n.quat[1],n.quat[2],n.quat[3],n.quat[0]),e.add(s),m){let t=new Zu(g(n.mesh,i),m);t.position.copy(s.position),t.quaternion.copy(s.quaternion),e.add(t)}})))}}await Promise.all(_);let b={placer:n,root:r,bodies:i,joints:a};return tx(b),b}var Qb=new Set([`jaw.stl`,`jaw_soft.stl`]),$b=.32,ex=new U(0,4e-5,.0075);function tx(e){let t=[];if(e.root.traverse(e=>{e.isMesh&&Qb.has(e.userData.meshName)&&t.push(e)}),!t.length)return;let n=t[0].parent;e.placer.updateWorldMatrix(!0,!0);let r=(t.find(e=>e.userData.meshName===`jaw.stl`)??t[0]).localToWorld(ex.clone()),i=new U(0,0,-1),a=n.getWorldQuaternion(new zr).invert(),o=n.worldToLocal(r.clone()),s=i.applyQuaternion(a).normalize(),c=new hl;c.name=`jaw_pivot`,c.position.copy(o),c.userData.jawAxis=s.toArray(),n.add(c);for(let e of t)e.position.sub(o),c.add(e)}var nx=new U;function rx(e,t){e._jawPivot===void 0&&(e._jawPivot=e.placer.getObjectByName(`jaw_pivot`)??null);let n=e._jawPivot;n&&(nx.fromArray(n.userData.jawAxis),n.quaternion.setFromAxisAngle(nx,$b*t))}function ix(e,t,n){let r=e.joints.get(t);if(!r)return;let i=n;r.range&&(i=Math.min(r.range[1],Math.max(r.range[0],i)));let a=ax.setFromAxisAngle(r.axis,i);r.body.quaternion.copy(r.baseQuat).multiply(a)}var ax=new zr;function ox(e,t){for(let[n,r]of Object.entries(t))ix(e,n,r)}function sx(e){let t=e.placer.clone(!0),n=t.getObjectByName(`duck_root`),r=new Map;for(let n of e.bodies.keys())r.set(n,t.getObjectByName(n));let i=new Map;for(let[n,r]of e.joints)i.set(n,{body:t.getObjectByName(r.body.name),axis:r.axis,baseQuat:r.baseQuat.clone(),range:r.range});return{placer:t,root:n,bodies:r,joints:i}}var cx=new Hr;function lx(e,t=0){return e.placer.updateWorldMatrix(!0,!0),cx.setFromObject(e.placer),Number.isFinite(cx.min.y)?(e.placer.position.y+=t-cx.min.y,t-cx.min.y):0}var ux={left_hip_yaw:0,left_hip_roll:0,left_hip_pitch:-.5236,left_knee:1.0472,left_ankle:0,neck_pitch:1.02,head_pitch:.9,head_yaw:0,head_roll:0,right_hip_yaw:0,right_hip_roll:0,right_hip_pitch:.5236,right_knee:-1.0472,right_ankle:0},dx={color:[1,.413,.007],roughness:.4,metalness:0},fx={color:[1,.144,.008],roughness:.45,metalness:0},px={color:[1,.608,.021],roughness:.4,metalness:0},mx={color:[.888,.86,.798],roughness:.35,metalness:0},hx={color:[.012,.012,.014],roughness:.55,metalness:.3},gx={color:[.256,.256,.279],roughness:.5,metalness:.35},_x={color:[.01,.012,.02],roughness:.05,metalness:0},vx={color:[.328,.312,.283],roughness:.35,metalness:0},yx={color:[.028,.028,.033],roughness:.5,metalness:0},bx={color:[.017,.017,.019],roughness:.5,metalness:0},xx={color:[.443,.308,.663],roughness:.4,metalness:0},Sx={color:[.221,.134,.465],roughness:.45,metalness:0},Cx={color:[.462,.367,.688],roughness:.35,metalness:0},wx={color:[.36,.23,.48],roughness:.45,metalness:0},Tx={color:[.164,.085,.584],roughness:.45,metalness:0},Ex={color:[.441,.613,.723],roughness:.35,metalness:0},Dx={classic:{headDome:mx,facePlate:vx,trim:fx,beakUpper:dx,beakLower:fx,tongue:dx,eyeRing:dx,lens:_x,bodyShell:mx,sideShells:mx,legShells:mx,feet:fx,soles:px,hips:gx,mechDark:hx,mechGray:gx},charcoal:{headDome:yx,facePlate:vx,trim:px,beakUpper:wx,beakLower:px,tongue:wx,eyeRing:xx,lens:_x,bodyShell:bx,sideShells:bx,legShells:bx,feet:px,soles:Sx,hips:gx,mechDark:hx,mechGray:gx},purple:{headDome:Cx,facePlate:vx,trim:px,beakUpper:wx,beakLower:px,tongue:wx,eyeRing:Ex,lens:_x,bodyShell:Cx,sideShells:Cx,legShells:Cx,feet:px,soles:Sx,hips:gx,mechDark:hx,mechGray:gx,swatch:Tx},blue:{headDome:Ex,facePlate:vx,trim:fx,beakUpper:dx,beakLower:fx,tongue:dx,eyeRing:dx,lens:_x,bodyShell:Ex,sideShells:Ex,legShells:Ex,feet:fx,soles:px,hips:gx,mechDark:hx,mechGray:gx}};Object.keys(Dx);var Ox=`classic`,kx={classic:`Cream`,charcoal:`Graphite`,purple:`Lavender`,blue:`Sky`},Ax={classic:`#f7e6cb`,charcoal:`#6c6a68`,purple:`#bfa9cf`,blue:`#a9dbe8`};function jx(e){return{"top_head_shell.stl":e.headDome,"bottom_head_shell.stl":e.trim,"face_part.stl":e.facePlate,"noenoeil.stl":e.eyeRing,"lens.stl":e.lens,"m12_lens_holder.stl":e.mechDark,"soft_mouth_top.stl":e.beakUpper,"jaw.stl":e.beakLower,"jaw_soft.stl":e.tongue,"trunk_base.stl":e.bodyShell,"left_shell.stl":e.sideShells,"right_shell.stl":e.sideShells,"upper_leg_left.stl":e.legShells,"upper_leg_right.stl":e.legShells,"hip_l.stl":e.hips,"foot_left.stl":e.feet,"foot_right.stl":e.feet,"ankle_left.stl":e.feet,"ankle_right.stl":e.feet,"sole_left.stl":e.soles,"sole_right.stl":e.soles,"ankle_l_v1.stl":e.feet,"ankle_r_v1.stl":e.feet,"roller_blade.stl":e.feet,"rim.stl":e.soles,"tire.stl":e.mechDark,"xl330.stl":e.mechDark,"leg.stl":e.mechGray,"seeed_bearing__configuration_default.stl":e.mechDark,"yaw2roll.stl":e.mechDark,"bearing_roll.stl":e.mechDark,"neck.stl":e.mechGray,"np_f970.stl":e.mechDark,"pcb__raspberry_pi_zero_2_w.stl":e.mechDark,"elec_rpi_robot_hat_pcb.stl":e.mechDark,"banana_pcb_locker.stl":e.mechDark,"speaker.stl":e.mechDark,"upper_leg_rigidity_plate.stl":e.mechGray,"yaw_roll_motion.stl":e.mechGray,"neck_pitch.stl":e.mechGray,"motor_support.stl":e.mechGray,"power_support.stl":e.mechGray,"seeed_bearing__configuration__22x16x4.stl":e.mechGray}}var Mx=e=>{let t=jx(e);return n=>t[n]??e.mechGray},Nx=new Map;function Px(e){let t=`${e.color.join(`,`)}|${e.roughness??.5}|${e.metalness??0}`,n=Nx.get(t);return n||(n=new ep({color:new G(...e.color),roughness:e.roughness??.5,metalness:e.metalness??0}),Nx.set(t,n)),n}var Fx=.35,Ix=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Lx=new Map,Rx=0;function zx(){let e=performance.now()/1e3;for(let[t,n]of Lx){let r=Math.min(1,(e-n.start)/Fx),i=Ix(r);n.mat.color.lerpColors(n.fromColor,n.toColor,i),n.mat.roughness=n.fromRough+(n.toRough-n.fromRough)*i,n.mat.metalness=n.fromMetal+(n.toMetal-n.fromMetal)*i;let a=t.material;a!==n.mat&&a?.color&&(a.color.copy(n.mat.color),a.roughness=n.mat.roughness,a.metalness=n.mat.metalness),r>=1&&(Lx.delete(t),a===n.mat&&(t.material=Px(n.spec),n.mat.dispose()))}Rx=Lx.size?requestAnimationFrame(zx):0}function Bx(e,t){let n=typeof t==`string`?Dx[t]:t,r=jx(n),i=!!e.placer?.parent;e.root.traverse(e=>{if(!e.isMesh||!e.userData.meshName)return;let t=r[e.userData.meshName]??n.mechGray,a=Px(t);if(!i){Lx.delete(e),e.material=a;return}if(e.material===a&&!Lx.has(e))return;let o=e.material,s=a.clone();s.color.copy(o.color),s.roughness=o.roughness,s.metalness=o.metalness,Lx.set(e,{mat:s,spec:t,fromColor:o.color.clone(),toColor:a.color.clone(),fromRough:o.roughness,toRough:a.roughness,fromMetal:o.metalness,toMetal:a.metalness,start:performance.now()/1e3}),e.material=s}),Lx.size&&!Rx&&(Rx=requestAnimationFrame(zx))}var Vx=new Float32Array(3),Hx=class{#e=[];#t=new Map;#n=!1;#r={jaw:0,orbitX:0,orbitY:0,ride:0};constructor({sources:e=[]}={}){for(let t of e)this.addSource(t)}addSource(e){e.onAction=(t,n)=>this.#i(t,{source:e.id,...n}),this.#e.push(e)}get sources(){return this.#e}init(){for(let e of this.#e)e.init?.()}dispose(){for(let e of this.#e)e.dispose?.()}update(e){for(let t of this.#e)t.poll?.(e);let t=0,n=0,r=0,i=0;for(let e of this.#e){let a=e.axes;a&&(t=Math.max(t,a.jaw??0),i=Math.max(i,a.ride??0),Math.abs(a.orbitX??0)>Math.abs(n)&&(n=a.orbitX),Math.abs(a.orbitY??0)>Math.abs(r)&&(r=a.orbitY))}this.#r.jaw=t,this.#r.orbitX=n,this.#r.orbitY=r,this.#r.ride=i}setLocked(e){this.#n=!!e}get locked(){return this.#n}getCommand(){if(this.#n)return Vx;for(let e of this.#e)if(e.isActive())return e.command;let e=this.#e[this.#e.length-1];return e?e.command:Vx}getAxes(){return this.#r}anyActive(){return this.#e.some(e=>e.isActive())}getPressed(){let e={};for(let t of this.#e)e[t.id]=t.pressed??{};return e}on(e,t){let n=this.#t.get(e);return n||this.#t.set(e,n=new Set),n.add(t),()=>n.delete(t)}#i(e,t){let n=this.#t.get(e);if(n)for(let e of n)e(t)}},Ux={ArrowUp:`fwd`,KeyW:`fwd`,ArrowDown:`back`,KeyS:`back`,ArrowLeft:`turnl`,KeyA:`turnl`,ArrowRight:`turnr`,KeyD:`turnr`},Wx={KeyC:`chaseToggle`,KeyG:`groundPick`,KeyM:`locoToggle`,KeyR:`sitToggle`,KeyQ:`kickL`,KeyE:`kickR`,KeyF:`alternateKick`},Gx=class{id=`keyboard`;connected=!0;command=new Float32Array(3);axes={jaw:0,orbitX:0,orbitY:0};pressed={fwd:!1,back:!1,turnl:!1,turnr:!1};onAction=()=>{};#e=new Set;#t;#n=[NaN,NaN,NaN];#r=null;#i=null;#a=null;constructor({getVelocityLimits:e}){this.#t=e}init(){this.#r=e=>{if(e.target?.closest?.(`input, select, textarea, button, [contenteditable=true]`)||e.repeat)return;if(e.code===`Space`){e.preventDefault(),this.onAction(`reset`);return}let t=Wx[e.code];if(t){this.onAction(t);return}let n=Ux[e.code];n&&(e.preventDefault(),this.#e.add(n),this.#o())},this.#i=e=>{let t=Ux[e.code];t&&(this.#e.delete(t),this.#o())},this.#a=()=>{this.#e.clear(),this.#o()},window.addEventListener(`keydown`,this.#r),window.addEventListener(`keyup`,this.#i),window.addEventListener(`blur`,this.#a)}dispose(){window.removeEventListener(`keydown`,this.#r),window.removeEventListener(`keyup`,this.#i),window.removeEventListener(`blur`,this.#a)}isActive(){return this.#e.size>0}poll(){let[e,t,n]=this.#t();(e!==this.#n[0]||t!==this.#n[1]||n!==this.#n[2])&&this.#o()}#o(){let e=this.#t(),[t,n,r]=e;this.#n=e;let i=this.#e;this.command[0]=i.has(`fwd`)?t:i.has(`back`)?n:0,this.command[2]=i.has(`turnl`)?r:i.has(`turnr`)?-r:0,this.pressed.fwd=i.has(`fwd`),this.pressed.back=i.has(`back`),this.pressed.turnl=i.has(`turnl`),this.pressed.turnr=i.has(`turnr`)}},Kx=.15,qx=.12,Jx=e=>Math.abs(e)e&&e.connected);return e.find(e=>e.mapping===`standard`)??e[0]}var sS=class{id=`gamepad`;connected=!1;command=new Float32Array(3);axes={jaw:0,orbitX:0,orbitY:0,ride:0};headMode=!1;head={neckPitch:0,pitch:0,yaw:0,roll:0};pressed={a:!1,x:!1,y:!1,rb:!1,lb:!1,r3:!1,dpadDown:!1,dpadUp:!1};onAction=()=>{};#e;#t=!1;#n=0;#r=!1;#i=!1;#a=!1;#o=!1;constructor({getVelocityLimits:e}){this.#e=e}init(){}dispose(){}isActive(){return this.#t}poll(){let e=this.pressed,t=oS();if(this.connected=!!t,!t){this.#t&&(this.#t=!1,this.command.fill(0),this.axes.jaw=0),this.axes.orbitX=0,this.axes.orbitY=0,this.axes.ride=0,this.#s(),this.#o&&(this.#o=!1,this.#a=!1,this.onAction(`wheeeStop`));return}let n=performance.now(),r=Jx(t.axes[0]??0),i=Jx(t.axes[1]??0),a=Jx(t.axes[2]??0),o=Jx(t.axes[3]??0),[s,c,l]=this.#e(),u;if(this.headMode)u=[0,0,0],this.head.pitch=-i,this.head.yaw=-r,this.head.neckPitch=-o,this.head.roll=-a,this.axes.orbitX=0,this.axes.orbitY=0;else{let e=-i;u=[e>=0?e*s:e*-c,0,-r*l],this.#s(),this.axes.orbitX=a,this.axes.orbitY=o}for(let e=0;e<3;e++)this.command[e]+=qx*(u[e]-this.command[e]);!this.headMode&&(r!==0||i!==0)?this.#t=!0:this.#t&&Math.abs(this.command[0])+Math.abs(this.command[1])+Math.abs(this.command[2])<.01&&(this.#t=!1,this.command.fill(0));let d=!!t.buttons[nS]?.pressed;d&&!e.r3&&this.onAction(`chaseToggle`),e.r3=d;let f=!!t.buttons[Yx]?.pressed;f&&!e.a&&this.onAction(`groundPick`),e.a=f;let p=!!t.buttons[Xx]?.pressed;p&&!e.x&&this.onAction(`sitToggle`),e.x=p;let m=!!t.buttons[Zx]?.pressed;m&&!e.y&&this.onAction(`headToggle`),e.y=m;let h=!!t.buttons[$x]?.pressed;h&&!e.rb&&this.onAction(`kickR`),e.rb=h;let g=!!t.buttons[Qx]?.pressed;g&&!e.lb&&this.onAction(`kickL`),e.lb=g;let _=!!t.buttons[iS]?.pressed;_&&!e.dpadDown&&this.onAction(`sitToggle`),e.dpadDown=_;let v=!!t.buttons[rS]?.pressed;v&&!e.dpadUp&&(this.#n=n,this.#r=!1,this.onAction(`walk`)),v&&!this.#r&&n-this.#n>=aS&&(this.#r=!0,this.onAction(`locoToggle`)),e.dpadUp=v;let y=t.buttons[tS]?.value??0,b=t.buttons[eS]?.value??0;this.axes.jaw=Math.max(y,b),this.axes.ride=b;let x=!this.#i&&y>=.35;x?this.#i=!0:this.#i&&y<.2&&(this.#i=!1);let S=!this.#a&&b>=.3;S?this.#a=!0:this.#a&&b<.2&&(this.#a=!1);let C=this.#i&&!x;S&&!C?(this.#o=!0,this.onAction(`wheeeStart`)):this.#o&&!this.#a&&(this.#o=!1,this.onAction(`wheeeStop`)),x&&!this.#a&&!this.#o&&this.onAction(`quack`)}#s(){this.head.neckPitch=0,this.head.pitch=0,this.head.yaw=0,this.head.roll=0}},cS={fall:{prio:3,seq:[{d:450,s:1,w:.7}]},explode:{prio:4,seq:[{d:550,s:1,w:1}]},land:{prio:2,seq:[{d:170,s:.7,w:.35}]},kick:{prio:1,seq:[{d:90,s:.5,w:.2}]},ballHit:{prio:2,seq:[{d:120,s:.85,w:.4}]},bump:{prio:1,seq:[{d:130,s:.55,w:.25}]},recover:{prio:2,seq:[{d:70,s:.3,w:.45},{gap:90},{d:100,s:.5,w:.65}]}},lS=240,uS=.12,dS=.4,fS=.03,pS={until:0,prio:0},mS=0,hS=0,gS=0,_S=!1,vS=()=>oS()?.vibrationActuator??null,yS=(e,t,n)=>{e.playEffect(`dual-rumble`,{duration:t.d,strongMagnitude:Math.min(1,t.s*n),weakMagnitude:Math.min(1,t.w*n)}).catch(()=>{})};function bS(e,t=1){let n=cS[e];if(!n)return;let r=vS();if(!r?.playEffect)return;let i=performance.now();if(i{if(a!==mS)return;let n=vS();n?.playEffect&&yS(n,e,t)},o),o+=e.d)}function xS(e){hS=Math.max(0,Math.min(1,e))}function SS(){let e=performance.now();if(efS)e-gS>=lS&&(gS=e,_S=!0,t.playEffect?.(`dual-rumble`,{duration:480,strongMagnitude:Math.min(1,uS*hS),weakMagnitude:Math.min(1,dS*hS)}).catch(()=>{}));else if(_S){_S=!1,gS=0;try{t.reset?.()?.catch?.(()=>{})}catch{}}}}var CS={pulse:bS,setBed:xS,tick:SS},wS=.18,TS=.12,ES=class{id=`touch`;connected=!1;command=new Float32Array(3);axes={jaw:0,orbitX:0,orbitY:0};pressed={stick:!1,a:!1,b:!1};onAction=()=>{};#e;#t=!1;#n=[0,0];#r=null;#i=null;#a=[];constructor({getVelocityLimits:e}){this.#e=e}init(){this.#r=window.matchMedia(`(pointer: coarse)`),window.__microduckTouched&&(this.connected=!0),this.#i=()=>{this.connected=this.connected||this.#r.matches},this.#r.addEventListener(`change`,this.#i),this.#i();let e=()=>{this.connected=!0};window.addEventListener(`touchstart`,e,{once:!0,passive:!0}),this.#a.push(()=>window.removeEventListener(`touchstart`,e));let t=document.getElementById(`touch-zone`),n=document.getElementById(`touch-stick`),r=n?.querySelector(`.nub`);t&&n&&r&&this.#s(t,n,r),this.#c(`touch-a`,`a`,()=>this.onAction(`alternateKick`)),this.#c(`touch-b`,`b`,()=>this.onAction(`quack`))}dispose(){this.#r?.removeEventListener(`change`,this.#i);for(let e of this.#a)e();this.#a=[]}isActive(){return this.#t}poll(){let[e,t]=this.#n,[n,r,i]=this.#e(),a=t>=0?t*n:t*-r,o=-e*i;this.command[0]+=wS*(a-this.command[0]),this.command[2]+=wS*(o-this.command[2]),this.pressed.stick?this.#t=!0:this.#t&&Math.abs(this.command[0])+Math.abs(this.command[2])<.01&&(this.#t=!1,this.command.fill(0)),this.axes.jaw=+!!this.pressed.b}#o(e,t,n){e.addEventListener(t,n),this.#a.push(()=>e.removeEventListener(t,n))}#s(e,t,n){let r=null,i=null,a=r=>{let a=e.getBoundingClientRect(),o=t.offsetWidth/2*.62,s=r.clientX-a.left-i.x,c=r.clientY-a.top-i.y,l=Math.hypot(s,c);l>o&&(s*=o/l,c*=o/l),n.style.transform=`translate(${s}px, ${c}px)`;let u=s/o,d=-c/o,f=Math.hypot(u,d)>=TS;this.#n[0]=f?u:0,this.#n[1]=f?d:0},o=()=>{r=null,i=null,this.pressed.stick=!1,t.classList.remove(`live`),n.style.transform=``,t.style.left=``,t.style.top=``,t.style.bottom=``,this.#n[0]=0,this.#n[1]=0};this.#o(e,`pointerdown`,n=>{n.preventDefault(),r=n.pointerId;let o=e.getBoundingClientRect(),s=t.offsetWidth/2;i={x:n.clientX-o.left,y:n.clientY-o.top},t.style.left=`${i.x-s}px`,t.style.top=`${i.y-s}px`,t.style.bottom=`auto`,this.pressed.stick=!0,t.classList.add(`live`),a(n);try{e.setPointerCapture(n.pointerId)}catch{}}),this.#o(e,`pointermove`,e=>{e.pointerId===r&&a(e)}),this.#o(e,`pointerup`,e=>{e.pointerId===r&&o()}),this.#o(e,`pointercancel`,e=>{e.pointerId===r&&o()})}#c(e,t,n){let r=document.getElementById(e);if(!r)return;this.#o(r,`pointerdown`,e=>{e.preventDefault(),this.pressed[t]=!0,r.classList.add(`down`),n();try{r.setPointerCapture(e.pointerId)}catch{}});let i=()=>{this.pressed[t]=!1,r.classList.remove(`down`)};this.#o(r,`pointerup`,i),this.#o(r,`pointercancel`,i)}},DS=.12,OS=2.2,kS=.15,AS=6,jS=500,MS=e=>Math.atan2(Math.sin(e),Math.cos(e)),NS=new go(new U(0,1,0),0),PS=class{id=`waypoint`;connected=!0;command=new Float32Array(3);axes={jaw:0,orbitX:0,orbitY:0};pressed={};onAction=()=>{};#e;#t;#n;#r;#i;#a;#o=null;#s=!1;#c=null;#l=new ch;#u=new H;#d=new U;#f=null;#p=null;constructor({camera:e,renderer:t,getVelocityLimits:n,getDuckPose:r,isSuppressed:i,getManualOverride:a}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i,this.#a=a}init(){this.#f=e=>{e.pointerType===`mouse`&&e.button===0&&e.target===this.#t.domElement&&(this.#i()||(this.#c={x:e.clientX,y:e.clientY,t:performance.now()}))},this.#p=e=>{if(!this.#c||e.pointerType!==`mouse`||e.button!==0){this.#c=null;return}let{x:t,y:n,t:r}=this.#c;if(this.#c=null,this.#i())return;let i=Math.hypot(e.clientX-t,e.clientY-n),a=performance.now()-r;i>AS||a>jS||this.#m(e)},window.addEventListener(`pointerdown`,this.#f),window.addEventListener(`pointerup`,this.#p)}dispose(){window.removeEventListener(`pointerdown`,this.#f),window.removeEventListener(`pointerup`,this.#p)}isActive(){return this.#s}get target(){return this.#o}cancel(){this.#o=null,this.#s=!1,this.command.fill(0)}poll(){if(this.#o&&this.#a()&&(this.#o=null),!this.#o){this.command.fill(0),this.#s=!1;return}let[e,t,n]=this.#r(),r=this.#o[0]-e,i=this.#o[1]-t;if(Math.hypot(r,i)BS,createWireframeFx:()=>JS,dispose:()=>rC,init:()=>XS,isDone:()=>eC,name:()=>IS,restore:()=>nC,setProgress:()=>tC,start:()=>ZS,startReverse:()=>QS,update:()=>$S}),IS=`wireframe`,LS=.6,RS=.3,zS=.6,BS=.8999999999999999,VS=e=>Math.min(Math.max(e,0),1),HS=e=>1-(1-e)*(1-e),US=e=>{let t=Math.sin(e*127.1)*43758.5453;return t-Math.floor(t)},WS=e=>{let t=.82+.18*US(Math.floor(e*60)+.5);return US(Math.floor(e*24)+7.7)<.12&&(t*=.5),t},GS=0,KS=.025,qS=.35;function JS(){let e={value:-1e3},t={value:-1e3},n={value:1},r={value:0},i={value:1},a=null,o=0,s=1,c=!1,l=!1,u=0,d=.3,f=1,p=()=>BS*f,m=new Map,h=null,g=null,_=[],v=e=>e.isMesh&&!e.userData.fxOverlay;function y(e){let n=m.get(e.uuid);if(n)return n;n=e.clone(),n.onBeforeCompile=e=>{e.uniforms.uFxSolidY=t,e.uniforms.uFxSpanK=i,e.vertexShader=e.vertexShader.replace(`#include `,`#include +varying vec3 vFxW;`).replace(`#include `,`#include +vFxW = (modelMatrix * vec4(transformed, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include +varying vec3 vFxW; +uniform float uFxSolidY; +uniform float uFxSpanK;`).replace(`#include `,`#include +float fxEdge = 0.0; +if (vFxW.y > uFxSolidY) discard; +fxEdge = 1.0 - smoothstep(0.002 * uFxSpanK, 0.018 * uFxSpanK, uFxSolidY - vFxW.y);`).replace(`#include `,`#include +gl_FragColor.rgb += fxEdge * vec3(0.95, 0.32, 0.05);`)};let r=`microduck-fx-wireframe-${GS++}`;return n.customProgramCacheKey=()=>r,n.needsUpdate=!0,m.set(e.uuid,n),n}function b(){h||(h=[],a.root.traverse(e=>{if(!v(e))return;let t=e.material,n=y(t);h.push([e,t,n]),e.material=n}))}function x(){if(h){for(let[e,t,n]of h)e.material===n&&(e.material=t);h=null}}function S(a){return new a.ShaderMaterial({uniforms:{uScanY:e,uSolidY:t,uFlicker:n,uTime:r,uSpanK:i},vertexShader:` + varying vec3 vW; + void main() { + vec4 wp = modelMatrix * vec4(position, 1.0); + vW = wp.xyz; + gl_Position = projectionMatrix * viewMatrix * wp; + }`,fragmentShader:` + uniform float uScanY, uSolidY, uFlicker, uTime, uSpanK; + varying vec3 vW; + void main() { + if (vW.y > uScanY || vW.y < uSolidY) discard; + float lead = 1.0 - smoothstep(0.0, 0.06 * uSpanK, uScanY - vW.y); + float tail = smoothstep(0.0, 0.018 * uSpanK, vW.y - uSolidY); + float stripes = 0.7 + 0.3 * sin(vW.y * 900.0 / uSpanK - uTime * 45.0); + vec3 c = vec3(1.0, 0.34, 0.06) * (0.55 + 1.6 * lead); + float a = (0.10 + 0.40 * lead) * stripes * tail * uFlicker; + gl_FragColor = vec4(c, a); + }`,wireframe:!0,transparent:!0,blending:a.AdditiveBlending,depthWrite:!1,depthTest:!0})}function C(e,t){g=S(e),t.traverse(t=>{if(!v(t))return;let n=new e.Mesh(t.userData.fxWireGeometry??t.geometry,g);n.userData.fxOverlay=!0,n.renderOrder=5,n.visible=!1,t.add(n),_.push(n)})}function w(i){let a=HS(VS(i/(LS*f))),o=HS(VS((i-RS*f)/(zS*f)));n.value=WS(i),r.value=i;let s=a>0&&a<1?(US(i*41.3)-.5)*.02*d:0;e.value=u+d*a+s,t.value=u+d*o;let c=i>0&&o<1;for(let e of _)e.visible=c}function T(){s>0?x():w(0);for(let e of _)e.visible=!1;l=!0,c=!1}function E(){let{THREE:e,root:t}=a;t.updateWorldMatrix(!0,!0);let n=new e.Box3().setFromObject(t);u=Math.min(n.min.y,0)-KS,d=Math.max(n.max.y-u,.04)*1.06,i.value=Math.max(1,d/qS),f=Math.min(Math.sqrt(i.value),2.5)}function D(e,t){s=e,t&&(o=e>0?0:p()),l=!1,E(),b(),w(o),c=!0}function O({THREE:e,scene:t,rig:n,root:r,camera:i,renderer:u,hidden:d=!0}){let f=r??n.placer;a={THREE:e,scene:t,root:f,camera:i,renderer:u},E(),C(e,f),o=0,s=1,l=!1,c=!1,d&&(b(),w(0))}function k(){D(1,!c)}function ee(){D(-1,!c)}function te(e){if(!(!c||l)){if(o+=s*e,s>0&&o>=p()){o=p(),w(o),T();return}if(s<0&&o<=0){o=0,w(o),T();return}w(o)}}function ne(){return l}function A(e){c=!1,l=!1,s=1,E(),b(),o=VS(e)*p(),w(o)}function j(){x()}function re(){x();for(let e of _)e.parent?.remove(e);_=[],g?.dispose(),g=null,a=null,c=!1,l=!1}return{init:O,start:k,startReverse:ee,update:te,isDone:ne,setProgress:A,restore:j,dispose:re,get playing(){return c},get reversing(){return c&&s<0},get TOTAL_S(){return p()}}}var YS=JS(),XS=(...e)=>YS.init(...e),ZS=(...e)=>YS.start(...e),QS=(...e)=>YS.startReverse(...e),$S=(...e)=>YS.update(...e),eC=(...e)=>YS.isDone(...e),tC=(...e)=>YS.setProgress(...e),nC=(...e)=>YS.restore(...e),rC=(...e)=>YS.dispose(...e);function iC(){let e=new to({transparent:!0,depthWrite:!1,uniforms:{uCell:{value:.1},uSection:{value:Ab},uCellColor:{value:new G(9339761)},uSectionColor:{value:new G(16757606)},uFadeDist:{value:3},uFocus:{value:new U},uReveal:{value:0},uTopoScale:{value:0},uBumps:{value:Pb.map(([e,t,n,r])=>new Mr(e,-t,n,r))}},vertexShader:` + #define NBUMPS ${Pb.length} + varying vec3 vWorld; + uniform float uTopoScale; + uniform vec4 uBumps[NBUMPS]; + // Same analytic relief as the physics heightfield (game.js topoH): + // a sum of cosine bumps, displacing the grid surface itself so the + // floor genuinely deforms - lines flow up the slopes for free since + // the fragment shader draws them from world xz. + float topoH(vec2 p) { + float H = 0.0; + for (int i = 0; i < NBUMPS; i++) { + float u = distance(p, uBumps[i].xy) / uBumps[i].w; + if (u < 1.0) H += uBumps[i].z * (0.5 + 0.5 * cos(3.14159265 * u)); + } + return H; + } + void main() { + vec4 w = modelMatrix * vec4(position, 1.0); + if (uTopoScale > 0.0) w.y += topoH(w.xz) * uTopoScale; + vWorld = w.xyz; + gl_Position = projectionMatrix * viewMatrix * w; + } + `,fragmentShader:` + varying vec3 vWorld; + uniform float uCell, uSection, uFadeDist, uReveal; + uniform vec3 uCellColor, uSectionColor, uFocus; + // Tron-style line: a thicker antialiased core plus a faint, much + // wider halo added on top (squared falloff keeps it a whisper of a + // glow rather than a bloom wash). + float lineProf(float g) { + float core = 1.0 - smoothstep(0.0, 1.8, g); + float halo = 1.0 - smoothstep(0.0, 7.0, g); + return core + halo * halo * 0.22; + } + float gridLine(vec2 p, float size) { + vec2 r = p / size; + vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r); + return lineProf(min(g.x, g.y)); + } + // Entrance draw-in: one family of parallel lines, drawn line by line. + // id picks the line, "along" runs down its length. Each line waits + // out its own hashed delay, then extends from the origin outward with + // a hard front. Returns (mask, head): head marks the bright segment + // right behind the draw front while the line is still growing. + vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) { + float jit = fract(sin(id * 127.1) * 43758.5453); + float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0); + float len = grow * maxLen; + float a = abs(along); + float mask = 1.0 - smoothstep(len - 0.05, len, a); + float head = (1.0 - smoothstep(0.0, 0.6, len - a)) * mask + * step(0.001, grow) * (1.0 - step(0.999, grow)); + return vec2(mask, head); + } + void main() { + float cell = gridLine(vWorld.xz, uCell); + // Section lattice shifted half a cell: with 5 sections across the + // 3 m arena (odd count) this centers a CELL on the origin and puts + // section lines exactly on the walls at +-1.5. + vec2 pSec = vWorld.xz + 0.5 * uSection; + float section = gridLine(pSec, uSection); + float d = distance(vWorld.xz, uFocus.xz); + float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6); + vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0)); + float alpha = min(max(section * 0.6, cell * 0.4) * fade, 1.0); + // Entrance: only the bright section lines get the line-by-line draw + // (staggered, with a hot draw head); the fine cells just fade in + // over the reveal's second half - drawing every small line reads as + // visual noise. lineProf(min(gx, gy)) == max of per-axis profiles + // (profile is monotonic) and the cell fade lands on exactly the + // steady-state cell term, so at uReveal 1 this branch equals the + // formula above exactly (and is skipped). + if (uReveal < 1.0) { + vec2 rs = pSec / uSection; + vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs); + // Const-x lines run along z and vice versa; the offset + // decorrelates the two families' hashed delays. + vec2 sx = drawLine(floor(rs.x + 0.5), vWorld.z, 0.00, 0.30, 0.35, 8.0); + vec2 sz = drawLine(floor(rs.y + 0.5) + 57.0, vWorld.x, 0.05, 0.30, 0.35, 8.0); + float secR = max(lineProf(gs.x) * sx.x, lineProf(gs.y) * sz.x); + float cellR = cell * smoothstep(0.5, 1.0, uReveal); + float headGlow = max(lineProf(gs.x) * sx.y, lineProf(gs.y) * sz.y); + col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0)); + alpha = min(max(secR * 0.6, cellR * 0.4) * fade, 1.0); + // Bright draw head: a short white-hot tip sells the "drawing" read. + headGlow = clamp(headGlow, 0.0, 1.0); + col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8); + alpha = min(alpha + headGlow * fade * 0.5, 1.0); + } + if (alpha < 0.004) discard; + gl_FragColor = vec4(col, alpha); + } + `}),t=new Wa(new So(30,30,256,256),e);return t.rotation.x=-Math.PI/2,t}function aC(e){return new to({transparent:!0,depthWrite:!1,side:2,uniforms:{uCell:{value:.1},uSection:{value:Ab},uCellColor:{value:new G(9339761)},uSectionColor:{value:new G(16757606)},uFadeDist:{value:5},uFocus:{value:new U},uWallH:{value:Ob},uAlongX:{value:+!!e},uReveal:{value:0}},vertexShader:` + varying vec3 vWorld; + void main() { + vec4 w = modelMatrix * vec4(position, 1.0); + vWorld = w.xyz; + gl_Position = projectionMatrix * viewMatrix * w; + } + `,fragmentShader:` + varying vec3 vWorld; + uniform float uCell, uSection, uFadeDist, uWallH, uAlongX, uReveal; + uniform vec3 uCellColor, uSectionColor, uFocus; + // Same Tron-style core + faint halo as the floor grid. + float lineProf(float g) { + float core = 1.0 - smoothstep(0.0, 1.8, g); + float halo = 1.0 - smoothstep(0.0, 7.0, g); + return core + halo * halo * 0.22; + } + float gridLine(vec2 p, float size) { + vec2 r = p / size; + vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r); + return lineProf(min(g.x, g.y)); + } + // Same line-by-line draw as the floor grid (see its comments). + vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) { + float jit = fract(sin(id * 127.1) * 43758.5453); + float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0); + float len = grow * maxLen; + float a = abs(along); + float mask = 1.0 - smoothstep(len - 0.05, len, a); + float head = (1.0 - smoothstep(0.0, 0.35, len - a)) * mask + * step(0.001, grow) * (1.0 - step(0.999, grow)); + return vec2(mask, head); + } + void main() { + // Wall surface coords: the in-plane horizontal world axis + height. + float h = mix(vWorld.z, vWorld.x, uAlongX); + vec2 p = vec2(h, vWorld.y); + float cell = gridLine(p, uCell); + // Horizontal axis shifted half a section to match the floor's odd + // lattice (vertical section lines meet the floor's at the base); + // the height axis keeps its base line at y = 0. + vec2 pSec = vec2(p.x + 0.5 * uSection, p.y); + float section = gridLine(pSec, uSection); + float d = distance(vWorld.xz, uFocus.xz); + float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6); + float vert = 1.0 - clamp(vWorld.y / uWallH, 0.0, 1.0); + vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0)); + float alpha = min(max(section * 0.9, cell * 0.6) * fade * (0.3 + 0.7 * vert), 1.0); + // Entrance: section lines only - horizontals zip out from the + // wall's center, verticals rise from the ground, each with a + // hashed delay; the fine cells fade in over the reveal's second + // half. Same steady-state equivalence argument as the floor grid. + if (uReveal < 1.0) { + vec2 rs = pSec / uSection; + vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs); + // Const-height lines run along h (grow from center outward); + // const-h lines run along y (grow up from the ground). + vec2 sh = drawLine(floor(rs.y + 0.5), p.x, 0.00, 0.30, 0.40, 2.0); + vec2 sv = drawLine(floor(rs.x + 0.5) + 31.0, p.y, 0.30, 0.30, 0.30, uWallH); + float secR = max(lineProf(gs.y) * sh.x, lineProf(gs.x) * sv.x); + float cellR = cell * smoothstep(0.5, 1.0, uReveal); + float headGlow = max(lineProf(gs.y) * sh.y, lineProf(gs.x) * sv.y); + col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0)); + alpha = min(max(secR * 0.9, cellR * 0.6) * fade * (0.3 + 0.7 * vert), 1.0); + headGlow = clamp(headGlow, 0.0, 1.0); + col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8); + alpha = min(alpha + headGlow * fade * 0.5, 1.0); + } + if (alpha < 0.004) discard; + gl_FragColor = vec4(col, alpha); + } + `})}var oC=e=>{let t=Math.sin(e*127.1)*43758.5453;return t-Math.floor(t)};function sC(){let e=[],t=[];for(let t=-2;t<=3;t++){let n=oC(t),r=oC(t+57);e.push({at:0+n*.3,u:n}),e.push({at:.05+r*.3,u:r})}t.push({at:0+oC(0)*.3,u:oC(0)});for(let e=-2;e<=3;e++){let n=oC(e+31);t.push({at:.3+n*.3,u:n})}return{grid:e,walls:t}}function cC(){let e=[],t=[],n=2*(Db+kb),r=[{x:Db,z:0,rotY:-Math.PI/2,alongX:!1},{x:-Db,z:0,rotY:Math.PI/2,alongX:!1},{x:0,z:Db,rotY:Math.PI,alongX:!0},{x:0,z:-Db,rotY:0,alongX:!0}];for(let i of r){let r=aC(i.alongX);e.push(r);let a=new Wa(new So(n,Ob),r);a.position.set(i.x,Ob/2,i.z),a.rotation.y=i.rotY,t.push(a)}return{wallMats:e,wallMeshes:t}}var lC=.9,uC=1.1,dC=.35,fC=.9,pC=.6,mC=e=>Math.min(Math.max(e,0),1);function hC({THREE:e,scene:t,camera:n,renderer:r,fx:i,getRig:a,grid:o,wallMats:s,syncRig:c,startCameraReset:l,setLocked:u,flashReset:d,onScanCue:f=()=>{},onLineCue:p=()=>{},onPropCue:m=()=>{}}){let h=Math.max(uC,1.25,pC+i.TOTAL_S),g=sC(),_=[...g.grid.map(e=>({at:e.at*uC,u:e.u})),...g.walls.map(e=>({at:dC+e.at*fC,u:e.u}))].sort((e,t)=>e.at-t.at),v=_.length,y=null,b=null,x=[],S=null,C=!1,w=!1,T=null,E,D=new Promise(e=>{E=e});function O(){let o=a();y!==o&&(i.dispose(),i.init({THREE:e,scene:t,rig:o,camera:n,renderer:r}),o.placer.traverse(e=>{e.isMesh&&!e.userData.meshName&&(e.userData.fxOverlay=!0)}),y=o)}function k(){O(),i.start(),b=performance.now(),ee(),f(i.TOTAL_S)}function ee(){let e=performance.now();for(let t of x)t.at=e+t.delayS*1e3,t.started=!1,t.prev=null}function te(){for(let e of x)e.fx.setProgress(0),e.at=null,e.started=!1}function ne(){for(let e of x)e.started||e.fx.start(),e.fx.update(1e3),e.at=null}function A(e){for(let t of x)t.fx.setProgress(e),t.at=null,t.started=!1}function j(){let e=performance.now();for(let t of x){if(t.at===null||e=pC&&!C&&(C=!0,k()),re(),e>=h){if(!i.isDone()&&e=.8&&(T.scanCued=!0,k()),T.scanCued&&re(),T.scanCued&&i.isDone()&&(T=null,u(!1))}function ce(){oe(),M(),j()}function le(e,t=e){S=null,o.material.uniforms.uReveal.value=e;for(let e of s)e.uniforms.uReveal.value=t}function N(e){S=null,T=null,O(),e>=1?(i.start(),ie(),ne(),u(!1),E()):(i.setProgress(e),A(e))}function ue(e,t=0){x.push({fx:e,delayS:t,at:null,started:!1,prev:null})}return O(),{CAM_RESET_S:lC,startEntrance:ae,playRespawn:se,drive:ce,bind:O,setReveal:le,setFx:N,addPropFx:ue,entranceFinished:D,get entranceDone(){return w},get respawnActive(){return T!==null}}}var gC=.35,_C=.25;function vC({THREE:e,scene:t,camera:n,renderer:r,fxModule:i,mesh:a,group:o}){let s=i.createWireframeFx();s.init({THREE:e,scene:t,root:o,camera:n,renderer:r,hidden:!1});let c=`hidden`,l=null,u=!1,d=null;function f(){c=`live`,l=null,a.visible=!0,s.start(),d=performance.now()}function p({cancelQueued:e=!1,parkPhysics:t}){e&&(u=!1),c!==`hidden`&&(c===`live`&&(l={pos:a.position.clone(),quat:a.quaternion.clone()},c=`ghost`),t(),s.startReverse(),d=performance.now())}function m(){u=!0}function h(e,t){a.position.set(e[t],e[t+1],e[t+2]),a.quaternion.set(e[t+4],e[t+5],e[t+6],e[t+3])}function g(e,t,n){c===`ghost`&&l?(a.visible=!0,a.position.copy(l.pos),a.quaternion.copy(l.quat)):n?(a.visible=!0,h(e,t)):a.visible=!1}function _(e){if(s.playing){let e=performance.now();d===null&&(d=e);let t=Math.min((e-d)/1e3,.25);d=e;let n=s.TOTAL_S/(s.reversing?_C:gC);s.update(t*n)}if(c===`ghost`&&s.isDone()){a.visible=!1,c=`hidden`,l=null,s.restore();let t=u;u=!1,t&&e()}}return{appear:f,despawn:p,queueRespawn:m,poseFromQpos:h,sync:g,drive:_,get visual(){return c}}}var yC=`microduck-sandbox`,bC=`lobby`,xC=[`wss://relay.damus.io`,`wss://nos.lol`,`wss://nostr.tegila.com.br`,`wss://staging.yabu.me`,`wss://social.amanah.eblessing.co`,`wss://relay-rpi.edufeed.org`,`wss://strfry.shock.network`],SC=3,CC=15,wC=.35,TC=150,EC=2e3,DC=1e3/CC/2,OC=.15,kC=.5,AC=40,jC=500,MC=.2,NC=.4,PC=e=>Math.atan2(2*(e[3]*e[6]+e[4]*e[5]),1-2*(e[5]*e[5]+e[6]*e[6])),FC=(e,t)=>{let n=t[0]-e.x,r=t[1]-e.y;if(n*n+r*r>MC*MC)return!0;let i=PC(t)-e.yaw;return Math.abs(Math.atan2(Math.sin(i),Math.cos(i)))>NC},IC=new Set;async function LC(e){let t={update(){},peerCount:()=>0,ghostCount:()=>0,debug:()=>[],mapDots:()=>[],destroy(){},injectState:()=>!1},n;try{let{joinRoom:e}=await x(async()=>{let{joinRoom:e}=await import(`./nostr-Dt1AaIWp.js`);return{joinRoom:e}},[]);n=e({appId:yC,relayConfig:{urls:xC}},bC)}catch(e){return console.warn(`ghosts disabled (signaling unavailable):`,e),t}let{scene:r,cloneRig:i,setJoint:a,setJawOpen:o,applyVariant:s,jointNames:c,getLocalState:l}=e,u=e.variantNames?new Set(e.variantNames):null,d=e.defaultVariant??e.variantNames?.[0],f=t=>e.getRigFor?e.getRigFor(t??0):e.rig,p=t=>{let n=t??0;return e.hasRigFor&&!e.hasRigFor(n)?0:n},m=n.makeAction(`s`),h=e=>m.send(e).catch(()=>{}),g=e=>{let t=[];e.root.traverse(e=>{e.isMesh&&t.push(e)});let n=new Map,r=null;for(let e of t){if(e.userData.fxOverlay){e.parent?.remove(e);continue}if(e.userData.ghostPrepass)continue;let t=n.get(e.material.uuid);if(t||(t=e.material.clone(),t.transparent=!0,t.opacity=wC,t.depthWrite=!1,n.set(e.material.uuid,t)),e.material=t,e.renderOrder=2,!e.userData.hasGhostTwin){r||(r=t.clone(),r.colorWrite=!1,r.depthWrite=!0);let n=new e.constructor(e.geometry,r);n.renderOrder=1,n.userData.ghostPrepass=!0,e.userData.hasGhostTwin=!0,e.add(n)}}},_=new Map,v=!1,y=(e,t=-1/0)=>({p:e.p,j:e.j,w:e.w??0,b:e.b??null,at:Math.max(performance.now(),t+DC)}),b=t=>{let n=p(t.l);n!==(t.l??0)&&e.prepareRigFor?.(t.l);let a=i(f(n));s(a,t.v),g(a),r.add(a.placer);let o=a.bodies.get(`trunk_base`);return o.position.set(t.p[0],t.p[1],t.p[2]),o.quaternion.set(t.p[4],t.p[5],t.p[6],t.p[3]),{rig:a,trunk:o,buf:[y(t)],variant:t.v,loco:n,ball:null,gapAvg:1e3/CC,delay:TC}},S=e=>{let t=_.get(e);if(!t)return;r.remove(t.rig.placer);let n=new Set;t.rig.root.traverse(e=>{e.isMesh&&!n.has(e.material.uuid)&&(n.add(e.material.uuid),e.material.dispose())}),t.ball&&(r.remove(t.ball.group),t.ball.mesh.material.dispose()),_.delete(e)},C=(e,t)=>Array.isArray(e)&&e.length===t&&e.every(Number.isFinite),w=e=>typeof e==`object`&&!!e&&C(e.p,7)&&C(e.j,c.length)&&(e.w==null||Number.isFinite(e.w))&&(e.b==null||C(e.b,7))&&typeof e.v==`string`,T=new Set,E=(t,r)=>{if(v)return;if(!w(t)){T.has(r)||(T.add(r),console.warn(`ghosts: dropping malformed state from peer`,r));return}u&&!u.has(t.v)&&(t.v=d),t.l=+!!t.l;let i=_.get(r);if(!i){if(_.size>=SC||!(r in n.getPeers()))return;i=b(t),i.spawn={x:t.p[0],y:t.p[1],yaw:PC(t.p)},i.revealed=!1,i.rig.placer.visible=!1,_.set(r,i),i.lastSeen=performance.now();return}i.lastSeen=performance.now();let a=i.buf[i.buf.length-1]?.at,o=y(t,a);if(a!==void 0){let e=o.at-a;i.gapAvg=e>i.gapAvg?e:i.gapAvg+(e-i.gapAvg)*OC}if(i.buf.push(o),i.buf.length>AC&&i.buf.shift(),!i.revealed&&FC(i.spawn,t.p)&&(i.revealed=!0,i.rig.placer.visible=!0),t.l!==i.loco){let n=performance.now();if(p(t.l)!==t.l)e.prepareRigFor?.(t.l);else if(n-(i.locoSwapAt??0)>=jC){let{lastSeen:e,spawn:a,revealed:o,buf:s,gapAvg:c,delay:l}=i;S(r),i=b(t),Object.assign(i,{lastSeen:e,spawn:a,revealed:o,buf:s,gapAvg:c,delay:l,locoSwapAt:n}),i.rig.placer.visible=o,_.set(r,i);return}}t.v!==i.variant&&(i.variant=t.v,s(i.rig,t.v),g(i.rig))},D=(e,{peerId:t})=>{try{E(e,t)}catch(e){T.has(t)||(T.add(t),console.warn(`ghosts: error handling state from peer`,t,e))}};m.onMessage=D,n.onPeerLeave=e=>S(e);let O=()=>{try{n.leave()}catch{}};window.addEventListener(`pagehide`,O);let k=()=>{let e=l();e&&h(e);let t=performance.now();for(let[e,n]of[..._])t-n.lastSeen>5e3&&S(e)},ee=null,te=null;try{let e=URL.createObjectURL(new Blob([`setInterval(() => postMessage(0), ${1e3/CC});`],{type:`text/javascript`}));ee=new Worker(e),URL.revokeObjectURL(e),ee.onmessage=k}catch{te=setInterval(k,1e3/CC)}let ne=e.rig.placer.quaternion.clone(),A=e.rig.placer.quaternion.clone(),j=(t,n,i,a)=>{if(!n&&!i){t.ball&&(t.ball.group.visible=!1);return}if(!t.ball){if(!e.makeGhostBall)return;let n=e.makeGhostBall(),i=n.mesh.material;i.transparent=!0,i.opacity=wC,i.depthWrite=!1,n.mesh.renderOrder=2,r.add(n.group),t.ball=n}t.ball.group.visible=t.revealed;let o=t.ball.mesh;if(n&&i)o.position.set(n[0]+(i[0]-n[0])*a,n[1]+(i[1]-n[1])*a,n[2]+(i[2]-n[2])*a),ne.set(n[4],n[5],n[6],n[3]),A.set(i[4],i[5],i[6],i[3]),o.quaternion.copy(ne.slerp(A,a));else{let e=n??i;o.position.set(e[0],e[1],e[2]),o.quaternion.set(e[4],e[5],e[6],e[3])}},re=performance.now(),ie={room:n,destroy(){if(!v){v=!0,IC.delete(ie),ee?.terminate(),te!==null&&clearInterval(te),window.removeEventListener(`pagehide`,O);try{n.leave()}catch{}for(let e of[..._.keys()])S(e)}},injectState:(e,t=`__debug`)=>D(e,{peerId:t}),peerCount:()=>Object.keys(n.getPeers()).length,ghostCount:()=>_.size,mapDots:()=>[..._.values()].filter(e=>e.revealed).map(e=>({x:e.trunk.position.x,y:e.trunk.position.y})),debug:()=>[..._.entries()].map(([e,t])=>{let n=0,r=0,i=null,a=0;t.rig.root.traverse(e=>{if(e.isMesh){if(e.userData.ghostPrepass){a++;return}n++,e.visible&&r++,i??=e.material.opacity}});let o=t.trunk.getWorldPosition(t.trunk.position.clone()),s=t.ball?{visible:t.ball.group.visible,p:t.ball.mesh.position.toArray()}:null;return{peerId:e,p:t.trunk.position.toArray(),world:o.toArray(),inScene:!!t.rig.placer.parent,revealed:t.revealed,meshes:n,visible:r,twins:a,op:i,v:t.variant,l:t.loco,ball:s,gapAvg:t.gapAvg,delay:t.delay,bufLen:t.buf.length}}),update(){let e=performance.now(),t=Math.min(250,e-re);re=e;for(let n of _.values()){let r=Math.min(EC,Math.max(TC,n.gapAvg*1.25+50)),i=t*kC;n.delay+=Math.min(i,Math.max(-i,r-n.delay));let s=e-n.delay,l=n.buf;for(;l.length>2&&l[1].at<=s;)l.shift();let u=l[0],d=l.length>1?l[1]:u,f=d.at-u.at,p=f>0?Math.min(1,Math.max(0,(s-u.at)/f)):1;n.trunk.position.set(u.p[0]+(d.p[0]-u.p[0])*p,u.p[1]+(d.p[1]-u.p[1])*p,u.p[2]+(d.p[2]-u.p[2])*p),ne.set(u.p[4],u.p[5],u.p[6],u.p[3]),A.set(d.p[4],d.p[5],d.p[6],d.p[3]),n.trunk.quaternion.copy(ne.slerp(A,p));for(let e=0;e{let n=Math.hypot(e[0],e[1],e[2]);i.push({x:e[0]/n,y:e[1]/n,z:e[2]/n,pent:t})},o=[[0,0,1],[0,0,-1]],s=Math.atan(.5),c=Math.cos(s),l=Math.sin(s);for(let e=0;e<5;e++){let t=e*72*Math.PI/180,n=(e*72+36)*Math.PI/180;o.push([c*Math.cos(t),c*Math.sin(t),l]),o.push([c*Math.cos(n),c*Math.sin(n),-l])}for(let e of o)a(e,!0);let u=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]>.3;for(let e=0;e<12;e++)for(let t=e+1;t<12;t++)if(u(o[e],o[t]))for(let n=t+1;n<12;n++)u(o[e],o[n])&&u(o[t],o[n])&&a([o[e][0]+o[t][0]+o[n][0],o[e][1]+o[t][1]+o[n][1],o[e][2]+o[t][2]+o[n][2]],!1);let d=1.6*Math.PI/180,f=.35*Math.PI/180,p=d*1.5,m=[233,231,224],h=[23,23,29],g=[200,197,188],_=r.createImageData(t,512),v=_.data,y=document.createElement(`canvas`);y.width=t,y.height=512;let b=y.getContext(`2d`),x=b.createImageData(t,512),S=x.data;for(let e=0;e<512;e++){let n=Math.PI/2-(e+.5)/512*Math.PI,r=Math.cos(n),a=Math.sin(n);for(let n=0;nu?(_=u,u=t,y=e.pent):t>_&&(_=t)}let b=(Math.acos(Math.min(1,_))-Math.acos(Math.min(1,u)))/2,x=y?Math.min(1,Math.max(0,(b-d)/f)):0,C=Math.min(1,Math.max(0,1-b/(d*.6)))*(1-x),w=(e*t+n)*4;for(let e=0;e<3;e++){let t=m[e]+(g[e]-m[e])*C;v[w+e]=t+(h[e]-t)*x}v[w+3]=255;let T=205-Math.max(0,1-b/p)**2*115+(Math.random()-.5)*14,E=Math.max(0,Math.min(255,T));S[w]=E,S[w+1]=E,S[w+2]=E,S[w+3]=255}}r.putImageData(_,0,0),b.putImageData(x,0,0);let C=(t,n)=>{let r=new dd(t);return n&&(r.colorSpace=un),r.anisotropy=e.capabilities.getMaxAnisotropy(),r};return{map:C(n,!0),bumpMap:C(y,!1)}}function zC(e){let t=new hl;t.rotation.x=-Math.PI/2;let n=RC(e),r=new Wa(new Wf(Tb,48,32),new tp({map:n.map,bumpMap:n.bumpMap,bumpScale:.0012,metalness:0,roughness:.55,clearcoat:.2,clearcoatRoughness:.35}));return r.userData.meshName=`ball`,r.userData.fxWireGeometry=new zf(Tb,1),r.visible=!1,t.add(r),{group:t,mesh:r}}var BC=e=>e;function VC(e,t=BC){let n=F.useSyncExternalStore(e.subscribe,F.useCallback(()=>t(e.getState()),[e,t]),F.useCallback(()=>t(e.getInitialState()),[e,t]));return F.useDebugValue(n),n}var HC=e=>{let t=ng(e),n=e=>VC(t,e);return Object.assign(n,t),n},Q=(e=>e?HC(e):HC)((e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)})(()=>({prebootDone:!1,entered:!1,menuOpen:!1,biosVisible:!1,bootDone:!1,bootFailed:!1,modeLabel:`Run`,loco:`legs`,locoWant:`legs`,locoSwitching:!1,rollersLoading:!1,variant:`classic`,padConnected:!1,touchMode:!1,ballActive:!1,reachy:{playing:!1,queue:[],speed:1,error:null},emotionBusy:!1,emotionStage:null,emotionError:null,scriptRecording:!1,scriptPlaying:!1,scriptParallel:!1,scriptActions:[],savedScripts:[],telemetry:{fps:0,ctrlHz:0,speed:0,odo:0,peers:0}}))),UC={};typeof window<`u`&&(window.__store=Q,window.__gameApi=UC);var WC=[];typeof window<`u`&&(window.__bootLog=WC);var GC=e=>{let t={label:e,status:null,raw:!1,progress:null};WC.push(t);let n=(e=`OK`)=>{t.status=e};return n.progress=e=>{t.progress=e},n},KC=e=>{WC.push({label:e,status:``,raw:!0})};function qC(e){let t=Q.getState();t.bootFailed||t.bootDone||(KC(`>> ${e}`),WC.push({label:`SYSTEM HALTED`,status:``,raw:!0,halt:!0}),Q.setState({bootFailed:!0,menuOpen:!1,biosVisible:!0}))}var JC=`/bundle/mujoco-Mp9KyG2b.wasm`,YC=`/bundle/ort-wasm-simd-threaded-Cpm-ox6i.wasm`,XC=!1;function ZC(e){return Math.atan2(2*(e[3]*e[6]+e[4]*e[5]),1-2*(e[5]*e[5]+e[6]*e[6]))}var QC=new Set;async function $C({scene:e,camera:t,renderer:n}){if(!XC){XC=!0;try{await ew({scene:e,camera:t,renderer:n})}catch(e){console.error(`[game] boot failed`,e),qC(e?.message||String(e))}}}async function ew({scene:e,camera:t,renderer:n}){let r=Q.setState,i=Q.getState;KC(`Microduck BIOS v1.0`),GC(`MEMORY CHECK`)(`640K OK`),GC(`DUCK FIRMWARE`)(`PRESENT`);let a=(e,t)=>{!i().bootDone&&!i().bootFailed&&qC(t)};window.addEventListener(`unhandledrejection`,e=>{console.error(`[game] unhandled rejection`,e.reason),a(e,e.reason?.message||String(e.reason))}),window.addEventListener(`error`,e=>{console.error(`[game] window error`,e.message),a(e,e.message)});let o=(e,t)=>{let n=GC(e);return t.then(e=>(n(`OK`),e),t=>{throw n(`FAILED`),console.error(`[game] ${e} FAILED`,t),qC(t?.message||String(t)),t})},[{default:s},c]=await o(`RUNTIME MODULES`,Promise.all([x(()=>import(`./mujoco-C26UsmAO.js`),__vite__mapDeps([0,1,2,3])),x(()=>import(`./ort.wasm.bundle.min-DQoiApJc.js`),__vite__mapDeps([4,1,2,3]))]));c.env.wasm.wasmPaths={wasm:YC},c.env.wasm.numThreads=1;async function l(e){let t=await(await fetch(D(`${Ub}/${e}`))).text(),n=new DOMParser().parseFromString(t,`text/xml`);for(let e of[...n.querySelectorAll(`geom[class="visual"]`)])e.remove();let r=new Set([...n.querySelectorAll(`geom[mesh]`)].map(e=>e.getAttribute(`mesh`)));for(let e of[...n.querySelectorAll(`asset > mesh`)]){let t=e.getAttribute(`name`)??e.getAttribute(`file`).replace(/\.stl$/i,``);r.has(t)||e.remove()}let i=n.documentElement,a=(e,t)=>{let r=n.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return r};i.appendChild(a(`option`,{timestep:String(vb)})),n.querySelector(`worldbody`).appendChild(a(`geom`,{name:`floor`,type:`plane`,size:`0 0 0.05`,pos:`0 0 0`}));let o=.05/2,s=.25/2,c=Db+o,l=Db+.05,u=[{name:`wall_px`,pos:`${c} 0 ${s}`,size:`${o} ${l} ${s}`},{name:`wall_nx`,pos:`${-c} 0 ${s}`,size:`${o} ${l} ${s}`},{name:`wall_py`,pos:`0 ${c} ${s}`,size:`${l} ${o} ${s}`},{name:`wall_ny`,pos:`0 ${-c} ${s}`,size:`${l} ${o} ${s}`}];for(let e of u)n.querySelector(`worldbody`).appendChild(a(`geom`,{name:e.name,type:`box`,pos:e.pos,size:e.size}));for(let e of Vb()){let t={name:e.name,type:`box`,pos:e.pos,size:e.size};e.euler&&(t.euler=e.euler),n.querySelector(`worldbody`).appendChild(a(`geom`,t))}let d=a(`body`,{name:`ball`,pos:Eb});d.appendChild(a(`freejoint`,{name:`ball_freejoint`})),d.appendChild(a(`geom`,{name:`ball_geom`,type:`sphere`,size:String(Tb),mass:`0.03`,friction:`0.4 0.01 0.003`,solref:`0.03 0.4`,condim:`6`})),n.querySelector(`worldbody`).appendChild(d),n.querySelector(`asset`).appendChild(a(`hfield`,{name:`terrain`,nrow:`65`,ncol:`65`,size:`${Db} ${Db} ${Fb} 0.1`})),n.querySelector(`worldbody`).appendChild(a(`geom`,{name:`terrain`,type:`hfield`,hfield:`terrain`,pos:`0 0 ${-Ib}`}));let f=n.createElement(`keyframe`);f.appendChild(a(`key`,{name:`STAND`})),i.appendChild(f),Mv(n);let p=[...n.querySelectorAll(`asset > mesh`)].map(e=>e.getAttribute(`file`));return{xml:new XMLSerializer().serializeToString(n),meshFiles:p}}let[u,{xml:d,meshFiles:f},p,m]=await Promise.all([o(`MUJOCO WASM`,s({locateFile:e=>e.endsWith(`.wasm`)?JC:e})),o(`PHYSICS MJCF`,l(`robot_allcollisions.xml`)),o(`KINEMATICS`,Gb(`${Ub}/kinematics.json`)),o(`REACHY MINI`,Av())]),h=GC(`MESH ASSETS`),g=new u.MjVFS;jv(g,m);let _=Lv(m);e.add(_.root),window.rl={...window.rl??{},reachyRig:_};let v=new Set;async function y(e){let t=await Yb();await Promise.all(e.map(async e=>{if(v.has(e))return;v.add(e);let n=t.get(e),r=n?Xb(n.welded):await(await fetch(D(`${Ub}/meshes/${e}?v=11`),{cache:`force-cache`})).arrayBuffer();g.addBuffer(`assets/${e}`,new Uint8Array(r))}))}try{await y(f)}catch(e){throw h(`FAILED`),qC(e?.message||String(e)),e}h(`${f.length} FILES`);let b={},S=Ox,C=(async()=>{let e=GC(`RENDER RIG`);try{let t=await Zb(p,{materialForMesh:Mx(Dx[S])});return e(`OK`),t}catch(t){throw e(`FAILED`),qC(t?.message||String(t)),t}})(),w=GC(`LOADING POLICIES`),E={executionProviders:[`wasm`]},ne=0,A=e=>c.InferenceSession.create(D(e),E).then(e=>(w.progress(`${++ne}/7`),e));try{[b.walk,b.sitstand,b.roll,b.kickL,b.kickR,b.groundpick,b.stand]=await Promise.all([A(hb.walk),A(hb.sitstand),A(hb.roll),A(hb.kickL),A(hb.kickR),A(hb.groundpick),A(hb.stand)])}catch(e){throw w(`FAILED`),qC(e?.message||String(e)),e}w(`7/7`);let ae=GC(`COMPILING PHYSICS`),M,N;try{M=u.MjModel.from_xml_string(d,g),fe(M),N=new u.MjData(M)}catch(e){throw ae(`FAILED`),qC(e?.message||String(e)),e}ae(`COMPILED`);let P=Jv(),de=Yv({mujoco:u,getWorld:()=>({model:M,data:N}),calibration:m.calibration,timeline:P,isLocked:()=>!!i().emotionBusy,onState:e=>r({reachy:{...i().reachy,...e}})}),F={timeline:P,start:()=>{Xe=!0,Ye.fill(0),Bn(!0)},finish:()=>{Ye.fill(0),Xe=!1,Bn(!1),Ge.fill(0)},drive:(e=0,t=0)=>{Ye[0]=e,Ye[2]=t},head:e=>Ge.set(e),mode:e=>Dr(e,{force:!0}),quack:(...e)=>Jn(...e),get currentMode(){return B},get sitFlag(){return Be}},I=ry({runtime:F,reachy:de,setState:e=>r(e)}),L=iy({setState:e=>r(e)});L.bindWait(e=>P.wait(e)),L.bindResolver((e={})=>{let t=String(e.robot||e.actor||``).toLowerCase(),n=String(e.action||e.type||``).toLowerCase();if(t===`reachy-mini`||t===`reachy`){if([`say`,`speech`,`speak`].includes(n)){let t=String(e.text||e.value||``);return{label:`Reachy says: ${t}`,run:()=>I.say(t)}}if([`emotion`,`emotions`].includes(n)){let t=String(e.value||e.emotion||`joy`).toLowerCase();return{label:`Reachy ${t}`,run:()=>I.playReachy(t)}}}if(t===`microduck`||t===`duck`){if([`emotion`,`emotions`].includes(n)){let t=String(e.value||e.emotion||`joy`).toLowerCase();return{label:`Microduck ${t}`,run:()=>I.playMicroduck(t)}}if([`wait`,`pause`].includes(n)){let t=Math.max(0,Number(e.seconds??e.duration??1));return{label:`Microduck wait ${t}s`,run:()=>P.wait(t)}}}if([`wait`,`pause`].includes(n)){let t=Math.max(0,Number(e.seconds??e.duration??1));return{label:`Wait ${t}s`,run:()=>P.wait(t)}}return null});function fe(e){let t=u.mj_name2id(e,u.mjtObj.mjOBJ_KEY.value,`STAND`),n=Array.from(e.qpos0);n.splice(0,7,Rb,0,.12,0,0,0,1),gb.forEach((t,r)=>{n[e.jnt(t).qposadr]=_b[r]}),Bv.forEach((t,r)=>{let i=u.mj_name2id(e,u.mjtObj.mjOBJ_JOINT.value,`reachy/${t}`);i>=0&&(n[e.jnt_qposadr[i]]=zv[r])});let r=new Float64Array(e.nu);for(let t=0;te.jnt(t).qposadr),dofAdr:gb.map(t=>e.jnt(t).dofadr),actuatorAdr:gb.map(t=>{let n=u.mj_name2id(e,u.mjtObj.mjOBJ_JOINT.value,t);for(let t=0;tu.mj_name2id(e,u.mjtObj.mjOBJ_BODY.value,t)),extraJoints:t.bodies.filter(e=>e.joint&&e.joint.type===`hinge`&&!R.has(e.joint.name)).map(t=>({name:t.joint.name,adr:e.jnt(t.joint.name).qposadr}))}}let{qposAdr:me,dofAdr:he,actuatorAdr:ge,gyroAdr:_e,trunkId:ve,standKeyId:ye,ballQposAdr:z,ballDofAdr:be,extraJoints:xe,ankleIds:Se}=pe(M,p),Ce={},we=`legs`,Te=()=>we===`rollers`?[Sb,Cb,wb]:[bb,xb,1],Ee=new Float32Array(14),De=new Float32Array(61),Oe=new Float32Array(13),ke=new Gx({getVelocityLimits:()=>Te()}),Ae=new sS({getVelocityLimits:()=>Te()}),Me=new ES({getVelocityLimits:()=>Te()}),Ne=new PS({camera:t,renderer:n,getVelocityLimits:()=>Te(),getDuckPose:()=>{let e=N.qpos;return[e[0],e[1],ZC(e)]},isSuppressed:()=>Le||He||B!==`walk`||!!ut,getManualOverride:()=>Ae.isActive()||Me.isActive()||ke.isActive()}),Pe={id:`panel`,command:new Float32Array(3),isActive(){return this.command[0]!==0||this.command[2]!==0}},Fe=new Hx({sources:[Ae,Me,ke,Pe,Ne]}),Ie=!1,Le=!0,Re=null,ze=null,B=`walk`,Be=0,Ve=()=>B===`kickL`||B===`kickR`,He=!1,Ue=2.5,We=new Float32Array([1,-1,1,-1]),Ge=new Float32Array(4),Ke=new Float32Array(4),qe=!1,Je=new Float32Array(3),Ye=new Float32Array(3),Xe=!1;function Ze(){return Xe?Ye:Le||He||B===`roll`||B===`crouch`||B===`groundpick`||Ve()||rt>0||st?Je:Fe.getCommand()}let Qe=null,$e=null,et=null,tt=null,nt=25,rt=0,it=null,at=null,ot=null,st=null,ct=0;function lt(){clearTimeout(it),it=null,clearTimeout(at),at=null}let ut=null,dt=()=>{};function ft(){if(!ut)return;let e=N.qpos,t=N.qvel,n=100*(ut.target[0]-e[ut.qAdr])-10*t[ut.dofAdr],r=100*(ut.target[1]-e[ut.qAdr+1])-10*t[ut.dofAdr+1],i=100*(ut.target[2]-e[ut.qAdr+2])-10*t[ut.dofAdr+2],a=Math.hypot(n,r,i);if(a>200){let e=200/a;n*=e,r*=e,i*=e}let o=N.xfrc_applied,s=ut.bodyId*6;o[s]=ut.mass*n,o[s+1]=ut.mass*r,o[s+2]=ut.mass*i}function pt(){if(!ut)return;let e=N.xfrc_applied,t=ut.bodyId*6;e[t]=0,e[t+1]=0,e[t+2]=0,ut=null}function mt(){let e=Nv(u,M,N);dt(),lt(),Qe=null,tt=null,$e=null,et=null,rt=0,ot=null,st=null,ct=0,B=`walk`,He=!1,Ae.headMode=!1,Ge.fill(0),Ke.fill(0),u.mj_resetDataKeyframe(M,N,ye),Pv(M,N,e),de.write(),u.mj_forward(M,N),Ee.fill(0),Be=0,ze?.despawn({cancelQueued:!0,parkPhysics:ht}),qe=!1,Mr(),Re?.playRespawn()}mt();function ht(){let e=N.qpos,t=N.qvel;e[z]=50,e[z+1]=0,e[z+2]=Tb,e[z+3]=1,e[z+4]=0,e[z+5]=0,e[z+6]=0;for(let e=0;e<6;e++)t[be+e]=0;u.mj_forward(M,N),qe=!1}function gt(e={}){if(Le&&!e.fromQueue||!ze)return;if(ze.visual!==`hidden`){ze.queueRespawn(),ze.despawn({parkPhysics:ht});return}let t=N.qpos,n=N.qvel,r=Db-Tb-.05,i=e=>Math.min(r,Math.max(-r,e));t[z]=i(.95+(Math.random()-.5)*.12),t[z+1]=i(.75+(Math.random()-.5)*.12),t[z+2]=Tb+.02,t[z+3]=1,t[z+4]=0,t[z+5]=0,t[z+6]=0;for(let e=0;e<6;e++)n[be+e]=0;u.mj_forward(M,N),qe=!0,ze.poseFromQpos(t,z),ze.appear()}let _t=new zr,vt=new U;function yt(){let e=N.qpos,t=N.qvel,n=N.sensordata,r=0;for(let e=0;e<3;e++)De[r++]=n[_e+e];let i=N.body(ve).xquat;_t.set(i[1],i[2],i[3],i[0]).conjugate(),vt.set(0,0,-1).applyQuaternion(_t),De[r++]=vt.x,De[r++]=vt.y,De[r++]=vt.z;for(let t=0;t<14;t++)De[r++]=e[me[t]]-_b[t];for(let e=0;e<14;e++)De[r++]=t[he[e]];for(let e=0;e<14;e++)De[r++]=Ee[e];if(Oe.fill(0,0,3),B===`sitstand`)Oe[0]=Be;else if(B===`crouch`&&$e){let e=2*Math.PI*$e.phase;Oe[0]=Math.cos(e),Oe[1]=Math.sin(e)}else if(B===`groundpick`&&et){let e=2*Math.PI*et.phase;Oe[0]=Math.cos(e),Oe[1]=Math.sin(e)}else{let e=Ze();Oe[0]=e[0],Oe[1]=e[1],Oe[2]=e[2]}for(let e=0;e<4;e++)Ke[e]+=.2*(Ge[e]-Ke[e]);let a=B===`groundpick`||st!==null;Oe[3]=a?0:Ke[0],Oe[4]=a?0:Ke[1],Oe[5]=a?0:Ke[2],Oe[6]=a?0:Ke[3];for(let e=0;e<13;e++)De[r++]=Oe[e];return De}let bt=()=>st?.state===`recovering`?b.stand:b[we===`rollers`&&B===`walk`?`drive`:B],xt=0;function St(){let e=N.body(ve).xquat;return _t.set(e[1],e[2],e[3],e[0]).conjugate(),vt.set(0,0,-1).applyQuaternion(_t),vt.z}function Ct(){let e=N.qpos[2],t=St();return!Number.isFinite(e)||!Number.isFinite(t)?`exploded`:t>-.5||e<.02?`fallen`:null}let wt=[{air:!1,prevZ:0,lastAt:0},{air:!1,prevZ:0,lastAt:0}],Tt=se({refDistance:.5}),Et=se({refDistance:.5}),Dt=[0,0,0],Ot=!1,kt=0,At=.35,jt=Vb().map(e=>{let[t,n]=e.pos.split(` `).map(Number),[r,i]=e.size.split(` `).map(Number);return{x:t,y:n,r:Math.hypot(r,i)+.14}}),Mt=[0,0,0],Nt=!1,Pt=0;function Ft(e,t){if(Math.max(Math.abs(e),Math.abs(t))>1.34)return!0;for(let n of jt)if(Math.hypot(e-n.x,t-n.y)=0&&Se[1]>=0){let t=N.xpos,n=t[Se[0]*3+2],r=t[Se[1]*3+2],i=Math.min(n,r);for(let t=0;t<2;t++){let a=wt[t],o=t===0?n:r,s=o-i,c=(o-a.prevZ)/yb;if(a.prevZ=o,s>.012)a.air=!0;else if(a.air&&s<.005&&c<-.02&&e-a.lastAt>130){a.air=!1,a.lastAt=e;let t=Math.min(1,Math.abs(c)/.35);k(`step`,{gain:.12+.14*t,rate:.9+Math.random()*.25,out:Tt.node})}}}let t=Math.hypot(N.qvel[0],N.qvel[1]),n=we===`rollers`&&!Le?Math.min(1,t/.5):0;if(te(n,Tt),CS.setBed(n),Le)Nt=!1;else{let t=N.qvel;if(Nt){let n=Math.hypot(t[0]-Mt[0],t[1]-Mt[1],t[2]-Mt[2]);if(n>At&&e-Pt>300&&Ft(N.qpos[0],N.qpos[1])){Pt=e;let t=Math.min(1,(n-At)/1.5);k(`thump`,{gain:.12+.3*t,rate:.55+.15*t+Math.random()*.06,out:Tt.node}),CS.pulse(`bump`,.5+.5*t)}}Mt[0]=t[0],Mt[1]=t[1],Mt[2]=t[2],Nt=!0}if(qe){let t=N.qvel,n=be;if(Ot){let r=Math.hypot(t[n]-Dt[0],t[n+1]-Dt[1],t[n+2]-Dt[2]);if(r>.5&&e-kt>90){kt=e;let t=Math.min(1,(r-.5)/3.5);k(`thump`,{gain:.14+.4*t,rate:1.25-.45*t+Math.random()*.08,out:Et.node});let n=z;Math.hypot(N.qpos[n]-N.qpos[0],N.qpos[n+1]-N.qpos[1])<.6&&CS.pulse(`ballHit`,.4+.6*t)}}Dt[0]=t[n],Dt[1]=t[n+1],Dt[2]=t[n+2],Ot=!0}else Ot=!1;CS.tick()}async function Lt(){let e=M;if(P.tick(yb),Wt(yb),st?.state!==`fallen`){let t={obs:new c.Tensor(`float32`,yt(),[1,61])},n=await bt().run(t);if(M!==e)return;let r=n.actions.data;Ee.set(r);let i=N.ctrl;for(let e=0;e<14;e++)i[ge[e]]=_b[e]+r[e]*1}for(let e=0;e<4;e++)de.write(),ft(),u.mj_step(M,N);It();let t=Ct();if(t===`exploded`)CS.pulse(`explode`),mt();else if(st)st.steps++,st.state===`fallen`?st.steps>=15&&(st={state:`recovering`,steps:0,uprightSteps:0},Ee.fill(0),Mr()):(st.uprightSteps=St()<-.85?st.uprightSteps+1:0,st.uprightSteps>=50?(st=null,B=`walk`,Ee.fill(0),CS.pulse(`recover`),Mr()):st.steps>=300&&mt());else if(t===`fallen`){if(we===`legs`&&B===`walk`&&!Le&&rt===0&&!at)ot=null,++ct>=10&&(ct=0,Tr(),st={state:`fallen`,steps:0},CS.pulse(`fall`),Mr());else{ct=0;let e=performance.now(),t=B===`roll`?5e3:1e3;ot??CS.pulse(`fall`),ot??=e,e-ot>t&&mt()}}else ct=0,ot=null;if(qe){let e=N.qpos;(Math.abs(e[z])>1.6||Math.abs(e[z+1])>1.6)&>()}if(rt>0&&B===`walk`&&rt--,Ve()&&tt&&(tt.steps++,tt.steps>=nt&&(tt=null,B=`walk`,rt=20,Mr())),B===`crouch`&&$e&&($e.phase+=yb/5,$e.phase>=.7&&($e=null,B=`walk`,Mr())),B===`groundpick`&&et&&(et.phase+=yb/4,et.phase>=.7&&(et=null,B=`walk`,Mr())),B===`roll`&&Qe){Qe.steps++,De[5]>-.3&&(Qe.tipped=!0);let e=De[5]<-.85,t=Qe.tipped&&e&&Qe.steps>=40,n=Qe.steps>=150;(t||n)&&(Qe=null,B=`walk`,Ee.fill(0),e?CS.pulse(`land`):mt(),Mr())}}let Rt=!1,zt=0,Bt=null,Vt=new WeakSet;function Ht(e,t){let n=0;for(let[r,i,a,o]of Pb){let s=Math.hypot(e-r,t-i)/o;s<1&&(n+=a*(.5+.5*Math.cos(Math.PI*s)))}return n}function Ut(e){if(Vt.has(e))return;let t=e.hfield_data;for(let e=0;e<65;e++){let n=-Db+2*Db*e/64;for(let r=0;r<65;r++){let i=-Db+2*Db*r/64;t[e*65+r]=Ht(i,n)/Fb}}Vt.add(e)}function Wt(e){Ut(M);let t=+!!Rt;if(zt!==t){let n=Math.max(-Lb*e,Math.min(Lb*e,t-zt));zt+=n}M.hfield_size[2]=Math.max(zt*Fb,1e-4),Bt&&(Bt.uniforms.uTopoScale.value=zt)}(async function(){let e=performance.now(),t=0,n=e;for(;;){await Lt(),t++;let r=performance.now();r-n>500&&(xt=t*1e3/(r-n),t=0,n=r),e+=yb*1e3;let i=e-performance.now();i>0?await new Promise(e=>setTimeout(e,i)):e=performance.now()}})();let Gt=iC();e.add(Gt),Bt=Gt.material;let{wallMats:Kt,wallMeshes:qt}=cC();for(let t of qt)e.add(t);let Jt=await C;e.add(Jt.placer);let Yt=Jt.bodies.get(`trunk_base`);Ce.legs={model:M,data:N,rig:Jt,trunkGroup:Yt,qposAdr:me,dofAdr:he,actuatorAdr:ge,gyroAdr:_e,trunkId:ve,standKeyId:ye,ballQposAdr:z,ballDofAdr:be,extraJoints:xe,ankleIds:Se};let Xt=null;function Zt(){return Xt??=(async()=>{let[{xml:e,meshFiles:t},n]=await Promise.all([l(`robot_allcollisions_rollers.xml`),Gb(`${Ub}/kinematics_rollers.json`)]),[r,i,a]=await Promise.all([Zb(n,{materialForMesh:Mx(Dx[S])}),c.InferenceSession.create(D(hb.drive),E),c.InferenceSession.create(D(hb.crouch),E),y(t)]);b.drive=i,b.crouch=a;let o=u.MjModel.from_xml_string(e,g);fe(o);let s=new u.MjData(o);Ce.rollers={model:o,data:s,rig:r,trunkGroup:r.bodies.get(`trunk_base`),...pe(o,n)}})(),Xt}let Qt=null,$t=null;function en(){Ce.rollers||Qt||Xt||($t??=(async()=>{Qt=await Zb(await Gb(`${Ub}/kinematics_rollers.json`),{materialForMesh:Mx(Dx[S])})})().catch(e=>{$t=null,console.warn(`[ghosts] roller ghost rig load failed`,e)}))}function tn(t){let n=Nv(u,M,N),i=Ce[t];we=t,e.remove(Jt.placer),{model:M,data:N,rig:Jt,trunkGroup:Yt,qposAdr:me,dofAdr:he,actuatorAdr:ge,gyroAdr:_e,trunkId:ve,standKeyId:ye,ballQposAdr:z,ballDofAdr:be,extraJoints:xe,ankleIds:Se}=i,Bx(Jt,S),e.add(Jt.placer),r({loco:t}),Pv(M,N,n),mt()}let nn=!1;async function rn(e,{force:t=!1}={}){if((e===`legs`||e===`rollers`)&&!(we===e||nn)&&!(!t&&(Le||Qe||tt||$e||et||at||st))){nn=!0,r({locoSwitching:!0});try{e===`rollers`&&!Ce.rollers&&(r({rollersLoading:!0}),await Zt()),tn(e)}catch(e){Xt=null,console.error(`[game] roller switch failed`,e)}finally{r({rollersLoading:!1,locoSwitching:!1}),nn=!1}}}async function an(){let e=we===`legs`?`rollers`:`legs`;r({locoWant:e}),await rn(e)}let on=null;function sn(){let e=i().locoWant;if(e===we){on&&=(clearInterval(on),null);return}e===`rollers`&&Zt().catch(()=>{}),nn||rn(e),on??=setInterval(sn,250)}Q.subscribe(e=>e.locoWant,sn),Re=hC({THREE:je,scene:e,camera:t,renderer:n,fx:FS,getRig:()=>Jt,grid:Gt,wallMats:Kt,syncRig:Un,startCameraReset:On,setLocked:e=>{Le=e,Fe.setLocked(e),!e&&ze&&!qe&>({fromQueue:!0})},flashReset:()=>{},onScanCue:e=>O(e),onPropCue:e=>le(e),onLineCue:e=>j(e)}),Q.subscribe(e=>e.entered,e=>{e&&(ce(),oe(),T())},{fireImmediately:!0}),Q.subscribe(e=>e.menuOpen,e=>re(e),{fireImmediately:!0});let{group:cn,mesh:ln}=zC(n);e.add(cn),ze=vC({THREE:je,scene:e,camera:t,renderer:n,fxModule:FS,mesh:ln,group:cn});let un=await Hb({THREE:je,GLTFLoader:hy,signed:D,scene:e,camera:t,renderer:n,fx:FS,ceremony:Re}),V=new dy(t,n.domElement);V.target.set(0,.15,0),V.enableDamping=!0,V.dampingFactor=.08,V.minDistance=.25,V.maxDistance=3,V.maxPolarAngle=Math.PI/2-.03;let dn=!1,fn=.42,pn=new U,mn=new U,hn=0,gn=0,_n=0,vn=!1,yn=.5,bn=e=>Math.atan2(Math.sin(e),Math.cos(e));function xn(){if(Cn!==null){if(!dn){Cn=null;return}let e=(performance.now()-Cn)/1e3/lC,n=e>=1?1:e<.5?4*e*e*e:1-(-2*e+2)**3/2;t.position.lerpVectors(wn,Tn,n),V.target.lerpVectors(En,Dn,n),t.lookAt(V.target),e>=1&&(Cn=null);return}if(He||!dn)return;let e=N.qpos,n;B===`roll`||Ve()?n=hn:(n=ZC(e),hn=n);let r=Fe.sources.some(e=>Math.abs(e.command[2])>.05);gn=bn(gn+bn(n-gn)*(r?yn:.04));let i=bn(gn-_n);(r||Math.abs(i)>.17)&&(vn=!0),vn&&(_n=bn(_n+i*(r?yn:.1)),!r&&Math.abs(i)<.03&&(vn=!1));let a=_n,o=t.position.distanceTo(V.target),s=o*Math.cos(fn),c=o*Math.sin(fn);pn.set(V.target.x-Math.cos(a)*s,V.target.y+c,V.target.z+Math.sin(a)*s),t.position.lerp(pn,.05),mn.copy(t.position).sub(V.target);let l=mn.length();l>1e-6&&t.position.copy(V.target).addScaledVector(mn,o/l),t.lookAt(V.target)}n.domElement.addEventListener(`pointerdown`,()=>{dn=!1});let Sn=t.position.distanceTo(V.target),Cn=null,wn=new U,Tn=new U,En=new U,Dn=new U;function On(){if(!dn){t.position.set(0,.85,1.8),V.target.set(0,.15,0),t.lookAt(V.target);return}let e=N.qpos,n=ZC(e);hn=n,gn=n,_n=n,vn=!1,Dn.set(e[0],e[2],-e[1]);let r=Sn*Math.cos(fn),i=Sn*Math.sin(fn);Tn.set(Dn.x-Math.cos(n)*r,Dn.y+i,Dn.z+Math.sin(n)*r),wn.copy(t.position),En.copy(V.target),Cn=performance.now(),dn=!0}let kn=new ch,An=new H,jn=new go,Mn=new U,Nn=new U;function Pn(e){let r=n.domElement.getBoundingClientRect();An.set((e.clientX-r.left)/r.width*2-1,-((e.clientY-r.top)/r.height)*2+1),kn.setFromCamera(An,t)}function Fn(){let e=kn.intersectObject(Jt.placer,!0)[0],t=qe?kn.intersectObject(ln,!0)[0]:void 0;return e&&(!t||e.distance<=t.distance)?{kind:`duck`,point:e.point}:t?{kind:`ball`,point:t.point}:null}function In(){if(!kn.ray.intersectPlane(jn,Mn))return;let e=Db-.05;ut.target[0]=Math.min(e,Math.max(-e,Mn.x)),ut.target[1]=Math.min(e,Math.max(-e,-Mn.z)),ut.target[2]=Math.min(.45,Math.max(.02,Mn.y))}function Ln(){ut&&(pt(),V.enabled=!0,n.domElement.style.cursor=``)}dt=Ln,window.addEventListener(`pointerdown`,e=>{if(e.target!==n.domElement||e.pointerType!==`mouse`||e.button!==0||ut||Le)return;Pn(e);let r=Fn();if(!r)return;let i=r.kind===`duck`?{bodyId:ve,qAdr:0,dofAdr:0,mass:M.body(ve).subtreemass}:{bodyId:u.mj_name2id(M,u.mjtObj.mjOBJ_BODY.value,`ball`),qAdr:z,dofAdr:be,mass:M.body(u.mj_name2id(M,u.mjtObj.mjOBJ_BODY.value,`ball`)).mass};t.getWorldDirection(Nn),jn.setFromNormalAndCoplanarPoint(Nn.negate(),r.point),ut={...i,target:[0,0,0]},In(),V.enabled=!1,n.domElement.style.cursor=`grabbing`;try{n.domElement.setPointerCapture(e.pointerId)}catch{}},!0);let Rn=0;window.addEventListener(`pointermove`,e=>{if(ut){Pn(e),In();return}if(e.target!==n.domElement||e.pointerType!==`mouse`||e.buttons||Le)return;let t=performance.now();if(t-Rn<80)return;Rn=t,Pn(e);let r=B===`walk`&&!He;n.domElement.style.cursor=Fn()?`grab`:r?`crosshair`:``}),window.addEventListener(`pointerup`,Ln),window.addEventListener(`pointercancel`,Ln);let zn=new Wa(new Vf(.05,.065,32),new oa({color:16742959,transparent:!0,opacity:.85,side:2}));zn.rotation.x=-Math.PI/2,zn.visible=!1,e.add(zn);let Bn=e=>{Le=e,Fe.setLocked(e)};Q.subscribe(e=>e.menuOpen,e=>{Re.entranceDone&&(e?Bn(!0):Re.respawnActive||Bn(!1))});let Vn=new U,Hn=new U;function Un(){_.sync(u,M,N);let e=N.qpos;Yt.position.set(e[0],e[1],e[2]),Yt.quaternion.set(e[4],e[5],e[6],e[3]);for(let t=0;t<14;t++)ix(Jt,gb[t],e[me[t]]);for(let t of xe)ix(Jt,t.name,e[t.adr]);ze&&ze.sync(e,z,qe),Cn===null&&dn&&(Vn.set(e[0],e[2],-e[1]),Hn.copy(Vn).sub(V.target),Hn.x*=.06,Hn.z*=.06,Hn.y*=.015,V.target.add(Hn),t.position.add(Hn)),Gt.position.set(V.target.x,0,V.target.z),Gt.material.uniforms.uFocus.value.copy(V.target);for(let e of Kt)e.uniforms.uFocus.value.copy(V.target)}let Wn=-1/0,Gn=0,Kn={classic:`duck1`,charcoal:`duck2`,purple:`duck3`,blue:`duck4`};function qn(){let e=Kn[S]??`duck1`,t=`abcdefghijkl`[Math.random()*12|0];ee(D(`./assets/voices/${e}/chirp_${t}.wav`),{gain:.7})}let Jn=()=>{Wn=performance.now(),qn()},Yn=[[.1,0],[.2,1],[.4,1],[.5,0]];function Xn(){let e=B===`groundpick`?et?.phase:null;if(e==null)return 0;let t=Yn;if(e<=t[0][0]||e>=t[t.length-1][0])return 0;for(let n=1;nt[n][0])continue;let[r,i]=t[n-1],[a,o]=t[n],s=(e-r)/(a-r);return i+(o-i)*(1-Math.cos(Math.PI*s))/2}return 0}function Zn(){let e=(performance.now()-Wn)/480,t=e>=0&&e<1?Math.sin(Math.PI*e):0;return Math.min(1,Xn()+Math.max(t,Gn))}function Qn(){rx(Jt,Zn())}let $n=[-12,-10,-8,-5,-3,0],er=null,tr=new Map,nr=null;function rr(e){let t=tr.get(e);return t||(t=fetch(e).then(e=>e.arrayBuffer()).then(e=>er.decodeAudioData(e)),tr.set(e,t)),t}async function ir(){ar({silent:!0}),er??=ce(),er.state===`suspended`&&er.resume().catch(()=>{});let e=Kn[S]??`duck1`,t=`ab`[Math.random()*2|0],n={loopSrc:null,gain:null};nr=n;let r;try{r=await rr(D(`./assets/voices/${e}/wheee_loop_${t}.wav`))}catch{return}if(nr!==n)return;let i=er.createGain();i.connect(ie(`voice`));let a=er.currentTime+.02;i.gain.setValueAtTime(0,a),i.gain.linearRampToValueAtTime(.7,a+.02);let o=er.createBufferSource();o.buffer=r,o.loop=!0,o.connect(i),o.start(a),Object.assign(n,{loopSrc:o,gain:i})}function ar({silent:e=!1}={}){let t=nr;if(!t)return;if(nr=null,e||!t.gain){try{t.loopSrc?.stop()}catch{}t.gain?.disconnect();return}let n=er.currentTime;t.gain.gain.setTargetAtTime(0,n,.05);let r=n+.3;try{t.loopSrc?.stop(r)}catch{}let i=t.gain;setTimeout(()=>i.disconnect(),400)}function or(e){let t=nr;if(!t?.loopSrc)return;let n=Math.min(1,Math.max(0,(e-.05)/.95)),r=$n[Math.round(n*($n.length-1))];t.loopSrc.playbackRate.setTargetAtTime(2**(r/12),er.currentTime,.04)}let sr=60,cr=performance.now(),lr=0,ur=null,dr=null,fr=0;function pr(){let e=performance.now(),t=(e-cr)/1e3;cr=e,t>0&&t<.5&&(sr+=(1/t-sr)*.05);let n=ur===null?0:Math.hypot(N.qpos[0]-ur,N.qpos[1]-dr);n<.05&&(lr+=n),ur=N.qpos[0],dr=N.qpos[1],!(e-fr<250)&&(fr=e,r({telemetry:{fps:Math.round(sr),ctrlHz:Math.round(xt),speed:Math.hypot(N.qvel[0],N.qvel[1]),odo:lr,peers:yr?.peerCount()??0}}))}let mr=2.4,hr={az:0,el:0},gr=new dh,_r=new U;function vr(e,n,r){Ie=e!==0||n!==0,Ie&&(dn=!1);let i=1-Math.exp(-8*r);if(hr.az+=(e*mr-hr.az)*i,hr.el+=(-n*mr*.75-hr.el)*i,dn){hr.az=0,hr.el=0;return}Math.abs(hr.az)<.001&&Math.abs(hr.el)<.001||(_r.copy(t.position).sub(V.target),gr.setFromVector3(_r),gr.theta-=hr.az*r,gr.phi+=hr.el*r,gr.phi=Math.min(V.maxPolarAngle,Math.max(.08,gr.phi)),gr.makeSafe(),t.position.setFromSpherical(gr).add(V.target),t.lookAt(V.target))}let yr=null,br=null,xr=null;function Sr(e){if(Fe.update(e),Gn=Fe.getAxes().jaw,or(Fe.getAxes().ride),Ae.connected!==br&&(br=Ae.connected,r({padConnected:Ae.connected})),Me.connected!==xr&&(xr=Me.connected,r({touchMode:Me.connected})),He&&Ae.connected){let e=Ae.head;Ge[0]=We[0]*e.neckPitch*Ue,Ge[1]=We[1]*e.pitch*Ue,Ge[2]=We[2]*e.yaw*Ue,Ge[3]=We[3]*e.roll*Ue}if(Ae.connected&&!He?vr(Fe.getAxes().orbitX,Fe.getAxes().orbitY,e):(Ie=!1,hr.az=0,hr.el=0),Un(),Qn(),yr?.update(),ue(t),Tt.setPosition(N.qpos[0],N.qpos[2],-N.qpos[1]),qe){let e=N.qpos;Et.setPosition(e[z],e[z+2],-e[z+1])}V.update(),xn(),Re.drive(),ze.drive(()=>gt({fromQueue:!0}));let n=Ne.target;zn.visible=!!n,n&&(zn.position.set(n[0],.012,-n[1]),zn.scale.setScalar(1+.15*Math.sin(performance.now()*.006))),pr()}Fe.init();let Cr=`left`,wr=e=>e===`gamepad`?`pad`:`kb`;Fe.on(`reset`,()=>mt()),Fe.on(`reset`,()=>Ne.cancel()),Fe.on(`spawnBall`,()=>gt()),Fe.on(`headToggle`,()=>Er()),Fe.on(`chaseToggle`,()=>{dn=!dn}),Fe.on(`locoToggle`,()=>an()),Fe.on(`roll`,({source:e})=>Or(wr(e))),Fe.on(`groundPick`,({source:e})=>Ar(wr(e))),Fe.on(`kickL`,({source:e})=>jr(`left`,wr(e))),Fe.on(`kickR`,({source:e})=>jr(`right`,wr(e))),Fe.on(`alternateKick`,({source:e})=>{jr(Cr,wr(e))&&(Cr=Cr===`left`?`right`:`left`)}),Fe.on(`sitToggle`,({source:e}={})=>{if(we!==`legs`)return kr(wr(e));Dr(B===`sitstand`&&Be===1?`walk`:`sit`)}),Fe.on(`walk`,()=>{B!==`walk`&&B!==`roll`&&B!==`crouch`&&Dr(`walk`)}),Fe.on(`quack`,()=>Jn()),Fe.on(`wheeeStart`,()=>ir()),Fe.on(`wheeeStop`,()=>ar());function Tr(){He&&(He=!1,Ae.headMode=!1,Mr())}function Er(){if(He)return Tr();Le||B!==`walk`&&B!==`sitstand`||rt>0||at||st||(He=!0,Ae.headMode=!0,Mr())}function Dr(e,{force:t=!1}={}){if(!(!t&&Le)&&!st&&!(B===`roll`&&Qe||Ve()&&tt||B===`crouch`&&$e||B===`groundpick`&&et)&&(e!==`sit`||we!==`rollers`)){if(Tr(),lt(),Qe=null,$e=null,et=null,e!==`sit`){if(B===`sitstand`&&Be===1){Be=0,at=setTimeout(()=>{at=null,B=e,Ee.fill(0),Mr()},2e3),Mr();return}B=e,Ee.fill(0)}else B=`sitstand`,Be=0,Ee.fill(0),it=setTimeout(()=>{it=null,B===`sitstand`&&(Be=1,Mr())},800);Mr()}}function Or(e=`kb`){if(we===`rollers`)return kr(e);Le||B!==`walk`||at||st||(Tr(),lt(),B=`roll`,Be=0,Qe={steps:0,tipped:!1},Mr())}function kr(e=`kb`){Le||B!==`walk`||nn||st||(Tr(),lt(),B=`crouch`,$e={phase:0},Mr())}function Ar(e=`kb`){we===`legs`&&(Le||B!==`walk`||at||st||(Tr(),lt(),B=`groundpick`,Be=0,et={phase:0},Mr()))}function jr(e,t=`kb`){return we===`rollers`||Le||B!==`walk`||at||st?!1:(Tr(),lt(),B=e===`left`?`kickL`:`kickR`,Be=0,tt={steps:0},CS.pulse(`kick`),Mr(),!0)}function Mr(){let e=B===`sitstand`&&Be===1,t=st?`Recovery`:B===`roll`?`Roll`:B===`crouch`?`Crouch`:B===`groundpick`?`Pick`:Ve()?`Kick`:He?`Head`:e?`Sit`:we===`rollers`?`Drive`:`Run`;i().modeLabel!==t&&r({modeLabel:t}),i().ballActive!==qe&&r({ballActive:qe})}Object.assign(UC,{reachy:de,setDrive:(e,t)=>{let[n,r,i]=Te();Pe.command[0]=Le?0:e>=0?Math.min(1,e)*n:Math.min(1,-e)*r,Pe.command[2]=Le?0:Math.max(-1,Math.min(1,t))*i},setMode:Dr,triggerRoll:Or,triggerKick:jr,triggerCrouch:kr,triggerGroundPick:Ar,toggleHeadMode:Er,quack:Jn,toggleCamera:()=>{dn=!dn},sharedCamera:()=>{dn=!1,On()},setHead:e=>{Le||Ge.set(e)},emotionRuntime:F,playEmotion:e=>I.play(e),playMicroduckEmotion:e=>I.playMicroduck(e),playReachyEmotion:e=>I.playReachy(e),reachySay:e=>I.say(e),script:L,frame:Sr,setVariant:e=>{!Dx[e]||e===S||(S=e,Bx(Jt,e),r({variant:e}))},requestLoco:e=>{(e===`legs`||e===`rollers`)&&(r({locoWant:e}),sn())},resetSim:mt,spawnBall:()=>gt(),startEntrance:()=>Re.startEntrance()}),window.rl={get model(){return M},get data(){return N},mujoco:u,camera:t,controls:V,reachyRig:_,reachy:de,timeline:P,get mode(){return B},get sitFlag(){return Be},buildObs:yt,cmd:Oe,velCmd:ke.command,lastAction:Ee,resetSim:mt,controller:Fe,kbSource:ke,padSource:Ae,spawnBall:gt,triggerKick:jr,triggerRoll:Or,sessions:b,ort:c,get loco(){return we},get locoSwitching(){return nn},toggleLoco:an,setLoco:rn,ensureRollers:Zt,triggerCrouch:kr,get crouchPhase(){return $e?.phase??null},triggerGroundPick:Ar,get groundPickPhase(){return et?.phase??null},get kickSteps(){return nt},set kickSteps(e){nt=e},get recovery(){return st?.state??null},debugPush:(e=0,t=0,n=0,r=0,i=0,a=0)=>{let o=N.qvel;o[0]+=e,o[1]+=t,o[2]+=n,o[3]+=r,o[4]+=i,o[5]+=a},get headMode(){return He},toggleHeadMode:Er,headTarget:Ge,headSmooth:Ke,get ballActive(){return qe},get ballQposAdr(){return z},get chaseCam(){return dn},set chaseCam(e){dn=!!e},get props(){return un},get relief(){return Rt},setRelief:e=>{Rt=!!e},get camResetActive(){return Cn!==null},get respawnActive(){return Re?.respawnActive??!1},get camPose(){return{pos:t.position.toArray(),target:V.target.toArray()}},get chaseYaw(){return{follow:_n,smooth:gn,held:hn,tracking:vn}},padOrbitStep:vr,jawOpenNow:Zn,step:async(e=1)=>{for(let t=0;t{Un(),n.render(e,t)},frame:(e=1/60)=>Sr(e),get ghosts(){return yr},get inputLocked(){return Le},entrance:{start:()=>Re.startEntrance(),setReveal:(e,t)=>Re.setReveal(e,t),setFx:e=>Re.setFx(e)}},r({bootDone:!0});let Nr=e=>Math.round(e*1e3)/1e3;if(new URLSearchParams(location.search).get(`ghosts`)!==`1`){yr={update(){},peerCount:()=>0,ghostCount:()=>0,debug:()=>[],mapDots:()=>[],destroy(){}};return}try{await Re.entranceFinished,yr=await LC({scene:e,rig:Jt,cloneRig:sx,setJoint:ix,setJawOpen:rx,applyVariant:Bx,jointNames:gb,variantNames:Object.keys(Dx),defaultVariant:Ox,getRigFor:e=>e?Ce.rollers?.rig??Qt??Ce.legs.rig:Ce.legs.rig,hasRigFor:e=>!e||!!(Ce.rollers||Qt),prepareRigFor:e=>{e&&en()},makeGhostBall:()=>{let e=new hl;e.rotation.x=-Math.PI/2;let t=new Wa(ln.geometry,ln.material.clone());return e.add(t),{group:e,mesh:t}},getLocalState:()=>{let e=N.qpos,t=Array(14);for(let n=0;n<14;n++)t[n]=Nr(e[me[n]]);let n={p:[Nr(e[0]),Nr(e[1]),Nr(e[2]),Nr(e[3]),Nr(e[4]),Nr(e[5]),Nr(e[6])],j:t,w:Nr(Zn()),v:S,l:+(we===`rollers`)};if(qe){let t=z;n.b=[Nr(e[t]),Nr(e[t+1]),Nr(e[t+2]),Nr(e[t+3]),Nr(e[t+4]),Nr(e[t+5]),Nr(e[t+6])]}return n}}),QC.add(yr),yr.room&&(yr.room.onPeerJoin=()=>void 0)}catch(e){window.__ghostErr=String(e&&e.stack||e),console.warn(`ghosts disabled:`,e)}}var tw=.055,nw=.05,rw=.12,iw=.0025,aw=4,ow=` +varying vec2 vUv; +void main() { + vUv = uv; + gl_Position = vec4(position.xy, 0.0, 1.0); +} +`,sw=` +uniform sampler2D tScene; +uniform float uBarrel, uAberration, uDarken, uFeather; +varying vec2 vUv; + +vec2 warp(vec2 uv, float k) { + vec2 cc = uv - 0.5; + return 0.5 + cc * (1.0 + k * dot(cc, cc)); +} + +void main() { + vec2 uvG = warp(vUv, uBarrel); + vec2 uvR = warp(vUv, uBarrel * (1.0 + uAberration)); + vec2 uvB = warp(vUv, uBarrel * (1.0 - uAberration)); + vec3 col = vec3( + texture2D(tScene, uvR).r, + texture2D(tScene, uvG).g, + texture2D(tScene, uvB).b + ); + // Outside the warped frame = beyond the tube, fade to black with a thin + // feather so the curved border stays anti-aliased. + vec2 d = min(uvG, 1.0 - uvG); + col *= smoothstep(0.0, uFeather, min(d.x, d.y)); + // Gentle corner falloff, like light dying on curved glass. + vec2 cc = vUv - 0.5; + col *= 1.0 - uDarken * 2.0 * dot(cc, cc); + // tScene already holds tone-mapped, sRGB-encoded values (see header): + // write them through untouched. + gl_FragColor = vec4(col, 1.0); +} +`;function cw(){let{size:e,viewport:t}=r_(),{target:n,quadScene:r,quadCamera:i,material:a,geometry:o}=(0,F.useMemo)(()=>{let e=new Pr(1,1,{samples:aw});e.isXRRenderTarget=!0,e.texture.colorSpace=un,e.texture.internalFormat=`RGBA8`;let t=new Y;t.setAttribute(`position`,new K(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3)),t.setAttribute(`uv`,new K(new Float32Array([0,0,2,0,0,2]),2));let n=new to({vertexShader:ow,fragmentShader:sw,uniforms:{tScene:{value:e.texture},uBarrel:{value:tw},uAberration:{value:nw},uDarken:{value:rw},uFeather:{value:iw}},depthTest:!1,depthWrite:!1}),r=new Wa(t,n);r.frustumCulled=!1;let i=new kl;return i.add(r),{target:e,quadScene:i,quadCamera:new Po(-1,1,1,-1,0,1),material:n,geometry:t}},[]);return(0,F.useEffect)(()=>{let r=t.dpr;n.setSize(Math.round(e.width*r),Math.round(e.height*r))},[n,e.width,e.height,t.dpr]),(0,F.useEffect)(()=>()=>{n.dispose(),a.dispose(),o.dispose()},[n,a,o]),i_(({gl:e,scene:t,camera:a})=>{e.setRenderTarget(n),e.render(t,a),e.setRenderTarget(null),e.render(r,i)},1),null}function lw(){let{scene:e,camera:t,gl:n}=r_();return(0,F.useEffect)(()=>{e.background=new G(2106415),n.setClearColor(2106415,1);let r=new qo(n);e.environment=r.fromScene(new Tv).texture,e.environmentIntensity=.45,$C({scene:e,camera:t,renderer:n})},[e,t,n]),i_((e,t)=>{UC.frame?.(Math.min(t,.05))}),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`ambientLight`,{intensity:.6}),(0,I.jsx)(`directionalLight`,{position:[2,4,2],intensity:1.6}),(0,I.jsx)(`directionalLight`,{position:[-2,2,1.5],intensity:.4}),(0,I.jsx)(`directionalLight`,{color:16757606,position:[0,3,-2],intensity:.7})]})}function uw(){return(0,I.jsxs)(wv,{style:{position:`fixed`,inset:0,zIndex:1},dpr:[1,2],gl:{antialias:!0,alpha:!0},camera:{fov:40,near:.02,far:30,position:[0,.85,1.8]},children:[(0,I.jsx)(lw,{}),(0,I.jsx)(cw,{})]})}var dw=pe(`MuiBox`,[`root`]),fw=b(),$=L({themeId:w,defaultTheme:fw,defaultClassName:dw.root,generateClassName:de.generate}),pw=C` + 0% { transform: translate(0, 0); } + 25% { transform: translate(-45px, 30px); } + 50% { transform: translate(25px, -55px); } + 75% { transform: translate(-30px, -15px); } + 100% { transform: translate(0, 0); } +`,mw=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E")`;function hw(){return(0,I.jsx)($,{"aria-hidden":!0,sx:{position:`fixed`,inset:0,zIndex:2,pointerEvents:`none`,backgroundImage:`radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.5px)`,backgroundSize:`21px 21px`,maskImage:`linear-gradient(to bottom, transparent 30%, black 100%)`}})}function gw(){return(0,I.jsxs)($,{"aria-hidden":!0,sx:{position:`fixed`,inset:0,zIndex:5,pointerEvents:`none`,overflow:`hidden`},children:[(0,I.jsx)($,{sx:{position:`absolute`,inset:0,opacity:.13,background:`repeating-linear-gradient( + to bottom, + rgba(0, 0, 0, 0.55) 0, + rgba(0, 0, 0, 0.55) 1px, + transparent 1px, + transparent 3px + ), + repeating-linear-gradient( + to right, + rgba(255, 70, 60, 0.05) 0, + rgba(255, 70, 60, 0.05) 1px, + rgba(70, 255, 90, 0.035) 1px, + rgba(70, 255, 90, 0.035) 2px, + rgba(70, 110, 255, 0.05) 2px, + rgba(70, 110, 255, 0.05) 3px + )`}}),(0,I.jsx)($,{sx:{position:`absolute`,inset:`-80px`,backgroundImage:mw,backgroundSize:`160px 160px`,opacity:.045,animation:`${pw} 0.5s steps(1) infinite`,willChange:`transform`,"@media (prefers-reduced-motion: reduce)":{animation:`none`}}}),(0,I.jsx)($,{sx:{position:`absolute`,inset:0,background:`radial-gradient( + 115% 90% at 50% 50%, + transparent 62%, + rgba(0, 0, 0, 0.42) 100% + )`}})]})}var _w=`#101018`,vw=`#faf8f2`,yw=`#FF7A2F`,bw=`#FFD23F`,xw=`#FF2FA8`,Sw=`#2FF0E6`,Cw=`'Anton', 'Arial Narrow', Impact, sans-serif`,ww={orange:{bg:yw,text:_w,edge:_w,shadow:_w,shadowOnDark:xw},yellow:{bg:bw,text:_w,edge:_w,shadow:_w,shadowOnDark:Sw},ink:{bg:_w,text:vw,edge:_w,shadow:yw,shadowOnDark:yw},paper:{bg:vw,text:_w,edge:_w,shadow:_w,shadowOnDark:yw}},Tw={xs:{fontSize:`0.78rem`,padding:`7px 14px`,border:2,shadow:4,hoverShadow:6},small:{fontSize:`0.92rem`,padding:`9px 20px`,border:3,shadow:5,hoverShadow:7},medium:{fontSize:`1.15rem`,padding:`13px 30px`,border:4,shadow:7,hoverShadow:10}};function Ew({children:e,href:t,target:n,rel:r,onClick:i,variant:a=`filled`,scheme:o=`orange`,size:s=`small`,onDark:c=!1,sx:l,...u}){let d=ww[o],f=Tw[s],p=c?d.shadowOnDark:d.shadow,m=a===`outline`,h=`${f.shadow}px ${f.shadow}px 0 ${p}`,g=`${f.hoverShadow}px ${f.hoverShadow}px 0 ${p}`,_=`0px 0px 0 ${p}`,v=[{position:`relative`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5em`,boxSizing:`border-box`,fontFamily:Cw,fontWeight:400,fontSize:f.fontSize,lineHeight:1.15,whiteSpace:`nowrap`,letterSpacing:`0.07em`,textTransform:`uppercase`,textDecoration:`none`,textAlign:`center`,padding:f.padding,border:`${f.border}px solid`,borderRadius:0,cursor:`pointer`,WebkitTapHighlightColor:`transparent`,userSelect:`none`,transition:`transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, color 0.12s ease`,...m?{background:`transparent`,color:d.bg,borderColor:d.bg,boxShadow:`none`,"&:hover":{background:d.bg,color:d.text,borderColor:d.edge,transform:`translate(-2px, -2px)`,boxShadow:h},"&:active":{background:d.bg,color:d.text,borderColor:d.edge,transform:`translate(2px, 2px)`,boxShadow:_}}:{background:d.bg,color:d.text,borderColor:d.edge,boxShadow:h,"&:hover":{transform:`translate(-2px, -2px)`,boxShadow:g},"&:active":{transform:`translate(${f.shadow}px, ${f.shadow}px)`,boxShadow:_}},"&:focus-visible":{outline:`3px dashed ${c?vw:_w}`,outlineOffset:`5px`},"@media (prefers-reduced-motion: reduce)":{transition:`none`}},...Array.isArray(l)?l:l?[l]:[]];return t?(0,I.jsx)($,{component:`a`,href:t,target:n,rel:r,onClick:i,sx:v,...u,children:e}):(0,I.jsx)($,{component:`button`,type:`button`,onClick:i,sx:v,...u,children:e})}var Dw=[-1.5,.75,-1];function Ow({component:e=`h2`,tone:t=`light`,accent:n=yw,fontSize:r=`2.4rem`,lines:i,sx:a}){let o=i.map(e=>typeof e==`string`?{text:e}:e),s=(e,r)=>{let i=Dw[r%Dw.length],a=e.variant===`outline`;return t===`dark`?a?{color:`transparent`,WebkitTextStroke:`0.032em ${e.color??`#ffffff`}`,textShadow:`-0.03em 0 0 ${xw}`,transform:`rotate(${i}deg)`}:{color:e.color??n,textShadow:`0.06em 0.06em 0 ${_w}, -0.035em 0 0 ${Sw}, 0.035em 0 0 ${xw}`,transform:`rotate(${i}deg)`}:a?{color:`transparent`,WebkitTextStroke:`0.03em ${e.color??`#101018`}`,transform:`rotate(${i}deg)`}:{color:e.color??`#101018`,textShadow:`0.05em 0.05em 0 ${n}`,transform:`rotate(${i}deg)`}};return(0,I.jsx)($,{component:e,sx:[{m:0,fontFamily:Cw,fontWeight:400,lineHeight:.95,letterSpacing:`normal`,textTransform:`uppercase`,fontSize:r},...Array.isArray(a)?a:a?[a]:[]],children:o.map((e,t)=>(0,I.jsx)($,{component:`span`,className:`comic-title-line`,sx:{display:`block`,...e.scale?{fontSize:`${e.scale}em`}:{},...s(e,t)},children:e.text},t))})}var kw={top:`to bottom`,bottom:`to top`,"top-left":`to bottom right`,"top-right":`to bottom left`,"bottom-left":`to top right`,"bottom-right":`to top left`};function Aw({color:e=`rgba(16, 16, 24, 0.06)`,size:t=14,corner:n=`bottom`,reach:r=55,dots:i=[3.1,2.55,2.05,1.6,1.15,.7],sx:a}){let o=kw[n],s=r/i.length;return(0,I.jsx)($,{"aria-hidden":!0,sx:[{position:`absolute`,inset:0,pointerEvents:`none`,overflow:`hidden`},...Array.isArray(a)?a:a?[a]:[]],children:i.map((n,r)=>{let i=s*r,a=r===0?`linear-gradient(${o}, #000 0%, transparent ${i+s}%)`:`linear-gradient(${o}, transparent ${i-s}%, #000 ${i}%, transparent ${i+s}%)`;return(0,I.jsx)($,{sx:{position:`absolute`,inset:0,backgroundImage:`radial-gradient(${e} ${n}px, transparent ${n+.7}px)`,backgroundSize:`${t}px ${t}px`,maskImage:a,WebkitMaskImage:a}},n)})})}var jw=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&*<>/=+`;function Mw(e){let[t,n]=(0,F.useState)(e.toUpperCase()),r=(0,F.useRef)(null),i=(0,F.useRef)(e.toUpperCase());return(0,F.useEffect)(()=>{let t=e.toUpperCase();if(i.current===t)return;i.current=t,r.current&&clearInterval(r.current);let a=t.length,o=()=>jw[Math.random()*46|0],s=performance.now();return r.current=setInterval(()=>{let e=Math.floor((performance.now()-s)/450*a);if(e>=a){clearInterval(r.current),r.current=null,n(t);return}let i=t.slice(0,e);for(let t=e;tr.current&&clearInterval(r.current)},[e]),t}var Nw=C` + 0%, 58% { opacity: 1; } + 59%, 100% { opacity: 0.12; } +`,Pw=C` + 0% { transform: scale(0.86); } + 55% { transform: scale(1.1); } + 100% { transform: scale(1); } +`,Fw=48,Iw=2,Lw=5,Rw=34,zw=4,Bw={position:`relative`,display:`inline-flex`,height:Fw,boxSizing:`border-box`,border:`${Iw}px solid rgba(250, 248, 242, 0.9)`,padding:`${Lw}px`,borderRadius:0,background:`rgba(8, 8, 12, 0.6)`,"&::after":{content:`""`,position:`absolute`,inset:0,pointerEvents:`none`,zIndex:2,boxShadow:`inset 0 0 0 1px ${_w}`}},Vw={cream:vw,orange:p},Hw={position:`absolute`,top:-9,zIndex:3,pointerEvents:`none`,userSelect:`none`,whiteSpace:`nowrap`,fontFamily:Cw,fontSize:`0.58rem`,letterSpacing:`0.09em`,textTransform:`uppercase`,lineHeight:1,padding:`3px 6px 2px`,color:_w,border:`2px solid ${_w}`,borderRadius:0,boxShadow:`2px 2px 0 ${_w}`};function Uw({caption:e,captionSide:t=`left`,captionFill:n=`cream`,children:r,sx:i}){return(0,I.jsxs)($,{sx:{...Bw,...i},children:[(0,I.jsx)($,{sx:{display:`inline-flex`,alignItems:`stretch`,height:`100%`,overflow:`hidden`},children:r}),e?(0,I.jsx)($,{"aria-hidden":!0,sx:{...Hw,background:Vw[n],...t===`right`?{right:-8}:{left:-8}},children:e}):null]})}function Ww({muted:e}){return(0,I.jsxs)($,{component:`svg`,viewBox:`0 0 24 24`,"aria-hidden":!0,fill:`none`,stroke:`currentColor`,strokeWidth:2.25,strokeLinecap:`square`,strokeLinejoin:`miter`,sx:{width:`1.05em`,height:`1.05em`,display:`block`,flex:`none`},children:[(0,I.jsx)(`path`,{d:`M4 9h4l5-4v14l-5-4H4z`}),e?(0,I.jsx)(`path`,{d:`M16 9l6 6M22 9l-6 6`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`path`,{d:`M16 9.5a3.5 3.5 0 0 1 0 5`}),(0,I.jsx)(`path`,{d:`M18.5 7a7 7 0 0 1 0 10`})]})]})}function Gw(){return(0,I.jsxs)($,{component:`svg`,viewBox:`0 0 24 24`,"aria-hidden":!0,fill:`none`,stroke:`currentColor`,strokeWidth:2.25,strokeLinecap:`square`,strokeLinejoin:`miter`,sx:{width:`0.95em`,height:`0.95em`,display:`block`,flex:`none`},children:[(0,I.jsx)(`path`,{d:`M20 12H6`}),(0,I.jsx)(`path`,{d:`M12 5l-7 7 7 7`})]})}var Kw={appearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`0.45em`,height:`100%`,px:`0.95rem`,margin:0,border:`none`,borderRadius:0,background:`transparent`,color:vw,cursor:`pointer`,fontFamily:Cw,fontSize:`0.92rem`,letterSpacing:`0.08em`,textTransform:`uppercase`,textDecoration:`none`,lineHeight:1,whiteSpace:`nowrap`,WebkitTapHighlightColor:`transparent`,userSelect:`none`,transition:`background 0.15s ease, color 0.15s ease, filter 0.15s ease`,"&:focus-visible":{outline:`2px dashed ${vw}`,outlineOffset:-5}};function qw(){return(0,I.jsx)(Uw,{caption:`Nav`,sx:{position:`fixed`,top:`1.25rem`,left:`1.5rem`,zIndex:10},children:(0,I.jsxs)($,{component:`button`,type:`button`,onClick:()=>{N(),Q.setState({menuOpen:!0})},sx:{...Kw,"&:hover":{color:p,background:`rgba(255, 122, 47, 0.12)`},"&:active":{filter:`brightness(0.92)`}},children:[(0,I.jsx)(Gw,{}),` Back`]})})}var Jw=`https://store.pollen-robotics.com/collections/microduck`;function Yw({sx:e}){let t=Mw(Q(e=>e.locoWant)===`rollers`?`Pre-order pack`:`Pre-order`);return(0,I.jsx)(Uw,{caption:`Shop`,captionSide:`right`,captionFill:`orange`,sx:{position:`fixed`,top:`1.25rem`,right:`1.5rem`,zIndex:10,...e},children:(0,I.jsx)($,{component:`a`,href:Jw,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>N(),sx:{...Kw,background:p,color:_w,"&:hover":{filter:`brightness(1.07)`},"&:active":{filter:`brightness(0.92)`}},children:t})})}function Xw(){let e=Q(e=>e.variant),t=Q(e=>e.locoWant);return(0,I.jsxs)($,{sx:{position:`relative`,zIndex:10,display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.85rem`,maxWidth:`100%`,mt:2},children:[(0,I.jsx)(Uw,{caption:`Color`,children:(0,I.jsx)($,{role:`group`,"aria-label":`Duck colours`,sx:{display:`inline-flex`,alignItems:`stretch`,height:`100%`,gap:`${zw}px`},children:Object.entries(Ax).map(([t,n])=>{let r=t===e,i=kx[t]??t;return(0,I.jsx)($,{component:`button`,type:`button`,title:i,"aria-label":`${i} colours`,"aria-pressed":r,onClick:()=>{N(),UC.setVariant?.(t)},sx:{appearance:`none`,width:Rw,height:`100%`,p:0,background:n,border:`none`,borderRadius:0,cursor:`pointer`,WebkitTapHighlightColor:`transparent`,boxShadow:r?`inset 0 0 0 2px ${vw}`:`none`,opacity:r?1:.7,animation:r?`${Pw} 0.28s ease`:`none`,transition:`opacity 0.15s ease, box-shadow 0.15s ease`,"&:hover":{opacity:1},"&:active":{animation:`none`,filter:`brightness(0.92)`},"&:focus-visible":{outline:`2px dashed ${vw}`,outlineOffset:-5},"@media (prefers-reduced-motion: reduce)":{animation:`none`}}},t)})})}),(0,I.jsx)(Uw,{caption:`Mode`,children:(0,I.jsx)($,{role:`group`,"aria-label":`Locomotion mode`,sx:{display:`inline-flex`,alignItems:`stretch`,height:`100%`,gap:`${zw}px`},children:[{name:`legs`,label:`Feet`},{name:`rollers`,label:`Rollers`}].map(({name:e,label:n})=>{let r=t===e;return(0,I.jsx)($,{component:`button`,type:`button`,"aria-pressed":r,onClick:()=>{N(),UC.requestLoco?.(e)},sx:{...Kw,px:`1.05rem`,background:r?p:`transparent`,color:r?_w:`rgba(250, 248, 242, 0.72)`,"&:hover":{color:r?_w:vw,background:r?p:`rgba(255, 122, 47, 0.12)`},"&:active":{filter:`brightness(0.92)`}},children:n},e)})})})]})}function Zw(){let[e,t]=(0,F.useState)(A);return(0,I.jsx)(Uw,{caption:`Sound`,children:(0,I.jsx)($,{component:`button`,type:`button`,"aria-label":e?`Unmute sound`:`Mute sound`,"aria-pressed":e,onClick:()=>{let n=!e;ne(n),t(n),n||N()},sx:{...Kw,px:`0.75rem`,color:e?`rgba(250, 248, 242, 0.5)`:vw,"&:hover":{color:e?vw:p,background:`rgba(255, 122, 47, 0.12)`},"&:active":{filter:`brightness(0.92)`}},children:(0,I.jsx)(Ww,{muted:e})})})}function Qw(){let e=Q(e=>e.telemetry),t=e.odo<1e3?`${e.odo.toFixed(1)}M`:`${(e.odo/1e3).toFixed(2)}KM`,n=[];return e.peers&&n.push(`${e.peers+1} ONLINE`),n.push(`${e.speed.toFixed(2)}M/S \u00b7 ODO ${t}`),n.push(`FPS ${e.fps} \u00b7 CTRL ${e.ctrlHz}HZ`),(0,I.jsx)($,{sx:{position:`fixed`,bottom:`1.25rem`,right:`1.5rem`,zIndex:10,pointerEvents:`none`,fontFamily:y,fontSize:`0.62rem`,letterSpacing:`0.14em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.35)`,fontVariantNumeric:`tabular-nums`,textShadow:`0 0 6px rgba(255, 255, 255, 0.15)`,whiteSpace:`pre-line`,textAlign:`right`,lineHeight:1.8},children:n.join(` +`)})}function $w(){return Q(e=>e.rollersLoading)?(0,I.jsxs)($,{sx:{position:`fixed`,top:`5.2rem`,right:`1.5rem`,zIndex:10,fontFamily:y,fontSize:`0.68rem`,letterSpacing:`0.14em`,color:p,textShadow:`0 0 8px rgba(255, 122, 47, 0.4)`},children:[`LOADING ROLLERS`,(0,I.jsx)($,{component:`span`,sx:{display:`inline-block`,ml:`0.15em`,animation:`${Nw} 0.8s steps(1) infinite`},children:`█`})]}):null}function eT(){let e=Q(e=>e.entered),t=Q(e=>e.menuOpen),n=Q(e=>e.touchMode);return!e||t?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qw,{}),(0,I.jsx)(Yw,{}),!n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qw,{}),(0,I.jsx)($w,{})]})]})}function tT(){let e=Q(e=>e.touchMode),t=Q(e=>e.entered),n=Q(e=>e.menuOpen);return(0,I.jsxs)($,{id:`touch-ui`,sx:{display:e&&t&&!n?`block`:`none`,"& #touch-zone":{position:`fixed`,left:0,right:`50%`,top:`30%`,bottom:0,zIndex:9,touchAction:`none`},"& #touch-stick":{position:`absolute`,left:`1.3rem`,bottom:`2rem`,width:`8.2rem`,height:`8.2rem`,borderRadius:`50%`,border:`1px solid rgba(255, 255, 255, 0.18)`,background:`rgba(8, 8, 12, 0.4)`,pointerEvents:`none`},"& #touch-stick .nub":{position:`absolute`,left:`50%`,top:`50%`,width:`3.6rem`,height:`3.6rem`,margin:`-1.8rem 0 0 -1.8rem`,borderRadius:`50%`,border:`1px solid rgba(255, 255, 255, 0.35)`,background:`rgba(255, 255, 255, 0.14)`,pointerEvents:`none`},"& #touch-stick.live":{borderColor:`rgba(255, 122, 47, 0.55)`},"& #touch-stick.live .nub":{background:`rgba(255, 122, 47, 0.45)`,borderColor:p},"& #touch-btns":{position:`fixed`,right:`1.3rem`,bottom:`2.2rem`,zIndex:12,width:`9.4rem`,height:`8.4rem`},"& .capwrap":{position:`absolute`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`0.3rem`},"& .cap-a":{right:0,top:0},"& .cap-b":{left:0,bottom:0},"& #touch-btns button":{appearance:`none`,width:`4.2rem`,height:`4.2rem`,borderRadius:`50%`,border:`1px solid rgba(255, 255, 255, 0.22)`,background:`rgba(8, 8, 12, 0.5)`,color:`rgba(255, 255, 255, 0.85)`,font:`inherit`,fontSize:`1.3rem`,fontWeight:700,cursor:`pointer`,touchAction:`none`,userSelect:`none`,WebkitUserSelect:`none`},"& #touch-btns button.down":{background:p,borderColor:p,color:g},"& .capwrap span":{fontSize:`0.55rem`,fontWeight:600,letterSpacing:`0.18em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.45)`}},children:[(0,I.jsx)(`div`,{id:`touch-zone`,children:(0,I.jsx)(`div`,{id:`touch-stick`,children:(0,I.jsx)(`div`,{className:`nub`})})}),(0,I.jsxs)(`div`,{id:`touch-btns`,children:[(0,I.jsxs)(`div`,{className:`capwrap cap-a`,children:[(0,I.jsx)(`button`,{type:`button`,id:`touch-a`,"aria-label":`Kick`,children:`A`}),(0,I.jsx)(`span`,{children:`Kick`})]}),(0,I.jsxs)(`div`,{className:`capwrap cap-b`,children:[(0,I.jsx)(`button`,{type:`button`,id:`touch-b`,"aria-label":`Quack`,children:`B`}),(0,I.jsx)(`span`,{children:`Quack`})]})]})]})}var nT=C` + 0%, 55% { opacity: 1; } + 56%, 100% { opacity: 0; } +`,rT=e=>new Promise(t=>setTimeout(t,e)),iT=e=>e.raw?e.label:e.status===null?e.progress?`${e.label} [${e.progress}]`:e.label:`${e.label} `.padEnd(26,`.`)+` ${e.status}`;function aT(){let e=Q(e=>e.entered),t=Q(e=>e.bootFailed),n=(0,F.useRef)(null),r=(0,F.useRef)(!1),[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(!1);(0,F.useEffect)(()=>{!e&&!t||r.current||(r.current=!0,c())},[e,t]);async function c(){let e=Q.getState;a(!0),Q.setState({biosVisible:!0}),E();let t=n.current,r=11,i=()=>(r=r*1103515245+12345&2147483647)/2147483647,o=new Map,c=0;for(;;){let{bootDone:n,bootFailed:r}=e();if(c div:first-of-type":{color:`rgba(255, 255, 255, 0.85)`,marginBottom:`0.55em`},"& > div:last-of-type::after":{content:`"\\2588"`,marginLeft:`0.15em`,animation:`${nT} 1s steps(1) infinite`},"& > div.halt":{color:`rgba(255, 82, 47, 0.95)`,animation:`${nT} 1s steps(1) infinite`}}})})}function oT(e){return typeof e.main==`string`}function sT(e,t=[]){if(!oT(e))return!1;for(let n of t)if(!e.hasOwnProperty(n)||typeof e[n]!=`string`)return!1;return!0}function cT(e=[]){return([,t])=>t&&sT(t,e)}function lT(e){return R(`MuiTypography`,e)}pe(`MuiTypography`,[`root`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`subtitle1`,`subtitle2`,`body1`,`body2`,`inherit`,`button`,`caption`,`overline`,`alignLeft`,`alignRight`,`alignCenter`,`alignJustify`,`noWrap`,`gutterBottom`]);var uT=e=>{let{align:t,gutterBottom:n,noWrap:r,variant:i,classes:a}=e;return Ee({root:[`root`,i,e.align!==`inherit`&&`align${Ae(t)}`,n&&`gutterBottom`,r&&`noWrap`]},lT,a)},dT=Oe(`span`,{name:`MuiTypography`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!==`inherit`&&t[`align${Ae(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom]}})(ke(({theme:e})=>({margin:0,variants:[{props:{variant:`inherit`},style:{font:`inherit`,lineHeight:`inherit`,letterSpacing:`inherit`}},...Object.entries(e.typography).filter(([e,t])=>e!==`inherit`&&t&&typeof t==`object`).map(([e,t])=>({props:{variant:e},style:t})),...Object.entries(e.palette).filter(cT()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}})),...Object.entries(e.palette?.text||{}).filter(([,e])=>typeof e==`string`).map(([t])=>({props:{color:`text${Ae(t)}`},style:{color:(e.vars||e).palette.text[t]}})),{props:({ownerState:e})=>e.align!==`inherit`,style:{textAlign:`var(--Typography-textAlign)`}},{props:({ownerState:e})=>e.noWrap,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},{props:({ownerState:e})=>e.gutterBottom,style:{marginBottom:`0.35em`}}]}))),fT={h1:`h1`,h2:`h2`,h3:`h3`,h4:`h4`,h5:`h5`,h6:`h6`,subtitle1:`h6`,subtitle2:`h6`,body1:`p`,body2:`p`,inherit:`p`},pT=F.forwardRef(function(e,t){let n=o({props:e,name:`MuiTypography`}),{color:r,align:i=`inherit`,className:a,component:s,gutterBottom:l=!1,noWrap:u=!1,variant:d=`body1`,variantMapping:f=fT,...p}=n,m={...n,align:i,color:r,className:a,component:s,gutterBottom:l,noWrap:u,variant:d,variantMapping:f},h=s||f[d]||fT[d]||`span`,g=uT(m);return(0,I.jsx)(dT,{as:h,ref:t,className:c(g.root,a),...p,ownerState:m,style:{...i!==`inherit`&&{"--Typography-textAlign":i},...p.style}})}),mT=1,hT=-1,gT=.55,_T=.32,vT=.3,yT=.04,bT=.09,xT=[.28,.2,.43],ST=[0,.122,0],CT=.78,wT=32,TT={classic:`duck1`,charcoal:`duck2`,purple:`duck3`,blue:`duck4`},ET=`abcdefghijkl`,DT=(e,t,n)=>Math.min(n,Math.max(t,e)),OT=(e,t)=>e+Math.random()*(t-e),kT=null,AT=null,jT=!1;function MT(){return kT||=FT().then(e=>(AT=e,jT=!0,e)).catch(e=>{throw jT=!0,e}),kT}var NT=()=>MT(),PT=()=>jT;async function FT(){let e=new kl,t=new oo(wT,1,.05,20);t.position.set(...ST.map((e,t)=>e+(xT[t]-e)/CT)),t.lookAt(...ST);let n=new El({antialias:!0,alpha:!0});n.setClearColor(0,0),n.setPixelRatio(Math.min(2,window.devicePixelRatio)),n.toneMapping=4;let r=n.domElement;r.style.position=`absolute`,r.style.inset=`0`,r.style.width=`100%`,r.style.height=`100%`,r.style.opacity=`0`,r.style.transition=`opacity 0.45s ease`,e.environment=new qo(n).fromScene(new Tv).texture,e.environmentIntensity=.25,e.add(new am(16777215,.45));let i=new im(16777215,1.25);i.position.set(2,4,2),e.add(i);let a=new im(16777215,.4);a.position.set(-2,2,1.5),e.add(a);let o=new im(16757606,.7);o.position.set(0,3,-2),e.add(o);let s=await Gb(`${Ub}/kinematics.json`),c=Q.getState().variant??`classic`;Dx[c]||(c=Ox);let l=await Zb(s,{materialForMesh:Mx(Dx[c])});l.placer.rotation.y=-Math.PI/2,e.add(l.placer),ox(l,ux),lx(l),n.render(e,t);let u=JS();u.init({THREE:je,scene:e,root:l.placer,camera:t,renderer:n,hidden:!0}),u.setProgress(.5),n.render(e,t),u.setProgress(0);let d=!1,f=l.joints.get(`head_yaw`).body,p=new U,m=new U,h=new H(0,0),g=null,_=0,v=-1/0,y=document.hasFocus(),b=!0,x=0,S=0,C=0,w=OT(0,6.3),T=OT(0,6.3),E=-1/0,O=0,k=e=>{if(!g)return;let t=g.getBoundingClientRect();!t.width||!t.height||(h.x=DT((e.clientX-t.left)/t.width*2-1,-2,2),h.y=DT(-((e.clientY-t.top)/t.height*2-1),-2,2),v=_,b=!0)},te=()=>{y=!1},ne=()=>{y=!0},A=()=>{b=!1},j=()=>{b=!0},re=()=>ie();function ie(){E=_+vT;let e=TT[c]??`duck1`,t=ET[Math.random()*12|0];ee(D(`./assets/voices/${e}/chirp_${t}.wav`),{gain:.7})}function ae(i,a){_=a,f.getWorldPosition(p),m.copy(t.position).sub(p);let o=Math.atan2(m.x,m.z),s=Math.atan2(m.y,Math.hypot(m.x,m.z)),g=y&&b&&a-v<3;C+=(+!!g-C)*(1-Math.exp(-i/.3));let D=o+h.x*gT,k=s*.5+h.y*_T,ee=o+.45*Math.sin(.21*a+w)*Math.sin(.09*a+T)*2,te=s*.5+.1*Math.sin(.4*a+T),ne=ee+(D-ee)*C,A=te+(k-te)*C,j=1-Math.exp(-i*(2.5+7.5*C));x+=(ne-x)*j,S+=(A-S)*j;let re=Math.sin(a*1.4)*.025;ix(l,`neck_pitch`,ux.neck_pitch+re),ix(l,`head_yaw`,mT*x),ix(l,`head_pitch`,ux.head_pitch+hT*S),ix(l,`head_roll`,.3*mT*(x-o));let ie=+(aO?yT:bT;O+=(ie-O)*(1-Math.exp(-i/ae)),rx(l,O),u&&(d||=(u.start(),!0),u.update(i),u.isDone()&&(u.dispose(),u=null));let oe=Q.getState().variant;!u&&oe!==c&&Dx[oe]&&(c=oe,Bx(l,oe)),n.render(e,t),r.style.opacity===`0`&&(r.style.opacity=`1`)}let oe=0,se=0,M=e=>{oe=requestAnimationFrame(M);let t=Math.min((e-se)/1e3,.05);se=e,ae(t,e/1e3)};function ce(){if(!g)return;let e=g.clientWidth,r=g.clientHeight;!e||!r||(t.aspect=e/r,t.updateProjectionMatrix(),n.setSize(e,r))}let le=new ResizeObserver(ce);function N(e){!e||g===e||(ue(),g=e,e.appendChild(r),le.observe(e),ce(),window.addEventListener(`pointermove`,k),window.addEventListener(`pointerdown`,re),window.addEventListener(`blur`,te),window.addEventListener(`focus`,ne),document.addEventListener(`mouseleave`,A),document.addEventListener(`mouseenter`,j),se=performance.now(),oe=requestAnimationFrame(M))}function ue(){g&&=(cancelAnimationFrame(oe),le.disconnect(),window.removeEventListener(`pointermove`,k),window.removeEventListener(`pointerdown`,re),window.removeEventListener(`blur`,te),window.removeEventListener(`focus`,ne),document.removeEventListener(`mouseleave`,A),document.removeEventListener(`mouseenter`,j),r.remove(),null)}let P={attach:N,detach:ue,quack:ie,step:ae};return window.__menuDuck=P,P}function IT({sx:e}){let t=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let e=!1;return MT().then(n=>{e||t.current&&n.attach(t.current)}).catch(e=>console.warn(`menu duck disabled:`,e)),()=>{e=!0,AT?.detach()}},[]),(0,I.jsx)($,{ref:t,"aria-hidden":!0,sx:{position:`relative`,touchAction:`manipulation`,userSelect:`none`,...e}})}var LT=[`KeyW`,`KeyA`,`KeyS`,`KeyD`],RT=`arrows or WASD`;function zT(e){if(typeof e!=`string`)return null;let t=e.trim();if([...t].length!==1||/[\p{M}\p{C}\p{Z}]/u.test(t))return null;let n=t.toUpperCase();return[...n].length===1?n:t}function BT(e,t){let n=[...new Set([...LT,...e])],r={},i=!0;for(let e of n){let n=null;try{n=zT(t?.get?.(e))}catch{n=null}n||(i=!1),r[e]=n}if(!i){for(let e of n)r[e]=e.replace(/^Key/,``);return{labels:r,moveHint:RT}}return{labels:r,moveHint:`arrows or ${LT.map(e=>r[e]).join(``)}`}}async function VT(e=globalThis.navigator){try{return await e?.keyboard?.getLayoutMap?.()??null}catch{return null}}var HT=C` + from { transform: translateY(12px); opacity: 0; } + to { transform: none; opacity: 1; } +`,UT=C` + from { transform: translateY(10px) scale(0.94); opacity: 0; } + to { transform: none; opacity: 1; } +`,WT=C` + from { opacity: 0.8; } + to { opacity: 0.18; } +`,GT=C` + to { transform: rotate(360deg); } +`,KT=(e,t=HT)=>({animation:`${t} 0.55s cubic-bezier(0.22, 1, 0.36, 1) both`,animationDelay:`${e}s`,"@media (prefers-reduced-motion: reduce)":{animation:`none`}}),qT=Oe(`kbd`)(({round:e})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:e?`1.9rem`:`1.65rem`,height:`1.65rem`,padding:`0 0.45rem`,font:`inherit`,fontSize:`0.68rem`,fontWeight:600,color:`#fff`,background:`#14141c`,border:`2px solid ${g}`,borderRadius:e?`50%`:8,boxShadow:`0 0 0 2px rgba(255, 255, 255, 0.82)`})),JT={kb:[{caps:[`↑←↓→`],name:`Move`},{codes:[`KeyQ`,`KeyE`],name:`Kick`},{codes:[`KeyR`],name:`Sit`},{codes:[`KeyG`],name:`Pick up`},{codes:[`KeyC`],name:`Camera`},{caps:[`Space`],name:`Reset`}],pad:[{caps:[`LS`],name:`Move`},{caps:[`LB`,`RB`],name:`Kick`},{caps:[`Y`],name:`Head`},{caps:[`RS`],name:`Camera`},{caps:[`X`,`↓`],name:`Sit`}],touch:[{caps:[`Stick`],name:`Move`},{caps:[`A`],round:!0,name:`Kick`},{caps:[`B`],round:!0,name:`Quack`}]},YT={pad:`A ground pick · RT quack · hold LT wheee · R3 chase`,touch:`drag to orbit · pinch to zoom`},XT={classic:p,charcoal:`#b9b5ae`,purple:`#bfa9cf`,blue:`#a9dbe8`},ZT=(e,t)=>`rgba(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)}, ${t})`,QT=JT.kb.flatMap(e=>e.codes??[]);function $T(e){let[t,n]=(0,F.useState)(()=>BT(QT,null));return(0,F.useEffect)(()=>{if(!e)return;let t=!1,r=0,i=async()=>{let e=++r,i=await VT();!t&&e===r&&n(BT(QT,i))};i();let a=navigator.keyboard;return a?.addEventListener?.(`layoutchange`,i),()=>{t=!0,a?.removeEventListener?.(`layoutchange`,i)}},[e]),t}function eE(){Q.setState({menuOpen:!1}),Q.getState().entered||Q.setState({entered:!0}),M()}function tE(){let e=Q(e=>e.menuOpen),t=Q(e=>e.entered),n=Q(e=>e.padConnected),r=Q(e=>e.touchMode),i=Q(e=>e.variant),a=Q(e=>e.bootDone),o=Q(e=>e.bootFailed),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(e),u=n?`pad`:r?`touch`:`kb`,{labels:d,moveHint:f}=$T(u===`kb`),[p,m]=(0,F.useState)(()=>window.matchMedia(`(min-width: 900px)`).matches);(0,F.useEffect)(()=>{let e=window.matchMedia(`(min-width: 900px)`),t=()=>m(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let h=!r&&p,[_,v]=(0,F.useState)(PT);(0,F.useEffect)(()=>{if(!h||_)return;let e=!0;return Promise.all([NT().catch(()=>{})]).catch(()=>{}).then(()=>{e&&v(!0)}),()=>{e=!1}},[h,_]);let[y,b]=(0,F.useState)(()=>!!document.fonts?.check?.(`1rem Anton`));(0,F.useEffect)(()=>{if(y)return;let e=!0,t=()=>{e&&b(!0)},n=document.fonts?.load?document.fonts.load(`1rem Anton`):Promise.resolve(),r=document.fonts?.ready??Promise.resolve();Promise.all([n,r]).then(t,t);let i=setTimeout(t,4e3);return()=>{e=!1,clearTimeout(i)}},[y]);let[x,S]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(x)return;let e=!0,t=()=>{e&&S(!0)},n=e=>new Promise(t=>{let n=new Image;n.src=D(e),n.complete&&n.naturalWidth?t():(n.addEventListener(`load`,t,{once:!0}),n.addEventListener(`error`,t,{once:!0}))});Promise.all([n(`./assets/duck-head-mark.webp`),n(`./assets/duck-head-mark-open.webp`)]).then(t,t);let r=setTimeout(t,2500);return()=>{e=!1,clearTimeout(r)}},[x]);let C=(_||!h)&&y&&x&&(a||o);if((0,F.useEffect)(()=>{let t=l.current;if(l.current=e,t&&!e){c(!0);let e=setTimeout(()=>c(!1),380);return()=>clearTimeout(e)}},[e]),(0,F.useEffect)(()=>{let e=e=>{let t=Q.getState();if(e.code===`Enter`&&t.menuOpen){if(e.target instanceof HTMLButtonElement&&e.target.dataset.cta!==`1`)return;e.preventDefault(),eE();return}if(e.code===`Escape`&&!t.biosVisible){if(t.menuOpen){t.entered&&eE();return}t.entered&&Q.setState({menuOpen:!0})}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,F.useEffect)(()=>{let e={enter:!1,menu:!1},t=!1,n,r=()=>{n=requestAnimationFrame(r),t&&(t=!1,Q.getState().menuOpen&&eE());let i=[...navigator.getGamepads?.()??[]].filter(e=>e&&e.connected),a=i.find(e=>e.mapping===`standard`)??i[0];if(!a){e.enter=!1,e.menu=!1;return}let o=!!a.buttons[0]?.pressed,s=!!(a.buttons[9]?.pressed||a.buttons[8]?.pressed),c=o&&!e.enter,l=s&&!e.menu;e.enter=o,e.menu=s;let u=Q.getState();if(c&&u.menuOpen){t=!0;return}l&&!u.menuOpen&&u.entered&&!u.biosVisible&&Q.setState({menuOpen:!0})};return n=requestAnimationFrame(r),()=>cancelAnimationFrame(n)},[]),!e&&!s)return null;let w=u===`kb`?JT.kb.map(e=>e.codes?{...e,caps:e.codes.map(e=>d[e])}:e):JT[u],T=`${f.replace(/^arrows or /,``)} works too \u00b7 drag to orbit \u00b7 scroll to zoom`,E=t?`Resume`:`Waddle in`,O=n?`press A`:r?null:`press Enter`,k=XT[i]??`#ff7a2f`;return(0,I.jsxs)($,{role:`dialog`,"aria-modal":`true`,"aria-label":`Microduck`,sx:{position:`fixed`,inset:0,zIndex:30,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,p:`2.4rem 1.4rem 1.8rem`,background:g,opacity:+!!e,pointerEvents:e?`auto`:`none`,overflowY:`auto`,transition:`opacity 0.35s ease, background 0.4s ease`},children:[(0,I.jsx)(Aw,{color:ZT(k,.16),size:20,corner:`top-left`,reach:60}),C&&(0,I.jsxs)($,{"aria-hidden":!0,sx:{position:`absolute`,top:`1.25rem`,left:`1.5rem`,zIndex:1,display:`flex`,alignItems:`center`,gap:`0.65rem`,userSelect:`none`,...KT(0,UT),"&:hover .duck-closed":{opacity:0},"&:hover .duck-open":{opacity:1}},children:[(0,I.jsxs)($,{component:`span`,sx:{position:`relative`,display:`block`,height:`2.1rem`,filter:`drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.5))`},children:[(0,I.jsx)($,{component:`img`,className:`duck-closed`,alt:``,src:D(`./assets/duck-head-mark.webp`),sx:{display:`block`,height:`100%`,width:`auto`}}),(0,I.jsx)($,{component:`img`,className:`duck-open`,alt:``,src:D(`./assets/duck-head-mark-open.webp`),sx:{position:`absolute`,top:`-0.75%`,left:`-1.1%`,width:`101.3%`,maxWidth:`none`,height:`auto`,opacity:0}})]}),(0,I.jsx)($,{component:`span`,sx:{fontFamily:`'Anton', 'Arial Narrow', Impact, sans-serif`,fontSize:`1rem`,letterSpacing:`0.05em`,textTransform:`uppercase`,color:`#fff`,display:{xs:`none`,sm:`block`}},children:`Microduck`})]}),C&&(0,I.jsx)(Yw,{sx:{...KT(.1)}}),!C&&(0,I.jsxs)($,{role:`status`,"aria-label":`Loading`,sx:{m:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`1.1rem`},children:[(0,I.jsx)($,{"aria-hidden":!0,sx:{width:`2.4rem`,height:`2.4rem`,borderRadius:`50%`,border:`3px solid rgba(255, 255, 255, 0.14)`,borderTopColor:k,animation:`${GT} 0.8s linear infinite`}}),(0,I.jsx)(pT,{sx:{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`0.64rem`,fontWeight:600,letterSpacing:`0.16em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.5)`},children:`Loading`})]}),C&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)($,{sx:{position:`relative`,display:`flex`,flexDirection:{xs:`column`,md:`row`},alignItems:`stretch`,justifyContent:`center`,gap:{xs:`0.4rem`,md:`1.5rem`},width:`100%`,maxWidth:`min(66rem, 94vw)`,flex:`1 1 auto`,minHeight:0,pt:{xs:`2.6rem`,md:0}},children:[(0,I.jsxs)($,{sx:{position:`relative`,flex:{md:`0 1 33rem`},width:`100%`,maxWidth:{xs:`min(48rem, 92vw)`,md:`none`},mx:{xs:`auto`,md:0},display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:{xs:`center`,md:h?`flex-start`:`center`},textAlign:{xs:`center`,md:h?`left`:`center`}},children:[(0,I.jsx)(Ow,{component:`h1`,tone:`dark`,accent:k,fontSize:`clamp(3.4rem, 9vw, 6.2rem)`,lines:[{text:`Microduck`},{text:`Reachy Mini`,variant:`outline`,scale:.7}],sx:{...KT(.08)}}),(0,I.jsx)(pT,{sx:{mx:{xs:`auto`,md:0},mt:`1.1rem`,"@media (max-height: 700px)":{mt:`0.8rem`},maxWidth:`34ch`,fontSize:{xs:`0.95rem`,sm:`1.05rem`},lineHeight:1.5,letterSpacing:`-0.012em`,color:`rgba(255, 255, 255, 0.72)`,textWrap:`balance`,...KT(.24)},children:`The exact same trained policies that drive the real robot, live in your browser.`}),(0,I.jsxs)($,{sx:{display:`inline-flex`,flexDirection:`column`,alignItems:`center`,mt:`2rem`,"@media (max-height: 700px)":{mt:`1.3rem`},...KT(.32)},children:[(0,I.jsxs)(Ew,{scheme:`orange`,size:`medium`,onDark:!0,"data-cta":`1`,onClick:eE,children:[n&&(0,I.jsx)($,{component:`span`,"aria-hidden":!0,sx:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`1.5em`,height:`1.5em`,borderRadius:`50%`,background:`#08080c`,color:`#faf8f2`,fontSize:`0.72em`,lineHeight:1},children:`A`}),E]}),O&&(0,I.jsx)(pT,{"aria-hidden":!0,sx:{mt:`0.85rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`0.66rem`,fontWeight:600,letterSpacing:`0.14em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.6)`,...KT(.4)},children:(0,I.jsx)($,{component:`span`,sx:{display:`inline-block`,animation:`${WT} 0.95s ease-in-out infinite alternate`,"@media (prefers-reduced-motion: reduce)":{animation:`none`,opacity:.6}},children:O})})]})]}),h&&(0,I.jsx)($,{sx:{position:`relative`,flex:{xs:`1 1 auto`,md:`1 1 22rem`},width:`100%`,minHeight:{xs:`min(30vh, 16rem)`,md:0},...KT(.16,UT)},children:(0,I.jsxs)($,{sx:{position:`absolute`,inset:0,overflow:`hidden`},children:[(0,I.jsx)($,{component:`img`,src:D(`./reachy-mini-home.png`),alt:`Reachy Mini`,sx:{position:`absolute`,zIndex:0,right:`-24%`,bottom:`-8%`,width:`124%`,height:`124%`,objectFit:`contain`,objectPosition:`center bottom`,filter:`saturate(.82) contrast(1.06)`,opacity:.98}}),(0,I.jsx)($,{sx:{position:`absolute`,zIndex:1,left:`-4%`,bottom:`0`,width:`58%`,height:`100%`},children:(0,I.jsx)(IT,{sx:{position:`absolute`,inset:0}})})]})})]}),(0,I.jsxs)($,{sx:{position:`relative`,width:`100%`,textAlign:`center`,mt:`1.2rem`,pt:`1.15rem`,borderTop:`1px solid rgba(255, 255, 255, 0.08)`,...KT(.5)},children:[(0,I.jsx)($,{sx:{display:`flex`,flexWrap:`wrap`,justifyContent:`center`,alignItems:`center`,gap:`0.55rem 1.25rem`,"& kbd":{minWidth:`1.45rem`,height:`1.45rem`,p:`0 0.34rem`,fontSize:`0.6rem`}},children:w.map(e=>(0,I.jsxs)($,{sx:{display:`inline-flex`,alignItems:`center`,gap:`0.45rem`},children:[(0,I.jsx)($,{sx:{display:`inline-flex`,gap:`0.22rem`},children:e.caps.map((t,n)=>(0,I.jsx)(qT,{round:+!!e.round,children:t},n))}),(0,I.jsx)($,{component:`span`,sx:{fontFamily:`'Anton', 'Arial Narrow', Impact, sans-serif`,fontSize:`0.74rem`,letterSpacing:`0.07em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.88)`},children:e.name})]},e.name))}),(0,I.jsx)(pT,{sx:{mt:`0.7rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`0.62rem`,fontWeight:600,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`rgba(255, 255, 255, 0.34)`},children:u===`kb`?T:YT[u]})]})]})]})}var nE={Home:Rv,"Look Left":{yaw:25},"Look Right":{yaw:-25},"Look Up":{pitch:-15},"Look Down":{pitch:15},"Tilt Left":{roll:-15},"Tilt Right":{roll:15},Curious:{roll:-12,yaw:12,z:5,leftAntenna:25,rightAntenna:-15},Excited:{z:12,pitch:-8,leftAntenna:30,rightAntenna:-30},Shy:{pitch:16,z:-10,yaw:-12,leftAntenna:-20,rightAntenna:20}},rE=(e,t=.65)=>({pose:{...Rv,...e},duration:t}),iE={Wave:[rE({leftAntenna:50}),rE({leftAntenna:-30}),rE({leftAntenna:50}),rE({leftAntenna:-30}),rE(Rv)],Nod:[rE({pitch:15}),rE({pitch:-10}),rE({pitch:15}),rE(Rv)],"Excited Dance":[rE(nE.Excited),rE({z:5,roll:-12,rightAntenna:30}),rE({z:12,roll:12,leftAntenna:-30}),rE(nE.Excited),rE(Rv)],"Look Around":[rE(nE[`Look Left`],1),rE(nE[`Look Up`],.8),rE(nE[`Look Right`],1),rE(Rv)],"Curious Peek":[rE(nE.Shy),rE({x:12,z:8,yaw:20,roll:-12},1.1),rE(nE.Curious),rE(Rv)]};function aE({side:e,title:t,children:n}){let r=Q(e=>e.entered&&e.bootDone&&!e.menuOpen&&!e.biosVisible),[i,a]=(0,F.useState)(()=>window.innerWidth>=900);return r?(0,I.jsxs)(`aside`,{className:`sim-panel sim-panel-${e}`,"aria-label":`${t} controls`,children:[(0,I.jsxs)(`button`,{className:`sim-panel-title`,"aria-expanded":i,onClick:()=>a(!i),children:[t,` `,(0,I.jsx)(`span`,{children:i?`−`:`+`})]}),i&&(0,I.jsx)(`div`,{className:`sim-panel-content`,children:n})]}):null}var oE=[[`x`,`x (mm)`,-20,20],[`y`,`y (mm)`,-20,20],[`z`,`z (mm)`,-30,20],[`roll`,`Roll (°)`,-25,25],[`pitch`,`Pitch (°)`,-25,25],[`yaw`,`Yaw (°)`,-45,45],[`leftAntenna`,`Left antenna (°)`,-90,90],[`rightAntenna`,`Right antenna (°)`,-90,90]];function sE(){let[e,t]=(0,F.useState)({...Rv}),[n,r]=(0,F.useState)(1),[i,a]=(0,F.useState)(null),o=Q(e=>e.reachy),s=Q(e=>e.emotionBusy||e.scriptPlaying),c=Q(e=>e.scriptRecording),[l,u]=(0,F.useState)(``),d=async e=>{a(null);try{await e(UC.reachy)}catch(e){e.name!==`AbortError`&&a(e.message)}},f=(e,t)=>c?UC.script?.add(e,()=>d(t)):d(t);return(0,I.jsxs)(aE,{side:`left`,title:`Reachy Mini`,children:[(0,I.jsxs)(`fieldset`,{disabled:s||o.playing&&!c,children:[(0,I.jsx)(`legend`,{children:`Poses`}),(0,I.jsx)(`div`,{className:`sim-buttons`,children:Object.entries(nE).map(([e,t])=>(0,I.jsx)(`button`,{onClick:()=>f(e,e=>e.playSequence([{pose:{...Rv,...t},duration:n}])),children:e},e))}),(0,I.jsx)(`legend`,{children:`Sequences`}),(0,I.jsx)(`div`,{className:`sim-buttons`,children:Object.entries(iE).map(([e,t])=>(0,I.jsx)(`button`,{onClick:()=>f(e,e=>e.playSequence(t)),children:e},e))}),(0,I.jsx)(`legend`,{children:`Emotions`}),(0,I.jsx)(`div`,{className:`sim-buttons`,children:[[`joy`,`Happy`],[`sadness`,`Sad`],[`anger`,`Angry`]].map(([e,t])=>(0,I.jsx)(`button`,{onClick:()=>f(`Reachy ${t}`,()=>UC.playReachyEmotion?.(e)),children:t},e))})]}),(0,I.jsxs)(`fieldset`,{disabled:s,children:[(0,I.jsx)(`legend`,{children:`Custom pose`}),oE.map(([n,r,i,a])=>(0,I.jsxs)(`label`,{className:`sim-field`,children:[(0,I.jsx)(`span`,{children:r}),(0,I.jsx)(`input`,{type:`number`,min:i,max:a,step:`1`,value:e[n],onChange:r=>t({...e,[n]:Number(r.target.value)})})]},n)),(0,I.jsxs)(`label`,{className:`sim-field`,children:[(0,I.jsx)(`span`,{children:`Duration (s)`}),(0,I.jsx)(`input`,{type:`number`,min:`0.1`,max:`30`,step:`0.1`,value:n,onChange:e=>r(Number(e.target.value))})]}),(0,I.jsxs)(`label`,{className:`sim-field`,children:[(0,I.jsx)(`span`,{children:`Playback speed`}),(0,I.jsx)(`select`,{value:o.speed,onChange:e=>d(t=>t.setSpeed(Number(e.target.value))),children:[.25,.5,1,1.5,2].map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,`×`]},e))})]}),(0,I.jsxs)(`div`,{className:`sim-buttons`,children:[(0,I.jsx)(`button`,{onClick:()=>f(`Reachy custom pose`,t=>t.enqueue(e,n)),children:`Queue`}),(0,I.jsx)(`button`,{disabled:o.playing&&!c,onClick:()=>f(`Play Reachy queue`,t=>o.queue.length?t.playQueue():t.playSequence([{pose:e,duration:n}])),children:`Play`}),(0,I.jsx)(`button`,{onClick:()=>UC.reachy?.stop(),children:`Stop`}),(0,I.jsx)(`button`,{onClick:()=>UC.reachy?.clear(),children:`Clear`})]})]}),(0,I.jsxs)(`fieldset`,{disabled:s,children:[(0,I.jsx)(`legend`,{children:`Text to speech`}),(0,I.jsx)(`input`,{className:`sim-speech`,value:l,placeholder:`What should Reachy say?`,onChange:e=>u(e.target.value)}),(0,I.jsx)(`button`,{disabled:!l.trim(),onClick:()=>f(`Reachy says: ${l.trim()}`,()=>UC.reachySay?.(l.trim())),children:`Say / add to script`})]}),(0,I.jsxs)(`p`,{role:`status`,children:[o.playing?`Playing · `:``,o.queue.length,` queued`]}),o.queue.length>0&&(0,I.jsx)(`ol`,{className:`sim-queue`,children:o.queue.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))}),(i||o.error)&&(0,I.jsx)(`p`,{className:`sim-error`,role:`alert`,children:i||o.error})]})}function cE(){let e=Q(e=>e.loco),t=Q(e=>e.modeLabel),n=Q(e=>e.emotionBusy||e.locoSwitching||e.scriptPlaying),r=Q(e=>e.scriptRecording),[i,a]=(0,F.useState)([0,0,0,0]),o=()=>UC.setDrive?.(0,0),s=(e,t,n)=>{e.currentTarget.setPointerCapture(e.pointerId),r?UC.script?.add(`${t>0?`Forward`:t<0?`Backwards`:n>0?`Turn left`:`Turn right`}`,async()=>{UC.setDrive?.(t,n),await UC.script.wait(1),UC.setDrive?.(0,0)}):UC.setDrive?.(t,n)},c=(e,t)=>r?UC.script?.add(e,async()=>{await t(),await UC.script.wait(.4)}):t();return(0,I.jsxs)(aE,{side:`right`,title:`Microduck`,children:[(0,I.jsxs)(`p`,{role:`status`,children:[t,` · `,e]}),(0,I.jsxs)(`fieldset`,{disabled:n,children:[(0,I.jsx)(`legend`,{children:`Move · hold to drive`}),(0,I.jsx)(`div`,{className:`sim-buttons`,children:[[`Forward`,1,0],[`Backwards`,-1,0],[`Turn left`,0,1],[`Turn right`,0,-1]].map(([e,t,n])=>(0,I.jsx)(`button`,{onPointerDown:e=>s(e,t,n),onPointerUp:o,onPointerCancel:o,onLostPointerCapture:o,onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),UC.setDrive?.(t,n))},onKeyUp:o,onBlur:o,children:e},e))}),(0,I.jsx)(`legend`,{children:`Actions`}),(0,I.jsxs)(`div`,{className:`sim-buttons`,children:[(0,I.jsx)(`button`,{disabled:e!==`legs`,onClick:()=>c(`Kick left`,()=>UC.triggerKick?.(`left`)),children:`Kick left`}),(0,I.jsx)(`button`,{disabled:e!==`legs`,onClick:()=>c(`Kick right`,()=>UC.triggerKick?.(`right`)),children:`Kick right`}),(0,I.jsx)(`button`,{disabled:e!==`legs`,onClick:()=>c(`Roll`,()=>UC.triggerRoll?.()),children:`Roll`}),(0,I.jsx)(`button`,{disabled:e!==`legs`,onClick:()=>c(`Sit`,()=>UC.setMode?.(`sit`)),children:`Sit`}),(0,I.jsx)(`button`,{onClick:()=>c(`Stand / Walk`,()=>UC.setMode?.(`walk`)),children:`Stand / Walk`}),(0,I.jsx)(`button`,{disabled:e!==`rollers`,onClick:()=>c(`Crouch`,()=>UC.triggerCrouch?.()),children:`Crouch`}),(0,I.jsx)(`button`,{disabled:e!==`legs`,onClick:()=>c(`Ground pick`,()=>UC.triggerGroundPick?.()),children:`Ground pick`}),(0,I.jsx)(`button`,{onClick:()=>c(`Microduck quack`,()=>UC.quack?.()),children:`Quack`}),(0,I.jsx)(`button`,{onClick:()=>c(`Ball`,()=>UC.spawnBall?.()),children:`Ball`}),(0,I.jsx)(`button`,{onClick:()=>c(`Reset Microduck`,()=>UC.resetSim?.()),children:`Reset`})]}),(0,I.jsx)(`legend`,{children:`Emotions`}),(0,I.jsx)(`div`,{className:`sim-buttons`,children:[[`joy`,`Happy`],[`sadness`,`Sad`],[`anger`,`Angry`]].map(([e,t])=>(0,I.jsx)(`button`,{onClick:()=>c(`Microduck ${t}`,()=>UC.playMicroduckEmotion?.(e)),children:t},e))}),(0,I.jsx)(`legend`,{children:`Head`}),(0,I.jsx)(`button`,{onClick:()=>c(`Toggle head control`,()=>UC.toggleHeadMode?.()),children:`Toggle gamepad head control`}),[`Neck pitch`,`Head pitch`,`Head yaw`,`Head roll`].map((e,t)=>(0,I.jsxs)(`label`,{className:`sim-field`,children:[(0,I.jsx)(`span`,{children:e}),(0,I.jsx)(`input`,{type:`range`,min:`-0.6`,max:`0.6`,step:`0.02`,value:i[t],onChange:e=>{let n=[...i];n[t]=Number(e.target.value),a(n),UC.setHead?.(n)}})]},e)),(0,I.jsx)(`button`,{onClick:()=>c(`Neutral head`,()=>{a([0,0,0,0]),UC.setHead?.([0,0,0,0])}),children:`Neutral head`}),(0,I.jsx)(`legend`,{children:`Appearance & locomotion`}),(0,I.jsx)(Xw,{}),(0,I.jsx)(`legend`,{children:`Camera`}),(0,I.jsxs)(`div`,{className:`sim-buttons`,children:[(0,I.jsx)(`button`,{onClick:()=>c(`Chase camera`,()=>UC.toggleCamera?.()),children:`Chase camera`}),(0,I.jsx)(`button`,{onClick:()=>c(`Both robots camera`,()=>UC.sharedCamera?.()),children:`Both robots`})]})]}),(0,I.jsx)(Zw,{}),(0,I.jsxs)(`details`,{className:`sim-help`,children:[(0,I.jsx)(`summary`,{children:`Keyboard & gamepad`}),(0,I.jsx)(`p`,{children:`Arrows / WASD / ZQSD: walk and turn. Q/E: kicks. F: alternate kicks. R: sit/stand or crouch. G: ground pick. M: legs/rollers. Space: reset. C: chase camera. Drag: orbit. Scroll: zoom.`}),(0,I.jsx)(`p`,{children:`Gamepad: left stick moves; right stick orbits; Y controls head; LB/RB kick; X or D-pad down sits; A picks; hold D-pad up switches mode; RT quacks; LT wheee; R3 chase; Menu pauses.`})]})]})}function lE(){let e=Q(e=>e.scriptRecording),t=Q(e=>e.scriptPlaying),n=Q(e=>e.scriptActions),r=Q(e=>e.savedScripts),i=Q(e=>e.entered),a=Q(e=>e.bootDone),o=Q(e=>e.menuOpen),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(``);(0,F.useEffect)(()=>{t&&f(!0)},[t]);let h=()=>{e||f(!1),UC.script?.toggle()},g=e||n.length>0||r.length>0;return!i||!a||o?null:(0,I.jsxs)(`div`,{className:`emotion-bar`,"aria-label":`Robot script`,children:[(0,I.jsx)(`button`,{disabled:t,onClick:h,children:e?`STOP SCRIPT`:`SCRIPT`}),g&&(0,I.jsxs)(`div`,{className:`script-editor${d?` is-collapsed`:``}`,children:[(0,I.jsx)(`button`,{className:`script-collapse`,"aria-label":d?`Expand script`:`Collapse script`,onClick:()=>f(e=>!e),children:d?`▲`:`▼`}),d?(0,I.jsxs)(`strong`,{children:[`Script (`,n.length,` actions)`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`strong`,{children:e?`Recording actions`:`Script`}),(0,I.jsx)(`ol`,{children:n.map(e=>{let t=e.label.startsWith(`Reachy`),n=t?`reachy-mini`:`microduck`;return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`label`,{className:`script-parallel-check`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:!!e.parallel||!!e.parallelGroup,onChange:()=>UC.script?.toggleParallel(e.index)}),`parallel`]}),(0,I.jsx)(`span`,{className:`script-actor ${t?`actor-orange`:`actor-blue`}`,children:n}),(0,I.jsx)(`span`,{children:e.label}),(e.parallel||e.parallelGroup)&&(0,I.jsxs)(`label`,{className:`script-delay`,children:[`départ après `,(0,I.jsx)(`input`,{"aria-label":`Delay ${e.label}`,type:`number`,min:`0`,step:`0.1`,value:e.delay||0,onChange:t=>UC.script?.setDelay(e.index,t.target.value)}),` s`]}),(0,I.jsx)(`button`,{className:`script-remove`,"aria-label":`Remove ${e.label}`,onClick:()=>UC.script?.remove(e.index),children:`×`})]},e.id)})}),e&&(0,I.jsx)(`button`,{onClick:()=>UC.script?.clear(),children:`Clear`}),(0,I.jsx)(`input`,{value:s,placeholder:`Script name`,onChange:e=>c(e.target.value)}),(0,I.jsx)(`button`,{disabled:!s.trim()||!n.length,onClick:()=>{UC.script?.save(s),u(s.trim())},children:`Save`}),(0,I.jsx)(`button`,{disabled:t||!n.length,onClick:()=>UC.script?.run(),children:t?`RUNNING`:`Run current`}),r.length>0&&(0,I.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`Saved scripts`}),r.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),(0,I.jsx)(`button`,{disabled:t||!l,onClick:()=>UC.script?.runSaved(l),children:`Run saved`}),(0,I.jsx)(`textarea`,{className:`script-ai`,value:p,placeholder:`JSON script: {"actions":[{"robot":"reachy-mini","action":"say","text":"Hello","parallel":true}]}`,onChange:e=>m(e.target.value)}),(0,I.jsx)(`button`,{onClick:()=>navigator.clipboard?.writeText(`Generate JSON only with an actions array. Use robot "microduck" or "reachy-mini", action "emotion", "say", or "wait"; use parallel:true only for actions that should overlap.`),children:`Copy format`}),(0,I.jsx)(`button`,{disabled:!p.trim()||t,onClick:()=>{try{UC.script?.load(p),m(``)}catch(e){window.alert(e.message)}},children:`Load JSON`})]})]})]})}function uE(){return(0,F.useEffect)(()=>{let e=new URLSearchParams(location.search),t=()=>{let e=[...navigator.getGamepads?.()??[]].find(e=>e&&e.connected);Q.setState({padConnected:!!e})};window.addEventListener(`gamepadconnected`,t),window.addEventListener(`gamepaddisconnected`,t),t();let n=matchMedia(`(pointer: coarse)`),r=()=>{window.__microduckTouched=!0,Q.setState({touchMode:!0})},i=()=>n.matches&&r();return n.matches?r():n.addEventListener(`change`,i),window.addEventListener(`touchstart`,r,{once:!0,passive:!0}),e.get(`touch`)===`1`&&r(),e.get(`boot`)===`1`?Q.setState({prebootDone:!0,entered:!0,menuOpen:!1}):Q.setState({prebootDone:!0,menuOpen:!0}),()=>{window.removeEventListener(`gamepadconnected`,t),window.removeEventListener(`gamepaddisconnected`,t),n.removeEventListener(`change`,i),window.removeEventListener(`touchstart`,r)}},[]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(uw,{}),(0,I.jsx)(hw,{}),(0,I.jsx)(gw,{}),(0,I.jsx)(eT,{}),(0,I.jsx)(sE,{}),(0,I.jsx)(cE,{}),(0,I.jsx)(lE,{}),(0,I.jsx)(tT,{}),(0,I.jsx)(aT,{}),(0,I.jsx)(tE,{})]})}export{uE as default}; \ No newline at end of file