Files
cad-Integration/text-to-cad-main/skills/cad/scripts/snapshot/runtime/snapshot-render.js
T
2026-07-22 13:48:46 +08:00

4169 lines
899 KiB
JavaScript

var dM=Object.defineProperty;var Eh=(n,e)=>()=>(n&&(e=n(n=0)),e);var wg=(n,e)=>{for(var t in e)dM(n,t,{get:e[t],enumerable:!0})};var Qn={};wg(Qn,{ACESFilmicToneMapping:()=>yu,AddEquation:()=>rr,AddOperation:()=>By,AdditiveAnimationBlendMode:()=>fp,AdditiveBlending:()=>pf,AgXToneMapping:()=>Hy,AlphaFormat:()=>qy,AlwaysCompare:()=>hx,AlwaysDepth:()=>Py,AlwaysStencilFunc:()=>Xf,AmbientLight:()=>yo,AnimationAction:()=>mu,AnimationClip:()=>Wi,AnimationLoader:()=>bd,AnimationMixer:()=>Ud,AnimationObjectGroup:()=>Dd,AnimationUtils:()=>j1,ArcCurve:()=>Nl,ArrayCamera:()=>Al,ArrowHelper:()=>tp,AttachedBindMode:()=>_f,Audio:()=>du,AudioAnalyser:()=>Ld,AudioContext:()=>Ua,AudioListener:()=>Pd,AudioLoader:()=>Rd,AxesHelper:()=>np,BackSide:()=>hn,BasicDepthPacking:()=>nx,BasicShadowMap:()=>PM,BatchedMesh:()=>Pl,Bone:()=>is,BooleanKeyframeTrack:()=>Gi,Box2:()=>Wd,Box3:()=>xt,Box3Helper:()=>Qd,BoxGeometry:()=>Qr,BoxHelper:()=>Jd,BufferAttribute:()=>Ze,BufferGeometry:()=>Be,BufferGeometryLoader:()=>hu,ByteType:()=>Xy,Cache:()=>Ni,Camera:()=>io,CameraHelper:()=>Zd,CanvasTexture:()=>_a,CapsuleGeometry:()=>Bl,CatmullRomCurve3:()=>Ll,CineonToneMapping:()=>ky,CircleGeometry:()=>zl,ClampToEdgeWrapping:()=>Xt,Clock:()=>fu,Color:()=>oe,ColorKeyframeTrack:()=>Na,ColorManagement:()=>rt,CompressedArrayTexture:()=>md,CompressedCubeTexture:()=>gd,CompressedTexture:()=>uo,CompressedTextureLoader:()=>Md,ConeGeometry:()=>Vl,ConstantAlphaFactor:()=>Cy,ConstantColorFactor:()=>wy,CubeCamera:()=>Ml,CubeReflectionMapping:()=>Bi,CubeRefractionMapping:()=>cr,CubeTexture:()=>es,CubeTextureLoader:()=>vd,CubeUVReflectionMapping:()=>_o,CubicBezierCurve:()=>Sa,CubicBezierCurve3:()=>Ol,CubicInterpolant:()=>ru,CullFaceBack:()=>df,CullFaceFront:()=>dy,CullFaceFrontBack:()=>IM,CullFaceNone:()=>fy,Curve:()=>Cn,CurvePath:()=>Fl,CustomBlending:()=>py,CustomToneMapping:()=>Gy,CylinderGeometry:()=>fo,Cylindrical:()=>Hd,Data3DTexture:()=>ua,DataArrayTexture:()=>eo,DataTexture:()=>Ui,DataTextureLoader:()=>Ad,DataUtils:()=>Ov,DecrementStencilOp:()=>VM,DecrementWrapStencilOp:()=>GM,DefaultLoadingManager:()=>Rx,DepthFormat:()=>or,DepthStencilFormat:()=>Zr,DepthTexture:()=>ma,DetachedBindMode:()=>Wy,DirectionalLight:()=>mr,DirectionalLightHelper:()=>Kd,DiscreteInterpolant:()=>su,DisplayP3ColorSpace:()=>bu,DodecahedronGeometry:()=>kl,DoubleSide:()=>On,DstAlphaFactor:()=>by,DstColorFactor:()=>vy,DynamicCopyUsage:()=>iv,DynamicDrawUsage:()=>ZM,DynamicReadUsage:()=>ev,EdgesGeometry:()=>Gl,EllipseCurve:()=>ho,EqualCompare:()=>ax,EqualDepth:()=>Ly,EqualStencilFunc:()=>YM,EquirectangularReflectionMapping:()=>$r,EquirectangularRefractionMapping:()=>na,Euler:()=>ha,EventDispatcher:()=>$n,ExtrudeGeometry:()=>Hl,FileLoader:()=>Sn,Float16BufferAttribute:()=>nd,Float32BufferAttribute:()=>ye,Float64BufferAttribute:()=>id,FloatType:()=>Xn,Fog:()=>Cl,FogExp2:()=>Tl,FramebufferTexture:()=>pd,FrontSide:()=>qn,Frustum:()=>ts,GLBufferAttribute:()=>zd,GLSL1:()=>sv,GLSL3:()=>Yf,GreaterCompare:()=>cx,GreaterDepth:()=>Dy,GreaterEqualCompare:()=>ux,GreaterEqualDepth:()=>Oy,GreaterEqualStencilFunc:()=>KM,GreaterStencilFunc:()=>jM,GridHelper:()=>Ba,Group:()=>Dn,HalfFloatType:()=>Zs,HemisphereLight:()=>go,HemisphereLightHelper:()=>jd,IcosahedronGeometry:()=>Wl,ImageBitmapLoader:()=>Da,ImageLoader:()=>as,ImageUtils:()=>la,IncrementStencilOp:()=>zM,IncrementWrapStencilOp:()=>kM,InstancedBufferAttribute:()=>Kn,InstancedBufferGeometry:()=>xo,InstancedInterleavedBuffer:()=>gr,InstancedMesh:()=>ao,Int16BufferAttribute:()=>ed,Int32BufferAttribute:()=>td,Int8BufferAttribute:()=>Zf,IntType:()=>sp,InterleavedBuffer:()=>Vi,InterleavedBufferAttribute:()=>Yt,Interpolant:()=>ki,InterpolateDiscrete:()=>Jr,InterpolateLinear:()=>lr,InterpolateSmooth:()=>gl,InvertStencilOp:()=>HM,KeepStencilOp:()=>Vr,KeyframeTrack:()=>Rn,LOD:()=>Il,LatheGeometry:()=>Ea,Layers:()=>to,LessCompare:()=>ox,LessDepth:()=>Ny,LessEqualCompare:()=>mp,LessEqualDepth:()=>ta,LessEqualStencilFunc:()=>qM,LessStencilFunc:()=>XM,Light:()=>hi,LightProbe:()=>lu,Line:()=>Un,Line3:()=>Fa,LineBasicMaterial:()=>Vt,LineCurve:()=>ba,LineCurve3:()=>Dl,LineDashedMaterial:()=>iu,LineLoop:()=>co,LineSegments:()=>xn,LinearDisplayP3ColorSpace:()=>Ga,LinearEncoding:()=>pp,LinearFilter:()=>yt,LinearInterpolant:()=>Pa,LinearMipMapLinearFilter:()=>UM,LinearMipMapNearestFilter:()=>DM,LinearMipmapLinearFilter:()=>jn,LinearMipmapNearestFilter:()=>Va,LinearSRGBColorSpace:()=>Dt,LinearToneMapping:()=>zy,LinearTransfer:()=>ra,Loader:()=>qt,LoaderUtils:()=>Jn,LoadingManager:()=>La,LoopOnce:()=>Qy,LoopPingPong:()=>tx,LoopRepeat:()=>ex,LuminanceAlphaFormat:()=>$y,LuminanceFormat:()=>jy,MOUSE:()=>CM,Material:()=>It,MaterialLoader:()=>uu,MathUtils:()=>Ha,Matrix3:()=>Ye,Matrix4:()=>we,MaxEquation:()=>xf,Mesh:()=>ft,MeshBasicMaterial:()=>sn,MeshDepthMaterial:()=>ga,MeshDistanceMaterial:()=>ya,MeshLambertMaterial:()=>tu,MeshMatcapMaterial:()=>nu,MeshNormalMaterial:()=>eu,MeshPhongMaterial:()=>Jl,MeshPhysicalMaterial:()=>_n,MeshStandardMaterial:()=>fr,MeshToonMaterial:()=>Ql,MinEquation:()=>yf,MirroredRepeatWrapping:()=>Kr,MixOperation:()=>Fy,MultiplyBlending:()=>gf,MultiplyOperation:()=>za,NearestFilter:()=>Mt,NearestMipMapLinearFilter:()=>OM,NearestMipMapNearestFilter:()=>LM,NearestMipmapLinearFilter:()=>qr,NearestMipmapNearestFilter:()=>Ks,NeverCompare:()=>sx,NeverDepth:()=>Iy,NeverStencilFunc:()=>WM,NoBlending:()=>Li,NoColorSpace:()=>En,NoToneMapping:()=>Oi,NormalAnimationBlendMode:()=>Su,NormalBlending:()=>Yr,NotEqualCompare:()=>lx,NotEqualDepth:()=>Uy,NotEqualStencilFunc:()=>$M,NumberKeyframeTrack:()=>li,Object3D:()=>it,ObjectLoader:()=>Cd,ObjectSpaceNormalMap:()=>rx,OctahedronGeometry:()=>Ra,OneFactor:()=>xy,OneMinusConstantAlphaFactor:()=>Ry,OneMinusConstantColorFactor:()=>Ty,OneMinusDstAlphaFactor:()=>My,OneMinusDstColorFactor:()=>Ay,OneMinusSrcAlphaFactor:()=>xl,OneMinusSrcColorFactor:()=>Sy,OrthographicCamera:()=>ci,P3Primaries:()=>oa,PCFShadowMap:()=>rp,PCFSoftShadowMap:()=>gu,PMREMGenerator:()=>pa,Path:()=>ss,PerspectiveCamera:()=>vt,Plane:()=>oi,PlaneGeometry:()=>ns,PlaneHelper:()=>ep,PointLight:()=>pr,PointLightHelper:()=>qd,Points:()=>lo,PointsMaterial:()=>rs,PolarGridHelper:()=>$d,PolyhedronGeometry:()=>hr,PositionalAudio:()=>Nd,PropertyBinding:()=>ot,PropertyMixer:()=>pu,QuadraticBezierCurve:()=>Ma,QuadraticBezierCurve3:()=>va,Quaternion:()=>Ft,QuaternionKeyframeTrack:()=>Zn,QuaternionLinearInterpolant:()=>ou,RED_GREEN_RGTC2_Format:()=>Hf,RED_RGTC1_Format:()=>Jy,REVISION:()=>TM,RGBADepthPacking:()=>ix,RGBAFormat:()=>mn,RGBAIntegerFormat:()=>up,RGBA_ASTC_10x10_Format:()=>Ff,RGBA_ASTC_10x5_Format:()=>Of,RGBA_ASTC_10x6_Format:()=>Df,RGBA_ASTC_10x8_Format:()=>Uf,RGBA_ASTC_12x10_Format:()=>Bf,RGBA_ASTC_12x12_Format:()=>zf,RGBA_ASTC_4x4_Format:()=>wf,RGBA_ASTC_5x4_Format:()=>Tf,RGBA_ASTC_5x5_Format:()=>Cf,RGBA_ASTC_6x5_Format:()=>Rf,RGBA_ASTC_6x6_Format:()=>If,RGBA_ASTC_8x5_Format:()=>Pf,RGBA_ASTC_8x6_Format:()=>Nf,RGBA_ASTC_8x8_Format:()=>Lf,RGBA_BPTC_Format:()=>ml,RGBA_ETC2_EAC_Format:()=>Ef,RGBA_PVRTC_2BPPV1_Format:()=>vf,RGBA_PVRTC_4BPPV1_Format:()=>Mf,RGBA_S3TC_DXT1_Format:()=>fl,RGBA_S3TC_DXT3_Format:()=>dl,RGBA_S3TC_DXT5_Format:()=>pl,RGB_BPTC_SIGNED_Format:()=>Vf,RGB_BPTC_UNSIGNED_Format:()=>kf,RGB_ETC1_Format:()=>hp,RGB_ETC2_Format:()=>Af,RGB_PVRTC_2BPPV1_Format:()=>bf,RGB_PVRTC_4BPPV1_Format:()=>Sf,RGB_S3TC_DXT1_Format:()=>hl,RGFormat:()=>Zy,RGIntegerFormat:()=>lp,RawShaderMaterial:()=>Zl,Ray:()=>ur,Raycaster:()=>Vd,Rec709Primaries:()=>sa,RectAreaLight:()=>au,RedFormat:()=>Ky,RedIntegerFormat:()=>cp,ReinhardToneMapping:()=>Vy,RenderTarget:()=>bl,RepeatWrapping:()=>zi,ReplaceStencilOp:()=>BM,ReverseSubtractEquation:()=>gy,RingGeometry:()=>Xl,SIGNED_RED_GREEN_RGTC2_Format:()=>Wf,SIGNED_RED_RGTC1_Format:()=>Gf,SRGBColorSpace:()=>lt,SRGBTransfer:()=>gt,Scene:()=>ro,ShaderChunk:()=>He,ShaderLib:()=>rn,ShaderMaterial:()=>yn,ShadowMaterial:()=>mo,Shape:()=>Fi,ShapeGeometry:()=>Yl,ShapePath:()=>ip,ShapeUtils:()=>ai,ShortType:()=>Yy,Skeleton:()=>oo,SkeletonHelper:()=>Yd,SkinnedMesh:()=>so,Source:()=>Ii,Sphere:()=>_t,SphereGeometry:()=>Ia,Spherical:()=>Gd,SphericalHarmonics3:()=>cu,SplineCurve:()=>Aa,SpotLight:()=>dr,SpotLightHelper:()=>Xd,Sprite:()=>Rl,SpriteMaterial:()=>xa,SrcAlphaFactor:()=>yl,SrcAlphaSaturateFactor:()=>Ey,SrcColorFactor:()=>_y,StaticCopyUsage:()=>nv,StaticDrawUsage:()=>aa,StaticReadUsage:()=>QM,StereoCamera:()=>Id,StreamCopyUsage:()=>rv,StreamDrawUsage:()=>JM,StreamReadUsage:()=>tv,StringKeyframeTrack:()=>Hi,SubtractEquation:()=>my,SubtractiveBlending:()=>mf,TOUCH:()=>RM,TangentSpaceNormalMap:()=>yr,TetrahedronGeometry:()=>ql,Texture:()=>Rt,TextureLoader:()=>cs,TorusGeometry:()=>jl,TorusKnotGeometry:()=>$l,Triangle:()=>Pi,TriangleFanDrawMode:()=>So,TriangleStripDrawMode:()=>ka,TrianglesDrawMode:()=>dp,TubeGeometry:()=>Kl,TwoPassDoubleSide:()=>NM,UVMapping:()=>xu,Uint16BufferAttribute:()=>fa,Uint32BufferAttribute:()=>da,Uint8BufferAttribute:()=>Jf,Uint8ClampedBufferAttribute:()=>Qf,Uniform:()=>Fd,UniformsGroup:()=>Bd,UniformsLib:()=>se,UniformsUtils:()=>Wa,UnsignedByteType:()=>Di,UnsignedInt248Type:()=>sr,UnsignedIntType:()=>Ri,UnsignedShort4444Type:()=>op,UnsignedShort5551Type:()=>ap,UnsignedShortType:()=>_u,VSMShadowMap:()=>si,Vector2:()=>Z,Vector3:()=>w,Vector4:()=>tt,VectorKeyframeTrack:()=>ui,VideoTexture:()=>dd,WebGL1Renderer:()=>wl,WebGL3DRenderTarget:()=>$f,WebGLArrayRenderTarget:()=>jf,WebGLCoordinateSystem:()=>Yn,WebGLCubeRenderTarget:()=>vl,WebGLMultipleRenderTargets:()=>Kf,WebGLRenderTarget:()=>Tn,WebGLRenderer:()=>El,WebGLUtils:()=>Mx,WebGPUCoordinateSystem:()=>Js,WireframeGeometry:()=>po,WrapAroundEnding:()=>ia,ZeroCurvatureEnding:()=>Hr,ZeroFactor:()=>yy,ZeroSlopeEnding:()=>Wr,ZeroStencilOp:()=>FM,_SRGBAFormat:()=>_l,createCanvasElement:()=>dx,sRGBEncoding:()=>ar});function wn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(en[n&255]+en[n>>8&255]+en[n>>16&255]+en[n>>24&255]+"-"+en[e&255]+en[e>>8&255]+"-"+en[e>>16&15|64]+en[e>>24&255]+"-"+en[t&63|128]+en[t>>8&255]+"-"+en[t>>16&255]+en[t>>24&255]+en[i&255]+en[i>>8&255]+en[i>>16&255]+en[i>>24&255]).toLowerCase()}function Ct(n,e,t){return Math.max(e,Math.min(t,n))}function gp(n,e){return(n%e+e)%e}function ov(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function av(n,e,t){return n!==e?(t-n)/(e-n):0}function Ko(n,e,t){return(1-t)*n+t*e}function cv(n,e,t,i){return Ko(n,e,1-Math.exp(-t*i))}function lv(n,e=1){return e-Math.abs(gp(n,e*2)-e)}function uv(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function hv(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function fv(n,e){return n+Math.floor(Math.random()*(e-n+1))}function dv(n,e){return n+Math.random()*(e-n)}function pv(n){return n*(.5-Math.random())}function mv(n){n!==void 0&&(Fg=n);let e=Fg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function gv(n){return n*jr}function yv(n){return n*Qs}function qf(n){return(n&n-1)===0&&n!==0}function xv(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Sl(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function _v(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),u=o((e+i)/2),h=s((e-i)/2),f=o((e-i)/2),d=s((i-e)/2),m=o((i-e)/2);switch(r){case"XYX":n.set(a*u,c*h,c*f,a*l);break;case"YZY":n.set(c*f,a*u,c*h,a*l);break;case"ZXZ":n.set(c*h,c*f,a*u,a*l);break;case"XZX":n.set(a*u,c*m,c*d,a*l);break;case"YXY":n.set(c*d,a*u,c*m,a*l);break;case"ZYZ":n.set(c*m,c*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function gn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function We(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function fx(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ws(n,e){return new Sv[n](e)}function ca(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function dx(){let n=ca("canvas");return n.style.display="block",n}function Zo(n){n in Bg||(Bg[n]=!0,console.warn(n))}function js(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ph(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Nh(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?la.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function Oh(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Pr.fromArray(n,s);let a=r.x*Math.abs(Pr.x)+r.y*Math.abs(Pr.y)+r.z*Math.abs(Pr.z),c=e.dot(Pr),l=t.dot(Pr),u=i.dot(Pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}function Hh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function Lv(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function pn(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Ct(n,-65504,65504),Ci.floatView[0]=n;let e=Ci.uint32View[0],t=e>>23&511;return Ci.baseTable[t]+((e&8388607)>>Ci.shiftTable[t])}function $o(n){let e=n>>10;return Ci.uint32View[0]=Ci.mantissaTable[Ci.offsetTable[e]+(n&1023)]+Ci.exponentTable[e],Ci.floatView[0]}function Uv(n,e,t,i,r,s,o,a){let c;if(e.side===hn?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===qn,a),c===null)return null;Uc.copy(a),Uc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Uc);return l<t.near||l>t.far?null:{distance:l,point:Uc.clone(),object:n}}function Fc(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,Ns),n.getVertexPosition(c,Ls),n.getVertexPosition(l,Os);let u=Uv(n,e,t,i,Ns,Ls,Os,Dc);if(u){r&&(Nc.fromBufferAttribute(r,a),Lc.fromBufferAttribute(r,c),Oc.fromBufferAttribute(r,l),u.uv=Pi.getInterpolation(Dc,Ns,Ls,Os,Nc,Lc,Oc,new Z)),s&&(Nc.fromBufferAttribute(s,a),Lc.fromBufferAttribute(s,c),Oc.fromBufferAttribute(s,l),u.uv1=Pi.getInterpolation(Dc,Ns,Ls,Os,Nc,Lc,Oc,new Z),u.uv2=u.uv1),o&&(Zg.fromBufferAttribute(o,a),Jg.fromBufferAttribute(o,c),Qg.fromBufferAttribute(o,l),u.normal=Pi.getInterpolation(Dc,Ns,Ls,Os,Zg,Jg,Qg,new w),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let h={a,b:c,c:l,normal:new w,materialIndex:0};Pi.getNormal(Ns,Ls,Os,h.normal),u.face=h}return u}function no(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function un(n){let e={};for(let t=0;t<n.length;t++){let i=no(n[t]);for(let r in i)e[r]=i[r]}return e}function Fv(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function mx(n){return n.getRenderTarget()===null?n.outputColorSpace:rt.workingColorSpace}function gx(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function Gv(n,e){let t=e.isWebGL2,i=new WeakMap;function r(l,u){let h=l.array,f=l.usage,d=h.byteLength,m=n.createBuffer();n.bindBuffer(u,m),n.bufferData(u,h,f),l.onUploadCallback();let y;if(h instanceof Float32Array)y=n.FLOAT;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)y=n.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=n.UNSIGNED_SHORT;else if(h instanceof Int16Array)y=n.SHORT;else if(h instanceof Uint32Array)y=n.UNSIGNED_INT;else if(h instanceof Int32Array)y=n.INT;else if(h instanceof Int8Array)y=n.BYTE;else if(h instanceof Uint8Array)y=n.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version,size:d}}function s(l,u,h){let f=u.array,d=u._updateRange,m=u.updateRanges;if(n.bindBuffer(h,l),d.count===-1&&m.length===0&&n.bufferSubData(h,0,f),m.length!==0){for(let y=0,g=m.length;y<g;y++){let p=m[y];t?n.bufferSubData(h,p.start*f.BYTES_PER_ELEMENT,f,p.start,p.count):n.bufferSubData(h,p.start*f.BYTES_PER_ELEMENT,f.subarray(p.start,p.start+p.count))}u.clearUpdateRanges()}d.count!==-1&&(t?n.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):n.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1),u.onUploadCallback()}function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),i.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);let u=i.get(l);u&&(n.deleteBuffer(u.buffer),i.delete(l))}function c(l,u){if(l.isGLBufferAttribute){let f=i.get(l);(!f||f.version<l.version)&&i.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);let h=i.get(l);if(h===void 0)i.set(l,r(l,u));else if(h.version<l.version){if(h.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(h.buffer,l,u),h.version=l.version}}return{get:o,remove:a,update:c}}function Mw(n,e,t,i,r,s,o){let a=new oe(0),c=s===!0?0:1,l,u,h=null,f=0,d=null;function m(g,p){let _=!1,x=p.isScene===!0?p.background:null;x&&x.isTexture&&(x=(p.backgroundBlurriness>0?t:e).get(x)),x===null?y(a,c):x&&x.isColor&&(y(x,1),_=!0);let b=n.xr.getEnvironmentBlendMode();b==="additive"?i.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||_)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),x&&(x.isCubeTexture||x.mapping===_o)?(u===void 0&&(u=new ft(new Qr(1,1,1),new yn({name:"BackgroundCubeMaterial",uniforms:no(rn.backgroundCube.uniforms),vertexShader:rn.backgroundCube.vertexShader,fragmentShader:rn.backgroundCube.fragmentShader,side:hn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,A,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),u.material.uniforms.envMap.value=x,u.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,u.material.toneMapped=rt.getTransfer(x.colorSpace)!==gt,(h!==x||f!==x.version||d!==n.toneMapping)&&(u.material.needsUpdate=!0,h=x,f=x.version,d=n.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new ft(new ns(2,2),new yn({name:"BackgroundMaterial",uniforms:no(rn.background.uniforms),vertexShader:rn.background.vertexShader,fragmentShader:rn.background.fragmentShader,side:qn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=rt.getTransfer(x.colorSpace)!==gt,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||f!==x.version||d!==n.toneMapping)&&(l.material.needsUpdate=!0,h=x,f=x.version,d=n.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function y(g,p){g.getRGB(zc,mx(n)),i.buffers.color.setClear(zc.r,zc.g,zc.b,p,o)}return{getClearColor:function(){return a},setClearColor:function(g,p=1){a.set(g),c=p,y(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,y(a,c)},render:m}}function vw(n,e,t,i){let r=n.getParameter(n.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},c=g(null),l=c,u=!1;function h(P,D,z,q,Y){let W=!1;if(o){let j=y(q,z,D);l!==j&&(l=j,d(l.object)),W=p(P,q,z,Y),W&&_(P,q,z,Y)}else{let j=D.wireframe===!0;(l.geometry!==q.id||l.program!==z.id||l.wireframe!==j)&&(l.geometry=q.id,l.program=z.id,l.wireframe=j,W=!0)}Y!==null&&t.update(Y,n.ELEMENT_ARRAY_BUFFER),(W||u)&&(u=!1,C(P,D,z,q),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(Y).buffer))}function f(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function d(P){return i.isWebGL2?n.bindVertexArray(P):s.bindVertexArrayOES(P)}function m(P){return i.isWebGL2?n.deleteVertexArray(P):s.deleteVertexArrayOES(P)}function y(P,D,z){let q=z.wireframe===!0,Y=a[P.id];Y===void 0&&(Y={},a[P.id]=Y);let W=Y[D.id];W===void 0&&(W={},Y[D.id]=W);let j=W[q];return j===void 0&&(j=g(f()),W[q]=j),j}function g(P){let D=[],z=[],q=[];for(let Y=0;Y<r;Y++)D[Y]=0,z[Y]=0,q[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:z,attributeDivisors:q,object:P,attributes:{},index:null}}function p(P,D,z,q){let Y=l.attributes,W=D.attributes,j=0,J=z.getAttributes();for(let le in J)if(J[le].location>=0){let Q=Y[le],ue=W[le];if(ue===void 0&&(le==="instanceMatrix"&&P.instanceMatrix&&(ue=P.instanceMatrix),le==="instanceColor"&&P.instanceColor&&(ue=P.instanceColor)),Q===void 0||Q.attribute!==ue||ue&&Q.data!==ue.data)return!0;j++}return l.attributesNum!==j||l.index!==q}function _(P,D,z,q){let Y={},W=D.attributes,j=0,J=z.getAttributes();for(let le in J)if(J[le].location>=0){let Q=W[le];Q===void 0&&(le==="instanceMatrix"&&P.instanceMatrix&&(Q=P.instanceMatrix),le==="instanceColor"&&P.instanceColor&&(Q=P.instanceColor));let ue={};ue.attribute=Q,Q&&Q.data&&(ue.data=Q.data),Y[le]=ue,j++}l.attributes=Y,l.attributesNum=j,l.index=q}function x(){let P=l.newAttributes;for(let D=0,z=P.length;D<z;D++)P[D]=0}function b(P){T(P,0)}function T(P,D){let z=l.newAttributes,q=l.enabledAttributes,Y=l.attributeDivisors;z[P]=1,q[P]===0&&(n.enableVertexAttribArray(P),q[P]=1),Y[P]!==D&&((i.isWebGL2?n:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,D),Y[P]=D)}function A(){let P=l.newAttributes,D=l.enabledAttributes;for(let z=0,q=D.length;z<q;z++)D[z]!==P[z]&&(n.disableVertexAttribArray(z),D[z]=0)}function M(P,D,z,q,Y,W,j){j===!0?n.vertexAttribIPointer(P,D,z,Y,W):n.vertexAttribPointer(P,D,z,q,Y,W)}function C(P,D,z,q){if(i.isWebGL2===!1&&(P.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;x();let Y=q.attributes,W=z.getAttributes(),j=D.defaultAttributeValues;for(let J in W){let le=W[J];if(le.location>=0){let X=Y[J];if(X===void 0&&(J==="instanceMatrix"&&P.instanceMatrix&&(X=P.instanceMatrix),J==="instanceColor"&&P.instanceColor&&(X=P.instanceColor)),X!==void 0){let Q=X.normalized,ue=X.itemSize,xe=t.get(X);if(xe===void 0)continue;let he=xe.buffer,Ce=xe.type,De=xe.bytesPerElement,Me=i.isWebGL2===!0&&(Ce===n.INT||Ce===n.UNSIGNED_INT||X.gpuType===sp);if(X.isInterleavedBufferAttribute){let Ue=X.data,N=Ue.stride,ae=X.offset;if(Ue.isInstancedInterleavedBuffer){for(let K=0;K<le.locationSize;K++)T(le.location+K,Ue.meshPerAttribute);P.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Ue.meshPerAttribute*Ue.count)}else for(let K=0;K<le.locationSize;K++)b(le.location+K);n.bindBuffer(n.ARRAY_BUFFER,he);for(let K=0;K<le.locationSize;K++)M(le.location+K,ue/le.locationSize,Ce,Q,N*De,(ae+ue/le.locationSize*K)*De,Me)}else{if(X.isInstancedBufferAttribute){for(let Ue=0;Ue<le.locationSize;Ue++)T(le.location+Ue,X.meshPerAttribute);P.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let Ue=0;Ue<le.locationSize;Ue++)b(le.location+Ue);n.bindBuffer(n.ARRAY_BUFFER,he);for(let Ue=0;Ue<le.locationSize;Ue++)M(le.location+Ue,ue/le.locationSize,Ce,Q,ue*De,ue/le.locationSize*Ue*De,Me)}}else if(j!==void 0){let Q=j[J];if(Q!==void 0)switch(Q.length){case 2:n.vertexAttrib2fv(le.location,Q);break;case 3:n.vertexAttrib3fv(le.location,Q);break;case 4:n.vertexAttrib4fv(le.location,Q);break;default:n.vertexAttrib1fv(le.location,Q)}}}}A()}function S(){U();for(let P in a){let D=a[P];for(let z in D){let q=D[z];for(let Y in q)m(q[Y].object),delete q[Y];delete D[z]}delete a[P]}}function v(P){if(a[P.id]===void 0)return;let D=a[P.id];for(let z in D){let q=D[z];for(let Y in q)m(q[Y].object),delete q[Y];delete D[z]}delete a[P.id]}function L(P){for(let D in a){let z=a[D];if(z[P.id]===void 0)continue;let q=z[P.id];for(let Y in q)m(q[Y].object),delete q[Y];delete z[P.id]}}function U(){G(),u=!0,l!==c&&(l=c,d(l.object))}function G(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:U,resetDefaultState:G,dispose:S,releaseStatesOfGeometry:v,releaseStatesOfProgram:L,initAttributes:x,enableAttribute:b,disableUnusedAttributes:A}}function Aw(n,e,t,i){let r=i.isWebGL2,s;function o(u){s=u}function a(u,h){n.drawArrays(s,u,h),t.update(h,s,1)}function c(u,h,f){if(f===0)return;let d,m;if(r)d=n,m="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[m](s,u,h,f),t.update(h,s,f)}function l(u,h,f){if(f===0)return;let d=e.get("WEBGL_multi_draw");if(d===null)for(let m=0;m<f;m++)this.render(u[m],h[m]);else{d.multiDrawArraysWEBGL(s,u,0,h,0,f);let m=0;for(let y=0;y<f;y++)m+=h[y];t.update(m,s,1)}}this.setMode=o,this.render=a,this.renderInstances=c,this.renderMultiDraw=l}function Ew(n,e,t){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){let M=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(M){if(M==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&n.constructor.name==="WebGL2RenderingContext",a=t.precision!==void 0?t.precision:"highp",c=s(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);let l=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),y=n.getParameter(n.MAX_VERTEX_ATTRIBS),g=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),p=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),x=f>0,b=o||e.has("OES_texture_float"),T=x&&b,A=o?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:m,maxAttributes:y,maxVertexUniforms:g,maxVaryings:p,maxFragmentUniforms:_,vertexTextures:x,floatFragmentTextures:b,floatVertexTextures:T,maxSamples:A}}function ww(n){let e=this,t=null,i=0,r=!1,s=!1,o=new oi,a=new Ye,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let d=h.length!==0||f||i!==0||r;return r=f,i=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,d){let m=h.clippingPlanes,y=h.clipIntersection,g=h.clipShadows,p=n.get(h);if(!r||m===null||m.length===0||s&&!g)s?u(null):l();else{let _=s?0:i,x=_*4,b=p.clippingState||null;c.value=b,b=u(m,f,x,d);for(let T=0;T!==x;++T)b[T]=t[T];p.clippingState=b,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,f,d,m){let y=h!==null?h.length:0,g=null;if(y!==0){if(g=c.value,m!==!0||g===null){let p=d+y*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(g===null||g.length<p)&&(g=new Float32Array(p));for(let x=0,b=d;x!==y;++x,b+=4)o.copy(h[x]).applyMatrix4(_,a),o.normal.toArray(g,b),g[b+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function Tw(n){let e=new WeakMap;function t(o,a){return a===$r?o.mapping=Bi:a===na&&(o.mapping=cr),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===$r||a===na)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new vl(c.height/2);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function Cw(n){let e=[],t=[],i=[],r=n,s=n-Xs+1+e0.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Xs?c=e0[o-n+Xs-1]:o===0&&(c=0),i.push(c);let l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,m=6,y=3,g=2,p=1,_=new Float32Array(y*m*d),x=new Float32Array(g*m*d),b=new Float32Array(p*m*d);for(let A=0;A<d;A++){let M=A%3*2/3-1,C=A>2?0:-1,S=[M,C,0,M+2/3,C,0,M+2/3,C+1,0,M,C,0,M+2/3,C+1,0,M,C+1,0];_.set(S,y*m*A),x.set(f,g*m*A);let v=[A,A,A,A,A,A];b.set(v,p*m*A)}let T=new Be;T.setAttribute("position",new Ze(_,y)),T.setAttribute("uv",new Ze(x,g)),T.setAttribute("faceIndex",new Ze(b,p)),e.push(T),r>Xs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function i0(n,e,t){let i=new Tn(n,e,t);return i.texture.mapping=_o,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Vc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Rw(n,e,t){let i=new Float32Array(Gr),r=new w(0,1,0);return new yn({name:"SphericalGaussianBlur",defines:{n:Gr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:yp(),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 <cube_uv_reflection_fragment>
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:Li,depthTest:!1,depthWrite:!1})}function r0(){return new yn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yp(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:Li,depthTest:!1,depthWrite:!1})}function s0(){return new yn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yp(),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:Li,depthTest:!1,depthWrite:!1})}function yp(){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 Iw(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let c=a.mapping,l=c===$r||c===na,u=c===Bi||c===cr;if(l||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new pa(n)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(l&&h&&h.height>0||u&&h&&r(h)){t===null&&(t=new pa(n));let f=l?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",s),f.texture}else return null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function Pw(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?(t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance")):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function Nw(n,e,t,i){let r={},s=new WeakMap;function o(h){let f=h.target;f.index!==null&&e.remove(f.index);for(let m in f.attributes)e.remove(f.attributes[m]);for(let m in f.morphAttributes){let y=f.morphAttributes[m];for(let g=0,p=y.length;g<p;g++)e.remove(y[g])}f.removeEventListener("dispose",o),delete r[f.id];let d=s.get(f);d&&(e.remove(d),s.delete(f)),i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(h,f){return r[f.id]===!0||(f.addEventListener("dispose",o),r[f.id]=!0,t.memory.geometries++),f}function c(h){let f=h.attributes;for(let m in f)e.update(f[m],n.ARRAY_BUFFER);let d=h.morphAttributes;for(let m in d){let y=d[m];for(let g=0,p=y.length;g<p;g++)e.update(y[g],n.ARRAY_BUFFER)}}function l(h){let f=[],d=h.index,m=h.attributes.position,y=0;if(d!==null){let _=d.array;y=d.version;for(let x=0,b=_.length;x<b;x+=3){let T=_[x+0],A=_[x+1],M=_[x+2];f.push(T,A,A,M,M,T)}}else if(m!==void 0){let _=m.array;y=m.version;for(let x=0,b=_.length/3-1;x<b;x+=3){let T=x+0,A=x+1,M=x+2;f.push(T,A,A,M,M,T)}}else return;let g=new(fx(f)?da:fa)(f,1);g.version=y;let p=s.get(h);p&&e.remove(p),s.set(h,g)}function u(h){let f=s.get(h);if(f){let d=h.index;d!==null&&f.version<d.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function Lw(n,e,t,i){let r=i.isWebGL2,s;function o(d){s=d}let a,c;function l(d){a=d.type,c=d.bytesPerElement}function u(d,m){n.drawElements(s,m,a,d*c),t.update(m,s,1)}function h(d,m,y){if(y===0)return;let g,p;if(r)g=n,p="drawElementsInstanced";else if(g=e.get("ANGLE_instanced_arrays"),p="drawElementsInstancedANGLE",g===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[p](s,m,a,d*c,y),t.update(m,s,y)}function f(d,m,y){if(y===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let p=0;p<y;p++)this.render(d[p]/c,m[p]);else{g.multiDrawElementsWEBGL(s,m,0,a,d,0,y);let p=0;for(let _=0;_<y;_++)p+=m[_];t.update(p,s,1)}}this.setMode=o,this.setIndex=l,this.render=u,this.renderInstances=h,this.renderMultiDraw=f}function Ow(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function Dw(n,e){return n[0]-e[0]}function Uw(n,e){return Math.abs(e[1])-Math.abs(n[1])}function Fw(n,e,t){let i={},r=new Float32Array(8),s=new WeakMap,o=new tt,a=[];for(let l=0;l<8;l++)a[l]=[l,0];function c(l,u,h){let f=l.morphTargetInfluences;if(e.isWebGL2===!0){let d=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,m=d!==void 0?d.length:0,y=s.get(u);if(y===void 0||y.count!==m){let P=function(){U.dispose(),s.delete(u),u.removeEventListener("dispose",P)};y!==void 0&&y.texture.dispose();let _=u.morphAttributes.position!==void 0,x=u.morphAttributes.normal!==void 0,b=u.morphAttributes.color!==void 0,T=u.morphAttributes.position||[],A=u.morphAttributes.normal||[],M=u.morphAttributes.color||[],C=0;_===!0&&(C=1),x===!0&&(C=2),b===!0&&(C=3);let S=u.attributes.position.count*C,v=1;S>e.maxTextureSize&&(v=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let L=new Float32Array(S*v*4*m),U=new eo(L,S,v,m);U.type=Xn,U.needsUpdate=!0;let G=C*4;for(let D=0;D<m;D++){let z=T[D],q=A[D],Y=M[D],W=S*v*4*D;for(let j=0;j<z.count;j++){let J=j*G;_===!0&&(o.fromBufferAttribute(z,j),L[W+J+0]=o.x,L[W+J+1]=o.y,L[W+J+2]=o.z,L[W+J+3]=0),x===!0&&(o.fromBufferAttribute(q,j),L[W+J+4]=o.x,L[W+J+5]=o.y,L[W+J+6]=o.z,L[W+J+7]=0),b===!0&&(o.fromBufferAttribute(Y,j),L[W+J+8]=o.x,L[W+J+9]=o.y,L[W+J+10]=o.z,L[W+J+11]=Y.itemSize===4?o.w:1)}}y={count:m,texture:U,size:new Z(S,v)},s.set(u,y),u.addEventListener("dispose",P)}let g=0;for(let _=0;_<f.length;_++)g+=f[_];let p=u.morphTargetsRelative?1:1-g;h.getUniforms().setValue(n,"morphTargetBaseInfluence",p),h.getUniforms().setValue(n,"morphTargetInfluences",f),h.getUniforms().setValue(n,"morphTargetsTexture",y.texture,t),h.getUniforms().setValue(n,"morphTargetsTextureSize",y.size)}else{let d=f===void 0?0:f.length,m=i[u.id];if(m===void 0||m.length!==d){m=[];for(let x=0;x<d;x++)m[x]=[x,0];i[u.id]=m}for(let x=0;x<d;x++){let b=m[x];b[0]=x,b[1]=f[x]}m.sort(Uw);for(let x=0;x<8;x++)x<d&&m[x][1]?(a[x][0]=m[x][0],a[x][1]=m[x][1]):(a[x][0]=Number.MAX_SAFE_INTEGER,a[x][1]=0);a.sort(Dw);let y=u.morphAttributes.position,g=u.morphAttributes.normal,p=0;for(let x=0;x<8;x++){let b=a[x],T=b[0],A=b[1];T!==Number.MAX_SAFE_INTEGER&&A?(y&&u.getAttribute("morphTarget"+x)!==y[T]&&u.setAttribute("morphTarget"+x,y[T]),g&&u.getAttribute("morphNormal"+x)!==g[T]&&u.setAttribute("morphNormal"+x,g[T]),r[x]=A,p+=A):(y&&u.hasAttribute("morphTarget"+x)===!0&&u.deleteAttribute("morphTarget"+x),g&&u.hasAttribute("morphNormal"+x)===!0&&u.deleteAttribute("morphNormal"+x),r[x]=0)}let _=u.morphTargetsRelative?1:1-p;h.getUniforms().setValue(n,"morphTargetBaseInfluence",_),h.getUniforms().setValue(n,"morphTargetInfluences",r)}}return{update:c}}function Bw(n,e,t,i){let r=new WeakMap;function s(c){let l=i.render.frame,u=c.geometry,h=e.get(c,u);if(r.get(h)!==l&&(e.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let f=c.skeleton;r.get(f)!==l&&(f.update(),r.set(f,l))}return h}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}function bo(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=o0[r];if(s===void 0&&(s=new Float32Array(r),o0[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Bt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function zt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Mu(n,e){let t=a0[e];t===void 0&&(t=new Int32Array(e),a0[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function zw(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Vw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Bt(t,e))return;n.uniform2fv(this.addr,e),zt(t,e)}}function kw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Bt(t,e))return;n.uniform3fv(this.addr,e),zt(t,e)}}function Gw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Bt(t,e))return;n.uniform4fv(this.addr,e),zt(t,e)}}function Hw(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Bt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),zt(t,e)}else{if(Bt(t,i))return;u0.set(i),n.uniformMatrix2fv(this.addr,!1,u0),zt(t,i)}}function Ww(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Bt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),zt(t,e)}else{if(Bt(t,i))return;l0.set(i),n.uniformMatrix3fv(this.addr,!1,l0),zt(t,i)}}function Xw(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Bt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),zt(t,e)}else{if(Bt(t,i))return;c0.set(i),n.uniformMatrix4fv(this.addr,!1,c0),zt(t,i)}}function Yw(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function qw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Bt(t,e))return;n.uniform2iv(this.addr,e),zt(t,e)}}function jw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Bt(t,e))return;n.uniform3iv(this.addr,e),zt(t,e)}}function $w(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Bt(t,e))return;n.uniform4iv(this.addr,e),zt(t,e)}}function Kw(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function Zw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Bt(t,e))return;n.uniform2uiv(this.addr,e),zt(t,e)}}function Jw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Bt(t,e))return;n.uniform3uiv(this.addr,e),zt(t,e)}}function Qw(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Bt(t,e))return;n.uniform4uiv(this.addr,e),zt(t,e)}}function eT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?xx:yx;t.setTexture2D(e||s,r)}function tT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Sx,r)}function nT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||bx,r)}function iT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||_x,r)}function rT(n){switch(n){case 5126:return zw;case 35664:return Vw;case 35665:return kw;case 35666:return Gw;case 35674:return Hw;case 35675:return Ww;case 35676:return Xw;case 5124:case 35670:return Yw;case 35667:case 35671:return qw;case 35668:case 35672:return jw;case 35669:case 35673:return $w;case 5125:return Kw;case 36294:return Zw;case 36295:return Jw;case 36296:return Qw;case 35678:case 36198:case 36298:case 36306:case 35682:return eT;case 35679:case 36299:case 36307:return tT;case 35680:case 36300:case 36308:case 36293:return nT;case 36289:case 36303:case 36311:case 36292:return iT}}function sT(n,e){n.uniform1fv(this.addr,e)}function oT(n,e){let t=bo(e,this.size,2);n.uniform2fv(this.addr,t)}function aT(n,e){let t=bo(e,this.size,3);n.uniform3fv(this.addr,t)}function cT(n,e){let t=bo(e,this.size,4);n.uniform4fv(this.addr,t)}function lT(n,e){let t=bo(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function uT(n,e){let t=bo(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function hT(n,e){let t=bo(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function fT(n,e){n.uniform1iv(this.addr,e)}function dT(n,e){n.uniform2iv(this.addr,e)}function pT(n,e){n.uniform3iv(this.addr,e)}function mT(n,e){n.uniform4iv(this.addr,e)}function gT(n,e){n.uniform1uiv(this.addr,e)}function yT(n,e){n.uniform2uiv(this.addr,e)}function xT(n,e){n.uniform3uiv(this.addr,e)}function _T(n,e){n.uniform4uiv(this.addr,e)}function ST(n,e,t){let i=this.cache,r=e.length,s=Mu(t,r);Bt(i,s)||(n.uniform1iv(this.addr,s),zt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||yx,s[o])}function bT(n,e,t){let i=this.cache,r=e.length,s=Mu(t,r);Bt(i,s)||(n.uniform1iv(this.addr,s),zt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||Sx,s[o])}function MT(n,e,t){let i=this.cache,r=e.length,s=Mu(t,r);Bt(i,s)||(n.uniform1iv(this.addr,s),zt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||bx,s[o])}function vT(n,e,t){let i=this.cache,r=e.length,s=Mu(t,r);Bt(i,s)||(n.uniform1iv(this.addr,s),zt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||_x,s[o])}function AT(n){switch(n){case 5126:return sT;case 35664:return oT;case 35665:return aT;case 35666:return cT;case 35674:return lT;case 35675:return uT;case 35676:return hT;case 5124:case 35670:return fT;case 35667:case 35671:return dT;case 35668:case 35672:return pT;case 35669:case 35673:return mT;case 5125:return gT;case 36294:return yT;case 36295:return xT;case 36296:return _T;case 35678:case 36198:case 36298:case 36306:case 35682:return ST;case 35679:case 36299:case 36307:return bT;case 35680:case 36300:case 36308:case 36293:return MT;case 36289:case 36303:case 36311:case 36292:return vT}}function h0(n,e){n.seq.push(e),n.map[e.id]=e}function ET(n,e,t){let i=n.name,r=i.length;for(Zh.lastIndex=0;;){let s=Zh.exec(i),o=Zh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){h0(t,l===void 0?new rd(a,n,e):new sd(a,n,e));break}else{let h=t.map[a];h===void 0&&(h=new od(a),h0(t,h)),t=h}}}function f0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function CT(n,e){let t=n.split(`
`),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
`)}function RT(n){let e=rt.getPrimaries(rt.workingColorSpace),t=rt.getPrimaries(n),i;switch(e===t?i="":e===oa&&t===sa?i="LinearDisplayP3ToLinearSRGB":e===sa&&t===oa&&(i="LinearSRGBToLinearDisplayP3"),n){case Dt:case Ga:return[i,"LinearTransferOETF"];case lt:case bu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function d0(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
`+r+`
`+CT(n.getShaderSource(e),o)}else return r}function IT(n,e){let t=RT(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function PT(n,e){let t;switch(e){case zy:t="Linear";break;case Vy:t="Reinhard";break;case ky:t="OptimizedCineon";break;case yu:t="ACESFilmic";break;case Hy:t="AgX";break;case Gy:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function NT(n){return[n.extensionDerivatives||n.envMapCubeUVHeight||n.bumpMap||n.normalMapTangentSpace||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ys).join(`
`)}function LT(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(Ys).join(`
`)}function OT(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function DT(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),o=s.name,a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function Ys(n){return n!==""}function p0(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function m0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function ad(n){return n.replace(UT,BT)}function BT(n,e){let t=He[e];if(t===void 0){let i=FT.get(e);if(i!==void 0)t=He[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return ad(t)}function g0(n){return n.replace(zT,VT)}function VT(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function y0(n){let e="precision "+n.precision+` float;
precision `+n.precision+" int;";return n.precision==="highp"?e+=`
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function kT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===rp?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===gu?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===si&&(e="SHADOWMAP_TYPE_VSM"),e}function GT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Bi:case cr:e="ENVMAP_TYPE_CUBE";break;case _o:e="ENVMAP_TYPE_CUBE_UV";break}return e}function HT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===cr&&(e="ENVMAP_MODE_REFRACTION"),e}function WT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case za:e="ENVMAP_BLENDING_MULTIPLY";break;case Fy:e="ENVMAP_BLENDING_MIX";break;case By:e="ENVMAP_BLENDING_ADD";break}return e}function XT(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function YT(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=kT(t),l=GT(t),u=HT(t),h=WT(t),f=XT(t),d=t.isWebGL2?"":NT(t),m=LT(t),y=OT(s),g=r.createProgram(),p,_,x=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Ys).join(`
`),p.length>0&&(p+=`
`),_=[d,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Ys).join(`
`),_.length>0&&(_+=`
`)):(p=[y0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#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(Ys).join(`
`),_=[d,y0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Oi?"#define TONE_MAPPING":"",t.toneMapping!==Oi?He.tonemapping_pars_fragment:"",t.toneMapping!==Oi?PT("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",He.colorspace_pars_fragment,IT("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Ys).join(`
`)),o=ad(o),o=p0(o,t),o=m0(o,t),a=ad(a),a=p0(a,t),a=m0(a,t),o=g0(o),a=g0(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es
`,p=[m,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+p,_=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===Yf?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Yf?"":"#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 b=x+p+o,T=x+_+a,A=f0(r,r.VERTEX_SHADER,b),M=f0(r,r.FRAGMENT_SHADER,T);r.attachShader(g,A),r.attachShader(g,M),t.index0AttributeName!==void 0?r.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(g,0,"position"),r.linkProgram(g);function C(U){if(n.debug.checkShaderErrors){let G=r.getProgramInfoLog(g).trim(),P=r.getShaderInfoLog(A).trim(),D=r.getShaderInfoLog(M).trim(),z=!0,q=!0;if(r.getProgramParameter(g,r.LINK_STATUS)===!1)if(z=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,g,A,M);else{let Y=d0(r,A,"vertex"),W=d0(r,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(g,r.VALIDATE_STATUS)+`
Program Info Log: `+G+`
`+Y+`
`+W)}else G!==""?console.warn("THREE.WebGLProgram: Program Info Log:",G):(P===""||D==="")&&(q=!1);q&&(U.diagnostics={runnable:z,programLog:G,vertexShader:{log:P,prefix:p},fragmentShader:{log:D,prefix:_}})}r.deleteShader(A),r.deleteShader(M),S=new $s(r,g),v=DT(r,g)}let S;this.getUniforms=function(){return S===void 0&&C(this),S};let v;this.getAttributes=function(){return v===void 0&&C(this),v};let L=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return L===!1&&(L=r.getProgramParameter(g,wT)),L},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=TT++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=A,this.fragmentShader=M,this}function jT(n,e,t,i,r,s,o){let a=new to,c=new cd,l=[],u=r.isWebGL2,h=r.logarithmicDepthBuffer,f=r.vertexTextures,d=r.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 y(S){return S===0?"uv":`uv${S}`}function g(S,v,L,U,G){let P=U.fog,D=G.geometry,z=S.isMeshStandardMaterial?U.environment:null,q=(S.isMeshStandardMaterial?t:e).get(S.envMap||z),Y=q&&q.mapping===_o?q.image.height:null,W=m[S.type];S.precision!==null&&(d=r.getMaxPrecision(S.precision),d!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",d,"instead."));let j=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,J=j!==void 0?j.length:0,le=0;D.morphAttributes.position!==void 0&&(le=1),D.morphAttributes.normal!==void 0&&(le=2),D.morphAttributes.color!==void 0&&(le=3);let X,Q,ue,xe;if(W){let an=rn[W];X=an.vertexShader,Q=an.fragmentShader}else X=S.vertexShader,Q=S.fragmentShader,c.update(S),ue=c.getVertexShaderID(S),xe=c.getFragmentShaderID(S);let he=n.getRenderTarget(),Ce=G.isInstancedMesh===!0,De=G.isBatchedMesh===!0,Me=!!S.map,Ue=!!S.matcap,N=!!q,ae=!!S.aoMap,K=!!S.lightMap,re=!!S.bumpMap,$=!!S.normalMap,Ee=!!S.displacementMap,me=!!S.emissiveMap,R=!!S.metalnessMap,E=!!S.roughnessMap,B=S.anisotropy>0,ie=S.clearcoat>0,te=S.iridescence>0,ee=S.sheen>0,ve=S.transmission>0,fe=B&&!!S.anisotropyMap,_e=ie&&!!S.clearcoatMap,Re=ie&&!!S.clearcoatNormalMap,ke=ie&&!!S.clearcoatRoughnessMap,ne=te&&!!S.iridescenceMap,st=te&&!!S.iridescenceThicknessMap,Ke=ee&&!!S.sheenColorMap,Fe=ee&&!!S.sheenRoughnessMap,Te=!!S.specularMap,be=!!S.specularColorMap,Xe=!!S.specularIntensityMap,ct=ve&&!!S.transmissionMap,Et=ve&&!!S.thicknessMap,je=!!S.gradientMap,ce=!!S.alphaMap,O=S.alphaTest>0,de=!!S.alphaHash,pe=!!S.extensions,Ne=!!D.attributes.uv1,Ie=!!D.attributes.uv2,dt=!!D.attributes.uv3,pt=Oi;return S.toneMapped&&(he===null||he.isXRRenderTarget===!0)&&(pt=n.toneMapping),{isWebGL2:u,shaderID:W,shaderType:S.type,shaderName:S.name,vertexShader:X,fragmentShader:Q,defines:S.defines,customVertexShaderID:ue,customFragmentShaderID:xe,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:d,batching:De,instancing:Ce,instancingColor:Ce&&G.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:he===null?n.outputColorSpace:he.isXRRenderTarget===!0?he.texture.colorSpace:Dt,map:Me,matcap:Ue,envMap:N,envMapMode:N&&q.mapping,envMapCubeUVHeight:Y,aoMap:ae,lightMap:K,bumpMap:re,normalMap:$,displacementMap:f&&Ee,emissiveMap:me,normalMapObjectSpace:$&&S.normalMapType===rx,normalMapTangentSpace:$&&S.normalMapType===yr,metalnessMap:R,roughnessMap:E,anisotropy:B,anisotropyMap:fe,clearcoat:ie,clearcoatMap:_e,clearcoatNormalMap:Re,clearcoatRoughnessMap:ke,iridescence:te,iridescenceMap:ne,iridescenceThicknessMap:st,sheen:ee,sheenColorMap:Ke,sheenRoughnessMap:Fe,specularMap:Te,specularColorMap:be,specularIntensityMap:Xe,transmission:ve,transmissionMap:ct,thicknessMap:Et,gradientMap:je,opaque:S.transparent===!1&&S.blending===Yr,alphaMap:ce,alphaTest:O,alphaHash:de,combine:S.combine,mapUv:Me&&y(S.map.channel),aoMapUv:ae&&y(S.aoMap.channel),lightMapUv:K&&y(S.lightMap.channel),bumpMapUv:re&&y(S.bumpMap.channel),normalMapUv:$&&y(S.normalMap.channel),displacementMapUv:Ee&&y(S.displacementMap.channel),emissiveMapUv:me&&y(S.emissiveMap.channel),metalnessMapUv:R&&y(S.metalnessMap.channel),roughnessMapUv:E&&y(S.roughnessMap.channel),anisotropyMapUv:fe&&y(S.anisotropyMap.channel),clearcoatMapUv:_e&&y(S.clearcoatMap.channel),clearcoatNormalMapUv:Re&&y(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&y(S.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&y(S.iridescenceMap.channel),iridescenceThicknessMapUv:st&&y(S.iridescenceThicknessMap.channel),sheenColorMapUv:Ke&&y(S.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(S.sheenRoughnessMap.channel),specularMapUv:Te&&y(S.specularMap.channel),specularColorMapUv:be&&y(S.specularColorMap.channel),specularIntensityMapUv:Xe&&y(S.specularIntensityMap.channel),transmissionMapUv:ct&&y(S.transmissionMap.channel),thicknessMapUv:Et&&y(S.thicknessMap.channel),alphaMapUv:ce&&y(S.alphaMap.channel),vertexTangents:!!D.attributes.tangent&&($||B),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,vertexUv1s:Ne,vertexUv2s:Ie,vertexUv3s:dt,pointsUvs:G.isPoints===!0&&!!D.attributes.uv&&(Me||ce),fog:!!P,useFog:S.fog===!0,fogExp2:P&&P.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:G.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:J,morphTextureStride:le,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:n.shadowMap.enabled&&L.length>0,shadowMapType:n.shadowMap.type,toneMapping:pt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:Me&&S.map.isVideoTexture===!0&&rt.getTransfer(S.map.colorSpace)===gt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===On,flipSided:S.side===hn,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:pe&&S.extensions.derivatives===!0,extensionFragDepth:pe&&S.extensions.fragDepth===!0,extensionDrawBuffers:pe&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:pe&&S.extensions.shaderTextureLOD===!0,extensionClipCullDistance:pe&&S.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()}}function p(S){let v=[];if(S.shaderID?v.push(S.shaderID):(v.push(S.customVertexShaderID),v.push(S.customFragmentShaderID)),S.defines!==void 0)for(let L in S.defines)v.push(L),v.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(_(v,S),x(v,S),v.push(n.outputColorSpace)),v.push(S.customProgramCacheKey),v.join()}function _(S,v){S.push(v.precision),S.push(v.outputColorSpace),S.push(v.envMapMode),S.push(v.envMapCubeUVHeight),S.push(v.mapUv),S.push(v.alphaMapUv),S.push(v.lightMapUv),S.push(v.aoMapUv),S.push(v.bumpMapUv),S.push(v.normalMapUv),S.push(v.displacementMapUv),S.push(v.emissiveMapUv),S.push(v.metalnessMapUv),S.push(v.roughnessMapUv),S.push(v.anisotropyMapUv),S.push(v.clearcoatMapUv),S.push(v.clearcoatNormalMapUv),S.push(v.clearcoatRoughnessMapUv),S.push(v.iridescenceMapUv),S.push(v.iridescenceThicknessMapUv),S.push(v.sheenColorMapUv),S.push(v.sheenRoughnessMapUv),S.push(v.specularMapUv),S.push(v.specularColorMapUv),S.push(v.specularIntensityMapUv),S.push(v.transmissionMapUv),S.push(v.thicknessMapUv),S.push(v.combine),S.push(v.fogExp2),S.push(v.sizeAttenuation),S.push(v.morphTargetsCount),S.push(v.morphAttributeCount),S.push(v.numDirLights),S.push(v.numPointLights),S.push(v.numSpotLights),S.push(v.numSpotLightMaps),S.push(v.numHemiLights),S.push(v.numRectAreaLights),S.push(v.numDirLightShadows),S.push(v.numPointLightShadows),S.push(v.numSpotLightShadows),S.push(v.numSpotLightShadowsWithMaps),S.push(v.numLightProbes),S.push(v.shadowMapType),S.push(v.toneMapping),S.push(v.numClippingPlanes),S.push(v.numClipIntersection),S.push(v.depthPacking)}function x(S,v){a.disableAll(),v.isWebGL2&&a.enable(0),v.supportsVertexTextures&&a.enable(1),v.instancing&&a.enable(2),v.instancingColor&&a.enable(3),v.matcap&&a.enable(4),v.envMap&&a.enable(5),v.normalMapObjectSpace&&a.enable(6),v.normalMapTangentSpace&&a.enable(7),v.clearcoat&&a.enable(8),v.iridescence&&a.enable(9),v.alphaTest&&a.enable(10),v.vertexColors&&a.enable(11),v.vertexAlphas&&a.enable(12),v.vertexUv1s&&a.enable(13),v.vertexUv2s&&a.enable(14),v.vertexUv3s&&a.enable(15),v.vertexTangents&&a.enable(16),v.anisotropy&&a.enable(17),v.alphaHash&&a.enable(18),v.batching&&a.enable(19),S.push(a.mask),a.disableAll(),v.fog&&a.enable(0),v.useFog&&a.enable(1),v.flatShading&&a.enable(2),v.logarithmicDepthBuffer&&a.enable(3),v.skinning&&a.enable(4),v.morphTargets&&a.enable(5),v.morphNormals&&a.enable(6),v.morphColors&&a.enable(7),v.premultipliedAlpha&&a.enable(8),v.shadowMapEnabled&&a.enable(9),v.useLegacyLights&&a.enable(10),v.doubleSided&&a.enable(11),v.flipSided&&a.enable(12),v.useDepthPacking&&a.enable(13),v.dithering&&a.enable(14),v.transmission&&a.enable(15),v.sheen&&a.enable(16),v.opaque&&a.enable(17),v.pointsUvs&&a.enable(18),v.decodeVideoTexture&&a.enable(19),S.push(a.mask)}function b(S){let v=m[S.type],L;if(v){let U=rn[v];L=Wa.clone(U.uniforms)}else L=S.uniforms;return L}function T(S,v){let L;for(let U=0,G=l.length;U<G;U++){let P=l[U];if(P.cacheKey===v){L=P,++L.usedTimes;break}}return L===void 0&&(L=new YT(n,v,S,s),l.push(L)),L}function A(S){if(--S.usedTimes===0){let v=l.indexOf(S);l[v]=l[l.length-1],l.pop(),S.destroy()}}function M(S){c.remove(S)}function C(){c.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:b,acquireProgram:T,releaseProgram:A,releaseShaderCache:M,programs:l,dispose:C}}function $T(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function KT(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function x0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function _0(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(h,f,d,m,y,g){let p=n[e];return p===void 0?(p={id:h.id,object:h,geometry:f,material:d,groupOrder:m,renderOrder:h.renderOrder,z:y,group:g},n[e]=p):(p.id=h.id,p.object=h,p.geometry=f,p.material=d,p.groupOrder=m,p.renderOrder=h.renderOrder,p.z=y,p.group=g),e++,p}function a(h,f,d,m,y,g){let p=o(h,f,d,m,y,g);d.transmission>0?i.push(p):d.transparent===!0?r.push(p):t.push(p)}function c(h,f,d,m,y,g){let p=o(h,f,d,m,y,g);d.transmission>0?i.unshift(p):d.transparent===!0?r.unshift(p):t.unshift(p)}function l(h,f){t.length>1&&t.sort(h||KT),i.length>1&&i.sort(f||x0),r.length>1&&r.sort(f||x0)}function u(){for(let h=e,f=n.length;h<f;h++){let d=n[h];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function ZT(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new _0,n.set(i,[o])):r>=s.length?(o=new _0,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function JT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new w,color:new oe};break;case"SpotLight":t={position:new w,direction:new w,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new w,halfWidth:new w,halfHeight:new w};break}return n[e.id]=t,t}}}function QT(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function t1(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function n1(n,e){let t=new JT,i=QT(),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 u=0;u<9;u++)r.probe.push(new w);let s=new w,o=new we,a=new we;function c(u,h){let f=0,d=0,m=0;for(let U=0;U<9;U++)r.probe[U].set(0,0,0);let y=0,g=0,p=0,_=0,x=0,b=0,T=0,A=0,M=0,C=0,S=0;u.sort(t1);let v=h===!0?Math.PI:1;for(let U=0,G=u.length;U<G;U++){let P=u[U],D=P.color,z=P.intensity,q=P.distance,Y=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)f+=D.r*z*v,d+=D.g*z*v,m+=D.b*z*v;else if(P.isLightProbe){for(let W=0;W<9;W++)r.probe[W].addScaledVector(P.sh.coefficients[W],z);S++}else if(P.isDirectionalLight){let W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity*v),P.castShadow){let j=P.shadow,J=i.get(P);J.shadowBias=j.bias,J.shadowNormalBias=j.normalBias,J.shadowRadius=j.radius,J.shadowMapSize=j.mapSize,r.directionalShadow[y]=J,r.directionalShadowMap[y]=Y,r.directionalShadowMatrix[y]=P.shadow.matrix,b++}r.directional[y]=W,y++}else if(P.isSpotLight){let W=t.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(D).multiplyScalar(z*v),W.distance=q,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,r.spot[p]=W;let j=P.shadow;if(P.map&&(r.spotLightMap[M]=P.map,M++,j.updateMatrices(P),P.castShadow&&C++),r.spotLightMatrix[p]=j.matrix,P.castShadow){let J=i.get(P);J.shadowBias=j.bias,J.shadowNormalBias=j.normalBias,J.shadowRadius=j.radius,J.shadowMapSize=j.mapSize,r.spotShadow[p]=J,r.spotShadowMap[p]=Y,A++}p++}else if(P.isRectAreaLight){let W=t.get(P);W.color.copy(D).multiplyScalar(z),W.halfWidth.set(P.width*.5,0,0),W.halfHeight.set(0,P.height*.5,0),r.rectArea[_]=W,_++}else if(P.isPointLight){let W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity*v),W.distance=P.distance,W.decay=P.decay,P.castShadow){let j=P.shadow,J=i.get(P);J.shadowBias=j.bias,J.shadowNormalBias=j.normalBias,J.shadowRadius=j.radius,J.shadowMapSize=j.mapSize,J.shadowCameraNear=j.camera.near,J.shadowCameraFar=j.camera.far,r.pointShadow[g]=J,r.pointShadowMap[g]=Y,r.pointShadowMatrix[g]=P.shadow.matrix,T++}r.point[g]=W,g++}else if(P.isHemisphereLight){let W=t.get(P);W.skyColor.copy(P.color).multiplyScalar(z*v),W.groundColor.copy(P.groundColor).multiplyScalar(z*v),r.hemi[x]=W,x++}}_>0&&(e.isWebGL2?n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=se.LTC_FLOAT_1,r.rectAreaLTC2=se.LTC_FLOAT_2):(r.rectAreaLTC1=se.LTC_HALF_1,r.rectAreaLTC2=se.LTC_HALF_2):n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=se.LTC_FLOAT_1,r.rectAreaLTC2=se.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=se.LTC_HALF_1,r.rectAreaLTC2=se.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=f,r.ambient[1]=d,r.ambient[2]=m;let L=r.hash;(L.directionalLength!==y||L.pointLength!==g||L.spotLength!==p||L.rectAreaLength!==_||L.hemiLength!==x||L.numDirectionalShadows!==b||L.numPointShadows!==T||L.numSpotShadows!==A||L.numSpotMaps!==M||L.numLightProbes!==S)&&(r.directional.length=y,r.spot.length=p,r.rectArea.length=_,r.point.length=g,r.hemi.length=x,r.directionalShadow.length=b,r.directionalShadowMap.length=b,r.pointShadow.length=T,r.pointShadowMap.length=T,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=b,r.pointShadowMatrix.length=T,r.spotLightMatrix.length=A+M-C,r.spotLightMap.length=M,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=S,L.directionalLength=y,L.pointLength=g,L.spotLength=p,L.rectAreaLength=_,L.hemiLength=x,L.numDirectionalShadows=b,L.numPointShadows=T,L.numSpotShadows=A,L.numSpotMaps=M,L.numLightProbes=S,r.version=e1++)}function l(u,h){let f=0,d=0,m=0,y=0,g=0,p=h.matrixWorldInverse;for(let _=0,x=u.length;_<x;_++){let b=u[_];if(b.isDirectionalLight){let T=r.directional[f];T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(p),f++}else if(b.isSpotLight){let T=r.spot[m];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(p),T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(p),m++}else if(b.isRectAreaLight){let T=r.rectArea[y];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(p),a.identity(),o.copy(b.matrixWorld),o.premultiply(p),a.extractRotation(o),T.halfWidth.set(b.width*.5,0,0),T.halfHeight.set(0,b.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){let T=r.point[d];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(p),d++}else if(b.isHemisphereLight){let T=r.hemi[g];T.direction.setFromMatrixPosition(b.matrixWorld),T.direction.transformDirection(p),g++}}}return{setup:c,setupView:l,state:r}}function S0(n,e){let t=new n1(n,e),i=[],r=[];function s(){i.length=0,r.length=0}function o(h){i.push(h)}function a(h){r.push(h)}function c(h){t.setup(i,h)}function l(h){t.setupView(i,h)}return{init:s,state:{lightsArray:i,shadowsArray:r,lights:t},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function i1(n,e){let t=new WeakMap;function i(s,o=0){let a=t.get(s),c;return a===void 0?(c=new S0(n,e),t.set(s,[c])):o>=a.length?(c=new S0(n,e),a.push(c)):c=a[o],c}function r(){t=new WeakMap}return{get:i,dispose:r}}function o1(n,e,t){let i=new ts,r=new Z,s=new Z,o=new tt,a=new ga({depthPacking:ix}),c=new ya,l={},u=t.maxTextureSize,h={[qn]:hn,[hn]:qn,[On]:On},f=new yn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Z},radius:{value:4}},vertexShader:r1,fragmentShader:s1}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let m=new Be;m.setAttribute("position",new Ze(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new ft(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rp;let p=this.type;this.render=function(A,M,C){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||A.length===0)return;let S=n.getRenderTarget(),v=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),U=n.state;U.setBlending(Li),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let G=p!==si&&this.type===si,P=p===si&&this.type!==si;for(let D=0,z=A.length;D<z;D++){let q=A[D],Y=q.shadow;if(Y===void 0){console.warn("THREE.WebGLShadowMap:",q,"has no shadow.");continue}if(Y.autoUpdate===!1&&Y.needsUpdate===!1)continue;r.copy(Y.mapSize);let W=Y.getFrameExtents();if(r.multiply(W),s.copy(Y.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/W.x),r.x=s.x*W.x,Y.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/W.y),r.y=s.y*W.y,Y.mapSize.y=s.y)),Y.map===null||G===!0||P===!0){let J=this.type!==si?{minFilter:Mt,magFilter:Mt}:{};Y.map!==null&&Y.map.dispose(),Y.map=new Tn(r.x,r.y,J),Y.map.texture.name=q.name+".shadowMap",Y.camera.updateProjectionMatrix()}n.setRenderTarget(Y.map),n.clear();let j=Y.getViewportCount();for(let J=0;J<j;J++){let le=Y.getViewport(J);o.set(s.x*le.x,s.y*le.y,s.x*le.z,s.y*le.w),U.viewport(o),Y.updateMatrices(q,J),i=Y.getFrustum(),b(M,C,Y.camera,q,this.type)}Y.isPointLightShadow!==!0&&this.type===si&&_(Y,C),Y.needsUpdate=!1}p=this.type,g.needsUpdate=!1,n.setRenderTarget(S,v,L)};function _(A,M){let C=e.update(y);f.defines.VSM_SAMPLES!==A.blurSamples&&(f.defines.VSM_SAMPLES=A.blurSamples,d.defines.VSM_SAMPLES=A.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Tn(r.x,r.y)),f.uniforms.shadow_pass.value=A.map.texture,f.uniforms.resolution.value=A.mapSize,f.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(M,null,C,f,y,null),d.uniforms.shadow_pass.value=A.mapPass.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(M,null,C,d,y,null)}function x(A,M,C,S){let v=null,L=C.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(L!==void 0)v=L;else if(v=C.isPointLight===!0?c:a,n.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0){let U=v.uuid,G=M.uuid,P=l[U];P===void 0&&(P={},l[U]=P);let D=P[G];D===void 0&&(D=v.clone(),P[G]=D,M.addEventListener("dispose",T)),v=D}if(v.visible=M.visible,v.wireframe=M.wireframe,S===si?v.side=M.shadowSide!==null?M.shadowSide:M.side:v.side=M.shadowSide!==null?M.shadowSide:h[M.side],v.alphaMap=M.alphaMap,v.alphaTest=M.alphaTest,v.map=M.map,v.clipShadows=M.clipShadows,v.clippingPlanes=M.clippingPlanes,v.clipIntersection=M.clipIntersection,v.displacementMap=M.displacementMap,v.displacementScale=M.displacementScale,v.displacementBias=M.displacementBias,v.wireframeLinewidth=M.wireframeLinewidth,v.linewidth=M.linewidth,C.isPointLight===!0&&v.isMeshDistanceMaterial===!0){let U=n.properties.get(v);U.light=C}return v}function b(A,M,C,S,v){if(A.visible===!1)return;if(A.layers.test(M.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&v===si)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,A.matrixWorld);let G=e.update(A),P=A.material;if(Array.isArray(P)){let D=G.groups;for(let z=0,q=D.length;z<q;z++){let Y=D[z],W=P[Y.materialIndex];if(W&&W.visible){let j=x(A,W,S,v);A.onBeforeShadow(n,A,M,C,G,j,Y),n.renderBufferDirect(C,null,G,j,A,Y),A.onAfterShadow(n,A,M,C,G,j,Y)}}}else if(P.visible){let D=x(A,P,S,v);A.onBeforeShadow(n,A,M,C,G,D,null),n.renderBufferDirect(C,null,G,D,A,null),A.onAfterShadow(n,A,M,C,G,D,null)}}let U=A.children;for(let G=0,P=U.length;G<P;G++)b(U[G],M,C,S,v)}function T(A){A.target.removeEventListener("dispose",T);for(let C in l){let S=l[C],v=A.target.uuid;v in S&&(S[v].dispose(),delete S[v])}}}function a1(n,e,t){let i=t.isWebGL2;function r(){let O=!1,de=new tt,pe=null,Ne=new tt(0,0,0,0);return{setMask:function(Ie){pe!==Ie&&!O&&(n.colorMask(Ie,Ie,Ie,Ie),pe=Ie)},setLocked:function(Ie){O=Ie},setClear:function(Ie,dt,pt,Gt,an){an===!0&&(Ie*=Gt,dt*=Gt,pt*=Gt),de.set(Ie,dt,pt,Gt),Ne.equals(de)===!1&&(n.clearColor(Ie,dt,pt,Gt),Ne.copy(de))},reset:function(){O=!1,pe=null,Ne.set(-1,0,0,0)}}}function s(){let O=!1,de=null,pe=null,Ne=null;return{setTest:function(Ie){Ie?De(n.DEPTH_TEST):Me(n.DEPTH_TEST)},setMask:function(Ie){de!==Ie&&!O&&(n.depthMask(Ie),de=Ie)},setFunc:function(Ie){if(pe!==Ie){switch(Ie){case Iy:n.depthFunc(n.NEVER);break;case Py:n.depthFunc(n.ALWAYS);break;case Ny:n.depthFunc(n.LESS);break;case ta:n.depthFunc(n.LEQUAL);break;case Ly:n.depthFunc(n.EQUAL);break;case Oy:n.depthFunc(n.GEQUAL);break;case Dy:n.depthFunc(n.GREATER);break;case Uy:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}pe=Ie}},setLocked:function(Ie){O=Ie},setClear:function(Ie){Ne!==Ie&&(n.clearDepth(Ie),Ne=Ie)},reset:function(){O=!1,de=null,pe=null,Ne=null}}}function o(){let O=!1,de=null,pe=null,Ne=null,Ie=null,dt=null,pt=null,Gt=null,an=null;return{setTest:function(mt){O||(mt?De(n.STENCIL_TEST):Me(n.STENCIL_TEST))},setMask:function(mt){de!==mt&&!O&&(n.stencilMask(mt),de=mt)},setFunc:function(mt,cn,ri){(pe!==mt||Ne!==cn||Ie!==ri)&&(n.stencilFunc(mt,cn,ri),pe=mt,Ne=cn,Ie=ri)},setOp:function(mt,cn,ri){(dt!==mt||pt!==cn||Gt!==ri)&&(n.stencilOp(mt,cn,ri),dt=mt,pt=cn,Gt=ri)},setLocked:function(mt){O=mt},setClear:function(mt){an!==mt&&(n.clearStencil(mt),an=mt)},reset:function(){O=!1,de=null,pe=null,Ne=null,Ie=null,dt=null,pt=null,Gt=null,an=null}}}let a=new r,c=new s,l=new o,u=new WeakMap,h=new WeakMap,f={},d={},m=new WeakMap,y=[],g=null,p=!1,_=null,x=null,b=null,T=null,A=null,M=null,C=null,S=new oe(0,0,0),v=0,L=!1,U=null,G=null,P=null,D=null,z=null,q=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),Y=!1,W=0,j=n.getParameter(n.VERSION);j.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(j)[1]),Y=W>=1):j.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),Y=W>=2);let J=null,le={},X=n.getParameter(n.SCISSOR_BOX),Q=n.getParameter(n.VIEWPORT),ue=new tt().fromArray(X),xe=new tt().fromArray(Q);function he(O,de,pe,Ne){let Ie=new Uint8Array(4),dt=n.createTexture();n.bindTexture(O,dt),n.texParameteri(O,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(O,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let pt=0;pt<pe;pt++)i&&(O===n.TEXTURE_3D||O===n.TEXTURE_2D_ARRAY)?n.texImage3D(de,0,n.RGBA,1,1,Ne,0,n.RGBA,n.UNSIGNED_BYTE,Ie):n.texImage2D(de+pt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ie);return dt}let Ce={};Ce[n.TEXTURE_2D]=he(n.TEXTURE_2D,n.TEXTURE_2D,1),Ce[n.TEXTURE_CUBE_MAP]=he(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(Ce[n.TEXTURE_2D_ARRAY]=he(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Ce[n.TEXTURE_3D]=he(n.TEXTURE_3D,n.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),De(n.DEPTH_TEST),c.setFunc(ta),me(!1),R(df),De(n.CULL_FACE),$(Li);function De(O){f[O]!==!0&&(n.enable(O),f[O]=!0)}function Me(O){f[O]!==!1&&(n.disable(O),f[O]=!1)}function Ue(O,de){return d[O]!==de?(n.bindFramebuffer(O,de),d[O]=de,i&&(O===n.DRAW_FRAMEBUFFER&&(d[n.FRAMEBUFFER]=de),O===n.FRAMEBUFFER&&(d[n.DRAW_FRAMEBUFFER]=de)),!0):!1}function N(O,de){let pe=y,Ne=!1;if(O)if(pe=m.get(de),pe===void 0&&(pe=[],m.set(de,pe)),O.isWebGLMultipleRenderTargets){let Ie=O.texture;if(pe.length!==Ie.length||pe[0]!==n.COLOR_ATTACHMENT0){for(let dt=0,pt=Ie.length;dt<pt;dt++)pe[dt]=n.COLOR_ATTACHMENT0+dt;pe.length=Ie.length,Ne=!0}}else pe[0]!==n.COLOR_ATTACHMENT0&&(pe[0]=n.COLOR_ATTACHMENT0,Ne=!0);else pe[0]!==n.BACK&&(pe[0]=n.BACK,Ne=!0);Ne&&(t.isWebGL2?n.drawBuffers(pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function ae(O){return g!==O?(n.useProgram(O),g=O,!0):!1}let K={[rr]:n.FUNC_ADD,[my]:n.FUNC_SUBTRACT,[gy]:n.FUNC_REVERSE_SUBTRACT};if(i)K[yf]=n.MIN,K[xf]=n.MAX;else{let O=e.get("EXT_blend_minmax");O!==null&&(K[yf]=O.MIN_EXT,K[xf]=O.MAX_EXT)}let re={[yy]:n.ZERO,[xy]:n.ONE,[_y]:n.SRC_COLOR,[yl]:n.SRC_ALPHA,[Ey]:n.SRC_ALPHA_SATURATE,[vy]:n.DST_COLOR,[by]:n.DST_ALPHA,[Sy]:n.ONE_MINUS_SRC_COLOR,[xl]:n.ONE_MINUS_SRC_ALPHA,[Ay]:n.ONE_MINUS_DST_COLOR,[My]:n.ONE_MINUS_DST_ALPHA,[wy]:n.CONSTANT_COLOR,[Ty]:n.ONE_MINUS_CONSTANT_COLOR,[Cy]:n.CONSTANT_ALPHA,[Ry]:n.ONE_MINUS_CONSTANT_ALPHA};function $(O,de,pe,Ne,Ie,dt,pt,Gt,an,mt){if(O===Li){p===!0&&(Me(n.BLEND),p=!1);return}if(p===!1&&(De(n.BLEND),p=!0),O!==py){if(O!==_||mt!==L){if((x!==rr||A!==rr)&&(n.blendEquation(n.FUNC_ADD),x=rr,A=rr),mt)switch(O){case Yr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.ONE,n.ONE);break;case mf:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case gf:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Yr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case mf:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case gf:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}b=null,T=null,M=null,C=null,S.set(0,0,0),v=0,_=O,L=mt}return}Ie=Ie||de,dt=dt||pe,pt=pt||Ne,(de!==x||Ie!==A)&&(n.blendEquationSeparate(K[de],K[Ie]),x=de,A=Ie),(pe!==b||Ne!==T||dt!==M||pt!==C)&&(n.blendFuncSeparate(re[pe],re[Ne],re[dt],re[pt]),b=pe,T=Ne,M=dt,C=pt),(Gt.equals(S)===!1||an!==v)&&(n.blendColor(Gt.r,Gt.g,Gt.b,an),S.copy(Gt),v=an),_=O,L=!1}function Ee(O,de){O.side===On?Me(n.CULL_FACE):De(n.CULL_FACE);let pe=O.side===hn;de&&(pe=!pe),me(pe),O.blending===Yr&&O.transparent===!1?$(Li):$(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),c.setFunc(O.depthFunc),c.setTest(O.depthTest),c.setMask(O.depthWrite),a.setMask(O.colorWrite);let Ne=O.stencilWrite;l.setTest(Ne),Ne&&(l.setMask(O.stencilWriteMask),l.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),l.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),B(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?De(n.SAMPLE_ALPHA_TO_COVERAGE):Me(n.SAMPLE_ALPHA_TO_COVERAGE)}function me(O){U!==O&&(O?n.frontFace(n.CW):n.frontFace(n.CCW),U=O)}function R(O){O!==fy?(De(n.CULL_FACE),O!==G&&(O===df?n.cullFace(n.BACK):O===dy?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Me(n.CULL_FACE),G=O}function E(O){O!==P&&(Y&&n.lineWidth(O),P=O)}function B(O,de,pe){O?(De(n.POLYGON_OFFSET_FILL),(D!==de||z!==pe)&&(n.polygonOffset(de,pe),D=de,z=pe)):Me(n.POLYGON_OFFSET_FILL)}function ie(O){O?De(n.SCISSOR_TEST):Me(n.SCISSOR_TEST)}function te(O){O===void 0&&(O=n.TEXTURE0+q-1),J!==O&&(n.activeTexture(O),J=O)}function ee(O,de,pe){pe===void 0&&(J===null?pe=n.TEXTURE0+q-1:pe=J);let Ne=le[pe];Ne===void 0&&(Ne={type:void 0,texture:void 0},le[pe]=Ne),(Ne.type!==O||Ne.texture!==de)&&(J!==pe&&(n.activeTexture(pe),J=pe),n.bindTexture(O,de||Ce[O]),Ne.type=O,Ne.texture=de)}function ve(){let O=le[J];O!==void 0&&O.type!==void 0&&(n.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function fe(){try{n.compressedTexImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function _e(){try{n.compressedTexImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Re(){try{n.texSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{n.texSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ne(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function st(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ke(){try{n.texStorage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Fe(){try{n.texStorage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Te(){try{n.texImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function be(){try{n.texImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Xe(O){ue.equals(O)===!1&&(n.scissor(O.x,O.y,O.z,O.w),ue.copy(O))}function ct(O){xe.equals(O)===!1&&(n.viewport(O.x,O.y,O.z,O.w),xe.copy(O))}function Et(O,de){let pe=h.get(de);pe===void 0&&(pe=new WeakMap,h.set(de,pe));let Ne=pe.get(O);Ne===void 0&&(Ne=n.getUniformBlockIndex(de,O.name),pe.set(O,Ne))}function je(O,de){let Ne=h.get(de).get(O);u.get(de)!==Ne&&(n.uniformBlockBinding(de,Ne,O.__bindingPointIndex),u.set(de,Ne))}function ce(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),i===!0&&(n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},J=null,le={},d={},m=new WeakMap,y=[],g=null,p=!1,_=null,x=null,b=null,T=null,A=null,M=null,C=null,S=new oe(0,0,0),v=0,L=!1,U=null,G=null,P=null,D=null,z=null,ue.set(0,0,n.canvas.width,n.canvas.height),xe.set(0,0,n.canvas.width,n.canvas.height),a.reset(),c.reset(),l.reset()}return{buffers:{color:a,depth:c,stencil:l},enable:De,disable:Me,bindFramebuffer:Ue,drawBuffers:N,useProgram:ae,setBlending:$,setMaterial:Ee,setFlipSided:me,setCullFace:R,setLineWidth:E,setPolygonOffset:B,setScissorTest:ie,activeTexture:te,bindTexture:ee,unbindTexture:ve,compressedTexImage2D:fe,compressedTexImage3D:_e,texImage2D:Te,texImage3D:be,updateUBOMapping:Et,uniformBlockBinding:je,texStorage2D:Ke,texStorage3D:Fe,texSubImage2D:Re,texSubImage3D:ke,compressedTexSubImage2D:ne,compressedTexSubImage3D:st,scissor:Xe,viewport:ct,reset:ce}}function c1(n,e,t,i,r,s,o){let a=r.isWebGL2,c=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new WeakMap,h,f=new WeakMap,d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,E){return d?new OffscreenCanvas(R,E):ca("canvas")}function y(R,E,B,ie){let te=1;if((R.width>ie||R.height>ie)&&(te=ie/Math.max(R.width,R.height)),te<1||E===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let ee=E?Sl:Math.floor,ve=ee(te*R.width),fe=ee(te*R.height);h===void 0&&(h=m(ve,fe));let _e=B?m(ve,fe):h;return _e.width=ve,_e.height=fe,_e.getContext("2d").drawImage(R,0,0,ve,fe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ve+"x"+fe+")."),_e}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function g(R){return qf(R.width)&&qf(R.height)}function p(R){return a?!1:R.wrapS!==Xt||R.wrapT!==Xt||R.minFilter!==Mt&&R.minFilter!==yt}function _(R,E){return R.generateMipmaps&&E&&R.minFilter!==Mt&&R.minFilter!==yt}function x(R){n.generateMipmap(R)}function b(R,E,B,ie,te=!1){if(a===!1)return E;if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let ee=E;if(E===n.RED&&(B===n.FLOAT&&(ee=n.R32F),B===n.HALF_FLOAT&&(ee=n.R16F),B===n.UNSIGNED_BYTE&&(ee=n.R8)),E===n.RED_INTEGER&&(B===n.UNSIGNED_BYTE&&(ee=n.R8UI),B===n.UNSIGNED_SHORT&&(ee=n.R16UI),B===n.UNSIGNED_INT&&(ee=n.R32UI),B===n.BYTE&&(ee=n.R8I),B===n.SHORT&&(ee=n.R16I),B===n.INT&&(ee=n.R32I)),E===n.RG&&(B===n.FLOAT&&(ee=n.RG32F),B===n.HALF_FLOAT&&(ee=n.RG16F),B===n.UNSIGNED_BYTE&&(ee=n.RG8)),E===n.RGBA){let ve=te?ra:rt.getTransfer(ie);B===n.FLOAT&&(ee=n.RGBA32F),B===n.HALF_FLOAT&&(ee=n.RGBA16F),B===n.UNSIGNED_BYTE&&(ee=ve===gt?n.SRGB8_ALPHA8:n.RGBA8),B===n.UNSIGNED_SHORT_4_4_4_4&&(ee=n.RGBA4),B===n.UNSIGNED_SHORT_5_5_5_1&&(ee=n.RGB5_A1)}return(ee===n.R16F||ee===n.R32F||ee===n.RG16F||ee===n.RG32F||ee===n.RGBA16F||ee===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ee}function T(R,E,B){return _(R,B)===!0||R.isFramebufferTexture&&R.minFilter!==Mt&&R.minFilter!==yt?Math.log2(Math.max(E.width,E.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?E.mipmaps.length:1}function A(R){return R===Mt||R===Ks||R===qr?n.NEAREST:n.LINEAR}function M(R){let E=R.target;E.removeEventListener("dispose",M),S(E),E.isVideoTexture&&u.delete(E)}function C(R){let E=R.target;E.removeEventListener("dispose",C),L(E)}function S(R){let E=i.get(R);if(E.__webglInit===void 0)return;let B=R.source,ie=f.get(B);if(ie){let te=ie[E.__cacheKey];te.usedTimes--,te.usedTimes===0&&v(R),Object.keys(ie).length===0&&f.delete(B)}i.remove(R)}function v(R){let E=i.get(R);n.deleteTexture(E.__webglTexture);let B=R.source,ie=f.get(B);delete ie[E.__cacheKey],o.memory.textures--}function L(R){let E=R.texture,B=i.get(R),ie=i.get(E);if(ie.__webglTexture!==void 0&&(n.deleteTexture(ie.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(B.__webglFramebuffer[te]))for(let ee=0;ee<B.__webglFramebuffer[te].length;ee++)n.deleteFramebuffer(B.__webglFramebuffer[te][ee]);else n.deleteFramebuffer(B.__webglFramebuffer[te]);B.__webglDepthbuffer&&n.deleteRenderbuffer(B.__webglDepthbuffer[te])}else{if(Array.isArray(B.__webglFramebuffer))for(let te=0;te<B.__webglFramebuffer.length;te++)n.deleteFramebuffer(B.__webglFramebuffer[te]);else n.deleteFramebuffer(B.__webglFramebuffer);if(B.__webglDepthbuffer&&n.deleteRenderbuffer(B.__webglDepthbuffer),B.__webglMultisampledFramebuffer&&n.deleteFramebuffer(B.__webglMultisampledFramebuffer),B.__webglColorRenderbuffer)for(let te=0;te<B.__webglColorRenderbuffer.length;te++)B.__webglColorRenderbuffer[te]&&n.deleteRenderbuffer(B.__webglColorRenderbuffer[te]);B.__webglDepthRenderbuffer&&n.deleteRenderbuffer(B.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let te=0,ee=E.length;te<ee;te++){let ve=i.get(E[te]);ve.__webglTexture&&(n.deleteTexture(ve.__webglTexture),o.memory.textures--),i.remove(E[te])}i.remove(E),i.remove(R)}let U=0;function G(){U=0}function P(){let R=U;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),U+=1,R}function D(R){let E=[];return E.push(R.wrapS),E.push(R.wrapT),E.push(R.wrapR||0),E.push(R.magFilter),E.push(R.minFilter),E.push(R.anisotropy),E.push(R.internalFormat),E.push(R.format),E.push(R.type),E.push(R.generateMipmaps),E.push(R.premultiplyAlpha),E.push(R.flipY),E.push(R.unpackAlignment),E.push(R.colorSpace),E.join()}function z(R,E){let B=i.get(R);if(R.isVideoTexture&&Ee(R),R.isRenderTargetTexture===!1&&R.version>0&&B.__version!==R.version){let ie=R.image;if(ie===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ie.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ue(B,R,E);return}}t.bindTexture(n.TEXTURE_2D,B.__webglTexture,n.TEXTURE0+E)}function q(R,E){let B=i.get(R);if(R.version>0&&B.__version!==R.version){ue(B,R,E);return}t.bindTexture(n.TEXTURE_2D_ARRAY,B.__webglTexture,n.TEXTURE0+E)}function Y(R,E){let B=i.get(R);if(R.version>0&&B.__version!==R.version){ue(B,R,E);return}t.bindTexture(n.TEXTURE_3D,B.__webglTexture,n.TEXTURE0+E)}function W(R,E){let B=i.get(R);if(R.version>0&&B.__version!==R.version){xe(B,R,E);return}t.bindTexture(n.TEXTURE_CUBE_MAP,B.__webglTexture,n.TEXTURE0+E)}let j={[zi]:n.REPEAT,[Xt]:n.CLAMP_TO_EDGE,[Kr]:n.MIRRORED_REPEAT},J={[Mt]:n.NEAREST,[Ks]:n.NEAREST_MIPMAP_NEAREST,[qr]:n.NEAREST_MIPMAP_LINEAR,[yt]:n.LINEAR,[Va]:n.LINEAR_MIPMAP_NEAREST,[jn]:n.LINEAR_MIPMAP_LINEAR},le={[sx]:n.NEVER,[hx]:n.ALWAYS,[ox]:n.LESS,[mp]:n.LEQUAL,[ax]:n.EQUAL,[ux]:n.GEQUAL,[cx]:n.GREATER,[lx]:n.NOTEQUAL};function X(R,E,B){if(B?(n.texParameteri(R,n.TEXTURE_WRAP_S,j[E.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,j[E.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,j[E.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,J[E.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,J[E.minFilter])):(n.texParameteri(R,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(R,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(E.wrapS!==Xt||E.wrapT!==Xt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(R,n.TEXTURE_MAG_FILTER,A(E.magFilter)),n.texParameteri(R,n.TEXTURE_MIN_FILTER,A(E.minFilter)),E.minFilter!==Mt&&E.minFilter!==yt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,le[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){let ie=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===Mt||E.minFilter!==qr&&E.minFilter!==jn||E.type===Xn&&e.has("OES_texture_float_linear")===!1||a===!1&&E.type===Zs&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||i.get(E).__currentAnisotropy)&&(n.texParameterf(R,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,r.getMaxAnisotropy())),i.get(E).__currentAnisotropy=E.anisotropy)}}function Q(R,E){let B=!1;R.__webglInit===void 0&&(R.__webglInit=!0,E.addEventListener("dispose",M));let ie=E.source,te=f.get(ie);te===void 0&&(te={},f.set(ie,te));let ee=D(E);if(ee!==R.__cacheKey){te[ee]===void 0&&(te[ee]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,B=!0),te[ee].usedTimes++;let ve=te[R.__cacheKey];ve!==void 0&&(te[R.__cacheKey].usedTimes--,ve.usedTimes===0&&v(E)),R.__cacheKey=ee,R.__webglTexture=te[ee].texture}return B}function ue(R,E,B){let ie=n.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(ie=n.TEXTURE_2D_ARRAY),E.isData3DTexture&&(ie=n.TEXTURE_3D);let te=Q(R,E),ee=E.source;t.bindTexture(ie,R.__webglTexture,n.TEXTURE0+B);let ve=i.get(ee);if(ee.version!==ve.__version||te===!0){t.activeTexture(n.TEXTURE0+B);let fe=rt.getPrimaries(rt.workingColorSpace),_e=E.colorSpace===En?null:rt.getPrimaries(E.colorSpace),Re=E.colorSpace===En||fe===_e?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,E.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,E.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);let ke=p(E)&&g(E.image)===!1,ne=y(E.image,ke,!1,r.maxTextureSize);ne=me(E,ne);let st=g(ne)||a,Ke=s.convert(E.format,E.colorSpace),Fe=s.convert(E.type),Te=b(E.internalFormat,Ke,Fe,E.colorSpace,E.isVideoTexture);X(ie,E,st);let be,Xe=E.mipmaps,ct=a&&E.isVideoTexture!==!0&&Te!==hp,Et=ve.__version===void 0||te===!0,je=T(E,ne,st);if(E.isDepthTexture)Te=n.DEPTH_COMPONENT,a?E.type===Xn?Te=n.DEPTH_COMPONENT32F:E.type===Ri?Te=n.DEPTH_COMPONENT24:E.type===sr?Te=n.DEPTH24_STENCIL8:Te=n.DEPTH_COMPONENT16:E.type===Xn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===or&&Te===n.DEPTH_COMPONENT&&E.type!==_u&&E.type!==Ri&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Ri,Fe=s.convert(E.type)),E.format===Zr&&Te===n.DEPTH_COMPONENT&&(Te=n.DEPTH_STENCIL,E.type!==sr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=sr,Fe=s.convert(E.type))),Et&&(ct?t.texStorage2D(n.TEXTURE_2D,1,Te,ne.width,ne.height):t.texImage2D(n.TEXTURE_2D,0,Te,ne.width,ne.height,0,Ke,Fe,null));else if(E.isDataTexture)if(Xe.length>0&&st){ct&&Et&&t.texStorage2D(n.TEXTURE_2D,je,Te,Xe[0].width,Xe[0].height);for(let ce=0,O=Xe.length;ce<O;ce++)be=Xe[ce],ct?t.texSubImage2D(n.TEXTURE_2D,ce,0,0,be.width,be.height,Ke,Fe,be.data):t.texImage2D(n.TEXTURE_2D,ce,Te,be.width,be.height,0,Ke,Fe,be.data);E.generateMipmaps=!1}else ct?(Et&&t.texStorage2D(n.TEXTURE_2D,je,Te,ne.width,ne.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,ne.width,ne.height,Ke,Fe,ne.data)):t.texImage2D(n.TEXTURE_2D,0,Te,ne.width,ne.height,0,Ke,Fe,ne.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){ct&&Et&&t.texStorage3D(n.TEXTURE_2D_ARRAY,je,Te,Xe[0].width,Xe[0].height,ne.depth);for(let ce=0,O=Xe.length;ce<O;ce++)be=Xe[ce],E.format!==mn?Ke!==null?ct?t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ce,0,0,0,be.width,be.height,ne.depth,Ke,be.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ce,Te,be.width,be.height,ne.depth,0,be.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ct?t.texSubImage3D(n.TEXTURE_2D_ARRAY,ce,0,0,0,be.width,be.height,ne.depth,Ke,Fe,be.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ce,Te,be.width,be.height,ne.depth,0,Ke,Fe,be.data)}else{ct&&Et&&t.texStorage2D(n.TEXTURE_2D,je,Te,Xe[0].width,Xe[0].height);for(let ce=0,O=Xe.length;ce<O;ce++)be=Xe[ce],E.format!==mn?Ke!==null?ct?t.compressedTexSubImage2D(n.TEXTURE_2D,ce,0,0,be.width,be.height,Ke,be.data):t.compressedTexImage2D(n.TEXTURE_2D,ce,Te,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ct?t.texSubImage2D(n.TEXTURE_2D,ce,0,0,be.width,be.height,Ke,Fe,be.data):t.texImage2D(n.TEXTURE_2D,ce,Te,be.width,be.height,0,Ke,Fe,be.data)}else if(E.isDataArrayTexture)ct?(Et&&t.texStorage3D(n.TEXTURE_2D_ARRAY,je,Te,ne.width,ne.height,ne.depth),t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ne.width,ne.height,ne.depth,Ke,Fe,ne.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Te,ne.width,ne.height,ne.depth,0,Ke,Fe,ne.data);else if(E.isData3DTexture)ct?(Et&&t.texStorage3D(n.TEXTURE_3D,je,Te,ne.width,ne.height,ne.depth),t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ne.width,ne.height,ne.depth,Ke,Fe,ne.data)):t.texImage3D(n.TEXTURE_3D,0,Te,ne.width,ne.height,ne.depth,0,Ke,Fe,ne.data);else if(E.isFramebufferTexture){if(Et)if(ct)t.texStorage2D(n.TEXTURE_2D,je,Te,ne.width,ne.height);else{let ce=ne.width,O=ne.height;for(let de=0;de<je;de++)t.texImage2D(n.TEXTURE_2D,de,Te,ce,O,0,Ke,Fe,null),ce>>=1,O>>=1}}else if(Xe.length>0&&st){ct&&Et&&t.texStorage2D(n.TEXTURE_2D,je,Te,Xe[0].width,Xe[0].height);for(let ce=0,O=Xe.length;ce<O;ce++)be=Xe[ce],ct?t.texSubImage2D(n.TEXTURE_2D,ce,0,0,Ke,Fe,be):t.texImage2D(n.TEXTURE_2D,ce,Te,Ke,Fe,be);E.generateMipmaps=!1}else ct?(Et&&t.texStorage2D(n.TEXTURE_2D,je,Te,ne.width,ne.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ke,Fe,ne)):t.texImage2D(n.TEXTURE_2D,0,Te,Ke,Fe,ne);_(E,st)&&x(ie),ve.__version=ee.version,E.onUpdate&&E.onUpdate(E)}R.__version=E.version}function xe(R,E,B){if(E.image.length!==6)return;let ie=Q(R,E),te=E.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+B);let ee=i.get(te);if(te.version!==ee.__version||ie===!0){t.activeTexture(n.TEXTURE0+B);let ve=rt.getPrimaries(rt.workingColorSpace),fe=E.colorSpace===En?null:rt.getPrimaries(E.colorSpace),_e=E.colorSpace===En||ve===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,E.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,E.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);let Re=E.isCompressedTexture||E.image[0].isCompressedTexture,ke=E.image[0]&&E.image[0].isDataTexture,ne=[];for(let ce=0;ce<6;ce++)!Re&&!ke?ne[ce]=y(E.image[ce],!1,!0,r.maxCubemapSize):ne[ce]=ke?E.image[ce].image:E.image[ce],ne[ce]=me(E,ne[ce]);let st=ne[0],Ke=g(st)||a,Fe=s.convert(E.format,E.colorSpace),Te=s.convert(E.type),be=b(E.internalFormat,Fe,Te,E.colorSpace),Xe=a&&E.isVideoTexture!==!0,ct=ee.__version===void 0||ie===!0,Et=T(E,st,Ke);X(n.TEXTURE_CUBE_MAP,E,Ke);let je;if(Re){Xe&&ct&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Et,be,st.width,st.height);for(let ce=0;ce<6;ce++){je=ne[ce].mipmaps;for(let O=0;O<je.length;O++){let de=je[O];E.format!==mn?Fe!==null?Xe?t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O,0,0,de.width,de.height,Fe,de.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O,be,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Xe?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O,0,0,de.width,de.height,Fe,Te,de.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O,be,de.width,de.height,0,Fe,Te,de.data)}}}else{je=E.mipmaps,Xe&&ct&&(je.length>0&&Et++,t.texStorage2D(n.TEXTURE_CUBE_MAP,Et,be,ne[0].width,ne[0].height));for(let ce=0;ce<6;ce++)if(ke){Xe?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ne[ce].width,ne[ce].height,Fe,Te,ne[ce].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,be,ne[ce].width,ne[ce].height,0,Fe,Te,ne[ce].data);for(let O=0;O<je.length;O++){let pe=je[O].image[ce].image;Xe?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O+1,0,0,pe.width,pe.height,Fe,Te,pe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O+1,be,pe.width,pe.height,0,Fe,Te,pe.data)}}else{Xe?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Fe,Te,ne[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,be,Fe,Te,ne[ce]);for(let O=0;O<je.length;O++){let de=je[O];Xe?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O+1,0,0,Fe,Te,de.image[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,O+1,be,Fe,Te,de.image[ce])}}}_(E,Ke)&&x(n.TEXTURE_CUBE_MAP),ee.__version=te.version,E.onUpdate&&E.onUpdate(E)}R.__version=E.version}function he(R,E,B,ie,te,ee){let ve=s.convert(B.format,B.colorSpace),fe=s.convert(B.type),_e=b(B.internalFormat,ve,fe,B.colorSpace);if(!i.get(E).__hasExternalTextures){let ke=Math.max(1,E.width>>ee),ne=Math.max(1,E.height>>ee);te===n.TEXTURE_3D||te===n.TEXTURE_2D_ARRAY?t.texImage3D(te,ee,_e,ke,ne,E.depth,0,ve,fe,null):t.texImage2D(te,ee,_e,ke,ne,0,ve,fe,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),$(E)?c.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ie,te,i.get(B).__webglTexture,0,re(E)):(te===n.TEXTURE_2D||te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ie,te,i.get(B).__webglTexture,ee),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ce(R,E,B){if(n.bindRenderbuffer(n.RENDERBUFFER,R),E.depthBuffer&&!E.stencilBuffer){let ie=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(B||$(E)){let te=E.depthTexture;te&&te.isDepthTexture&&(te.type===Xn?ie=n.DEPTH_COMPONENT32F:te.type===Ri&&(ie=n.DEPTH_COMPONENT24));let ee=re(E);$(E)?c.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ee,ie,E.width,E.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,ie,E.width,E.height)}else n.renderbufferStorage(n.RENDERBUFFER,ie,E.width,E.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,R)}else if(E.depthBuffer&&E.stencilBuffer){let ie=re(E);B&&$(E)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ie,n.DEPTH24_STENCIL8,E.width,E.height):$(E)?c.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ie,n.DEPTH24_STENCIL8,E.width,E.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,E.width,E.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,R)}else{let ie=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let te=0;te<ie.length;te++){let ee=ie[te],ve=s.convert(ee.format,ee.colorSpace),fe=s.convert(ee.type),_e=b(ee.internalFormat,ve,fe,ee.colorSpace),Re=re(E);B&&$(E)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Re,_e,E.width,E.height):$(E)?c.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Re,_e,E.width,E.height):n.renderbufferStorage(n.RENDERBUFFER,_e,E.width,E.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function De(R,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(E.depthTexture).__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),z(E.depthTexture,0);let ie=i.get(E.depthTexture).__webglTexture,te=re(E);if(E.depthTexture.format===or)$(E)?c.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ie,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ie,0);else if(E.depthTexture.format===Zr)$(E)?c.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ie,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ie,0);else throw new Error("Unknown depthTexture format")}function Me(R){let E=i.get(R),B=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!E.__autoAllocateDepthBuffer){if(B)throw new Error("target.depthTexture not supported in Cube render targets");De(E.__webglFramebuffer,R)}else if(B){E.__webglDepthbuffer=[];for(let ie=0;ie<6;ie++)t.bindFramebuffer(n.FRAMEBUFFER,E.__webglFramebuffer[ie]),E.__webglDepthbuffer[ie]=n.createRenderbuffer(),Ce(E.__webglDepthbuffer[ie],R,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer=n.createRenderbuffer(),Ce(E.__webglDepthbuffer,R,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ue(R,E,B){let ie=i.get(R);E!==void 0&&he(ie.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),B!==void 0&&Me(R)}function N(R){let E=R.texture,B=i.get(R),ie=i.get(E);R.addEventListener("dispose",C),R.isWebGLMultipleRenderTargets!==!0&&(ie.__webglTexture===void 0&&(ie.__webglTexture=n.createTexture()),ie.__version=E.version,o.memory.textures++);let te=R.isWebGLCubeRenderTarget===!0,ee=R.isWebGLMultipleRenderTargets===!0,ve=g(R)||a;if(te){B.__webglFramebuffer=[];for(let fe=0;fe<6;fe++)if(a&&E.mipmaps&&E.mipmaps.length>0){B.__webglFramebuffer[fe]=[];for(let _e=0;_e<E.mipmaps.length;_e++)B.__webglFramebuffer[fe][_e]=n.createFramebuffer()}else B.__webglFramebuffer[fe]=n.createFramebuffer()}else{if(a&&E.mipmaps&&E.mipmaps.length>0){B.__webglFramebuffer=[];for(let fe=0;fe<E.mipmaps.length;fe++)B.__webglFramebuffer[fe]=n.createFramebuffer()}else B.__webglFramebuffer=n.createFramebuffer();if(ee)if(r.drawBuffers){let fe=R.texture;for(let _e=0,Re=fe.length;_e<Re;_e++){let ke=i.get(fe[_e]);ke.__webglTexture===void 0&&(ke.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&$(R)===!1){let fe=ee?E:[E];B.__webglMultisampledFramebuffer=n.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let _e=0;_e<fe.length;_e++){let Re=fe[_e];B.__webglColorRenderbuffer[_e]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,B.__webglColorRenderbuffer[_e]);let ke=s.convert(Re.format,Re.colorSpace),ne=s.convert(Re.type),st=b(Re.internalFormat,ke,ne,Re.colorSpace,R.isXRRenderTarget===!0),Ke=re(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ke,st,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+_e,n.RENDERBUFFER,B.__webglColorRenderbuffer[_e])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(B.__webglDepthRenderbuffer=n.createRenderbuffer(),Ce(B.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(te){t.bindTexture(n.TEXTURE_CUBE_MAP,ie.__webglTexture),X(n.TEXTURE_CUBE_MAP,E,ve);for(let fe=0;fe<6;fe++)if(a&&E.mipmaps&&E.mipmaps.length>0)for(let _e=0;_e<E.mipmaps.length;_e++)he(B.__webglFramebuffer[fe][_e],R,E,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,_e);else he(B.__webglFramebuffer[fe],R,E,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0);_(E,ve)&&x(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ee){let fe=R.texture;for(let _e=0,Re=fe.length;_e<Re;_e++){let ke=fe[_e],ne=i.get(ke);t.bindTexture(n.TEXTURE_2D,ne.__webglTexture),X(n.TEXTURE_2D,ke,ve),he(B.__webglFramebuffer,R,ke,n.COLOR_ATTACHMENT0+_e,n.TEXTURE_2D,0),_(ke,ve)&&x(n.TEXTURE_2D)}t.unbindTexture()}else{let fe=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?fe=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(fe,ie.__webglTexture),X(fe,E,ve),a&&E.mipmaps&&E.mipmaps.length>0)for(let _e=0;_e<E.mipmaps.length;_e++)he(B.__webglFramebuffer[_e],R,E,n.COLOR_ATTACHMENT0,fe,_e);else he(B.__webglFramebuffer,R,E,n.COLOR_ATTACHMENT0,fe,0);_(E,ve)&&x(fe),t.unbindTexture()}R.depthBuffer&&Me(R)}function ae(R){let E=g(R)||a,B=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ie=0,te=B.length;ie<te;ie++){let ee=B[ie];if(_(ee,E)){let ve=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,fe=i.get(ee).__webglTexture;t.bindTexture(ve,fe),x(ve),t.unbindTexture()}}}function K(R){if(a&&R.samples>0&&$(R)===!1){let E=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],B=R.width,ie=R.height,te=n.COLOR_BUFFER_BIT,ee=[],ve=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=i.get(R),_e=R.isWebGLMultipleRenderTargets===!0;if(_e)for(let Re=0;Re<E.length;Re++)t.bindFramebuffer(n.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,fe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,fe.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,fe.__webglFramebuffer);for(let Re=0;Re<E.length;Re++){ee.push(n.COLOR_ATTACHMENT0+Re),R.depthBuffer&&ee.push(ve);let ke=fe.__ignoreDepthValues!==void 0?fe.__ignoreDepthValues:!1;if(ke===!1&&(R.depthBuffer&&(te|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&(te|=n.STENCIL_BUFFER_BIT)),_e&&n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,fe.__webglColorRenderbuffer[Re]),ke===!0&&(n.invalidateFramebuffer(n.READ_FRAMEBUFFER,[ve]),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[ve])),_e){let ne=i.get(E[Re]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ne,0)}n.blitFramebuffer(0,0,B,ie,0,0,B,ie,te,n.NEAREST),l&&n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ee)}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),_e)for(let Re=0;Re<E.length;Re++){t.bindFramebuffer(n.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,fe.__webglColorRenderbuffer[Re]);let ke=i.get(E[Re]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,fe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,ke,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,fe.__webglMultisampledFramebuffer)}}function re(R){return Math.min(r.maxSamples,R.samples)}function $(R){let E=i.get(R);return a&&R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Ee(R){let E=o.render.frame;u.get(R)!==E&&(u.set(R,E),R.update())}function me(R,E){let B=R.colorSpace,ie=R.format,te=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===_l||B!==Dt&&B!==En&&(rt.getTransfer(B)===gt?a===!1?e.has("EXT_sRGB")===!0&&ie===mn?(R.format=_l,R.minFilter=yt,R.generateMipmaps=!1):E=la.sRGBToLinear(E):(ie!==mn||te!==Di)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",B)),E}this.allocateTextureUnit=P,this.resetTextureUnits=G,this.setTexture2D=z,this.setTexture2DArray=q,this.setTexture3D=Y,this.setTextureCube=W,this.rebindTextures=Ue,this.setupRenderTarget=N,this.updateRenderTargetMipmap=ae,this.updateMultisampleRenderTarget=K,this.setupDepthRenderbuffer=Me,this.setupFrameBufferTexture=he,this.useMultisampledRTT=$}function Mx(n,e,t){let i=t.isWebGL2;function r(s,o=En){let a,c=rt.getTransfer(o);if(s===Di)return n.UNSIGNED_BYTE;if(s===op)return n.UNSIGNED_SHORT_4_4_4_4;if(s===ap)return n.UNSIGNED_SHORT_5_5_5_1;if(s===Xy)return n.BYTE;if(s===Yy)return n.SHORT;if(s===_u)return n.UNSIGNED_SHORT;if(s===sp)return n.INT;if(s===Ri)return n.UNSIGNED_INT;if(s===Xn)return n.FLOAT;if(s===Zs)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===qy)return n.ALPHA;if(s===mn)return n.RGBA;if(s===jy)return n.LUMINANCE;if(s===$y)return n.LUMINANCE_ALPHA;if(s===or)return n.DEPTH_COMPONENT;if(s===Zr)return n.DEPTH_STENCIL;if(s===_l)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Ky)return n.RED;if(s===cp)return n.RED_INTEGER;if(s===Zy)return n.RG;if(s===lp)return n.RG_INTEGER;if(s===up)return n.RGBA_INTEGER;if(s===hl||s===fl||s===dl||s===pl)if(c===gt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===hl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===fl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===dl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===pl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===hl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===fl)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===dl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===pl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Sf||s===bf||s===Mf||s===vf)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Sf)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===bf)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Mf)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===vf)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===hp)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Af||s===Ef)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Af)return c===gt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Ef)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===wf||s===Tf||s===Cf||s===Rf||s===If||s===Pf||s===Nf||s===Lf||s===Of||s===Df||s===Uf||s===Ff||s===Bf||s===zf)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===wf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Tf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Cf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Rf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===If)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Pf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Nf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Lf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Of)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Df)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Uf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Ff)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Bf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===zf)return c===gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===ml||s===Vf||s===kf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===ml)return c===gt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Vf)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===kf)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Jy||s===Gf||s===Hf||s===Wf)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===ml)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Gf)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Hf)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Wf)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sr?i?n.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}function u1(n,e){function t(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function i(g,p){p.color.getRGB(g.fogColor.value,mx(n)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function r(g,p,_,x,b){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(g,p):p.isMeshToonMaterial?(s(g,p),h(g,p)):p.isMeshPhongMaterial?(s(g,p),u(g,p)):p.isMeshStandardMaterial?(s(g,p),f(g,p),p.isMeshPhysicalMaterial&&d(g,p,b)):p.isMeshMatcapMaterial?(s(g,p),m(g,p)):p.isMeshDepthMaterial?s(g,p):p.isMeshDistanceMaterial?(s(g,p),y(g,p)):p.isMeshNormalMaterial?s(g,p):p.isLineBasicMaterial?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?c(g,p,_,x):p.isSpriteMaterial?l(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,t(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===hn&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===hn&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,t(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,t(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);let _=e.get(p).envMap;if(_&&(g.envMap.value=_,g.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap){g.lightMap.value=p.lightMap;let x=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=p.lightMapIntensity*x,t(p.lightMap,g.lightMapTransform)}p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,_,x){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*_,g.scale.value=x*.5,p.map&&(g.map.value=p.map,t(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function l(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function h(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function f(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,g.roughnessMapTransform)),e.get(p).envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function d(g,p,_){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===hn&&g.clearcoatNormalScale.value.negate())),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=_.texture,g.transmissionSamplerSize.value.set(_.width,_.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function y(g,p){let _=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(_.matrixWorld),g.nearDistance.value=_.shadow.camera.near,g.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function h1(n,e,t,i){let r={},s={},o=[],a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(_,x){let b=x.program;i.uniformBlockBinding(_,b)}function l(_,x){let b=r[_.id];b===void 0&&(m(_),b=u(_),r[_.id]=b,_.addEventListener("dispose",g));let T=x.program;i.updateUBOMapping(_,T);let A=e.render.frame;s[_.id]!==A&&(f(_),s[_.id]=A)}function u(_){let x=h();_.__bindingPointIndex=x;let b=n.createBuffer(),T=_.__size,A=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,T,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,x,b),b}function h(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){let x=r[_.id],b=_.uniforms,T=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,x);for(let A=0,M=b.length;A<M;A++){let C=Array.isArray(b[A])?b[A]:[b[A]];for(let S=0,v=C.length;S<v;S++){let L=C[S];if(d(L,A,S,T)===!0){let U=L.__offset,G=Array.isArray(L.value)?L.value:[L.value],P=0;for(let D=0;D<G.length;D++){let z=G[D],q=y(z);typeof z=="number"||typeof z=="boolean"?(L.__data[0]=z,n.bufferSubData(n.UNIFORM_BUFFER,U+P,L.__data)):z.isMatrix3?(L.__data[0]=z.elements[0],L.__data[1]=z.elements[1],L.__data[2]=z.elements[2],L.__data[3]=0,L.__data[4]=z.elements[3],L.__data[5]=z.elements[4],L.__data[6]=z.elements[5],L.__data[7]=0,L.__data[8]=z.elements[6],L.__data[9]=z.elements[7],L.__data[10]=z.elements[8],L.__data[11]=0):(z.toArray(L.__data,P),P+=q.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,U,L.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function d(_,x,b,T){let A=_.value,M=x+"_"+b;if(T[M]===void 0)return typeof A=="number"||typeof A=="boolean"?T[M]=A:T[M]=A.clone(),!0;{let C=T[M];if(typeof A=="number"||typeof A=="boolean"){if(C!==A)return T[M]=A,!0}else if(C.equals(A)===!1)return C.copy(A),!0}return!1}function m(_){let x=_.uniforms,b=0,T=16;for(let M=0,C=x.length;M<C;M++){let S=Array.isArray(x[M])?x[M]:[x[M]];for(let v=0,L=S.length;v<L;v++){let U=S[v],G=Array.isArray(U.value)?U.value:[U.value];for(let P=0,D=G.length;P<D;P++){let z=G[P],q=y(z),Y=b%T;Y!==0&&T-Y<q.boundary&&(b+=T-Y),U.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=b,b+=q.storage}}}let A=b%T;return A>0&&(b+=T-A),_.__size=b,_.__cache={},this}function y(_){let x={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(x.boundary=4,x.storage=4):_.isVector2?(x.boundary=8,x.storage=8):_.isVector3||_.isColor?(x.boundary=16,x.storage=12):_.isVector4?(x.boundary=16,x.storage=16):_.isMatrix3?(x.boundary=48,x.storage=48):_.isMatrix4?(x.boundary=64,x.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),x}function g(_){let x=_.target;x.removeEventListener("dispose",g);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),n.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function p(){for(let _ in r)n.deleteBuffer(r[_]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}function Hc(n,e,t,i,r,s){ks.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Ho.x=s*ks.x-r*ks.y,Ho.y=r*ks.x+s*ks.y):Ho.copy(ks),n.copy(e),n.x+=Ho.x,n.y+=Ho.y,n.applyMatrix4(vx)}function m1(n,e){return n.z-e.z}function g1(n,e){return e.z-n.z}function x1(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function V0(n,e,t,i,r,s,o){let a=fd.distanceSqToPoint(n);if(a<t){let c=new w;fd.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}function xp(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,d=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,d*=u,r(o,a,f,d)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function k0(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function _1(n,e){let t=1-n;return t*t*e}function S1(n,e){return 2*(1-n)*n*e}function b1(n,e){return n*n*e}function Qo(n,e,t,i){return _1(n,e)+S1(n,t)+b1(n,i)}function M1(n,e){let t=1-n;return t*t*t*e}function v1(n,e){let t=1-n;return 3*t*t*n*e}function A1(n,e){return 3*(1-n)*n*n*e}function E1(n,e){return n*n*n*e}function ea(n,e,t,i,r){return M1(n,e)+v1(n,t)+A1(n,i)+E1(n,r)}function Ax(n,e,t,i,r){let s,o;if(r===G1(n,e,t,i)>0)for(s=e;s<t;s+=i)o=G0(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=G0(s,n[s],n[s+1],o);return o&&vu(o,o.next)&&(Ca(o),o=o.next),o}function os(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(vu(t,t.next)||At(t.prev,t,t.next)===0)){if(Ca(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function wa(n,e,t,i,r,s,o){if(!n)return;!o&&s&&U1(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?C1(n,i,r,s):T1(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Ca(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=R1(os(n),e,t),wa(n,e,t,i,r,s,2)):o===2&&I1(n,e,t,i,r,s):wa(os(n),e,t,i,r,s,1);break}}}function T1(n){let e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,f=r>s?r>o?r:o:s>o?s:o,d=a>c?a>l?a:l:c>l?c:l,m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=h&&m.y<=d&&qs(r,a,s,c,o,l,m.x,m.y)&&At(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function C1(n,e,t,i){let r=n.prev,s=n,o=n.next;if(At(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,m=u<h?u<f?u:f:h<f?h:f,y=a>c?a>l?a:l:c>l?c:l,g=u>h?u>f?u:f:h>f?h:f,p=yd(d,m,e,t,i),_=yd(y,g,e,t,i),x=n.prevZ,b=n.nextZ;for(;x&&x.z>=p&&b&&b.z<=_;){if(x.x>=d&&x.x<=y&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&qs(a,u,c,h,l,f,x.x,x.y)&&At(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=d&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==o&&qs(a,u,c,h,l,f,b.x,b.y)&&At(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=p;){if(x.x>=d&&x.x<=y&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&qs(a,u,c,h,l,f,x.x,x.y)&&At(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=_;){if(b.x>=d&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==o&&qs(a,u,c,h,l,f,b.x,b.y)&&At(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function R1(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!vu(r,s)&&Ex(r,i,i.next,s)&&Ta(r,s)&&Ta(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Ca(i),Ca(i.next),i=n=s),i=i.next}while(i!==n);return os(i)}function I1(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&z1(o,a)){let c=wx(o,a);o=os(o,o.next),c=os(c,c.next),wa(o,e,t,i,r,s,0),wa(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function P1(n,e,t,i){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=Ax(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(B1(l));for(r.sort(N1),s=0;s<r.length;s++)t=L1(r[s],t);return t}function N1(n,e){return n.x-e.x}function L1(n,e){let t=O1(n,e);if(!t)return e;let i=wx(t,n);return os(i,i.next),os(t,t.next)}function O1(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>i&&(i=f,r=t.x<t.next.x?t:t.next,f===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&qs(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Ta(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&D1(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function D1(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function U1(n,e,t,i){let r=n;do r.z===0&&(r.z=yd(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,F1(r)}function F1(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function yd(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function B1(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function qs(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function z1(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!V1(n,e)&&(Ta(n,e)&&Ta(e,n)&&k1(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||vu(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function vu(n,e){return n.x===e.x&&n.y===e.y}function Ex(n,e,t,i){let r=il(At(n,e,t)),s=il(At(n,e,i)),o=il(At(t,i,n)),a=il(At(t,i,e));return!!(r!==s&&o!==a||r===0&&nl(n,t,e)||s===0&&nl(n,i,e)||o===0&&nl(t,n,i)||a===0&&nl(t,e,i))}function nl(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function il(n){return n>0?1:n<0?-1:0}function V1(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Ex(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ta(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function k1(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function wx(n,e){let t=new xd(n.i,n.x,n.y),i=new xd(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function G0(n,e,t,i){let r=new xd(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ca(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xd(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function G1(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function H0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function W0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function W1(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function X1(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function X0(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function Xr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Tx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Cx(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function _d(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function _p(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function Y1(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),h=[],f=[];for(let d=0;d<l.times.length;++d){let m=l.times[d]*r;if(!(m<t||m>=i)){h.push(l.times[d]);for(let y=0;y<u;++y)f.push(l.values[d*u+y])}}h.length!==0&&(l.times=Xr(h,l.times.constructor),l.values=Xr(f,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function q1(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(p){return p.name===a.name&&p.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let f=0,d=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=a.times.length-1,y;if(s<=a.times[0]){let p=u,_=h-u;y=a.values.slice(p,_)}else if(s>=a.times[m]){let p=m*h+u,_=p+h-u;y=a.values.slice(p,_)}else{let p=a.createInterpolant(),_=u,x=h-u;p.evaluate(s),y=p.resultBuffer.slice(_,x)}c==="quaternion"&&new Ft().fromArray(y).normalize().conjugate().toArray(y);let g=l.times.length;for(let p=0;p<g;++p){let _=p*d+f;if(c==="quaternion")Ft.multiplyQuaternionsFlat(l.values,_,y,0,l.values,_);else{let x=d-f*2;for(let b=0;b<x;++b)l.values[_+b]-=y[b]}}}return n.blendMode=fp,n}function $1(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return li;case"vector":case"vector2":case"vector3":case"vector4":return ui;case"color":return Na;case"quaternion":return Zn;case"bool":case"boolean":return Gi;case"string":return Hi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function K1(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=$1(n.type);if(n.times===void 0){let t=[],i=[];_p(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function ey(){return(typeof performance>"u"?Date:performance).now()}function iy(n,e){return n.distance-e.distance}function kd(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)kd(r[s],e,t,!0)}}function Ix(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Ix(n.children[t]));return e}function Nt(n,e,t,i,r,s,o){cl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],cl.x,cl.y,cl.z)}}var TM,CM,RM,fy,df,dy,IM,PM,rp,gu,si,qn,hn,On,NM,Li,Yr,pf,mf,gf,py,rr,my,gy,yf,xf,yy,xy,_y,Sy,yl,xl,by,My,vy,Ay,Ey,wy,Ty,Cy,Ry,Iy,Py,Ny,ta,Ly,Oy,Dy,Uy,za,Fy,By,Oi,zy,Vy,ky,yu,Gy,Hy,_f,Wy,xu,Bi,cr,$r,na,_o,zi,Xt,Kr,Mt,Ks,LM,qr,OM,yt,Va,DM,jn,UM,Di,Xy,Yy,_u,sp,Ri,Xn,Zs,op,ap,sr,qy,mn,jy,$y,or,Zr,Ky,cp,Zy,lp,up,hl,fl,dl,pl,Sf,bf,Mf,vf,hp,Af,Ef,wf,Tf,Cf,Rf,If,Pf,Nf,Lf,Of,Df,Uf,Ff,Bf,zf,ml,Vf,kf,Jy,Gf,Hf,Wf,Qy,ex,tx,Jr,lr,gl,Hr,Wr,ia,Su,fp,dp,ka,So,pp,ar,nx,ix,yr,rx,En,lt,Dt,bu,Ga,ra,gt,sa,oa,FM,Vr,BM,zM,VM,kM,GM,HM,WM,XM,YM,qM,jM,$M,KM,Xf,sx,ox,ax,mp,cx,lx,ux,hx,aa,ZM,JM,QM,ev,tv,nv,iv,rv,sv,Yf,_l,Yn,Js,$n,en,Fg,jr,Qs,Ha,Z,Ye,Ih,Sv,Bg,zg,Vg,_c,bv,rt,vs,la,Mv,Ii,vv,Rt,tt,bl,Tn,eo,jf,ua,$f,Kf,Ft,w,Lh,kg,xt,Mi,Gn,Sc,As,Es,ws,Zi,Ji,Ir,Bo,bc,Mc,Pr,Av,zo,Dh,_t,vi,Uh,vc,Qi,Fh,Ac,Bh,ur,we,Ts,Hn,Ev,wv,er,Ec,vn,Gg,Hg,ha,to,Tv,Wg,Cs,Ai,wc,Vo,Cv,Rv,Xg,Yg,qg,Iv,Pv,it,Wn,Ei,zh,wi,Rs,Is,jg,Vh,kh,Gh,Tc,Pi,px,tr,Cc,oe,tn,Nv,It,sn,Ci,Ov,Ot,Rc,Ze,Zf,Jf,Qf,ed,fa,td,da,nd,ye,id,Dv,Ln,Wh,Ps,An,ko,Wt,Be,$g,Nr,Ic,Kg,Ns,Ls,Os,Xh,Pc,Nc,Lc,Oc,Zg,Jg,Qg,Dc,Uc,ft,Qr,Wa,Bv,zv,yn,io,vt,Ds,Us,Ml,es,vl,Yh,Vv,kv,oi,Lr,Bc,ts,ns,Hv,Wv,Xv,Yv,qv,jv,$v,Kv,Zv,Jv,Qv,eA,tA,nA,iA,rA,sA,oA,aA,cA,lA,uA,hA,fA,dA,pA,mA,gA,yA,xA,_A,SA,bA,MA,vA,AA,EA,wA,TA,CA,RA,IA,PA,NA,LA,OA,DA,UA,FA,BA,zA,VA,kA,GA,HA,WA,XA,YA,qA,jA,$A,KA,ZA,JA,QA,eE,tE,nE,iE,rE,sE,oE,aE,cE,lE,uE,hE,fE,dE,pE,mE,gE,yE,xE,_E,SE,bE,ME,vE,AE,EE,wE,TE,CE,RE,IE,PE,NE,LE,OE,DE,UE,FE,BE,zE,VE,kE,GE,HE,WE,XE,YE,qE,jE,$E,KE,ZE,JE,QE,ew,tw,nw,iw,rw,sw,ow,aw,cw,lw,uw,hw,fw,dw,pw,mw,gw,yw,xw,_w,Sw,bw,He,se,rn,zc,ci,Xs,e0,Gr,qh,t0,jh,$h,Kh,kr,Fs,n0,pa,ma,yx,xx,_x,Sx,bx,o0,a0,c0,l0,u0,rd,sd,od,Zh,$s,wT,TT,UT,FT,zT,qT,cd,ld,e1,ga,ya,r1,s1,Al,Dn,l1,Jo,ud,El,wl,Tl,Cl,ro,Vi,ln,Yt,xa,Bs,Go,zs,Vs,ks,Ho,vx,kc,Wo,Gc,b0,Jh,M0,Rl,Wc,v0,Il,A0,E0,w0,f1,T0,Xc,Qh,C0,ef,so,is,Ui,R0,d1,oo,Kn,Gs,I0,Yc,P0,p1,Xo,Yo,ao,hd,Hs,nr,N0,y1,L0,tf,qc,Or,qo,nf,nn,jc,Pl,Vt,O0,D0,U0,rf,$c,Un,F0,B0,xn,co,rs,z0,fd,Kc,Zc,lo,dd,pd,uo,md,gd,_a,Cn,ho,Nl,Jc,sf,of,af,Ll,Sa,Ol,ba,Dl,Ma,va,Aa,Ul,Fl,ss,Ea,Bl,zl,fo,Vl,hr,kl,Qc,el,cf,tl,Gl,Fi,w1,ai,Hl,H1,Wl,Ra,Xl,Yl,Ia,ql,jl,$l,Kl,po,Y0,mo,Zl,fr,_n,Jl,Ql,eu,tu,nu,iu,j1,ki,ru,Pa,su,Rn,Gi,Na,li,ou,Zn,Hi,ui,Wi,Ni,La,Rx,qt,Ti,Sd,Sn,bd,Md,as,vd,Ad,cs,hi,go,lf,q0,j0,Oa,Ed,dr,$0,jo,uf,wd,pr,Td,mr,yo,au,cu,lu,uu,Jn,xo,hu,Cd,Z1,K0,Z0,Da,rl,Ua,Rd,J0,Q0,Dr,Id,fu,Ur,ty,J1,Fr,Pd,du,Br,ny,Q1,zr,Nd,Ld,pu,Sp,eC,bp,tC,nC,iC,rC,sC,oC,aC,Od,ot,Dd,mu,cC,Ud,Fd,lC,Bd,gr,zd,Vd,Gd,Hd,ry,Wd,sy,sl,Fa,oy,Xd,ir,ol,hf,Yd,qd,uC,ay,cy,jd,Ba,$d,ly,al,uy,Kd,cl,Tt,Zd,ll,Jd,Qd,ep,hy,ul,ff,tp,np,ip,ei=Eh(()=>{TM="160",CM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},RM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fy=0,df=1,dy=2,IM=3,PM=0,rp=1,gu=2,si=3,qn=0,hn=1,On=2,NM=2,Li=0,Yr=1,pf=2,mf=3,gf=4,py=5,rr=100,my=101,gy=102,yf=103,xf=104,yy=200,xy=201,_y=202,Sy=203,yl=204,xl=205,by=206,My=207,vy=208,Ay=209,Ey=210,wy=211,Ty=212,Cy=213,Ry=214,Iy=0,Py=1,Ny=2,ta=3,Ly=4,Oy=5,Dy=6,Uy=7,za=0,Fy=1,By=2,Oi=0,zy=1,Vy=2,ky=3,yu=4,Gy=5,Hy=6,_f="attached",Wy="detached",xu=300,Bi=301,cr=302,$r=303,na=304,_o=306,zi=1e3,Xt=1001,Kr=1002,Mt=1003,Ks=1004,LM=1004,qr=1005,OM=1005,yt=1006,Va=1007,DM=1007,jn=1008,UM=1008,Di=1009,Xy=1010,Yy=1011,_u=1012,sp=1013,Ri=1014,Xn=1015,Zs=1016,op=1017,ap=1018,sr=1020,qy=1021,mn=1023,jy=1024,$y=1025,or=1026,Zr=1027,Ky=1028,cp=1029,Zy=1030,lp=1031,up=1033,hl=33776,fl=33777,dl=33778,pl=33779,Sf=35840,bf=35841,Mf=35842,vf=35843,hp=36196,Af=37492,Ef=37496,wf=37808,Tf=37809,Cf=37810,Rf=37811,If=37812,Pf=37813,Nf=37814,Lf=37815,Of=37816,Df=37817,Uf=37818,Ff=37819,Bf=37820,zf=37821,ml=36492,Vf=36494,kf=36495,Jy=36283,Gf=36284,Hf=36285,Wf=36286,Qy=2200,ex=2201,tx=2202,Jr=2300,lr=2301,gl=2302,Hr=2400,Wr=2401,ia=2402,Su=2500,fp=2501,dp=0,ka=1,So=2,pp=3e3,ar=3001,nx=3200,ix=3201,yr=0,rx=1,En="",lt="srgb",Dt="srgb-linear",bu="display-p3",Ga="display-p3-linear",ra="linear",gt="srgb",sa="rec709",oa="p3",FM=0,Vr=7680,BM=7681,zM=7682,VM=7683,kM=34055,GM=34056,HM=5386,WM=512,XM=513,YM=514,qM=515,jM=516,$M=517,KM=518,Xf=519,sx=512,ox=513,ax=514,mp=515,cx=516,lx=517,ux=518,hx=519,aa=35044,ZM=35048,JM=35040,QM=35045,ev=35049,tv=35041,nv=35046,iv=35050,rv=35042,sv="100",Yf="300 es",_l=1035,Yn=2e3,Js=2001,$n=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},en=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Fg=1234567,jr=Math.PI/180,Qs=180/Math.PI;Ha={DEG2RAD:jr,RAD2DEG:Qs,generateUUID:wn,clamp:Ct,euclideanModulo:gp,mapLinear:ov,inverseLerp:av,lerp:Ko,damp:cv,pingpong:lv,smoothstep:uv,smootherstep:hv,randInt:fv,randFloat:dv,randFloatSpread:pv,seededRandom:mv,degToRad:gv,radToDeg:yv,isPowerOfTwo:qf,ceilPowerOfTwo:xv,floorPowerOfTwo:Sl,setQuaternionFromProperEuler:_v,normalize:We,denormalize:gn},Z=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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 i=this.dot(e)/t;return Math.acos(Ct(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ye=class n{constructor(e,t,i,r,s,o,a,c,l){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],h=i[7],f=i[2],d=i[5],m=i[8],y=r[0],g=r[3],p=r[6],_=r[1],x=r[4],b=r[7],T=r[2],A=r[5],M=r[8];return s[0]=o*y+a*_+c*T,s[3]=o*g+a*x+c*A,s[6]=o*p+a*b+c*M,s[1]=l*y+u*_+h*T,s[4]=l*g+u*x+h*A,s[7]=l*p+u*b+h*M,s[2]=f*y+d*_+m*T,s[5]=f*g+d*x+m*A,s[8]=f*p+d*b+m*M,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],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*s*u+i*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,f=a*c-u*s,d=l*s-o*c,m=t*h+i*f+r*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/m;return e[0]=h*y,e[1]=(r*l-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=f*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=d*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*s)*y,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,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Ih.makeScale(e,t)),this}rotate(e){return this.premultiply(Ih.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ih.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Ih=new Ye;Sv={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};Bg={};zg=new Ye().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Vg=new Ye().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),_c={[Dt]:{transfer:ra,primaries:sa,toReference:n=>n,fromReference:n=>n},[lt]:{transfer:gt,primaries:sa,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Ga]:{transfer:ra,primaries:oa,toReference:n=>n.applyMatrix3(Vg),fromReference:n=>n.applyMatrix3(zg)},[bu]:{transfer:gt,primaries:oa,toReference:n=>n.convertSRGBToLinear().applyMatrix3(Vg),fromReference:n=>n.applyMatrix3(zg).convertLinearToSRGB()}},bv=new Set([Dt,Ga]),rt={enabled:!0,_workingColorSpace:Dt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!bv.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=_c[e].toReference,r=_c[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return _c[n].primaries},getTransfer:function(n){return n===En?ra:_c[n].transfer}};la=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{vs===void 0&&(vs=ca("canvas")),vs.width=e.width,vs.height=e.height;let i=vs.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=vs}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=ca("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=js(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(js(t[i]/255)*255):t[i]=js(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Mv=0,Ii=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Mv++}),this.uuid=wn(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Nh(r[o].image)):s.push(Nh(r[o]))}else s=Nh(r);i.url=s}return t||(e.images[this.uuid]=i),i}};vv=0,Rt=class n extends $n{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Xt,r=Xt,s=yt,o=jn,a=mn,c=Di,l=n.DEFAULT_ANISOTROPY,u=En){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vv++}),this.uuid=wn(),this.name="",this.source=new Ii(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Z(0,0),this.repeat=new Z(1,1),this.center=new Z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ye,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Zo("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===ar?lt:En),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zi:e.x=e.x-Math.floor(e.x);break;case Xt:e.x=e.x<0?0:1;break;case Kr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case zi:e.y=e.y-Math.floor(e.y);break;case Xt:e.y=e.y<0?0:1;break;case Kr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Zo("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===lt?ar:pp}set encoding(e){Zo("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===ar?lt:En}};Rt.DEFAULT_IMAGE=null;Rt.DEFAULT_MAPPING=xu;Rt.DEFAULT_ANISOTROPY=1;tt=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,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,i,r,s,c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],m=c[9],y=c[2],g=c[6],p=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-y)<.01&&Math.abs(m-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+y)<.1&&Math.abs(m+g)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(l+1)/2,b=(d+1)/2,T=(p+1)/2,A=(u+f)/4,M=(h+y)/4,C=(m+g)/4;return x>b&&x>T?x<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(x),r=A/i,s=M/i):b>T?b<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),i=A/r,s=C/r):T<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(T),i=M/s,r=C/s),this.set(i,r,s,t),this}let _=Math.sqrt((g-m)*(g-m)+(h-y)*(h-y)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(g-m)/_,this.y=(h-y)/_,this.z=(f-u)/_,this.w=Math.acos((l+d+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},bl=class extends $n{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new tt(0,0,e,t),this.scissorTest=!1,this.viewport=new tt(0,0,e,t);let r={width:e,height:t,depth:1};i.encoding!==void 0&&(Zo("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===ar?lt:En),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Rt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Ii(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Tn=class extends bl{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},eo=class extends Rt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Mt,this.minFilter=Mt,this.wrapR=Xt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},jf=class extends Tn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new eo(null,e,t,i),this.texture.isRenderTargetTexture=!0}},ua=class extends Rt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Mt,this.minFilter=Mt,this.wrapR=Xt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},$f=class extends Tn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new ua(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Kf=class extends Tn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let o=0;o<i;o++)this.texture[o]=s.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.texture.length;r<s;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}},Ft=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],h=i[r+3],f=s[o+0],d=s[o+1],m=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=m,e[t+3]=y;return}if(h!==y||c!==f||l!==d||u!==m){let g=1-a,p=c*f+l*d+u*m+h*y,_=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){let T=Math.sqrt(x),A=Math.atan2(T,p*_);g=Math.sin(g*A)/T,a=Math.sin(a*A)/T}let b=a*_;if(c=c*g+f*b,l=l*g+d*b,u=u*g+m*b,h=h*g+y*b,g===1-a){let T=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=T,l*=T,u*=T,h*=T}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],h=s[o],f=s[o+1],d=s[o+2],m=s[o+3];return e[t]=a*m+u*h+c*d-l*f,e[t+1]=c*m+u*f+l*h-a*d,e[t+2]=l*m+u*d+a*f-c*h,e[t+3]=u*m-a*h-c*f-l*d,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,i,r){return this._x=e,this._y=t,this._z=i,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 i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),h=a(s/2),f=c(i/2),d=c(r/2),m=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h-f*d*m;break;case"YXZ":this._x=f*u*h+l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h+f*d*m;break;case"ZXY":this._x=f*u*h-l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h-f*d*m;break;case"ZYX":this._x=f*u*h-l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h+f*d*m;break;case"YZX":this._x=f*u*h+l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h-f*d*m;break;case"XZY":this._x=f*u*h-l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h+f*d*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=i+a+h;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(o-r)*d}else if(i>a&&i>h){let d=2*Math.sqrt(1+i-a-h);this._w=(u-c)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+l)/d}else if(a>h){let d=2*Math.sqrt(1+a-i-h);this._w=(s-l)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(c+u)/d}else{let d=2*Math.sqrt(1+h-i-a);this._w=(o-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ct(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let d=1-t;return this._w=d*o+t*this._w,this._x=d*i+t*this._x,this._y=d*r+t*this._y,this._z=d*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=o*h+this._w*f,this._x=i*h+this._x*f,this._y=r*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}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}},w=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(kg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(kg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),u=2*(a*t-s*r),h=2*(s*i-o*t);return this.x=t+c*l+o*h-a*u,this.y=i+c*u+a*l-s*h,this.z=r+c*h+s*u-o*l,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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Lh.copy(this).projectOnVector(e),this.sub(Lh)}reflect(e){return this.sub(Lh.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 i=this.dot(e)/t;return Math.acos(Ct(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+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,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,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()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Lh=new w,kg=new Ft,xt=class{constructor(e=new w(1/0,1/0,1/0),t=new w(-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,i=e.length;t<i;t+=3)this.expandByPoint(Gn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Gn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Gn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Gn):Gn.fromBufferAttribute(s,o),Gn.applyMatrix4(e.matrixWorld),this.expandByPoint(Gn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Sc.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Sc.copy(i.boundingBox)),Sc.applyMatrix4(e.matrixWorld),this.union(Sc)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Gn),Gn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bo),bc.subVectors(this.max,Bo),As.subVectors(e.a,Bo),Es.subVectors(e.b,Bo),ws.subVectors(e.c,Bo),Zi.subVectors(Es,As),Ji.subVectors(ws,Es),Ir.subVectors(As,ws);let t=[0,-Zi.z,Zi.y,0,-Ji.z,Ji.y,0,-Ir.z,Ir.y,Zi.z,0,-Zi.x,Ji.z,0,-Ji.x,Ir.z,0,-Ir.x,-Zi.y,Zi.x,0,-Ji.y,Ji.x,0,-Ir.y,Ir.x,0];return!Oh(t,As,Es,ws,bc)||(t=[1,0,0,0,1,0,0,0,1],!Oh(t,As,Es,ws,bc))?!1:(Mc.crossVectors(Zi,Ji),t=[Mc.x,Mc.y,Mc.z],Oh(t,As,Es,ws,bc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gn).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:(Mi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mi),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)}},Mi=[new w,new w,new w,new w,new w,new w,new w,new w],Gn=new w,Sc=new xt,As=new w,Es=new w,ws=new w,Zi=new w,Ji=new w,Ir=new w,Bo=new w,bc=new w,Mc=new w,Pr=new w;Av=new xt,zo=new w,Dh=new w,_t=class{constructor(e=new w,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 i=this.center;t!==void 0?i.copy(t):Av.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;zo.subVectors(e,this.center);let t=zo.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(zo,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Dh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zo.copy(e.center).add(Dh)),this.expandByPoint(zo.copy(e.center).sub(Dh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},vi=new w,Uh=new w,vc=new w,Qi=new w,Fh=new w,Ac=new w,Bh=new w,ur=class{constructor(e=new w,t=new w(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,vi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=vi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(vi.copy(this.origin).addScaledVector(this.direction,t),vi.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Uh.copy(e).add(t).multiplyScalar(.5),vc.copy(t).sub(e).normalize(),Qi.copy(this.origin).sub(Uh);let s=e.distanceTo(t)*.5,o=-this.direction.dot(vc),a=Qi.dot(this.direction),c=-Qi.dot(vc),l=Qi.lengthSq(),u=Math.abs(1-o*o),h,f,d,m;if(u>0)if(h=o*c-a,f=o*a-c,m=s*u,h>=0)if(f>=-m)if(f<=m){let y=1/u;h*=y,f*=y,d=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f<=-m?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=m?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Uh).addScaledVector(vc,f),d}intersectSphere(e,t){vi.subVectors(e.center,this.origin);let i=vi.dot(this.direction),r=vi.dot(vi)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(i=(e.min.x-f.x)*l,r=(e.max.x-f.x)*l):(i=(e.max.x-f.x)*l,r=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,vi)!==null}intersectTriangle(e,t,i,r,s){Fh.subVectors(t,e),Ac.subVectors(i,e),Bh.crossVectors(Fh,Ac);let o=this.direction.dot(Bh),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Qi.subVectors(this.origin,e);let c=a*this.direction.dot(Ac.crossVectors(Qi,Ac));if(c<0)return null;let l=a*this.direction.dot(Fh.cross(Qi));if(l<0||c+l>o)return null;let u=-a*Qi.dot(Bh);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},we=class n{constructor(e,t,i,r,s,o,a,c,l,u,h,f,d,m,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,u,h,f,d,m,y,g)}set(e,t,i,r,s,o,a,c,l,u,h,f,d,m,y,g){let p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=f,p[3]=d,p[7]=m,p[11]=y,p[15]=g,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 n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/Ts.setFromMatrixColumn(e,0).length(),s=1/Ts.setFromMatrixColumn(e,1).length(),o=1/Ts.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let f=o*u,d=o*h,m=a*u,y=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+m*l,t[5]=f-y*l,t[9]=-a*c,t[2]=y-f*l,t[6]=m+d*l,t[10]=o*c}else if(e.order==="YXZ"){let f=c*u,d=c*h,m=l*u,y=l*h;t[0]=f+y*a,t[4]=m*a-d,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=d*a-m,t[6]=y+f*a,t[10]=o*c}else if(e.order==="ZXY"){let f=c*u,d=c*h,m=l*u,y=l*h;t[0]=f-y*a,t[4]=-o*h,t[8]=m+d*a,t[1]=d+m*a,t[5]=o*u,t[9]=y-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let f=o*u,d=o*h,m=a*u,y=a*h;t[0]=c*u,t[4]=m*l-d,t[8]=f*l+y,t[1]=c*h,t[5]=y*l+f,t[9]=d*l-m,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let f=o*c,d=o*l,m=a*c,y=a*l;t[0]=c*u,t[4]=y-f*h,t[8]=m*h+d,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=d*h+m,t[10]=f-y*h}else if(e.order==="XZY"){let f=o*c,d=o*l,m=a*c,y=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+y,t[5]=o*u,t[9]=d*h-m,t[2]=m*h-d,t[6]=a*u,t[10]=y*h+f}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(Ev,e,wv)}lookAt(e,t,i){let r=this.elements;return vn.subVectors(e,t),vn.lengthSq()===0&&(vn.z=1),vn.normalize(),er.crossVectors(i,vn),er.lengthSq()===0&&(Math.abs(i.z)===1?vn.x+=1e-4:vn.z+=1e-4,vn.normalize(),er.crossVectors(i,vn)),er.normalize(),Ec.crossVectors(vn,er),r[0]=er.x,r[4]=Ec.x,r[8]=vn.x,r[1]=er.y,r[5]=Ec.y,r[9]=vn.y,r[2]=er.z,r[6]=Ec.z,r[10]=vn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],h=i[5],f=i[9],d=i[13],m=i[2],y=i[6],g=i[10],p=i[14],_=i[3],x=i[7],b=i[11],T=i[15],A=r[0],M=r[4],C=r[8],S=r[12],v=r[1],L=r[5],U=r[9],G=r[13],P=r[2],D=r[6],z=r[10],q=r[14],Y=r[3],W=r[7],j=r[11],J=r[15];return s[0]=o*A+a*v+c*P+l*Y,s[4]=o*M+a*L+c*D+l*W,s[8]=o*C+a*U+c*z+l*j,s[12]=o*S+a*G+c*q+l*J,s[1]=u*A+h*v+f*P+d*Y,s[5]=u*M+h*L+f*D+d*W,s[9]=u*C+h*U+f*z+d*j,s[13]=u*S+h*G+f*q+d*J,s[2]=m*A+y*v+g*P+p*Y,s[6]=m*M+y*L+g*D+p*W,s[10]=m*C+y*U+g*z+p*j,s[14]=m*S+y*G+g*q+p*J,s[3]=_*A+x*v+b*P+T*Y,s[7]=_*M+x*L+b*D+T*W,s[11]=_*C+x*U+b*z+T*j,s[15]=_*S+x*G+b*q+T*J,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],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],m=e[3],y=e[7],g=e[11],p=e[15];return m*(+s*c*h-r*l*h-s*a*f+i*l*f+r*a*d-i*c*d)+y*(+t*c*d-t*l*f+s*o*f-r*o*d+r*l*u-s*c*u)+g*(+t*l*h-t*a*d-s*o*h+i*o*d+s*a*u-i*l*u)+p*(-r*a*u-t*c*h+t*a*f+r*o*h-i*o*f+i*c*u)}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,i){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]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],m=e[12],y=e[13],g=e[14],p=e[15],_=h*g*l-y*f*l+y*c*d-a*g*d-h*c*p+a*f*p,x=m*f*l-u*g*l-m*c*d+o*g*d+u*c*p-o*f*p,b=u*y*l-m*h*l+m*a*d-o*y*d-u*a*p+o*h*p,T=m*h*c-u*y*c-m*a*f+o*y*f+u*a*g-o*h*g,A=t*_+i*x+r*b+s*T;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/A;return e[0]=_*M,e[1]=(y*f*s-h*g*s-y*r*d+i*g*d+h*r*p-i*f*p)*M,e[2]=(a*g*s-y*c*s+y*r*l-i*g*l-a*r*p+i*c*p)*M,e[3]=(h*c*s-a*f*s-h*r*l+i*f*l+a*r*d-i*c*d)*M,e[4]=x*M,e[5]=(u*g*s-m*f*s+m*r*d-t*g*d-u*r*p+t*f*p)*M,e[6]=(m*c*s-o*g*s-m*r*l+t*g*l+o*r*p-t*c*p)*M,e[7]=(o*f*s-u*c*s+u*r*l-t*f*l-o*r*d+t*c*d)*M,e[8]=b*M,e[9]=(m*h*s-u*y*s-m*i*d+t*y*d+u*i*p-t*h*p)*M,e[10]=(o*y*s-m*a*s+m*i*l-t*y*l-o*i*p+t*a*p)*M,e[11]=(u*a*s-o*h*s-u*i*l+t*h*l+o*i*d-t*a*d)*M,e[12]=T*M,e[13]=(u*y*r-m*h*r+m*i*f-t*y*f-u*i*g+t*h*g)*M,e[14]=(m*a*r-o*y*r-m*i*c+t*y*c+o*i*g-t*a*g)*M,e[15]=(o*h*r-u*a*r+u*i*c-t*h*c-o*i*f+t*a*f)*M,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=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,i,r))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,h=a+a,f=s*l,d=s*u,m=s*h,y=o*u,g=o*h,p=a*h,_=c*l,x=c*u,b=c*h,T=i.x,A=i.y,M=i.z;return r[0]=(1-(y+p))*T,r[1]=(d+b)*T,r[2]=(m-x)*T,r[3]=0,r[4]=(d-b)*A,r[5]=(1-(f+p))*A,r[6]=(g+_)*A,r[7]=0,r[8]=(m+x)*M,r[9]=(g-_)*M,r[10]=(1-(f+y))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=Ts.set(r[0],r[1],r[2]).length(),o=Ts.set(r[4],r[5],r[6]).length(),a=Ts.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Hn.copy(this);let l=1/s,u=1/o,h=1/a;return Hn.elements[0]*=l,Hn.elements[1]*=l,Hn.elements[2]*=l,Hn.elements[4]*=u,Hn.elements[5]*=u,Hn.elements[6]*=u,Hn.elements[8]*=h,Hn.elements[9]*=h,Hn.elements[10]*=h,t.setFromRotationMatrix(Hn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Yn){let c=this.elements,l=2*s/(t-e),u=2*s/(i-r),h=(t+e)/(t-e),f=(i+r)/(i-r),d,m;if(a===Yn)d=-(o+s)/(o-s),m=-2*o*s/(o-s);else if(a===Js)d=-o/(o-s),m=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Yn){let c=this.elements,l=1/(t-e),u=1/(i-r),h=1/(o-s),f=(t+e)*l,d=(i+r)*u,m,y;if(a===Yn)m=(o+s)*h,y=-2*h;else if(a===Js)m=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=y,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Ts=new w,Hn=new we,Ev=new w(0,0,0),wv=new w(1,1,1),er=new w,Ec=new w,vn=new w,Gg=new we,Hg=new Ft,ha=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,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,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],f=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(Ct(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ct(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ct(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ct(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Ct(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Ct(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Gg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Gg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hg.setFromEuler(this),this.setFromQuaternion(Hg,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}};ha.DEFAULT_ORDER="XYZ";to=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Tv=0,Wg=new w,Cs=new Ft,Ai=new we,wc=new w,Vo=new w,Cv=new w,Rv=new Ft,Xg=new w(1,0,0),Yg=new w(0,1,0),qg=new w(0,0,1),Iv={type:"added"},Pv={type:"removed"},it=class n extends $n{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Tv++}),this.uuid=wn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new w,t=new ha,i=new Ft,r=new w(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new we},normalMatrix:{value:new Ye}}),this.matrix=new we,this.matrixWorld=new we,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new to,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cs.setFromAxisAngle(e,t),this.quaternion.multiply(Cs),this}rotateOnWorldAxis(e,t){return Cs.setFromAxisAngle(e,t),this.quaternion.premultiply(Cs),this}rotateX(e){return this.rotateOnAxis(Xg,e)}rotateY(e){return this.rotateOnAxis(Yg,e)}rotateZ(e){return this.rotateOnAxis(qg,e)}translateOnAxis(e,t){return Wg.copy(e).applyQuaternion(this.quaternion),this.position.add(Wg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Xg,e)}translateY(e){return this.translateOnAxis(Yg,e)}translateZ(e){return this.translateOnAxis(qg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ai.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?wc.copy(e):wc.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Vo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ai.lookAt(Vo,wc,this.up):Ai.lookAt(wc,Vo,this.up),this.quaternion.setFromRotationMatrix(Ai),r&&(Ai.extractRotation(r.matrixWorld),Cs.setFromRotationMatrix(Ai),this.quaternion.premultiply(Cs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Iv)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Pv)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ai.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ai.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ai),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vo,e,Cv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vo,Rv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),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 s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),f=o(e.skeletons),d=o(e.animations),m=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),f.length>0&&(i.skeletons=f),d.length>0&&(i.animations=d),m.length>0&&(i.nodes=m)}return i.object=r,i;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};it.DEFAULT_UP=new w(0,1,0);it.DEFAULT_MATRIX_AUTO_UPDATE=!0;it.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Wn=new w,Ei=new w,zh=new w,wi=new w,Rs=new w,Is=new w,jg=new w,Vh=new w,kh=new w,Gh=new w,Tc=!1,Pi=class n{constructor(e=new w,t=new w,i=new w){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Wn.subVectors(e,t),r.cross(Wn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Wn.subVectors(r,t),Ei.subVectors(i,t),zh.subVectors(e,t);let o=Wn.dot(Wn),a=Wn.dot(Ei),c=Wn.dot(zh),l=Ei.dot(Ei),u=Ei.dot(zh),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;let f=1/h,d=(l*c-a*u)*f,m=(o*u-a*c)*f;return s.set(1-d-m,m,d)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,wi)===null?!1:wi.x>=0&&wi.y>=0&&wi.x+wi.y<=1}static getUV(e,t,i,r,s,o,a,c){return Tc===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Tc=!0),this.getInterpolation(e,t,i,r,s,o,a,c)}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,wi)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,wi.x),c.addScaledVector(o,wi.y),c.addScaledVector(a,wi.z),c)}static isFrontFacing(e,t,i,r){return Wn.subVectors(i,t),Ei.subVectors(e,t),Wn.cross(Ei).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),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 Wn.subVectors(this.c,this.b),Ei.subVectors(this.a,this.b),Wn.cross(Ei).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return Tc===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Tc=!0),n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;Rs.subVectors(r,i),Is.subVectors(s,i),Vh.subVectors(e,i);let c=Rs.dot(Vh),l=Is.dot(Vh);if(c<=0&&l<=0)return t.copy(i);kh.subVectors(e,r);let u=Rs.dot(kh),h=Is.dot(kh);if(u>=0&&h<=u)return t.copy(r);let f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(i).addScaledVector(Rs,o);Gh.subVectors(e,s);let d=Rs.dot(Gh),m=Is.dot(Gh);if(m>=0&&d<=m)return t.copy(s);let y=d*l-c*m;if(y<=0&&l>=0&&m<=0)return a=l/(l-m),t.copy(i).addScaledVector(Is,a);let g=u*m-d*h;if(g<=0&&h-u>=0&&d-m>=0)return jg.subVectors(s,r),a=(h-u)/(h-u+(d-m)),t.copy(r).addScaledVector(jg,a);let p=1/(g+y+f);return o=y*p,a=f*p,t.copy(i).addScaledVector(Rs,o).addScaledVector(Is,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},px={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},tr={h:0,s:0,l:0},Cc={h:0,s:0,l:0};oe=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,rt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=rt.workingColorSpace){return this.r=e,this.g=t,this.b=i,rt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=rt.workingColorSpace){if(e=gp(e,1),t=Ct(t,0,1),i=Ct(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Hh(o,s,e+1/3),this.g=Hh(o,s,e),this.b=Hh(o,s,e-1/3)}return rt.toWorkingColorSpace(this,r),this}setStyle(e,t=lt){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=lt){let i=px[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=js(e.r),this.g=js(e.g),this.b=js(e.b),this}copyLinearToSRGB(e){return this.r=Ph(e.r),this.g=Ph(e.g),this.b=Ph(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=lt){return rt.fromWorkingColorSpace(tn.copy(this),e),Math.round(Ct(tn.r*255,0,255))*65536+Math.round(Ct(tn.g*255,0,255))*256+Math.round(Ct(tn.b*255,0,255))}getHexString(e=lt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=rt.workingColorSpace){rt.fromWorkingColorSpace(tn.copy(this),t);let i=tn.r,r=tn.g,s=tn.b,o=Math.max(i,r,s),a=Math.min(i,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case i:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-i)/h+2;break;case s:c=(i-r)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=rt.workingColorSpace){return rt.fromWorkingColorSpace(tn.copy(this),t),e.r=tn.r,e.g=tn.g,e.b=tn.b,e}getStyle(e=lt){rt.fromWorkingColorSpace(tn.copy(this),e);let t=tn.r,i=tn.g,r=tn.b;return e!==lt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(tr),this.setHSL(tr.h+e,tr.s+t,tr.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(tr),e.getHSL(Cc);let i=Ko(tr.h,Cc.h,t),r=Ko(tr.s,Cc.s,t),s=Ko(tr.l,Cc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},tn=new oe;oe.NAMES=px;Nv=0,It=class extends $n{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Nv++}),this.uuid=wn(),this.name="",this.type="Material",this.blending=Yr,this.side=qn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yl,this.blendDst=xl,this.blendEquation=rr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=ta,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Xf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Vr,this.stencilZFail=Vr,this.stencilZPass=Vr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===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(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Yr&&(i.blending=this.blending),this.side!==qn&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==yl&&(i.blendSrc=this.blendSrc),this.blendDst!==xl&&(i.blendDst=this.blendDst),this.blendEquation!==rr&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ta&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Xf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Vr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Vr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Vr&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}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,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,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++}},sn=class extends It{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=za,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ci=Lv();Ov={toHalfFloat:pn,fromHalfFloat:$o},Ot=new w,Rc=new Z,Ze=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=aa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Xn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Rc.fromBufferAttribute(this,t),Rc.applyMatrix3(e),this.setXY(t,Rc.x,Rc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ot.fromBufferAttribute(this,t),Ot.applyMatrix3(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ot.fromBufferAttribute(this,t),Ot.applyMatrix4(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ot.fromBufferAttribute(this,t),Ot.applyNormalMatrix(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ot.fromBufferAttribute(this,t),Ot.transformDirection(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=gn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=We(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=gn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=gn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=gn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=gn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array),s=We(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==aa&&(e.usage=this.usage),e}},Zf=class extends Ze{constructor(e,t,i){super(new Int8Array(e),t,i)}},Jf=class extends Ze{constructor(e,t,i){super(new Uint8Array(e),t,i)}},Qf=class extends Ze{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},ed=class extends Ze{constructor(e,t,i){super(new Int16Array(e),t,i)}},fa=class extends Ze{constructor(e,t,i){super(new Uint16Array(e),t,i)}},td=class extends Ze{constructor(e,t,i){super(new Int32Array(e),t,i)}},da=class extends Ze{constructor(e,t,i){super(new Uint32Array(e),t,i)}},nd=class extends Ze{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=$o(this.array[e*this.itemSize]);return this.normalized&&(t=gn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=pn(t),this}getY(e){let t=$o(this.array[e*this.itemSize+1]);return this.normalized&&(t=gn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=pn(t),this}getZ(e){let t=$o(this.array[e*this.itemSize+2]);return this.normalized&&(t=gn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=pn(t),this}getW(e){let t=$o(this.array[e*this.itemSize+3]);return this.normalized&&(t=gn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=pn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array)),this.array[e+0]=pn(t),this.array[e+1]=pn(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array)),this.array[e+0]=pn(t),this.array[e+1]=pn(i),this.array[e+2]=pn(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array),s=We(s,this.array)),this.array[e+0]=pn(t),this.array[e+1]=pn(i),this.array[e+2]=pn(r),this.array[e+3]=pn(s),this}},ye=class extends Ze{constructor(e,t,i){super(new Float32Array(e),t,i)}},id=class extends Ze{constructor(e,t,i){super(new Float64Array(e),t,i)}},Dv=0,Ln=new we,Wh=new it,Ps=new w,An=new xt,ko=new xt,Wt=new w,Be=class n extends $n{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Dv++}),this.uuid=wn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(fx(e)?da:fa)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Ye().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ln.makeRotationFromQuaternion(e),this.applyMatrix4(Ln),this}rotateX(e){return Ln.makeRotationX(e),this.applyMatrix4(Ln),this}rotateY(e){return Ln.makeRotationY(e),this.applyMatrix4(Ln),this}rotateZ(e){return Ln.makeRotationZ(e),this.applyMatrix4(Ln),this}translate(e,t,i){return Ln.makeTranslation(e,t,i),this.applyMatrix4(Ln),this}scale(e,t,i){return Ln.makeScale(e,t,i),this.applyMatrix4(Ln),this}lookAt(e){return Wh.lookAt(e),Wh.updateMatrix(),this.applyMatrix4(Wh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ps).negate(),this.translate(Ps.x,Ps.y,Ps.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new ye(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];An.setFromBufferAttribute(s),this.morphTargetsRelative?(Wt.addVectors(this.boundingBox.min,An.min),this.boundingBox.expandByPoint(Wt),Wt.addVectors(this.boundingBox.max,An.max),this.boundingBox.expandByPoint(Wt)):(this.boundingBox.expandByPoint(An.min),this.boundingBox.expandByPoint(An.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _t);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new w,1/0);return}if(e){let i=this.boundingSphere.center;if(An.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];ko.setFromBufferAttribute(a),this.morphTargetsRelative?(Wt.addVectors(An.min,ko.min),An.expandByPoint(Wt),Wt.addVectors(An.max,ko.max),An.expandByPoint(Wt)):(An.expandByPoint(ko.min),An.expandByPoint(ko.max))}An.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Wt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Wt));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Wt.fromBufferAttribute(a,l),c&&(Ps.fromBufferAttribute(e,l),Wt.add(Ps)),r=Math.max(r,i.distanceToSquared(Wt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=e.array,r=t.position.array,s=t.normal.array,o=t.uv.array,a=r.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ze(new Float32Array(4*a),4));let c=this.getAttribute("tangent").array,l=[],u=[];for(let v=0;v<a;v++)l[v]=new w,u[v]=new w;let h=new w,f=new w,d=new w,m=new Z,y=new Z,g=new Z,p=new w,_=new w;function x(v,L,U){h.fromArray(r,v*3),f.fromArray(r,L*3),d.fromArray(r,U*3),m.fromArray(o,v*2),y.fromArray(o,L*2),g.fromArray(o,U*2),f.sub(h),d.sub(h),y.sub(m),g.sub(m);let G=1/(y.x*g.y-g.x*y.y);isFinite(G)&&(p.copy(f).multiplyScalar(g.y).addScaledVector(d,-y.y).multiplyScalar(G),_.copy(d).multiplyScalar(y.x).addScaledVector(f,-g.x).multiplyScalar(G),l[v].add(p),l[L].add(p),l[U].add(p),u[v].add(_),u[L].add(_),u[U].add(_))}let b=this.groups;b.length===0&&(b=[{start:0,count:i.length}]);for(let v=0,L=b.length;v<L;++v){let U=b[v],G=U.start,P=U.count;for(let D=G,z=G+P;D<z;D+=3)x(i[D+0],i[D+1],i[D+2])}let T=new w,A=new w,M=new w,C=new w;function S(v){M.fromArray(s,v*3),C.copy(M);let L=l[v];T.copy(L),T.sub(M.multiplyScalar(M.dot(L))).normalize(),A.crossVectors(C,L);let G=A.dot(u[v])<0?-1:1;c[v*4]=T.x,c[v*4+1]=T.y,c[v*4+2]=T.z,c[v*4+3]=G}for(let v=0,L=b.length;v<L;++v){let U=b[v],G=U.start,P=U.count;for(let D=G,z=G+P;D<z;D+=3)S(i[D+0]),S(i[D+1]),S(i[D+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ze(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let f=0,d=i.count;f<d;f++)i.setXYZ(f,0,0,0);let r=new w,s=new w,o=new w,a=new w,c=new w,l=new w,u=new w,h=new w;if(e)for(let f=0,d=e.count;f<d;f+=3){let m=e.getX(f+0),y=e.getX(f+1),g=e.getX(f+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(i,m),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,g),a.add(u),c.add(u),l.add(u),i.setXYZ(m,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let f=0,d=t.count;f<d;f+=3)r.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),i.setXYZ(f+0,u.x,u.y,u.z),i.setXYZ(f+1,u.x,u.y,u.z),i.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Wt.fromBufferAttribute(e,t),Wt.normalize(),e.setXYZ(t,Wt.x,Wt.y,Wt.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u),d=0,m=0;for(let y=0,g=c.length;y<g;y++){a.isInterleavedBufferAttribute?d=c[y]*a.data.stride+a.offset:d=c[y]*u;for(let p=0;p<u;p++)f[m++]=l[d++]}return new Ze(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,i);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){let f=l[u],d=e(f,i);c.push(d)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);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 i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){let d=l[h];u.push(d.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.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 i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],h=s[l];for(let f=0,d=h.length;f<d;f++)u.push(h[f].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},$g=new we,Nr=new ur,Ic=new _t,Kg=new w,Ns=new w,Ls=new w,Os=new w,Xh=new w,Pc=new w,Nc=new Z,Lc=new Z,Oc=new Z,Zg=new w,Jg=new w,Qg=new w,Dc=new w,Uc=new w,ft=class extends it{constructor(e=new Be,t=new sn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Pc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],h=s[c];u!==0&&(Xh.fromBufferAttribute(h,e),o?Pc.addScaledVector(Xh,u):Pc.addScaledVector(Xh.sub(t),u))}t.add(Pc)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ic.copy(i.boundingSphere),Ic.applyMatrix4(s),Nr.copy(e.ray).recast(e.near),!(Ic.containsPoint(Nr.origin)===!1&&(Nr.intersectSphere(Ic,Kg)===null||Nr.origin.distanceToSquared(Kg)>(e.far-e.near)**2))&&($g.copy(s).invert(),Nr.copy(e.ray).applyMatrix4($g),!(i.boundingBox!==null&&Nr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Nr)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,y=f.length;m<y;m++){let g=f[m],p=o[g.materialIndex],_=Math.max(g.start,d.start),x=Math.min(a.count,Math.min(g.start+g.count,d.start+d.count));for(let b=_,T=x;b<T;b+=3){let A=a.getX(b),M=a.getX(b+1),C=a.getX(b+2);r=Fc(this,p,e,i,l,u,h,A,M,C),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let m=Math.max(0,d.start),y=Math.min(a.count,d.start+d.count);for(let g=m,p=y;g<p;g+=3){let _=a.getX(g),x=a.getX(g+1),b=a.getX(g+2);r=Fc(this,o,e,i,l,u,h,_,x,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let m=0,y=f.length;m<y;m++){let g=f[m],p=o[g.materialIndex],_=Math.max(g.start,d.start),x=Math.min(c.count,Math.min(g.start+g.count,d.start+d.count));for(let b=_,T=x;b<T;b+=3){let A=b,M=b+1,C=b+2;r=Fc(this,p,e,i,l,u,h,A,M,C),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let m=Math.max(0,d.start),y=Math.min(c.count,d.start+d.count);for(let g=m,p=y;g<p;g+=3){let _=g,x=g+1,b=g+2;r=Fc(this,o,e,i,l,u,h,_,x,b),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};Qr=class n extends Be{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],h=[],f=0,d=0;m("z","y","x",-1,-1,i,t,e,o,s,0),m("z","y","x",1,-1,i,t,-e,o,s,1),m("x","z","y",1,1,e,i,t,r,o,2),m("x","z","y",1,-1,e,i,-t,r,o,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new ye(l,3)),this.setAttribute("normal",new ye(u,3)),this.setAttribute("uv",new ye(h,2));function m(y,g,p,_,x,b,T,A,M,C,S){let v=b/M,L=T/C,U=b/2,G=T/2,P=A/2,D=M+1,z=C+1,q=0,Y=0,W=new w;for(let j=0;j<z;j++){let J=j*L-G;for(let le=0;le<D;le++){let X=le*v-U;W[y]=X*_,W[g]=J*x,W[p]=P,l.push(W.x,W.y,W.z),W[y]=0,W[g]=0,W[p]=A>0?1:-1,u.push(W.x,W.y,W.z),h.push(le/M),h.push(1-j/C),q+=1}}for(let j=0;j<C;j++)for(let J=0;J<M;J++){let le=f+J+D*j,X=f+J+D*(j+1),Q=f+(J+1)+D*(j+1),ue=f+(J+1)+D*j;c.push(le,X,ue),c.push(X,Q,ue),Y+=6}a.addGroup(d,Y,S),d+=Y,f+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};Wa={clone:no,merge:un},Bv=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,zv=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,yn=class extends It{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Bv,this.fragmentShader=zv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=no(e.uniforms),this.uniformsGroups=Fv(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},io=class extends it{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new we,this.projectionMatrix=new we,this.projectionMatrixInverse=new we,this.coordinateSystem=Yn}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)}},vt=class extends io{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,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=Qs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(jr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Qs*2*Math.atan(Math.tan(jr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,s,o){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=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(jr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,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}},Ds=-90,Us=1,Ml=class extends it{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new vt(Ds,Us,e,t);r.layers=this.layers,this.add(r);let s=new vt(Ds,Us,e,t);s.layers=this.layers,this.add(s);let o=new vt(Ds,Us,e,t);o.layers=this.layers,this.add(o);let a=new vt(Ds,Us,e,t);a.layers=this.layers,this.add(a);let c=new vt(Ds,Us,e,t);c.layers=this.layers,this.add(c);let l=new vt(Ds,Us,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===Yn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Js)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,h=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(h,f,d),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}},es=class extends Rt{constructor(e,t,i,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Bi,super(e,t,i,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},vl=class extends Tn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];t.encoding!==void 0&&(Zo("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===ar?lt:En),this.texture=new es(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:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:yt}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 i={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 <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},r=new Qr(5,5,5),s=new yn({name:"CubemapFromEquirect",uniforms:no(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:hn,blending:Li});s.uniforms.tEquirect.value=t;let o=new ft(r,s),a=t.minFilter;return t.minFilter===jn&&(t.minFilter=yt),new Ml(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},Yh=new w,Vv=new w,kv=new Ye,oi=class{constructor(e=new w(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,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Yh.subVectors(i,t).cross(Vv.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 i=e.delta(Yh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||kv.getNormalMatrix(e),r=this.coplanarPoint(Yh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Lr=new _t,Bc=new w,ts=class{constructor(e=new oi,t=new oi,i=new oi,r=new oi,s=new oi,o=new oi){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Yn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],f=r[7],d=r[8],m=r[9],y=r[10],g=r[11],p=r[12],_=r[13],x=r[14],b=r[15];if(i[0].setComponents(c-s,f-l,g-d,b-p).normalize(),i[1].setComponents(c+s,f+l,g+d,b+p).normalize(),i[2].setComponents(c+o,f+u,g+m,b+_).normalize(),i[3].setComponents(c-o,f-u,g-m,b-_).normalize(),i[4].setComponents(c-a,f-h,g-y,b-x).normalize(),t===Yn)i[5].setComponents(c+a,f+h,g+y,b+x).normalize();else if(t===Js)i[5].setComponents(a,h,y,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){return Lr.center.set(0,0,0),Lr.radius=.7071067811865476,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Bc.x=r.normal.x>0?e.max.x:e.min.x,Bc.y=r.normal.y>0?e.max.y:e.min.y,Bc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Bc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};ns=class n extends Be{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,u=c+1,h=e/a,f=t/c,d=[],m=[],y=[],g=[];for(let p=0;p<u;p++){let _=p*f-o;for(let x=0;x<l;x++){let b=x*h-s;m.push(b,-_,0),y.push(0,0,1),g.push(x/a),g.push(1-p/c)}}for(let p=0;p<c;p++)for(let _=0;_<a;_++){let x=_+l*p,b=_+l*(p+1),T=_+1+l*(p+1),A=_+1+l*p;d.push(x,b,A),d.push(b,T,A)}this.setIndex(d),this.setAttribute("position",new ye(m,3)),this.setAttribute("normal",new ye(y,3)),this.setAttribute("uv",new ye(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},Hv=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,Wv=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
}
float hash3D( vec3 value ) {
return hash2D( vec2( hash2D( value.xy ), value.z ) );
}
float getAlphaHashThreshold( vec3 position ) {
float maxDeriv = max(
length( dFdx( position.xyz ) ),
length( dFdy( position.xyz ) )
);
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
vec2 pixScales = vec2(
exp2( floor( log2( pixScale ) ) ),
exp2( ceil( log2( pixScale ) ) )
);
vec2 alpha = vec2(
hash3D( floor( pixScales.x * position.xyz ) ),
hash3D( floor( pixScales.y * position.xyz ) )
);
float lerpFactor = fract( log2( pixScale ) );
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
float a = min( lerpFactor, 1.0 - lerpFactor );
vec3 cases = vec3(
x * x / ( 2.0 * a * ( 1.0 - a ) ),
( x - 0.5 * a ) / ( 1.0 - a ),
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
);
float threshold = ( x < ( 1.0 - a ) )
? ( ( x < a ) ? cases.x : cases.y )
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
#endif`,Xv=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,Yv=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,qv=`#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
#endif`,jv=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,$v=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,Kv=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,Zv=`#ifdef USE_BATCHING
attribute float batchId;
uniform highp sampler2D batchingTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,Jv=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( batchId );
#endif`,Qv=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,eA=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,tA=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated`,nA=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,iA=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vBumpMapUv );
vec2 dSTdy = dFdy( vBumpMapUv );
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,rA=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#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`,sA=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,oA=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,aA=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,cA=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,lA=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,uA=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
varying vec3 vColor;
#endif`,hA=`#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`,fA=`#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`,dA=`#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`,pA=`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`,mA=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,gA=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,yA=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,xA=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,_A="gl_FragColor = linearToOutputTexel( gl_FragColor );",SA=`
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 );
}`,bA=`#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, 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`,MA=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,vA=`#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`,AA=`#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`,EA=`#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`,wA=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,TA=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,CA=`#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`,RA=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,IA=`#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
}`,PA=`#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`,NA=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,LA=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,OA=`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`,DA=`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`,UA=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, 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, 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`,FA=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,BA=`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`,zA=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,VA=`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`,kA=`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_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`,GA=`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
#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 );
}`,HA=`
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`,WA=`#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`,XA=`#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`,YA=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,qA=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,jA=`#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
varying float vIsPerspective;
#else
uniform float logDepthBufFC;
#endif
#endif`,$A=`#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#else
if ( isPerspectiveMatrix( projectionMatrix ) ) {
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
gl_Position.z *= gl_Position.w;
}
#endif
#endif`,KA=`#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`,ZA=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,JA=`#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`,QA=`#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`,eE=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,tE=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,nE=`#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`,iE=`#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`,rE=`#ifdef USE_MORPHTARGETS
uniform float morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
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`,sE=`#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`,oE=`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;`,aE=`#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`,cE=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,lE=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,uE=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,hE=`#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`,fE=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,dE=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,pE=`#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`,mE=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,gE=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,yE=`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 );
}`,xE=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,_E=`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;`,SE=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,bE=`#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`,ME=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,vE=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,AE=`#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 ) {
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
vec3 lightToPosition = shadowCoord.xyz;
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
return (
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
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
#endif`,EE=`#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`,wE=`#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`,TE=`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;
}`,CE=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,RE=`#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`,IE=`#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`,PE=`#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`,NE=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,LE=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,OE=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,DE=`#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 = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color *= toneMappingExposure;
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;
return color;
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,UE=`#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.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,FE=`#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 ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
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;
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
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`,BE=`#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`,zE=`#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`,VE=`#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`,kE=`#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`,GE=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,HE=`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 <tonemapping_fragment>
#include <colorspace_fragment>
}`,WE=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,XE=`#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;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,YE=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,qE=`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 <tonemapping_fragment>
#include <colorspace_fragment>
}`,jE=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,$E=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
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
}`,KE=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,ZE=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
}`,JE=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,QE=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,ew=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,tw=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,nw=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,iw=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
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 <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,rw=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,sw=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,ow=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,aw=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
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 <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,cw=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,lw=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,uw=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,hw=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,fw=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,dw=`#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_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 <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
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 <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,pw=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,mw=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,gw=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#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 <color_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,yw=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,xw=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,_w=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,Sw=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
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 <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,bw=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,He={alphahash_fragment:Hv,alphahash_pars_fragment:Wv,alphamap_fragment:Xv,alphamap_pars_fragment:Yv,alphatest_fragment:qv,alphatest_pars_fragment:jv,aomap_fragment:$v,aomap_pars_fragment:Kv,batching_pars_vertex:Zv,batching_vertex:Jv,begin_vertex:Qv,beginnormal_vertex:eA,bsdfs:tA,iridescence_fragment:nA,bumpmap_pars_fragment:iA,clipping_planes_fragment:rA,clipping_planes_pars_fragment:sA,clipping_planes_pars_vertex:oA,clipping_planes_vertex:aA,color_fragment:cA,color_pars_fragment:lA,color_pars_vertex:uA,color_vertex:hA,common:fA,cube_uv_reflection_fragment:dA,defaultnormal_vertex:pA,displacementmap_pars_vertex:mA,displacementmap_vertex:gA,emissivemap_fragment:yA,emissivemap_pars_fragment:xA,colorspace_fragment:_A,colorspace_pars_fragment:SA,envmap_fragment:bA,envmap_common_pars_fragment:MA,envmap_pars_fragment:vA,envmap_pars_vertex:AA,envmap_physical_pars_fragment:UA,envmap_vertex:EA,fog_vertex:wA,fog_pars_vertex:TA,fog_fragment:CA,fog_pars_fragment:RA,gradientmap_pars_fragment:IA,lightmap_fragment:PA,lightmap_pars_fragment:NA,lights_lambert_fragment:LA,lights_lambert_pars_fragment:OA,lights_pars_begin:DA,lights_toon_fragment:FA,lights_toon_pars_fragment:BA,lights_phong_fragment:zA,lights_phong_pars_fragment:VA,lights_physical_fragment:kA,lights_physical_pars_fragment:GA,lights_fragment_begin:HA,lights_fragment_maps:WA,lights_fragment_end:XA,logdepthbuf_fragment:YA,logdepthbuf_pars_fragment:qA,logdepthbuf_pars_vertex:jA,logdepthbuf_vertex:$A,map_fragment:KA,map_pars_fragment:ZA,map_particle_fragment:JA,map_particle_pars_fragment:QA,metalnessmap_fragment:eE,metalnessmap_pars_fragment:tE,morphcolor_vertex:nE,morphnormal_vertex:iE,morphtarget_pars_vertex:rE,morphtarget_vertex:sE,normal_fragment_begin:oE,normal_fragment_maps:aE,normal_pars_fragment:cE,normal_pars_vertex:lE,normal_vertex:uE,normalmap_pars_fragment:hE,clearcoat_normal_fragment_begin:fE,clearcoat_normal_fragment_maps:dE,clearcoat_pars_fragment:pE,iridescence_pars_fragment:mE,opaque_fragment:gE,packing:yE,premultiplied_alpha_fragment:xE,project_vertex:_E,dithering_fragment:SE,dithering_pars_fragment:bE,roughnessmap_fragment:ME,roughnessmap_pars_fragment:vE,shadowmap_pars_fragment:AE,shadowmap_pars_vertex:EE,shadowmap_vertex:wE,shadowmask_pars_fragment:TE,skinbase_vertex:CE,skinning_pars_vertex:RE,skinning_vertex:IE,skinnormal_vertex:PE,specularmap_fragment:NE,specularmap_pars_fragment:LE,tonemapping_fragment:OE,tonemapping_pars_fragment:DE,transmission_fragment:UE,transmission_pars_fragment:FE,uv_pars_fragment:BE,uv_pars_vertex:zE,uv_vertex:VE,worldpos_vertex:kE,background_vert:GE,background_frag:HE,backgroundCube_vert:WE,backgroundCube_frag:XE,cube_vert:YE,cube_frag:qE,depth_vert:jE,depth_frag:$E,distanceRGBA_vert:KE,distanceRGBA_frag:ZE,equirect_vert:JE,equirect_frag:QE,linedashed_vert:ew,linedashed_frag:tw,meshbasic_vert:nw,meshbasic_frag:iw,meshlambert_vert:rw,meshlambert_frag:sw,meshmatcap_vert:ow,meshmatcap_frag:aw,meshnormal_vert:cw,meshnormal_frag:lw,meshphong_vert:uw,meshphong_frag:hw,meshphysical_vert:fw,meshphysical_frag:dw,meshtoon_vert:pw,meshtoon_frag:mw,points_vert:gw,points_frag:yw,shadow_vert:xw,shadow_frag:_w,sprite_vert:Sw,sprite_frag:bw},se={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ye},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ye}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ye}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ye}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ye},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ye},normalScale:{value:new Z(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ye},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ye}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ye}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ye}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(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 oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0},uvTransform:{value:new Ye}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Z(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ye},alphaMap:{value:null},alphaMapTransform:{value:new Ye},alphaTest:{value:0}}},rn={basic:{uniforms:un([se.common,se.specularmap,se.envmap,se.aomap,se.lightmap,se.fog]),vertexShader:He.meshbasic_vert,fragmentShader:He.meshbasic_frag},lambert:{uniforms:un([se.common,se.specularmap,se.envmap,se.aomap,se.lightmap,se.emissivemap,se.bumpmap,se.normalmap,se.displacementmap,se.fog,se.lights,{emissive:{value:new oe(0)}}]),vertexShader:He.meshlambert_vert,fragmentShader:He.meshlambert_frag},phong:{uniforms:un([se.common,se.specularmap,se.envmap,se.aomap,se.lightmap,se.emissivemap,se.bumpmap,se.normalmap,se.displacementmap,se.fog,se.lights,{emissive:{value:new oe(0)},specular:{value:new oe(1118481)},shininess:{value:30}}]),vertexShader:He.meshphong_vert,fragmentShader:He.meshphong_frag},standard:{uniforms:un([se.common,se.envmap,se.aomap,se.lightmap,se.emissivemap,se.bumpmap,se.normalmap,se.displacementmap,se.roughnessmap,se.metalnessmap,se.fog,se.lights,{emissive:{value:new oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag},toon:{uniforms:un([se.common,se.aomap,se.lightmap,se.emissivemap,se.bumpmap,se.normalmap,se.displacementmap,se.gradientmap,se.fog,se.lights,{emissive:{value:new oe(0)}}]),vertexShader:He.meshtoon_vert,fragmentShader:He.meshtoon_frag},matcap:{uniforms:un([se.common,se.bumpmap,se.normalmap,se.displacementmap,se.fog,{matcap:{value:null}}]),vertexShader:He.meshmatcap_vert,fragmentShader:He.meshmatcap_frag},points:{uniforms:un([se.points,se.fog]),vertexShader:He.points_vert,fragmentShader:He.points_frag},dashed:{uniforms:un([se.common,se.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:He.linedashed_vert,fragmentShader:He.linedashed_frag},depth:{uniforms:un([se.common,se.displacementmap]),vertexShader:He.depth_vert,fragmentShader:He.depth_frag},normal:{uniforms:un([se.common,se.bumpmap,se.normalmap,se.displacementmap,{opacity:{value:1}}]),vertexShader:He.meshnormal_vert,fragmentShader:He.meshnormal_frag},sprite:{uniforms:un([se.sprite,se.fog]),vertexShader:He.sprite_vert,fragmentShader:He.sprite_frag},background:{uniforms:{uvTransform:{value:new Ye},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:He.background_vert,fragmentShader:He.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:He.backgroundCube_vert,fragmentShader:He.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:He.cube_vert,fragmentShader:He.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:He.equirect_vert,fragmentShader:He.equirect_frag},distanceRGBA:{uniforms:un([se.common,se.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:He.distanceRGBA_vert,fragmentShader:He.distanceRGBA_frag},shadow:{uniforms:un([se.lights,se.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:He.shadow_vert,fragmentShader:He.shadow_frag}};rn.physical={uniforms:un([rn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ye},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ye},clearcoatNormalScale:{value:new Z(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ye},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ye},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ye},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ye},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ye},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ye},transmissionSamplerSize:{value:new Z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ye},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ye},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ye},anisotropyVector:{value:new Z},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ye}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag};zc={r:0,b:0,g:0};ci=class extends io{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,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,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,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),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,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}},Xs=4,e0=[.125,.215,.35,.446,.526,.582],Gr=20,qh=new ci,t0=new oe,jh=null,$h=0,Kh=0,kr=(1+Math.sqrt(5))/2,Fs=1/kr,n0=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,kr,Fs),new w(0,kr,-Fs),new w(Fs,0,kr),new w(-Fs,0,kr),new w(kr,Fs,0),new w(-kr,Fs,0)],pa=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,i=.1,r=100){jh=this._renderer.getRenderTarget(),$h=this._renderer.getActiveCubeFace(),Kh=this._renderer.getActiveMipmapLevel(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=s0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=r0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(jh,$h,Kh),e.scissorTest=!1,Vc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Bi||e.mapping===cr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),jh=this._renderer.getRenderTarget(),$h=this._renderer.getActiveCubeFace(),Kh=this._renderer.getActiveMipmapLevel();let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:yt,minFilter:yt,generateMipmaps:!1,type:Zs,format:mn,colorSpace:Dt,depthBuffer:!1},r=i0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=i0(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Cw(s)),this._blurMaterial=Rw(s,e,t)}return r}_compileMaterial(e){let t=new ft(this._lodPlanes[0],e);this._renderer.compile(t,qh)}_sceneToCubeUV(e,t,i,r){let a=new vt(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(t0),u.toneMapping=Oi,u.autoClear=!1;let d=new sn({name:"PMREM.Background",side:hn,depthWrite:!1,depthTest:!1}),m=new ft(new Qr,d),y=!1,g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,y=!0):(d.color.copy(t0),y=!0);for(let p=0;p<6;p++){let _=p%3;_===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):_===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));let x=this._cubeSize;Vc(r,_*x,p>2?x:0,x,x),u.setRenderTarget(r),y&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Bi||e.mapping===cr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=s0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=r0());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new ft(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Vc(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,qh)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){let s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=n0[(r-1)%n0.length];this._blur(e,r-1,r,s,o)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ft(this._lodPlanes[r],l),f=l.uniforms,d=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Gr-1),y=s/m,g=isFinite(s)?1+Math.floor(u*y):Gr;g>Gr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Gr}`);let p=[],_=0;for(let M=0;M<Gr;++M){let C=M/y,S=Math.exp(-C*C/2);p.push(S),M===0?_+=S:M<g&&(_+=2*S)}for(let M=0;M<p.length;M++)p[M]=p[M]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:x}=this;f.dTheta.value=m,f.mipInt.value=x-i;let b=this._sizeLods[r],T=3*b*(r>x-Xs?r-x+Xs:0),A=4*(this._cubeSize-b);Vc(t,T,A,3*b,2*b),c.setRenderTarget(t),c.render(h,qh)}};ma=class extends Rt{constructor(e,t,i,r,s,o,a,c,l,u){if(u=u!==void 0?u:or,u!==or&&u!==Zr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===or&&(i=Ri),i===void 0&&u===Zr&&(i=sr),super(null,r,s,o,a,c,u,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Mt,this.minFilter=c!==void 0?c:Mt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},yx=new Rt,xx=new ma(1,1);xx.compareFunction=mp;_x=new eo,Sx=new ua,bx=new es,o0=[],a0=[],c0=new Float32Array(16),l0=new Float32Array(9),u0=new Float32Array(4);rd=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=rT(t.type)}},sd=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=AT(t.type)}},od=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},Zh=/(\w+)(\])?(\[|\.)?/g;$s=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);ET(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};wT=37297,TT=0;UT=/^[ \t]*#include +<([\w\d./]+)>/gm;FT=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);zT=/#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;qT=0,cd=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new ld(e),t.set(e,i)),i}},ld=class{constructor(e){this.id=qT++,this.code=e,this.usedTimes=0}};e1=0;ga=class extends It{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=nx,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}},ya=class extends It{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}},r1=`void main() {
gl_Position = vec4( position, 1.0 );
}`,s1=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
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 ) );
}`;Al=class extends vt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Dn=class extends it{constructor(){super(),this.isGroup=!0,this.type="Group"}},l1={type:"move"},Jo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dn,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 Dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),p=this._getHandJoint(l,y);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,m=.005;l.inputState.pinching&&f>d+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(l1)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Dn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},ud=class extends $n{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,m=null,y=t.getContextAttributes(),g=null,p=null,_=[],x=[],b=new Z,T=null,A=new vt;A.layers.enable(1),A.viewport=new tt;let M=new vt;M.layers.enable(2),M.viewport=new tt;let C=[A,M],S=new Al;S.layers.enable(1),S.layers.enable(2);let v=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getGripSpace()},this.getHand=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getHandSpace()};function U(X){let Q=x.indexOf(X.inputSource);if(Q===-1)return;let ue=_[Q];ue!==void 0&&(ue.update(X.inputSource,X.frame,l||o),ue.dispatchEvent({type:X.type,data:X.inputSource}))}function G(){r.removeEventListener("select",U),r.removeEventListener("selectstart",U),r.removeEventListener("selectend",U),r.removeEventListener("squeeze",U),r.removeEventListener("squeezestart",U),r.removeEventListener("squeezeend",U),r.removeEventListener("end",G),r.removeEventListener("inputsourceschange",P);for(let X=0;X<_.length;X++){let Q=x[X];Q!==null&&(x[X]=null,_[X].disconnect(Q))}v=null,L=null,e.setRenderTarget(g),d=null,f=null,h=null,r=null,p=null,le.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(b.width,b.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){a=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(X){l=X},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",U),r.addEventListener("selectstart",U),r.addEventListener("selectend",U),r.addEventListener("squeeze",U),r.addEventListener("squeezestart",U),r.addEventListener("squeezeend",U),r.addEventListener("end",G),r.addEventListener("inputsourceschange",P),y.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(b),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let Q={antialias:r.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,Q),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),p=new Tn(d.framebufferWidth,d.framebufferHeight,{format:mn,type:Di,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let Q=null,ue=null,xe=null;y.depth&&(xe=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Q=y.stencil?Zr:or,ue=y.stencil?sr:Ri);let he={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:s};h=new XRWebGLBinding(r,t),f=h.createProjectionLayer(he),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),p=new Tn(f.textureWidth,f.textureHeight,{format:mn,type:Di,depthTexture:new ma(f.textureWidth,f.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});let Ce=e.properties.get(p);Ce.__ignoreDepthValues=f.ignoreDepthValues}p.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),le.setContext(r),le.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function P(X){for(let Q=0;Q<X.removed.length;Q++){let ue=X.removed[Q],xe=x.indexOf(ue);xe>=0&&(x[xe]=null,_[xe].disconnect(ue))}for(let Q=0;Q<X.added.length;Q++){let ue=X.added[Q],xe=x.indexOf(ue);if(xe===-1){for(let Ce=0;Ce<_.length;Ce++)if(Ce>=x.length){x.push(ue),xe=Ce;break}else if(x[Ce]===null){x[Ce]=ue,xe=Ce;break}if(xe===-1)break}let he=_[xe];he&&he.connect(ue)}}let D=new w,z=new w;function q(X,Q,ue){D.setFromMatrixPosition(Q.matrixWorld),z.setFromMatrixPosition(ue.matrixWorld);let xe=D.distanceTo(z),he=Q.projectionMatrix.elements,Ce=ue.projectionMatrix.elements,De=he[14]/(he[10]-1),Me=he[14]/(he[10]+1),Ue=(he[9]+1)/he[5],N=(he[9]-1)/he[5],ae=(he[8]-1)/he[0],K=(Ce[8]+1)/Ce[0],re=De*ae,$=De*K,Ee=xe/(-ae+K),me=Ee*-ae;Q.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(me),X.translateZ(Ee),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();let R=De+Ee,E=Me+Ee,B=re-me,ie=$+(xe-me),te=Ue*Me/E*R,ee=N*Me/E*R;X.projectionMatrix.makePerspective(B,ie,te,ee,R,E),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function Y(X,Q){Q===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(Q.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;S.near=M.near=A.near=X.near,S.far=M.far=A.far=X.far,(v!==S.near||L!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),v=S.near,L=S.far);let Q=X.parent,ue=S.cameras;Y(S,Q);for(let xe=0;xe<ue.length;xe++)Y(ue[xe],Q);ue.length===2?q(S,A,M):S.projectionMatrix.copy(A.projectionMatrix),W(X,S,Q)};function W(X,Q,ue){ue===null?X.matrix.copy(Q.matrixWorld):(X.matrix.copy(ue.matrixWorld),X.matrix.invert(),X.matrix.multiply(Q.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(Q.projectionMatrix),X.projectionMatrixInverse.copy(Q.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Qs*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(X){c=X,f!==null&&(f.fixedFoveation=X),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=X)};let j=null;function J(X,Q){if(u=Q.getViewerPose(l||o),m=Q,u!==null){let ue=u.views;d!==null&&(e.setRenderTargetFramebuffer(p,d.framebuffer),e.setRenderTarget(p));let xe=!1;ue.length!==S.cameras.length&&(S.cameras.length=0,xe=!0);for(let he=0;he<ue.length;he++){let Ce=ue[he],De=null;if(d!==null)De=d.getViewport(Ce);else{let Ue=h.getViewSubImage(f,Ce);De=Ue.viewport,he===0&&(e.setRenderTargetTextures(p,Ue.colorTexture,f.ignoreDepthValues?void 0:Ue.depthStencilTexture),e.setRenderTarget(p))}let Me=C[he];Me===void 0&&(Me=new vt,Me.layers.enable(he),Me.viewport=new tt,C[he]=Me),Me.matrix.fromArray(Ce.transform.matrix),Me.matrix.decompose(Me.position,Me.quaternion,Me.scale),Me.projectionMatrix.fromArray(Ce.projectionMatrix),Me.projectionMatrixInverse.copy(Me.projectionMatrix).invert(),Me.viewport.set(De.x,De.y,De.width,De.height),he===0&&(S.matrix.copy(Me.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),xe===!0&&S.cameras.push(Me)}}for(let ue=0;ue<_.length;ue++){let xe=x[ue],he=_[ue];xe!==null&&he!==void 0&&he.update(xe,Q,l||o)}j&&j(X,Q),Q.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Q}),m=null}let le=new gx;le.setAnimationLoop(J),this.setAnimationLoop=function(X){j=X},this.dispose=function(){}}};El=class{constructor(e={}){let{canvas:t=dx(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=o;let d=new Uint32Array(4),m=new Int32Array(4),y=null,g=null,p=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=lt,this._useLegacyLights=!1,this.toneMapping=Oi,this.toneMappingExposure=1;let x=this,b=!1,T=0,A=0,M=null,C=-1,S=null,v=new tt,L=new tt,U=null,G=new oe(0),P=0,D=t.width,z=t.height,q=1,Y=null,W=null,j=new tt(0,0,D,z),J=new tt(0,0,D,z),le=!1,X=new ts,Q=!1,ue=!1,xe=null,he=new we,Ce=new Z,De=new w,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ue(){return M===null?q:1}let N=i;function ae(I,F){for(let k=0;k<I.length;k++){let H=I[k],V=t.getContext(H,F);if(V!==null)return V}return null}try{let I={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r160"),t.addEventListener("webglcontextlost",ce,!1),t.addEventListener("webglcontextrestored",O,!1),t.addEventListener("webglcontextcreationerror",de,!1),N===null){let F=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&F.shift(),N=ae(F,I),N===null)throw ae(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&N instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),N.getShaderPrecisionFormat===void 0&&(N.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let K,re,$,Ee,me,R,E,B,ie,te,ee,ve,fe,_e,Re,ke,ne,st,Ke,Fe,Te,be,Xe,ct;function Et(){K=new Pw(N),re=new Ew(N,K,e),K.init(re),be=new Mx(N,K,re),$=new a1(N,K,re),Ee=new Ow(N),me=new $T,R=new c1(N,K,$,me,re,be,Ee),E=new Tw(x),B=new Iw(x),ie=new Gv(N,re),Xe=new vw(N,K,ie,re),te=new Nw(N,ie,Ee,Xe),ee=new Bw(N,te,ie,Ee),Ke=new Fw(N,re,R),ke=new ww(me),ve=new jT(x,E,B,K,re,Xe,ke),fe=new u1(x,me),_e=new ZT,Re=new i1(K,re),st=new Mw(x,E,B,$,ee,f,c),ne=new o1(x,ee,re),ct=new h1(N,Ee,re,$),Fe=new Aw(N,K,Ee,re),Te=new Lw(N,K,Ee,re),Ee.programs=ve.programs,x.capabilities=re,x.extensions=K,x.properties=me,x.renderLists=_e,x.shadowMap=ne,x.state=$,x.info=Ee}Et();let je=new ud(x,N);this.xr=je,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let I=K.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){let I=K.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(I){I!==void 0&&(q=I,this.setSize(D,z,!1))},this.getSize=function(I){return I.set(D,z)},this.setSize=function(I,F,k=!0){if(je.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}D=I,z=F,t.width=Math.floor(I*q),t.height=Math.floor(F*q),k===!0&&(t.style.width=I+"px",t.style.height=F+"px"),this.setViewport(0,0,I,F)},this.getDrawingBufferSize=function(I){return I.set(D*q,z*q).floor()},this.setDrawingBufferSize=function(I,F,k){D=I,z=F,q=k,t.width=Math.floor(I*k),t.height=Math.floor(F*k),this.setViewport(0,0,I,F)},this.getCurrentViewport=function(I){return I.copy(v)},this.getViewport=function(I){return I.copy(j)},this.setViewport=function(I,F,k,H){I.isVector4?j.set(I.x,I.y,I.z,I.w):j.set(I,F,k,H),$.viewport(v.copy(j).multiplyScalar(q).floor())},this.getScissor=function(I){return I.copy(J)},this.setScissor=function(I,F,k,H){I.isVector4?J.set(I.x,I.y,I.z,I.w):J.set(I,F,k,H),$.scissor(L.copy(J).multiplyScalar(q).floor())},this.getScissorTest=function(){return le},this.setScissorTest=function(I){$.setScissorTest(le=I)},this.setOpaqueSort=function(I){Y=I},this.setTransparentSort=function(I){W=I},this.getClearColor=function(I){return I.copy(st.getClearColor())},this.setClearColor=function(){st.setClearColor.apply(st,arguments)},this.getClearAlpha=function(){return st.getClearAlpha()},this.setClearAlpha=function(){st.setClearAlpha.apply(st,arguments)},this.clear=function(I=!0,F=!0,k=!0){let H=0;if(I){let V=!1;if(M!==null){let ge=M.texture.format;V=ge===up||ge===lp||ge===cp}if(V){let ge=M.texture.type,Ae=ge===Di||ge===Ri||ge===_u||ge===sr||ge===op||ge===ap,Pe=st.getClearColor(),Le=st.getClearAlpha(),qe=Pe.r,Ve=Pe.g,Ge=Pe.b;Ae?(d[0]=qe,d[1]=Ve,d[2]=Ge,d[3]=Le,N.clearBufferuiv(N.COLOR,0,d)):(m[0]=qe,m[1]=Ve,m[2]=Ge,m[3]=Le,N.clearBufferiv(N.COLOR,0,m))}else H|=N.COLOR_BUFFER_BIT}F&&(H|=N.DEPTH_BUFFER_BIT),k&&(H|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(H)},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",ce,!1),t.removeEventListener("webglcontextrestored",O,!1),t.removeEventListener("webglcontextcreationerror",de,!1),_e.dispose(),Re.dispose(),me.dispose(),E.dispose(),B.dispose(),ee.dispose(),Xe.dispose(),ct.dispose(),ve.dispose(),je.dispose(),je.removeEventListener("sessionstart",an),je.removeEventListener("sessionend",mt),xe&&(xe.dispose(),xe=null),cn.stop()};function ce(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let I=Ee.autoReset,F=ne.enabled,k=ne.autoUpdate,H=ne.needsUpdate,V=ne.type;Et(),Ee.autoReset=I,ne.enabled=F,ne.autoUpdate=k,ne.needsUpdate=H,ne.type=V}function de(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function pe(I){let F=I.target;F.removeEventListener("dispose",pe),Ne(F)}function Ne(I){Ie(I),me.remove(I)}function Ie(I){let F=me.get(I).programs;F!==void 0&&(F.forEach(function(k){ve.releaseProgram(k)}),I.isShaderMaterial&&ve.releaseShaderCache(I))}this.renderBufferDirect=function(I,F,k,H,V,ge){F===null&&(F=Me);let Ae=V.isMesh&&V.matrixWorld.determinant()<0,Pe=lM(I,F,k,H,V);$.setMaterial(H,Ae);let Le=k.index,qe=1;if(H.wireframe===!0){if(Le=te.getWireframeAttribute(k),Le===void 0)return;qe=2}let Ve=k.drawRange,Ge=k.attributes.position,Pt=Ve.start*qe,Mn=(Ve.start+Ve.count)*qe;ge!==null&&(Pt=Math.max(Pt,ge.start*qe),Mn=Math.min(Mn,(ge.start+ge.count)*qe)),Le!==null?(Pt=Math.max(Pt,0),Mn=Math.min(Mn,Le.count)):Ge!=null&&(Pt=Math.max(Pt,0),Mn=Math.min(Mn,Ge.count));let Ht=Mn-Pt;if(Ht<0||Ht===1/0)return;Xe.setup(V,H,Pe,k,Le);let bi,bt=Fe;if(Le!==null&&(bi=ie.get(Le),bt=Te,bt.setIndex(bi)),V.isMesh)H.wireframe===!0?($.setLineWidth(H.wireframeLinewidth*Ue()),bt.setMode(N.LINES)):bt.setMode(N.TRIANGLES);else if(V.isLine){let $e=H.linewidth;$e===void 0&&($e=1),$.setLineWidth($e*Ue()),V.isLineSegments?bt.setMode(N.LINES):V.isLineLoop?bt.setMode(N.LINE_LOOP):bt.setMode(N.LINE_STRIP)}else V.isPoints?bt.setMode(N.POINTS):V.isSprite&&bt.setMode(N.TRIANGLES);if(V.isBatchedMesh)bt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)bt.renderInstances(Pt,Ht,V.count);else if(k.isInstancedBufferGeometry){let $e=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,bh=Math.min(k.instanceCount,$e);bt.renderInstances(Pt,Ht,bh)}else bt.render(Pt,Ht)};function dt(I,F,k){I.transparent===!0&&I.side===On&&I.forceSinglePass===!1?(I.side=hn,I.needsUpdate=!0,yc(I,F,k),I.side=qn,I.needsUpdate=!0,yc(I,F,k),I.side=On):yc(I,F,k)}this.compile=function(I,F,k=null){k===null&&(k=I),g=Re.get(k),g.init(),_.push(g),k.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(g.pushLight(V),V.castShadow&&g.pushShadow(V))}),I!==k&&I.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(g.pushLight(V),V.castShadow&&g.pushShadow(V))}),g.setupLights(x._useLegacyLights);let H=new Set;return I.traverse(function(V){let ge=V.material;if(ge)if(Array.isArray(ge))for(let Ae=0;Ae<ge.length;Ae++){let Pe=ge[Ae];dt(Pe,k,V),H.add(Pe)}else dt(ge,k,V),H.add(ge)}),_.pop(),g=null,H},this.compileAsync=function(I,F,k=null){let H=this.compile(I,F,k);return new Promise(V=>{function ge(){if(H.forEach(function(Ae){me.get(Ae).currentProgram.isReady()&&H.delete(Ae)}),H.size===0){V(I);return}setTimeout(ge,10)}K.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let pt=null;function Gt(I){pt&&pt(I)}function an(){cn.stop()}function mt(){cn.start()}let cn=new gx;cn.setAnimationLoop(Gt),typeof self<"u"&&cn.setContext(self),this.setAnimationLoop=function(I){pt=I,je.setAnimationLoop(I),I===null?cn.stop():cn.start()},je.addEventListener("sessionstart",an),je.addEventListener("sessionend",mt),this.render=function(I,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(F),F=je.getCamera()),I.isScene===!0&&I.onBeforeRender(x,I,F,M),g=Re.get(I,_.length),g.init(),_.push(g),he.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),X.setFromProjectionMatrix(he),ue=this.localClippingEnabled,Q=ke.init(this.clippingPlanes,ue),y=_e.get(I,p.length),y.init(),p.push(y),ri(I,F,0,x.sortObjects),y.finish(),x.sortObjects===!0&&y.sort(Y,W),this.info.render.frame++,Q===!0&&ke.beginShadows();let k=g.state.shadowsArray;if(ne.render(k,I,F),Q===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),st.render(y,I),g.setupLights(x._useLegacyLights),F.isArrayCamera){let H=F.cameras;for(let V=0,ge=H.length;V<ge;V++){let Ae=H[V];Sg(y,I,Ae,Ae.viewport)}}else Sg(y,I,F);M!==null&&(R.updateMultisampleRenderTarget(M),R.updateRenderTargetMipmap(M)),I.isScene===!0&&I.onAfterRender(x,I,F),Xe.resetDefaultState(),C=-1,S=null,_.pop(),_.length>0?g=_[_.length-1]:g=null,p.pop(),p.length>0?y=p[p.length-1]:y=null};function ri(I,F,k,H){if(I.visible===!1)return;if(I.layers.test(F.layers)){if(I.isGroup)k=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(F);else if(I.isLight)g.pushLight(I),I.castShadow&&g.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||X.intersectsSprite(I)){H&&De.setFromMatrixPosition(I.matrixWorld).applyMatrix4(he);let Ae=ee.update(I),Pe=I.material;Pe.visible&&y.push(I,Ae,Pe,k,De.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(!I.frustumCulled||X.intersectsObject(I))){let Ae=ee.update(I),Pe=I.material;if(H&&(I.boundingSphere!==void 0?(I.boundingSphere===null&&I.computeBoundingSphere(),De.copy(I.boundingSphere.center)):(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),De.copy(Ae.boundingSphere.center)),De.applyMatrix4(I.matrixWorld).applyMatrix4(he)),Array.isArray(Pe)){let Le=Ae.groups;for(let qe=0,Ve=Le.length;qe<Ve;qe++){let Ge=Le[qe],Pt=Pe[Ge.materialIndex];Pt&&Pt.visible&&y.push(I,Ae,Pt,k,De.z,Ge)}}else Pe.visible&&y.push(I,Ae,Pe,k,De.z,null)}}let ge=I.children;for(let Ae=0,Pe=ge.length;Ae<Pe;Ae++)ri(ge[Ae],F,k,H)}function Sg(I,F,k,H){let V=I.opaque,ge=I.transmissive,Ae=I.transparent;g.setupLightsView(k),Q===!0&&ke.setGlobalState(x.clippingPlanes,k),ge.length>0&&cM(V,ge,F,k),H&&$.viewport(v.copy(H)),V.length>0&&gc(V,F,k),ge.length>0&&gc(ge,F,k),Ae.length>0&&gc(Ae,F,k),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function cM(I,F,k,H){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;let ge=re.isWebGL2;xe===null&&(xe=new Tn(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?Zs:Di,minFilter:jn,samples:ge?4:0})),x.getDrawingBufferSize(Ce),ge?xe.setSize(Ce.x,Ce.y):xe.setSize(Sl(Ce.x),Sl(Ce.y));let Ae=x.getRenderTarget();x.setRenderTarget(xe),x.getClearColor(G),P=x.getClearAlpha(),P<1&&x.setClearColor(16777215,.5),x.clear();let Pe=x.toneMapping;x.toneMapping=Oi,gc(I,k,H),R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe);let Le=!1;for(let qe=0,Ve=F.length;qe<Ve;qe++){let Ge=F[qe],Pt=Ge.object,Mn=Ge.geometry,Ht=Ge.material,bi=Ge.group;if(Ht.side===On&&Pt.layers.test(H.layers)){let bt=Ht.side;Ht.side=hn,Ht.needsUpdate=!0,bg(Pt,k,H,Mn,Ht,bi),Ht.side=bt,Ht.needsUpdate=!0,Le=!0}}Le===!0&&(R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe)),x.setRenderTarget(Ae),x.setClearColor(G,P),x.toneMapping=Pe}function gc(I,F,k){let H=F.isScene===!0?F.overrideMaterial:null;for(let V=0,ge=I.length;V<ge;V++){let Ae=I[V],Pe=Ae.object,Le=Ae.geometry,qe=H===null?Ae.material:H,Ve=Ae.group;Pe.layers.test(k.layers)&&bg(Pe,F,k,Le,qe,Ve)}}function bg(I,F,k,H,V,ge){I.onBeforeRender(x,F,k,H,V,ge),I.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),V.onBeforeRender(x,F,k,H,I,ge),V.transparent===!0&&V.side===On&&V.forceSinglePass===!1?(V.side=hn,V.needsUpdate=!0,x.renderBufferDirect(k,F,H,V,I,ge),V.side=qn,V.needsUpdate=!0,x.renderBufferDirect(k,F,H,V,I,ge),V.side=On):x.renderBufferDirect(k,F,H,V,I,ge),I.onAfterRender(x,F,k,H,V,ge)}function yc(I,F,k){F.isScene!==!0&&(F=Me);let H=me.get(I),V=g.state.lights,ge=g.state.shadowsArray,Ae=V.state.version,Pe=ve.getParameters(I,V.state,ge,F,k),Le=ve.getProgramCacheKey(Pe),qe=H.programs;H.environment=I.isMeshStandardMaterial?F.environment:null,H.fog=F.fog,H.envMap=(I.isMeshStandardMaterial?B:E).get(I.envMap||H.environment),qe===void 0&&(I.addEventListener("dispose",pe),qe=new Map,H.programs=qe);let Ve=qe.get(Le);if(Ve!==void 0){if(H.currentProgram===Ve&&H.lightsStateVersion===Ae)return vg(I,Pe),Ve}else Pe.uniforms=ve.getUniforms(I),I.onBuild(k,Pe,x),I.onBeforeCompile(Pe,x),Ve=ve.acquireProgram(Pe,Le),qe.set(Le,Ve),H.uniforms=Pe.uniforms;let Ge=H.uniforms;return(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(Ge.clippingPlanes=ke.uniform),vg(I,Pe),H.needsLights=hM(I),H.lightsStateVersion=Ae,H.needsLights&&(Ge.ambientLightColor.value=V.state.ambient,Ge.lightProbe.value=V.state.probe,Ge.directionalLights.value=V.state.directional,Ge.directionalLightShadows.value=V.state.directionalShadow,Ge.spotLights.value=V.state.spot,Ge.spotLightShadows.value=V.state.spotShadow,Ge.rectAreaLights.value=V.state.rectArea,Ge.ltc_1.value=V.state.rectAreaLTC1,Ge.ltc_2.value=V.state.rectAreaLTC2,Ge.pointLights.value=V.state.point,Ge.pointLightShadows.value=V.state.pointShadow,Ge.hemisphereLights.value=V.state.hemi,Ge.directionalShadowMap.value=V.state.directionalShadowMap,Ge.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Ge.spotShadowMap.value=V.state.spotShadowMap,Ge.spotLightMatrix.value=V.state.spotLightMatrix,Ge.spotLightMap.value=V.state.spotLightMap,Ge.pointShadowMap.value=V.state.pointShadowMap,Ge.pointShadowMatrix.value=V.state.pointShadowMatrix),H.currentProgram=Ve,H.uniformsList=null,Ve}function Mg(I){if(I.uniformsList===null){let F=I.currentProgram.getUniforms();I.uniformsList=$s.seqWithValue(F.seq,I.uniforms)}return I.uniformsList}function vg(I,F){let k=me.get(I);k.outputColorSpace=F.outputColorSpace,k.batching=F.batching,k.instancing=F.instancing,k.instancingColor=F.instancingColor,k.skinning=F.skinning,k.morphTargets=F.morphTargets,k.morphNormals=F.morphNormals,k.morphColors=F.morphColors,k.morphTargetsCount=F.morphTargetsCount,k.numClippingPlanes=F.numClippingPlanes,k.numIntersection=F.numClipIntersection,k.vertexAlphas=F.vertexAlphas,k.vertexTangents=F.vertexTangents,k.toneMapping=F.toneMapping}function lM(I,F,k,H,V){F.isScene!==!0&&(F=Me),R.resetTextureUnits();let ge=F.fog,Ae=H.isMeshStandardMaterial?F.environment:null,Pe=M===null?x.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:Dt,Le=(H.isMeshStandardMaterial?B:E).get(H.envMap||Ae),qe=H.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Ve=!!k.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ge=!!k.morphAttributes.position,Pt=!!k.morphAttributes.normal,Mn=!!k.morphAttributes.color,Ht=Oi;H.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(Ht=x.toneMapping);let bi=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,bt=bi!==void 0?bi.length:0,$e=me.get(H),bh=g.state.lights;if(Q===!0&&(ue===!0||I!==S)){let Nn=I===S&&H.id===C;ke.setState(H,I,Nn)}let wt=!1;H.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==bh.state.version||$e.outputColorSpace!==Pe||V.isBatchedMesh&&$e.batching===!1||!V.isBatchedMesh&&$e.batching===!0||V.isInstancedMesh&&$e.instancing===!1||!V.isInstancedMesh&&$e.instancing===!0||V.isSkinnedMesh&&$e.skinning===!1||!V.isSkinnedMesh&&$e.skinning===!0||V.isInstancedMesh&&$e.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&$e.instancingColor===!1&&V.instanceColor!==null||$e.envMap!==Le||H.fog===!0&&$e.fog!==ge||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==ke.numPlanes||$e.numIntersection!==ke.numIntersection)||$e.vertexAlphas!==qe||$e.vertexTangents!==Ve||$e.morphTargets!==Ge||$e.morphNormals!==Pt||$e.morphColors!==Mn||$e.toneMapping!==Ht||re.isWebGL2===!0&&$e.morphTargetsCount!==bt)&&(wt=!0):(wt=!0,$e.__version=H.version);let Tr=$e.currentProgram;wt===!0&&(Tr=yc(H,F,V));let Ag=!1,Do=!1,Mh=!1,Qt=Tr.getUniforms(),Cr=$e.uniforms;if($.useProgram(Tr.program)&&(Ag=!0,Do=!0,Mh=!0),H.id!==C&&(C=H.id,Do=!0),Ag||S!==I){Qt.setValue(N,"projectionMatrix",I.projectionMatrix),Qt.setValue(N,"viewMatrix",I.matrixWorldInverse);let Nn=Qt.map.cameraPosition;Nn!==void 0&&Nn.setValue(N,De.setFromMatrixPosition(I.matrixWorld)),re.logarithmicDepthBuffer&&Qt.setValue(N,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Qt.setValue(N,"isOrthographic",I.isOrthographicCamera===!0),S!==I&&(S=I,Do=!0,Mh=!0)}if(V.isSkinnedMesh){Qt.setOptional(N,V,"bindMatrix"),Qt.setOptional(N,V,"bindMatrixInverse");let Nn=V.skeleton;Nn&&(re.floatVertexTextures?(Nn.boneTexture===null&&Nn.computeBoneTexture(),Qt.setValue(N,"boneTexture",Nn.boneTexture,R)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}V.isBatchedMesh&&(Qt.setOptional(N,V,"batchingTexture"),Qt.setValue(N,"batchingTexture",V._matricesTexture,R));let vh=k.morphAttributes;if((vh.position!==void 0||vh.normal!==void 0||vh.color!==void 0&&re.isWebGL2===!0)&&Ke.update(V,k,Tr),(Do||$e.receiveShadow!==V.receiveShadow)&&($e.receiveShadow=V.receiveShadow,Qt.setValue(N,"receiveShadow",V.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Cr.envMap.value=Le,Cr.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),Do&&(Qt.setValue(N,"toneMappingExposure",x.toneMappingExposure),$e.needsLights&&uM(Cr,Mh),ge&&H.fog===!0&&fe.refreshFogUniforms(Cr,ge),fe.refreshMaterialUniforms(Cr,H,q,z,xe),$s.upload(N,Mg($e),Cr,R)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&($s.upload(N,Mg($e),Cr,R),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Qt.setValue(N,"center",V.center),Qt.setValue(N,"modelViewMatrix",V.modelViewMatrix),Qt.setValue(N,"normalMatrix",V.normalMatrix),Qt.setValue(N,"modelMatrix",V.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){let Nn=H.uniformsGroups;for(let Ah=0,fM=Nn.length;Ah<fM;Ah++)if(re.isWebGL2){let Eg=Nn[Ah];ct.update(Eg,Tr),ct.bind(Eg,Tr)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Tr}function uM(I,F){I.ambientLightColor.needsUpdate=F,I.lightProbe.needsUpdate=F,I.directionalLights.needsUpdate=F,I.directionalLightShadows.needsUpdate=F,I.pointLights.needsUpdate=F,I.pointLightShadows.needsUpdate=F,I.spotLights.needsUpdate=F,I.spotLightShadows.needsUpdate=F,I.rectAreaLights.needsUpdate=F,I.hemisphereLights.needsUpdate=F}function hM(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(I,F,k){me.get(I.texture).__webglTexture=F,me.get(I.depthTexture).__webglTexture=k;let H=me.get(I);H.__hasExternalTextures=!0,H.__hasExternalTextures&&(H.__autoAllocateDepthBuffer=k===void 0,H.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(I,F){let k=me.get(I);k.__webglFramebuffer=F,k.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(I,F=0,k=0){M=I,T=F,A=k;let H=!0,V=null,ge=!1,Ae=!1;if(I){let Le=me.get(I);Le.__useDefaultFramebuffer!==void 0?($.bindFramebuffer(N.FRAMEBUFFER,null),H=!1):Le.__webglFramebuffer===void 0?R.setupRenderTarget(I):Le.__hasExternalTextures&&R.rebindTextures(I,me.get(I.texture).__webglTexture,me.get(I.depthTexture).__webglTexture);let qe=I.texture;(qe.isData3DTexture||qe.isDataArrayTexture||qe.isCompressedArrayTexture)&&(Ae=!0);let Ve=me.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(Array.isArray(Ve[F])?V=Ve[F][k]:V=Ve[F],ge=!0):re.isWebGL2&&I.samples>0&&R.useMultisampledRTT(I)===!1?V=me.get(I).__webglMultisampledFramebuffer:Array.isArray(Ve)?V=Ve[k]:V=Ve,v.copy(I.viewport),L.copy(I.scissor),U=I.scissorTest}else v.copy(j).multiplyScalar(q).floor(),L.copy(J).multiplyScalar(q).floor(),U=le;if($.bindFramebuffer(N.FRAMEBUFFER,V)&&re.drawBuffers&&H&&$.drawBuffers(I,V),$.viewport(v),$.scissor(L),$.setScissorTest(U),ge){let Le=me.get(I.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,Le.__webglTexture,k)}else if(Ae){let Le=me.get(I.texture),qe=F||0;N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,Le.__webglTexture,k||0,qe)}C=-1},this.readRenderTargetPixels=function(I,F,k,H,V,ge,Ae){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=me.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Ae!==void 0&&(Pe=Pe[Ae]),Pe){$.bindFramebuffer(N.FRAMEBUFFER,Pe);try{let Le=I.texture,qe=Le.format,Ve=Le.type;if(qe!==mn&&be.convert(qe)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Ge=Ve===Zs&&(K.has("EXT_color_buffer_half_float")||re.isWebGL2&&K.has("EXT_color_buffer_float"));if(Ve!==Di&&be.convert(Ve)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ve===Xn&&(re.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!Ge){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=I.width-H&&k>=0&&k<=I.height-V&&N.readPixels(F,k,H,V,be.convert(qe),be.convert(Ve),ge)}finally{let Le=M!==null?me.get(M).__webglFramebuffer:null;$.bindFramebuffer(N.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(I,F,k=0){let H=Math.pow(2,-k),V=Math.floor(F.image.width*H),ge=Math.floor(F.image.height*H);R.setTexture2D(F,0),N.copyTexSubImage2D(N.TEXTURE_2D,k,0,0,I.x,I.y,V,ge),$.unbindTexture()},this.copyTextureToTexture=function(I,F,k,H=0){let V=F.image.width,ge=F.image.height,Ae=be.convert(k.format),Pe=be.convert(k.type);R.setTexture2D(k,0),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,k.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,k.unpackAlignment),F.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,H,I.x,I.y,V,ge,Ae,Pe,F.image.data):F.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,H,I.x,I.y,F.mipmaps[0].width,F.mipmaps[0].height,Ae,F.mipmaps[0].data):N.texSubImage2D(N.TEXTURE_2D,H,I.x,I.y,Ae,Pe,F.image),H===0&&k.generateMipmaps&&N.generateMipmap(N.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(I,F,k,H,V=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ge=I.max.x-I.min.x+1,Ae=I.max.y-I.min.y+1,Pe=I.max.z-I.min.z+1,Le=be.convert(H.format),qe=be.convert(H.type),Ve;if(H.isData3DTexture)R.setTexture3D(H,0),Ve=N.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)R.setTexture2DArray(H,0),Ve=N.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,H.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,H.unpackAlignment);let Ge=N.getParameter(N.UNPACK_ROW_LENGTH),Pt=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Mn=N.getParameter(N.UNPACK_SKIP_PIXELS),Ht=N.getParameter(N.UNPACK_SKIP_ROWS),bi=N.getParameter(N.UNPACK_SKIP_IMAGES),bt=k.isCompressedTexture?k.mipmaps[V]:k.image;N.pixelStorei(N.UNPACK_ROW_LENGTH,bt.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,bt.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,I.min.x),N.pixelStorei(N.UNPACK_SKIP_ROWS,I.min.y),N.pixelStorei(N.UNPACK_SKIP_IMAGES,I.min.z),k.isDataTexture||k.isData3DTexture?N.texSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,qe,bt.data):k.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,bt.data)):N.texSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,qe,bt),N.pixelStorei(N.UNPACK_ROW_LENGTH,Ge),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Pt),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Mn),N.pixelStorei(N.UNPACK_SKIP_ROWS,Ht),N.pixelStorei(N.UNPACK_SKIP_IMAGES,bi),V===0&&H.generateMipmaps&&N.generateMipmap(Ve),$.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?R.setTextureCube(I,0):I.isData3DTexture?R.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?R.setTexture2DArray(I,0):R.setTexture2D(I,0),$.unbindTexture()},this.resetState=function(){T=0,A=0,M=null,$.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===bu?"display-p3":"srgb",t.unpackColorSpace=rt.workingColorSpace===Ga?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===lt?ar:pp}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ar?lt:Dt}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}},wl=class extends El{};wl.prototype.isWebGL1Renderer=!0;Tl=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new oe(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Cl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ro=class extends it{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){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}},Vi=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=aa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=wn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},ln=new w,Yt=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.applyMatrix4(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.applyNormalMatrix(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.transformDirection(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=gn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=gn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=gn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=gn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),i=We(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),i=We(i,this.array),r=We(r,this.array),s=We(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Ze(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},xa=class extends It{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Go=new w,zs=new w,Vs=new w,ks=new Z,Ho=new Z,vx=new we,kc=new w,Wo=new w,Gc=new w,b0=new Z,Jh=new Z,M0=new Z,Rl=class extends it{constructor(e=new xa){if(super(),this.isSprite=!0,this.type="Sprite",Bs===void 0){Bs=new Be;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Vi(t,5);Bs.setIndex([0,1,2,0,2,3]),Bs.setAttribute("position",new Yt(i,3,0,!1)),Bs.setAttribute("uv",new Yt(i,2,3,!1))}this.geometry=Bs,this.material=e,this.center=new Z(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),zs.setFromMatrixScale(this.matrixWorld),vx.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Vs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&zs.multiplyScalar(-Vs.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Hc(kc.set(-.5,-.5,0),Vs,o,zs,r,s),Hc(Wo.set(.5,-.5,0),Vs,o,zs,r,s),Hc(Gc.set(.5,.5,0),Vs,o,zs,r,s),b0.set(0,0),Jh.set(1,0),M0.set(1,1);let a=e.ray.intersectTriangle(kc,Wo,Gc,!1,Go);if(a===null&&(Hc(Wo.set(-.5,.5,0),Vs,o,zs,r,s),Jh.set(0,1),a=e.ray.intersectTriangle(kc,Gc,Wo,!1,Go),a===null))return;let c=e.ray.origin.distanceTo(Go);c<e.near||c>e.far||t.push({distance:c,point:Go.clone(),uv:Pi.getInterpolation(Go,kc,Wo,Gc,b0,Jh,M0,new Z),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}};Wc=new w,v0=new w,Il=class extends it{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 i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Wc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Wc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Wc.setFromMatrixPosition(e.matrixWorld),v0.setFromMatrixPosition(this.matrixWorld);let i=Wc.distanceTo(v0)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},A0=new w,E0=new tt,w0=new tt,f1=new w,T0=new we,Xc=new w,Qh=new _t,C0=new we,ef=new ur,so=class extends ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_f,this.bindMatrix=new we,this.bindMatrixInverse=new we,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new xt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Xc),this.boundingBox.expandByPoint(Xc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new _t),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Xc),this.boundingSphere.expandByPoint(Xc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Qh.copy(this.boundingSphere),Qh.applyMatrix4(r),e.ray.intersectsSphere(Qh)!==!1&&(C0.copy(r).invert(),ef.copy(e.ray).applyMatrix4(C0),!(this.boundingBox!==null&&ef.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ef)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new tt,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===_f?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Wy?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;E0.fromBufferAttribute(r.attributes.skinIndex,e),w0.fromBufferAttribute(r.attributes.skinWeight,e),A0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=w0.getComponent(s);if(o!==0){let a=E0.getComponent(s);T0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(f1.copy(A0).applyMatrix4(T0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}},is=class extends it{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ui=class extends Rt{constructor(e=null,t=1,i=1,r,s,o,a,c,l=Mt,u=Mt,h,f){super(null,o,a,c,l,u,r,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},R0=new we,d1=new we,oo=class n{constructor(e=[],t=[]){this.uuid=wn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new we)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new we;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:d1;R0.multiplyMatrices(a,t[s]),R0.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Ui(t,e,e,mn,Xn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new is),this.bones.push(o),this.boneInverses.push(new we().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Kn=class extends Ze{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Gs=new we,I0=new we,Yc=[],P0=new xt,p1=new we,Xo=new ft,Yo=new _t,ao=class extends ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Kn(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,p1)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new xt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gs),P0.copy(e.boundingBox).applyMatrix4(Gs),this.boundingBox.union(P0)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new _t),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gs),Yo.copy(e.boundingSphere).applyMatrix4(Gs),this.boundingSphere.union(Yo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Xo.geometry=this.geometry,Xo.material=this.material,Xo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yo.copy(this.boundingSphere),Yo.applyMatrix4(i),e.ray.intersectsSphere(Yo)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Gs),I0.multiplyMatrices(i,Gs),Xo.matrixWorld=I0,Xo.raycast(e,Yc);for(let o=0,a=Yc.length;o<a;o++){let c=Yc[o];c.instanceId=s,c.object=this,t.push(c)}Yc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Kn(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};hd=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Hs="batchId",nr=new we,N0=new we,y1=new we,L0=new we,tf=new ts,qc=new xt,Or=new _t,qo=new w,nf=new hd,nn=new ft,jc=[];Pl=class extends ft{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new Be,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Ui(t,e,e,mn,Xn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:h}=c,f=new l.constructor(i*u),d=new c.constructor(f,u,h);d.setUsage(c.usage),t.setAttribute(a,d)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Ze(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Hs,new Ze(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Hs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Hs}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Hs)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new 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 xt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,nr),this.getBoundingBoxAt(r,qc).applyMatrix4(nr),t.union(qc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _t);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,nr),this.getBoundingSphereAt(r,Or).applyMatrix4(nr),t.union(Or))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let h=this._visibility,f=this._active,d=this._matricesTexture,m=this._matricesTexture.image.data;h.push(!0),f.push(!0);let y=this._geometryCount;this._geometryCount++,y1.toArray(m,y*16),d.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new xt,sphereInitialized:!1,sphere:new _t});let g=this.geometry.getAttribute(Hs);for(let p=0;p<r.vertexCount;p++)g.setX(r.vertexStart+p,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let d in i.attributes){if(d===Hs)continue;let m=t.getAttribute(d),y=i.getAttribute(d);x1(m,y,c);let g=m.itemSize;for(let p=m.count,_=l;p<_;p++){let x=c+p;for(let b=0;b<g;b++)y.setComponent(x,b,0)}y.needsUpdate=!0}if(r){let d=a.indexStart;for(let m=0;m<o.count;m++)s.setX(d+m,c+o.getX(m));for(let m=o.count,y=a.indexCount;m<y;m++)s.setX(d+m,c);s.needsUpdate=!0}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let h=this._drawRanges[e],f=t.getAttribute("position");return h.count=r?o.count:f.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,h=l.start+l.count;u<h;u++){let f=u;a&&(f=a.getX(f)),s.expandByPoint(qo.fromBufferAttribute(c,f))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return this;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,qc),qc.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let h=l.start,f=l.start+l.count;h<f;h++){let d=h;a&&(d=a.getX(d)),qo.fromBufferAttribute(c,d),u=Math.max(u,s.center.distanceToSquared(qo))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;nn.material=this.material,nn.geometry.index=c.index,nn.geometry.attributes=c.attributes,nn.geometry.boundingBox===null&&(nn.geometry.boundingBox=new xt),nn.geometry.boundingSphere===null&&(nn.geometry.boundingSphere=new _t);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];nn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,nn.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,nn.geometry.boundingBox),this.getBoundingSphereAt(l,nn.geometry.boundingSphere),nn.raycast(e,jc);for(let h=0,f=jc.length;h<f;h++){let d=jc[h];d.object=this,d.batchId=l,t.push(d)}jc.length=0}nn.material=null,nn.geometry.index=null,nn.geometry.attributes={},nn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.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,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(L0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),tf.setFromProjectionMatrix(L0,e.isWebGPURenderer?Js:Yn));let d=0;if(this.sortObjects){N0.copy(this.matrixWorld).invert(),qo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(N0);for(let g=0,p=c.length;g<p;g++)if(c[g]){this.getMatrixAt(g,nr),this.getBoundingSphereAt(g,Or).applyMatrix4(nr);let _=!1;if(f&&(_=!tf.intersectsSphere(Or)),!_){let x=qo.distanceTo(Or.center);nf.push(h[g],x)}}let m=nf.list,y=this.customSort;y===null?m.sort(s.transparent?g1:m1):y.call(this,m,i);for(let g=0,p=m.length;g<p;g++){let _=m[g];l[d]=_.start*a,u[d]=_.count,d++}nf.reset()}else for(let m=0,y=c.length;m<y;m++)if(c[m]){let g=!1;if(f&&(this.getMatrixAt(m,nr),this.getBoundingSphereAt(m,Or).applyMatrix4(nr),g=!tf.intersectsSphere(Or)),!g){let p=h[m];l[d]=p.start*a,u[d]=p.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Vt=class extends It{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},O0=new w,D0=new w,U0=new we,rf=new ur,$c=new _t,Un=class extends it{constructor(e=new Be,t=new Vt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)O0.fromBufferAttribute(t,r-1),D0.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=O0.distanceTo(D0);e.setAttribute("lineDistance",new ye(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),$c.copy(i.boundingSphere),$c.applyMatrix4(r),$c.radius+=s,e.ray.intersectsSphere($c)===!1)return;U0.copy(r).invert(),rf.copy(e.ray).applyMatrix4(U0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new w,u=new w,h=new w,f=new w,d=this.isLineSegments?2:1,m=i.index,g=i.attributes.position;if(m!==null){let p=Math.max(0,o.start),_=Math.min(m.count,o.start+o.count);for(let x=p,b=_-1;x<b;x+=d){let T=m.getX(x),A=m.getX(x+1);if(l.fromBufferAttribute(g,T),u.fromBufferAttribute(g,A),rf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);let C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let p=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let x=p,b=_-1;x<b;x+=d){if(l.fromBufferAttribute(g,x),u.fromBufferAttribute(g,x+1),rf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);let A=e.ray.origin.distanceTo(f);A<e.near||A>e.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},F0=new w,B0=new w,xn=class extends Un{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,i=[];for(let r=0,s=t.count;r<s;r+=2)F0.fromBufferAttribute(t,r),B0.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+F0.distanceTo(B0);e.setAttribute("lineDistance",new ye(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},co=class extends Un{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},rs=class extends It{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},z0=new we,fd=new ur,Kc=new _t,Zc=new w,lo=class extends it{constructor(e=new Be,t=new rs){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Kc.copy(i.boundingSphere),Kc.applyMatrix4(r),Kc.radius+=s,e.ray.intersectsSphere(Kc)===!1)return;z0.copy(r).invert(),fd.copy(e.ray).applyMatrix4(z0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,h=i.attributes.position;if(l!==null){let f=Math.max(0,o.start),d=Math.min(l.count,o.start+o.count);for(let m=f,y=d;m<y;m++){let g=l.getX(m);Zc.fromBufferAttribute(h,g),V0(Zc,g,c,r,e,t,this)}}else{let f=Math.max(0,o.start),d=Math.min(h.count,o.start+o.count);for(let m=f,y=d;m<y;m++)Zc.fromBufferAttribute(h,m),V0(Zc,m,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};dd=class extends Rt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:yt,this.magFilter=s!==void 0?s:yt,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},pd=class extends Rt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Mt,this.minFilter=Mt,this.generateMipmaps=!1,this.needsUpdate=!0}},uo=class extends Rt{constructor(e,t,i,r,s,o,a,c,l,u,h,f){super(null,o,a,c,l,u,r,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},md=class extends uo{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Xt}},gd=class extends uo{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Bi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},_a=class extends Rt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Cn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],f=i[r+1]-u,d=(o-u)/f;return(r+d)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new Z:new w);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new w,r=[],s=[],o=[],a=new w,c=new we;for(let d=0;d<=e;d++){let m=d/e;r[d]=this.getTangentAt(m,new w)}s[0]=new w,o[0]=new w;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),h=Math.abs(r[0].y),f=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),f<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Ct(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,m))}o[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(Ct(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(c.makeRotationAxis(r[m],d*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}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}},ho=class extends Cn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){let i=t||new Z,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return i.set(c,l)}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}},Nl=class extends ho{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};Jc=new w,sf=new xp,of=new xp,af=new xp,Ll=class extends Cn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new w){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(Jc.subVectors(r[0],r[1]).add(r[0]),l=Jc);let h=r[a%s],f=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Jc.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Jc),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,m=Math.pow(l.distanceToSquared(h),d),y=Math.pow(h.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(u),d);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),sf.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,m,y,g),of.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,m,y,g),af.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,m,y,g)}else this.curveType==="catmullrom"&&(sf.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),of.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),af.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return i.set(sf.calc(c),of.calc(c),af.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new w().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};Sa=class extends Cn{constructor(e=new Z,t=new Z,i=new Z,r=new Z){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Z){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ea(e,r.x,s.x,o.x,a.x),ea(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Ol=class extends Cn{constructor(e=new w,t=new w,i=new w,r=new w){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new w){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ea(e,r.x,s.x,o.x,a.x),ea(e,r.y,s.y,o.y,a.y),ea(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ba=class extends Cn{constructor(e=new Z,t=new Z){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Z){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Z){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Dl=class extends Cn{constructor(e=new w,t=new w){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new w){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new w){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ma=class extends Cn{constructor(e=new Z,t=new Z,i=new Z){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Z){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Qo(e,r.x,s.x,o.x),Qo(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},va=class extends Cn{constructor(e=new w,t=new w,i=new w){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new w){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Qo(e,r.x,s.x,o.x),Qo(e,r.y,s.y,o.y),Qo(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Aa=class extends Cn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Z){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set(k0(a,c.x,l.x,u.x,h.x),k0(a,c.y,l.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new Z().fromArray(r))}return this}},Ul=Object.freeze({__proto__:null,ArcCurve:Nl,CatmullRomCurve3:Ll,CubicBezierCurve:Sa,CubicBezierCurve3:Ol,EllipseCurve:ho,LineCurve:ba,LineCurve3:Dl,QuadraticBezierCurve:Ma,QuadraticBezierCurve3:va,SplineCurve:Aa}),Fl=class extends Cn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Ul[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Ul[r.type]().fromJSON(r))}return this}},ss=class extends Fl{constructor(e){super(),this.type="Path",this.currentPoint=new Z,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ba(this.currentPoint.clone(),new Z(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Ma(this.currentPoint.clone(),new Z(e,t),new Z(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new Sa(this.currentPoint.clone(),new Z(e,t),new Z(i,r),new Z(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Aa(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new ho(e,t,i,r,s,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),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}},Ea=class n extends Be{constructor(e=[new Z(0,-.5),new Z(.5,0),new Z(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ct(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,h=new w,f=new Z,d=new w,m=new w,y=new w,g=0,p=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,y.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,m.copy(d),d.x+=y.x,d.y+=y.y,d.z+=y.z,d.normalize(),c.push(d.x,d.y,d.z),y.copy(m)}for(let _=0;_<=t;_++){let x=i+_*u*r,b=Math.sin(x),T=Math.cos(x);for(let A=0;A<=e.length-1;A++){h.x=e[A].x*b,h.y=e[A].y,h.z=e[A].x*T,o.push(h.x,h.y,h.z),f.x=_/t,f.y=A/(e.length-1),a.push(f.x,f.y);let M=c[3*A+0]*b,C=c[3*A+1],S=c[3*A+0]*T;l.push(M,C,S)}}for(let _=0;_<t;_++)for(let x=0;x<e.length-1;x++){let b=x+_*e.length,T=b,A=b+e.length,M=b+e.length+1,C=b+1;s.push(T,A,C),s.push(M,C,A)}this.setIndex(s),this.setAttribute("position",new ye(o,3)),this.setAttribute("uv",new ye(a,2)),this.setAttribute("normal",new ye(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Bl=class n extends Ea{constructor(e=1,t=1,i=4,r=8){let s=new ss;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},zl=class n extends Be{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new w,u=new Z;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=t;h++,f+=3){let d=i+h/t*r;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new ye(o,3)),this.setAttribute("normal",new ye(a,3)),this.setAttribute("uv",new ye(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},fo=class n extends Be{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],h=[],f=[],d=[],m=0,y=[],g=i/2,p=0;_(),o===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new ye(h,3)),this.setAttribute("normal",new ye(f,3)),this.setAttribute("uv",new ye(d,2));function _(){let b=new w,T=new w,A=0,M=(t-e)/i;for(let C=0;C<=s;C++){let S=[],v=C/s,L=v*(t-e)+e;for(let U=0;U<=r;U++){let G=U/r,P=G*c+a,D=Math.sin(P),z=Math.cos(P);T.x=L*D,T.y=-v*i+g,T.z=L*z,h.push(T.x,T.y,T.z),b.set(D,M,z).normalize(),f.push(b.x,b.y,b.z),d.push(G,1-v),S.push(m++)}y.push(S)}for(let C=0;C<r;C++)for(let S=0;S<s;S++){let v=y[S][C],L=y[S+1][C],U=y[S+1][C+1],G=y[S][C+1];u.push(v,L,G),u.push(L,U,G),A+=6}l.addGroup(p,A,0),p+=A}function x(b){let T=m,A=new Z,M=new w,C=0,S=b===!0?e:t,v=b===!0?1:-1;for(let U=1;U<=r;U++)h.push(0,g*v,0),f.push(0,v,0),d.push(.5,.5),m++;let L=m;for(let U=0;U<=r;U++){let P=U/r*c+a,D=Math.cos(P),z=Math.sin(P);M.x=S*z,M.y=g*v,M.z=S*D,h.push(M.x,M.y,M.z),f.push(0,v,0),A.x=D*.5+.5,A.y=z*.5*v+.5,d.push(A.x,A.y),m++}for(let U=0;U<r;U++){let G=T+U,P=L+U;b===!0?u.push(P,P+1,G):u.push(P+1,P,G),C+=3}l.addGroup(p,C,b===!0?1:2),p+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vl=class n extends fo{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},hr=class n extends Be{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new ye(s,3)),this.setAttribute("normal",new ye(s.slice(),3)),this.setAttribute("uv",new ye(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(_){let x=new w,b=new w,T=new w;for(let A=0;A<t.length;A+=3)d(t[A+0],x),d(t[A+1],b),d(t[A+2],T),c(x,b,T,_)}function c(_,x,b,T){let A=T+1,M=[];for(let C=0;C<=A;C++){M[C]=[];let S=_.clone().lerp(b,C/A),v=x.clone().lerp(b,C/A),L=A-C;for(let U=0;U<=L;U++)U===0&&C===A?M[C][U]=S:M[C][U]=S.clone().lerp(v,U/L)}for(let C=0;C<A;C++)for(let S=0;S<2*(A-C)-1;S++){let v=Math.floor(S/2);S%2===0?(f(M[C][v+1]),f(M[C+1][v]),f(M[C][v])):(f(M[C][v+1]),f(M[C+1][v+1]),f(M[C+1][v]))}}function l(_){let x=new w;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(_),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function u(){let _=new w;for(let x=0;x<s.length;x+=3){_.x=s[x+0],_.y=s[x+1],_.z=s[x+2];let b=g(_)/2/Math.PI+.5,T=p(_)/Math.PI+.5;o.push(b,1-T)}m(),h()}function h(){for(let _=0;_<o.length;_+=6){let x=o[_+0],b=o[_+2],T=o[_+4],A=Math.max(x,b,T),M=Math.min(x,b,T);A>.9&&M<.1&&(x<.2&&(o[_+0]+=1),b<.2&&(o[_+2]+=1),T<.2&&(o[_+4]+=1))}}function f(_){s.push(_.x,_.y,_.z)}function d(_,x){let b=_*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function m(){let _=new w,x=new w,b=new w,T=new w,A=new Z,M=new Z,C=new Z;for(let S=0,v=0;S<s.length;S+=9,v+=6){_.set(s[S+0],s[S+1],s[S+2]),x.set(s[S+3],s[S+4],s[S+5]),b.set(s[S+6],s[S+7],s[S+8]),A.set(o[v+0],o[v+1]),M.set(o[v+2],o[v+3]),C.set(o[v+4],o[v+5]),T.copy(_).add(x).add(b).divideScalar(3);let L=g(T);y(A,v+0,_,L),y(M,v+2,x,L),y(C,v+4,b,L)}}function y(_,x,b,T){T<0&&_.x===1&&(o[x]=_.x-1),b.x===0&&b.z===0&&(o[x]=T/2/Math.PI+.5)}function g(_){return Math.atan2(_.z,-_.x)}function p(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},kl=class n extends hr{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Qc=new w,el=new w,cf=new w,tl=new Pi,Gl=class extends Be{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(jr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},d=[];for(let m=0;m<c;m+=3){o?(l[0]=o.getX(m),l[1]=o.getX(m+1),l[2]=o.getX(m+2)):(l[0]=m,l[1]=m+1,l[2]=m+2);let{a:y,b:g,c:p}=tl;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),tl.getNormal(cf),h[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,h[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,h[2]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){let x=(_+1)%3,b=h[_],T=h[x],A=tl[u[_]],M=tl[u[x]],C=`${b}_${T}`,S=`${T}_${b}`;S in f&&f[S]?(cf.dot(f[S].normal)<=s&&(d.push(A.x,A.y,A.z),d.push(M.x,M.y,M.z)),f[S]=null):C in f||(f[C]={index0:l[_],index1:l[x],normal:cf.clone()})}}for(let m in f)if(f[m]){let{index0:y,index1:g}=f[m];Qc.fromBufferAttribute(a,y),el.fromBufferAttribute(a,g),d.push(Qc.x,Qc.y,Qc.z),d.push(el.x,el.y,el.z)}this.setAttribute("position",new ye(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fi=class extends ss{constructor(e){super(e),this.uuid=wn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new ss().fromJSON(r))}return this}},w1={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=Ax(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(i&&(s=P1(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let m=t;m<r;m+=t)h=n[m],f=n[m+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return wa(s,o,t,a,c,d,0),o}};ai=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];H0(e),W0(i,e);let o=e.length;t.forEach(H0);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,W0(i,t[c]);let a=w1.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};Hl=class n extends Be{constructor(e=new Fi([new Z(.5,.5),new Z(-.5,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new ye(r,3)),this.setAttribute("uv",new ye(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:d-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:H1,x,b=!1,T,A,M,C;p&&(x=p.getSpacedPoints(u),b=!0,f=!1,T=p.computeFrenetFrames(u,!1),A=new w,M=new w,C=new w),f||(g=0,d=0,m=0,y=0);let S=a.extractPoints(l),v=S.shape,L=S.holes;if(!ai.isClockWise(v)){v=v.reverse();for(let N=0,ae=L.length;N<ae;N++){let K=L[N];ai.isClockWise(K)&&(L[N]=K.reverse())}}let G=ai.triangulateShape(v,L),P=v;for(let N=0,ae=L.length;N<ae;N++){let K=L[N];v=v.concat(K)}function D(N,ae,K){return ae||console.error("THREE.ExtrudeGeometry: vec does not exist"),N.clone().addScaledVector(ae,K)}let z=v.length,q=G.length;function Y(N,ae,K){let re,$,Ee,me=N.x-ae.x,R=N.y-ae.y,E=K.x-N.x,B=K.y-N.y,ie=me*me+R*R,te=me*B-R*E;if(Math.abs(te)>Number.EPSILON){let ee=Math.sqrt(ie),ve=Math.sqrt(E*E+B*B),fe=ae.x-R/ee,_e=ae.y+me/ee,Re=K.x-B/ve,ke=K.y+E/ve,ne=((Re-fe)*B-(ke-_e)*E)/(me*B-R*E);re=fe+me*ne-N.x,$=_e+R*ne-N.y;let st=re*re+$*$;if(st<=2)return new Z(re,$);Ee=Math.sqrt(st/2)}else{let ee=!1;me>Number.EPSILON?E>Number.EPSILON&&(ee=!0):me<-Number.EPSILON?E<-Number.EPSILON&&(ee=!0):Math.sign(R)===Math.sign(B)&&(ee=!0),ee?(re=-R,$=me,Ee=Math.sqrt(ie)):(re=me,$=R,Ee=Math.sqrt(ie/2))}return new Z(re/Ee,$/Ee)}let W=[];for(let N=0,ae=P.length,K=ae-1,re=N+1;N<ae;N++,K++,re++)K===ae&&(K=0),re===ae&&(re=0),W[N]=Y(P[N],P[K],P[re]);let j=[],J,le=W.concat();for(let N=0,ae=L.length;N<ae;N++){let K=L[N];J=[];for(let re=0,$=K.length,Ee=$-1,me=re+1;re<$;re++,Ee++,me++)Ee===$&&(Ee=0),me===$&&(me=0),J[re]=Y(K[re],K[Ee],K[me]);j.push(J),le=le.concat(J)}for(let N=0;N<g;N++){let ae=N/g,K=d*Math.cos(ae*Math.PI/2),re=m*Math.sin(ae*Math.PI/2)+y;for(let $=0,Ee=P.length;$<Ee;$++){let me=D(P[$],W[$],re);he(me.x,me.y,-K)}for(let $=0,Ee=L.length;$<Ee;$++){let me=L[$];J=j[$];for(let R=0,E=me.length;R<E;R++){let B=D(me[R],J[R],re);he(B.x,B.y,-K)}}}let X=m+y;for(let N=0;N<z;N++){let ae=f?D(v[N],le[N],X):v[N];b?(M.copy(T.normals[0]).multiplyScalar(ae.x),A.copy(T.binormals[0]).multiplyScalar(ae.y),C.copy(x[0]).add(M).add(A),he(C.x,C.y,C.z)):he(ae.x,ae.y,0)}for(let N=1;N<=u;N++)for(let ae=0;ae<z;ae++){let K=f?D(v[ae],le[ae],X):v[ae];b?(M.copy(T.normals[N]).multiplyScalar(K.x),A.copy(T.binormals[N]).multiplyScalar(K.y),C.copy(x[N]).add(M).add(A),he(C.x,C.y,C.z)):he(K.x,K.y,h/u*N)}for(let N=g-1;N>=0;N--){let ae=N/g,K=d*Math.cos(ae*Math.PI/2),re=m*Math.sin(ae*Math.PI/2)+y;for(let $=0,Ee=P.length;$<Ee;$++){let me=D(P[$],W[$],re);he(me.x,me.y,h+K)}for(let $=0,Ee=L.length;$<Ee;$++){let me=L[$];J=j[$];for(let R=0,E=me.length;R<E;R++){let B=D(me[R],J[R],re);b?he(B.x,B.y+x[u-1].y,x[u-1].x+K):he(B.x,B.y,h+K)}}}Q(),ue();function Q(){let N=r.length/3;if(f){let ae=0,K=z*ae;for(let re=0;re<q;re++){let $=G[re];Ce($[2]+K,$[1]+K,$[0]+K)}ae=u+g*2,K=z*ae;for(let re=0;re<q;re++){let $=G[re];Ce($[0]+K,$[1]+K,$[2]+K)}}else{for(let ae=0;ae<q;ae++){let K=G[ae];Ce(K[2],K[1],K[0])}for(let ae=0;ae<q;ae++){let K=G[ae];Ce(K[0]+z*u,K[1]+z*u,K[2]+z*u)}}i.addGroup(N,r.length/3-N,0)}function ue(){let N=r.length/3,ae=0;xe(P,ae),ae+=P.length;for(let K=0,re=L.length;K<re;K++){let $=L[K];xe($,ae),ae+=$.length}i.addGroup(N,r.length/3-N,1)}function xe(N,ae){let K=N.length;for(;--K>=0;){let re=K,$=K-1;$<0&&($=N.length-1);for(let Ee=0,me=u+g*2;Ee<me;Ee++){let R=z*Ee,E=z*(Ee+1),B=ae+re+R,ie=ae+$+R,te=ae+$+E,ee=ae+re+E;De(B,ie,te,ee)}}}function he(N,ae,K){c.push(N),c.push(ae),c.push(K)}function Ce(N,ae,K){Me(N),Me(ae),Me(K);let re=r.length/3,$=_.generateTopUV(i,r,re-3,re-2,re-1);Ue($[0]),Ue($[1]),Ue($[2])}function De(N,ae,K,re){Me(N),Me(ae),Me(re),Me(ae),Me(K),Me(re);let $=r.length/3,Ee=_.generateSideWallUV(i,r,$-6,$-3,$-2,$-1);Ue(Ee[0]),Ue(Ee[1]),Ue(Ee[3]),Ue(Ee[1]),Ue(Ee[2]),Ue(Ee[3])}function Me(N){r.push(c[N*3+0]),r.push(c[N*3+1]),r.push(c[N*3+2])}function Ue(N){s.push(N.x),s.push(N.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return W1(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Ul[r.type]().fromJSON(r)),new n(i,e.options)}},H1={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new Z(s,o),new Z(a,c),new Z(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],h=e[i*3+2],f=e[r*3],d=e[r*3+1],m=e[r*3+2],y=e[s*3],g=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new Z(o,1-c),new Z(l,1-h),new Z(f,1-m),new Z(y,1-p)]:[new Z(a,1-c),new Z(u,1-h),new Z(d,1-m),new Z(g,1-p)]}};Wl=class n extends hr{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Ra=class n extends hr{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Xl=class n extends Be{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],h=e,f=(t-e)/r,d=new w,m=new Z;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let p=s+g/i*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),m.x=(d.x/t+1)/2,m.y=(d.y/t+1)/2,u.push(m.x,m.y)}h+=f}for(let y=0;y<r;y++){let g=y*(i+1);for(let p=0;p<i;p++){let _=p+g,x=_,b=_+i+1,T=_+i+2,A=_+1;a.push(x,b,A),a.push(b,T,A)}}this.setIndex(a),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(l,3)),this.setAttribute("uv",new ye(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Yl=class n extends Be{constructor(e=new Fi([new Z(0,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new ye(r,3)),this.setAttribute("normal",new ye(s,3)),this.setAttribute("uv",new ye(o,2));function l(u){let h=r.length/3,f=u.extractPoints(t),d=f.shape,m=f.holes;ai.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,p=m.length;g<p;g++){let _=m[g];ai.isClockWise(_)===!0&&(m[g]=_.reverse())}let y=ai.triangulateShape(d,m);for(let g=0,p=m.length;g<p;g++){let _=m[g];d=d.concat(_)}for(let g=0,p=d.length;g<p;g++){let _=d[g];r.push(_.x,_.y,0),s.push(0,0,1),o.push(_.x,_.y)}for(let g=0,p=y.length;g<p;g++){let _=y[g],x=_[0]+h,b=_[1]+h,T=_[2]+h;i.push(x,b,T),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return X1(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Ia=class n extends Be{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new w,f=new w,d=[],m=[],y=[],g=[];for(let p=0;p<=i;p++){let _=[],x=p/i,b=0;p===0&&o===0?b=.5/t:p===i&&c===Math.PI&&(b=-.5/t);for(let T=0;T<=t;T++){let A=T/t;h.x=-e*Math.cos(r+A*s)*Math.sin(o+x*a),h.y=e*Math.cos(o+x*a),h.z=e*Math.sin(r+A*s)*Math.sin(o+x*a),m.push(h.x,h.y,h.z),f.copy(h).normalize(),y.push(f.x,f.y,f.z),g.push(A+b,1-x),_.push(l++)}u.push(_)}for(let p=0;p<i;p++)for(let _=0;_<t;_++){let x=u[p][_+1],b=u[p][_],T=u[p+1][_],A=u[p+1][_+1];(p!==0||o>0)&&d.push(x,b,A),(p!==i-1||c<Math.PI)&&d.push(b,T,A)}this.setIndex(d),this.setAttribute("position",new ye(m,3)),this.setAttribute("normal",new ye(y,3)),this.setAttribute("uv",new ye(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},ql=class n extends hr{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},jl=class n extends Be{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new w,h=new w,f=new w;for(let d=0;d<=i;d++)for(let m=0;m<=r;m++){let y=m/r*s,g=d/i*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(y),h.y=(e+t*Math.cos(g))*Math.sin(y),h.z=t*Math.sin(g),a.push(h.x,h.y,h.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(m/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let m=1;m<=r;m++){let y=(r+1)*d+m-1,g=(r+1)*(d-1)+m-1,p=(r+1)*(d-1)+m,_=(r+1)*d+m;o.push(y,g,_),o.push(g,p,_)}this.setIndex(o),this.setAttribute("position",new ye(a,3)),this.setAttribute("normal",new ye(c,3)),this.setAttribute("uv",new ye(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},$l=class n extends Be{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],h=new w,f=new w,d=new w,m=new w,y=new w,g=new w,p=new w;for(let x=0;x<=i;++x){let b=x/i*s*Math.PI*2;_(b,s,o,e,d),_(b+.01,s,o,e,m),g.subVectors(m,d),p.addVectors(m,d),y.crossVectors(g,p),p.crossVectors(y,g),y.normalize(),p.normalize();for(let T=0;T<=r;++T){let A=T/r*Math.PI*2,M=-t*Math.cos(A),C=t*Math.sin(A);h.x=d.x+(M*p.x+C*y.x),h.y=d.y+(M*p.y+C*y.y),h.z=d.z+(M*p.z+C*y.z),c.push(h.x,h.y,h.z),f.subVectors(h,d).normalize(),l.push(f.x,f.y,f.z),u.push(x/i),u.push(T/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let T=(r+1)*(x-1)+(b-1),A=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;a.push(T,A,C),a.push(A,M,C)}this.setIndex(a),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(l,3)),this.setAttribute("uv",new ye(u,2));function _(x,b,T,A,M){let C=Math.cos(x),S=Math.sin(x),v=T/b*x,L=Math.cos(v);M.x=A*(2+L)*.5*C,M.y=A*(2+L)*S*.5,M.z=A*Math.sin(v)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},Kl=class n extends Be{constructor(e=new va(new w(-1,-1,0),new w(-1,1,0),new w(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new w,c=new w,l=new Z,u=new w,h=[],f=[],d=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new ye(h,3)),this.setAttribute("normal",new ye(f,3)),this.setAttribute("uv",new ye(d,2));function y(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),_(),p()}function g(x){u=e.getPointAt(x/t,u);let b=o.normals[x],T=o.binormals[x];for(let A=0;A<=r;A++){let M=A/r*Math.PI*2,C=Math.sin(M),S=-Math.cos(M);c.x=S*b.x+C*T.x,c.y=S*b.y+C*T.y,c.z=S*b.z+C*T.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,h.push(a.x,a.y,a.z)}}function p(){for(let x=1;x<=t;x++)for(let b=1;b<=r;b++){let T=(r+1)*(x-1)+(b-1),A=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;m.push(T,A,C),m.push(A,M,C)}}function _(){for(let x=0;x<=t;x++)for(let b=0;b<=r;b++)l.x=x/t,l.y=b/r,d.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Ul[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},po=class extends Be{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new w,s=new w;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],f=h.start,d=h.count;for(let m=f,y=f+d;m<y;m+=3)for(let g=0;g<3;g++){let p=a.getX(m+g),_=a.getX(m+(g+1)%3);r.fromBufferAttribute(o,p),s.fromBufferAttribute(o,_),X0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),X0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new ye(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};Y0=Object.freeze({__proto__:null,BoxGeometry:Qr,CapsuleGeometry:Bl,CircleGeometry:zl,ConeGeometry:Vl,CylinderGeometry:fo,DodecahedronGeometry:kl,EdgesGeometry:Gl,ExtrudeGeometry:Hl,IcosahedronGeometry:Wl,LatheGeometry:Ea,OctahedronGeometry:Ra,PlaneGeometry:ns,PolyhedronGeometry:hr,RingGeometry:Xl,ShapeGeometry:Yl,SphereGeometry:Ia,TetrahedronGeometry:ql,TorusGeometry:jl,TorusKnotGeometry:$l,TubeGeometry:Kl,WireframeGeometry:po}),mo=class extends It{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new oe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Zl=class extends yn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},fr=class extends It{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},_n=class extends fr{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Z(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Jl=class extends It{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new oe(16777215),this.specular=new oe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=za,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Ql=class extends It{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new oe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},eu=class extends It{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},tu=class extends It{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=za,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.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}},nu=class extends It{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new oe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},iu=class extends Vt{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}};j1={convertArray:Xr,isTypedArray:Tx,getKeyframeOrder:Cx,sortedArray:_d,flattenJSON:_p,subclip:Y1,makeClipAdditive:q1},ki=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ru=class extends ki{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Hr,endingEnd:Hr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Wr:s=e,a=2*t-i;break;case ia:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Wr:o=e,c=2*i-t;break;case ia:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,p=-f*g+2*f*y-f*m,_=(1+f)*g+(-1.5-2*f)*y+(-.5+f)*m+1,x=(-1-d)*g+(1.5+d)*y+.5*m,b=d*g-d*y;for(let T=0;T!==a;++T)s[T]=p*o[u+T]+_*o[l+T]+x*o[c+T]+b*o[h+T];return s}},Pa=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),h=1-u;for(let f=0;f!==a;++f)s[f]=o[l+f]*h+o[c+f]*u;return s}},su=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Rn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Xr(t,this.TimeBufferType),this.values=Xr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Xr(e.times,Array),values:Xr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ru(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Jr:t=this.InterpolantFactoryMethodDiscrete;break;case lr:t=this.InterpolantFactoryMethodLinear;break;case gl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jr;case this.InterpolantFactoryMethodLinear:return lr;case this.InterpolantFactoryMethodSmooth:return gl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}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 i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Tx(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===gl,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let h=a*i,f=h-i,d=h+i;for(let m=0;m!==i;++m){let y=t[h+m];if(y!==t[f+m]||y!==t[d+m]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let h=a*i,f=o*i;for(let d=0;d!==i;++d)t[f+d]=t[h+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Rn.prototype.TimeBufferType=Float32Array;Rn.prototype.ValueBufferType=Float32Array;Rn.prototype.DefaultInterpolation=lr;Gi=class extends Rn{};Gi.prototype.ValueTypeName="bool";Gi.prototype.ValueBufferType=Array;Gi.prototype.DefaultInterpolation=Jr;Gi.prototype.InterpolantFactoryMethodLinear=void 0;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;Na=class extends Rn{};Na.prototype.ValueTypeName="color";li=class extends Rn{};li.prototype.ValueTypeName="number";ou=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Ft.slerpFlat(s,0,o,l-a,o,l,c);return s}},Zn=class extends Rn{InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}};Zn.prototype.ValueTypeName="quaternion";Zn.prototype.DefaultInterpolation=lr;Zn.prototype.InterpolantFactoryMethodSmooth=void 0;Hi=class extends Rn{};Hi.prototype.ValueTypeName="string";Hi.prototype.ValueBufferType=Array;Hi.prototype.DefaultInterpolation=Jr;Hi.prototype.InterpolantFactoryMethodLinear=void 0;Hi.prototype.InterpolantFactoryMethodSmooth=void 0;ui=class extends Rn{};ui.prototype.ValueTypeName="vector";Wi=class{constructor(e,t=-1,i,r=Su){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=wn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(K1(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Rn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Cx(c);c=_d(c,1,u),l=_d(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new li(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let h=u[1],f=r[h];f||(r[h]=f=[]),f.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,f,d,m,y){if(d.length!==0){let g=[],p=[];_p(d,g,p,m),g.length!==0&&y.push(new h(f,g,p))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let f=l[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let d={},m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let y=0;y<f[m].morphTargets.length;y++)d[f[m].morphTargets[y]]=-1;for(let y in d){let g=[],p=[];for(let _=0;_!==f[m].morphTargets.length;++_){let x=f[m];g.push(x.time),p.push(x.morphTarget===y?1:0)}r.push(new li(".morphTargetInfluence["+y+"]",g,p))}c=d.length*o}else{let d=".bones["+t[h].name+"]";i(ui,d+".position",f,"pos",r),i(Zn,d+".quaternion",f,"rot",r),i(ui,d+".scale",f,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};Ni={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},La=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){let d=l[h],m=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return m}return null}}},Rx=new La,qt=class{constructor(e){this.manager=e!==void 0?e:Rx,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};qt.DEFAULT_MATERIAL_NAME="__DEFAULT";Ti={},Sd=class extends Error{constructor(e,t){super(e),this.response=t}},Sn=class extends qt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Ni.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:i,onError:r});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=Ti[e],h=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=f?parseInt(f):0,m=d!==0,y=0,g=new ReadableStream({start(p){_();function _(){h.read().then(({done:x,value:b})=>{if(x)p.close();else{y+=b.byteLength;let T=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:d});for(let A=0,M=u.length;A<M;A++){let C=u[A];C.onProgress&&C.onProgress(T)}p.enqueue(b),_()}})}}});return new Response(g)}else throw new Sd(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(m=>d.decode(m))}}}).then(l=>{Ni.add(e,l);let u=Ti[e];delete Ti[e];for(let h=0,f=u.length;h<f;h++){let d=u[h];d.onLoad&&d.onLoad(l)}}).catch(l=>{let u=Ti[e];if(u===void 0)throw this.manager.itemError(e),l;delete Ti[e];for(let h=0,f=u.length;h<f;h++){let d=u[h];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},bd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=Wi.parse(e[i]);t.push(r)}return t}},Md=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new uo,c=new Sn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(h){c.load(e[h],function(f){let d=s.parse(f,!0);o[h]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},l+=1,l===6&&(d.mipmapCount===1&&(a.minFilter=yt),a.image=o,a.format=d.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let h=0,f=e.length;h<f;++h)u(h);else c.load(e,function(h){let f=s.parse(h,!0);if(f.isCubemap){let d=f.mipmaps.length/f.mipmapCount;for(let m=0;m<d;m++){o[m]={mipmaps:[]};for(let y=0;y<f.mipmapCount;y++)o[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+y]),o[m].format=f.format,o[m].width=f.width,o[m].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=yt),a.format=f.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},as=class extends qt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=Ni.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=ca("img");function c(){u(),Ni.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},vd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=new es;s.colorSpace=lt;let o=new as(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Ad=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Ui,a=new Sn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Xt,o.wrapT=l.wrapT!==void 0?l.wrapT:Xt,o.magFilter=l.magFilter!==void 0?l.magFilter:yt,o.minFilter=l.minFilter!==void 0?l.minFilter:yt,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0?o.colorSpace=l.colorSpace:l.encoding!==void 0&&(o.encoding=l.encoding),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=jn),l.mipmapCount===1&&(o.minFilter=yt),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},cs=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=new Rt,o=new as(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},hi=class extends it{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},go=class extends hi{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},lf=new we,q0=new w,j0=new w,Oa=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Z(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ts,this._frameExtents=new Z(1,1),this._viewportCount=1,this._viewports=[new tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;q0.setFromMatrixPosition(e.matrixWorld),t.position.copy(q0),j0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(j0),t.updateMatrixWorld(),lf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(lf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ed=class extends Oa{constructor(){super(new vt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Qs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},dr=class extends hi{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ed}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},$0=new we,jo=new w,uf=new w,wd=class extends Oa{constructor(){super(new vt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Z(4,2),this._viewportCount=6,this._viewports=[new tt(2,1,1,1),new tt(0,1,1,1),new tt(3,1,1,1),new tt(1,1,1,1),new tt(3,0,1,1),new tt(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),jo.setFromMatrixPosition(e.matrixWorld),i.position.copy(jo),uf.copy(i.position),uf.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(uf),i.updateMatrixWorld(),r.makeTranslation(-jo.x,-jo.y,-jo.z),$0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix($0)}},pr=class extends hi{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new wd}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Td=class extends Oa{constructor(){super(new ci(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},mr=class extends hi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.shadow=new Td}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},yo=class extends hi{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},au=class extends hi{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},cu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new w)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},lu=class extends hi{constructor(e=new cu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},uu=class n extends qt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new oe().setHex(o.value);break;case"v2":r.uniforms[s].value=new Z().fromArray(o.value);break;case"v3":r.uniforms[s].value=new w().fromArray(o.value);break;case"v4":r.uniforms[s].value=new tt().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ye().fromArray(o.value);break;case"m4":r.uniforms[s].value=new we().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Z().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Z().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:mo,SpriteMaterial:xa,RawShaderMaterial:Zl,ShaderMaterial:yn,PointsMaterial:rs,MeshPhysicalMaterial:_n,MeshStandardMaterial:fr,MeshPhongMaterial:Jl,MeshToonMaterial:Ql,MeshNormalMaterial:eu,MeshLambertMaterial:tu,MeshDepthMaterial:ga,MeshDistanceMaterial:ya,MeshBasicMaterial:sn,MeshMatcapMaterial:nu,LineDashedMaterial:iu,LineBasicMaterial:Vt,Material:It};return new t[e]}},Jn=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},xo=class extends Be{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},hu=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,m){if(t[m]!==void 0)return t[m];let g=d.interleavedBuffers[m],p=s(d,g.buffer),_=Ws(g.type,p),x=new Vi(_,g.stride);return x.uuid=g.uuid,t[m]=x,x}function s(d,m){if(i[m]!==void 0)return i[m];let g=d.arrayBuffers[m],p=new Uint32Array(g).buffer;return i[m]=p,p}let o=e.isInstancedBufferGeometry?new xo:new Be,a=e.data.index;if(a!==void 0){let d=Ws(a.type,a.array);o.setIndex(new Ze(d,1))}let c=e.data.attributes;for(let d in c){let m=c[d],y;if(m.isInterleavedBufferAttribute){let g=r(e.data,m.data);y=new Yt(g,m.itemSize,m.offset,m.normalized)}else{let g=Ws(m.type,m.array),p=m.isInstancedBufferAttribute?Kn:Ze;y=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),m.usage!==void 0&&y.setUsage(m.usage),o.setAttribute(d,y)}let l=e.data.morphAttributes;if(l)for(let d in l){let m=l[d],y=[];for(let g=0,p=m.length;g<p;g++){let _=m[g],x;if(_.isInterleavedBufferAttribute){let b=r(e.data,_.data);x=new Yt(b,_.itemSize,_.offset,_.normalized)}else{let b=Ws(_.type,_.array);x=new Ze(b,_.itemSize,_.normalized)}_.name!==void 0&&(x.name=_.name),y.push(x)}o.morphAttributes[d]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,m=h.length;d!==m;++d){let y=h[d];o.addGroup(y.start,y.count,y.materialIndex)}let f=e.data.boundingSphere;if(f!==void 0){let d=new w;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new _t(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Cd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?Jn.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Sn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?Jn.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Sn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let h=!1;for(let f in o)if(o[f].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new Fi().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new oo().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new hu;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Y0?a=Y0[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new uu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=Wi.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Ws(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new La(t);s=new as(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let h=e[l],f=h.url;if(Array.isArray(f)){let d=[];for(let m=0,y=f.length;m<y;m++){let g=f[m],p=a(g);p!==null&&(p instanceof HTMLImageElement?d.push(p):d.push(new Ui(p.data,p.width,p.height)))}r[h.uuid]=new Ii(d)}else{let d=a(h.url);r[h.uuid]=new Ii(d)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Ws(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new as(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,f=l.length;h<f;h++){let d=l[h],m=await s(d);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ui(m.data,m.width,m.height)))}i[c.uuid]=new Ii(u)}else{let u=await s(c.url);i[c.uuid]=new Ii(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new es,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Ui:u=new Rt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,Z1)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],K0),u.wrapT=i(a.wrap[1],K0)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.encoding!==void 0&&(u.encoding=a.encoding),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,Z0)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Z0)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){let d=[];for(let m=0,y=f.length;m<y;m++){let g=f[m];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(i[g])}return d}return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),i[f]}}function l(f){return r[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),r[f]}let u,h;switch(e.type){case"Scene":o=new ro,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new oe(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Cl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Tl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":o=new vt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new ci(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new yo(e.color,e.intensity);break;case"DirectionalLight":o=new mr(e.color,e.intensity);break;case"PointLight":o=new pr(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new au(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new dr(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new go(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new lu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new so(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new ft(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);let f=e.count,d=e.instanceMatrix,m=e.instanceColor;o=new ao(u,h,f),o.instanceMatrix=new Kn(new Float32Array(d.array),16),m!==void 0&&(o.instanceColor=new Kn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new Pl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new xt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let p=new _t;return p.radius=y.sphereRadius,p.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:p}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Il;break;case"Line":o=new Un(a(e.geometry),c(e.material));break;case"LineLoop":o=new co(a(e.geometry),c(e.material));break;case"LineSegments":o=new xn(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new lo(a(e.geometry),c(e.material));break;case"Sprite":o=new Rl(c(e.material));break;case"Group":o=new Dn;break;case"Bone":o=new is;break;default:o=new it}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let f=e.children;for(let d=0;d<f.length;d++)o.add(this.parseObject(f[d],t,i,r,s))}if(e.animations!==void 0){let f=e.animations;for(let d=0;d<f.length;d++){let m=f[d];o.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let f=e.levels;for(let d=0;d<f.length;d++){let m=f[d],y=o.getObjectByProperty("uuid",m.object);y!==void 0&&o.addLevel(y,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},Z1={UVMapping:xu,CubeReflectionMapping:Bi,CubeRefractionMapping:cr,EquirectangularReflectionMapping:$r,EquirectangularRefractionMapping:na,CubeUVReflectionMapping:_o},K0={RepeatWrapping:zi,ClampToEdgeWrapping:Xt,MirroredRepeatWrapping:Kr},Z0={NearestFilter:Mt,NearestMipmapNearestFilter:Ks,NearestMipmapLinearFilter:qr,LinearFilter:yt,LinearMipmapNearestFilter:Va,LinearMipmapLinearFilter:jn},Da=class extends qt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=Ni.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return Ni.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),Ni.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Ni.add(e,c),s.manager.itemStart(e)}},Ua=class{static getContext(){return rl===void 0&&(rl=new(window.AudioContext||window.webkitAudioContext)),rl}static setContext(e){rl=e}},Rd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Ua.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},J0=new we,Q0=new we,Dr=new we,Id=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new vt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new vt,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,Dr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(jr*t.fov*.5)/t.zoom,a,c;Q0.elements[12]=-r,J0.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Dr.elements[0]=2*t.near/(c-a),Dr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Dr),a=-o*t.aspect-s,c=o*t.aspect-s,Dr.elements[0]=2*t.near/(c-a),Dr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Dr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Q0),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(J0)}},fu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ey(),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=ey();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};Ur=new w,ty=new Ft,J1=new w,Fr=new w,Pd=class extends it{constructor(){super(),this.type="AudioListener",this.context=Ua.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new fu}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.filter),this.filter.disconnect(this.context.destination)):this.gain.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,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ur,ty,J1),Fr.set(0,0,-1).applyQuaternion(ty),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ur.x,r),t.positionY.linearRampToValueAtTime(Ur.y,r),t.positionZ.linearRampToValueAtTime(Ur.z,r),t.forwardX.linearRampToValueAtTime(Fr.x,r),t.forwardY.linearRampToValueAtTime(Fr.y,r),t.forwardZ.linearRampToValueAtTime(Fr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Ur.x,Ur.y,Ur.z),t.setOrientation(Fr.x,Fr.y,Fr.z,i.x,i.y,i.z)}},du=class extends it{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._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;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Br=new w,ny=new Ft,Q1=new w,zr=new w,Nd=class extends du{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Br,ny,Q1),zr.set(0,0,1).applyQuaternion(ny);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Br.x,i),t.positionY.linearRampToValueAtTime(Br.y,i),t.positionZ.linearRampToValueAtTime(Br.z,i),t.orientationX.linearRampToValueAtTime(zr.x,i),t.orientationY.linearRampToValueAtTime(zr.y,i),t.orientationZ.linearRampToValueAtTime(zr.z,i)}else t.setPosition(Br.x,Br.y,Br.z),t.setOrientation(zr.x,zr.y,zr.z)}},Ld=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},pu=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];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 i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Ft.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Ft.multiplyQuaternionsFlat(e,o,e,t,e,i),Ft.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Sp="\\[\\]\\.:\\/",eC=new RegExp("["+Sp+"]","g"),bp="[^"+Sp+"]",tC="[^"+Sp.replace("\\.","")+"]",nC=/((?:WC+[\/:])*)/.source.replace("WC",bp),iC=/(WCOD+)?/.source.replace("WCOD",tC),rC=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bp),sC=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bp),oC=new RegExp("^"+nC+iC+rC+sC+"$"),aC=["material","materials","bones","map"],Od=class{constructor(e,t,i){let r=i||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},ot=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(eC,"")}static parseTrackName(e){let t=oC.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);aC.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ot.Composite=Od;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Dd=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=wn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let f=arguments[u],d=f.uuid,m=t[d];if(m===void 0){m=c++,t[d]=m,e.push(f);for(let y=0,g=o;y!==g;++y)s[y].push(new ot(f,i[y],r[y]))}else if(m<l){a=e[m];let y=--l,g=e[y];t[g.uuid]=m,e[m]=g,t[d]=y,e[y]=f;for(let p=0,_=o;p!==_;++p){let x=s[p],b=x[y],T=x[m];x[m]=b,T===void 0&&(T=new ot(f,i[p],r[p])),x[y]=T}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,m=r;d!==m;++d){let y=i[d],g=y[h],p=y[u];y[u]=g,y[h]=p}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){let f=--s,d=e[f],m=--o,y=e[m];t[d.uuid]=h,e[h]=d,t[y.uuid]=f,e[f]=y,e.pop();for(let g=0,p=r;g!==p;++g){let _=i[g],x=_[f],b=_[m];_[h]=x,_[f]=b,_.pop()}}else{let f=--o,d=e[f];f>0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let m=0,y=r;m!==y;++m){let g=i[m];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){let m=c[f];h[f]=new ot(m,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},mu=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Hr,endingEnd:Hr};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ex,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,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}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,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,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,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case fp:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Su:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.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 i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===tx;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Qy){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}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(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=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(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Wr,r.endingEnd=Wr):(e?r.endingStart=this.zeroSlopeAtStart?Wr:Hr:r.endingStart=ia,t?r.endingEnd=this.zeroSlopeAtEnd?Wr:Hr:r.endingEnd=ia)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},cC=new Float32Array(1),Ud=class extends $n{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){let f=r[h],d=f.name,m=u[d];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,d));continue}let y=t&&t._propertyBindings[h].binding.parsedPath;m=new pu(ot.create(i,d,y),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,d),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}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<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let h=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete h[f],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Pa(new Float32Array(2),new Float32Array(2),1,cC),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Wi.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Su),c!==void 0){let h=c.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new mu(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Wi.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Fd=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},lC=0,Bd=class extends $n{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:lC++}),this.name="",this.usage=aa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},gr=class extends Vi{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},zd=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Vd=class{constructor(e,t,i=0,r=1/0){this.ray=new ur(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new to,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return kd(e,this,i,t),i.sort(iy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)kd(e[r],this,i,t);return i.sort(iy),i}};Gd=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ct(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Hd=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},ry=new Z,Wd=class{constructor(e=new Z(1/0,1/0),t=new Z(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=ry.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ry).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)}},sy=new w,sl=new w,Fa=class{constructor(e=new w,t=new w){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){sy.subVectors(e,this.start),sl.subVectors(this.end,this.start);let i=sl.dot(sl),s=sl.dot(sy)/i;return t&&(s=Ct(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).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)}},oy=new w,Xd=class extends it{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Be,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 o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new ye(r,3));let s=new Vt({fog:!1,toneMapped:!1});this.cone=new xn(i,s),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);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),oy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(oy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},ir=new w,ol=new we,hf=new we,Yd=class extends xn{constructor(e){let t=Ix(e),i=new Be,r=[],s=[],o=new oe(0,0,1),a=new oe(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new ye(r,3)),i.setAttribute("color",new ye(s,3));let c=new Vt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");hf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(ol.multiplyMatrices(hf,a.matrixWorld),ir.setFromMatrixPosition(ol),r.setXYZ(o,ir.x,ir.y,ir.z),ol.multiplyMatrices(hf,a.parent.matrixWorld),ir.setFromMatrixPosition(ol),r.setXYZ(o+1,ir.x,ir.y,ir.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};qd=class extends ft{constructor(e,t,i){let r=new Ia(t,4,2),s=new sn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},uC=new w,ay=new oe,cy=new oe,jd=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Ra(t);r.rotateY(Math.PI*.5),this.material=new sn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new Ze(o,3)),this.add(new ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");ay.copy(this.light.color),cy.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?ay:cy;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(uC.setFromMatrixPosition(this.light.matrixWorld).negate())}},Ba=class extends xn{constructor(e=10,t=10,i=4473924,r=8947848){i=new oe(i),r=new oe(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let f=0,d=0,m=-a;f<=t;f++,m+=o){c.push(-a,0,m,a,0,m),c.push(m,0,-a,m,0,a);let y=f===s?i:r;y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3}let u=new Be;u.setAttribute("position",new ye(c,3)),u.setAttribute("color",new ye(l,3));let h=new Vt({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},$d=class extends xn{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new oe(s),o=new oe(o);let a=[],c=[];if(t>1)for(let h=0;h<t;h++){let f=h/t*(Math.PI*2),d=Math.sin(f)*e,m=Math.cos(f)*e;a.push(0,0,0),a.push(d,0,m);let y=h&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let h=0;h<i;h++){let f=h&1?s:o,d=e-e/i*h;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*d,p=Math.cos(y)*d;a.push(g,0,p),c.push(f.r,f.g,f.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*d,p=Math.cos(y)*d,a.push(g,0,p),c.push(f.r,f.g,f.b)}}let l=new Be;l.setAttribute("position",new ye(a,3)),l.setAttribute("color",new ye(c,3));let u=new Vt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},ly=new w,al=new w,uy=new w,Kd=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Be;r.setAttribute("position",new ye([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Vt({fog:!1,toneMapped:!1});this.lightPlane=new Un(r,s),this.add(this.lightPlane),r=new Be,r.setAttribute("position",new ye([0,0,0,0,0,1],3)),this.targetLine=new Un(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),ly.setFromMatrixPosition(this.light.matrixWorld),al.setFromMatrixPosition(this.light.target.matrixWorld),uy.subVectors(al,ly),this.lightPlane.lookAt(al),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(al),this.targetLine.scale.z=uy.length()}},cl=new w,Tt=new io,Zd=class extends xn{constructor(e){let t=new Be,i=new Vt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,y){c(m),c(y)}function c(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}t.setAttribute("position",new ye(r,3)),t.setAttribute("color",new ye(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new oe(16755200),u=new oe(16711680),h=new oe(43775),f=new oe(16777215),d=new oe(3355443);this.setColors(l,u,h,f,d)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;Tt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Nt("c",t,e,Tt,0,0,-1),Nt("t",t,e,Tt,0,0,1),Nt("n1",t,e,Tt,-i,-r,-1),Nt("n2",t,e,Tt,i,-r,-1),Nt("n3",t,e,Tt,-i,r,-1),Nt("n4",t,e,Tt,i,r,-1),Nt("f1",t,e,Tt,-i,-r,1),Nt("f2",t,e,Tt,i,-r,1),Nt("f3",t,e,Tt,-i,r,1),Nt("f4",t,e,Tt,i,r,1),Nt("u1",t,e,Tt,i*.7,r*1.1,-1),Nt("u2",t,e,Tt,-i*.7,r*1.1,-1),Nt("u3",t,e,Tt,0,r*2,-1),Nt("cf1",t,e,Tt,-i,0,1),Nt("cf2",t,e,Tt,i,0,1),Nt("cf3",t,e,Tt,0,-r,1),Nt("cf4",t,e,Tt,0,r,1),Nt("cn1",t,e,Tt,-i,0,-1),Nt("cn2",t,e,Tt,i,0,-1),Nt("cn3",t,e,Tt,0,-r,-1),Nt("cn4",t,e,Tt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};ll=new xt,Jd=class extends xn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new Be;s.setIndex(new Ze(i,1)),s.setAttribute("position",new Ze(r,3)),super(s,new Vt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&ll.setFromObject(this.object),ll.isEmpty())return;let t=ll.min,i=ll.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Qd=class extends xn{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Be;s.setIndex(new Ze(i,1)),s.setAttribute("position",new ye(r,3)),super(s,new Vt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},ep=class extends Un{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Be;o.setAttribute("position",new ye(s,3)),o.computeBoundingSphere(),super(o,new Vt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new Be;c.setAttribute("position",new ye(a,3)),c.computeBoundingSphere(),this.add(new ft(c,new sn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},hy=new w,tp=class extends it{constructor(e=new w(0,0,1),t=new w(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",ul===void 0&&(ul=new Be,ul.setAttribute("position",new ye([0,0,0,0,1,0],3)),ff=new fo(0,.5,1,5,1),ff.translate(0,-.5,0)),this.position.copy(t),this.line=new Un(ul,new Vt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ft(ff,new sn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{hy.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(hy,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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()}},np=class extends xn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Be;r.setAttribute("position",new ye(t,3)),r.setAttribute("color",new ye(i,3));let s=new Vt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new oe,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},ip=class{constructor(){this.type="ShapePath",this.color=new oe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ss,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){let _=[];for(let x=0,b=p.length;x<b;x++){let T=p[x],A=new Fi;A.curves=T.curves,_.push(A)}return _}function i(p,_){let x=_.length,b=!1;for(let T=x-1,A=0;A<x;T=A++){let M=_[T],C=_[A],S=C.x-M.x,v=C.y-M.y;if(Math.abs(v)>Number.EPSILON){if(v<0&&(M=_[A],S=-S,C=_[T],v=-v),p.y<M.y||p.y>C.y)continue;if(p.y===M.y){if(p.x===M.x)return!0}else{let L=v*(p.x-M.x)-S*(p.y-M.y);if(L===0)return!0;if(L<0)continue;b=!b}}else{if(p.y!==M.y)continue;if(C.x<=p.x&&p.x<=M.x||M.x<=p.x&&p.x<=C.x)return!0}}return b}let r=ai.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new Fi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let h=[],f=[],d=[],m=0,y;f[m]=void 0,d[m]=[];for(let p=0,_=s.length;p<_;p++)a=s[p],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new Fi,p:y},f[m].s.curves=a.curves,u&&m++,d[m]=[]):d[m].push({h:a,p:y[0]});if(!f[0])return t(s);if(f.length>1){let p=!1,_=0;for(let x=0,b=f.length;x<b;x++)h[x]=[];for(let x=0,b=f.length;x<b;x++){let T=d[x];for(let A=0;A<T.length;A++){let M=T[A],C=!0;for(let S=0;S<f.length;S++)i(M.p,f[S].p)&&(x!==S&&_++,C?(C=!1,h[S].push(M)):p=!0);C&&h[x].push(M)}}_>0&&p===!1&&(d=h)}let g;for(let p=0,_=f.length;p<_;p++){c=f[p].s,l.push(c),g=d[p];for(let x=0,b=g.length;x<b;x++)c.holes.push(g[x].h)}return l}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"160"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="160")});function Dm(n,e){if(e===dp)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===So||e===ka){let t=n.getIndex();if(t===null){let o=[],a=n.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}let i=t.count-2,r=[];if(e===So)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=n.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}var Eb=Eh(()=>{ei()});var Pb={};wg(Pb,{GLTFLoader:()=>zm});function NN(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function DN(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new fr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qn})),n.DefaultMaterial}function Ms(n,e,t){for(let i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function wr(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function UN(n,e,t){let i=!1,r=!1,s=!1;for(let l=0,u=e.length;l<u;l++){let h=e[l];if(h.POSITION!==void 0&&(i=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(n);let o=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];if(i){let f=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;o.push(f)}if(r){let f=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;a.push(f)}if(s){let f=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],f=l[2];return i&&(n.morphAttributes.position=u),r&&(n.morphAttributes.normal=h),s&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function FN(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function BN(n){let e,t=n.extensions&&n.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Bm(t.attributes):e=n.indices+":"+Bm(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+Bm(n.targets[i]);return e}function Bm(n){let e="",t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function lg(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function zN(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}function kN(n,e,t){let i=e.attributes,r=new xt;if(i.POSITION!==void 0){let a=t.json.accessors[i.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(r.set(new w(c[0],c[1],c[2]),new w(l[0],l[1],l[2])),a.normalized){let u=lg(Lo[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new w,c=new w;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let f=t.json.accessors[h.POSITION],d=f.min,m=f.max;if(d!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){let y=lg(Lo[f.componentType]);c.multiplyScalar(y)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}n.boundingBox=r;let o=new _t;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function Rb(n,e,t){let i=e.attributes,r=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){n.setAttribute(a,c)})}for(let o in i){let a=cg[o]||o.toLowerCase();a in n.attributes||r.push(s(i[o],a))}if(e.indices!==void 0&&!n.index){let o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});r.push(o)}return rt.workingColorSpace!==Dt&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rt.workingColorSpace}" not supported.`),wr(n,e),kN(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?UN(n,e.targets,t):n})}var zm,Je,Vm,km,Gm,Hm,Wm,Xm,Ym,qm,jm,$m,Km,Zm,Jm,Qm,eg,tg,ng,Ib,dc,wb,ig,rg,sg,og,fh,LN,ag,kn,Lo,Tb,Cb,Um,cg,Er,ON,Fm,VN,ug,Nb=Eh(()=>{ei();Eb();zm=class extends qt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Hm(t)}),this.register(function(t){return new Jm(t)}),this.register(function(t){return new Qm(t)}),this.register(function(t){return new eg(t)}),this.register(function(t){return new Xm(t)}),this.register(function(t){return new Ym(t)}),this.register(function(t){return new qm(t)}),this.register(function(t){return new jm(t)}),this.register(function(t){return new Gm(t)}),this.register(function(t){return new $m(t)}),this.register(function(t){return new Wm(t)}),this.register(function(t){return new Zm(t)}),this.register(function(t){return new Km(t)}),this.register(function(t){return new Vm(t)}),this.register(function(t){return new tg(t)}),this.register(function(t){return new ng(t)})}load(e,t,i,r){let s=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=Jn.extractUrlBase(e);o=Jn.resolveURL(l,this.path)}else o=Jn.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){r?r(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Sn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(u){t(u),s.manager.itemEnd(e)},a)}catch(u){a(u)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let s,o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ib){try{o[Je.KHR_BINARY_GLTF]=new ig(e)}catch(h){r&&r(h);return}s=JSON.parse(o[Je.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new ug(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){let h=s.extensionsUsed[u],f=s.extensionsRequired||[];switch(h){case Je.KHR_MATERIALS_UNLIT:o[h]=new km;break;case Je.KHR_DRACO_MESH_COMPRESSION:o[h]=new rg(s,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:o[h]=new sg;break;case Je.KHR_MESH_QUANTIZATION:o[h]=new og;break;default:f.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,r)}parseAsync(e,t){let i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}};Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Vm=class{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,i="light:"+e,r=t.cache.get(i);if(r)return r;let s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],l,u=new oe(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],Dt);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new mr(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new pr(u),l.distance=h;break;case"spot":l=new dr(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,wr(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(l),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,i=this.parser,s=i.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return i._getNodeRef(t.cache,a,c)})}},km=class{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return sn}extendParams(e,t,i){let r=[];e.color=new oe(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Dt),e.opacity=o[3]}s.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",s.baseColorTexture,lt))}return Promise.all(r)}},Gm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},Hm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Z(a,a)}return Promise.all(s)}},Wm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}},Xm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new oe(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Dt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,lt)),o.sheenRoughnessTexture!==void 0&&s.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}},Ym=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}},qm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new oe().setRGB(a[0],a[1],a[2],Dt),Promise.all(s)}},jm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},$m=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new oe().setRGB(a[0],a[1],a[2],Dt),o.specularColorTexture!==void 0&&s.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,lt)),Promise.all(s)}},Km=class{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}},Zm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}},Jm=class{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},Qm=class{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=i.textureLoader;if(a.uri){let l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(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}},eg=class{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=i.textureLoader;if(a.uri){let l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(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}},tg=class{constructor(e){this.name=Je.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){let r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let c=r.byteOffset||0,l=r.byteLength||0,u=r.count,h=r.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,r.mode,r.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(d),u,h,f,r.mode,r.filter),d})})}else return null}},ng=class{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;let r=t.meshes[i.mesh];for(let l of r.primitives)if(l.mode!==kn.TRIANGLES&&l.mode!==kn.TRIANGLE_STRIP&&l.mode!==kn.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=i.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],f=l[0].count,d=[];for(let m of h){let y=new we,g=new w,p=new Ft,_=new w(1,1,1),x=new ao(m.geometry,m.material,f);for(let b=0;b<f;b++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,b),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,b),c.SCALE&&_.fromBufferAttribute(c.SCALE,b),x.setMatrixAt(b,y.compose(g,p,_));for(let b in c)if(b==="_COLOR_0"){let T=c[b];x.instanceColor=new Kn(T.array,T.itemSize,T.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&m.geometry.setAttribute(b,c[b]);it.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}},Ib="glTF",dc=12,wb={JSON:1313821514,BIN:5130562},ig=class{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,dc),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ib)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-dc,s=new DataView(e,dc),o=0;for(;o<r;){let a=s.getUint32(o,!0);o+=4;let c=s.getUint32(o,!0);if(o+=4,c===wb.JSON){let l=new Uint8Array(e,dc+o,a);this.content=i.decode(l)}else if(c===wb.BIN){let l=dc+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},rg=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let i=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=cg[u]||u.toLowerCase();a[h]=o[u]}for(let u in e.attributes){let h=cg[u]||u.toLowerCase();if(o[u]!==void 0){let f=i.accessors[e.attributes[u]],d=Lo[f.componentType];l[h]=d.name,c[h]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(u){return new Promise(function(h,f){r.decodeDracoFile(u,function(d){for(let m in d.attributes){let y=d.attributes[m],g=c[m];g!==void 0&&(y.normalized=g)}h(d)},a,l,Dt,f)})})}},sg=class{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},og=class{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}},fh=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[s+o];return t}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=r-t,h=(i-t)/u,f=h*h,d=f*h,m=e*l,y=m-l,g=-2*d+3*f,p=d-f,_=1-g,x=p-f+h;for(let b=0;b!==a;b++){let T=o[y+b+a],A=o[y+b+c]*u,M=o[m+b+a],C=o[m+b]*u;s[b]=_*T+x*A+g*M+p*C}return s}},LN=new Ft,ag=class extends fh{interpolate_(e,t,i,r){let s=super.interpolate_(e,t,i,r);return LN.fromArray(s).normalize().toArray(s),s}},kn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Lo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Tb={9728:Mt,9729:yt,9984:Ks,9985:Va,9986:qr,9987:jn},Cb={33071:Xt,33648:Kr,10497:zi},Um={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cg={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Er={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ON={CUBICSPLINE:void 0,LINEAR:lr,STEP:Jr},Fm={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};VN=new we,ug=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new NN,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 i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new cs(this.options.manager):this.textureLoader=new Da(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Sn(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 i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return Ms(s,a,r),wr(a,r),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let o=t[r].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;let r=i.clone(),s=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())s(u,a.children[l])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let i=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&i.push(s)}return i}getDependency(e,t){let i=e+":"+t,r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,o){i.load(Jn.resolveURL(t.uri,r.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){let r=t.byteLength||0,s=t.byteOffset||0;return i.slice(s,s+r)})}loadAccessor(e){let t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let o=Um[r.type],a=Lo[r.componentType],c=r.normalized===!0,l=new a(r.count*o);return Promise.resolve(new Ze(l,o,c))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(o){let a=o[0],c=Um[r.type],l=Lo[r.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,f=r.byteOffset||0,d=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,m=r.normalized===!0,y,g;if(d&&d!==h){let p=Math.floor(f/d),_="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+p+":"+r.count,x=t.cache.get(_);x||(y=new l(a,p*d,r.count*d/u),x=new Vi(y,d/u),t.cache.add(_,x)),g=new Yt(x,c,f%d/u,m)}else a===null?y=new l(r.count*c):y=new l(a,f,r.count*c),g=new Ze(y,c,m);if(r.sparse!==void 0){let p=Um.SCALAR,_=Lo[r.sparse.indices.componentType],x=r.sparse.indices.byteOffset||0,b=r.sparse.values.byteOffset||0,T=new _(o[1],x,r.sparse.count*p),A=new l(o[2],b,r.sparse.count*c);a!==null&&(g=new Ze(g.array.slice(),g.itemSize,g.normalized));for(let M=0,C=T.length;M<C;M++){let S=T[M];if(g.setX(S,A[M*c]),c>=2&&g.setY(S,A[M*c+1]),c>=3&&g.setZ(S,A[M*c+2]),c>=4&&g.setW(S,A[M*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){let t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let c=i.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){let r=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,i).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(s.samplers||{})[o.sampler]||{};return u.magFilter=Tb[f.magFilter]||yt,u.minFilter=Tb[f.minFilter]||jn,u.wrapS=Cb[f.wrapS]||zi,u.wrapT=Cb[f.wrapT]||zi,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());let o=r.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let f=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let m=f;t.isImageBitmapLoader===!0&&(m=function(y){let g=new Rt(y);g.needsUpdate=!0,f(g)}),t.load(Jn.resolveURL(h,s.path),m,void 0,d)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),h.userData.mimeType=o.mimeType||zN(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,i,r){let s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[Je.KHR_TEXTURE_TRANSFORM]){let a=i.extensions!==void 0?i.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=s.associations.get(o);o=s.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,i=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+i.uuid,c=this.cache.get(a);c||(c=new rs,It.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(a,c)),i=c}else if(e.isLine){let a="LineBasicMaterial:"+i.uuid,c=this.cache.get(a);c||(c=new Vt,It.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(a,c)),i=c}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=i.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return fr}loadMaterial(e){let t=this,i=this.json,r=this.extensions,s=i.materials[e],o,a={},c=s.extensions||{},l=[];if(c[Je.KHR_MATERIALS_UNLIT]){let h=r[Je.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new oe(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Dt),a.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,lt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=On);let u=s.alphaMode||Fm.OPAQUE;if(u===Fm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Fm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==sn&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Z(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==sn&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==sn){let h=s.emissiveFactor;a.emissive=new oe().setRGB(h[0],h[1],h[2],Dt)}return s.emissiveTexture!==void 0&&o!==sn&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,lt)),Promise.all(l).then(function(){let h=new o(a);return s.name&&(h.name=s.name),wr(h,s),t.associations.set(h,{materials:e}),s.extensions&&Ms(r,h,s),h})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Rb(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],u=BN(l),h=r[u];if(h)o.push(h.promise);else{let f;l.extensions&&l.extensions[Je.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=Rb(new Be,l,t),r[u]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,i=this.json,r=this.extensions,s=i.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?DN(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let d=0,m=u.length;d<m;d++){let y=u[d],g=o[d],p,_=l[d];if(g.mode===kn.TRIANGLES||g.mode===kn.TRIANGLE_STRIP||g.mode===kn.TRIANGLE_FAN||g.mode===void 0)p=s.isSkinnedMesh===!0?new so(y,_):new ft(y,_),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===kn.TRIANGLE_STRIP?p.geometry=Dm(p.geometry,ka):g.mode===kn.TRIANGLE_FAN&&(p.geometry=Dm(p.geometry,So));else if(g.mode===kn.LINES)p=new xn(y,_);else if(g.mode===kn.LINE_STRIP)p=new Un(y,_);else if(g.mode===kn.LINE_LOOP)p=new co(y,_);else if(g.mode===kn.POINTS)p=new lo(y,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&FN(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),wr(p,s),g.extensions&&Ms(r,p,g),t.assignFinalMaterial(p),h.push(p)}for(let d=0,m=h.length;d<m;d++)t.associations.set(h[d],{meshes:e,primitives:d});if(h.length===1)return s.extensions&&Ms(r,h[0],s),h[0];let f=new Dn;s.extensions&&Ms(r,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=h.length;d<m;d++)f.add(h[d]);return f})}loadCamera(e){let t,i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new vt(Ha.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new ci(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),wr(t,i),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],i=[];for(let r=0,s=t.joints.length;r<s;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){let s=r.pop(),o=r,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let f=new we;s!==null&&f.fromArray(s.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new oo(a,c)})}loadAnimation(e){let t=this.json,i=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let h=0,f=r.channels.length;h<f;h++){let d=r.channels[h],m=r.samplers[d.sampler],y=d.target,g=y.node,p=r.parameters!==void 0?r.parameters[m.input]:m.input,_=r.parameters!==void 0?r.parameters[m.output]:m.output;y.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",_)),l.push(m),u.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let f=h[0],d=h[1],m=h[2],y=h[3],g=h[4],p=[];for(let _=0,x=f.length;_<x;_++){let b=f[_],T=d[_],A=m[_],M=y[_],C=g[_];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();let S=i._createAnimationTracks(b,T,A,M,C);if(S)for(let v=0;v<S.length;v++)p.push(S[v])}return new Wi(s,void 0,p)})}createNodeMesh(e){let t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(s){let o=i._getNodeRef(i.meshCache,r.mesh,s);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=r.weights.length;c<l;c++)a.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){let t=this.json,i=this,r=t.nodes[e],s=i._loadNodeShallow(e),o=[],a=r.children||[];for(let l=0,u=a.length;l<u;l++)o.push(i.getDependency("node",a[l]));let c=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],f=l[2];f!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(f,VN)});for(let d=0,m=h.length;d<m;d++)u.add(h[d]);return u})}_loadNodeShallow(e){let t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(l){return r._getNodeRef(r.cameraCache,s.camera,l)})),r._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(s.isBone===!0?u=new is:l.length>1?u=new Dn:l.length===1?u=l[0]:u=new it,u!==l[0])for(let h=0,f=l.length;h<f;h++)u.add(l[h]);if(s.name&&(u.userData.name=s.name,u.name=o),wr(u,s),s.extensions&&Ms(i,u,s),s.matrix!==void 0){let h=new we;h.fromArray(s.matrix),u.applyMatrix4(h)}else s.translation!==void 0&&u.position.fromArray(s.translation),s.rotation!==void 0&&u.quaternion.fromArray(s.rotation),s.scale!==void 0&&u.scale.fromArray(s.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,i=this.json.scenes[e],r=this,s=new Dn;i.name&&(s.name=r.createUniqueName(i.name)),wr(s,i),i.extensions&&Ms(t,s,i);let o=i.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(r.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)s.add(c[u]);let l=u=>{let h=new Map;for(let[f,d]of r.associations)(f instanceof It||f instanceof Rt)&&h.set(f,d);return u.traverse(f=>{let d=r.associations.get(f);d!=null&&h.set(f,d)}),h};return r.associations=l(s),s})}_createAnimationTracks(e,t,i,r,s){let o=[],a=e.name?e.name:e.uuid,c=[];Er[s.path]===Er.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Er[s.path]){case Er.weights:l=li;break;case Er.rotation:l=Zn;break;case Er.position:case Er.scale:l=ui;break;default:i.itemSize===1?l=li:l=ui;break}let u=r.interpolation!==void 0?ON[r.interpolation]:lr,h=this._getArrayFromAccessor(i);for(let f=0,d=c.length;f<d;f++){let m=new l(c[f]+"."+Er[s.path],t.array,h,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let i=lg(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){let r=this instanceof Zn?ag:fh;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}});var pM={signature:"GIF",version:"89a",trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};function Ig(n=256){let e=0,t=new Uint8Array(n);return{get buffer(){return t.buffer},reset(){e=0},bytesView(){return t.subarray(0,e)},bytes(){return t.slice(0,e)},writeByte(r){i(e+1),t[e]=r,e++},writeBytes(r,s=0,o=r.length){i(e+o);for(let a=0;a<o;a++)t[e++]=r[a+s]},writeBytesView(r,s=0,o=r.byteLength){i(e+o),t.set(r.subarray(s,s+o),e),e+=o}};function i(r){var s=t.length;if(s>=r)return;var o=1024*1024;r=Math.max(r,s*(s<o?2:1.125)>>>0),s!=0&&(r=Math.max(r,256));let a=t;t=new Uint8Array(r),e>0&&t.set(a.subarray(0,e),0)}}var wh=12,Tg=5003,mM=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function gM(n,e,t,i,r=Ig(512),s=new Uint8Array(256),o=new Int32Array(Tg),a=new Int32Array(Tg)){let c=o.length,l=Math.max(2,i);s.fill(0),a.fill(0),o.fill(-1);let u=0,h=0,f=l+1,d=f,m=!1,y=d,g=(1<<y)-1,p=1<<f-1,_=p+1,x=p+2,b=0,T=t[0],A=0;for(let S=c;S<65536;S*=2)++A;A=8-A,r.writeByte(l),C(p);let M=t.length;for(let S=1;S<M;S++)e:{let v=t[S],L=(v<<wh)+T,U=v<<A^T;if(o[U]===L){T=a[U];break e}let G=U===0?1:c-U;for(;o[U]>=0;)if(U-=G,U<0&&(U+=c),o[U]===L){T=a[U];break e}C(T),T=v,x<1<<wh?(a[U]=x++,o[U]=L):(o.fill(-1),x=p+2,m=!0,C(p))}return C(T),C(_),r.writeByte(0),r.bytesView();function C(S){for(u&=mM[h],h>0?u|=S<<h:u=S,h+=y;h>=8;)s[b++]=u&255,b>=254&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0),u>>=8,h-=8;if((x>g||m)&&(m?(y=d,g=(1<<y)-1,m=!1):(++y,g=y===wh?1<<y:(1<<y)-1)),S==_){for(;h>0;)s[b++]=u&255,b>=254&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0),u>>=8,h-=8;b>0&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0)}}}var yM=gM;function Pg(n,e,t){return n<<8&63488|e<<2&992|t>>3}function Ng(n,e,t,i){return n>>4|e&240|(t&240)<<4|(i&240)<<8}function Lg(n,e,t){return n>>4<<8|e&240|t>>4}function xc(n,e,t){return n<e?e:n>t?t:n}function Uo(n){return n*n}function Cg(n,e,t){var i=0,r=1e100;let s=n[e],o=s.cnt,a=s.ac,c=s.rc,l=s.gc,u=s.bc;for(var h=s.fw;h!=0;h=n[h].fw){let d=n[h],m=d.cnt,y=o*m/(o+m);if(!(y>=r)){var f=0;t&&(f+=y*Uo(d.ac-a),f>=r)||(f+=y*Uo(d.rc-c),!(f>=r)&&(f+=y*Uo(d.gc-l),!(f>=r)&&(f+=y*Uo(d.bc-u),!(f>=r)&&(r=f,i=h))))}}s.err=r,s.nn=i}function Th(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function xM(n,e){let t=e==="rgb444"?4096:65536,i=new Array(t),r=n.length;if(e==="rgba4444")for(let s=0;s<r;++s){let o=n[s],a=o>>24&255,c=o>>16&255,l=o>>8&255,u=o&255,h=Ng(u,l,c,a),f=h in i?i[h]:i[h]=Th();f.rc+=u,f.gc+=l,f.bc+=c,f.ac+=a,f.cnt++}else if(e==="rgb444")for(let s=0;s<r;++s){let o=n[s],a=o>>16&255,c=o>>8&255,l=o&255,u=Lg(l,c,a),h=u in i?i[u]:i[u]=Th();h.rc+=l,h.gc+=c,h.bc+=a,h.cnt++}else for(let s=0;s<r;++s){let o=n[s],a=o>>16&255,c=o>>8&255,l=o&255,u=Pg(l,c,a),h=u in i?i[u]:i[u]=Th();h.rc+=l,h.gc+=c,h.bc+=a,h.cnt++}return i}function Og(n,e,t={}){let{format:i="rgb565",clearAlpha:r=!0,clearAlphaColor:s=0,clearAlphaThreshold:o=0,oneBitAlpha:a=!1}=t;if(!n||!n.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(n instanceof Uint8Array)&&!(n instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let c=new Uint32Array(n.buffer),l=t.useSqrt!==!1,u=i==="rgba4444",h=xM(c,i),f=h.length,d=f-1,m=new Uint32Array(f+1);for(var y=0,g=0;g<f;++g){let P=h[g];if(P!=null){var p=1/P.cnt;u&&(P.ac*=p),P.rc*=p,P.gc*=p,P.bc*=p,h[y++]=P}}Uo(e)/y<.022&&(l=!1);for(var g=0;g<y-1;++g)h[g].fw=g+1,h[g+1].bk=g,l&&(h[g].cnt=Math.sqrt(h[g].cnt));l&&(h[g].cnt=Math.sqrt(h[g].cnt));var _,x,b;for(g=0;g<y;++g){Cg(h,g,!1);var T=h[g].err;for(x=++m[0];x>1&&(b=x>>1,!(h[_=m[b]].err<=T));x=b)m[x]=_;m[x]=g}var A=y-e;for(g=0;g<A;){for(var M;;){var C=m[1];if(M=h[C],M.tm>=M.mtm&&h[M.nn].mtm<=M.tm)break;M.mtm==d?C=m[1]=m[m[0]--]:(Cg(h,C,!1),M.tm=g);var T=h[C].err;for(x=1;(b=x+x)<=m[0]&&(b<m[0]&&h[m[b]].err>h[m[b+1]].err&&b++,!(T<=h[_=m[b]].err));x=b)m[x]=_;m[x]=C}var S=h[M.nn],v=M.cnt,L=S.cnt,p=1/(v+L);u&&(M.ac=p*(v*M.ac+L*S.ac)),M.rc=p*(v*M.rc+L*S.rc),M.gc=p*(v*M.gc+L*S.gc),M.bc=p*(v*M.bc+L*S.bc),M.cnt+=S.cnt,M.mtm=++g,h[S.bk].fw=S.fw,h[S.fw].bk=S.bk,S.mtm=d}let U=[];var G=0;for(g=0;;++G){let P=xc(Math.round(h[g].rc),0,255),D=xc(Math.round(h[g].gc),0,255),z=xc(Math.round(h[g].bc),0,255),q=255;u&&(q=xc(Math.round(h[g].ac),0,255),a&&(q=q<=(typeof a=="number"?a:127)?0:255),r&&q<=o&&(P=D=z=s,q=0));let Y=u?[P,D,z,q]:[P,D,z];if(_M(U,Y)||U.push(Y),(g=h[g].fw)==0)break}return U}function _M(n,e){for(let t=0;t<n.length;t++){let i=n[t],r=i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2],s=i.length>=4&&e.length>=4?i[3]===e[3]:!0;if(r&&s)return!0}return!1}function Dg(n,e,t="rgb565"){if(!n||!n.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(n instanceof Uint8Array)&&!(n instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");if(e.length>256)throw new Error("applyPalette() only works with 256 colors or less");let i=new Uint32Array(n.buffer),r=i.length,s=t==="rgb444"?4096:65536,o=new Uint8Array(r),a=new Array(s),c=t==="rgba4444";if(t==="rgba4444")for(let l=0;l<r;l++){let u=i[l],h=u>>24&255,f=u>>16&255,d=u>>8&255,m=u&255,y=Ng(m,d,f,h),g=y in a?a[y]:a[y]=SM(m,d,f,h,e);o[l]=g}else{let l=t==="rgb444"?Lg:Pg;for(let u=0;u<r;u++){let h=i[u],f=h>>16&255,d=h>>8&255,m=h&255,y=l(m,d,f),g=y in a?a[y]:a[y]=bM(m,d,f,e);o[u]=g}}return o}function SM(n,e,t,i,r){let s=0,o=1e100;for(let a=0;a<r.length;a++){let c=r[a],l=c[3],u=Rr(l-i);if(u>o)continue;let h=c[0];if(u+=Rr(h-n),u>o)continue;let f=c[1];if(u+=Rr(f-e),u>o)continue;let d=c[2];u+=Rr(d-t),!(u>o)&&(o=u,s=a)}return s}function bM(n,e,t,i){let r=0,s=1e100;for(let o=0;o<i.length;o++){let a=i[o],c=a[0],l=Rr(c-n);if(l>s)continue;let u=a[1];if(l+=Rr(u-e),l>s)continue;let h=a[2];l+=Rr(h-t),!(l>s)&&(s=l,r=o)}return r}function Rr(n){return n*n}function Ch(n={}){let{initialCapacity:e=4096,auto:t=!0}=n,i=Ig(e),r=5003,s=new Uint8Array(256),o=new Int32Array(r),a=new Int32Array(r),c=!1;return{reset(){i.reset(),c=!1},finish(){i.writeByte(pM.trailer)},bytes(){return i.bytes()},bytesView(){return i.bytesView()},get buffer(){return i.buffer},get stream(){return i},writeHeader:l,writeFrame(u,h,f,d={}){let{transparent:m=!1,transparentIndex:y=0,delay:g=0,palette:p=null,repeat:_=0,colorDepth:x=8,dispose:b=-1}=d,T=!1;if(t?c||(T=!0,l(),c=!0):T=!!d.first,h=Math.max(0,Math.floor(h)),f=Math.max(0,Math.floor(f)),T){if(!p)throw new Error("First frame must include a { palette } option");vM(i,h,f,p,x),Rg(i,p),_>=0&&AM(i,_)}let A=Math.round(g/10);MM(i,b,A,m,y);let M=!!p&&!T;EM(i,h,f,M?p:null),M&&Rg(i,p),wM(i,u,h,f,x,s,o,a)}};function l(){Ug(i,"GIF89a")}}function MM(n,e,t,i,r){n.writeByte(33),n.writeByte(249),n.writeByte(4),r<0&&(r=0,i=!1);var s,o;i?(s=1,o=2):(s=0,o=0),e>=0&&(o=e&7),o<<=2,n.writeByte(0|o|0|s),Ki(n,t),n.writeByte(r||0),n.writeByte(0)}function vM(n,e,t,i,r=8){let s=1,o=0,a=Rh(i.length)-1,c=s<<7|r-1<<4|o<<3|a;Ki(n,e),Ki(n,t),n.writeBytes([c,0,0])}function AM(n,e){n.writeByte(33),n.writeByte(255),n.writeByte(11),Ug(n,"NETSCAPE2.0"),n.writeByte(3),n.writeByte(1),Ki(n,e),n.writeByte(0)}function Rg(n,e){let t=1<<Rh(e.length);for(let i=0;i<t;i++){let r=[0,0,0];i<e.length&&(r=e[i]),n.writeByte(r[0]),n.writeByte(r[1]),n.writeByte(r[2])}}function EM(n,e,t,i){if(n.writeByte(44),Ki(n,0),Ki(n,0),Ki(n,e),Ki(n,t),i){let r=0,s=0,o=Rh(i.length)-1;n.writeByte(128|r|s|0|o)}else n.writeByte(0)}function wM(n,e,t,i,r=8,s,o,a){yM(t,i,e,r,n,s,o,a)}function Ki(n,e){n.writeByte(e&255),n.writeByte(e>>8&255)}function Ug(n,e){for(var t=0;t<e.length;t++)n.writeByte(e.charCodeAt(t))}function Rh(n){return Math.max(Math.ceil(Math.log2(n)),1)}var Fo=Ch;ei();var Px=Object.freeze(["x","y","z"]),Mp=Object.freeze({x:0,y:0,z:0}),Au=Object.freeze({enabled:!1,axis:"x",offset:Mp.x,offsets:Mp,invert:!1}),Nx=Object.freeze({x:0,y:1,z:2}),hC=1e-6;function Lx(n,e){let t=Number(n);return Number.isFinite(t)?t:e}function fC(n,e,t){return Math.min(Math.max(n,e),t)}function Xa(n=null){let e=n&&typeof n=="object"?n:{},t=Px.includes(String(e.axis||"").toLowerCase())?String(e.axis).toLowerCase():Au.axis,i=e.offsets&&typeof e.offsets=="object"?e.offsets:{},r=Lx(e.offset,Au.offset),s=Object.fromEntries(Px.map(l=>[l,fC(Lx(i[l],l===t?r:Mp[l]),0,1)])),o=s[t],a=o>hC;return{enabled:(e.enabled===!0?!0:e.enabled===!1?!1:a)&&a,axis:t,offset:o,offsets:s,invert:e.invert===!0}}function Ox(n){return Nx[String(n||"").toLowerCase()]??Nx.x}ei();var Bn=Object.freeze([0,0,1]),vp=Object.freeze([0,1,0]),ls=Object.freeze({front:Object.freeze({name:"front",direction:Object.freeze([0,-1,0]),up:Bn}),back:Object.freeze({name:"back",direction:Object.freeze([0,1,0]),up:Bn}),right:Object.freeze({name:"right",direction:Object.freeze([1,0,0]),up:Bn}),left:Object.freeze({name:"left",direction:Object.freeze([-1,0,0]),up:Bn}),top:Object.freeze({name:"top",direction:Object.freeze([0,0,1]),up:vp}),bottom:Object.freeze({name:"bottom",direction:Object.freeze([0,0,-1]),up:vp}),iso:Object.freeze({name:"iso",direction:Object.freeze([1,-1,.8]),up:Bn}),isometric:Object.freeze({name:"iso",direction:Object.freeze([1,-1,.8]),up:Bn}),side:Object.freeze({name:"side",direction:Object.freeze([1,0,0]),up:Bn})});var fi="iso",dC=Object.freeze(["preset","position","target","up","zoom","direction","name"]);function Fx(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Fn(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function Mo(n,{fieldName:e="camera vector",required:t=!1,nonZero:i=!1,strict:r=!0}={}){if(n==null){if(t&&r)throw new Error(`${e} must be a three-number array`);return null}if(!Array.isArray(n)||n.length<3){if(r)throw new Error(`${e} must be a three-number array`);return null}let s=[Number(n[0]),Number(n[1]),Number(n[2])];if(!s.every(Number.isFinite)){if(r)throw new Error(`${e} must contain only finite numbers`);return null}if(i&&s[0]**2+s[1]**2+s[2]**2<=1e-12){if(r)throw new Error(`${e} must not be the zero vector`);return null}return s}function Eu(n,e=1,{fieldName:t="camera.zoom",strict:i=!1}={}){if(n==null||n==="")return e;let r=Number(n);if(Number.isFinite(r)&&r>0)return r;if(i)throw new Error(`${t} must be a positive finite number`);return e}function Dx(n){return{name:n.name,direction:[...n.direction],up:[...n.up]}}function Ux(n,{presets:e=ls,strict:t=!0}={}){let i=String(n||fi).trim().toLowerCase();if(e[i])return Dx(e[i]);let r=i.split(":").map(s=>Number(s));if(r.length>=2&&r.every(Number.isFinite)){let s=r[0]*Math.PI/180,o=r[1]*Math.PI/180,a=Math.cos(o);return{name:`${r[0]}:${r[1]}`,direction:[Math.sin(s)*a,-Math.cos(s)*a,Math.sin(o)],up:[...Bn]}}if(t)throw new Error(`Unknown camera preset: ${n}`);return Dx(e[fi])}function pC(n,{strict:e=!0}={}){let t=String(n||"").trim();if(!t.startsWith("{"))return null;try{let i=JSON.parse(t);if(!Fx(i))throw new Error("camera JSON must be an object");return i}catch(i){if(e){let r=i instanceof Error?i.message:String(i);throw new Error(`Invalid camera JSON: ${r}`)}return null}}function mC(n){let e=Object.keys(n).filter(t=>!dC.includes(t));if(e.length)throw new Error(`Unsupported camera fields: ${e.join(", ")}`)}function Ap(n=fi,{presets:e=ls,strict:t=!0}={}){let r=(typeof n=="string"?pC(n,{strict:t}):null)||n;if(!Fx(r)){let f=Ux(r||fi,{presets:e,strict:t});return{sourceKind:"string",name:f.name,preset:f.name,direction:f.direction,position:null,target:null,up:f.up,zoom:1,hasExplicitPosition:!1,hasExplicitTarget:!1,hasExplicitUp:!1,hasExplicitZoom:!1}}mC(r);let s=r.preset??fi,o=Ux(s,{presets:e,strict:t}),a=Mo(r.direction,{fieldName:"camera.direction",nonZero:!0,strict:t})||o.direction,c=Mo(r.position,{fieldName:"camera.position",strict:t}),l=Mo(r.target,{fieldName:"camera.target",strict:t}),u=Mo(r.up,{fieldName:"camera.up",nonZero:!0,strict:t})||o.up||[...Bn],h=Object.prototype.hasOwnProperty.call(r,"zoom");return{sourceKind:"object",name:String(r.name||o.name||"custom"),preset:o.name,direction:a,position:c,target:l,up:u,zoom:Eu(r.zoom,1,{strict:t,fieldName:"camera.zoom"}),hasExplicitPosition:Object.prototype.hasOwnProperty.call(r,"position"),hasExplicitTarget:Object.prototype.hasOwnProperty.call(r,"target"),hasExplicitUp:Object.prototype.hasOwnProperty.call(r,"up"),hasExplicitZoom:h}}function Bx(n,e){return e?.[n]?e[n]:e?.cad?e.cad:{minBoundsSpan:1,minModelRadius:1,minCameraDistance:10,minCameraFar:1e3}}function gC(n,e,t){let i=Bx(e,t),r=Array.isArray(n?.min)?n.min:[0,0,0],s=Array.isArray(n?.max)?n.max:[1,1,1],o=new w((Fn(r[0])+Fn(s[0],1))/2,(Fn(r[1])+Fn(s[1],1))/2,(Fn(r[2])+Fn(s[2],1))/2),a=new w(Math.max(Fn(s[0],1)-Fn(r[0]),i.minBoundsSpan),Math.max(Fn(s[1],1)-Fn(r[1]),i.minBoundsSpan),Math.max(Fn(s[2],1)-Fn(r[2]),i.minBoundsSpan));return{center:o,radius:Math.max(a.length()/2,i.minModelRadius),size:a}}function vo(n){return new w(n[0],n[1],n[2])}function zx(n=fi,e={}){let t=Ap(n,e),i=t.target?vo(t.target):null,r=t.position?vo(t.position):null,s=r&&i?r.clone().sub(i).normalize().toArray():Mo(t.direction,{fieldName:"camera.direction",nonZero:!0,strict:!1})||[...ls[fi].direction];return{name:t.name,direction:s,up:[...t.up||Bn],zoom:t.zoom}}function Ep(n=fi,e=null,{sceneScale:t="cad",settingsByScale:i=null,presets:r=ls,strict:s=!0}={}){let o=Ap(n,{presets:r,strict:s}),a=Bx(t,i),{center:c,radius:l,size:u}=gC(e,t,i),h=o.target?vo(o.target):c.clone(),f=Mo(o.direction,{fieldName:"camera.direction",nonZero:!0,strict:s})||[...ls[fi].direction],d=o.position?vo(o.position):h.clone().add(vo(f).normalize().multiplyScalar(Math.max(l*3.2,a.minCameraDistance||a.minModelRadius*10||10))),m=d.clone().sub(h);if(m.lengthSq()<=1e-12)throw new Error("camera.position must differ from camera.target");let y=vo(o.up||Bn);if(y.lengthSq()<=1e-12)throw new Error("camera.up must not be the zero vector");return{name:o.name,preset:o.preset,position:d.toArray(),target:h.toArray(),up:y.normalize().toArray(),zoom:o.zoom,direction:m.normalize().toArray(),view:{name:o.name,direction:m.normalize().toArray(),up:y.normalize().toArray(),zoom:o.zoom},sourceKind:o.sourceKind,hasExplicitPosition:o.hasExplicitPosition,hasExplicitTarget:o.hasExplicitTarget,hasExplicitUp:o.hasExplicitUp,hasExplicitZoom:o.hasExplicitZoom,radius:l,size:u.toArray()}}function Vx(n=fi,e={}){let t=Ap(n,e);return t.sourceKind==="object"&&(t.hasExplicitPosition||t.hasExplicitTarget||t.hasExplicitUp)}var bn=Object.freeze({PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"});function wu(n,e=bn.PERSPECTIVE){let t=String(n||"").trim().toLowerCase();return t===bn.ORTHOGRAPHIC?bn.ORTHOGRAPHIC:t===bn.PERSPECTIVE?bn.PERSPECTIVE:e===bn.ORTHOGRAPHIC?bn.ORTHOGRAPHIC:bn.PERSPECTIVE}var at=Object.freeze({HIDDEN_EDGES:"hidden_edges",HIDDEN_LINES_REMOVED:"hidden_lines_removed",RENDERED:"rendered",SOLID:"solid",TRANSPARENT:"transparent",UNSHADED:"unshaded",WIREFRAME:"wireframe"}),yC=Object.freeze(Object.values(at)),xC=Object.freeze(["x","y","z","radial"]),VL=Object.freeze(["positive","negative"]),Tu=8,_C=/^#(?:[0-9a-fA-F]{3}){1,2}$/,us="#132232",kx="#8dc5ff",SC=Object.freeze(["feature","tangent","seam","degenerate"]),wp=Object.freeze({feature:Object.freeze({color:us,opacity:1,thickness:1.15}),tangent:Object.freeze({color:us,opacity:.5,thickness:1.15}),seam:Object.freeze({color:us,opacity:.85,thickness:1.15}),degenerate:Object.freeze({color:us,opacity:1,thickness:0})}),Ya=Object.freeze({enabled:!0,contrastMode:"manual",color:us,thickness:1,classes:wp,highlightColor:kx,highlightOpacity:1,highlightThickness:3,silhouette:!1,silhouetteScale:0}),Gx=Object.freeze({...Ya,enabled:!1}),Xi=Object.freeze({enabled:!1,axis:"z",direction:"positive",spacing:1.45,depth:1,keepBaseGrounded:!0,mergeCoplanar:!1,autoFrame:!0}),bC=Object.freeze({projection:bn.ORTHOGRAPHIC,mode:at.SOLID,clip:Au,exploded:Xi,edges:Ya});function fs(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Hx(n,e,t){return Math.min(Math.max(n,e),t)}function hs(n,e,t=-1/0,i=1/0){let r=Number(n);return Number.isFinite(r)?Hx(r,t,i):e}function Cu(n,e){let t=String(n||"").trim();return _C.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function Ao(n,e=!1){return typeof n=="boolean"?n:e}function MC(n,e="manual"){let t=String(n||"").trim().toLowerCase();return["auto","manual"].includes(t)?t:e}function vC(n={},e=wp,t=us){let i=fs(n)?n:{},r=Cu(t,us);return Object.fromEntries(SC.map(s=>{let o=fs(i[s])?i[s]:{},a=e?.[s]||wp[s],c=o.enabled===!1;return[s,{color:Cu(o.color,r),opacity:hs(o.opacity,a.opacity,0,1),thickness:c?0:hs(o.thickness,a.thickness,0,6)}]}))}function qa(n=null,e=Ya){let t=fs(n)?n:{},i=Cu(t.color,e.color),r={enabled:Ao(t.enabled,e.enabled),contrastMode:MC(t.contrastMode,e.contrastMode),color:i,thickness:hs(t.thickness,e.thickness,.5,6),classes:vC(t.classes,e.classes,i),highlightColor:Cu(t.highlightColor,e.highlightColor||kx),highlightOpacity:hs(t.highlightOpacity,e.highlightOpacity||1,0,1),highlightThickness:hs(t.highlightThickness,e.highlightThickness||3,.5,6),silhouette:Ao(t.silhouette,e.silhouette||!1),silhouetteScale:hs(t.silhouetteScale,e.silhouetteScale||0,0,.04)};return typeof t.depthTest=="boolean"&&(r.depthTest=t.depthTest),r}function AC(n){return String(n||"").trim().toLowerCase().replace(/\s+/g,"_").replace(/-/g,"_")}function ti(n){let e=AC(n);return e?e==="wire"||e==="wire_frame"?at.WIREFRAME:e==="edges"||e==="edge"||e==="shaded_edges"||e==="shaded_with_edges"||e==="with_edges"?at.SOLID:e==="shaded"||e==="shaded_without_edges"||e==="without_edges"?at.RENDERED:e==="translucent"||e==="xray"||e==="x_ray"||e==="see_through"?at.TRANSPARENT:e==="hidden_edge"||e==="hidden_edges_visible"||e==="hidden_edge_display"||e==="shaded_hidden_edges"?at.HIDDEN_EDGES:e==="visible_edges"||e==="visible_edges_only"||e==="hidden_lines"||e==="hidden_line_removed"||e==="hidden_lines_removed"||e==="hidden_edges_removed"?at.HIDDEN_LINES_REMOVED:e==="flat"?at.UNSHADED:e==="appearance"||e==="material"||e==="materials"?at.RENDERED:yC.includes(e)?e:at.SOLID:at.SOLID}function EC(n,e=Xi.axis){let t=String(n||"").trim().toLowerCase(),i=t.startsWith("-")?t.slice(1):t;return xC.includes(i)?i:e}function wC(n,e=Xi.direction){let t=String(n||"").trim().toLowerCase();return["negative","reverse","down","backward","-","-1"].includes(t)?"negative":["positive","forward","up","+","+1","1"].includes(t)?"positive":e}function TC(n,e=Xi.depth){let t=String(n??"").trim().toLowerCase();if(["all","full","parts","leaves","leaf"].includes(t))return Tu;let i=Math.round(Number(n));return Number.isFinite(i)?Hx(i,1,Tu):e}function Tp(n=null,e={}){let t=fs(n)?n:{},i=fs(e)?{...t,...e}:t,r=String(i.axis||"").trim().toLowerCase();return{enabled:Ao(i.enabled,Xi.enabled),axis:EC(i.axis),direction:wC(i.direction||(r.startsWith("-")?"negative":"positive")),spacing:hs(i.spacing??i.distance??i.distanceScale,Xi.spacing,.25,4),depth:TC(i.depth??i.levels??i.scopeDepth),keepBaseGrounded:Ao(i.keepBaseGrounded??i.groundBase,Xi.keepBaseGrounded),mergeCoplanar:Ao(i.mergeCoplanar??i.mergeLayers??i.coalesceLayers,Xi.mergeCoplanar),autoFrame:Ao(i.autoFrame,Xi.autoFrame)}}function Ru(n=null){let e=fs(n)?n:{},t={};return fs(e.exploded)&&e.exploded.enabled!==void 0&&(t.enabled=e.exploded.enabled),{projection:wu(e.projection,bC.projection),mode:ti(e.mode),clip:Xa(e.clip),exploded:Tp(e.exploded,t),edges:qa(e.edges)}}function Wx(n){return Ru(n).edges}function di(n){return ti(n)===at.WIREFRAME}function ja(n){return[at.SOLID,at.TRANSPARENT,at.HIDDEN_EDGES,at.HIDDEN_LINES_REMOVED].includes(ti(n))}function Xx(n){return![at.RENDERED,at.UNSHADED].includes(ti(n))}function Yx(n,e=null){let t=ti(n);return t===at.WIREFRAME||ja(t)}function Eo(n){return[at.TRANSPARENT,at.HIDDEN_EDGES].includes(ti(n))}function qx(n){return[at.UNSHADED,at.HIDDEN_LINES_REMOVED,at.WIREFRAME].includes(ti(n))}function Iu(n,e=1){let t=ti(n);if(t===at.WIREFRAME)return .035;if(t===at.TRANSPARENT)return .22;if(t===at.HIDDEN_LINES_REMOVED)return .045;let i=Number(e);return Number.isFinite(i)?i:1}var CC=/^#(?:[0-9a-fA-F]{3}){1,2}$/,RC=50,tc=Ya,nc=Gx;function Qx(n,e,t){return Math.min(Math.max(n,e),t)}function nt(n,e,t=-1/0,i=1/0){let r=Number(n);return Number.isFinite(r)?Qx(r,t,i):e}function St(n,e){let t=String(n||"").trim();return CC.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function e_(n,e=Se?.materials?.defaultColor||"#ffffff"){let i=(Array.isArray(n)?n:[n]).map(r=>St(r,"")).filter(Boolean).slice(0,RC);return i.length?i:[St(e,"#ffffff")]}function Pp(n={},e=0){let t=e_(n.fillColors,n.defaultColor||Se?.materials?.defaultColor||"#ffffff"),r=In(n.cycleColors,Se?.materials?.cycleColors||!1)?Math.max(Math.floor(Number(e)||0),0)%t.length:0;return t[r]}function IC(n,e="#000000"){let t=St(n,e),i=t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t,r=s=>{let o=parseInt(i.slice(s,s+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return{r:r(1),g:r(3),b:r(5)}}function PC(n,e="#000000"){let t=IC(n,e);return .2126*t.r+.7152*t.g+.0722*t.b}function In(n,e=!1){return typeof n=="boolean"?n:e}function NC(n,e="solid"){let t=String(n||"").trim().toLowerCase();return["solid","linear","radial","transparent"].includes(t)?t:e}function LC(n,e="multiply"){let t=String(n||"").trim().toLowerCase();return["multiply","blend"].includes(t)?t:e}var Lt=Object.freeze({STAGE:"stage",GRID:"grid",NONE:"none"}),$t=Object.freeze({SYSTEM:"system",LIGHT:"light",DARK:"dark"}),OC=Object.freeze(Object.values($t));function Pu(n,e=$t.SYSTEM){let t=String(n||"").trim().toLowerCase();return OC.includes(t)?t:e}var t_=Object.freeze([Object.freeze(["background","solidColor"]),Object.freeze(["background","linearStart"]),Object.freeze(["background","linearEnd"]),Object.freeze(["background","radialInner"]),Object.freeze(["background","radialOuter"]),Object.freeze(["floor","color"]),Object.freeze(["floor","gridCenterColor"]),Object.freeze(["floor","gridCellColor"]),Object.freeze(["floor","grid","centerColor"]),Object.freeze(["floor","grid","cellColor"]),Object.freeze(["lighting","directional","color"]),Object.freeze(["lighting","spot","color"]),Object.freeze(["lighting","point","color"]),Object.freeze(["lighting","ambient","color"]),Object.freeze(["lighting","hemisphere","skyColor"]),Object.freeze(["lighting","hemisphere","groundColor"])]);function Rp(n,e){return e.reduce((t,i)=>t&&typeof t=="object"?t[i]:void 0,n)}function n_(n,e,t){let i=n;for(let r=0;r<e.length-1;r+=1){let s=e[r];(!i[s]||typeof i[s]!="object"||Array.isArray(i[s]))&&(i[s]={}),i=i[s]}i[e[e.length-1]]=t}function i_(n){return JSON.parse(JSON.stringify(n))}function Nu(n={},e=n){let t={};for(let i of t_){let r=Rp(e,i)||"#ffffff";n_(t,i,St(Rp(n,i),r))}return t}function Np(n={},e=n){return Object.freeze({light:Nu(n,n),dark:Nu(e,n)})}function wo(n,e,t=Np(n,n)){return Object.freeze({...n,colorMode:Pu(e),modeColors:t})}function DC(n={},e=Se){let t=n&&typeof n=="object"?n:{},i=e&&typeof e=="object"?e:Se,r=i?.modeColors&&typeof i.modeColors=="object"?i.modeColors:Np(i,i);return{light:Nu(t.light,r.light||i),dark:Nu(t.dark,r.dark||i)}}function UC(n,e={}){for(let t of t_){let i=Rp(e,t);i&&n_(n,t,i)}}var Du=.25,Uu=4,ds=Object.freeze({enabled:!0,gridCenterColor:"#6b7280",gridCellColor:"#cbd5e1",gridOpacity:.18,gridDensity:1,centerColor:"#6b7280",cellColor:"#cbd5e1",opacity:.18,density:1});function FC(n,e=Lt.STAGE){let t=String(n||"").trim().toLowerCase();return t==="glass"?Lt.STAGE:Object.values(Lt).includes(t)?t:e}var Ip=Object.freeze([{id:"studio-hdri-43",label:"Studio HDRI 43",url:"https://static.morflax.com/textures/env/Studio_HDRI_43.jpg"},{id:"studio-hdri-41",label:"Studio HDRI 41",url:"https://static.morflax.com/textures/env/Studio_HDRI_41.jpg"},{id:"studio-hdri-12",label:"Studio HDRI 12",url:"https://static.morflax.com/textures/env/Studio_HDRI_12.jpg"},{id:"studio-hdri-17",label:"Studio HDRI 17",url:"https://static.morflax.com/textures/env/Studio_HDRI_17.jpg"},{id:"studio-hdri-22",label:"Studio HDRI 22",url:"https://static.morflax.com/textures/env/Studio_HDRI_22.jpg"},{id:"colorful-1",label:"Colorful 1",url:"https://static.morflax.com/textures/env/colorful-1.jpg"},{id:"colorful-dark-1",label:"Colorful Dark 1",url:"https://static.morflax.com/textures/env/colorful-dark-1.jpg"}]),Lu=Object.freeze(["#b6c4ce","#f4a7a7","#f8c77e","#f7e38d","#b9e88f","#8fe3c0","#92d7f5","#a9b8ff","#c7a8ff","#f2a7d9"]),Za=Object.freeze(["#4cc9f0"]),Ja=Object.freeze(["#ff4faf"]),Qa=Object.freeze(["#b9856e"]),Sr=Object.freeze(["#178f9f","#ef7459"]),ec=Object.freeze(["#0b7a3f"]),r_="#66ff99",BC="#b7ffc9",zC=Object.freeze({feature:Object.freeze({opacity:1,thickness:1.15}),tangent:Object.freeze({opacity:.84,thickness:.95}),seam:Object.freeze({opacity:.92,thickness:1}),degenerate:Object.freeze({opacity:.72,thickness:.8})}),VC=Object.freeze({...tc,enabled:!0,color:r_,classes:zC,highlightColor:BC,highlightOpacity:1,highlightThickness:3}),jx=Object.freeze(["#b6c4ce","#8f9aa3","#d3dae0","#68737d"]);function zn(n,e,t=.5){let i=St(n,"#000000"),r=St(e,i),s=Qx(Number(t),0,1),o=a=>{let c=parseInt(i.slice(a,a+2),16),l=parseInt(r.slice(a,a+2),16);return Math.round(c+(l-c)*s).toString(16).padStart(2,"0")};return`#${o(1)}${o(3)}${o(5)}`}function kC(n,e){let t=Array.isArray(n)?n:[],i=Array.isArray(e)?e:[],r=Math.max(t.length,i.length);return Object.freeze(r?Array.from({length:r},(s,o)=>{let a=t[o]||t.at(-1)||"#ffffff",c=i[o]||i.at(-1)||a;return zn(a,c)}):["#ffffff"])}function ni(n,e={}){let t=St(n,"#f1f5f9"),i=In(e.enabled,!1),r=PC(t)>=.36,s=St(e.centerColor,r?zn(t,"#0f172a",.48):zn(t,"#f8fafc",.46)),o=St(e.cellColor,r?zn(t,"#475569",.26):zn(t,"#cbd5e1",.22)),a=nt(e.opacity,ds.opacity,0,1),c=nt(e.density,ds.density,Du,Uu);return{gridCenterColor:s,gridCellColor:o,gridOpacity:a,gridDensity:c,grid:{enabled:i,centerColor:s,cellColor:o,opacity:a,density:c},centerColor:s,cellColor:o,opacity:a,density:c}}var Vn=Object.freeze({materials:{defaultColor:Lu[0],fillColors:Lu,cycleColors:!1,overrideSourceColors:!1,tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.12,brightness:1.02,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02},edges:{...tc},background:{type:"linear",solidColor:"#edf5fb",linearStart:"#fbfdff",linearEnd:"#b8cadb",linearAngle:135,radialInner:"#ffffff",radialOuter:"#b3c4d4"},floor:{mode:Lt.STAGE,color:"#edf3f8",roughness:.7,reflectivity:.14,shadowOpacity:.16,horizonBlend:.18,...ni("#edf3f8",{opacity:.2}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-43",intensity:.32,rotationY:-.25,useAsBackground:!1},lighting:{toneMappingExposure:1.16,directional:{enabled:!0,color:"#ffffff",intensity:1.16,position:{x:-210,y:260,z:270}},spot:{enabled:!0,color:"#f4fbff",intensity:.52,angle:.74,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#ffe2ba",intensity:.28,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#ffffff",intensity:.4},hemisphere:{enabled:!0,skyColor:"#ffffff",groundColor:"#d6e2ee",intensity:1.12}}}),ht=Object.freeze({materials:{defaultColor:Lu[0],fillColors:Lu,cycleColors:!1,overrideSourceColors:!1,tintMode:"blend",tintStrength:0,saturation:1.2,contrast:1.14,brightness:1.06,roughness:.54,metalness:.02,clearcoat:.14,clearcoatRoughness:.4,opacity:1,envMapIntensity:.5,emissiveIntensity:.03},edges:{...nc},background:{type:"linear",solidColor:"#081b2d",linearStart:"#18304a",linearEnd:"#030914",linearAngle:135,radialInner:"#174267",radialOuter:"#030914"},floor:{mode:Lt.STAGE,color:"#0a2238",roughness:.38,reflectivity:.1,shadowOpacity:.42,horizonBlend:.1,...ni("#0a2238",{opacity:.22}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-43",intensity:.18,rotationY:-.25,useAsBackground:!1},lighting:{toneMappingExposure:1.22,directional:{enabled:!0,color:"#ffffff",intensity:1.42,position:{x:-210,y:260,z:270}},spot:{enabled:!0,color:"#70c4ff",intensity:.24,angle:.74,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#9bd0ff",intensity:.36,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#c6d8ea",intensity:.24},hemisphere:{enabled:!0,skyColor:"#ffffff",groundColor:"#020713",intensity:.98}}}),_r=Object.freeze({...ht,materials:{...ht.materials,defaultColor:jx[0],fillColors:jx},background:{...ht.background,solidColor:"#151617",linearStart:"#2a2b2d",linearEnd:"#070809",radialInner:"#303133",radialOuter:"#070809"},floor:{...ht.floor,color:"#171819",...ni("#171819",{opacity:.22})}}),$x=kC(ht.materials.fillColors,_r.materials.fillColors),xr=Object.freeze({...ht,materials:{...ht.materials,defaultColor:$x[0],fillColors:$x},edges:{...tc},background:{...ht.background,solidColor:zn(ht.background.solidColor,_r.background.solidColor),linearStart:zn(ht.background.linearStart,_r.background.linearStart),linearEnd:zn(ht.background.linearEnd,_r.background.linearEnd),radialInner:zn(ht.background.radialInner,_r.background.radialInner),radialOuter:zn(ht.background.radialOuter,_r.background.radialOuter)},floor:{...ht.floor,color:zn(ht.floor.color,_r.floor.color),...ni(zn(ht.floor.color,_r.floor.color),{opacity:.22})}}),GC=Object.freeze({materials:{...ht.materials,defaultColor:Za[0],fillColors:Za,cycleColors:!1},edges:{...nc},background:{type:"radial",solidColor:"#04131f",linearStart:"#07253a",linearEnd:"#0b8edc",linearAngle:128,radialInner:"#0b8edc",radialOuter:"#02070c"},floor:{mode:Lt.STAGE,color:"#06324f",roughness:.58,reflectivity:.2,shadowOpacity:.3,horizonBlend:.18,...ni("#06324f",{opacity:.24}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),HC=Object.freeze({materials:{...ht.materials,defaultColor:Ja[0],fillColors:Ja,cycleColors:!1},edges:{...nc},background:{type:"radial",solidColor:"#281323",linearStart:"#7a1a52",linearEnd:"#301426",linearAngle:140,radialInner:"#7f1a55",radialOuter:"#25101f"},floor:{mode:Lt.STAGE,color:"#4a1833",roughness:.56,reflectivity:.2,shadowOpacity:.26,horizonBlend:.22,...ni("#4a1833",{opacity:.24}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),WC=Object.freeze({materials:{...ht.materials,defaultColor:Qa[0],fillColors:Qa,cycleColors:!1},edges:{...nc},background:{type:"linear",solidColor:"#f3eadc",linearStart:"#f7ead8",linearEnd:"#c88d5d",linearAngle:162,radialInner:"#f7ead8",radialOuter:"#b06c43"},floor:{mode:Lt.STAGE,color:"#d4a070",roughness:.72,reflectivity:.14,shadowOpacity:.34,horizonBlend:.12,...ni("#d4a070",{opacity:.18}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),XC=Object.freeze({materials:{...Vn.materials,defaultColor:Sr[0],fillColors:Sr,cycleColors:!0},edges:{...nc},background:{type:"linear",solidColor:"#dff7f7",linearStart:"#fff4d6",linearEnd:"#47c5d6",linearAngle:152,radialInner:"#fff8e8",radialOuter:"#1a8fb5"},floor:{mode:Lt.STAGE,color:"#f2d59b",roughness:.74,reflectivity:.18,shadowOpacity:.2,horizonBlend:.2,...ni("#f2d59b",{opacity:.18}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-12",intensity:.36,rotationY:-.18,useAsBackground:!1},lighting:{toneMappingExposure:1.18,directional:{enabled:!0,color:"#fff7df",intensity:1.3,position:{x:-220,y:280,z:250}},spot:{enabled:!0,color:"#e4fbff",intensity:.36,angle:.72,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#ffd08a",intensity:.24,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#fff8e6",intensity:.34},hemisphere:{enabled:!0,skyColor:"#bff8ff",groundColor:"#f2d59b",intensity:1.04}}}),YC=Object.freeze({materials:{...ht.materials,defaultColor:ec[0],fillColors:ec,cycleColors:!1},edges:{...VC},background:{type:"radial",solidColor:"#020403",linearStart:"#031109",linearEnd:"#000000",linearAngle:180,radialInner:"#062414",radialOuter:"#000201"},floor:{mode:Lt.GRID,color:"#020403",roughness:.58,reflectivity:.12,shadowOpacity:.35,horizonBlend:0,gridCenterColor:r_,gridCellColor:"#0c3d22",gridOpacity:.34,gridDensity:1.15},environment:ht.environment,lighting:ht.lighting}),$a="#f0f4f9",Kx="#e2e9f0",Zx=Object.freeze({...Vn,background:{...Vn.background,type:"solid",solidColor:$a,linearStart:$a,linearEnd:$a,radialInner:$a,radialOuter:$a},edges:{...tc},floor:{...Vn.floor,color:Kx,enabled:!0,...ni(Kx,{enabled:!0,opacity:.2})},environment:{...Vn.environment,enabled:!1},lighting:{...Vn.lighting,hemisphere:{...Vn.lighting.hemisphere,groundColor:"#c7d5e3"}}}),Jx="#202832",qC=Object.freeze({...xr,edges:{...tc,color:"#1c2836"},background:{...xr.background,solidColor:"#181f28",linearStart:"#242e3a",linearEnd:"#0c1016",radialInner:"#293443",radialOuter:"#0c1016"},floor:{...xr.floor,color:Jx,enabled:!0,...ni(Jx,{enabled:!0,opacity:.22})},lighting:{...xr.lighting,spot:{...xr.lighting.spot,color:"#b3d4f2"},point:{...xr.lighting.point,color:"#bfd8f0"},ambient:{...xr.lighting.ambient,color:"#dfe7f0"},hemisphere:{...xr.lighting.hemisphere,groundColor:"#333d4b"}}}),Lp=wo(Zx,$t.SYSTEM,Np(Zx,qC)),jC=wo(GC,$t.DARK),$C=wo(HC,$t.DARK),KC=wo(WC,$t.LIGHT),ZC=wo(XC,$t.LIGHT),JC=wo(YC,$t.DARK),Ou=Object.freeze([{id:"workbench",label:"Workbench",description:"Balanced CAD workbench lighting with system-aware light and dark canvas colors.",preview:{background:"#f0f4f9",modelColor:"#b6c4ce",accentColor:"#4ea7d8"},settings:Lp},{id:"blue",label:"Blue",description:"Single cyan fill against deep-navy CAD lighting.",preview:{background:Za[0],modelColor:Za[0],accentColor:Za[0]},settings:jC},{id:"pink",label:"Magenta",description:"Single saturated magenta fill against a near-black studio backdrop.",preview:{background:Ja[0],modelColor:Ja[0],accentColor:Ja[0]},settings:$C},{id:"clay-sunrise",label:"Clay",description:"Single warm clay fill with a soft presentation stage.",preview:{background:Qa[0],modelColor:Qa[0],accentColor:Qa[0]},settings:KC},{id:"beach",label:"Beach",description:"Two-color aqua-and-coral fill with warm beach presentation lighting.",preview:{background:`linear-gradient(135deg, ${Sr[0]} 0%, ${Sr[0]} 50%, ${Sr[1]} 50%, ${Sr[1]} 100%)`,modelColor:Sr[0],accentColor:Sr[1]},settings:ZC},{id:"terminal",label:"Terminal",description:"Single terminal-green fill with green CAD edge linework and a dark grid floor.",preview:{background:ec[0],modelColor:ec[0],accentColor:ec[0]},settings:JC}]),QC=Object.freeze({cinematic:"workbench",light:"workbench",dark:"workbench",charcoal:"workbench",darkoal:"workbench","dark-2":"workbench"}),eR="workbench",s_=Object.freeze(Ou.find(n=>n.id===eR)||Ou[0]),Se=Object.freeze(s_.settings);var tR=new Set(Ip.map(n=>n.id)),nR=Object.freeze({defaultColor:"#aeb9c3",tintStrength:.28,saturation:.42,contrast:1.02,brightness:.94,roughness:.46,metalness:.02,clearcoat:.18,clearcoatRoughness:.34,opacity:1,envMapIntensity:.58}),iR=Object.freeze({defaultColor:"#aeb9c3",tintMode:"blend",tintStrength:.08,saturation:1,contrast:1.04,brightness:1.02,roughness:.46,metalness:.02,clearcoat:.18,clearcoatRoughness:.34,opacity:1,envMapIntensity:.58,emissiveIntensity:.06}),rR=Object.freeze({defaultColor:"#aeb9c3",tintMode:"blend",tintStrength:0,saturation:1.34,contrast:1.02,brightness:.82,roughness:.76,metalness:0,clearcoat:0,clearcoatRoughness:.72,opacity:1,envMapIntensity:.08,emissiveIntensity:.01}),sR=Object.freeze({defaultColor:"#bcc8d4",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.07,brightness:1.04,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),oR=Object.freeze({defaultColor:"#748899",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.07,brightness:1.04,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),aR=Object.freeze({defaultColor:"#556c7f",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.12,brightness:1.02,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),HL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),WL=Object.freeze({enabled:!0,color:"#8fa1b5",thickness:1.65}),XL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),YL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),o_=Object.freeze({solidColor:"#050711",linearStart:"#02040b",linearEnd:"#252f47",linearAngle:90,radialInner:"#171d30",radialOuter:"#02040b"}),cR=o_,lR=Object.freeze({solidColor:"#0a0f18",linearStart:"#08111c",linearEnd:"#1f2c3d",linearAngle:90,radialInner:"#182337",radialOuter:"#08111c"}),uR=Object.freeze({mode:Lt.STAGE,color:"#141a29",roughness:.62,reflectivity:.22,shadowOpacity:.24,horizonBlend:.28}),hR=Object.freeze({mode:Lt.STAGE,color:"#141a29",roughness:.62,reflectivity:.06,shadowOpacity:.24,horizonBlend:.12}),fR=Object.freeze({mode:Lt.STAGE,color:"#121a24",roughness:.86,reflectivity:.06,shadowOpacity:.24,horizonBlend:.28}),dR=Object.freeze({enabled:!0,presetId:"studio-hdri-43",intensity:.46,rotationY:-.35,useAsBackground:!1}),pR=Object.freeze({enabled:!1,presetId:"studio-hdri-43",intensity:0,rotationY:-.35,useAsBackground:!1}),mR=Object.freeze({toneMappingExposure:1.2,directional:{enabled:!0,color:"#f1f6fb",intensity:2.45,position:{x:-190,y:300,z:210}},spot:{enabled:!0,color:"#dbeafe",intensity:1.34,angle:.72,distance:0,position:{x:160,y:245,z:126}},point:{enabled:!0,color:"#8fb6d8",intensity:.34,distance:0,position:{x:-260,y:95,z:-220}},ambient:{enabled:!0,color:"#1e293b",intensity:.2},hemisphere:{enabled:!0,skyColor:"#dbe7f3",groundColor:"#070a14",intensity:.68}}),gR=Object.freeze({toneMappingExposure:1.03,directional:{enabled:!0,color:"#f1f6fb",intensity:1.28,position:{x:-190,y:300,z:210}},spot:{enabled:!0,color:"#dbeafe",intensity:.18,angle:.72,distance:0,position:{x:160,y:245,z:126}},point:{enabled:!0,color:"#8fb6d8",intensity:.08,distance:0,position:{x:-260,y:95,z:-220}},ambient:{enabled:!0,color:"#1e293b",intensity:.42},hemisphere:{enabled:!0,skyColor:"#dbe7f3",groundColor:"#070a14",intensity:.92}});function yR(n){let e=String(n||"").trim();return tR.has(e)?e:Se.environment.presetId}function Cp(n,e){return{x:nt(n?.x,e.x,-5e3,5e3),y:nt(n?.y,e.y,-5e3,5e3),z:nt(n?.z,e.z,-5e3,5e3)}}function a_(n,e){return typeof e=="number"?Math.abs((Number(n)||0)-e)<1e-6:e&&typeof e=="object"?!n||typeof n!="object"?!1:Object.entries(e).every(([t,i])=>a_(n[t],i)):n===e}function Ka(n,e){return e.some(t=>a_(n,t))}function xR(n){let e=Ka(n?.materials,[nR,iR,rR,sR,oR,aR,Vn.materials]),t=Ka(n?.floor,[uR,hR,fR,Vn.floor]),i=Ka(n?.environment,[dR,pR,Vn.environment,Lp.environment]),r=Ka(n?.background,[o_,cR,lR,Vn.background]),s=Ka(n?.lighting,[mR,gR,Vn.lighting]);return e&&r&&t&&i&&s}function br(n={}){let e=n&&typeof n=="object"?n:{},t=e.materials&&typeof e.materials=="object"?e.materials:{},i=e.background&&typeof e.background=="object"?e.background:{},r=e.environment&&typeof e.environment=="object"?e.environment:{},s=e.floor&&typeof e.floor=="object"?e.floor:{},o=e.lighting&&typeof e.lighting=="object"?e.lighting:{},a=!!(e.materials&&typeof e.materials=="object"),c=a&&!Object.hasOwn(t,"tintMode"),l=a&&!Object.hasOwn(t,"emissiveIntensity"),u=St(t.defaultColor||t.tintColor,Se.materials.defaultColor),h=e_(t.fillColors,u),f=St(s.color,Se.floor?.color||"#141416"),d=FC(s.mode,Se.floor?.mode||Lt.STAGE),m=s.grid&&typeof s.grid=="object"&&!Array.isArray(s.grid)?s.grid:{},y=ni(f),g=St(m.centerColor??s.gridCenterColor??s.gridCenter,y.centerColor),p=St(m.cellColor??s.gridCellColor??s.gridCell,y.cellColor),_=nt(m.opacity??s.gridOpacity,y.opacity,0,1),x=nt(m.density??s.gridDensity,y.density,Du,Uu),T={colorMode:Pu(e.colorMode,Se?.colorMode||$t.SYSTEM),materials:{defaultColor:h[0]||u,fillColors:h,cycleColors:In(t.cycleColors,Se.materials.cycleColors||!1),overrideSourceColors:In(t.overrideSourceColors,Se.materials.overrideSourceColors||!1),tintMode:LC(t.tintMode,c?"multiply":Se.materials.tintMode),tintStrength:nt(t.tintStrength,Se.materials.tintStrength,0,1),saturation:nt(t.saturation,Se.materials.saturation,0,2.5),contrast:nt(t.contrast,Se.materials.contrast,0,2.5),brightness:nt(t.brightness,Se.materials.brightness,0,2),roughness:nt(t.roughness,Se.materials.roughness,0,1),metalness:nt(t.metalness,Se.materials.metalness,0,1),clearcoat:nt(t.clearcoat,Se.materials.clearcoat,0,1),clearcoatRoughness:nt(t.clearcoatRoughness,Se.materials.clearcoatRoughness,0,1),opacity:nt(t.opacity,Se.materials.opacity,0,1),envMapIntensity:nt(t.envMapIntensity,Se.materials.envMapIntensity,0,4),emissiveIntensity:nt(t.emissiveIntensity,l?0:Se.materials.emissiveIntensity,0,2)},background:{type:NC(i.type,Se.background.type),solidColor:St(i.solidColor,Se.background.solidColor),linearStart:St(i.linearStart,Se.background.linearStart),linearEnd:St(i.linearEnd,Se.background.linearEnd),linearAngle:nt(i.linearAngle,Se.background.linearAngle,-360,360),radialInner:St(i.radialInner,Se.background.radialInner),radialOuter:St(i.radialOuter,Se.background.radialOuter)},floor:{mode:d,enabled:In(s.enabled,d!==Lt.NONE),color:f,roughness:nt(s.roughness,Se.floor?.roughness??.72,0,1),reflectivity:nt(s.reflectivity,Se.floor?.reflectivity??.12,0,1),shadowOpacity:nt(s.shadowOpacity,Se.floor?.shadowOpacity??.45,0,1),horizonBlend:nt(s.horizonBlend,Se.floor?.horizonBlend??0,0,1),gridCenterColor:g,gridCellColor:p,gridOpacity:_,gridDensity:x,grid:{enabled:In(m.enabled,d===Lt.GRID),centerColor:g,cellColor:p,opacity:_,density:x}},environment:{enabled:In(r.enabled,Se.environment.enabled),presetId:yR(r.presetId),intensity:nt(r.intensity,Se.environment.intensity,0,4),rotationY:nt(r.rotationY,Se.environment.rotationY,-Math.PI*2,Math.PI*2),useAsBackground:In(r.useAsBackground,Se.environment.useAsBackground)},lighting:{toneMappingExposure:nt(o.toneMappingExposure,Se.lighting.toneMappingExposure,.05,6),directional:{enabled:In(o.directional?.enabled,Se.lighting.directional.enabled),color:St(o.directional?.color,Se.lighting.directional.color),intensity:nt(o.directional?.intensity,Se.lighting.directional.intensity,0,20),position:Cp(o.directional?.position,Se.lighting.directional.position)},spot:{enabled:In(o.spot?.enabled,Se.lighting.spot.enabled),color:St(o.spot?.color,Se.lighting.spot.color),intensity:nt(o.spot?.intensity,Se.lighting.spot.intensity,0,20),angle:nt(o.spot?.angle,Se.lighting.spot.angle,.01,Math.PI/2),distance:nt(o.spot?.distance,Se.lighting.spot.distance,0,5e3),position:Cp(o.spot?.position,Se.lighting.spot.position)},point:{enabled:In(o.point?.enabled,Se.lighting.point.enabled),color:St(o.point?.color,Se.lighting.point.color),intensity:nt(o.point?.intensity,Se.lighting.point.intensity,0,20),distance:nt(o.point?.distance,Se.lighting.point.distance,0,5e3),position:Cp(o.point?.position,Se.lighting.point.position)},ambient:{enabled:In(o.ambient?.enabled,Se.lighting.ambient.enabled),color:St(o.ambient?.color,Se.lighting.ambient.color),intensity:nt(o.ambient?.intensity,Se.lighting.ambient.intensity,0,20)},hemisphere:{enabled:In(o.hemisphere?.enabled,Se.lighting.hemisphere.enabled),skyColor:St(o.hemisphere?.skyColor,Se.lighting.hemisphere.skyColor),groundColor:St(o.hemisphere?.groundColor,Se.lighting.hemisphere.groundColor),intensity:nt(o.hemisphere?.intensity,Se.lighting.hemisphere.intensity,0,20)}}};return T.modeColors=DC(e.modeColors,T),!Object.hasOwn(e,"colorMode")&&!Object.hasOwn(e,"modeColors")&&xR(T)?br(i_(Lp)):T}function _R(n=Se){return br(JSON.parse(JSON.stringify(n)))}function SR(n){let e=String(n||"").trim(),t=QC[e]||e;return Ou.some(i=>i.id===t)?t:""}function bR(n){let e=SR(n);return Ou.find(t=>t.id===e)||s_}function MR(n){return _R(bR(n).settings)}function c_(n){return MR(n)}function vR(n={},{prefersDark:e=!1,systemFallback:t=$t.LIGHT}={}){let i=Pu(n?.colorMode,Se?.colorMode||$t.SYSTEM);return i===$t.SYSTEM?e===!0||Pu(t,$t.LIGHT)===$t.DARK?$t.DARK:$t.LIGHT:i}function l_(n={},e={}){let t=br(n),i=vR(t,e),r=i_(t);return r.colorMode=i,UC(r,t.modeColors?.[i]),br(r)}function u_(n){return Ip.find(e=>e.id===n)||Ip[0]}function AR(n){return n instanceof Float32Array}function Bp(n){return n instanceof Uint32Array}function pi(n,e){return Math.hypot(Number(e?.[0]||0)-Number(n?.[0]||0),Number(e?.[1]||0)-Number(n?.[1]||0),Number(e?.[2]||0)-Number(n?.[2]||0))}function ER(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let i of n)for(let r=0;r+2<i.length;r+=3)e[0]=Math.min(e[0],i[r]),e[1]=Math.min(e[1],i[r+1]),e[2]=Math.min(e[2],i[r+2]),t[0]=Math.max(t[0],i[r]),t[1]=Math.max(t[1],i[r+1]),t[2]=Math.max(t[2],i[r+2]);return!Number.isFinite(e[0])||!Number.isFinite(t[0])?null:{min:e,max:t}}function wR(n){let e=ER(n);return e?Math.max(1e-5,pi(e.min,e.max)*1e-7):1e-5}function Bu(n,e){let t=Number(e)*3;return!Number.isInteger(e)||t<0||t+2>=n.edgePositions.length?null:[n.edgePositions[t],n.edgePositions[t+1],n.edgePositions[t+2]]}function zu(n){return new Set((Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean))}function p_(n){let e=(Array.isArray(n)?n:[n]).map(t=>String(t||"").trim().toLowerCase()).filter(Boolean);return e.length?new Set(e):null}function TR(n,e){let t=String(n||"").trim();if(!t||!e?.size)return!1;for(let i of e)if(t===i||t.startsWith(`${i}.`))return!0;return!1}function h_(n,e){return TR(n?.occurrenceId||n?.partId||n?.id,e)}function CR(n,e,t){return!(e.size&&!h_(n,e)||t.size&&h_(n,t))}function RR(n,e){if(!e?.size)return!0;let t=String(n?.visibilityClass||"feature").trim().toLowerCase()||"feature";return e.has(t)}function m_(n,e,t,i){return CR(n,e,t)&&RR(n,i)}function Op(n,e,t=1e-7){if(!e)return;let i=n.length>=3?[n[n.length-3],n[n.length-2],n[n.length-1]]:null;(!i||pi(i,e)>t)&&n.push(e[0],e[1],e[2])}function Dp(n,e,t){let i=[],r=[],s=null;for(let o=e;o<e+t;o+=1){let a=Number(n.edgeIndices[o*2]),c=Number(n.edgeIndices[o*2+1]),l=Bu(n,a),u=Bu(n,c);!l||!u||pi(l,u)<=1e-10||(s&&pi(s,l)>1e-5&&(r.length>=6&&i.push(new Float32Array(r)),r=[],s=null),s||Op(r,l),Op(r,u),s=u)}return r.length>=6&&i.push(new Float32Array(r)),i}function IR(n,e,t,i){let r=[],s=-1,o=0,a=()=>{s>=0&&o>0&&r.push(...Dp(n,s,o)),s=-1,o=0};for(let c=0;c<i;c+=1)Number(e[c])===t?(s<0&&(s=c),o+=1):a();return a(),r}function g_(n,e){let t=e*3;return[n[t],n[t+1],n[t+2]]}function Up(n){return g_(n,0)}function Fp(n){return g_(n,Math.floor(n.length/3)-1)}function f_(n){let e=[];for(let t=n.length-3;t>=0;t-=3)e.push(n[t],n[t+1],n[t+2]);return e}function Fu(n,e,{skipFirst:t=!0,tolerance:i=1e-7}={}){let r=t?3:0;for(let s=r;s+2<e.length;s+=3)Op(n,[e[s],e[s+1],e[s+2]],i)}function PR(n,e){if(n.length<12)return n;let t=Up(n),i=Fp(n);if(pi(t,i)>e)return n;let r=Array.from(n);return r[r.length-3]=r[0],r[r.length-2]=r[1],r[r.length-1]=r[2],new Float32Array(r)}function d_(n){if(!Array.isArray(n)||n.length<=1)return n||[];let e=wR(n),t=n.filter(i=>i?.length>=6).map(i=>Array.from(i));for(let i=0;i<t.length;i+=1){let r=!0;for(;r;){r=!1;for(let s=i+1;s<t.length;s+=1){let o=t[i],a=t[s],c=Up(o),l=Fp(o),u=Up(a),h=Fp(a),f=null;if(pi(l,u)<=e?(f=[...o],Fu(f,a,{tolerance:e})):pi(l,h)<=e?(f=[...o],Fu(f,f_(a),{tolerance:e})):pi(c,h)<=e?(f=[...a],Fu(f,o,{tolerance:e})):pi(c,u)<=e&&(f=f_(a),Fu(f,o,{tolerance:e})),f){t[i]=f,t.splice(s,1),r=!0;break}}}}return t.filter(i=>i.length>=6).map(i=>PR(new Float32Array(i),e))}function zp(n){let e=n?.proxy||{};return AR(e.edgePositions)&&Bp(e.edgeIndices)&&e.edgePositions.length>=6&&e.edgeIndices.length>=2}function y_(n){return!n?.surfaceEdgeRendering&&Number(n?.schemaVersion||0)<3&&zp(n)}function Vp(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=null}={}){if(!zp(n))return null;let r=n.proxy,s=Math.floor(r.edgeIndices.length/2);if(s<=0)return null;let o=zu(e),a=zu(t),c=o.size>0||a.size>0,l=p_(i),u=Array.isArray(n.edges)?n.edges:[],h=!!(l?.size&&u.length),f=c||h,d=Bp(r.edgeIds)?r.edgeIds:null,m=new Float32Array(s*6),y=0,g=p=>{let _=Number(r.edgeIndices[p*2]),x=Number(r.edgeIndices[p*2+1]),b=Bu(r,_),T=Bu(r,x);!b||!T||pi(b,T)<=1e-10||(m[y]=b[0],m[y+1]=b[1],m[y+2]=b[2],m[y+3]=T[0],m[y+4]=T[1],m[y+5]=T[2],y+=6)};if(f){if(!u.length)return null;for(let p=0;p<u.length;p+=1){let _=u[p];if(!m_(_,o,a,l))continue;let x=Number(_?.segmentStart||0),b=Number(_?.segmentCount||0);if(Number.isInteger(x)&&Number.isInteger(b)&&x>=0&&b>0&&x+b<=s){for(let T=x;T<x+b;T+=1)g(T);continue}if(d)for(let T=0;T<s;T+=1)Number(d[T])===p&&g(T)}}else for(let p=0;p<s;p+=1)g(p);return y<=0?null:y===m.length?m:m.subarray(0,y)}function x_(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=null}={}){if(!zp(n))return[];let r=n.proxy,s=Math.floor(r.edgeIndices.length/2);if(s<=0)return[];let o=Array.isArray(n.edges)?n.edges:[],a=Bp(r.edgeIds)?r.edgeIds:null,c=zu(e),l=zu(t),u=c.size>0||l.size>0,h=p_(i),f=!!(h?.size&&o.length),d=u||f,m=[];if(o.length){for(let y=0;y<o.length;y+=1){let g=o[y];if(!g||!m_(g,c,l,h))continue;let p=Number(g.segmentStart||0),_=Number(g.segmentCount||0);Number.isInteger(p)&&Number.isInteger(_)&&p>=0&&_>0&&p+_<=s?m.push(...Dp(r,p,_)):a&&m.push(...IR(r,a,y,s))}return d_(m)}if(d)return[];for(let y=0;y<s;y+=1){let g=a?Number(a[y]):-1;m.push(...Dp(r,y,1))}return d_(m)}function on(n,e,t){return Math.min(Math.max(n,e),t)}var To=0,NR=.0045,LR=25e-5,OR=.006,kp=new Set(["tangent","seam"]),DR=.006,UR=25e-5,FR=.008,v_=Object.freeze(["feature"]),BR=Object.freeze(["feature","tangent","seam","degenerate"]),A_=1200,E_=18e4,zR=/^#(?:[0-9a-fA-F]{3}){1,2}$/,Gp=Object.freeze({feature:Object.freeze({color:"#132232",opacity:1,thickness:1.15}),tangent:Object.freeze({color:"#132232",opacity:.5,thickness:1.15}),seam:Object.freeze({color:"#132232",opacity:.85,thickness:1.15}),degenerate:Object.freeze({color:"#132232",opacity:1,thickness:0})});function Hp(n=1,{visibilityClass:e=""}={}){let t=Number.isFinite(Number(n))?Math.max(1,Number(n)):1,i=String(e||"").trim().toLowerCase(),r=kp.has(i)?DR:NR,s=kp.has(i)?UR:LR,o=kp.has(i)?FR:OR;return on(r+Math.max(0,t-1)*s,r,o)}function VR(n){let e=n?.getAttribute?.("position"),t=e?.array;return!e?.count||!t?.length?null:t}function kR(n,e){if(!n)return;let t=on(Number(e)||0,0,1),i=t<.999;n.opacity=t,n.depthWrite=!1,n.transparent!==i&&(n.transparent=i,n.needsUpdate=!0)}function ku(n,e,t){let i=Math.max(1,Math.floor(Number(e)||1)),r=Math.max(1,Math.floor(Number(t)||1));for(let s of n||[])s?.resolution?.set?.(i,r)}function w_(n={},e,t=null){t?.add?.(e),n.registerScreenSpaceLineMaterial?.(e)}function T_(n={},e,t=null){t?.delete?.(e),n.unregisterScreenSpaceLineMaterial?.(e)}function Vu(n){return(Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean)}function GR(n,e=[]){let t=String(n||"").trim();return!t||!e.length?!1:e.some(i=>t===i||t.startsWith(`${i}.`))}function __(n,e=[]){return GR(n?.occurrenceId||n?.partId||n?.id,e)}function HR(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=[]}={}){if(e.length&&!__(n,e)||t.length&&__(n,t))return!1;if(i.length){let r=String(n?.visibilityClass||"feature").trim().toLowerCase()||"feature";if(!i.includes(r))return!1}return!0}function WR(n,e={}){let t=Array.isArray(n?.edges)?n.edges:[];if(!t.length)return!1;let i=0,r=0;for(let s of t){if(!HR(s,e))continue;let o=Number.isFinite(Number(s?.segmentCount))?Math.max(1,Number(s.segmentCount)):1;if(i+=1,r+=(o+1)*3,i>A_||r>E_)return!1}return i>0}function XR(n,e=v_){let t=(Array.isArray(n)?n:[n]).map(i=>String(i||"").trim().toLowerCase()).filter(Boolean);return t.length?t:e}function S_(n,e){let t=String(n||"").trim();return zR.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function YR(n={},e={},t=v_){let i=n?.classes&&typeof n.classes=="object"?n.classes:null,r=i?[]:XR(n?.visibilityClasses,t),s=Number.isFinite(Number(n?.opacity))?on(Number(n.opacity),0,1):e?.edgeOpacity??.84,o=Number.isFinite(Number(n?.thickness))?on(Number(n.thickness),.5,6):e?.edgeThickness??1,a=S_(n?.color,e?.edge||"#18181b");return i?BR.map(c=>{let l=i[c]||Gp[c],u=Number.isFinite(Number(l.opacity))?on(Number(l.opacity),0,1):Gp[c].opacity,h=Number.isFinite(Number(l.thickness))?on(Number(l.thickness),0,6):Gp[c].thickness,f=S_(l.color,a);return h<=0||u<=0?null:{classId:c,color:f,opacity:u,thickness:h}}).filter(Boolean):r.map(c=>({classId:c,color:a,opacity:s,thickness:o}))}function qR(n){return Array.isArray(n?.edges)&&n.edges.some(e=>String(e?.visibilityClass||"").trim())}function C_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={},l=null){let u=n.LineSegments2,h=n.LineSegmentsGeometry,f=n.LineMaterial;if(!u||!h||!f||!(Array.isArray(e)||ArrayBuffer.isView(e))||!e.length)return null;let d=new h;d.setPositions(e);let m=R_(f,{color:t,opacity:i,lineWidth:r,depthTest:o,depthWrite:a,depthBias:c});w_(n,m,l);let y=new u(d,m);return y.renderOrder=s,y.frustumCulled=!1,y.userData.beforeDispose=()=>{T_(n,m,l)},y.userData.disposeGeometry=!0,y.userData.disposeMaterial=!0,y}function R_(n,{color:e,opacity:t=1,lineWidth:i=1,depthTest:r=!0,depthWrite:s=!1,depthBias:o=To}={}){let a=new n({color:e,linewidth:i,opacity:t,depthTest:r,depthWrite:s,toneMapped:!1,worldUnits:!1});return kR(a,t),Wp(a,o),a}function Wp(n,e=To){let t=on(Number(e)||0,0,.01);return!n||t<=0||(n.polygonOffset=!0,n.polygonOffsetFactor=0,n.polygonOffsetUnits=-on(Math.round(t*1e3),1,10),n.needsUpdate=!0),n}function b_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={},l=null){let u=n.Line2,h=n.LineGeometry,f=n.LineMaterial;if(!u||!h||!f||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let d=new h;d.setPositions(e);let m=R_(f,{color:t,opacity:i,lineWidth:r,depthTest:o,depthWrite:a,depthBias:c});w_(n,m,l);let y=new u(d,m);return y.renderOrder=s,y.frustumCulled=!1,y.userData.beforeDispose=()=>{T_(n,m,l)},y.userData.disposeGeometry=!0,y.userData.disposeMaterial=!0,y}function M_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={}){let l=n.THREE;if(!l||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let u=new l.BufferGeometry,h=e instanceof Float32Array?e:new Float32Array(e);u.setAttribute("position",new l.BufferAttribute(h,3));let f=new l.LineBasicMaterial({color:t,linewidth:Number.isFinite(Number(r))?Number(r):1,transparent:Number(i)<.999,opacity:on(Number(i)||0,0,1),depthTest:o,depthWrite:a,toneMapped:!1});Wp(f,c);let d=new l.Line(u,f);return d.renderOrder=s,d.frustumCulled=!1,d.userData.disposeGeometry=!0,d.userData.disposeMaterial=!0,d}function jR(n={},e,{color:t,opacity:i=1,renderOrder:r=3,depthTest:s=!0,depthWrite:o=!1,depthBias:a=To}={}){let c=n.THREE;if(!c||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let l=new c.BufferGeometry,u=e instanceof Float32Array?e:new Float32Array(e);l.setAttribute("position",new c.BufferAttribute(u,3));let h=new c.LineBasicMaterial({color:t,transparent:Number(i)<.999,opacity:on(Number(i)||0,0,1),depthTest:s,depthWrite:o,toneMapped:!1});Wp(h,a);let f=new c.LineSegments(l,h);return f.renderOrder=r,f.frustumCulled=!1,f.userData.disposeGeometry=!0,f.userData.disposeMaterial=!0,f}function $R(n,e,t,i=null){let r=VR(e);return r?C_(n,r,t,i):null}function I_(n={},{geometry:e,edgeSettings:t,baseTheme:i,partId:r,displayMode:s,thickness:o,wireframeEdgeColor:a=""},c=null){let l=n.THREE,u=di(s),h=t?.depthTest!==!1,f=Number.isFinite(Number(t?.opacity))?on(Number(t.opacity),0,1):i?.edgeOpacity??.84,d=u?a||t?.color||i?.edge||"#18181b":t?.color||i?.edge||"#18181b";if(u&&l){let y=Math.max(f,.9),g=new l.LineBasicMaterial({color:d,transparent:y<.999,opacity:y,depthTest:!1,depthWrite:!1,toneMapped:!1}),p=new l.LineSegments(e,g);return p.renderOrder=4,p.frustumCulled=!1,p.userData.partId=r,{edgeMesh:p,edgeMaterial:g}}let m=$R(n,e,{color:d,opacity:f,lineWidth:Number.isFinite(Number(o))?Number(o):1,renderOrder:3,depthTest:h,depthWrite:!1,depthBias:Hp(o)},c);return m?(m.userData.partId=r,{edgeMesh:m,edgeMaterial:m.material}):{edgeMesh:null,edgeMaterial:null}}function Xp(n={},e,t,i,r=null){let s=Vu(t?.includePartIds),o=Vu(t?.excludePartIds),a=Vu(t?.focusedPartIds),c=Vu(t?.highlightPartIds),l=YR(t,i).filter(M=>M.classId==="feature"||qR(e)),u=l.map(M=>M.classId),h=Number.isFinite(Number(t?.opacity))?on(Number(t.opacity),0,1):i?.edgeOpacity??.84,f=Number.isFinite(Number(t?.highlightOpacity))?on(Number(t.highlightOpacity),0,1):h,d=Number.isFinite(Number(t?.dimmedOpacity))?on(Number(t.dimmedOpacity),0,1):h,m=Number.isFinite(Number(t?.thickness))?on(Number(t.thickness),.5,6):i?.edgeThickness??1,y={color:t?.color||i?.edge||"#18181b",lineWidth:m,renderOrder:3,depthTest:t?.depthTest!==!1,depthWrite:!1,depthBias:Hp(m)},g=(M,C)=>C_(n,M,C,r)||jR(n,M,C),p=(M,C={})=>(Number.isFinite(Number(C.lineWidth))?Number(C.lineWidth):1)<=1.05?M_(n,M,C)||b_(n,M,C,r):b_(n,M,C,r)||M_(n,M,C),_=M=>{let C=M.filter(Boolean);if(!C.length)return null;if(C.length===1)return C[0];let S=n.THREE?new n.THREE.Group:null;if(!S)return C[0];for(let v of C)S.add(v);return S},x=(M,C)=>{if(!n.THREE||!Array.isArray(M)||!M.length)return null;let S=M.reduce((v,L)=>v+(L?.length||0),0);return M.length>A_||S>E_?null:_(M.map(v=>p(v,C)))},b=(M,C={})=>{let S=Number.isFinite(Number(C.lineWidth))?Number(C.lineWidth):M.thickness,v={includePartIds:C.includePartIds||s,excludePartIds:C.excludePartIds||o,visibilityClasses:[M.classId]},L={...y,...C,color:C.color||M.color||y.color,lineWidth:S,opacity:Number.isFinite(Number(C.opacity))?C.opacity:M.opacity,depthBias:Number.isFinite(Number(C.depthBias))?C.depthBias:Hp(S,{visibilityClass:M.classId})},U=WR(e,v)?x_(e,v):[],G=x(U,L);if(G)return G;let P=Vp(e,{...v});return P?.length?g(P,L):null};if(c.length){let M=Vp(e,{includePartIds:c,visibilityClasses:u});if(!M?.length)return null;let C=g(M,{...y,color:t?.highlightColor||y.color,opacity:f,depthBias:Number.isFinite(Number(t?.highlightDepthBias))?on(Number(t.highlightDepthBias),0,.01):0,renderOrder:Number.isFinite(Number(t?.highlightRenderOrder))?Number(t.highlightRenderOrder):26});return C&&(C.name="TopologyDisplayEdgeHighlights",C.userData.partId="__topology_highlight__"),C}if(a.length&&n.THREE){let M=new n.THREE.Group;for(let C of l){let S=b(C,{excludePartIds:a,opacity:Math.min(d,C.opacity),renderOrder:3}),v=b(C,{includePartIds:a,opacity:C.opacity,renderOrder:4});S&&M.add(S),v&&M.add(v)}return M.children.length?(M.name="TopologyDisplayEdges",M.userData.partId="__topology__",M):null}let T=l.map(M=>b(M)),A=_(T);return A?(A.name="TopologyDisplayEdges",A.userData.partId="__topology__",A):null}var KR=/^\s*#([^\s]*)/,ZR=/^o((?:\d+)(?:\.\d+)*)$/,JR=/^o((?:\d+)(?:\.\d+)*)\.([sfev])(\d+)$/,QR=/^([sfev])(\d+)$/;function Yp(n){return n==="s"?"shape":n==="f"?"face":n==="e"?"edge":"vertex"}function Gu(n){let e=String(n||"").replace(/\\/g,"/").trim().replace(/^\/+|\/+$/g,"");return!e||e.split("/").some(t=>!t||t==="."||t==="..")?"":e}function qp(n,{inheritedOccurrenceId:e=""}={}){let t=String(n||"").trim().replace(/^#/,"");if(!t)return null;let i=t.match(JR);if(i){let o=`o${i[1]}`,a=i[2],c=Number(i[3]);return{selectorType:Yp(a),occurrenceId:o,ordinal:c,kind:a,canonical:`${o}.${a}${c}`}}let r=t.match(ZR);if(r)return{selectorType:"occurrence",occurrenceId:`o${r[1]}`,ordinal:null,kind:"",canonical:`o${r[1]}`};let s=t.match(QR);if(s){let o=s[1],a=Number(s[2]);return e?{selectorType:Yp(o),occurrenceId:e,ordinal:a,kind:o,canonical:`${e}.${o}${a}`}:{selectorType:Yp(o),occurrenceId:"",ordinal:a,kind:o,canonical:`${o}${a}`}}return{selectorType:"opaque",occurrenceId:"",ordinal:null,kind:"",canonical:t}}function N_(n,e={}){return qp(n,e)}function Hu(n){let e=Array.isArray(n)?n.flatMap(r=>String(r||"").split(",")):String(n||"").split(","),t=[],i="";for(let r of e){let s=qp(r,{inheritedOccurrenceId:i});s&&(t.push(s.canonical),s.occurrenceId&&(i=s.occurrenceId))}return t}function P_(n){let e=Hu(n),t=[...new Set(e.filter(Boolean))],i={occurrence:1,shape:2,face:3,edge:4,vertex:5,opaque:6};return t.map((r,s)=>({selector:r,index:s,parsed:qp(r)})).sort((r,s)=>{let o=r.parsed?.occurrenceId||"",a=s.parsed?.occurrenceId||"";if(o!==a)return o.localeCompare(a);let c=i[r.parsed?.selectorType]??99,l=i[s.parsed?.selectorType]??99;if(c!==l)return c-l;let u=Number(r.parsed?.ordinal||0),h=Number(s.parsed?.ordinal||0);return u!==h?u-h:r.selector!==s.selector?r.selector.localeCompare(s.selector):r.index-s.index}).map(r=>r.selector)}function Wu(n){let e=String(n||"").trim().match(KR);if(!e)return null;let t=String(e[1]||"").trim();return{token:e[0],cadPath:"",selectors:Hu(t)}}function ic({cadPath:n="",selector:e="",selectors:t}={}){let i=P_(t!==void 0?t:e?[e]:[]);return i.length?`#${i.join(",")}`:"#"}var L_=1,eI=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function fn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function ut(n,e=""){return String(n??e).trim()||e}function Ut(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function tI(n,e,t){return Math.min(Math.max(n,e),t)}function D_(n){let e=ut(n,"number").toLowerCase();return["number","boolean","enum","select","color","string","button"].includes(e)?e==="select"?"enum":e:"number"}function nI(n){return(Array.isArray(n)?n:[]).map(e=>{if(fn(e)){let i=ut(e.value);return i?{value:i,label:ut(e.label,i)}:null}let t=ut(e);return t?{value:t,label:t}:null}).filter(Boolean)}function iI(n,e){let t=fn(e)?e:{},i=D_(t.type),r=Ut(t.min,0),s=Math.max(Ut(t.max,i==="number"?1:r),r),o=nI(t.options||t.values),a=i==="boolean"?!1:i==="color"?"#ffffff":i==="enum"?o[0]?.value||"":i==="string"?"":0;return{id:n,type:i,label:ut(t.label,n),description:ut(t.description),unit:ut(t.unit),min:r,max:s,step:Math.max(Ut(t.step,i==="number"?.01:1),0),defaultValue:Xu({type:i,min:r,max:s,options:o},t.default??t.defaultValue??a),options:o}}function Xu(n,e){let t=D_(n?.type);if(t==="boolean")return e===!0;if(t==="color"){let s=ut(e,ut(n?.defaultValue,"#ffffff"));return eI.test(s)?s:"#ffffff"}if(t==="enum"){let s=Array.isArray(n?.options)?n.options:[],o=ut(e,s[0]?.value||"");return s.some(a=>a.value===o)?o:s[0]?.value||""}if(t==="string")return String(e??"");if(t==="button")return Math.max(0,Math.floor(Ut(e,0)));let i=Ut(n?.min,0),r=Math.max(Ut(n?.max,i),i);return tI(Ut(e,Ut(n?.defaultValue,i)),i,r)}function rI(n){return Object.entries(fn(n)?n:{}).map(([e,t])=>iI(ut(e),t)).filter(e=>e.id)}function sI(n){let e=String(n||"").split("?")[0].split("#")[0].replace(/\\/g,"/").trim();if(!e)return"";try{e=new URL(e,"http://localhost").pathname}catch{}let t=e.replace(/^\/+|\/+$/g,""),i=t.lastIndexOf("/"),r=i>=0?t.slice(0,i):"",o=(i>=0?t.slice(i+1):t).match(/^\.?(.+)\.step\.js$/);return o?.[1]?Gu([r,o[1]].filter(Boolean).join("/")):""}function oI(n){let e=ut(n).replace(/\\/g,"/");if(!e||e.startsWith("/")||/^[A-Za-z]:\//.test(e)||/^[a-z][a-z0-9+.-]*:/i.test(e))return"";let t=e.split("/").filter(r=>r&&r!==".");if(!t.length||t.some(r=>r===".."))return"";let i=t.join("/");return/\.(step|stp)$/i.test(i)?i:""}function aI(n){return Gu(String(n||"").replace(/\.(step|stp)$/i,""))}function cI(n){let e=fn(n)?n:{};return{...e,path:oI(e.path)}}function lI(n,e){if(!fn(n)&&!e.path)return null;let t=fn(n)?{...n}:{};return e.path?t.path=e.path:delete t.path,Object.keys(t).length?t:null}function uI(n,e=""){let t=fn(n)?n:{},i=ut(t.ref),r=Wu(i);if(r)return ic({selectors:r.selectors});let s=i.startsWith("#")?i.slice(1):"",o=Hu(s||t.selector||t.selectors||t.occurrence||t.occurrences||[]);return o.length?ic({selectors:o}):i}function hI(n,{cadPath:e=""}={}){return Object.entries(fn(n)?n:{}).map(([t,i])=>{let r=fn(i)?i:{},s=ut(t);return s?{id:s,label:ut(r.label,s),description:ut(r.description),ref:uI(r,e),partIds:Array.isArray(r.partIds)?r.partIds.map(o=>ut(o)).filter(Boolean):[],axis:U_(r.axis,[0,0,1]),origin:dI(r.origin,null)}:null}).filter(Boolean)}function fI(n){return Object.entries(fn(n)?n:{}).map(([e,t])=>{let i=fn(t)?t:{},r=ut(e);return r?{id:r,label:ut(i.label,r),description:ut(i.description),duration:Math.max(Ut(i.duration??i.durationSeconds,1),.001),loop:i.loop!==!1,update:typeof i.update=="function"?i.update:null,raw:i}:null}).filter(Boolean)}function U_(n,e=[0,0,0]){let t=Array.isArray(n)?n:e;return[Ut(t?.[0],e[0]||0),Ut(t?.[1],e[1]||0),Ut(t?.[2],e[2]||0)]}function dI(n,e=[0,0,0]){return!Array.isArray(n)&&e===null?null:U_(n,e||[0,0,0])}function pI(n,{url:e="",cadPath:t=""}={}){if(!fn(n))throw new Error("STEP runtime module must export an object");let i=fn(n.manifest)?n.manifest:n,r=Number(i.schemaVersion||n.schemaVersion||1);if(r!==L_)throw new Error(`Unsupported STEP runtime module schemaVersion ${r||"unknown"}`);let s=cI(i.step),o=aI(s.path),a=o||Gu(t)||sI(e),c=rI(i.parameters),l=Object.fromEntries(c.map(d=>[d.id,d])),u=Object.fromEntries(c.map(d=>[d.id,d.defaultValue])),h=lI(i.step,s),f={...i,schemaVersion:L_};return h?f.step=h:delete f.step,{url:ut(e),cadPath:a,step:{path:s.path,cadPath:o||a,explicit:!!s.path,inferred:!s.path&&!!a},module:n,manifest:f,features:hI(i.features,{cadPath:a}),parameters:c,parameterMap:l,defaultParameterValues:u,animations:fI(i.animations)}}async function F_(n,e={}){let t=await import(n);return pI(t?.default??t,{url:n,...e})}function B_(n,e={}){let t=n?.parameterMap||{};return Object.fromEntries(Object.values(t).map(i=>[i.id,Xu(i,fn(e)&&Object.hasOwn(e,i.id)?e[i.id]:i.defaultValue)]))}function mI(n){let e=Array.isArray(n?.min)?n.min:[0,0,0],t=Array.isArray(n?.max)?n.max:e;return[(Ut(e[0])+Ut(t[0]))/2,(Ut(e[1])+Ut(t[1]))/2,(Ut(e[2])+Ut(t[2]))/2]}function gI(n){let e=(Array.isArray(n)?n:[]).filter(r=>Array.isArray(r?.min)&&Array.isArray(r?.max));if(!e.length)return null;let t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let r of e)for(let s=0;s<3;s+=1)t[s]=Math.min(t[s],Ut(r.min[s])),i[s]=Math.max(i[s],Ut(r.max[s]));return{min:t,max:i}}function jp(n,e){let t=ut(n),i=Array.isArray(e?.parts)?e.parts:[];return!t||!i.length?[]:i.filter(r=>[r?.id,r?.occurrenceId].map(o=>ut(o)).filter(Boolean).some(o=>o===t||o.startsWith(`${t}.`)||t.startsWith(`${o}.`))).map(r=>ut(r.id||r.occurrenceId)).filter(Boolean)}function O_(n,e){let t=ut(n);return!t||!e?null:e.referenceByNormalizedSelector?.get(t)||e.referenceByDisplaySelector?.get(t)||e.referenceMap?.get(t)||null}function Mr(n){return[...new Set((Array.isArray(n)?n:[]).map(e=>ut(e)).filter(Boolean))]}function yI(n){let e=Wu(n?.ref);return e?e.selectors.length?e.selectors:["__model__"]:[]}function $p(n,{meshData:e=null,selectorRuntime:t=null}={}){let i=Array.isArray(e?.parts)?e.parts:[],r=new Map(i.map(o=>[ut(o.id||o.occurrenceId),o])),s=i.length?i.map(o=>ut(o.id||o.occurrenceId)).filter(Boolean):["__model__"];return Object.fromEntries((Array.isArray(n?.features)?n.features:[]).map(o=>{let a=yI(o),c=a.map(d=>d==="__model__"?null:O_(d,t)).filter(Boolean),l=a.flatMap(d=>{if(d==="__model__")return s;let m=N_(d);if(m?.occurrenceId)return jp(m.occurrenceId,e);let y=O_(d,t);return jp(y?.partId||y?.occurrenceId||d,e)}),u=Mr([...o.partIds,...l]),h=u.map(d=>r.get(d)).filter(Boolean),f=gI(h.map(d=>d.bounds))||e?.bounds||null;return[o.id,{...o,selectors:a,references:c,partIds:u,parts:h,bounds:f,center:o.origin||mI(f),transform:h.length===1&&h[0]?.transform||null,transforms:h.map(d=>d?.transform||null),missing:a.length>0&&u.length===0&&a[0]!=="__model__"}]}))}function ps(n,e,t){if(Array.isArray(n))return Mr(n.flatMap(o=>ps(o,e,t)));if(fn(n)){if(Array.isArray(n.partIds))return Mr(n.partIds);if(n.partId)return Mr([n.partId]);if(n.feature)return ps(n.feature,e,t);if(n.ref)return ps(n.ref,e,t)}let i=ut(n);if(!i)return[];if(i==="*"||i==="all"||i==="__all__"){let o=Array.isArray(t?.parts)?t.parts:[];return o.length?Mr(o.map(a=>a?.id||a?.occurrenceId)):["__model__"]}let r=e?.[i];if(r)return Mr(r.partIds);let s=Wu(i);if(s){let o=s.selectors.length?s.selectors:["*"];return Mr(o.flatMap(a=>ps(a,e,t)))}return Mr(jp(i,t))}function mi(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function xI(n,e,t){return Math.min(Math.max(n,e),t)}function Yu(n){return[...new Set((Array.isArray(n)?n:[]).map(e=>String(e||"").trim()).filter(Boolean))]}function rc(n,e){let t=new n.Matrix4;return!Array.isArray(e)||e.length!==16?(t.identity(),t):(t.set(Number(e[0])||0,Number(e[1])||0,Number(e[2])||0,Number(e[3])||0,Number(e[4])||0,Number(e[5])||0,Number(e[6])||0,Number(e[7])||0,Number(e[8])||0,Number(e[9])||0,Number(e[10])||0,Number(e[11])||0,Number(e[12])||0,Number(e[13])||0,Number(e[14])||0,Number(e[15])||0),t)}function z_(n,e,t=!0){return!t||n?.partTransformsBaked===!0?null:e?.transform||null}function Jp(n,e=[0,0,0]){return Array.isArray(n)||ArrayBuffer.isView(n)?[mi(n[0],e[0]||0),mi(n[1],e[1]||0),mi(n[2],e[2]||0)]:n&&typeof n=="object"?[mi(n.x,e[0]||0),mi(n.y,e[1]||0),mi(n.z,e[2]||0)]:[...e]}function Kp(n,e,t=[0,0,0]){let i=Jp(e,t);return new n.Vector3(i[0],i[1],i[2])}function _I(n,e={}){let t=Kp(n,e.axis,[0,0,1]);t.lengthSq()<=1e-12&&t.set(0,0,1),t.normalize();let i=Kp(n,e.origin,[0,0,0]),r=Number.isFinite(Number(e.angleRad))?Number(e.angleRad):mi(e.angleDeg,0)*Math.PI/180;return new n.Matrix4().makeTranslation(i.x,i.y,i.z).multiply(new n.Matrix4().makeRotationAxis(t,r)).multiply(new n.Matrix4().makeTranslation(-i.x,-i.y,-i.z))}function SI(n,e={}){let t=e.scale??e,i=Array.isArray(t)||ArrayBuffer.isView(t)?Jp(t,[1,1,1]):[mi(t,1),mi(t,1),mi(t,1)],r=Kp(n,e.origin,[0,0,0]);return new n.Matrix4().makeTranslation(r.x,r.y,r.z).multiply(new n.Matrix4().makeScale(i[0],i[1],i[2])).multiply(new n.Matrix4().makeTranslation(-r.x,-r.y,-r.z))}function bI(n,e){let t=Jp(e,[0,0,0]);return new n.Matrix4().makeTranslation(t[0],t[1],t[2])}function MI(n,e={}){if(!e||typeof e!="object")return new n.Matrix4;if(Array.isArray(e.matrix)&&e.matrix.length===16)return rc(n,e.matrix);let t=new n.Matrix4;return e.scale!==void 0&&t.premultiply(SI(n,e)),e.rotate&&typeof e.rotate=="object"&&t.premultiply(_I(n,e.rotate)),e.translate!==void 0&&t.premultiply(bI(n,e.translate)),t}function vI(n,e={}){if(!e||typeof e!="object")return new n.Matrix4;let t=Array.isArray(e.transforms)?e.transforms:[e],i=new n.Matrix4;for(let r of t)i.premultiply(MI(n,r));return i}function AI(n,e=1e-6){if(!n?.elements||n.elements.length!==16)return!1;let t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return n.elements.some((i,r)=>Math.abs(Number(i)-t[r])>e)}function EI(n){for(let e of Array.isArray(n)?n:[])e.effectMatrix=null,e.effectStyle=null,e.effectVisible=null,e.effectHighlighted=!1}function wI(n,e){let t=Array.isArray(n?.parts)?n.parts.map(r=>String(r?.id||r?.occurrenceId||"").trim()).filter(Boolean):[];if(t.length)return Yu(t);let i=(Array.isArray(e)?e:[]).map(r=>String(r?.partId||"").trim()).filter(Boolean);return Yu(i.length?i:["__model__"])}function Zp(n,e,t,i){if(n&&typeof n=="object"&&!Array.isArray(n)){if(Array.isArray(n.partIds))return Yu(n.partIds);if(n.partId)return Yu([n.partId]);if(n.feature)return Zp(n.feature,e,t,i);if(n.ref)return ps(String(n.ref),e,t)}let r=String(n||"").trim();return r==="*"||r==="all"||r==="__all__"?wI(t,i):ps(n,e,t)}function Qp(n,{meshData:e,features:t,runtime:i,effectsByPartId:r,onTransformEffect:s}){let o=c=>{let l=String(c||"").trim();if(!l)return null;let u=r.get(l)||{matrix:null,style:null,visible:null,highlighted:!1};return r.set(l,u),u},a=(c,l)=>{let u=Zp(c,t,e,i?.displayRecords);for(let h of u){let f=o(h);f&&l(f,h)}return u};return{transform(c,l){let u=vI(n,l),h=a(c,f=>{f.matrix=f.matrix?f.matrix.clone().premultiply(u):u.clone()});h.length&&AI(u)&&s?.({target:c,spec:l,partIds:h,matrix:u.clone()})},style(c,l={}){!l||typeof l!="object"||a(c,u=>{u.style={...u.style||{},...l}})},visible(c,l=!0){a(c,u=>{u.visible=l!==!1})},highlight(c,l=!0){a(c,u=>{u.highlighted=l!==!1})},clear(c){let l=Zp(c,t,e,i?.displayRecords);for(let u of l)r.delete(u)}}}function TI(n={}){let e=Math.max(Number(n.duration)||0,0),t=Math.max(Number(n.elapsedSec)||0,0);return{elapsed:t,elapsedSec:t,duration:e,progress:e>0?xI(t/e,0,1):0,cycle:e>0?t/e:0,playing:n.playing===!0,speed:Math.max(Number(n.speed)||1,0)}}function qu({runtime:n,stepModuleRuntime:e,features:t,effects:i,cleanup:r}){let s=e?.definition||null;return{THREE:n?.THREE,scene:n?.scene,modelGroup:n?.modelGroup,edgesGroup:n?.edgesGroup,runtime:n,manifest:s?.manifest||{},module:s?.module||null,cadPath:e?.cadPath||s?.cadPath||"",params:e?.parameterValues||{},features:t,effects:i,time:TI(e?.animationState),cleanup:typeof r=="function"?r:()=>{},requestRender:()=>n?.requestRender?.()}}function V_(n,e,t){EI(e);for(let i of Array.isArray(e)?e:[]){let r=t.get(String(i?.partId||"").trim());r&&(i.effectMatrix=r.matrix instanceof n.Matrix4?r.matrix.clone():null,i.effectStyle=r.style&&typeof r.style=="object"?{...r.style}:null,i.effectVisible=r.visible,i.effectHighlighted=r.highlighted===!0)}}function em(n,e,t){if(!e||!(t instanceof n.Matrix4))return;e.matrixAutoUpdate=!1;let i=e.matrix instanceof n.Matrix4?e.matrix:new n.Matrix4;i.copy(t),e.matrix=i,e.matrixWorldNeedsUpdate=!0}function tm(n,e){if(!e||!n?.Matrix4)return null;let t=[e.effectMatrix,e.explodedViewMatrix].filter(r=>r instanceof n.Matrix4);if(!t.length)return null;let i=new n.Matrix4;for(let r of t)i.premultiply(r);return i}function CI(n,e){let t=rc(n,e?.baseTransform),i=tm(n,e);return i?i.multiply(t):t}function ms(n,e){if(!e)return;let t=CI(n,e);em(n,e.mesh,t),em(n,e.edges,t),em(n,e.silhouette,t)}var Yi=Object.freeze({CAD:"cad",URDF:"urdf"}),RI=Object.freeze({[Yi.CAD]:Object.freeze({minModelRadius:1,minGridSize:280,lightingScopeRadius:140,lightingReferenceModelRadius:760}),[Yi.URDF]:Object.freeze({minModelRadius:.05,minGridSize:.28,lightingScopeRadius:.14,lightingReferenceModelRadius:.76})}),sO=Object.freeze({[Yi.CAD]:Object.freeze({minExtent:60,normalBias:.024,radius:14}),[Yi.URDF]:Object.freeze({minExtent:.55,normalBias:12e-6,radius:14})});function nm(n){return n===Yi.URDF?Yi.URDF:Yi.CAD}function im(n){return RI[nm(n)]}function k_(n,e){let t=Number(n);return Math.max(Number.isFinite(t)?t:0,im(e).minModelRadius)}var II=Yi,lm=.84,G_=16,H_="#8dc5ff",ju="#4f9dff",PI=.08,NI=.12,LI=23,OI=26,DI=.035,UI=/^#(?:[0-9a-fA-F]{3}){1,2}$/,Co="__model__",kt=Object.freeze({surface:"#f4f4f5",surfaceRoughness:.92,surfaceMetalness:.03,surfaceClearcoat:0,surfaceClearcoatRoughness:.6,edge:"#18181b",edgeThickness:1,edgeOpacity:lm}),Zu="_cad_edge_barycentric",Ju="_cad_edge_class",FI=Object.freeze(["feature","tangent","seam","degenerate"]),W_=Object.freeze({feature:Object.freeze({color:"#132232",thickness:1.15,opacity:1}),tangent:Object.freeze({color:"#132232",thickness:1.15,opacity:.5}),seam:Object.freeze({color:"#132232",thickness:1.15,opacity:.85}),degenerate:Object.freeze({color:"#132232",thickness:0,opacity:1})}),X_=new WeakMap;function BI(n){let e=n?.geometrySource;return e&&typeof e=="object"?e:n}function Qe(n,e,t){return Math.min(Math.max(n,e),t)}function ze(n,e=0){return Number.isFinite(Number(n))?Number(n):e}function Y_(n){return Array.isArray(n)?n:[]}function gi(n,e=1){return(Array.isArray(n)||ArrayBuffer.isView(n))&&n.length>=e&&n.length%e===0}function iS(n){return nm(n)}function cm(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let i=0;i+2<(n?.length||0);i+=3){let r=Number(n[i]),s=Number(n[i+1]),o=Number(n[i+2]);[r,s,o].every(Number.isFinite)&&(e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],s),e[2]=Math.min(e[2],o),t[0]=Math.max(t[0],r),t[1]=Math.max(t[1],s),t[2]=Math.max(t[2],o))}return!e.every(Number.isFinite)||!t.every(Number.isFinite)?{min:[0,0,0],max:[1,1,1]}:{min:e,max:t}}function Ku(n,e,t=II.CAD){let i=iS(t),r=im(i),s=Array.isArray(e?.min)?e.min:[0,0,0],o=Array.isArray(e?.max)?e.max:[1,1,1],a=new n.Vector3((ze(s[0])+ze(o[0],1))/2,(ze(s[1])+ze(o[1],1))/2,(ze(s[2])+ze(o[2],1))/2),c=new n.Vector3(Math.max(ze(o[0],1)-ze(s[0]),r.minModelRadius),Math.max(ze(o[1],1)-ze(s[1]),r.minModelRadius),Math.max(ze(o[2],1)-ze(s[2]),r.minModelRadius));return{center:a,size:c,radius:k_(c.length()/2,i)}}function rS(n){let e=BI(n),t=X_.get(e);return t||(t={whole:new Map,part:new Map,edge:new Map},X_.set(e,t)),t}function zI(n){return n.map((e,t)=>String(e?.id||e?.occurrenceId||`part:${t}`)).join("|")}function sS(n){return n&&(n.userData={...n.userData||{},cadSceneCachedGeometry:!0}),n}function VI(n){let e=Array.isArray(n)?n:[n];for(let t of e)t?.map?.dispose?.(),t?.alphaMap?.dispose?.(),t?.dispose?.()}function oS(n,{disposeCachedGeometry:e=!1}={}){if(n){for(;n.children?.length;)oS(n.children[0],{disposeCachedGeometry:e});n.parent?.remove(n),typeof n.userData?.beforeDispose=="function"&&(n.userData.beforeDispose(n),delete n.userData.beforeDispose),(e||n.geometry?.userData?.cadSceneCachedGeometry!==!0)&&n.geometry?.dispose?.(),VI(n.material)}}function rm(n,e={}){for(;n?.children?.length;)oS(n.children[0],e)}function aS(n,e,t,i){let r=gi(t,3);if(!i&&r){e.setAttribute("normal",new n.BufferAttribute(new Float32Array(t),3));return}e.computeVertexNormals()}function cS(n,e,t,i=0,r=0){let s=t?.surfaceEdgeBarycentric,o=t?.surfaceEdgeClass,a=Math.max(0,Math.floor(Number(i)||0))*3,c=Math.max(0,Math.floor(Number(r)||0))*3;!(s instanceof Float32Array)||!(o instanceof Uint8Array)||c<=0||s.length<a+c||o.length<a+c||(e.setAttribute(Zu,new n.BufferAttribute(s.slice(a,a+c),3)),e.setAttribute(Ju,new n.BufferAttribute(o.slice(a,a+c),3)))}function kI(n){let e=n?.getAttribute?.(Zu),t=n?.getAttribute?.(Ju);return e?.itemSize===3&&t?.itemSize===3&&e.count>0&&e.count===t.count}function gs(n,e){let t=String(e||"").trim();if(!UI.test(t))return null;let i=t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t;return new n.Color(i)}function um(n,e,t={},{applyTint:i=!0}={}){let r=(e||new n.Color("#ffffff")).clone(),s=Qe(Number(t.tintStrength)||0,0,1);if(i&&s>0){let l=new n.Color(t.defaultColor||t.tintColor||"#ffffff");t.tintMode==="blend"?r.lerp(l,s):r.lerp(r.clone().multiply(l),s)}let o=Qe(Number(t.saturation)||1,0,2.5);if(Math.abs(o-1)>1e-4){let l={};r.getHSL(l),r.setHSL(l.h,Qe(l.s*o,0,1),l.l)}let a=Qe(Number(t.contrast)||1,0,2.5),c=Qe(Number(t.brightness)||1,0,2);return r.r=Qe(((r.r-.5)*a+.5)*c,0,1),r.g=Qe(((r.g-.5)*a+.5)*c,0,1),r.b=Qe(((r.b-.5)*a+.5)*c,0,1),r}function GI(n,e,t={}){if(!gi(e,3))return null;let i=new Float32Array(e.length),r=new n.Color;for(let s=0;s+2<e.length;s+=3){r.setRGB(Qe(Number(e[s])||0,0,1),Qe(Number(e[s+1])||0,0,1),Qe(Number(e[s+2])||0,0,1));let o=um(n,r,t);i[s]=o.r,i[s+1]=o.g,i[s+2]=o.b}return i}function lS(n){return!!n?.has_source_colors&&gi(n?.colors,3)}function HI(n,e){return lS(n)?e&&Object.hasOwn(e,"hasSourceColors")?!!e.hasSourceColors:!0:!1}function WI(n,e={},t=0){return new n.Color(Pp(e,t))}function q_(n,e={},t=0){return um(n,WI(n,e,t),e,{applyTint:!1})}function uS(n,{hasVertexColors:e=!1,sourceColor:t=null,materialSettings:i,fallbackColor:r="#ffffff",fillIndex:s=0,forceFill:o=!1}){return o?q_(n,i,s):e?new n.Color("#ffffff"):t?um(n,t,i):q_(n,{...i,defaultColor:r||i?.defaultColor},s)}function XI(n={},e,t="#132232"){let i=W_[e]||W_.feature,r=n?.classes?.[e]||{};return{color:r.color||t||i.color,thickness:Qe(Number.isFinite(Number(r.thickness))?Number(r.thickness):i.thickness,0,6),opacity:Qe(Number.isFinite(Number(r.opacity))?Number(r.opacity):i.opacity,0,1)}}function YI(n,e,t={},i=kt){let r=t?.color||i?.edge||kt.edge,s=Object.fromEntries(FI.map(c=>[c,XI(t,c,r)])),o=new n.Color(r),a=Object.fromEntries(Object.entries(s).map(([c,l])=>[c,gs(n,l.color)||o.clone()]));e.userData.cadSurfaceEdges=!0,e.userData.cadSurfaceEdgeBaseColor=o.clone(),e.userData.cadSurfaceEdgeColor=o.clone(),e.userData.cadSurfaceEdgeBaseClassSettings=Object.fromEntries(Object.entries(s).map(([c,l])=>[c,{...l}])),e.extensions={...e.extensions||{},derivatives:!0},e.onBeforeCompile=c=>{let l=e.userData.cadSurfaceEdgeColor?.isColor?e.userData.cadSurfaceEdgeColor:o;e.userData.cadSurfaceEdgeShader=c,c.uniforms.cadSurfaceEdgeColor={value:l.clone()},c.uniforms.cadSurfaceFeatureColor={value:a.feature.clone()},c.uniforms.cadSurfaceTangentColor={value:a.tangent.clone()},c.uniforms.cadSurfaceSeamColor={value:a.seam.clone()},c.uniforms.cadSurfaceDegenerateColor={value:a.degenerate.clone()},c.uniforms.cadSurfaceFeatureThickness={value:s.feature.thickness},c.uniforms.cadSurfaceTangentThickness={value:s.tangent.thickness},c.uniforms.cadSurfaceSeamThickness={value:s.seam.thickness},c.uniforms.cadSurfaceDegenerateThickness={value:s.degenerate.thickness},c.uniforms.cadSurfaceFeatureOpacity={value:s.feature.opacity},c.uniforms.cadSurfaceTangentOpacity={value:s.tangent.opacity},c.uniforms.cadSurfaceSeamOpacity={value:s.seam.opacity},c.uniforms.cadSurfaceDegenerateOpacity={value:s.degenerate.opacity},c.vertexShader=c.vertexShader.replace("#include <common>",`#include <common>
attribute vec3 ${Zu};
attribute vec3 ${Ju};
varying vec3 vCadSurfaceEdgeBarycentric;
varying vec3 vCadSurfaceEdgeClass;`).replace("#include <begin_vertex>",`#include <begin_vertex>
vCadSurfaceEdgeBarycentric = ${Zu};
vCadSurfaceEdgeClass = ${Ju};`),c.fragmentShader=c.fragmentShader.replace("#include <common>",`#include <common>
uniform vec3 cadSurfaceEdgeColor;
uniform vec3 cadSurfaceFeatureColor;
uniform vec3 cadSurfaceTangentColor;
uniform vec3 cadSurfaceSeamColor;
uniform vec3 cadSurfaceDegenerateColor;
uniform float cadSurfaceFeatureThickness;
uniform float cadSurfaceTangentThickness;
uniform float cadSurfaceSeamThickness;
uniform float cadSurfaceDegenerateThickness;
uniform float cadSurfaceFeatureOpacity;
uniform float cadSurfaceTangentOpacity;
uniform float cadSurfaceSeamOpacity;
uniform float cadSurfaceDegenerateOpacity;
varying vec3 vCadSurfaceEdgeBarycentric;
varying vec3 vCadSurfaceEdgeClass;
float cadSurfaceEdgeThicknessFor(float classCode) {
if (classCode < 0.5) {
return 0.0;
}
if (abs(classCode - 2.0) < 0.5) {
return cadSurfaceTangentThickness;
}
if (abs(classCode - 3.0) < 0.5) {
return cadSurfaceSeamThickness;
}
if (abs(classCode - 4.0) < 0.5) {
return cadSurfaceDegenerateThickness;
}
return cadSurfaceFeatureThickness;
}
float cadSurfaceEdgeOpacityFor(float classCode) {
if (classCode < 0.5) {
return 0.0;
}
if (abs(classCode - 2.0) < 0.5) {
return cadSurfaceTangentOpacity;
}
if (abs(classCode - 3.0) < 0.5) {
return cadSurfaceSeamOpacity;
}
if (abs(classCode - 4.0) < 0.5) {
return cadSurfaceDegenerateOpacity;
}
return cadSurfaceFeatureOpacity;
}
vec3 cadSurfaceEdgeColorFor(float classCode) {
if (classCode < 0.5) {
return cadSurfaceEdgeColor;
}
if (abs(classCode - 2.0) < 0.5) {
return cadSurfaceTangentColor;
}
if (abs(classCode - 3.0) < 0.5) {
return cadSurfaceSeamColor;
}
if (abs(classCode - 4.0) < 0.5) {
return cadSurfaceDegenerateColor;
}
return cadSurfaceFeatureColor;
}
float cadSurfaceEdgeCoverage(float barycentric, float classCode) {
float thickness = cadSurfaceEdgeThicknessFor(classCode);
float opacity = cadSurfaceEdgeOpacityFor(classCode);
if (thickness <= 0.0 || opacity <= 0.0) {
return 0.0;
}
float pixelDistance = barycentric / max(fwidth(barycentric), 1e-6);
float halfWidth = max(thickness * 0.5, 0.001);
float coverage = 1.0 - smoothstep(max(halfWidth - 0.75, 0.0), halfWidth + 0.75, pixelDistance);
return clamp(coverage * opacity, 0.0, 1.0);
}
vec4 cadSurfaceEdgeLayerFor(float barycentric, float classCode) {
float edgeAlpha = cadSurfaceEdgeCoverage(barycentric, classCode);
return vec4(cadSurfaceEdgeColorFor(classCode), edgeAlpha);
}
vec4 cadSurfaceEdgeLayer() {
vec4 edge0 = cadSurfaceEdgeLayerFor(vCadSurfaceEdgeBarycentric.x, vCadSurfaceEdgeClass.x);
vec4 edge1 = cadSurfaceEdgeLayerFor(vCadSurfaceEdgeBarycentric.y, vCadSurfaceEdgeClass.y);
vec4 edge2 = cadSurfaceEdgeLayerFor(vCadSurfaceEdgeBarycentric.z, vCadSurfaceEdgeClass.z);
vec4 edge = edge0;
if (edge1.a > edge.a) {
edge = edge1;
}
if (edge2.a > edge.a) {
edge = edge2;
}
return edge;
}`).replace("#include <opaque_fragment>",`vec4 cadSurfaceEdgeMix = cadSurfaceEdgeLayer();
if (cadSurfaceEdgeMix.a > 0.0) {
outgoingLight = mix(outgoingLight, cadSurfaceEdgeMix.rgb, cadSurfaceEdgeMix.a);
}
#include <opaque_fragment>`)},e.customProgramCacheKey=()=>"cad-surface-edges-v2"}function qI(n,e,{color:t,useVertexColors:i=!1,edgeSettings:r=null}={}){let s=Number.isFinite(Number(e?.surfaceOpacity))?Number(e.surfaceOpacity):1,o=new n.MeshPhysicalMaterial({color:t||e?.surface||kt.surface,roughness:Number.isFinite(Number(e?.surfaceRoughness))?Number(e.surfaceRoughness):kt.surfaceRoughness,metalness:Number.isFinite(Number(e?.surfaceMetalness))?Number(e.surfaceMetalness):kt.surfaceMetalness,clearcoat:Number.isFinite(Number(e?.surfaceClearcoat))?Number(e.surfaceClearcoat):kt.surfaceClearcoat,clearcoatRoughness:Number.isFinite(Number(e?.surfaceClearcoatRoughness))?Number(e.surfaceClearcoatRoughness):kt.surfaceClearcoatRoughness,side:n.DoubleSide,vertexColors:i,transparent:s<.999,opacity:s,emissive:0,emissiveIntensity:0,polygonOffset:!1,polygonOffsetFactor:0,polygonOffsetUnits:0});return r?.enabled&&YI(n,o,r,e),o}function jI(n,e,t=0){return new n.MeshBasicMaterial({color:Pp(e||{},t),transparent:!0,opacity:.035,depthWrite:!1})}function $I(n,{color:e,useVertexColors:t=!1,opacity:i=1}={}){return new n.MeshBasicMaterial({color:e||kt.surface,side:n.DoubleSide,vertexColors:t,transparent:i<.999,opacity:i,depthWrite:i>=.999})}function KI(n,e,t){return gs(n,e?.color||t?.sourceColor)}function ZI(n,e=1){let t=Number(n?.opacity);return Number.isFinite(t)?Qe(t,0,1):e}function JI(n,e){let t=Array.isArray(e)?e:[],i=t.map(r=>String(r?.color||"").trim().toLowerCase()).filter(Boolean);return i.length?i.length!==t.length||new Set(i).size>1:!1}function QI(n){return(Array.isArray(n)?n:[]).some(t=>{let i=Number(t?.opacity);return Number.isFinite(i)&&Qe(i,0,1)<.999})}function e2(n){let e=new n.BufferGeometry;return e.setAttribute("position",new n.BufferAttribute(new Float32Array(0),3)),e}function t2(n,e){return[String(n?.occurrenceId||""),String(n?.id||""),String(n?.partSourcePath||n?.sourcePath||""),String(n?.label||n?.name||""),String(e).padStart(8,"0")].join("\0")}function n2(n=[]){return new Map([...n].map((e,t)=>({part:e,key:t2(e,t)})).sort((e,t)=>e.key.localeCompare(t.key)).map(({part:e},t)=>[e,t]))}function hS(n,e,t,i){let r=rS(e),s=r.part.get(t)||r.whole.get(t);if(s)return s;let o=i();return o?.geometry?(sS(o.geometry),t===Co?r.whole.set(t,o):r.part.set(t,o),o):null}function i2(n,e,t,i=!1){let r=String(t?.id||t?.occurrenceId||"").trim(),s=t?.sourceMesh&&typeof t.sourceMesh=="object"?t.sourceMesh:null,o=s&&t?.hasSourceColors?"source-colors":"flat",c=(s?`source:${String(t?.sourceMeshKey||t?.meshUrl||t?.partFileRef||r||"").trim()}:${o}`:"")||r||`${ze(t?.vertexOffset)}:${ze(t?.triangleOffset)}`;return hS(n,e,c,()=>{let l=s?0:ze(t?.vertexOffset,0),u=s?Math.floor((s.vertices?.length||0)/3):ze(t?.vertexCount,0),h=s?0:ze(t?.triangleOffset,0),f=s?Math.floor((s.indices?.length||0)/3):ze(t?.triangleCount,0);if(u<=0||f<=0)return null;let d,m,y,g;if(s)d=s.vertices||new Float32Array(0),m=t?.hasSourceColors&&gi(s.colors,3)&&s.colors.length===d.length?new Float32Array(s.colors):null,y=gi(s.normals,3)?s.normals:null,g=s.indices||new Uint32Array(0);else{let _=l*3,x=_+u*3;d=e.vertices.slice(_,x),m=HI(e,t)?new Float32Array(e.colors.slice(_,x)):null,y=gi(e.normals,3)?e.normals.slice(_,x):null;let b=e.indices.slice(h*3,h*3+f*3);g=new Uint32Array(b.length);for(let T=0;T<b.length;T+=1)g[T]=Math.max(0,Number(b[T])-l)}if(!g.length)return null;let p=new n.BufferGeometry;return p.setAttribute("position",new n.BufferAttribute(d instanceof Float32Array?d:new Float32Array(d),3)),p.setIndex(new n.BufferAttribute(g instanceof Uint32Array?g:new Uint32Array(g),1)),m&&m.length===d.length&&p.setAttribute("color",new n.BufferAttribute(new Float32Array(m),3)),s||cS(n,p,e,l,u),aS(n,p,y,i),p.computeBoundingSphere(),{geometry:p,rawColors:m}})}function r2(n,e,t=!1){return hS(n,e,Co,()=>{let i=new n.BufferGeometry;i.setAttribute("position",new n.BufferAttribute(new Float32Array(e.vertices||[]),3)),i.setIndex(new n.BufferAttribute(new Uint32Array(e.indices||[]),1));let r=lS(e)&&e.colors?.length===e.vertices?.length?new Float32Array(e.colors):null;return r&&i.setAttribute("color",new n.BufferAttribute(new Float32Array(r),3)),cS(n,i,e,0,Math.floor((e.vertices?.length||0)/3)),aS(n,i,e.normals,t),i.computeBoundingSphere(),{geometry:i,rawColors:r}})}function s2(n,e,t){if(!e?.geometry||!e.rawColors||!e.hasVertexColors)return;let i=GI(n,e.rawColors,t);if(!i)return;let r=e.geometry.getAttribute("color");if(r?.array?.length===i.length){r.array.set(i),r.needsUpdate=!0;return}e.geometry.setAttribute("color",new n.BufferAttribute(i,3))}function j_(n,e,t){if(!gi(e,3)||!gi(t,2))return null;let i=Math.floor(e.length/3),r=Math.floor(t.length/2);if(r<=0)return null;let s=new Float32Array(r*6),o=0;for(let l=0;l+1<t.length;l+=2){let u=Number(t[l]),h=Number(t[l+1]);if(!Number.isInteger(u)||!Number.isInteger(h)||u<0||h<0||u>=i||h>=i)continue;let f=u*3,d=h*3;s[o]=Number(e[f]),s[o+1]=Number(e[f+1]),s[o+2]=Number(e[f+2]),s[o+3]=Number(e[d]),s[o+4]=Number(e[d+1]),s[o+5]=Number(e[d+2]),o+=6}if(!o)return null;let a=new n.BufferGeometry,c=o===s.length?s:s.subarray(0,o);return a.setAttribute("position",new n.BufferAttribute(c,3)),a}function o2(n,e,t,i,r,s={}){let o=rS(e),a=t?String(t?.id||t?.occurrenceId||"").trim():Co,c=t?.sourceMesh?String(t?.sourceMeshKey||t?.meshUrl||t?.partFileRef||"").trim():"",l=`${r}:${c?`source:${c}`:a||Co}`,u=o.edge.get(l);if(u)return u;let h=null;if(di(r))h=new n.WireframeGeometry(i);else if(t){let f=ze(t?.edgeIndexOffset,0),d=ze(t?.edgeIndexCount,0);if(d>=2&&gi(e?.edge_indices,2)){let y=typeof e.edge_indices.subarray=="function"?e.edge_indices.subarray(f,f+d):e.edge_indices.slice(f,f+d);h=j_(n,e.vertices,y)}h||=new n.EdgesGeometry(i,G_)}else gi(e?.edge_indices,2)&&(h=j_(n,e.vertices,e.edge_indices));return h||=new n.EdgesGeometry(i,G_),h.getAttribute("position")?.count||(h.dispose(),h=e2(n)),sS(h),o.edge.set(l,h),h}function a2(n=null,e=null){let t=Number.isFinite(Number(e?.edgeThickness))?Number(e.edgeThickness):kt.edgeThickness;return Number.isFinite(Number(n?.thickness))?Qe(Number(n.thickness),.5,6):t}function c2(n,e){if(!n)return;let t=Qe(Number(e)||0,0,1),i=t<.999;n.opacity=t,n.depthWrite=!1,n.transparent!==i&&(n.transparent=i,n.needsUpdate=!0)}function l2(n,e,t,i,r,s){let o=di(s),a=i?.depthTest===!1?!1:!o,c=new n.LineBasicMaterial({color:i?.color||t?.edge||kt.edge,transparent:!0,opacity:o?Math.max(ze(i?.opacity,.92),.9):ze(i?.opacity,t?.edgeOpacity??lm),depthTest:a,depthWrite:!1}),l=new n.LineSegments(e,c);return l.userData.partId=r,{object:l,material:c}}function u2(n){if(!n)return{object:null,material:null};let e=n.object||n.edgeMesh||n.mesh||n.line||null;return{object:e,material:n.material||n.edgeMaterial||e?.material||null}}function h2(n=null){if(!n||typeof n!="object")return{mode:"basic"};let e=String(n.mode||n.type||"").trim().toLowerCase();return{...n,mode:e==="screen-space"||e==="screenspace"?"screen-space":"basic",wireframeEdgeColor:String(n.wireframeEdgeColor||"").trim()}}function f2(n,e={}){n.edgeRendering=e;for(let t of["Line2","LineGeometry","LineSegments2","LineSegmentsGeometry","LineMaterial"])n[t]=e[t]||e.constructors?.[t]||null}function d2(n,e,t,i){let r=i*Qe(ze(t?.silhouetteScale,.004),0,.04);if(!(r>0))return null;let s=new n.ShaderMaterial({uniforms:{color:{value:new n.Color(t?.color||kt.edge)},opacity:{value:Qe(ze(t?.opacity,.9),0,1)},offset:{value:r}},vertexShader:`
uniform float offset;
void main() {
vec3 displaced = position + normal * offset;
gl_Position = projectionMatrix * modelViewMatrix * vec4(displaced, 1.0);
}
`,fragmentShader:`
uniform vec3 color;
uniform float opacity;
void main() {
gl_FragColor = vec4(color, opacity);
}
`,side:n.BackSide,transparent:!0,depthTest:!0,depthWrite:!1}),o=new n.Mesh(e,s);return o.renderOrder=-1,o}function p2(n,e,t={}){return t.silhouette!==!1&&!di(e)&&n.silhouette===!0&&(n.enabled===!0||t.silhouette===!0)}function m2(n,e){let t=Array.isArray(e?.min)?e.min:[0,0,0],i=Array.isArray(e?.max)?e.max:t;return new n.Vector3((ze(t[0])+ze(i[0]))/2,(ze(t[1])+ze(i[1]))/2,(ze(t[2])+ze(i[2]))/2)}function fS(n,e,t,{baseTheme:i=kt,displayMode:r=at.SOLID}={}){if(!e?.material||!t)return;let s=di(r),o=t.overrideSourceColors===!0||s,a=!o&&!!e.hasVertexColors;if(e.useVertexColors=a,e.baseColor=uS(n,{hasVertexColors:a,sourceColor:o?null:e.sourceColor||null,materialSettings:t,fallbackColor:t?.defaultColor||i?.surface||kt.surface,fillIndex:e.fillIndex||0,forceFill:o||!e.hasSourceColor}),e.material.vertexColors=a,s){e.material.color&&e.baseColor&&e.material.color.copy(e.baseColor),e.baseOpacity=Iu(r,.035),e.material.opacity=e.baseOpacity,e.material.transparent=!0,e.material.depthWrite=!1,e.material.needsUpdate=!0;return}s2(n,e,t),e.material.roughness=Qe(Number(t.roughness)||0,0,1),e.material.metalness=Qe(Number(t.metalness)||0,0,1),e.material.clearcoat=Qe(Number(t.clearcoat)||0,0,1),e.material.clearcoatRoughness=Qe(Number(t.clearcoatRoughness)||0,0,1);let c=Number.isFinite(Number(e.sourceOpacity))?Qe(Number(e.sourceOpacity),0,1):1;e.baseOpacity=Qe(Iu(r,t.opacity)*c,0,1),e.material.opacity=e.baseOpacity,e.material.transparent=e.baseOpacity<.999,e.material.depthWrite=r===at.TRANSPARENT?!1:e.baseOpacity>=.999,e.material.envMapIntensity=Math.max(Number(t.envMapIntensity)||0,0),e.material.color&&e.baseColor&&e.material.color.copy(e.baseColor),e.baseEmissiveIntensity=Qe(Number(t.emissiveIntensity)||0,0,2),e.baseEmissiveColor=e.baseColor?e.baseColor.clone():null,"emissive"in e.material&&e.material.emissive&&(e.baseEmissiveColor&&e.baseEmissiveIntensity>0?e.material.emissive.copy(e.baseEmissiveColor):e.material.emissive.set(0),e.material.emissiveIntensity=e.baseEmissiveIntensity),e.material.needsUpdate=!0}function g2(n){return(Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean)}function $_(n){let e=String(n||"").trim();return e.startsWith("#")?e.slice(1).trim():e}function $u(n,e){if(!e?.size)return!1;if(e.has(Co))return!0;let t=$_(n);if(!t)return!1;for(let i of e){let r=$_(i);if(r&&(t===r||t.startsWith(`${r}.`)))return!0}return!1}function y2(n,e,t){return e?(Number.isFinite(Number(n[t]))||(n[t]=Number.isFinite(Number(e.renderOrder))?Number(e.renderOrder):0),n[t]):0}function K_(n,e,t,i,r){if(!e)return;let s=y2(n,e,t);e.renderOrder=i?r:s}function x2(n,e,t,{writeTransparentDepth:i=!0}={}){let r=n?.material;if(!r)return;Object.hasOwn(n,"baseDepthWrite")||(n.baseDepthWrite=r.depthWrite!==!1);let s=e||t<.999;r.transparent!==s&&(r.transparent=s,r.needsUpdate=!0),r.depthWrite=s&&!i?!1:n.baseDepthWrite}var _2=Object.freeze({feature:"cadSurfaceFeatureOpacity",tangent:"cadSurfaceTangentOpacity",seam:"cadSurfaceSeamOpacity",degenerate:"cadSurfaceDegenerateOpacity"}),S2=Object.freeze({feature:"cadSurfaceFeatureColor",tangent:"cadSurfaceTangentColor",seam:"cadSurfaceSeamColor",degenerate:"cadSurfaceDegenerateColor"});function b2(n,e,t,i=null){let r=e?.material,s=r?.userData;if(!r||s?.cadSurfaceEdges!==!0)return;let o=t?.isColor?t:gs(n,t)||s.cadSurfaceEdgeBaseColor;if(o?.isColor){s.cadSurfaceEdgeColor=o.clone();let h=s.cadSurfaceEdgeShader?.uniforms?.cadSurfaceEdgeColor;h?.value?.copy&&h.value.copy(o)}let a=i!=null&&Number.isFinite(Number(i))?Qe(Number(i),0,1):null,c=s.cadSurfaceEdgeBaseClassSettings||{},l=s.cadSurfaceEdgeShader?.uniforms||null,u=a!==null||o?.isColor&&s.cadSurfaceEdgeBaseColor?.isColor&&!o.equals(s.cadSurfaceEdgeBaseColor);for(let[h,f]of Object.entries(S2)){let d=gs(n,c[h]?.color)||s.cadSurfaceEdgeBaseColor,m=u?o:d;m?.isColor&&l?.[f]?.value?.copy&&l[f].value.copy(m)}for(let[h,f]of Object.entries(_2)){let d=Number(c[h]?.opacity),m=a===null?Number.isFinite(d)?d:null:a;m!==null&&(s[`cadSurfaceEdge${h}Opacity`]=m,l?.[f]&&(l[f].value=m))}}function M2(n,e,{baseTheme:t=kt,edgeSettings:i,hiddenPartIds:r,hoveredPartId:s,focusedPartId:o,selectedPartIds:a,showEdges:c=!0}={}){let l=new Set(Array.isArray(r)?r:[]),u=new Set(Array.isArray(a)?a:[]),h=new Set((Array.isArray(s)?s:[s]).map(M=>String(M||"").trim()).filter(Boolean)),f=i?.color||t?.edge||kt.edge,d=Number.isFinite(Number(t?.surfaceOpacity))?Number(t.surfaceOpacity):1,m=new Set(g2(o)),y=m.size>0,g=Number.isFinite(Number(i?.opacity))?Qe(Number(i.opacity),0,1):t?.edgeOpacity??kt.edgeOpacity??lm,p=Number.isFinite(Number(i?.highlightOpacity))?Qe(Number(i.highlightOpacity),0,1):1,_=String(i?.highlightColor||ju).trim()||ju,x=new n.Color(H_),b=new n.Color(_),T=new n.Color(ju),A=new n.Color(_);for(let M of Array.isArray(e)?e:[]){if(!M?.mesh||!M?.material)continue;let C=M.effectStyle&&typeof M.effectStyle=="object"?M.effectStyle:{},S=M.effectVisible===!1,v=gs(n,C.color),L=gs(n,C.edgeColor),U=gs(n,C.emissive),G=$u(M.partId,l),P=!G&&($u(M.partId,u)||M.effectHighlighted===!0),D=!G&&!S&&$u(M.partId,h),z=!G&&!S&&y&&$u(M.partId,m),q=!G&&!S&&y&&!z,Y=P||D;M.mesh.visible=!S,M.edges&&(M.edges.visible=c&&!S),M.silhouette&&(M.silhouette.visible=!S),K_(M,M.mesh,"baseMeshRenderOrder",Y,LI),K_(M,M.edges,"baseEdgeRenderOrder",Y,OI);let W=Number.isFinite(Number(M.baseOpacity))?Number(M.baseOpacity):d,j=Number.isFinite(Number(C.opacity))?Qe(Number(C.opacity),0,1):1,J=Number.isFinite(Number(C.edgeOpacity))?Qe(Number(C.edgeOpacity),0,1):j,le=P||D?p*J:null,X=Math.min(W*j,DI),Q=P?Qe(W*j+NI,0,1):D?Qe(W*j+PI,0,1):W*j,ue=G||q?X:Q;x2(M,G||q||Y,ue,{writeTransparentDepth:!G&&!q}),M.material.opacity=ue,M.baseColor&&M.material.color&&M.material.color.copy(P?T:D?x:v||M.baseColor),"emissive"in M.material&&M.material.emissive&&(P?M.material.emissive.set(ju):D?M.material.emissive.set(H_):M.baseEmissiveColor&&M.baseEmissiveIntensity>0?M.material.emissive.copy(M.baseEmissiveColor):M.material.emissive.set(0),M.material.emissiveIntensity=P?.08:D?.12:Qe(U?Number(C.emissiveIntensity)||.22:Number(M.baseEmissiveIntensity)||0,0,2),!P&&!D&&U&&M.material.emissive.copy(U));let xe=P?A:D?b:L||f;b2(n,M,xe,le),M.edgeMaterial&&(M.edgeMaterial.color?.set?.(xe),c2(M.edgeMaterial,P||D?p*J:G||q?ue:g*J))}}function v2(n){for(let e of Array.isArray(n)?n:[])e.effectMatrix=null,e.effectStyle=null,e.effectVisible=null,e.effectHighlighted=!1}function A2(n,e){let t=Array.isArray(e?.min)?e.min:[0,0,0],i=Array.isArray(e?.max)?e.max:[1,1,1];return[[t[0],t[1],t[2]],[t[0],t[1],i[2]],[t[0],i[1],t[2]],[t[0],i[1],i[2]],[i[0],t[1],t[2]],[i[0],t[1],i[2]],[i[0],i[1],t[2]],[i[0],i[1],i[2]]].map(r=>new n.Vector3(ze(r[0]),ze(r[1]),ze(r[2])))}function E2(n,e,t=null){if(!e||!Array.isArray(e.min)||!Array.isArray(e.max))return null;if(!(t instanceof n.Matrix4))return{min:[...e.min],max:[...e.max]};let i=A2(n,e).map(o=>o.applyMatrix4(t)),r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let o of i)r[0]=Math.min(r[0],o.x),r[1]=Math.min(r[1],o.y),r[2]=Math.min(r[2],o.z),s[0]=Math.max(s[0],o.x),s[1]=Math.max(s[1],o.y),s[2]=Math.max(s[2],o.z);return r.every(Number.isFinite)&&s.every(Number.isFinite)?{min:r,max:s}:null}function w2(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0],i=0;for(let r of Array.isArray(n)?n:[])if(!(!r||!Array.isArray(r.min)||!Array.isArray(r.max))){i+=1;for(let s=0;s<3;s+=1)e[s]=Math.min(e[s],ze(r.min[s])),t[s]=Math.max(t[s],ze(r.max[s]))}return i>0&&e.every(Number.isFinite)&&t.every(Number.isFinite)?{min:e,max:t}:null}function T2(n,e,t){let i=[];for(let r of Array.isArray(e)?e:[]){if(r.effectVisible===!1)continue;let s=rc(n,r.baseTransform),o=r.effectMatrix instanceof n.Matrix4?r.effectMatrix.clone():null,a=o?o.multiply(s):s;i.push(E2(n,r.partBounds,a))}return w2(i)||t}function C2(n,e,t,i,r={}){let s=t?.definition||null,o=s?.module||null;if(!s||!o?.setup)return;let a=new Map,c=$p(s,{meshData:i,selectorRuntime:t?.selectorRuntime||null}),l=qu({runtime:e,stepModuleRuntime:t,features:c,effects:Qp(n,{meshData:i,features:c,runtime:e,effectsByPartId:a}),cleanup:u=>{typeof u=="function"&&e.cleanups.push(u)}});try{o.setup(l)}catch(u){r.onWarning?.({title:"STEP parameter setup failed",message:u instanceof Error?u.message:String(u),error:u})}}function Z_(n,e,t={}){for(;n.cleanups.length;)try{n.cleanups.pop()?.()}catch(s){t.onWarning?.({title:"STEP parameter cleanup failed",message:s instanceof Error?s.message:String(s),error:s})}let i=e?.definition?.module||null;if(!i?.dispose)return;let r=qu({runtime:n,stepModuleRuntime:e,features:{},effects:{},cleanup:()=>{}});try{i.dispose(r)}catch(s){t.onWarning?.({title:"STEP parameter dispose failed",message:s instanceof Error?s.message:String(s),error:s})}}function R2(n,e,t,i,r={}){let s=t?.definition||null,o=s?.module||null;if(!s||!o){v2(e.displayRecords);for(let h of e.displayRecords)ms(n,h);return e.baseBounds}let a=new Map,c=$p(s,{meshData:i,selectorRuntime:t?.selectorRuntime||null}),l=Qp(n,{meshData:i,features:c,runtime:e,effectsByPartId:a}),u=qu({runtime:e,stepModuleRuntime:t,features:c,effects:l,cleanup:h=>{typeof h=="function"&&e.cleanups.push(h)}});try{o.update?.(u),o.render?.(u)}catch(h){r.onWarning?.({title:"STEP parameter update failed",message:h instanceof Error?h.message:String(h),error:h})}V_(n,e.displayRecords,a);for(let h of e.displayRecords)ms(n,h);return T2(n,e.displayRecords,e.baseBounds)}function I2(n,e,t,i=null){let r=Xa(e);if(!r.enabled||!t)return null;let s=Ox(r.axis),o=Array.isArray(t?.min)?t.min:[0,0,0],a=Array.isArray(t?.max)?t.max:o,c=ze(o[s]),l=ze(a[s]),u=Math.min(c,l),h=Math.max(c,l),f=u+(h-u)*r.offset,d=new n.Vector3(s===0?1:0,s===1?1:0,s===2?1:0);r.invert&&d.multiplyScalar(-1);let m=i?.clone?i.clone():new n.Vector3(0,0,0);return m.setComponent(s,m.getComponent(s)+f),new n.Plane().setFromNormalAndCoplanarPoint(d,m)}function sm(n,e){if(!n)return;let t=Array.isArray(n)?n:[n],i=Array.isArray(e)&&e.length>0;for(let r of t){if(!r)continue;let s=r.userData?.cadClipPlaneEnabled===!0,o=Number(r.userData?.cadClipPlaneCount)||0,a=r.clipping===!0;r.clippingPlanes=i?e:null,r.clipIntersection=!1,r.clipShadows=i,"clipping"in r&&(r.clipping=i),r.userData={...r.userData||{},cadClipPlaneEnabled:i,cadClipPlaneCount:i?e.length:0},(s!==i||o!==(i?e.length:0)||a!==(r.clipping===!0))&&(r.needsUpdate=!0)}}function P2(n,e,t,i=null){let r=I2(n.THREE,e,t,i),s=r?[r]:[];n.activeClipPlane=r,n.activeClipPlanes=s;for(let o of n.displayRecords)sm(o.material,s),sm(o.edgeMaterial,s),sm(o.silhouette?.material,s)}function J_(n={}){return n&&typeof n=="object"?n:{}}function N2(n){return Array.isArray(n)?n:String(n||"").trim().split(",")}function L2(n){let e=String(n||"").trim();return e?(e.startsWith("#")?e.slice(1):e).split(",").map(i=>i.trim()).filter(Boolean):[]}function om(n){return N2(n).flatMap(L2)}function Q_(n,e,{descendants:t=!1}={}){let i=String(n||"").trim(),r=String(e||"").trim();return!i||!r?!1:i===r||t&&i.startsWith(`${r}.`)}function eS(n,e){let t=String(e||"").trim();return t?[n?.id,n?.occurrenceId].some(i=>Q_(i,t,{descendants:!0}))?!0:[n?.name,n?.label,n?.linkName].some(i=>Q_(i,t)):!1}function O2(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0],i=0;for(let r of Array.isArray(n)?n:[]){let s=r?.bounds;if(!(!Array.isArray(s?.min)||!Array.isArray(s?.max))){i+=1;for(let o=0;o<3;o+=1)e[o]=Math.min(e[o],Number(s.min[o])),t[o]=Math.max(t[o],Number(s.max[o]))}}return i>0&&e.every(Number.isFinite)&&t.every(Number.isFinite)?{min:e,max:t}:null}function D2(n,e={}){let t=Array.isArray(n?.parts)?n.parts:[];if(!t.length)return n;let i=[...om(e.focus),...om(e.refs)],r=om(e.hide);if(!i.length&&!r.length)return n;let s=t.filter(o=>i.length&&!i.some(a=>eS(o,a))?!1:!r.some(a=>eS(o,a)));if(!s.length)throw new Error("No renderable parts remain after applying focus/hide filters");return{...n,parts:s,bounds:O2(s)||n.bounds}}function U2(n,e={}){return e.materialSettings&&typeof e.materialSettings=="object"?e.materialSettings:n.materials||{}}function dS(n,e,t){if(Array.isArray(t.parts))return t.parts.filter(r=>ze(r?.vertexCount)>0&&ze(r?.triangleCount)>0);let i=Y_(n?.parts).filter(r=>ze(r?.vertexCount)>0&&ze(r?.triangleCount)>0);if(!i.length)return[];if(t.renderPartsIndividually===!0)return i;if(t.renderPartsIndividually===!1){let r=Y_(t.pickableParts).filter(o=>ze(o?.vertexCount)>0&&ze(o?.triangleCount)>0);return r.length?r:JI(n,i)||QI(i)||e?.materials?.cycleColors===!0&&Array.isArray(e?.materials?.fillColors)&&e.materials.fillColors.length>1?i:[]}return i}function F2(n,e,t,i,r){let s=e.edgeSettings,o=e.baseTheme,a=e.displayMode,l=e.edgeRendering?.mode==="screen-space"?I_(e,{THREE:n,geometry:i,edgeSettings:s,baseTheme:o,partId:t.partId,displayMode:a,thickness:a2(s,o),wireframeEdgeColor:e.edgeRendering?.wireframeEdgeColor||""},e.screenSpaceLineMaterials):l2(n,i,o,s,t.partId,a),{object:u,material:h}=u2(l);u&&(u.userData.partId=t.partId,t.edges=u,t.edgeMaterial=h,t.baseEdgeColor=h?.color?.isColor?h.color.clone():new n.Color(s?.color||o?.edge||kt.edge),t.baseEdgeOpacity=Number.isFinite(Number(h?.opacity))?Number(h.opacity):1,e.edgesGroup.add(u))}function B2(n,e,t,i){let r=e.theme,s=e.materialSettings,o=e.displayMode,a=e.baseTheme,c=e.edgeSettings,l=t.bounds||cm(t.vertices||[]),{radius:u}=Ku(n,l,e.scale),h=p2(c,o,i),f=dS(t,r,i),d=n2(f),m=f.length===0,y=[],g=({part:p=null,geometryEntry:_,fillIndex:x=0,baseTransform:b=null})=>{let T=p?String(p?.id||p?.occurrenceId||`part:${y.length}`):Co,A=di(o),M=s.overrideSourceColors===!0||A,C=!!_.geometry.getAttribute("color"),S=!A&&!Eo(o)&&c.enabled&&kI(_.geometry),v=KI(n,p,t),L=ZI(p),U=C||!!v,G=!M&&C,P=uS(n,{hasVertexColors:G,sourceColor:M?null:v,materialSettings:s,fallbackColor:s.defaultColor||a?.surface||kt.surface,fillIndex:x,forceFill:M||!U}),D=A?jI(n,s,x):qx(o)?$I(n,{color:P,useVertexColors:G,opacity:Iu(o,s.opacity)}):qI(n,a,{color:P,useVertexColors:G,edgeSettings:S?c:null});c.enabled&&!A&&!S&&(D.polygonOffset=!0,D.polygonOffsetFactor=1,D.polygonOffsetUnits=1);let z=new n.Mesh(_.geometry,D);z.castShadow=!0,z.receiveShadow=!1,z.userData.partId=T;let q=p?i.callbacks?.faceIdsForPart?.(p):i.callbacks?.faceIdsForMesh?.(t);q&&(z.userData.faceIds=q),e.modelGroup.add(z);let Y={partId:T,sourcePart:p||null,mesh:z,edges:null,silhouette:null,material:D,edgeMaterial:null,baseColor:P,sourceColor:v,sourceOpacity:L,baseTransform:b,partCenter:m2(n,p?.bounds||l),partBounds:p?.bounds||p?.sourceBounds||l,effectMatrix:null,effectStyle:null,effectVisible:null,effectHighlighted:!1,fillIndex:x,hasSourceColor:U,hasVertexColors:G,useVertexColors:G,rawColors:_.rawColors,geometry:_.geometry,baseOpacity:Number.isFinite(Number(D.opacity))?Number(D.opacity):1,baseEmissiveColor:P?P.clone():null,baseEmissiveIntensity:0,baseEdgeColor:null,baseEdgeOpacity:1};if(h){let W=d2(n,_.geometry,c,u);W&&(Y.silhouette=W,e.modelGroup.add(W))}i.selection?.showEdges!==!1&&!S&&(c.enabled||A)&&F2(n,e,Y,o2(n,t,p,_.geometry,o,c),i),fS(n,Y,s,{baseTheme:a,displayMode:o}),ms(n,Y),y.push(Y)};if(m){let p=r2(n,t,i.recomputeNormals===!0);p&&g({geometryEntry:p,fillIndex:0})}else for(let p of f){let _=i2(n,t,p,i.recomputeNormals===!0);_&&g({part:p,geometryEntry:_,fillIndex:d.get(p)??y.length,baseTransform:z_(t,p,i.renderPartsIndividually===!0)})}return y}function tS(n,e,t){let i=qa(e?.edges);return JSON.stringify({meshData:n?"mesh":"",displayMode:ti(t.displayMode),parts:zI(dS(n,e,t)),recomputeNormals:t.recomputeNormals===!0,edgeSettings:i,silhouette:t.silhouette!==!1&&i.silhouette===!0&&(i.enabled!==!1||t.silhouette===!0),edgeRendering:t.edgeRendering?.mode||"basic",wireframeEdgeColor:t.edgeRendering?.wireframeEdgeColor||""})}function nS(n={}){let e=ti(n.displayMode),t=n.theme||n.themeSettings||n.settings||void 0,i=br(t),r=qa(t?.edges),s=n.applyDisplayModeEdgePolicy!==!1,o={...i,edges:s?{...r,enabled:Xx(e)&&(ja(e)||r.enabled===!0),depthTest:Eo(e)?!1:r.depthTest}:r},a=iS(n.scale??n.sceneScale??n.sceneScaleMode),c=n.callbacks&&typeof n.callbacks=="object"?n.callbacks:{},l=n.baseTheme&&typeof n.baseTheme=="object"?n.baseTheme:kt;return{...n,theme:o,displayMode:e,scale:a,callbacks:c,baseTheme:l,selection:J_(n.selection),filterSelection:n.filterSelection===!1?{}:J_(n.filterSelection??n.selection),clip:Xa(n.clip),stepParameters:n.stepParameters||null,parameterSetup:n.parameterSetup!==!1,materialSettings:U2(o,n),edgeRendering:h2(n.edgeRendering)}}function am(n,e){n.theme=e.theme,n.displayMode=e.displayMode,n.scale=e.scale,n.baseTheme=e.baseTheme,n.edgeSettings={...qa(e.theme?.edges),depthTest:Eo(e.displayMode)?!1:void 0},n.materialSettings=e.materialSettings,f2(n,e.edgeRendering)}function z2(n){return n?.meshData||n}function pS(n,e,t={}){if(!n)throw new Error("buildModel requires THREE");let i=z2(e),r=nS(t),s=D2(i,r.filterSelection),o=new n.Group,a=new n.Group,c=new n.Group;o.name="CadSceneRoot",a.name="CadSceneModel",c.name="CadSceneEdges",o.add(a),o.add(c);let l=s?.bounds||cm(s?.vertices||[]),u={THREE:n,root:o,modelGroup:a,edgesGroup:c,displayRecords:[],records:[],baseBounds:l,bounds:l,modelBounds:l,modelRadius:Ku(n,l,r.scale).radius,cleanups:[],activeClipPlane:null,activeClipPlanes:[],screenSpaceLineMaterials:new Set,syncScreenSpaceLineMaterials(x,b){ku(u.screenSpaceLineMaterials,x,b)},registerScreenSpaceLineMaterial(x){x?.resolution?.set&&u.screenSpaceLineMaterials.add(x)},unregisterScreenSpaceLineMaterial(x){u.screenSpaceLineMaterials.delete(x)},requestRender:()=>{}};am(u,r);let h=!1,f=r,d="",m=null,y=!1,g=(x=f)=>{rm(a),rm(c),am(u,x),u.baseBounds=s?.bounds||cm(s?.vertices||[]),u.displayRecords=B2(n,u,s,x),u.records=u.displayRecords,u.bounds=u.baseBounds,u.modelBounds=u.baseBounds,u.modelRadius=Ku(n,u.baseBounds,u.scale).radius,d=tS(s,u.theme,x)},p=(x=f)=>{am(u,x);for(let M of u.displayRecords)fS(n,M,u.materialSettings,{baseTheme:u.baseTheme,displayMode:u.displayMode});let b=x.parameterSetup!==!1,T=x.stepParameters||null;(m!==T||y!==b)&&(y&&Z_(u,m,x.callbacks),m=T,y=b,y&&C2(n,u,m,s,x.callbacks));let A=R2(n,u,m,s,x.callbacks);u.bounds=A||u.baseBounds,u.modelBounds=u.bounds,u.modelRadius=Ku(n,u.bounds,u.scale).radius,M2(n,u.displayRecords,{baseTheme:u.baseTheme,edgeSettings:u.edgeSettings,...x.selection,showEdges:x.selection?.showEdges!==!1}),P2(u,x.clip,u.bounds,x.modelOffset||a.position)};g(f),p(f);let _={source:e,meshData:s,root:o,modelGroup:a,edgesGroup:c,get displayRecords(){return u.displayRecords},get records(){return u.displayRecords},get bounds(){return u.bounds},get radius(){return u.modelRadius},get runtime(){return u},update(x={}){if(h)return _;let b={...f,...x,selection:{...f.selection||{},...x.selection||{}},callbacks:{...f.callbacks||{},...x.callbacks||{}}};return Object.prototype.hasOwnProperty.call(x,"theme")&&!Object.prototype.hasOwnProperty.call(x,"materialSettings")&&delete b.materialSettings,f=nS(b),tS(s,f.theme,f)!==d&&g(f),p(f),_},dispose(){h||(h=!0,y&&Z_(u,m,f.callbacks),rm(o))}};return _}ei();ei();ei();var mS=new xt,Qu=new w,qi=class extends xo{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";let e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new ye(e,3)),this.setAttribute("uv",new ye(t,2))}applyMatrix4(e){let t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let i=new gr(t,6,1);return this.setAttribute("instanceStart",new Yt(i,3,0)),this.setAttribute("instanceEnd",new Yt(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let i=new gr(t,6,1);return this.setAttribute("instanceColorStart",new Yt(i,3,0)),this.setAttribute("instanceColorEnd",new Yt(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new po(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),mS.setFromBufferAttribute(t),this.boundingBox.union(mS))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _t),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let i=this.boundingSphere.center;this.boundingBox.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Qu.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Qu)),Qu.fromBufferAttribute(t,s),r=Math.max(r,i.distanceToSquared(Qu));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}};ei();se.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Z(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};rn.line={uniforms:Wa.merge([se.common,se.fog,se.line]),vertexShader:`
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
uniform float linewidth;
uniform vec2 resolution;
attribute vec3 instanceStart;
attribute vec3 instanceEnd;
attribute vec3 instanceColorStart;
attribute vec3 instanceColorEnd;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#ifdef USE_DASH
uniform float dashScale;
attribute float instanceDistanceStart;
attribute float instanceDistanceEnd;
varying float vLineDistance;
#endif
void trimSegment( const in vec4 start, inout vec4 end ) {
// trim end segment so it terminates between the camera plane and the near plane
// conservative estimate of the near plane
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
float nearEstimate = - 0.5 * b / a;
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
end.xyz = mix( start.xyz, end.xyz, alpha );
}
void main() {
#ifdef USE_COLOR
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
#endif
#ifdef USE_DASH
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
vUv = uv;
#endif
float aspect = resolution.x / resolution.y;
// camera space
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
#ifdef WORLD_UNITS
worldStart = start.xyz;
worldEnd = end.xyz;
#else
vUv = uv;
#endif
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
// perhaps there is a more elegant solution -- WestLangley
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
if ( perspective ) {
if ( start.z < 0.0 && end.z >= 0.0 ) {
trimSegment( start, end );
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
trimSegment( end, start );
}
}
// clip space
vec4 clipStart = projectionMatrix * start;
vec4 clipEnd = projectionMatrix * end;
// ndc space
vec3 ndcStart = clipStart.xyz / clipStart.w;
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
// direction
vec2 dir = ndcEnd.xy - ndcStart.xy;
// account for clip-space aspect ratio
dir.x *= aspect;
dir = normalize( dir );
#ifdef WORLD_UNITS
vec3 worldDir = normalize( end.xyz - start.xyz );
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
vec3 worldFwd = cross( worldDir, worldUp );
worldPos = position.y < 0.5 ? start: end;
// height offset
float hw = linewidth * 0.5;
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
// don't extend the line if we're rendering dashes because we
// won't be rendering the endcaps
#ifndef USE_DASH
// cap extension
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
// add width to the box
worldPos.xyz += worldFwd * hw;
// endcaps
if ( position.y > 1.0 || position.y < 0.0 ) {
worldPos.xyz -= worldFwd * 2.0 * hw;
}
#endif
// project the worldpos
vec4 clip = projectionMatrix * worldPos;
// shift the depth of the projected points so the line
// segments overlap neatly
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
clip.z = clipPose.z * clip.w;
#else
vec2 offset = vec2( dir.y, - dir.x );
// undo aspect ratio adjustment
dir.x /= aspect;
offset.x /= aspect;
// sign flip
if ( position.x < 0.0 ) offset *= - 1.0;
// endcaps
if ( position.y < 0.0 ) {
offset += - dir;
} else if ( position.y > 1.0 ) {
offset += dir;
}
// adjust for linewidth
offset *= linewidth;
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
offset /= resolution.y;
// select end
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
// back to clip space
offset *= clip.w;
clip.xy += offset;
#endif
gl_Position = clip;
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`,fragmentShader:`
uniform vec3 diffuse;
uniform float opacity;
uniform float linewidth;
#ifdef USE_DASH
uniform float dashOffset;
uniform float dashSize;
uniform float gapSize;
#endif
varying float vLineDistance;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
float mua;
float mub;
vec3 p13 = p1 - p3;
vec3 p43 = p4 - p3;
vec3 p21 = p2 - p1;
float d1343 = dot( p13, p43 );
float d4321 = dot( p43, p21 );
float d1321 = dot( p13, p21 );
float d4343 = dot( p43, p43 );
float d2121 = dot( p21, p21 );
float denom = d2121 * d4343 - d4321 * d4321;
float numer = d1343 * d4321 - d1321 * d4343;
mua = numer / denom;
mua = clamp( mua, 0.0, 1.0 );
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
mub = clamp( mub, 0.0, 1.0 );
return vec2( mua, mub );
}
void main() {
#include <clipping_planes_fragment>
#ifdef USE_DASH
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
#endif
float alpha = opacity;
#ifdef WORLD_UNITS
// Find the closest points on the view ray and the line segment
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
vec3 lineDir = worldEnd - worldStart;
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
vec3 p1 = worldStart + lineDir * params.x;
vec3 p2 = rayEnd * params.y;
vec3 delta = p1 - p2;
float len = length( delta );
float norm = len / linewidth;
#ifndef USE_DASH
#ifdef USE_ALPHA_TO_COVERAGE
float dnorm = fwidth( norm );
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
#else
if ( norm > 0.5 ) {
discard;
}
#endif
#endif
#else
#ifdef USE_ALPHA_TO_COVERAGE
// artifacts appear on some hardware if a derivative is taken within a conditional
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
float dlen = fwidth( len2 );
if ( abs( vUv.y ) > 1.0 ) {
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
}
#else
if ( abs( vUv.y ) > 1.0 ) {
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
if ( len2 > 1.0 ) discard;
}
#endif
#endif
vec4 diffuseColor = vec4( diffuse, alpha );
#include <logdepthbuf_fragment>
#include <color_fragment>
gl_FragColor = vec4( diffuseColor.rgb, alpha );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
`};var ji=class extends yn{constructor(e){super({type:"LineMaterial",uniforms:Wa.clone(rn.line.uniforms),vertexShader:rn.line.vertexShader,fragmentShader:rn.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}};var gS=new w,yS=new w,Kt=new tt,Zt=new tt,yi=new tt,hm=new w,fm=new we,Jt=new Fa,xS=new w,eh=new xt,th=new _t,xi=new tt,_i,ys;function _S(n,e,t){return xi.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),xi.multiplyScalar(1/xi.w),xi.x=ys/t.width,xi.y=ys/t.height,xi.applyMatrix4(n.projectionMatrixInverse),xi.multiplyScalar(1/xi.w),Math.abs(Math.max(xi.x,xi.y))}function V2(n,e){let t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,s=i.attributes.instanceEnd,o=Math.min(i.instanceCount,r.count);for(let a=0,c=o;a<c;a++){Jt.start.fromBufferAttribute(r,a),Jt.end.fromBufferAttribute(s,a),Jt.applyMatrix4(t);let l=new w,u=new w;_i.distanceSqToSegment(Jt.start,Jt.end,u,l),u.distanceTo(l)<ys*.5&&e.push({point:u,pointOnLine:l,distance:_i.origin.distanceTo(u),object:n,face:null,faceIndex:a,uv:null,uv1:null})}}function k2(n,e,t){let i=e.projectionMatrix,s=n.material.resolution,o=n.matrixWorld,a=n.geometry,c=a.attributes.instanceStart,l=a.attributes.instanceEnd,u=Math.min(a.instanceCount,c.count),h=-e.near;_i.at(1,yi),yi.w=1,yi.applyMatrix4(e.matrixWorldInverse),yi.applyMatrix4(i),yi.multiplyScalar(1/yi.w),yi.x*=s.x/2,yi.y*=s.y/2,yi.z=0,hm.copy(yi),fm.multiplyMatrices(e.matrixWorldInverse,o);for(let f=0,d=u;f<d;f++){if(Kt.fromBufferAttribute(c,f),Zt.fromBufferAttribute(l,f),Kt.w=1,Zt.w=1,Kt.applyMatrix4(fm),Zt.applyMatrix4(fm),Kt.z>h&&Zt.z>h)continue;if(Kt.z>h){let x=Kt.z-Zt.z,b=(Kt.z-h)/x;Kt.lerp(Zt,b)}else if(Zt.z>h){let x=Zt.z-Kt.z,b=(Zt.z-h)/x;Zt.lerp(Kt,b)}Kt.applyMatrix4(i),Zt.applyMatrix4(i),Kt.multiplyScalar(1/Kt.w),Zt.multiplyScalar(1/Zt.w),Kt.x*=s.x/2,Kt.y*=s.y/2,Zt.x*=s.x/2,Zt.y*=s.y/2,Jt.start.copy(Kt),Jt.start.z=0,Jt.end.copy(Zt),Jt.end.z=0;let y=Jt.closestPointToPointParameter(hm,!0);Jt.at(y,xS);let g=Ha.lerp(Kt.z,Zt.z,y),p=g>=-1&&g<=1,_=hm.distanceTo(xS)<ys*.5;if(p&&_){Jt.start.fromBufferAttribute(c,f),Jt.end.fromBufferAttribute(l,f),Jt.start.applyMatrix4(o),Jt.end.applyMatrix4(o);let x=new w,b=new w;_i.distanceSqToSegment(Jt.start,Jt.end,b,x),t.push({point:b,pointOnLine:x,distance:_i.origin.distanceTo(b),object:n,face:null,faceIndex:f,uv:null,uv1:null})}}}var xs=class extends ft{constructor(e=new qi,t=new ji({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let o=0,a=0,c=t.count;o<c;o++,a+=2)gS.fromBufferAttribute(t,o),yS.fromBufferAttribute(i,o),r[a]=a===0?0:r[a-1],r[a+1]=r[a]+gS.distanceTo(yS);let s=new gr(r,2,1);return e.setAttribute("instanceDistanceStart",new Yt(s,1,0)),e.setAttribute("instanceDistanceEnd",new Yt(s,1,1)),this}raycast(e,t){let i=this.material.worldUnits,r=e.camera;r===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');let s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;_i=e.ray;let o=this.matrixWorld,a=this.geometry,c=this.material;ys=c.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),th.copy(a.boundingSphere).applyMatrix4(o);let l;if(i)l=ys*.5;else{let h=Math.max(r.near,th.distanceToPoint(_i.origin));l=_S(r,h,c.resolution)}if(th.radius+=l,_i.intersectsSphere(th)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),eh.copy(a.boundingBox).applyMatrix4(o);let u;if(i)u=ys*.5;else{let h=Math.max(r.near,eh.distanceToPoint(_i.origin));u=_S(r,h,c.resolution)}eh.expandByScalar(u),_i.intersectsBox(eh)!==!1&&(i?V2(this,t):k2(this,r,t))}};var _s=class extends qi{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){let t=e.length-3,i=new Float32Array(2*t);for(let r=0;r<t;r+=3)i[2*r]=e[r],i[2*r+1]=e[r+1],i[2*r+2]=e[r+2],i[2*r+3]=e[r+3],i[2*r+4]=e[r+4],i[2*r+5]=e[r+5];return super.setPositions(i),this}setColors(e){let t=e.length-3,i=new Float32Array(2*t);for(let r=0;r<t;r+=3)i[2*r]=e[r],i[2*r+1]=e[r+1],i[2*r+2]=e[r+2],i[2*r+3]=e[r+3],i[2*r+4]=e[r+4],i[2*r+5]=e[r+5];return super.setColors(i),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}};var sc=class extends xs{constructor(e=new _s,t=new ji({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}};function Ro(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function oc(n,e,t){let i=n?.tables?.[t],r=n?.[e];return!Array.isArray(i)||!Array.isArray(r)?[]:r.filter(Array.isArray).map(s=>Object.fromEntries(i.map((o,a)=>[o,s[a]])))}function SS(n,e,t,i){let r=n?.relations?.[t];if(Array.isArray(r)||ArrayBuffer.isView(r))return r;let s=n?.relations?.[i];return typeof s=="string"&&e?.[s]?e[s]:[]}function G2(n,e,t,i){let r=n?.[t]?.[i];return typeof r=="string"&&e?.[r]?e[r]:new Uint32Array(0)}function lc(n,e){if(!n||!e.startsWith(`${n}.`))return e;let t=e.slice(n.length+1);return t.startsWith("s")||t.startsWith("f")||t.startsWith("e")?t:e}function H2(n){return n==="occurrence"?"Occurrence":n==="shape"?"Shape":n==="face"?"Face":"Edge"}function Si(n,e){if(!Array.isArray(e)||e.length<3)return e;if(!Array.isArray(n)||n.length<16)return[Number(e[0]),Number(e[1]),Number(e[2])];let t=Number(e[0]),i=Number(e[1]),r=Number(e[2]);return[n[0]*t+n[1]*i+n[2]*r+n[3],n[4]*t+n[5]*i+n[6]*r+n[7],n[8]*t+n[9]*i+n[10]*r+n[11]]}function bS(n){let e=Number(n?.[0]||0),t=Number(n?.[1]||0),i=Number(n?.[2]||0),r=Math.hypot(e,t,i);return r<=1e-9?null:[e/r,t/r,i/r]}function uc(n,e){return!Array.isArray(e)||e.length<3||!Array.isArray(n)||n.length<16?bS(e||[]):bS([n[0]*e[0]+n[1]*e[1]+n[2]*e[2],n[4]*e[0]+n[5]*e[1]+n[6]*e[2],n[8]*e[0]+n[9]*e[1]+n[10]*e[2]])}function vr(n,e){if(!Ro(e))return e;let t=Array.isArray(e.min)?e.min:[0,0,0],i=Array.isArray(e.max)?e.max:[0,0,0],r=[[t[0],t[1],t[2]],[t[0],t[1],i[2]],[t[0],i[1],t[2]],[t[0],i[1],i[2]],[i[0],t[1],t[2]],[i[0],t[1],i[2]],[i[0],i[1],t[2]],[i[0],i[1],i[2]]].map(c=>Si(n,c)),s=r.map(c=>c[0]),o=r.map(c=>c[1]),a=r.map(c=>c[2]);return{min:[Math.min(...s),Math.min(...o),Math.min(...a)],max:[Math.max(...s),Math.max(...o),Math.max(...a)]}}function gm(n,e){if(!Ro(e))return e;let t=new Set(["origin","center","location"]),i=new Set(["axis","direction","normal"]);return Object.fromEntries(Object.entries(e).map(([r,s])=>t.has(r)&&Array.isArray(s)&&s.length===3?[r,Si(n,s)]:i.has(r)&&Array.isArray(s)&&s.length===3?[r,uc(n,s)]:[r,s]))}function dm(n,e){return Array.isArray(e)?e.map(t=>Array.isArray(t)&&t.length>=3?Si(n,t):t):e}function W2(n,e){return Array.isArray(e)?e.map(t=>Ro(t)&&Array.isArray(t.points)?{...t,points:dm(n,t.points)}:t):e}function X2(n,e){if(!Ro(e))return e;let t=new Set(["origin","center","location"]),i=new Set(["axis","direction","normal","xDir","yDir"]);return Object.fromEntries(Object.entries(e).map(([r,s])=>t.has(r)&&Array.isArray(s)&&s.length===3?[r,Si(n,s)]:i.has(r)&&Array.isArray(s)&&s.length===3?[r,uc(n,s)]:[r,s]))}function pm(n,e){if(!(n instanceof Float32Array)||!Array.isArray(e)||e.length<16)return n;let t=new Float32Array(n.length);for(let i=0;i<n.length;i+=3){let r=Si(e,[n[i],n[i+1],n[i+2]]);t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2]}return t}function Y2(n,e){return!Ro(n)||!Array.isArray(e)||e.length<16?n:{...n,bbox:n.bbox?vr(e,n.bbox):n.bbox,center:Array.isArray(n.center)?Si(e,n.center):n.center,normal:Array.isArray(n.normal)?uc(e,n.normal):n.normal,params:n.params?gm(e,n.params):n.params,points:dm(e,n.points),loops:Array.isArray(n.loops)?n.loops.map(t=>dm(e,t)):n.loops,loopsMeta:W2(e,n.loopsMeta),surface:X2(e,n.surface),centroid:Array.isArray(n.centroid)?Si(e,n.centroid):n.centroid,transform:e}}function q2(n,e,t){return t?`topology|${t}|${e}|${n}`:n}function j2(n,e){if(n==="occurrence")return String(e.name||e.sourceName||e.id||"").trim();if(n==="shape"){let t=String(e.name||e.sourceName||"").trim(),i=`${e.kind||"shape"}${e.volume?` volume=${e.volume}`:e.area?` area=${e.area}`:""}`;return t?`${t} ${i}`:i}return n==="face"?`${e.surfaceType||"face"} area=${e.area??0}`:`${e.curveType||"edge"} length=${e.length??0}`}function $2(n,e){let t=String(n||"").trim(),i=String(e||"").trim();return!i||t===i||t.startsWith(`${i}.`)}function ym(n,e){let t=String(n||"").trim();if(!t||!e||typeof e!="object"||!$2(t,e.sourceOccurrenceId))return"";let i=String(e.sourceRootOccurrenceId||"").trim(),r=String(e.targetRootOccurrenceId||"").trim();if(!i||!r)return"";if(t===i)return r;let s=`${i}.`;return t.startsWith(s)?`${r}.${t.slice(s.length)}`:""}function xm(n,e,t,i,r="",s=null){if(!e||!Number.isFinite(Number(t)))return"";if(s&&typeof s=="object"){let a=n==="occurrence"?String(e?.id||"").trim():String(e?.occurrenceId||"").trim(),c=ym(a,s);return c?n==="occurrence"?c:`${c}.${n==="shape"?"s":n==="face"?"f":"e"}${t+1}`:""}let o=String(r||"").trim();return o?n==="occurrence"?o:`${o}.${n==="shape"?"s":n==="face"?"f":"e"}${t+1}`:lc(i,String(e?.id||"").trim())}function K2(n,e,t="",i=null){let r=String(n||"").trim();if(!r)return"";let s=r.match(/^(.*)\.([sfe]\d+)$/i);if(!s)return lc(e,r);let o=String(s[1]||"").trim(),a=String(s[2]||"").trim();if(!o||!a)return lc(e,r);if(i&&typeof i=="object"){let l=ym(o,i);return l?`${l}.${a}`:""}let c=String(t||"").trim();return c?`${c}.${a}`:lc(e,r)}function Z2(n,e,t,i="",r=null){if(n==="occurrence")return"";let s=String(e?.occurrenceId||"").trim();return s?r&&typeof r=="object"?ym(s,r):String(i||"").trim()||lc(t,s):""}function J2(n,e,t,i,r,s,o,a,c,l){let u=Number(n?.[s]||0),h=Number(n?.[o]||0),f=[],d=Math.min(e?.length||0,u+h);for(let m=u;m<d;m+=1){let y=e[m],g=Number(y),p=t[g],_=xm(a,p,g,i,c,l)||String(p?.[r]||"").trim();_&&f.push(_)}return f}function nh({selectorType:n,row:e,rowIndex:t,singleOccurrenceId:i,copyCadPath:r,partId:s,selectorTransform:o,relationRows:a,targetRows:c,targetKey:l,startKey:u,countKey:h,remapOccurrenceId:f="",remapOccurrencePrefix:d=null,targetSelectorType:m=""}){let y=xm(n,e,t,i,f,d),g=y,p=q2(g,n,s),_=j2(n,e),x=ic({cadPath:r,selector:g}),b=a&&c?J2(e,a,c,i,l,u,h,m,f,d):[];return{id:p,selectorType:n,normalizedSelector:y,displaySelector:g,label:`${H2(n)} ${g}`,summary:_,shortSummary:_,copyText:x,partId:s,occurrenceId:Z2(n,e,i,f,d),shapeId:K2(e.shapeId,i,f,d),rowIndex:t,pickData:{selectorType:n,rowIndex:t,name:e.name||null,sourceName:e.sourceName||null,kind:e.kind||null,bbox:e.bbox||null,surfaceType:e.surfaceType||null,center:e.center||null,normal:e.normal||null,params:e.params||null,triangleStart:e.triangleStart??0,triangleCount:e.triangleCount??0,segmentStart:e.segmentStart??0,segmentCount:e.segmentCount??0,adjacentSelectors:b,transform:o||null}}}function Q2(n){return[...new Set(n.map(e=>String(e.occurrenceId||"").trim()).filter(Boolean))].sort()}function ac(n,e){return!Array.isArray(e)||e.length<16?n:n.map(t=>({...t,transform:Array.isArray(t.transform)?t.transform:e,bbox:t.bbox?vr(e,t.bbox):t.bbox,center:Array.isArray(t.center)?Si(e,t.center):t.center,normal:Array.isArray(t.normal)?uc(e,t.normal):t.normal,params:t.params?gm(e,t.params):t.params}))}function eP(n,e){return!n||!Array.isArray(e)||e.length<16?n:{...n,bbox:n.bbox?vr(e,n.bbox):n.bbox,center:Array.isArray(n.center)?Si(e,n.center):n.center,normal:Array.isArray(n.normal)?uc(e,n.normal):n.normal,params:n.params?gm(e,n.params):n.params}}function MS(n,e){let t=Array.isArray(e?.[0])?e:[e],i=t.map(()=>0);return n.map(r=>{let s={...r};return t.forEach(([o,a],c)=>{let l=Math.max(0,Number(r?.[a]||0));s[o]=i[c],s[a]=l,i[c]+=l}),s})}function vS(n,{copyCadPath:e="",partId:t="",transform:i=null,remapOccurrenceId:r="",remapOccurrencePrefix:s=null}={}){let o=n?.manifest||{},a=n?.buffers||{},c=SS(o,a,"faceEdgeRows","faceEdgeRowsView"),l=SS(o,a,"edgeFaceRows","edgeFaceRowsView"),u=ac(oc(o,"occurrences","occurrenceColumns"),i),h=ac(oc(o,"shapes","shapeColumns"),i),f=MS(ac(oc(o,"faces","faceColumns"),i),[["edgeStart","edgeCount"]]),d=MS(ac(oc(o,"edges","edgeColumns"),i),[["faceStart","faceCount"]]),m=Q2(h),y=m.length===1?m[0]:"",g={facePositions:pm(a.facePositions,i),faceIndices:a.faceIndices||new Uint32Array(0),faceIds:a.faceIds||new Uint32Array(0),faceRuns:G2(o,a,"faceProxy","runsView"),faceRunColumns:Array.isArray(o?.faceProxy?.runColumns)?o.faceProxy.runColumns:[],edgePositions:pm(a.edgePositions,i),edgeIndices:a.edgeIndices||new Uint32Array(0),edgeIds:a.edgeIds||new Uint32Array(0),faceEdgeRows:c,edgeFaceRows:l},p=[];p.push(...u.map((S,v)=>nh({selectorType:"occurrence",row:S,rowIndex:v,singleOccurrenceId:y,copyCadPath:e,partId:t,selectorTransform:i,remapOccurrenceId:r,remapOccurrencePrefix:s}))),p.push(...h.map((S,v)=>nh({selectorType:"shape",row:S,rowIndex:v,singleOccurrenceId:y,copyCadPath:e,partId:t,selectorTransform:i,remapOccurrenceId:r,remapOccurrencePrefix:s}))),p.push(...f.map((S,v)=>nh({selectorType:"face",row:S,rowIndex:v,singleOccurrenceId:y,copyCadPath:e,partId:t,selectorTransform:i,relationRows:c,targetRows:d,targetKey:"id",startKey:"edgeStart",countKey:"edgeCount",remapOccurrenceId:r,remapOccurrencePrefix:s,targetSelectorType:"edge"}))),p.push(...d.map((S,v)=>nh({selectorType:"edge",row:S,rowIndex:v,singleOccurrenceId:y,copyCadPath:e,partId:t,selectorTransform:i,relationRows:l,targetRows:f,targetKey:"id",startKey:"faceStart",countKey:"faceCount",remapOccurrenceId:r,remapOccurrencePrefix:s,targetSelectorType:"face"})));let _=p.filter(S=>String(S?.normalizedSelector||"").trim()),x=new Map(_.map(S=>[S.id,S])),b=new Map(_.map(S=>[S.normalizedSelector,S])),T=new Map(_.map(S=>[S.displaySelector,S])),A=new Map(_.filter(S=>S.selectorType==="face").map(S=>[S.rowIndex,S])),M=new Map(_.filter(S=>S.selectorType==="edge").map(S=>[S.rowIndex,S])),C=new Map(u.map((S,v)=>[v,xm("occurrence",S,v,y,r,s)||String(S?.id||"").trim()]));return{schemaVersion:Number(o.schemaVersion||1),surfaceEdgeRendering:!!o?.capabilities?.surfaceEdgeRendering,capabilities:o.capabilities||null,cadPath:e||String(o.cadRef||"").trim(),stepHash:String(o.stepHash||""),bbox:i?vr(i,o.bbox||{}):o.bbox,occurrences:u,shapes:h,faces:f,edges:d,vertices:[],references:_,referenceMap:x,referenceByNormalizedSelector:b,referenceByDisplaySelector:T,faceReferenceByRowIndex:A,edgeReferenceByRowIndex:M,vertexReferenceByRowIndex:new Map,occurrenceIdByRowIndex:C,faceReferenceMap:new Map(_.filter(S=>S.selectorType==="face").map(S=>[S.id,S])),edgeReferenceMap:new Map(_.filter(S=>S.selectorType==="edge").map(S=>[S.id,S])),vertexReferenceMap:new Map,singleOccurrenceId:y,proxy:g}}function AS(n,{transform:e=null}={}){let t=n?.manifest||{};if(String(t.profile||"")==="surface-edges"){let h=t.edgeRendering&&typeof t.edgeRendering=="object"?t.edgeRendering:{};return{schemaVersion:Number(t.schemaVersion||1),surfaceEdgeRendering:!0,edgeRendering:{visibilityClasses:Array.isArray(h.visibilityClasses)?h.visibilityClasses.map(f=>String(f||"").trim()).filter(Boolean):[],generatedVisibilityClasses:Array.isArray(h.generatedVisibilityClasses)?h.generatedVisibilityClasses.map(f=>String(f||"").trim()).filter(Boolean):[],visibilityClassCounts:h.visibilityClassCounts||{},generatedVisibilityClassCounts:h.generatedVisibilityClassCounts||{}},stepHash:String(t.stepHash||""),bbox:e?vr(e,t.bbox||{}):t.bbox,edges:[],proxy:{edgePositions:new Float32Array(0),edgeIndices:new Uint32Array(0),edgeIds:new Uint32Array(0)}}}let i=n?.buffers||{},r=t?.edgeProxy||{},s=String(r.positionsView||"edgePositions"),o=String(r.indicesView||"edgeIndices"),a=String(r.edgeIdsView||"edgeIds"),c=i[s]instanceof Float32Array?i[s]:new Float32Array(0),l=i[o]instanceof Uint32Array?i[o]:new Uint32Array(0),u=i[a]instanceof Uint32Array?i[a]:new Uint32Array(0);return{schemaVersion:Number(t.schemaVersion||1),stepHash:String(t.stepHash||""),bbox:e?vr(e,t.bbox||{}):t.bbox,edges:ac(oc(t,"edges","edgeColumns"),e),proxy:{edgePositions:pm(c,e),edgeIndices:l,edgeIds:u}}}function ES(n){return(n instanceof Map?[...n.entries()]:Ro(n)?Object.entries(n):[]).map(([t,i])=>[String(t||"").trim(),Array.isArray(i)&&i.length>=16?i.slice(0,16).map(r=>Number(r)):null]).filter(([t,i])=>t&&i&&i.every(Number.isFinite))}function tP(n,e){let t=String(e||"").trim(),i=n.find(([s])=>s==="__model__"||s==="*"||s==="__all__")?.[1]||null,r=null;for(let[s,o]of n)s==="__model__"||s==="*"||s==="__all__"||t&&(t===s||t.startsWith(`${s}.`))&&(!r||s.length>r[0].length)&&(r=[s,o]);return r?.[1]||i}function nP(n,e){return e==="occurrence"?String(n?.id||"").trim():String(n?.occurrenceId||n?.partId||"").trim()}function cc(n,e,t){let i=[];return{rows:(Array.isArray(n)?n:[]).map(s=>{let o=tP(t,nP(s,e));return i.push(o),o?eP(s,o):s}),transforms:i}}function iP(n,e){return e?{...n,pickData:Y2(n.pickData,e)}:n}function mm({positions:n,indices:e,ids:t,rowTransforms:i,elementSize:r}){if(!(n instanceof Float32Array)||!(e instanceof Uint32Array)||!e.length||!(t instanceof Uint32Array)||!t.length)return{positions:n,indices:e,ids:t};let s=Math.floor(e.length/r),o=new Float32Array(s*r*3),a=new Uint32Array(s*r),c=new Uint32Array(s),l=0;for(let u=0;u<s;u+=1){let h=Number(t[u]),f=Number.isInteger(h)&&i[h]||null;c[u]=Number.isInteger(h)?h:0;for(let d=0;d<r;d+=1){let y=Number(e[u*r+d])*3,g=l*3,p=[n[y],n[y+1],n[y+2]],_=f?Si(f,p):p;o[g]=_[0],o[g+1]=_[1],o[g+2]=_[2],a[u*r+d]=l,l+=1}}return{positions:o,indices:a,ids:c}}function wS(n,e=null){let t=ES(e);if(!n||!t.length)return n||null;let i=cc(n.occurrences,"occurrence",t),r=cc(n.shapes,"shape",t),s=cc(n.faces,"face",t),o=cc(n.edges,"edge",t),a={occurrence:i.transforms,shape:r.transforms,face:s.transforms,edge:o.transforms,vertex:[]},c=(Array.isArray(n.references)?n.references:[]).map(p=>iP(p,a[p?.selectorType]?.[Number(p?.rowIndex)]||null)),l=new Map(c.map(p=>[p.id,p])),u=new Map(c.map(p=>[p.normalizedSelector,p])),h=new Map(c.map(p=>[p.displaySelector,p])),f=new Map(c.filter(p=>p.selectorType==="face").map(p=>[p.rowIndex,p])),d=new Map(c.filter(p=>p.selectorType==="edge").map(p=>[p.rowIndex,p])),m=n.proxy||{},y=mm({positions:m.facePositions,indices:m.faceIndices,ids:m.faceIds,rowTransforms:s.transforms,elementSize:3}),g=mm({positions:m.edgePositions,indices:m.edgeIndices,ids:m.edgeIds,rowTransforms:o.transforms,elementSize:2});return{...n,bbox:n.bbox?vr(t.find(([p])=>p==="__model__"||p==="*"||p==="__all__")?.[1],n.bbox):n.bbox,occurrences:i.rows,shapes:r.rows,faces:s.rows,edges:o.rows,references:c,referenceMap:l,referenceByNormalizedSelector:u,referenceByDisplaySelector:h,faceReferenceByRowIndex:f,edgeReferenceByRowIndex:d,faceReferenceMap:new Map(c.filter(p=>p.selectorType==="face").map(p=>[p.id,p])),edgeReferenceMap:new Map(c.filter(p=>p.selectorType==="edge").map(p=>[p.id,p])),proxy:{...m,facePositions:y.positions,faceIndices:y.indices,faceIds:y.ids,edgePositions:g.positions,edgeIndices:g.indices,edgeIds:g.ids}}}function TS(n,e=null){let t=ES(e);if(!n||!t.length)return n||null;let i=cc(n.edges,"edge",t),r=n.proxy||{},s=mm({positions:r.edgePositions,indices:r.edgeIndices,ids:r.edgeIds,rowTransforms:i.transforms,elementSize:2}),o=t.find(([a])=>a==="__model__"||a==="*"||a==="__all__")?.[1]||null;return{...n,bbox:o&&n.bbox?vr(o,n.bbox):n.bbox,edges:i.rows,proxy:{...r,edgePositions:s.positions,edgeIndices:s.indices,edgeIds:s.ids}}}var CS=new WeakMap,rP=new WeakMap,sP=new WeakMap,oP=32;function _m(n,e={}){for(let t of Array.isArray(n)?n:[]){let i=t?.material;i&&(i.polygonOffset=!1,i.polygonOffsetFactor=0,i.polygonOffsetUnits=0,i.needsUpdate=!0)}}function Sm(n){if(n){for(;n.children?.length;)Sm(n.children[0]);if(n.parent?.remove?.(n),typeof n.userData?.beforeDispose=="function"&&(n.userData.beforeDispose(n),delete n.userData.beforeDispose),n.userData?.disposeGeometry!==!1&&n.geometry?.dispose?.(),n.userData?.disposeMaterial!==!1){let e=Array.isArray(n.material)?n.material:[n.material];for(let t of e)t?.dispose?.()}}}function aP(n,e=1e-6){if(!n?.elements||n.elements.length!==16)return!1;let t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return n.elements.some((i,r)=>Math.abs(Number(i)-t[r])>e)}function cP(n){if(!n?.elements||n.elements.length!==16)return null;let e=n.elements;return[e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]]}function lP(n){let e=Number(n);return Number.isFinite(e)?String(e):"0"}function uP(n){return n?.size?[...n.entries()].map(([e,t])=>{let i=Array.isArray(t)||ArrayBuffer.isView(t)?Array.from(t,lP):[];return`${String(e||"").trim()}:${i.join(",")}`}).sort().join("|"):""}function RS(n,e,t,i){if(!e||!t?.size)return null;let r=uP(t);if(!r)return null;let s=n.get(e);if(s||(s=new Map,n.set(e,s)),s.has(r))return s.get(r);let o=i(e,t);return s.set(r,o),s.size>oP&&s.delete(s.keys().next().value),o}function hP(n){let e=new Map;for(let t of Array.isArray(n)?n:[]){let i=String(t?.partId||"").trim();if(!i||!t?.effectMatrix||!aP(t.effectMatrix))continue;let r=cP(t.effectMatrix);r&&e.set(i,r)}return e}function IS(n){return Array.isArray(n?.edges)&&n.edges.some(e=>String(e?.visibilityClass||"").trim())}function fP(n,e){let t=Array.isArray(n?.edges)?n.edges:[],i=Array.isArray(e?.edges)?e.edges:[],r=t.every((s,o)=>{let a=i[o]||{},c=Number(s?.segmentStart),l=Number(a?.segmentStart),u=Number(s?.segmentCount),h=Number(a?.segmentCount);return(!Number.isFinite(c)||!Number.isFinite(l)||c===l)&&(!Number.isFinite(u)||!Number.isFinite(h)||u===h)});return!!(t.length&&t.length===i.length&&r&&!IS(n)&&IS(e))}function dP(n){return!!(n?.surfaceEdgeRendering||Number(n?.schemaVersion||0)>=3)}function pP(n,e){if(!fP(n,e))return n||null;let t=CS.get(n);if(t?.selectorRuntime===e)return t.runtime;let i={...n,edges:n.edges.map((r,s)=>({...r,visibilityClass:e.edges[s]?.visibilityClass||"feature"}))};return CS.set(n,{selectorRuntime:e,runtime:i}),i}function bm({selectorRuntime:n=null,displayEdgeRuntime:e=null,displayRecords:t=null,transformDisplayEdges:i=!0}={}){let r=hP(t),s=pP(e,n),o=r.size&&n?RS(rP,n,r,wS):null,a=i&&r.size&&s?RS(sP,s,r,TS):null,c=o||n||null,l=a||s||null;return{selectorTransforms:r,transformCount:r.size,transformedSelectorRuntime:o,transformedDisplayEdgeRuntime:a,selectorRuntime:c,displayEdgeRuntime:l,topologyRuntime:l||c}}function PS({edgesVisible:n=!1,wireframeMode:e=!1,cadEdgeSource:t=!1,displayEdgeRuntime:i=null,selectorRuntime:r=null,edgeSettings:s=null}={}){return!!(n&&!e&&t&&!dP(i||r)&&y_(i||r,s))}function NS({transformDetected:n=!1,topologyDisplayEdgesVisible:e=!1,displayEdgeRuntime:t=null,displayRecords:i=[]}={}){return!!(n&&e&&t&&Array.isArray(i)&&i.length>1)}function Io(n){return(Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean)}function LS(n,e=[]){let t=String(n||"").trim();if(!t)return!1;for(let i of e)if(t===i||t.startsWith(`${i}.`))return!0;return!1}function Mm(n=[]){let e=[],t=new Set;for(let i of Array.isArray(n)?n:[]){let r=String(i?.partId||"").trim();!r||t.has(r)||(t.add(r),e.push(i))}return e}function mP(n=[]){return Mm(n).map(e=>String(e.partId||"").trim())}function gP(n={},e=[],t={},i=.035,{transformByRecord:r=!1,displayRecords:s=[]}={}){let o=a=>Number.isFinite(Number(a))?Number(a):null;return JSON.stringify({color:String(n?.color||""),opacity:o(n?.opacity),thickness:o(n?.thickness),includePartIds:Io(n?.includePartIds),excludePartIds:Io(n?.excludePartIds),visibilityClasses:Io(n?.visibilityClasses),classes:n?.classes&&typeof n.classes=="object"?Object.fromEntries(Object.entries(n.classes).map(([a,c])=>[a,{color:String(c?.color||""),opacity:o(c?.opacity),thickness:o(c?.thickness)}])):null,highlightColor:String(n?.highlightColor||""),highlightOpacity:o(n?.highlightOpacity),highlightRenderOrder:o(n?.highlightRenderOrder),focusedPartIds:Io(e),dimmedOpacity:i,baseEdge:String(t?.edge||""),baseEdgeOpacity:o(t?.edgeOpacity),baseEdgeThickness:o(t?.edgeThickness),transformByRecord:r===!0,recordPartIds:r===!0?mP(s):[]})}function OS(n,e,t){let i=n?.THREE;if(!i||!e)return!1;let r=tm(i,t)||new i.Matrix4;e.matrixAutoUpdate=!1;let s=e.matrix instanceof i.Matrix4?e.matrix:new i.Matrix4,o=!s.equals(r);o&&(s.copy(r),e.matrix=s,e.matrixWorldNeedsUpdate=!0);let a=t?.mesh?.visible!==!1&&t?.effectVisible!==!1;return e.visible!==a?(e.visible=a,!0):o}function yP(n,e,t=[]){if(!e?.children?.length)return!1;let i=new Map;for(let s of Mm(t))i.set(String(s.partId||"").trim(),s);let r=!1;for(let s of e.children){let o=String(s?.userData?.cadTopologyDisplayRecordPartId||"").trim(),a=i.get(o)||null;if(!a){s.visible!==!1&&(s.visible=!1,r=!0);continue}r=OS(n,s,a)||r}return r&&n.edgesGroup?.updateMatrixWorld?.(!0),r}function xP(n,e,{edgeSettings:t={},focusedPartIds:i=[],viewerTheme:r={},dimmedOpacity:s=.035,displayRecords:o=[]}={}){if(!n?.THREE||!e)return null;let a=Mm(o);if(!a.length)return null;let c=new n.THREE.Group,l=Io(i),u=Io(t?.highlightPartIds),h=Number.isFinite(Number(t?.opacity))?Number(t.opacity):null;for(let f of a){let d=String(f?.partId||"").trim();if(!d||u.length&&!LS(d,u))continue;let m=l.length&&!LS(d,l)?s:h,y=u.length?{...t,highlightPartIds:[d]}:{...t,includePartIds:[d],...m!==null?{opacity:m}:{}},g=Xp(n,e,y,r);g&&(g.userData={...g.userData||{},cadTopologyDisplayRecordPartId:d},OS(n,g,f),c.add(g))}return c.children.length?(c.name="TopologyDisplayEdges",c.userData.partId="__topology__",c.userData.disposeGeometry=!1,c.userData.disposeMaterial=!1,c):null}function DS(n,e,{visible:t=!1,edgeSettings:i={},focusedPartIds:r=[],viewerTheme:s={},dimmedOpacity:o=.035,transformByRecord:a=!1,displayRecords:c=[],syncClip:l=null}={}){if(!n?.THREE||!n?.edgesGroup)return!1;let u=t?e:null,h=u?gP(i,r,s,o,{transformByRecord:a,displayRecords:c}):"",f=n.topologyDisplayEdgeLine||null;if(f&&f.userData?.cadTopologyDisplayEdgeRuntime===u&&f.userData?.cadTopologyDisplayEdgeSettingsKey===h){let m=a?yP(n,f,c):!1;return m&&(_m(n.displayRecords,i),l?.(n),n.requestRender?.()),m}if(f&&(n.edgesGroup.remove(f),Sm(f),n.topologyDisplayEdgeLine=null),!u)return l?.(n),n.requestRender?.(),!0;let d=a?xP(n,u,{edgeSettings:i,focusedPartIds:r,viewerTheme:s,dimmedOpacity:o,displayRecords:c}):Xp(n,u,{...i,focusedPartIds:r,dimmedOpacity:o},s);return d?(d.userData={...d.userData||{},cadTopologyDisplayEdgeRuntime:u,cadTopologyDisplayEdgeSettingsKey:h},n.topologyDisplayEdgeLine=d,n.edgesGroup.add(d),n.edgesGroup.updateMatrixWorld?.(!0),_m(n.displayRecords,i),l?.(n),n.requestRender?.(),!0):(l?.(n),n.requestRender?.(),!0)}var jt=1e-6,_P=Math.PI*(3-Math.sqrt(5)),US=Object.freeze({x:0,y:1,z:2});function FS(n,e,t){return Math.min(Math.max(n,e),t)}function et(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function BS(n,e,t=null){let i=Array.isArray(e?.min)||ArrayBuffer.isView(e?.min)?e.min:null,r=Array.isArray(e?.max)||ArrayBuffer.isView(e?.max)?e.max:null;return!i||!r?t?.clone?.()||new n.Vector3:new n.Vector3((et(i[0])+et(r[0]))/2,(et(i[1])+et(r[1]))/2,(et(i[2])+et(r[2]))/2)}function ih(n,e){let t=Array.isArray(e?.min)||ArrayBuffer.isView(e?.min)?e.min:null,i=Array.isArray(e?.max)||ArrayBuffer.isView(e?.max)?e.max:null;return!t||!i?0:new n.Vector3(Math.max(et(i[0])-et(t[0]),0),Math.max(et(i[1])-et(t[1]),0),Math.max(et(i[2])-et(t[2]),0)).length()/2}function Ar(n,e){let t=Array.isArray(n?.min)||ArrayBuffer.isView(n?.min)?n.min:null,i=Array.isArray(n?.max)||ArrayBuffer.isView(n?.max)?n.max:null;return!t||!i?0:Math.max(et(i[e])-et(t[e]),0)}function SP(n){return Math.max(Ar(n,0),Ar(n,1),Ar(n,2))}function zS(n,e=[0,0,0],t=1){return!n||!Array.isArray(n.min)||!Array.isArray(n.max)?null:{min:n.min.map((i,r)=>et(i)+et(e[r])*t),max:n.max.map((i,r)=>et(i)+et(e[r])*t)}}function rh(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0],i=0;for(let r of Array.isArray(n)?n:[])if(!(!r||!Array.isArray(r.min)||!Array.isArray(r.max))){i+=1;for(let s=0;s<3;s+=1)e[s]=Math.min(e[s],et(r.min[s])),t[s]=Math.max(t[s],et(r.max[s]))}return i>0&&e.every(Number.isFinite)&&t.every(Number.isFinite)?{min:e,max:t}:null}function vm(n,e,t=null){return e?.isVector3?e:Array.isArray(e)||ArrayBuffer.isView(e)?new n.Vector3(et(e[0]),et(e[1]),et(e[2])):t}function VS(n){let t=String(n||"").trim().match(/^o\d+(?:\.\d+)*/i);return t?t[0].split(".").filter(Boolean):[]}function bP(n=[]){let e=n.map(r=>VS(r?.partId)).filter(r=>r.length>1);if(!e.length)return[];let t=[],i=Math.min(...e.map(r=>r.length));for(let r=0;r<i;r+=1){let s=e[0][r];if(!e.every(o=>o[r]===s))break;t.push(s)}return t.length>=i?t.slice(0,-1):t}function MP(n,{depth:e=1,commonPrefix:t=[]}={}){let i=String(n||"").trim(),r=VS(i);if(!r.length)return i;let s=Math.max(1,Math.min(Math.round(Number(e))||1,Tu)),o=Math.min(t.length,Math.max(r.length-1,0)),a=Math.min(r.length,o+s);return r.slice(0,a).join(".")||i}function vP(n){let e=String(n?.partId||"").trim();return!!(n?.mesh&&e&&e!=="__model__")}function AP(n,e,t){let i=bP(e),r=new Map;return e.forEach((s,o)=>{let a=MP(s?.partId,{depth:t.depth,commonPrefix:i})||String(s?.partId||`part:${o}`),c=s?.partBounds&&Array.isArray(s.partBounds.min)&&Array.isArray(s.partBounds.max)?s.partBounds:null,l=r.get(a)||{key:a,records:[],recordIndex:o,boundsList:[]};l.records.push(s),c&&l.boundsList.push(c),r.set(a,l)}),[...r.values()].map(s=>{let o=rh(s.boundsList)||s.records[0]?.partBounds||null;return{...s,bounds:o,center:BS(n,o),radius:ih(n,o)}})}function EP(n,e,t){let i=new n.Vector3;return i.setComponent(US[e]??2,t==="negative"?-1:1),i}function wP(n,e,t){let i=Math.max(1,t),r=i>1?1-(e+.5)/i*2:0,s=Math.sqrt(Math.max(0,1-r*r)),o=e*_P,a=new n.Vector3(Math.cos(o)*s,Math.sin(o)*s,r);return a.lengthSq()<=jt&&a.set(1,0,0),a.normalize()}function TP(n,e,t,i,r,s){let o=e.center?.isVector3?e.center.clone().sub(t):new n.Vector3;return o.lengthSq()<=jt?o.copy(wP(n,i,r)):o.normalize(),s==="negative"?o.multiplyScalar(-1):o}function CP(n,e,t,i){let r=BS(n,t),s=Math.max(ih(n,t),jt),o=Math.max(SP(t),jt),a=Math.max(et(i.spacing,1.45),.25),c=Math.max(s*.32*a,s*.12),l=[],u=e.filter(h=>h.records.length>0&&h.bounds).sort((h,f)=>h.recordIndex-f.recordIndex);if(u.forEach((h,f)=>{let d=TP(n,h,r,f,u.length,i.direction),m=ih(n,h.bounds),y=c+Math.min(m*.18*a,s*.2*a),g=d.clone().multiplyScalar(y);for(let p of h.records)l.push({record:p,partId:String(p.partId||"").trim(),groupKey:h.key,layerIndex:f,direction:d.clone(),distance:y,translation:g.clone(),matrix:new n.Matrix4})}),i.keepBaseGrounded!==!1){let h=Array.isArray(t?.min)||ArrayBuffer.isView(t?.min)?t.min:null,f=h?et(h[2]):null,d=rh(l.map(y=>zS(y.record?.partBounds,y.translation.toArray(),1))),m=Array.isArray(d?.min)?et(d.min[2]):null;if(Number.isFinite(f)&&Number.isFinite(m)&&m<f-jt){let y=Math.min(f-m,o*a);for(let g of l)g.translation.z+=y,g.distance=g.translation.length(),g.direction=g.distance>jt?g.translation.clone().normalize():g.direction}}return l}function kS(n,e=[],t=null,i={}){if(!n?.Vector3||!n?.Matrix4)return[];let r=Tp(i),s=r.axis==="radial",o=US[r.axis]??2,a=(Array.isArray(e)?e:[]).filter(vP);if(a.length<2)return[];let c=Math.max(ih(n,t),jt),l=Math.max(Ar(t,o),jt),u=AP(n,a,r).filter(C=>C.records.length>0&&C.bounds);if(u.length<2)return[];if(s)return CP(n,u,t,r);let h=u.sort((C,S)=>{let v=et(C.center?.getComponent?.(o)),L=et(S.center?.getComponent?.(o));return Math.abs(v-L)>jt?v-L:C.recordIndex-S.recordIndex}),f=Math.max(...h.map(C=>Ar(C.bounds,o)),l*.08,jt),d=h.map(C=>Ar(C.bounds,o)).filter(C=>C>jt).sort((C,S)=>C-S),m=d.length?d[Math.floor(d.length/2)]:f,y=Math.max(l*.025,f*.18,jt),g=Math.max(et(r.spacing,1.45),.25),p=Math.max(l*.075,m*.35,c*.035,jt)*g,_=EP(n,r.axis,r.direction),x=[];for(let C of h){let S=et(C.center.getComponent(o)),v=x[x.length-1];r.mergeCoplanar===!0&&v&&Math.abs(S-v.center)<=y?(v.groups.push(C),v.bounds=rh([v.bounds,C.bounds])||v.bounds,v.center=(v.center*(v.groups.length-1)+S)/v.groups.length):x.push({center:S,bounds:C.bounds,groups:[C]})}let b=(C,S)=>{let v=C?Ar(C.bounds,o):m,L=S?Ar(S.bounds,o):m;return Math.max(p,Math.min(v,L)*.22*g)},T=null,A=null,M=[];return x.forEach((C,S)=>{let v=et(C.bounds.min[o]),L=et(C.bounds.max[o]),U=0;if(r.keepBaseGrounded!==!1&&S===0)U=0,T=L;else{let G=T===null?v:T+b(A,C);U=Math.max(0,G-v),T=L+U}A=C;for(let G of C.groups){let P=_.clone().multiplyScalar(U);for(let D of G.records)M.push({record:D,partId:String(D.partId||"").trim(),groupKey:G.key,layerIndex:S,direction:P.lengthSq()>jt?P.clone().normalize():_.clone(),distance:P.length(),translation:P,matrix:new n.Matrix4})}}),M}function RP(n,e,t=0){if(!n?.Vector3)return null;let i=FS(et(t),0,1),r=vm(n,e?.toTranslation,vm(n,e?.translation,new n.Vector3(0,0,et(e?.distance)))),s=vm(n,e?.fromTranslation,null);if(!s&&i<=jt)return null;let o=s?s.x+(r.x-s.x)*i:r.x*i,a=s?s.y+(r.y-s.y)*i:r.y*i,c=s?s.z+(r.z-s.z)*i:r.z*i;return s&&Math.abs(o)<=jt&&Math.abs(a)<=jt&&Math.abs(c)<=jt?null:new n.Vector3(o,a,c)}function GS(n,e=[],t=0){for(let i of Array.isArray(e)?e:[]){let r=i?.record;if(!r)continue;let s=RP(n,i,t);if(!s){r.explodedViewMatrix=null;continue}let o=i.matrix instanceof n.Matrix4?i.matrix:new n.Matrix4;o.makeTranslation(s.x,s.y,s.z),i.matrix=o,r.explodedViewMatrix=o}}function HS(n=[]){for(let e of Array.isArray(n)?n:[])e&&(e.explodedViewMatrix=null)}function WS(n,e=[],t=null,i=1){if(!n?.Vector3)return t;let r=FS(et(i),0,1),s=(Array.isArray(e)?e:[]).map(o=>zS(o?.record?.partBounds,o?.translation?.toArray?.()||[0,0,0],r));return rh(s)||t}ei();function XS({alpha:n=!0,antialias:e=!0,powerPreference:t="high-performance",preserveDrawingBuffer:i=!1,logarithmicDepthBuffer:r=!0}={}){return{alpha:n,antialias:e,powerPreference:t,preserveDrawingBuffer:i,logarithmicDepthBuffer:r}}function IP(n={}){return{...XS(n),antialias:!1,powerPreference:"default",logarithmicDepthBuffer:!1}}function YS(n,{allowFallback:e=!1,isRecoverableError:t=()=>!0,...i}={}){try{return new n.WebGLRenderer(XS(i))}catch(r){if(!e||!t(r))throw r;return new n.WebGLRenderer(IP(i))}}var dn=Object.freeze({CAD:"cad",URDF:"urdf"});var fc=ls,PP=Object.freeze(["themeSettings","display","camera","framing","sceneScale","clip","selection","floor","background","lighting","outputSize","renderScale"]);function qS(n={}){let e={};for(let t of PP)e[t]=Object.prototype.hasOwnProperty.call(n,t)?n[t]:null;return e}function hc(n,e,t){return Math.min(Math.max(n,e),t)}function Oe(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function Am(n){return n===dn.URDF?dn.URDF:dn.CAD}function Po(n,e){return e[Am(n)]}function jS({explicit:n="",kind:e="",parts:t=[]}={}){let i=String(n||"").trim().toLowerCase();if(i)return Am(i);let r=String(e||"").trim().toLowerCase();return r==="urdf"||r==="srdf"||r==="sdf"||(Array.isArray(t)?t:[]).some(s=>String(s?.linkName||"").trim())?dn.URDF:dn.CAD}function NP(n={},{defaultThemeId:e="workbench"}={}){return typeof n.appearance=="string"?{themeId:n.appearance,settings:null}:n.appearance&&typeof n.appearance=="object"&&!Array.isArray(n.appearance)?{themeId:e,settings:n.appearance}:{themeId:e,settings:null}}function $S(n={},{defaultThemeId:e="workbench"}={}){let t=NP(n,{defaultThemeId:e}),i=c_(t.themeId||e),r=br(t.settings||i);return typeof n.appearance=="string"?l_(r,{prefersDark:!1}):r}function sh(n="iso",e=fc,{strict:t=!1}={}){return zx(n,{presets:e,strict:t})}function KS(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let i=0;i+2<(n?.length||0);i+=3){let r=Number(n[i]),s=Number(n[i+1]),o=Number(n[i+2]);[r,s,o].every(Number.isFinite)&&(e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],s),e[2]=Math.min(e[2],o),t[0]=Math.max(t[0],r),t[1]=Math.max(t[1],s),t[2]=Math.max(t[2],o))}return!e.every(Number.isFinite)||!t.every(Number.isFinite)?{min:[0,0,0],max:[1,1,1]}:{min:e,max:t}}function ZS(n,e,t){let i=Po(e,t),r=Array.isArray(n?.min)?n.min:[0,0,0],s=Array.isArray(n?.max)?n.max:[1,1,1],o=new w((Oe(r[0])+Oe(s[0],1))/2,(Oe(r[1])+Oe(s[1],1))/2,(Oe(r[2])+Oe(s[2],1))/2),a=new w(Math.max(Oe(s[0],1)-Oe(r[0]),i.minBoundsSpan),Math.max(Oe(s[1],1)-Oe(r[1]),i.minBoundsSpan),Math.max(Oe(s[2],1)-Oe(r[2]),i.minBoundsSpan));return{center:o,radius:Math.max(a.length()/2,i.minModelRadius),size:a}}function JS(n,e,t){if(n.type==="solid")return new oe(n.solidColor);let i=document.createElement("canvas");i.width=Math.max(2,e),i.height=Math.max(2,t);let r=i.getContext("2d");if(n.type==="radial"){let o=r.createRadialGradient(i.width/2,i.height/2,0,i.width/2,i.height/2,Math.max(i.width,i.height)/1.35);o.addColorStop(0,n.radialInner),o.addColorStop(1,n.radialOuter),r.fillStyle=o,r.fillRect(0,0,i.width,i.height)}else{let o=(Oe(n.linearAngle,135)-90)*Math.PI/180,a=i.width/2,c=i.height/2,l=Math.hypot(i.width,i.height),u=Math.cos(o)*l/2,h=Math.sin(o)*l/2,f=r.createLinearGradient(a-u,c-h,a+u,c+h);f.addColorStop(0,n.linearStart),f.addColorStop(1,n.linearEnd),r.fillStyle=f,r.fillRect(0,0,i.width,i.height)}let s=new _a(i);return s.colorSpace=lt,s}async function QS(n,e,t=[]){let i=e.environment||{};if(!i.enabled){n.environment=null;return}let r=u_(i.presetId),s=String(r?.url||"").trim();if(s)try{let o=new cs;typeof o.setCrossOrigin=="function"&&o.setCrossOrigin("anonymous");let a=await o.loadAsync(s);a.mapping=$r,a.colorSpace=lt,n.environment=a,n.environmentRotation?.set&&n.environmentRotation.set(0,Oe(i.rotationY),0),i.useAsBackground&&(n.background=a)}catch{t.push(`Environment preset unavailable: ${r?.label||i.presetId||"default"}`)}}function eb(n,e){let t=e.lighting||{},i=(a,c)=>{a.visible=c,n.add(a)};i(new go(t.hemisphere?.skyColor||"#ffffff",t.hemisphere?.groundColor||"#101014",Oe(t.hemisphere?.intensity,1)),t.hemisphere?.enabled!==!1),i(new yo(t.ambient?.color||"#ffffff",Oe(t.ambient?.intensity,.2)),t.ambient?.enabled!==!1);let r=new mr(t.directional?.color||"#ffffff",Oe(t.directional?.intensity,1));r.position.set(Oe(t.directional?.position?.x,160),Oe(t.directional?.position?.y,-140),Oe(t.directional?.position?.z,240)),r.castShadow=!0,i(r,t.directional?.enabled!==!1);let s=new dr(t.spot?.color||"#ffffff",Oe(t.spot?.intensity,0),Oe(t.spot?.distance,0),Oe(t.spot?.angle,Math.PI/6));s.position.set(Oe(t.spot?.position?.x,160),Oe(t.spot?.position?.y,-120),Oe(t.spot?.position?.z,140)),i(s,t.spot?.enabled===!0),n.add(s.target);let o=new pr(t.point?.color||"#ffffff",Oe(t.point?.intensity,0),Oe(t.point?.distance,0));o.position.set(Oe(t.point?.position?.x,-120),Oe(t.point?.position?.y,80),Oe(t.point?.position?.z,140)),i(o,t.point?.enabled===!0)}function tb(n,e,t,i,r){let s=t.floor||{},o=s.mode||Lt.STAGE,a=s.enabled===!0||!Object.hasOwn(s,"enabled")&&o!==Lt.NONE&&o!==Lt.GRID,c=s.grid&&typeof s.grid=="object"&&!Array.isArray(s.grid)?s.grid:{},l=c.enabled===!0||o===Lt.GRID;if(!a&&!l)return;let u=Po(i,r),{center:h,radius:f}=ZS(e,i,r),d=Array.isArray(e?.min)?Oe(e.min[2]):0,m=Math.max(f*3,u.minFloorSize);if(l){let g=hc(Oe(c.density??s.gridDensity,ds.gridDensity),Du,Uu),p=new Ba(m,Math.max(8,Math.round(28*g)),c.centerColor||s.gridCenterColor||s.color||ds.gridCenterColor,c.cellColor||s.gridCellColor||s.color||ds.gridCellColor),_=Array.isArray(p.material)?p.material:[p.material];for(let x of _)x.transparent=!0,x.opacity=hc(Oe(c.opacity??s.gridOpacity,ds.gridOpacity),0,1),x.depthWrite=!1,x.toneMapped=!1;p.rotation.x=Math.PI/2,p.position.set(h.x,h.y,d-.02),n.add(p)}if(!a)return;let y=new ft(new ns(m,m),new mo({color:s.color||"#f1f5f9",opacity:hc(Oe(s.shadowOpacity,.24),0,1)}));y.rotation.x=0,y.position.set(h.x,h.y,d-.03),y.receiveShadow=!0,n.add(y)}function Em(n){let e=Array.isArray(n?.min)?n.min:[0,0,0],t=Array.isArray(n?.max)?n.max:[1,1,1];return[[e[0],e[1],e[2]],[e[0],e[1],t[2]],[e[0],t[1],e[2]],[e[0],t[1],t[2]],[t[0],e[1],e[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[t[0],t[1],t[2]]].map(i=>new w(Oe(i[0]),Oe(i[1]),Oe(i[2])))}function wm(n={}){let e=n.render?.padding??n.render?.paddingPercent??n.padding??n.paddingPercent;return hc(Oe(e,.04),0,.15)}function Tm(n,e,t,i,r,s,o){let a=Po(s,o),c=sh(n,fc,{strict:!1}),l=new w(...c.direction).normalize(),u=new w(...c.up).normalize(),h=new w().crossVectors(l,u).normalize(),f=new w().crossVectors(h,l).normalize(),d=Em(e),m=d.map(b=>b.dot(h)),y=d.map(b=>b.dot(f)),g=Math.max(Math.max(...m)-Math.min(...m),a.minBoundsSpan),p=Math.max(Math.max(...y)-Math.min(...y),a.minBoundsSpan),_=Math.max(t/Math.max(i,1),.01),x=Math.max(1-r*2,.1);return Math.max(p/(2*x),g/(2*_*x),a.minBoundsSpan/2)/Eu(c.zoom,1)}function nb(n,e,t,i,r,{lockedHalfHeight:s=null,padding:o=.12,sceneScale:a=dn.CAD,settingsByScale:c}={}){let l=Po(a,c),u=Ep(e,t,{sceneScale:a,settingsByScale:c,strict:!1}),h=new w(...u.target);n.position.set(...u.position),n.up.set(...u.up),n.lookAt(h);let f=Math.max(i/Math.max(r,1),.01),d=s||Tm(u.view,t,i,r,o,a,c);return n.top=d,n.bottom=-d,n.left=-d*f,n.right=d*f,n.near=.01,n.far=Math.max(u.radius*12,l.minCameraFar),n.updateProjectionMatrix(),u}function ib(n,e,t,i,r,{sceneScale:s=dn.CAD,settingsByScale:o,strict:a=!0}={}){let c=Po(s,o),l=Ep(e,t,{sceneScale:s,settingsByScale:o,strict:a});return n.aspect=Math.max(i/Math.max(r,1),.01),n.position.set(...l.position),n.up.set(...l.up),n.zoom=Eu(l.zoom,1),n.near=Math.max(l.radius/1200,.01),n.far=Math.max(l.radius*600,c.minCameraFar,2e3),n.lookAt(new w(...l.target)),n.updateProjectionMatrix(),l}function rb(n,e,t,i,r,s,o){let a=wm(r);return Math.max(...n.map(c=>{let l=Oe(c.width,t),u=Oe(c.height,i);return Tm(sh(c.camera||r.camera||"iso"),e,l,u,a,s,o)}),Po(s,o).minBoundsSpan/2)}function sb(n,e){return{width:Math.max(1,Math.floor(Oe(n.width,e.width||1400))),height:Math.max(1,Math.floor(Oe(n.height,e.height||900)))}}function ob(n,e,t,i,{defaultRenderScale:r=1}={}){let s=YS(Qn,{preserveDrawingBuffer:!0});return s.outputColorSpace=lt,s.toneMapping=yu,s.toneMappingExposure=Math.max(Oe(i.lighting?.toneMappingExposure,1),.05),s.shadowMap.enabled=!0,s.shadowMap.type=gu,s.setPixelRatio(hc(Oe(t.render?.renderScale,t.renderScale||r),1,3)),s.setSize(n,e,!1),document.body.innerHTML="",document.body.appendChild(s.domElement),s}function LP(n,e="image/png"){return n.domElement.toDataURL(e)}function Cm(n={}){return typeof n.render?.viewLabels=="boolean"?n.render.viewLabels:typeof n.viewLabels=="boolean"?n.viewLabels:!1}function Rm(n,e,t,i,{corner:r="top-left",fill:s="#111827",background:o="rgba(255, 255, 255, 0.9)",border:a="rgba(17, 24, 39, 0.42)"}={}){let c=String(e||"").trim();if(!c)return;let l=Math.max(t,1),u=Math.max(i,1),h=Math.max(18,Math.min(Math.round(l*.018),32)),f=Math.round(h*.72),d=Math.round(h*.42);n.save(),n.font=`700 ${h}px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,n.textBaseline="top";let m=n.measureText(c),y=Math.ceil(m.width+f*2),g=Math.ceil(h+d*2),p=Math.max(18,Math.round(Math.min(l,u)*.024)),_=r.includes("right")?l-p-y:p,x=r.includes("bottom")?u-p-g:p;n.fillStyle=o,n.strokeStyle=a,n.lineWidth=Math.max(1,Math.round(h*.06)),n.beginPath(),n.roundRect(_,x,y,g,Math.round(h*.28)),n.fill(),n.stroke(),n.fillStyle=s,n.fillText(c,_+f,x+d),n.restore()}function ab(n,e,t){if(!Cm(t))return LP(n);let i=n.domElement,r=document.createElement("canvas");r.width=i.width,r.height=i.height;let s=r.getContext("2d");return s.drawImage(i,0,0),Rm(s,e,r.width,r.height),r.toDataURL("image/png")}var hb=1,OP="workbench",ch=Object.freeze({[dn.CAD]:Object.freeze({minBoundsSpan:1,minModelRadius:1,minFloorSize:100,minCameraDistance:10,minCameraFar:1e3}),[dn.URDF]:Object.freeze({minBoundsSpan:.05,minModelRadius:.05,minFloorSize:.5,minCameraDistance:.5,minCameraFar:10})});function DP(n,e,t){return Math.min(Math.max(n,e),t)}function Ss(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function ah(n){return Array.isArray(n)?n:[]}function No(n,e=!1){return typeof n=="boolean"?n:e}function UP(n={},e={}){let t=String(n.render?.scale||n.render?.sceneScale||n.render?.sceneScaleMode||n.scale||n.sceneScale||"").trim().toLowerCase();return jS({explicit:t,kind:n.resolved?.kind||n.kind,parts:e?.parts})}function FP(n={}){return $S(n,{defaultThemeId:OP})}function BP(n="iso"){return sh(n,fc,{strict:!0})}function zP(n){return KS(n)}function VP(n,e,t){return JS(n,e,t)}async function kP(n,e,t){return QS(n,e,t)}function GP(n,e){return eb(n,e)}function HP(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0],i=0;for(let r of Array.isArray(n)?n:[])if(!(!r||!Array.isArray(r.min)||!Array.isArray(r.max))){i+=1;for(let s=0;s<3;s+=1)e[s]=Math.min(e[s],Ss(r.min[s])),t[s]=Math.max(t[s],Ss(r.max[s]))}return i>0&&e.every(Number.isFinite)&&t.every(Number.isFinite)?{min:e,max:t}:null}function WP(n,e,t,i=dn.CAD){return tb(n,e,t,i,ch)}function XP(n){return Em(n)}function YP(n={}){return wm(n)}function qP(n,e,t,i,r,s=null,o=.12,a=dn.CAD){return nb(n,e,t,i,r,{lockedHalfHeight:s,padding:o,sceneScale:a,settingsByScale:ch})}function jP(n,e,t,i,r,s=dn.CAD){return ib(n,e,t,i,r,{sceneScale:s,settingsByScale:ch,strict:!0})}function $P(n,e,t,i,r,s=dn.CAD){return rb(n,e,t,i,r,s,ch)}function oh(n,e){return sb(n,e)}function KP(n,e,t,i){return ob(n,e,t,i,{defaultRenderScale:hb})}function ZP(n={}){return Cm(n)}function JP(n,e,t,i,{corner:r="top-left",fill:s="#111827",background:o="rgba(255, 255, 255, 0.9)",border:a="rgba(17, 24, 39, 0.42)"}={}){return Rm(n,e,t,i,{corner:r,fill:s,background:o,border:a})}function QP(n,e,t){return ab(n,e,t)}function eN(n={}){return No(n.render?.tightFrame,No(n.tightFrame,!0))}function tN(n,e){let t=new w().setFromMatrixColumn(e.matrixWorld,0).normalize(),i=new w().setFromMatrixColumn(e.matrixWorld,1).normalize(),r=new w,s={x:1/0,y:1/0},o={x:-1/0,y:-1/0},a=0;for(let c of Array.isArray(n)?n:[]){let l=c?.mesh,u=l?.geometry?.getAttribute?.("position");if(!(!l?.visible||!u||u.count<=0)){l.updateWorldMatrix?.(!0,!1);for(let h=0;h<u.count;h+=1){r.fromBufferAttribute(u,h).applyMatrix4(l.matrixWorld);let f=r.dot(t),d=r.dot(i);!Number.isFinite(f)||!Number.isFinite(d)||(s.x=Math.min(s.x,f),s.y=Math.min(s.y,d),o.x=Math.max(o.x,f),o.y=Math.max(o.y,d),a+=1)}}}return!a||![s.x,s.y,o.x,o.y].every(Number.isFinite)?null:{centerX:(s.x+o.x)/2,centerY:(s.y+o.y)/2,spanX:Math.max(o.x-s.x,1e-6),spanY:Math.max(o.y-s.y,1e-6),count:a}}function nN(n,e,t,i,r,s=1){n.updateMatrixWorld(!0);let o=tN(e,n);if(!o)return null;let a=Math.max(t/Math.max(i,1),.01),c=Math.max(1-r*2,.1),l=Math.max(o.spanY/(2*c),o.spanX/(2*a*c),1e-6)/Math.max(Ss(s,1),1e-6),u=new w().setFromMatrixColumn(n.matrixWorld,0).normalize(),h=new w().setFromMatrixColumn(n.matrixWorld,1).normalize(),f=n.position.dot(u),d=n.position.dot(h);return n.position.addScaledVector(u,o.centerX-f).addScaledVector(h,o.centerY-d),n.top=l,n.bottom=-l,n.left=-l*a,n.right=l*a,n.updateProjectionMatrix(),n.updateMatrixWorld(!0),{...o,halfHeight:l}}function fb(n={}){let e=String(n.plane||"XY").toUpperCase();if(Array.isArray(n.normal)&&n.normal.length>=3){let i=new w(n.normal[0],n.normal[1],n.normal[2]).normalize(),r=Array.isArray(n.at)&&n.at.length>=3?new w(n.at[0],n.at[1],n.at[2]):new w,s=Math.abs(i.z)<.9?new w(0,0,1):new w(0,1,0),o=new w().crossVectors(s,i).normalize(),a=new w().crossVectors(i,o).normalize();return{normal:i,at:r,u:o,v:a}}let t=Ss(n.offset,0);return e==="XZ"?{normal:new w(0,1,0),at:new w(0,t,0),u:new w(1,0,0),v:new w(0,0,1)}:e==="YZ"?{normal:new w(1,0,0),at:new w(t,0,0),u:new w(0,1,0),v:new w(0,0,1)}:{normal:new w(0,0,1),at:new w(0,0,t),u:new w(1,0,0),v:new w(0,1,0)}}function iN(n,e={}){let t=n.vertices||new Float32Array(0),i=n.indices||new Uint32Array(0),{normal:r,at:s,u:o,v:a}=fb(e),c=new w,l=[new w,new w,new w],u=[],h=d=>r.dot(new w().subVectors(d,s)),f=d=>{let m=new w().subVectors(d,s);return[m.dot(o),m.dot(a)]};for(let d=0;d+2<i.length;d+=3){for(let g=0;g<3;g+=1){let p=Number(i[d+g])*3;l[g].set(t[p],t[p+1],t[p+2])}let m=l.map(g=>h(g)),y=[];for(let[g,p]of[[0,1],[1,2],[2,0]]){let _=m[g],x=m[p];if(Math.abs(_)<1e-7&&y.push(l[g].clone()),_<0&&x>0||_>0&&x<0){let b=_/(_-x);c.copy(l[g]).lerp(l[p],b),y.push(c.clone())}}y.length>=2&&u.push([f(y[0]),f(y[1])])}return u}function db(n){let e=[],t=[];for(let i of n)for(let r of i)e.push(r[0]),t.push(r[1]);return e.length?{minX:Math.min(...e),minY:Math.min(...t),maxX:Math.max(...e),maxY:Math.max(...t)}:{minX:-1,minY:-1,maxX:1,maxY:1}}function pb(n={}){let e=String(n.plane||"XY").toUpperCase(),t=Ss(n.offset,0);if(Array.isArray(n.normal)&&n.normal.length>=3){let r=n.normal.map(o=>Number(o).toFixed(3)).join(", "),s=Array.isArray(n.at)&&n.at.length>=3?n.at.map(o=>Number(o).toFixed(3)).join(", "):"0.000, 0.000, 0.000";return`CUT N[${r}] @ [${s}]`}return`SECTION ${e} @ ${e==="YZ"?"X":e==="XZ"?"Y":"Z"}=${t.toFixed(3)}`}function cb(n,e=1e3){return`${Math.round(n[0]*e)}:${Math.round(n[1]*e)}`}function rN(n){let e=n.map((s,o)=>({index:o,a:s[0],b:s[1],aKey:cb(s[0]),bKey:cb(s[1])})),t=new Map;for(let s of e)for(let o of[s.aKey,s.bKey])t.has(o)||t.set(o,[]),t.get(o).push(s);let i=new Set,r=[];for(let s of e){if(i.has(s.index))continue;i.add(s.index);let o=s.aKey,a=s.bKey,c=[s.a,s.b];for(let l=0;l<e.length&&a!==o;l+=1){let u=(t.get(a)||[]).find(f=>!i.has(f.index));if(!u)break;i.add(u.index);let h=u.aKey===a?u.b:u.a;a=u.aKey===a?u.bKey:u.aKey,c.push(h)}c.length>=3&&a===o&&r.push(c)}return r}function sN(n,e,t,i=.12){let{minX:r,minY:s,maxX:o,maxY:a}=db(n),c=Math.max(o-r,1),l=Math.max(a-s,1),u=Math.max(20,Math.min(e,t)*i),h=Math.min((e-u*2)/c,(t-u*2)/l),f=(e-c*h)/2-r*h,d=(t+l*h)/2+s*h;return{minX:r,minY:s,maxX:o,maxY:a,spanX:c,spanY:l,scale:h,ox:f,oy:d}}function oN(n,e,t){for(let i of e)if(i.length){n.moveTo(i[0][0]*t.scale+t.ox,t.oy-i[0][1]*t.scale);for(let r=1;r<i.length;r+=1)n.lineTo(i[r][0]*t.scale+t.ox,t.oy-i[r][1]*t.scale);n.closePath()}}function aN(n,e,t){n.save(),n.strokeStyle="rgba(17, 24, 39, 0.2)",n.lineWidth=1;let i=14;for(let r=-t;r<e+t;r+=i)n.beginPath(),n.moveTo(r,t),n.lineTo(r+t,0),n.stroke();n.restore()}function cN(n,e,t,i){let r=(e.minX+e.maxX)/2*e.scale+e.ox,s=e.oy-(e.minY+e.maxY)/2*e.scale;n.save(),n.strokeStyle="rgba(239, 68, 68, 0.75)",n.lineWidth=1.5,n.setLineDash([10,8,2,8]),n.beginPath(),n.moveTo(Math.max(0,r),0),n.lineTo(Math.max(0,r),i),n.moveTo(0,Math.max(0,s)),n.lineTo(t,Math.max(0,s)),n.stroke(),n.restore()}function lN(n,e,t,i,r){let s=fb(e),a=XP(t).map(A=>A.dot(s.normal)),c=Math.min(...a),l=Math.max(...a),u=s.at.dot(s.normal),h=Math.max(170,Math.min(i*.24,260)),f=Math.max(78,Math.min(r*.16,130)),d=Math.max(18,Math.round(Math.min(i,r)*.024)),m=i-d-h,y=r-d-f,g=16,p=m+g,_=y+f/2,x=h-g*2,b=DP((u-c)/Math.max(l-c,1e-9),0,1),T=p+b*x;n.save(),n.fillStyle="rgba(255, 255, 255, 0.92)",n.strokeStyle="rgba(17, 24, 39, 0.42)",n.lineWidth=1,n.beginPath(),n.roundRect(m,y,h,f,8),n.fill(),n.stroke(),n.fillStyle="#111827",n.font="700 13px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",n.fillText("CUT LOCATOR",m+g,y+10),n.strokeStyle="#9ca3af",n.lineWidth=8,n.lineCap="round",n.beginPath(),n.moveTo(p,_),n.lineTo(p+x,_),n.stroke(),n.strokeStyle="#ef4444",n.lineWidth=3,n.beginPath(),n.moveTo(T,_-22),n.lineTo(T,_+22),n.stroke(),n.font="600 12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",n.fillStyle="#ef4444",n.fillText(pb(e).replace(/^SECTION\s+/,""),m+g,y+f-22),n.restore()}function uN(n,e="#132232"){let{minX:t,minY:i,maxX:r,maxY:s}=db(n),o=4,a=[t-o,i-o,Math.max(r-t+o*2,1),Math.max(s-i+o*2,1)].map(l=>Number(l).toFixed(4)).join(" "),c=n.map(l=>`<path d="M ${l[0][0].toFixed(4)} ${l[0][1].toFixed(4)} L ${l[1][0].toFixed(4)} ${l[1][1].toFixed(4)}"/>`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${a}" fill="none" stroke="${e}" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round">${c}</svg>`}function hN(n,e,t,i,{edgeSettings:r=null,transparent:s=!1,section:o={},bounds:a=null,viewLabels:c=!1}={}){let l=document.createElement("canvas");l.width=e,l.height=t;let u=l.getContext("2d"),h=i.background||{};s||(u.fillStyle=h.solidColor||"#ffffff",u.fillRect(0,0,e,t));let f=sN(n,e,t),d=rN(n);d.length&&(u.save(),u.beginPath(),oN(u,d,f),u.fillStyle="rgba(209, 213, 219, 0.72)",u.fill("evenodd"),u.clip("evenodd"),aN(u,e,t),u.restore()),cN(u,f,e,t),u.strokeStyle=r?.color||"#132232",u.lineWidth=3,u.lineCap="round",u.lineJoin="round";for(let m of n)u.beginPath(),u.moveTo(m[0][0]*f.scale+f.ox,f.oy-m[0][1]*f.scale),u.lineTo(m[1][0]*f.scale+f.ox,f.oy-m[1][1]*f.scale),u.stroke();return a&&lN(u,o,a,e,t),c&&JP(u,pb(o),e,t),l.toDataURL("image/png")}function lb(n){return ah(n.parts).map((e,t)=>({id:String(e?.id||e?.occurrenceId||`part:${t}`),occurrenceId:String(e?.occurrenceId||e?.id||""),name:String(e?.name||e?.label||e?.id||`Part ${t+1}`),label:String(e?.label||e?.name||e?.id||`Part ${t+1}`),triangleCount:Math.max(0,Math.floor(Ss(e?.triangleCount,0))),vertexCount:Math.max(0,Math.floor(Ss(e?.vertexCount,0))),bounds:e?.bounds||null}))}function lh(n,e={}){let t=String(e.mode||"view").trim().toLowerCase(),i=FP(e),r=UP(e,n),s=String(e.resolved?.kind||e.kind||n?.sourceFormat||"").trim().toLowerCase(),o=s==="step"||s==="stp",a=o?Ru(e.display):Ru({projection:bn.PERSPECTIVE}),c=a.mode,l=n.bounds||zP(n.vertices||[]),u=ah(e.outputs).length?ah(e.outputs):[{path:e.output||"",camera:e.camera||"iso"}],h=[],f=qS({themeSettings:i,display:a,sceneScale:r,clip:a.clip,selection:e.selection||null,floor:i.floor||null,background:i.background||null,lighting:i.lighting||null,renderScale:e.render?.renderScale??e.renderScale??hb}),d=Wx(a),m={...d,enabled:ja(c)?!0:d.enabled,depthTest:Eo(c)?!1:d.depthTest},y=di(c),g=o&&Yx(c,m),p=e.stepParameters?.selectorRuntime||e.selectorRuntime||null,_=e.stepParameters?.displayEdgeRuntime||e.displayEdgeRuntime||null,x=PS({edgesVisible:g,wireframeMode:y,cadEdgeSource:o,displayEdgeRuntime:_,selectorRuntime:p,edgeSettings:m}),b=x?{...i,edges:{...m,enabled:!1}}:{...i,edges:g?m:{...m,enabled:!1}};return{mode:t,theme:i,sceneTheme:b,sceneScale:r,sourceKind:s,stepDisplayEnabled:o,displaySettings:a,displayMode:c,wireframeMode:y,edgesVisible:g,bounds:l,outputs:u,warnings:h,sharedRenderOptions:f,edgeSettings:m,selectorRuntime:p,displayEdgeRuntime:_,topologyDisplayEdgesVisible:x}}function mb(n,e={}){let t=e.selection||{},i=n.mode==="view"||n.mode==="orbit"?{hide:t.hide}:t;return{theme:n.sceneTheme,displayMode:n.displayMode,applyDisplayModeEdgePolicy:!n.topologyDisplayEdgesVisible,scale:n.sceneScale,clip:n.sharedRenderOptions.clip,silhouette:n.topologyDisplayEdgesVisible&&n.edgeSettings.silhouette===!0,renderPartsIndividually:!0,selection:{...e.selection||{},showEdges:n.edgesVisible},edgeRendering:{mode:"screen-space",Line2:sc,LineGeometry:_s,LineSegments2:xs,LineSegmentsGeometry:qi,LineMaterial:ji},callbacks:{onWarning:r=>{let s=String(r?.message||r?.title||"").trim();s&&n.warnings.push(s)}},filterSelection:i}}function gb(n,e,t={}){if(!e?.root)throw new Error("renderModel requires a model returned by buildModel");let i=t.job||{},r=t.context||lh(e.meshData,i),s=performance.now(),o=oh(r.outputs[0]||{},i),a=KP(o.width,o.height,i,r.theme),c=new ro;No(i.render?.transparent,!1)||r.theme.background?.type==="transparent"?(c.background=null,a.setClearColor(new oe("#000000"),0)):c.background=VP(r.theme.background||{},o.width,o.height);let l=kP(c,r.theme,r.warnings);GP(c,r.theme),Object.assign(e.runtime,{Line2:sc,LineGeometry:_s,LineSegments2:xs,LineSegmentsGeometry:qi,LineMaterial:ji}),c.add(e.root),WP(c,e.bounds||r.bounds,r.theme,r.sceneScale);let u=new ci(-1,1,1,-1,.001,1e4),h=new vt(48,o.width/Math.max(o.height,1),.1,5e4);return{THREE:n||Qn,model:e,scene:c,renderer:a,orthographicCamera:u,perspectiveCamera:h,context:r,sceneBuildStarted:s,ready:l,dispose(){e.dispose?.(),a.dispose?.()}}}function fN(n=[]){return Array.from(new Set(ah(n).map(e=>String(e?.partId||"").trim()).filter(e=>e&&e!=="__model__")))}function ub(n,e){let{context:t,model:i,THREE:r}=n,s=t.displaySettings?.exploded,o=r||Qn,a=()=>{HS(i.displayRecords);for(let l of i.displayRecords)ms(o,l);i.root?.updateMatrixWorld?.(!0)};if(s?.enabled!==!0)return a(),e;let c=kS(o,i.displayRecords,e,s);if(!c.length)return a(),e;GS(o,c,1);for(let l of i.displayRecords)ms(o,l);return i.root?.updateMatrixWorld?.(!0),s.autoFrame===!1?e:WS(o,c,e,1)}function dN(n){let{context:e,model:t}=n,i=fN(t.displayRecords),r=bm({selectorRuntime:e.selectorRuntime,displayEdgeRuntime:e.displayEdgeRuntime,displayRecords:t.displayRecords,transformDisplayEdges:!1}),s=NS({transformDetected:r.transformCount>0,topologyDisplayEdgesVisible:e.topologyDisplayEdgesVisible,displayEdgeRuntime:e.displayEdgeRuntime,displayRecords:t.displayRecords}),o=s?r:bm({selectorRuntime:e.selectorRuntime,displayEdgeRuntime:e.displayEdgeRuntime,displayRecords:t.displayRecords});DS(t.runtime,s?e.displayEdgeRuntime:o.topologyRuntime,{visible:e.topologyDisplayEdgesVisible,edgeSettings:i.length?{...e.edgeSettings,includePartIds:i}:e.edgeSettings,viewerTheme:t.runtime?.baseTheme,transformByRecord:s,displayRecords:t.displayRecords})}async function Im(n,e={}){let t=e.job||{},i=n.context||lh(n.model.meshData,t),r=n.model.meshData,{mode:s,theme:o,sceneScale:a,bounds:c,outputs:l,warnings:u,edgeSettings:h}=i,f=n.model?.bounds||r.bounds||c;if(s==="list")return{ok:!0,mode:s,parts:lb(r),bounds:f,warnings:u};if(s==="section"){let C=t.section||{},S=iN(r,C);return{ok:!0,mode:s,outputs:l.map(v=>{let{width:L,height:U}=oh(v,t);return(String(v.format||t.section?.format||"").toLowerCase()||(String(v.path||"").toLowerCase().endsWith(".svg")?"svg":"png"))==="svg"?{path:String(v.path||""),mimeType:"image/svg+xml",text:uN(S,h.color)}:{path:String(v.path||""),width:L,height:U,mimeType:"image/png",dataUrl:hN(S,L,U,o,{edgeSettings:h,transparent:No(t.render?.transparent,!1),section:C,bounds:f,viewLabels:ZP(t)})}}),section:{segmentCount:S.length},warnings:u}}await n.ready;let d=performance.now()-n.sceneBuildStarted,m=No(t.render?.lockFraming,No(t.lockFraming,!1)),y=YP(t),g=new Map,p=C=>C.stepParameters||t.stepParameters||null;for(let C of l){let S=p(C),v=S?n.model.update({stepParameters:S}).bounds:n.model.update({stepParameters:null}).bounds;g.set(C,ub(n,v))}let _=m?HP(l.map(C=>g.get(C)))||c:null,x=oh(l[0]||{},t),b=m?$P(l,_,x.width,x.height,t,a):null,T=[],A=performance.now();for(let C of l){let S=p(C),{width:v,height:L}=oh(C,t);n.renderer.setSize(v,L,!1);let U=S?n.model.update({stepParameters:S}).bounds:n.model.update({stepParameters:null}).bounds,G=ub(n,U);dN(n),ku(n.model.runtime.screenSpaceLineMaterials,v,L);let P=C.camera||t.camera||"iso",z=wu(i.displaySettings?.projection,bn.ORTHOGRAPHIC)===bn.PERSPECTIVE||Vx(P,{presets:fc,strict:!0}),q=z?null:BP(P),Y=z?jP(n.perspectiveCamera,P,_||G,v,L,a):qP(n.orthographicCamera,q,_||G,v,L,b,y,a),W=z?n.perspectiveCamera:n.orthographicCamera;!z&&!m&&eN(t)&&(n.scene.updateMatrixWorld(!0),nN(W,n.model.displayRecords,v,L,y,q?.zoom)),n.renderer.render(n.scene,W);let j=String(C.viewLabel||C.label||Y.name||"").toUpperCase();T.push({path:String(C.path||""),camera:Y.name,width:v,height:L,mimeType:"image/png",dataUrl:QP(n.renderer,j,t)})}let M=performance.now()-A;return{ok:!0,mode:s,outputs:T,timings:{sceneBuildMs:d,renderMs:M,meshCount:n.model.displayRecords.length||lb(r).length||1},warnings:u}}var pN=18,mN=4,gN=720;function $i(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function yN(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function Pm(n,e,t){return Math.min(Math.max(n,e),t)}function xN(n,e){let t=Math.round(Number(n));return Number.isInteger(t)&&t>0?t:e}function _N(n){return $i(n)&&($i(n.values)||$i(n.animate)||Object.hasOwn(n,"durationSeconds")||Object.hasOwn(n,"duration")||Object.hasOwn(n,"fps")||Object.hasOwn(n,"loop"))}function uh(n){return n!=null}function Nm(n){return n?.parameterMap&&typeof n.parameterMap=="object"?n.parameterMap:{}}function SN(n,e,t){let i=Nm(n);for(let r of Object.keys($i(e)?e:{}))if(!i[r])throw new Error(`Unknown STEP parameter in ${t}: ${r}`)}function bN(n,e,t){let i=Nm(n)[e];if(!i)throw new Error(`Unknown STEP parameter animation: ${e}`);if(i.type!=="number")throw new Error(`STEP parameter animation must be numeric: ${e}`);if(!$i(t))throw new Error(`STEP parameter animation range must be an object: ${e}`);let r=Number(t.from),s=Number(t.to);if(!Number.isFinite(r)||!Number.isFinite(s))throw new Error(`STEP parameter animation range requires finite from/to values: ${e}`);return{parameterId:e,from:r,to:s}}function MN(n,e){return Object.fromEntries(Object.entries($i(e)?e:{}).map(([t,i])=>{let r=String(t||"").trim();if(!r)return null;let s=bN(n,r,i);return[r,s]}).filter(Boolean))}function yb(n,e={}){if(!$i(e))throw new Error("STEP parameters must be a JSON object");let t=_N(e),i=t?e.values||{}:e;if(!$i(i))throw new Error("STEP parameters.values must be a JSON object");SN(n,i,"stepParameters");let r=B_(n,i),s=t?MN(n,e.animate):{},o=Object.keys(s).length>0,a=Pm(xN(e.fps,pN),1,60),c=Pm(yN(e.durationSeconds??e.duration,mN),.1,60),l=o?Math.max(2,Math.min(Math.round(a*c),gN)):1;return{values:r,animate:s,animated:o,fps:a,durationSeconds:c,frameCount:l,loop:e.loop!==!1}}function xb(n,e){let t=Math.max(Math.floor(Number(n?.frameCount)||1),1),i=Pm(Math.floor(Number(e)||0),0,t-1);return t<=1?0:n?.loop===!1?i/(t-1):i/t}function _b(n,e,t){let i=xb(e,t),r={...e?.values||{}};for(let[s,o]of Object.entries($i(e?.animate)?e.animate:{})){let a=Nm(n)[s];a&&(r[s]=Xu(a,o.from+(o.to-o.from)*i))}return r}function Sb(n,e){let t=xb(n,e),i=Math.max(Number(n?.durationSeconds)||0,0),r=t*i;return{activeId:"params",playing:!!n?.animated,elapsedSec:r,duration:i,speed:1,loop:n?.loop!==!1}}var c3=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Lm(n){let e=(Array.isArray(n)?n:[]).filter(Boolean);if(!e.length)return{min:[0,0,0],max:[0,0,0]};let t=e.flatMap(s=>[s.min[0],s.max[0]]),i=e.flatMap(s=>[s.min[1],s.max[1]]),r=e.flatMap(s=>[s.min[2],s.max[2]]);return{min:[Math.min(...t),Math.min(...i),Math.min(...r)],max:[Math.max(...t),Math.max(...i),Math.max(...r)]}}var bb=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function vN(n){return!Array.isArray(n)||n.length!==16?[...bb]:n.map((e,t)=>Number.isFinite(Number(e))?Number(e):bb[t])}function AN(n){let e=n?.assembly?.mesh;return e&&typeof e=="object"?e:null}function vb(n){return String(AN(n)?.addressing||"").trim()==="gltf-node-extras"}function EN(n){let e=n?.assembly?.root;return e&&typeof e=="object"?e:null}function Om(n){if(!Array.isArray(n)||n.length<3)return null;let e=n.slice(0,3).map(t=>Number(t));return e.every(t=>Number.isFinite(t))?e:null}function Mb(n){if(!n||typeof n!="object")return null;let e={part:String(n.part||"").trim(),frame:String(n.frame||"").trim()},t=Om(n.position),i=Om(n.orientation);t&&(e.position=t),i&&(e.orientation=i);let r=n.axes&&typeof n.axes=="object"?n.axes:null;if(r){let s={};for(let o of["x","y","z"]){let a=Om(r[o]);a&&(s[o]=a)}Object.keys(s).length&&(e.axes=s)}return e.position||e.orientation||e.part||e.frame?e:null}function wN(n){let e=n?.assemblyMates;return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map((t,i)=>{let r=String(t.id||`m${i+1}`).trim()||`m${i+1}`;return{id:r,label:String(t.label||r).trim()||r,sourceLabel:String(t.sourceLabel||t.name||"").trim(),type:String(t.type||t.relation||"mate").trim(),relation:String(t.relation||t.type||"mate").trim(),fixed:String(t.fixed||"").trim(),moving:String(t.moving||"").trim(),parameters:t.parameters&&typeof t.parameters=="object"?t.parameters:{},fixedEndpoint:Mb(t.fixedEndpoint),movingEndpoint:Mb(t.movingEndpoint)}}):[]}function TN(n){let e=[],t=n?[n]:[];for(;t.length;){let i=t.pop(),r=Array.isArray(i?.children)?i.children:[];if(r.length){for(let s=r.length-1;s>=0;s-=1)t.push(r[s]);continue}String(i?.nodeType||"").trim()==="part"&&e.push(i)}return e}function hh(n){return String(n?.occurrenceId||n?.id||"").trim()}function bs(n,e){return Math.max(0,Math.floor(Number(n?.[e])||0))}function CN(n,e){return[String(n?.occurrenceId||"").trim(),String(n?.id||"").trim()].filter(Boolean).some(i=>e.has(i))}function RN(n,e){return[String(n?.occurrenceId||"").trim(),String(n?.id||"").trim()].filter(Boolean).some(i=>e.some(r=>i.startsWith(r)))}function IN(n,e){let t=Array.isArray(n?.parts)?n.parts:[],i=new Set([e?.occurrenceId,e?.id].map(o=>String(o||"").trim()).filter(Boolean)),r=t.filter(o=>CN(o,i));if(r.length)return r;let s=[...i].map(o=>`${o}.`);return s.length?t.filter(o=>RN(o,s)):[]}function Ab(n,e){let t=EN(n);if(!t)throw new Error("Assembly topology is missing assembly.root");let i=TN(t),r=[],s=[];for(let S of i){let v=String(S?.id||S?.occurrenceId||"").trim(),L=String(S?.occurrenceId||S?.id||"").trim(),U=IN(e,S);if(!U.length){let G=L||v;G&&s.push(G);continue}r.push({manifestPart:S,sourceParts:U})}if(!r.length)throw new Error("Assembly topology did not match any renderable GLB nodes");let o=0,a=0;for(let{sourceParts:S}of r)for(let v of S)o+=bs(v,"vertexCount"),a+=bs(v,"triangleCount")*3;let c=e?.vertices||new Float32Array(0),l=e?.normals||new Float32Array(0),u=e?.colors||new Float32Array(0),h=e?.surfaceEdgeBarycentric||new Float32Array(0),f=e?.surfaceEdgeClass||new Uint8Array(0),d=e?.indices||new Uint32Array(0),m=u.length===c.length&&u.length>0,y=h.length===c.length&&f.length===c.length&&c.length>0,g=new Float32Array(o*3),p=new Float32Array(o*3),_=m?new Float32Array(o*3):new Float32Array(0),x=y?new Float32Array(o*3):new Float32Array(0),b=y?new Uint8Array(o*3):new Uint8Array(0),T=new Uint32Array(a),A=[],M=0,C=0;for(let{manifestPart:S,sourceParts:v}of r){let L=String(S?.id||S?.occurrenceId||"").trim(),U=String(S?.occurrenceId||S?.id||"").trim(),G=v[0],P=M,D=Math.floor(C/3),z=[];for(let j of v){let J=bs(j,"vertexOffset"),le=bs(j,"vertexCount"),X=bs(j,"triangleOffset"),Q=bs(j,"triangleCount"),ue=Math.floor(C/3)-D;z.push({occurrenceId:hh(j),primitiveIndex:bs(j,"primitiveIndex"),triangleOffset:ue,triangleCount:Q});let xe=J*3,he=xe+le*3;g.set(c.subarray(xe,he),M*3),l.length>=he&&p.set(l.subarray(xe,he),M*3),m&&u.length>=he&&_.set(u.subarray(xe,he),M*3),y&&h.length>=he&&x.set(h.subarray(xe,he),M*3),y&&f.length>=he&&b.set(f.subarray(xe,he),M*3);let Ce=X*3,De=Ce+Q*3;for(let Me=Ce;Me<De;Me+=1)T[C]=d[Me]-J+M,C+=1;M+=le}let q=String(S?.sourcePath||"").trim(),Y=String(S?.displayName||S?.instancePath||S?.occurrenceId||q||G?.label||G?.name||hh(G)).trim(),W=Lm(v.map(j=>j.bounds));A.push({...G,...S,id:L||U||hh(G),occurrenceId:U||L||hh(G),name:Y,label:Y,nodeType:"part",sourceKind:String(S?.sourceKind||"").trim(),sourcePath:q,partSourcePath:q,sourceBounds:W,bounds:S?.bbox||W,transform:vN(S?.worldTransform||S?.transform),hasSourceColors:PN(S)&&(m||v.some(j=>!!j.hasSourceColors||!!j.color)),vertexOffset:P,vertexCount:M-P,triangleOffset:D,triangleCount:Math.floor(C/3)-D,sourcePartRanges:z,edgeIndexOffset:0,edgeIndexCount:0})}return{...e,vertices:g,indices:T,normals:p,colors:_,surfaceEdgeBarycentric:x,surfaceEdgeClass:b,edge_indices:new Uint32Array(0),parts:A,bounds:Lm(A.map(S=>S.bounds))||e?.bounds,assemblyRoot:t,assemblyMates:wN(n),meshlessLeafPartIds:s,partTransformsBaked:!0,has_source_colors:m}}function PN(n){return n?.useSourceColors!==!1}var GN=Object.freeze(["_cad_edge_barycentric","_CAD_EDGE_BARYCENTRIC"]),HN=Object.freeze(["_cad_edge_class","_CAD_EDGE_CLASS"]),WN=Object.freeze([.72,.72,.72,1]),XN=1e-6;function Db(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function Lb(n,e,t,i){[e,t,i].every(Number.isFinite)&&(n.min[0]=Math.min(n.min[0],e),n.min[1]=Math.min(n.min[1],t),n.min[2]=Math.min(n.min[2],i),n.max[0]=Math.max(n.max[0],e),n.max[1]=Math.max(n.max[1],t),n.max[2]=Math.max(n.max[2],i))}function Ub(n){return!n?.min?.every(Number.isFinite)||!n?.max?.every(Number.isFinite)?{min:[0,0,0],max:[0,0,0]}:{min:[...n.min],max:[...n.max]}}function Fb(n){let e=n?.pbrMetallicRoughness?.baseColorFactor;return Array.isArray(e)?e:null}function YN(n,e){return!Array.isArray(n)||!Array.isArray(e)?!1:e.every((t,i)=>Math.abs(Number(n[i]??(i===3?1:0))-t)<=XN)}function qN(n){let e=n?.extras?.cadSourceColor;return e===!0||e===!1?e:null}function jN(n){let e=n?.userData?.cadSourceColor;return e===!0||e===!1?e:null}function $N(n,e){return YN(Fb(n),WN)&&e?.color?.getHexString?.()==="dddddd"}function KN(n,e,{rawMaterial:t=null,stepTopology:i=!1}={}){if(!e||!n?.color)return null;let r=jN(n)??qN(t);return r===!1||i&&r!==!0&&$N(t,n)?null:{rgb:[n.color.r,n.color.g,n.color.b],hex:`#${n.color.getHexString()}`,opacity:ZN(n,t)}}function ZN(n,e=null){let t=Number(n?.opacity);if(Number.isFinite(t))return Math.min(Math.max(t,0),1);let i=Fb(e)?.[3],r=Number(i);return Number.isFinite(r)?Math.min(Math.max(r,0),1):1}function JN(n,e){if(Array.isArray(n)){let t=Number.isInteger(e?.materialIndex)?e.materialIndex:0;return n[t]||n[0]||null}return n||null}function QN(n){return Number.isInteger(n?.materialIndex)?n.materialIndex:0}function eL(n,e){return!Array.isArray(n)||n.length<=0?null:n[QN(e)]||n[0]||null}function tL(n){let e=n?.elements;return!Array.isArray(e)&&!(e instanceof Float32Array)?!1:[1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1].every((i,r)=>Math.abs(Number(e[r])-i)<1e-6)}function nL(n,e){e?.updateWorldMatrix?.(!0,!0);let t=Array.isArray(e?.children)?e.children:[];return t.length!==1||!tL(t[0]?.matrixWorld)?null:new n.Matrix4().copy(t[0].matrixWorld).invert()}function Bb(n){let e=n||null;for(;e;){let i=String(e.userData?.cadOccurrenceId||"").trim();if(i)return i;e=e.parent||null}let t=String(n?.name||"").trim();return/^o\d+(?:\.\d+)*$/.test(t)?t:""}function iL(n){let e=!1;return n?.traverse?.(t=>{e||(e=!!String(t?.userData?.cadOccurrenceId||"").trim())}),e}function rL(n,e){let t=n.x*1e3,i=n.y*1e3,r=n.z*1e3;return e?{x:t,y:-r,z:i}:{x:t,y:i,z:r}}function zb(n,e){return n?n.getX(e):e}function Ob(n,e){for(let t of e){let i=n?.getAttribute?.(t);if(i)return i}return null}function Vb(n,e,t){for(let i=0;i<3;i+=1){let r=zb(e,t+i);if(r<0||r>=n.count)return!1}return!0}function sL(n,e,t,i){let r=0;for(let s=0;s<i;s+=3)Vb(n,e,t+s)&&(r+=3);return r}function oL(n,e,t,i,r,s,o,a=0,c=0,{rawMaterial:l=null,stepTopology:u=!1}={}){let h=e?.geometry,f=h?.getAttribute?.("position");if(!f||f.itemSize!==3||f.count<=0)return null;e.updateWorldMatrix?.(!0,!1);let d=e.matrixWorld?s?new n.Matrix4().multiplyMatrices(s,e.matrixWorld):new n.Matrix4().copy(e.matrixWorld):null,m=d?new n.Matrix3().getNormalMatrix(d):null,y=h.getAttribute("normal"),g=Ob(h,GN),p=Ob(h,HN),_=h.getIndex?.(),x=Math.max(0,Math.floor(Number(t?.start||0))),b=_?.count||f.count,T=Math.floor(Number(t?.count||b-x)),A=Math.max(0,Math.min(T,b-x)),M=A-A%3;if(M<=0)return null;let C=sL(f,_,x,M),S=Math.floor(C/3);if(C<=0||S<=0)return null;let v=KN(i,r,{rawMaterial:l,stepTopology:u}),L=Bb(e),U=String(L||e?.name||e?.parent?.name||`glb:${c}`).trim(),G=L||`glb:${c}`;return{mesh:e,positions:f,normals:y,surfaceEdgeBarycentric:g,surfaceEdgeClass:p,indexAttribute:_,sourceStart:x,triangleVertexCount:M,matrixWorld:d,normalMatrix:m,convertYUpToCad:o,id:G,occurrenceId:G,primitiveIndex:Math.max(0,Math.floor(Number(a)||0)),name:U||G,label:U||G,color:v?.hex||"",opacity:v?v.opacity:1,hasSourceColors:!!v,vertexCount:C,triangleCount:S}}function aL(n,e,t,i){let r=Db(),s=new n.Vector3,o=new n.Vector3,a=i.vertexOffset,c=Math.floor(i.indexOffset/3),l=0;for(let f=0;f<e.triangleVertexCount;f+=3)if(Vb(e.positions,e.indexAttribute,e.sourceStart+f))for(let d=0;d<3;d+=1){let m=e.sourceStart+f+d,y=zb(e.indexAttribute,m),g=a+l,p=g*3;s.set(e.positions.getX(y),e.positions.getY(y),e.positions.getZ(y)),e.matrixWorld&&s.applyMatrix4(e.matrixWorld);let _=rL(s,e.convertYUpToCad),x=_.x,b=_.y,T=_.z;if(t.vertices[p]=x,t.vertices[p+1]=b,t.vertices[p+2]=T,Lb(r,x,b,T),Lb(t.bounds,x,b,T),e.normals?.itemSize===3&&y<e.normals.count){o.set(e.normals.getX(y),e.normals.getY(y),e.normals.getZ(y)),e.normalMatrix&&o.applyMatrix3(e.normalMatrix).normalize();let A=e.convertYUpToCad?{x:o.x,y:-o.z,z:o.y}:o;t.normals[p]=A.x,t.normals[p+1]=A.y,t.normals[p+2]=A.z}t.surfaceEdgeBarycentric&&e.surfaceEdgeBarycentric?.itemSize===3&&y<e.surfaceEdgeBarycentric.count&&(t.surfaceEdgeBarycentric[p]=e.surfaceEdgeBarycentric.getX(y),t.surfaceEdgeBarycentric[p+1]=e.surfaceEdgeBarycentric.getY(y),t.surfaceEdgeBarycentric[p+2]=e.surfaceEdgeBarycentric.getZ(y)),t.surfaceEdgeClass&&e.surfaceEdgeClass?.itemSize===3&&y<e.surfaceEdgeClass.count&&(t.surfaceEdgeClass[p]=e.surfaceEdgeClass.getX(y),t.surfaceEdgeClass[p+1]=e.surfaceEdgeClass.getY(y),t.surfaceEdgeClass[p+2]=e.surfaceEdgeClass.getZ(y)),t.indices[i.indexOffset+l]=g,l+=1}let u=Math.floor(l/3),h={id:e.id,occurrenceId:e.occurrenceId,primitiveIndex:e.primitiveIndex,name:e.name,label:e.label,nodeType:"part",color:e.color,opacity:e.opacity,hasSourceColors:e.hasSourceColors,bounds:Ub(r),vertexOffset:a,vertexCount:l,triangleOffset:c,triangleCount:u,edgeIndexOffset:0,edgeIndexCount:0};return i.vertexOffset+=l,i.indexOffset+=u*3,h}function cL(n,e){let t=Array.isArray(e?.parser?.json?.materials)&&e.parser.json.materials.length>0,i=Array.isArray(e?.parser?.json?.materials)?e.parser.json.materials:[],r=nL(n,e?.scene),s=!!e?.parser?.json?.extensions?.STEP_topology,o=!s&&!iL(e?.scene)&&!r,a=[],c=new Set,l=0,u=0,h=!1,f=new Map;e?.scene?.traverse?.(A=>{if(!A?.isMesh||!A.geometry)return;let M=Bb(A)||String(A?.name||`glb:${a.length}`).trim(),C=f.get(M)||0,S=Array.isArray(A.geometry.groups)&&A.geometry.groups.length?A.geometry.groups:[null];S.forEach((v,L)=>{let U=oL(n,A,v,JN(A.material,v),t,r,o,C+L,a.length,{rawMaterial:eL(i,v),stepTopology:s});U&&(a.push(U),l+=U.vertexCount,u+=U.triangleCount*3,h||=!!(U.surfaceEdgeBarycentric&&U.surfaceEdgeClass),U.color&&c.add(U.color.toLowerCase()))}),f.set(M,C+S.length)});let d=new Float32Array(l*3),m=new Uint32Array(u),y=new Float32Array(l*3),g=h?new Float32Array(l*3):null,p=h?new Uint8Array(l*3):null,_=[],x={vertices:d,indices:m,normals:y,surfaceEdgeBarycentric:g,surfaceEdgeClass:p,bounds:Db()},b={vertexOffset:0,indexOffset:0};for(let A of a)_.push(aL(n,A,x,b));let T=new Float32Array(0);return{vertices:d,indices:m,normals:y,surfaceEdgeBarycentric:g||new Float32Array(0),surfaceEdgeClass:p||new Uint8Array(0),colors:T,edge_indices:new Uint32Array(0),bounds:Ub(x.bounds),parts:_,has_source_colors:c.size>0,sourceColor:c.size===1?[...c][0]:""}}function lL(n,e){let t=new n;return new Promise((i,r)=>{t.parse(e,"",i,r)})}async function dh(n){let[e,{GLTFLoader:t}]=await Promise.all([Promise.resolve().then(()=>(ei(),Qn)),Promise.resolve().then(()=>(Nb(),Pb))]),i=await lL(t,n);return cL(e,i)}var Pn="STEP_topology";var hg="_CAD_EDGE_BARYCENTRIC",fg="_CAD_EDGE_CLASS",y3=Object.freeze({DEGENERATE:2,SEAM:4,NOT_REFERENCEABLE:8,BOUNDARY:16,NON_MANIFOLD:32,HARD:64,TANGENT:128,UNKNOWN_CONTINUITY:256}),ph=Object.freeze({FEATURE:"feature",TANGENT:"tangent",SEAM:"seam",DEGENERATE:"degenerate",BOUNDARY:"boundary",NON_MANIFOLD:"nonManifold",UNKNOWN:"unknown"}),x3=Object.freeze({none:0,feature:1,tangent:2,seam:3,degenerate:4,boundary:5,nonManifold:6,unknown:7}),_3=Object.freeze([ph.FEATURE,ph.TANGENT,ph.SEAM,ph.DEGENERATE]);function pc(n){return Number(n)===2}function Oo(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function uL(n,e){return new Error(`Failed to fetch ${n}: ${e.status} ${e.statusText}`)}var kb=new Map,mh=new Map,Gb=new Map,Hb=new Map,Wb=new Map,Xb=new Map,hL="version https://git-lfs.github.com/spec/v1",fL=512;async function dL(n,{signal:e}={}){let t=await fetch(n,{signal:e});if(!t.ok)throw uL(n,t);return t.arrayBuffer()}async function yh(n,e,t,{cachePending:i=!0}={}){if(!e)throw new Error("Missing asset cache key");if(n.has(e)){let s=n.get(e);if(i||typeof s?.then!="function")return s}if(!i){let s=await t();return n.set(e,s),s}let r;return r=t().catch(s=>{throw n.get(e)===r&&n.delete(e),s}),n.set(e,r),r}function pL(n,e){let t=n.get(e);return t&&typeof t.then!="function"?t:null}function mc(n,e,t){return n.set(e,t),t}function dg(){if(typeof DOMException=="function")return new DOMException("The operation was aborted.","AbortError");let n=new Error("The operation was aborted.");return n.name="AbortError",n}function mL(n,e){return e?e.aborted?Promise.reject(dg()):new Promise((t,i)=>{let r=()=>{e.removeEventListener?.("abort",s)},s=()=>{r(),i(dg())};e.addEventListener?.("abort",s,{once:!0}),n.then(o=>{r(),t(o)},o=>{r(),i(o)})}):n}function gL(n){let e=Number(n?.byteLength||0);if(!Number.isFinite(e)||e<=0)return null;let t=new TextDecoder("utf-8").decode(new Uint8Array(n,0,Math.min(e,fL)));if(!t.startsWith(hL))return null;let i=t.match(/^oid sha256:([0-9a-f]{64})\r?$/m)?.[1]||"",r=t.match(/^size ([0-9]+)\r?$/m)?.[1]||"",s=r?Number(r):null;return{oid:i,size:Number.isSafeInteger(s)?s:null}}function yL(n){let e=String(n||"").trim();if(!e)return"(unknown)";try{let t=typeof window<"u"&&window.location?.href?window.location.href:"http://localhost/",i=new URL(e,t);return decodeURIComponent(i.pathname||e)}catch{return e.split(/[?#]/)[0]||e}}function xh(n,e,t="Render asset"){let i=gL(n);if(!i)return;let r=i.size!==null?` Expected LFS object size: ${i.size} bytes.`:"",s=i.oid?` sha256:${i.oid}.`:"";throw new Error(`${t} is a Git LFS pointer, not downloaded mesh data: ${yL(e)}.${s}${r} Fetch the LFS object for this file and reload the viewer.`)}async function _h(n,{signal:e}={}){if(!n)throw new Error("Missing asset cache key");if(e?.aborted)throw dg();let t=pL(kb,n);if(t)return t;let i=mh.get(n);return i||(i=dL(n).then(r=>mc(kb,n,r)).finally(()=>{mh.get(n)===i&&mh.delete(n)}),mh.set(n,i)),mL(i,e)}async function Yb(n,{signal:e}={}){let t=await yh(Gb,n,async()=>{let i=await _h(n,{signal:e});return xh(i,n,"GLB render asset"),dh(i)},{cachePending:!e});return mc(Gb,n,t)}function pg(n){let e=new DataView(n);if(e.byteLength<20||e.getUint32(0,!0)!==1179937895||e.getUint32(4,!0)!==2)throw new Error("Invalid GLB topology container");let t=Math.min(e.getUint32(8,!0),e.byteLength),i=12,r=null,s=null;for(;i+8<=t;){let o=e.getUint32(i,!0),a=e.getUint32(i+4,!0);if(i+=8,i+o>t)throw new Error("Invalid GLB chunk length");a===1313821514?r=JSON.parse(new TextDecoder("utf-8").decode(n.slice(i,i+o)).trim()):a===5130562&&(s={buffer:n,byteOffset:i,byteLength:o}),i+=o}if(!r||!s)throw new Error("GLB topology requires JSON and BIN chunks");return{json:r,bin:s}}function qb(n,e,t){let i=Number(t),r=Array.isArray(n?.bufferViews)?n.bufferViews[i]:null;if(!Number.isInteger(i)||!r||Number(r.buffer||0)!==0)return null;let s=e.byteOffset+Number(r.byteOffset||0),o=Number(r.byteLength||0);return!Number.isFinite(s)||!Number.isFinite(o)||o<0||s<e.byteOffset||s+o>e.byteOffset+e.byteLength?null:{byteOffset:s,byteLength:o}}function xL(n,e){if(!Oo(e))return null;let t=qb(n.json,n.bin,e.bufferView);if(!t)return null;let i=Number(e.count||0),r=Number(e.byteOffset||0);if(!Number.isFinite(i)||i<0||!Number.isFinite(r)||r<0)return null;let s=t.byteOffset+r;return e.dtype==="float32"?new Float32Array(n.bin.buffer,s,i):e.dtype==="uint32"?new Uint32Array(n.bin.buffer,s,i):null}function jb(n,e){let t=n?.buffers?.views;if(!Oo(t))return{};let i={};for(let[r,s]of Object.entries(t)){let o=xL(e,s);o&&(i[r]=o)}return i}function _L(n){let e=Array.isArray(n?.json?.meshes)?n.json.meshes:[],t=0;for(let i of e)for(let r of Array.isArray(i?.primitives)?i.primitives:[]){t+=1;let s=r?.attributes||{};if(s[hg]===void 0||s[fg]===void 0)return!1}return t>0}function mg(n){let e=n.json?.extensions?.[Pn];if(!Oo(e))throw new Error(`GLB is missing ${Pn}`);if(!pc(e.schemaVersion))throw new Error(`Unsupported ${Pn} schemaVersion ${e.schemaVersion||"unknown"}; expected ${2}`);if(e.edgeView===void 0||e.edgeView===null)throw new Error(`${Pn} edgeView is not available`);if(!_L(n))throw new Error(`${Pn} requires ${hg} and ${fg} on every STEP mesh primitive`);return e}function gg(n,e,t="utf-8"){let i=qb(n.json,n.bin,e);if(!i)return null;let r=new Uint8Array(n.bin.buffer,i.byteOffset,i.byteLength);return JSON.parse(new TextDecoder(String(t||"utf-8")).decode(r))}function SL(n){let e=pg(n),t=mg(e),i=gg(e,t.indexView,t.encoding);if(!Oo(i))throw new Error(`${Pn} indexView is invalid`);if(!pc(i.schemaVersion))throw new Error(`Unsupported ${Pn} index schemaVersion ${i.schemaVersion||"unknown"}; expected ${2}`);return i}function bL(n){let e=pg(n),t=mg(e),i=gg(e,t.selectorView,t.encoding);if(!Oo(i))throw new Error(`${Pn} selectorView is not available`);if(!pc(i.schemaVersion))throw new Error(`Unsupported ${Pn} selector schemaVersion ${i.schemaVersion||"unknown"}; expected ${2}`);if(i?.buffers?.littleEndian===!1)throw new Error("Big-endian selector buffers are not supported");return{manifest:i,buffers:jb(i,e)}}function ML(n){let e=pg(n),t=mg(e),i=gg(e,t.edgeView,t.encoding);if(!Oo(i))throw new Error(`${Pn} edgeView is not available`);if(!pc(i.schemaVersion))throw new Error(`Unsupported ${Pn} edgeView schemaVersion ${i.schemaVersion||"unknown"}; expected ${2}`);if(String(i.profile||"")!=="surface-edges")throw new Error(`${Pn} edgeView has unsupported profile ${i.profile||"unknown"}`);if(i?.buffers?.littleEndian===!1)throw new Error("Big-endian edgeView buffers are not supported");return{manifest:i,buffers:jb(i,e)}}async function $b(n,{signal:e}={}){let t=await yh(Xb,n,async()=>{let i=await _h(n,{signal:e});return xh(i,n,"GLB topology asset"),SL(i)},{cachePending:!e});return mc(Xb,n,t)}async function Kb(n,{signal:e}={}){let t=await yh(Hb,n,async()=>{let i=await _h(n,{signal:e});return xh(i,n,"GLB selector topology asset"),bL(i)},{cachePending:!e});return mc(Hb,n,t)}async function Zb(n,{signal:e}={}){let t=await yh(Wb,n,async()=>{let i=await _h(n,{signal:e});return xh(i,n,"GLB display edge topology asset"),ML(i)},{cachePending:!e});return mc(Wb,n,t)}var ii=Object.freeze({STEP:"step",STP:"stp",GLB:"glb",STL:"stl",THREE_MF:"3mf",UNKNOWN:"unknown"});function Jb(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Qb(n=""){let e=String(n||"").trim().toLowerCase();return e==="step"||e==="stp"||e==="glb"||e==="stl"||e==="3mf"?e:ii.UNKNOWN}function vL(n=""){let e=String(n||"").split(/[?#]/,1)[0].toLowerCase();return e.endsWith(".step")?ii.STEP:e.endsWith(".stp")?ii.STP:e.endsWith(".glb")||e.endsWith(".gltf")?ii.GLB:e.endsWith(".stl")?ii.STL:e.endsWith(".3mf")?ii.THREE_MF:ii.UNKNOWN}function yg(n){let e=typeof n=="string"?n:n?.kind,t=Qb(e);return t===ii.STEP||t===ii.STP}function Sh(n,e,t){if(e!=null&&!yg(n))throw new Error(`${t} is supported only for STEP/STP sources`)}async function AL(n){let e=await Yb(n),t=await $b(n);return vb(t)?Ab(t,e):e}async function EL(n,{cadPath:e=""}={}){if(!n)return null;try{let t=await Kb(n);return vS(t,{copyCadPath:e})}catch{return null}}async function wL(n){if(!n)return null;try{return AS(await Zb(n))}catch{return null}}async function TL(n,e){if(yg(e))return AL(n);if(e===ii.GLB){let t=await fetch(n,{cache:"no-store"});if(!t.ok)throw new Error(`Failed to load GLB source: HTTP ${t.status}`);return dh(await t.arrayBuffer())}throw new Error(`Unsupported render source kind: ${e||ii.UNKNOWN}`)}async function CL({kind:n,stepParameters:e,stepParameterUrl:t,cadPath:i,selectorRuntime:r}){Sh(n,e,"stepParameters"),Sh(n,t,"stepParameterUrl");let s=uh(e);if(!t){if(!s)return null;throw new Error("STEP render parameters require resolved.stepParameterUrl")}let o=await F_(t,{cadPath:i}),a=yb(o,s?e:{});return{definition:o,renderParameters:a,selectorRuntime:r,cadPath:i||o.cadPath||"",sourceUrl:t}}function xg(n,e=0){if(!n)return null;let{definition:t,renderParameters:i}=n;return{definition:t,selectorRuntime:n.selectorRuntime||null,parameterValues:_b(t,i,e),animationState:Sb(i,e),cadPath:n.cadPath||t.cadPath||"",sourceUrl:n.sourceUrl||t.url||""}}async function eM(n,e={}){let t=Jb(n)?n:{};if(Object.prototype.hasOwnProperty.call(t,"params"))throw new Error("Render source jobs use stepParameters; params is no longer a shared render API field");let i=Jb(t.resolved)?t.resolved:{},r=t.meshData||e.meshData||(t.vertices&&t.indices?t:null),s=t.kind||i.kind||e.kind||(typeof n=="string"?vL(n):""),o=Qb(s),a=t.stepParameters??e.stepParameters,c=String(t.stepParameterUrl||i.stepParameterUrl||e.stepParameterUrl||"").trim(),l=String(t.cadPath||i.inputPath||e.cadPath||"").trim();Sh(o,a,"stepParameters"),Sh(o,c,"stepParameterUrl");let u=r,h=String(t.glbUrl||i.glbUrl||e.glbUrl||"").trim(),f=String(typeof n=="string"?n:t.url||i.url||h||"").trim();if(!u){if(!f)throw new Error("loadSource requires meshData, a source URL, or resolved.glbUrl");u=await TL(yg(o)&&h||f,o)}let d=t.selectorRuntime||e.selectorRuntime||await EL(h||f,{cadPath:l}),m=t.displayEdgeRuntime||e.displayEdgeRuntime||await wL(h||f),y=await CL({kind:o,stepParameters:a,stepParameterUrl:c,cadPath:l,selectorRuntime:d});return{kind:o,meshData:u,selectorRuntime:d,displayEdgeRuntime:m,stepParameterSource:y,resolved:i,url:f,glbUrl:h,cadPath:l}}function tM(n){let e=n.orbit&&typeof n.orbit=="object"?n.orbit:{},t=Array.isArray(n.outputs)&&n.outputs.length?n.outputs[0]:{},i=Math.max(1,Math.floor(Number(t.width||n.width||e.width||720))),r=Math.max(1,Math.floor(Number(t.height||n.height||e.height||480))),s=Math.max(1,Math.min(Number(e.fps||6),60)),o=Math.max(.1,Math.min(Number(e.durationSeconds||12),60)),a=Math.max(2,Math.min(Math.round(s*o),720)),c=Number.isFinite(Number(e.startAzimuth))?Number(e.startAzimuth):-45,l=Number.isFinite(Number(e.elevation))?Number(e.elevation):30,u=Number.isFinite(Number(e.turns))?Number(e.turns):1;return{path:String(t.path||n.output||""),width:i,height:r,fps:s,durationSeconds:o,frameCount:a,outputs:Array.from({length:a},(h,f)=>({path:"",width:i,height:r,camera:`${c+360*u*f/a}:${l}`}))}}var rM=Ch||Fo?.GIFEncoder||Fo,nM=Og||Fo?.quantize,iM=Dg||Fo?.applyPalette;async function sM(n,e,t){let i=new Image;i.decoding="async";let r=new Promise((a,c)=>{i.onload=a,i.onerror=()=>c(new Error("Failed to load rendered orbit frame"))});i.src=n,await r;let s=document.createElement("canvas");s.width=e,s.height=t;let o=s.getContext("2d",{willReadFrequently:!0});return o.drawImage(i,0,0,e,t),o.getImageData(0,0,e,t)}function oM(n={}){let e=String(n.appearance?.background?.type||"").toLowerCase();return!!n.render?.transparent||e==="transparent"}function aM(n,{transparent:e=!1}={}){if(!e){let r=nM(n.data,256);return{indexed:iM(n.data,r),palette:r,transparent:!1,transparentIndex:0}}let t=nM(n.data,256,{format:"rgba4444",oneBitAlpha:!0}),i=t.findIndex(r=>Number(r?.[3])<=127);return{indexed:iM(n.data,t,"rgba4444"),palette:t,transparent:i>=0,transparentIndex:Math.max(i,0)}}async function _g(n,e){let t=lh(n.meshData,e),i=pS(Qn,n,mb(t,e));if(t.mode==="list"||t.mode==="section")try{return await Im({model:i,context:t},{job:e})}finally{i.dispose()}let r=gb(Qn,i,{job:e,context:t});try{return await Im(r,{job:e})}finally{r.dispose()}}async function RL(n,e){let t=tM(e),i=await _g(n,{...e,mode:"view",outputs:t.outputs,render:{...e.render||{},lockFraming:!0}}),r=rM(),s=oM(e);for(let c=0;c<i.outputs.length;c+=1){let l=await sM(i.outputs[c].dataUrl,t.width,t.height),u=aM(l,{transparent:s});r.writeFrame(u.indexed,t.width,t.height,{palette:u.palette,transparent:u.transparent,transparentIndex:u.transparentIndex,delay:1e3/t.fps,repeat:0,dispose:u.transparent?2:-1})}r.finish();let o=r.bytesView(),a="";for(let c=0;c<o.length;c+=1)a+=String.fromCharCode(o[c]);return{ok:!0,mode:"orbit",outputs:[{path:t.path,width:t.width,height:t.height,frameCount:t.frameCount,mimeType:"image/gif",dataUrl:`data:image/gif;base64,${btoa(a)}`}],timings:i.timings,warnings:i.warnings||[]}}async function IL(n,e,t){let i=t.renderParameters,r=Array.isArray(e.outputs)&&e.outputs.length?e.outputs[0]:{},s=Math.max(1,Math.floor(Number(r.width||e.width||720))),o=Math.max(1,Math.floor(Number(r.height||e.height||480))),a=Array.from({length:i.frameCount},(d,m)=>({...r,path:"",width:s,height:o,stepParameters:xg(t,m)})),c=await _g(n,{...e,outputs:a,render:{...e.render||{},lockFraming:!0}}),l=rM(),u=oM(e);for(let d=0;d<c.outputs.length;d+=1){let m=await sM(c.outputs[d].dataUrl,s,o),y=aM(m,{transparent:u});l.writeFrame(y.indexed,s,o,{palette:y.palette,transparent:y.transparent,transparentIndex:y.transparentIndex,delay:1e3/i.fps,repeat:i.loop===!1?-1:0,dispose:y.transparent?2:-1})}l.finish();let h=l.bytesView(),f="";for(let d=0;d<h.length;d+=1)f+=String.fromCharCode(h[d]);return{ok:!0,mode:String(e.mode||"view").toLowerCase(),outputs:[{path:String(r.path||e.output||""),width:s,height:o,frameCount:i.frameCount,fps:i.fps,durationSeconds:i.durationSeconds,loop:i.loop!==!1,mimeType:"image/gif",dataUrl:`data:image/gif;base64,${btoa(f)}`}],timings:c.timings,warnings:c.warnings||[]}}async function PL(n){let e=await eM(n),t=e.stepParameterSource,i=uh(n.stepParameters),r={...n,selectorRuntime:e.selectorRuntime,displayEdgeRuntime:e.displayEdgeRuntime};if(t&&i&&String(n.mode||"view").toLowerCase()!=="view")throw new Error("stepParameters support only view mode; set display.mode for display-style changes");let s=t?{...r,stepParameters:xg(t,0)}:r;return t?.renderParameters?.animated?IL(e,r,t):String(n.mode||"view").toLowerCase()==="orbit"?RL(e,s):_g(e,s)}typeof window<"u"&&(window.__snapshotRender=PL);export{PL as runHeadlessRenderJob};