Files
AR-Menu/Needle/MenuScene/dist/assets/three@0.169.19.js
pelpanagiotis 6947303755 Commit Needle production dist and nginx-only Docker image
- Track Needle/MenuScene/dist and Needle/SampleScene/dist for container deploys
- Dockerfile copies pre-built dist (no npm in image); rebuild with npm run build before commit
- Fix Needle .gitignore: /assets/ so dist/assets is not ignored
- Git LFS: track *.wasm; relax .dockerignore so dist is sent as build context

Made-with: Cursor
2026-04-19 23:39:59 +03:00

3864 lines
943 KiB
JavaScript

import{n as e}from"./rolldown-runtime.CYVBeYYp.js";var t=e({ACESFilmicToneMapping:()=>4,AONode:()=>yC,AddEquation:()=>100,AddOperation:()=>2,AdditiveAnimationBlendMode:()=>it,AdditiveBlending:()=>2,AfterImageNode:()=>Dk,AgXToneMapping:()=>6,AlphaFormat:()=>ie,AlwaysCompare:()=>519,AlwaysDepth:()=>1,AlwaysStencilFunc:()=>519,AmbientLight:()=>Cp,AmbientLightNode:()=>BN,AnaglyphPassNode:()=>PA,AnalyticLightNode:()=>fj,AnamorphicNode:()=>Lk,AnimationAction:()=>_m,AnimationClip:()=>Kf,AnimationLoader:()=>np,AnimationMixer:()=>ym,AnimationObjectGroup:()=>gm,AnimationUtils:()=>Nf,ArcCurve:()=>Mu,ArrayCamera:()=>Ac,ArrayElementNode:()=>Lh,ArrowHelper:()=>fh,AssignNode:()=>M_,AttachedBindMode:()=>a,AttributeNode:()=>cb,Audio:()=>Xp,AudioAnalyser:()=>nm,AudioContext:()=>Lp,AudioListener:()=>Yp,AudioLoader:()=>Rp,AxesHelper:()=>ph,BRDF_GGX:()=>Kw,BRDF_Lambert:()=>Aw,BackSide:()=>1,BasicDepthPacking:()=>at,BasicEnvironmentNode:()=>Cw,BasicNodeLibrary:()=>$N,BasicShadowMap:()=>0,BatchNode:()=>XS,BatchedMesh:()=>nu,BloomNode:()=>gA,Bone:()=>wl,BooleanKeyframeTrack:()=>zf,Box2:()=>Nm,Box3:()=>Gn,Box3Helper:()=>sh,BoxGeometry:()=>Zi,BoxHelper:()=>oh,Break:()=>aC,BufferAttribute:()=>bi,BufferAttributeNode:()=>Vy,BufferGeometry:()=>Ii,BufferGeometryLoader:()=>Ap,BufferNode:()=>vx,BumpMapNode:()=>Qx,BypassNode:()=>Xy,ByteType:()=>x,Cache:()=>Yf,CacheNode:()=>Jy,Camera:()=>la,CameraHelper:()=>rh,CanvasTexture:()=>ku,CapsuleGeometry:()=>od,CatmullRomCurve3:()=>Ru,CineonToneMapping:()=>3,CircleGeometry:()=>sd,ClampToEdgeWrapping:()=>c,Clock:()=>Up,CodeNode:()=>KE,Color:()=>P,ColorKeyframeTrack:()=>Bf,ColorManagement:()=>Tn,ColorSpaceNode:()=>Oy,CompressedArrayTexture:()=>Du,CompressedCubeTexture:()=>Ou,CompressedTexture:()=>Eu,CompressedTextureLoader:()=>rp,ComputeNode:()=>Ky,ConeGeometry:()=>ld,ConstNode:()=>Kh,ConstantAlphaFactor:()=>213,ConstantColorFactor:()=>211,ContextNode:()=>_y,Continue:()=>iC,Controls:()=>hh,ConvertNode:()=>Rh,CubeCamera:()=>ga,CubeReflectionMapping:()=>301,CubeRefractionMapping:()=>302,CubeTexture:()=>_a,CubeTextureLoader:()=>ap,CubeTextureNode:()=>gx,CubeUVReflectionMapping:()=>306,CubicBezierCurve:()=>Yu,CubicBezierCurve3:()=>Xu,CubicInterpolant:()=>Ff,CullFaceBack:()=>1,CullFaceFront:()=>2,CullFaceFrontBack:()=>3,CullFaceNone:()=>0,Curve:()=>Au,CurvePath:()=>rd,CustomBlending:()=>5,CustomToneMapping:()=>5,CylinderGeometry:()=>cd,Cylindrical:()=>Am,DFGApprox:()=>qw,D_GGX:()=>Uw,Data3DTexture:()=>Bn,DataArrayTexture:()=>Rn,DataTexture:()=>Tl,DataTextureLoader:()=>op,DataUtils:()=>_i,DecrementStencilOp:()=>yt,DecrementWrapStencilOp:()=>xt,DefaultLoadingManager:()=>Zf,DenoiseNode:()=>iA,DepthFormat:()=>le,DepthOfFieldNode:()=>Vk,DepthStencilFormat:()=>ue,DepthTexture:()=>ho,DetachedBindMode:()=>o,DirectionalLight:()=>Sp,DirectionalLightHelper:()=>eh,DirectionalLightNode:()=>NN,Discard:()=>rb,DiscreteInterpolant:()=>Lf,DisplayP3ColorSpace:()=>dt,DodecahedronGeometry:()=>dd,DotScreenNode:()=>Uk,DoubleSide:()=>2,DstAlphaFactor:()=>206,DstColorFactor:()=>208,DynamicCopyUsage:()=>At,DynamicDrawUsage:()=>wt,DynamicReadUsage:()=>Dt,EPSILON:()=>av,EdgesGeometry:()=>gd,EllipseCurve:()=>ju,EnvironmentNode:()=>iE,EqualCompare:()=>514,EqualDepth:()=>4,EqualStencilFunc:()=>514,EquirectUVNode:()=>mw,EquirectangularReflectionMapping:()=>303,EquirectangularRefractionMapping:()=>304,Euler:()=>Dr,EventDispatcher:()=>Ft,ExpressionNode:()=>tb,ExtrudeGeometry:()=>$d,FXAANode:()=>cA,F_Schlick:()=>kw,FileLoader:()=>tp,FilmNode:()=>qk,Float16BufferAttribute:()=>Oi,Float32BufferAttribute:()=>F,FloatType:()=>E,Fn:()=>U,Fog:()=>Wc,FogExp2:()=>Uc,FogExp2Node:()=>ZA,FogNode:()=>qA,FogRangeNode:()=>YA,FramebufferTexture:()=>Tu,FrontFacingNode:()=>Qb,FrontSide:()=>0,Frustum:()=>Ta,FunctionCallNode:()=>P_,FunctionNode:()=>ZE,FunctionOverloadingNode:()=>rO,GLBufferAttribute:()=>wm,GLSL1:()=>`100`,GLSL3:()=>Mt,GLSLNodeParser:()=>XN,GTAONode:()=>eA,GaussianBlurNode:()=>Ck,GreaterCompare:()=>516,GreaterDepth:()=>6,GreaterEqualCompare:()=>518,GreaterEqualDepth:()=>5,GreaterEqualStencilFunc:()=>518,GreaterStencilFunc:()=>516,GridHelper:()=>Ym,Group:()=>jc,HalfFloatType:()=>D,HemisphereLight:()=>lp,HemisphereLightHelper:()=>Jm,HemisphereLightNode:()=>VN,IESSpotLightNode:()=>zN,INFINITY:()=>ov,IcosahedronGeometry:()=>nf,If:()=>W,ImageBitmapLoader:()=>Fp,ImageLoader:()=>ip,ImageUtils:()=>kn,IncrementStencilOp:()=>vt,IncrementWrapStencilOp:()=>bt,IndexNode:()=>VS,InstanceNode:()=>JS,InstancedBufferAttribute:()=>kl,InstancedBufferGeometry:()=>kp,InstancedInterleavedBuffer:()=>Cm,InstancedMesh:()=>Ll,InstancedPointsNodeMaterial:()=>rw,Int16BufferAttribute:()=>wi,Int32BufferAttribute:()=>Ei,Int8BufferAttribute:()=>xi,IntType:()=>w,InterleavedBuffer:()=>Kc,InterleavedBufferAttribute:()=>Jc,Interpolant:()=>Pf,InterpolateDiscrete:()=>Ze,InterpolateLinear:()=>Qe,InterpolateSmooth:()=>$e,InvertStencilOp:()=>St,IrradianceNode:()=>SC,JoinNode:()=>Bh,KeepStencilOp:()=>gt,KeyframeTrack:()=>Rf,LOD:()=>pl,LatheGeometry:()=>ad,Layers:()=>Or,LessCompare:()=>513,LessDepth:()=>2,LessEqualCompare:()=>515,LessEqualDepth:()=>3,LessEqualStencilFunc:()=>515,LessStencilFunc:()=>513,Light:()=>cp,LightProbe:()=>Ep,LightProbeNode:()=>HN,LightingContextNode:()=>bC,LightingModel:()=>Tw,LightingNode:()=>vC,LightsNode:()=>gC,Line:()=>du,Line2NodeMaterial:()=>lw,Line3:()=>Im,LineBasicMaterial:()=>ru,LineBasicNodeMaterial:()=>aw,LineCurve:()=>Zu,LineCurve3:()=>Qu,LineDashedMaterial:()=>Tf,LineDashedNodeMaterial:()=>sw,LineLoop:()=>gu,LineSegments:()=>hu,LinearDisplayP3ColorSpace:()=>ft,LinearFilter:()=>h,LinearInterpolant:()=>If,LinearMipMapLinearFilter:()=>y,LinearMipMapNearestFilter:()=>_,LinearMipmapLinearFilter:()=>v,LinearMipmapNearestFilter:()=>g,LinearSRGBColorSpace:()=>ut,LinearToneMapping:()=>1,LinearTransfer:()=>pt,Loader:()=>Qf,LoaderUtils:()=>Op,LoadingManager:()=>Xf,Loop:()=>rC,LoopNode:()=>nC,LoopOnce:()=>Je,LoopPingPong:()=>Xe,LoopRepeat:()=>Ye,LuminanceAlphaFormat:()=>ce,LuminanceFormat:()=>se,Lut3DNode:()=>Yk,MOUSE:()=>r,MRTNode:()=>tO,MatcapUVNode:()=>_E,Material:()=>di,MaterialLoader:()=>Dp,MaterialNode:()=>$,MaterialReferenceNode:()=>Ox,MathUtils:()=>ln,Matrix2:()=>jm,Matrix3:()=>j,Matrix4:()=>N,MaxEquation:()=>104,MaxMipLevelNode:()=>pb,Mesh:()=>Ji,MeshBasicMaterial:()=>fi,MeshBasicNodeMaterial:()=>Ow,MeshDepthMaterial:()=>hc,MeshDistanceMaterial:()=>gc,MeshLambertMaterial:()=>Cf,MeshLambertNodeMaterial:()=>Iw,MeshMatcapMaterial:()=>wf,MeshMatcapNodeMaterial:()=>bE,MeshNormalMaterial:()=>Sf,MeshNormalNodeMaterial:()=>pw,MeshPhongMaterial:()=>bf,MeshPhongNodeMaterial:()=>Rw,MeshPhysicalMaterial:()=>yf,MeshPhysicalNodeMaterial:()=>uE,MeshSSSNodeMaterial:()=>fE,MeshStandardMaterial:()=>vf,MeshStandardNodeMaterial:()=>cE,MeshToonMaterial:()=>xf,MeshToonNodeMaterial:()=>gE,MinEquation:()=>103,MirroredRepeatWrapping:()=>l,MixOperation:()=>1,ModelNode:()=>Pb,ModelViewProjectionNode:()=>zS,MorphNode:()=>dC,MultiplyBlending:()=>4,MultiplyOperation:()=>0,NearestFilter:()=>u,NearestMipMapLinearFilter:()=>m,NearestMipMapNearestFilter:()=>f,NearestMipmapLinearFilter:()=>p,NearestMipmapNearestFilter:()=>d,NeutralToneMapping:()=>7,NeverCompare:()=>512,NeverDepth:()=>0,NeverStencilFunc:()=>512,NoBlending:()=>0,NoColorSpace:()=>``,NoToneMapping:()=>0,Node:()=>R,NodeAttribute:()=>LE,NodeBuilder:()=>JD,NodeCache:()=>UE,NodeCode:()=>VE,NodeFrame:()=>YD,NodeFunctionInput:()=>XD,NodeLoader:()=>PE,NodeMaterial:()=>tw,NodeMaterialLoader:()=>FE,NodeMaterialObserver:()=>vh,NodeObjectLoader:()=>IE,NodeShaderStage:()=>Ah,NodeType:()=>jh,NodeUniform:()=>RE,NodeUpdateType:()=>L,NodeUtils:()=>kh,NodeVar:()=>zE,NodeVarying:()=>BE,NormalAnimationBlendMode:()=>rt,NormalBlending:()=>1,NormalMapNode:()=>Jx,NotEqualCompare:()=>517,NotEqualDepth:()=>7,NotEqualStencilFunc:()=>517,NumberKeyframeTrack:()=>Vf,Object3D:()=>Wr,Object3DNode:()=>Ob,ObjectLoader:()=>jp,ObjectSpaceNormalMap:()=>1,OctahedronGeometry:()=>rf,OneFactor:()=>201,OneMinusConstantAlphaFactor:()=>214,OneMinusConstantColorFactor:()=>212,OneMinusDstAlphaFactor:()=>207,OneMinusDstColorFactor:()=>209,OneMinusSrcAlphaFactor:()=>205,OneMinusSrcColorFactor:()=>203,OrthographicCamera:()=>Ba,OscNode:()=>dO,OutputStructNode:()=>QD,P3Primaries:()=>`p3`,PCFShadowMap:()=>1,PCFSoftShadowMap:()=>2,PI:()=>sv,PI2:()=>cv,PMREMGenerator:()=>$a,PMREMNode:()=>$T,ParallaxBarrierPassNode:()=>IA,ParameterNode:()=>WE,PassNode:()=>_k,Path:()=>id,PerspectiveCamera:()=>pa,PhongLightingModel:()=>Pw,PhysicalLightingModel:()=>OT,PixelationPassNode:()=>SA,Plane:()=>Sa,PlaneGeometry:()=>Oa,PlaneHelper:()=>ch,PointLight:()=>bp,PointLightHelper:()=>Wm,PointLightNode:()=>MN,PointUVNode:()=>JO,Points:()=>Su,PointsMaterial:()=>_u,PointsNodeMaterial:()=>SE,PolarGridHelper:()=>Xm,PolyhedronGeometry:()=>ud,PositionalAudio:()=>tm,PosterizeNode:()=>lk,PropertyBinding:()=>hm,PropertyMixer:()=>rm,PropertyNode:()=>t_,QuadraticBezierCurve:()=>$u,QuadraticBezierCurve3:()=>ed,Quaternion:()=>Hn,QuaternionKeyframeTrack:()=>Uf,QuaternionLinearInterpolant:()=>Hf,RED_GREEN_RGTC2_Format:()=>Ke,RED_RGTC1_Format:()=>We,REVISION:()=>n,RGBADepthPacking:()=>ot,RGBAFormat:()=>oe,RGBAIntegerFormat:()=>ge,RGBA_ASTC_10x10_Format:()=>Re,RGBA_ASTC_10x5_Format:()=>Fe,RGBA_ASTC_10x6_Format:()=>Ie,RGBA_ASTC_10x8_Format:()=>Le,RGBA_ASTC_12x10_Format:()=>ze,RGBA_ASTC_12x12_Format:()=>Be,RGBA_ASTC_4x4_Format:()=>De,RGBA_ASTC_5x4_Format:()=>Oe,RGBA_ASTC_5x5_Format:()=>ke,RGBA_ASTC_6x5_Format:()=>Ae,RGBA_ASTC_6x6_Format:()=>je,RGBA_ASTC_8x5_Format:()=>Me,RGBA_ASTC_8x6_Format:()=>Ne,RGBA_ASTC_8x8_Format:()=>Pe,RGBA_BPTC_Format:()=>Ve,RGBA_ETC2_EAC_Format:()=>Ee,RGBA_PVRTC_2BPPV1_Format:()=>Ce,RGBA_PVRTC_4BPPV1_Format:()=>k,RGBA_S3TC_DXT1_Format:()=>ve,RGBA_S3TC_DXT3_Format:()=>ye,RGBA_S3TC_DXT5_Format:()=>be,RGBDepthPacking:()=>st,RGBFormat:()=>ae,RGBIntegerFormat:()=>he,RGBShiftNode:()=>Gk,RGB_BPTC_SIGNED_Format:()=>He,RGB_BPTC_UNSIGNED_Format:()=>Ue,RGB_ETC1_Format:()=>we,RGB_ETC2_Format:()=>Te,RGB_PVRTC_2BPPV1_Format:()=>Se,RGB_PVRTC_4BPPV1_Format:()=>xe,RGB_S3TC_DXT1_Format:()=>_e,RGDepthPacking:()=>ct,RGFormat:()=>pe,RGIntegerFormat:()=>me,RTTNode:()=>UO,RangeNode:()=>tj,RawShaderMaterial:()=>_f,Ray:()=>_r,Raycaster:()=>Em,Rec709Primaries:()=>ht,RectAreaLight:()=>wp,RectAreaLightNode:()=>LN,RedFormat:()=>de,RedIntegerFormat:()=>fe,ReferenceNode:()=>Tx,ReflectorNode:()=>LO,ReinhardToneMapping:()=>2,RemapNode:()=>Qy,RenderOutputNode:()=>ab,RenderTarget:()=>In,RendererReferenceNode:()=>Iy,RepeatWrapping:()=>s,ReplaceStencilOp:()=>_t,Return:()=>ib,ReverseSubtractEquation:()=>102,RingGeometry:()=>af,RotateNode:()=>CE,SIGNED_RED_GREEN_RGTC2_Format:()=>qe,SIGNED_RED_RGTC1_Format:()=>Ge,SRGBColorSpace:()=>lt,SRGBTransfer:()=>mt,SSAAPassNode:()=>TA,Scene:()=>Gc,SceneNode:()=>XO,Schlick_to_F0:()=>Yw,ScreenNode:()=>TC,ScriptableNode:()=>GA,ScriptableValueNode:()=>BA,SetNode:()=>Uh,ShaderChunk:()=>ka,ShaderLib:()=>Aa,ShaderMaterial:()=>aa,ShaderNode:()=>Sg,ShadowMaterial:()=>gf,ShadowNodeMaterial:()=>kE,Shape:()=>_d,ShapeGeometry:()=>of,ShapePath:()=>mh,ShapeUtils:()=>Xd,ShortType:()=>S,Skeleton:()=>Ol,SkeletonHelper:()=>Hm,SkinnedMesh:()=>Cl,SkinningNode:()=>$S,SobelOperatorNode:()=>zk,Source:()=>jn,Sphere:()=>lr,SphereGeometry:()=>cf,Spherical:()=>km,SphericalHarmonics3:()=>Tp,SplineCurve:()=>td,SplitNode:()=>Hh,SpotLight:()=>hp,SpotLightHelper:()=>Rm,SpotLightNode:()=>RN,Sprite:()=>ll,SpriteMaterial:()=>Yc,SpriteNodeMaterial:()=>EE,SpriteSheetUVNode:()=>gO,SrcAlphaFactor:()=>204,SrcAlphaSaturateFactor:()=>210,SrcColorFactor:()=>202,StackNode:()=>gD,StaticCopyUsage:()=>kt,StaticDrawUsage:()=>Ct,StaticReadUsage:()=>Et,StereoCamera:()=>Hp,StereoPassNode:()=>kA,StorageArrayElementNode:()=>vO,StorageBufferNode:()=>tk,StorageTextureNode:()=>ik,StreamCopyUsage:()=>jt,StreamDrawUsage:()=>Tt,StreamReadUsage:()=>Ot,StringKeyframeTrack:()=>Wf,SubtractEquation:()=>101,SubtractiveBlending:()=>3,TBNViewMatrix:()=>Ux,TOUCH:()=>i,TangentSpaceNormalMap:()=>0,TempNode:()=>zh,TetrahedronGeometry:()=>lf,Texture:()=>Pn,Texture3DNode:()=>jE,TextureLoader:()=>sp,TextureNode:()=>hb,TextureSizeNode:()=>db,TextureUtils:()=>Dc,TimerNode:()=>oO,ToneMappingNode:()=>Ry,ToonOutlinePassNode:()=>RA,TorusGeometry:()=>uf,TorusKnotGeometry:()=>df,TransitionNode:()=>vA,Triangle:()=>ii,TriangleFanDrawMode:()=>2,TriangleStripDrawMode:()=>1,TrianglesDrawMode:()=>0,TriplanarTexturesNode:()=>bO,TubeGeometry:()=>ff,UVMapping:()=>300,Uint16BufferAttribute:()=>Ti,Uint32BufferAttribute:()=>Di,Uint8BufferAttribute:()=>Si,Uint8ClampedBufferAttribute:()=>Ci,Uniform:()=>bm,UniformArrayNode:()=>xx,UniformGroupNode:()=>Jg,UniformNode:()=>e_,UniformsGroup:()=>Sm,UniformsLib:()=>I,UniformsUtils:()=>na,UnsignedByteType:()=>b,UnsignedInt101111Type:()=>re,UnsignedInt248Type:()=>te,UnsignedInt5999Type:()=>ne,UnsignedIntType:()=>T,UnsignedShort4444Type:()=>ee,UnsignedShort5551Type:()=>O,UnsignedShortType:()=>C,UserDataNode:()=>sk,VSMShadowMap:()=>3,V_GGX_SmithCorrelated:()=>Vw,VarNode:()=>by,VaryingNode:()=>Sy,Vector2:()=>A,Vector3:()=>M,Vector4:()=>Fn,VectorKeyframeTrack:()=>Gf,VertexColorNode:()=>KO,VideoTexture:()=>wu,ViewportDepthNode:()=>UC,ViewportDepthTextureNode:()=>VC,ViewportSharedTextureNode:()=>fk,ViewportTextureNode:()=>LC,VolumeNodeMaterial:()=>NE,WebGL3DRenderTarget:()=>Vn,WebGLArrayRenderTarget:()=>zn,WebGLCoordinateSystem:()=>Nt,WebGLCubeRenderTarget:()=>va,WebGLMultipleRenderTargets:()=>gh,WebGLRenderTarget:()=>Ln,WebGLRenderer:()=>Hc,WebGLUtils:()=>kc,WebGPUCoordinateSystem:()=>Pt,WireframeGeometry:()=>pf,WrapAroundEnding:()=>nt,ZeroCurvatureEnding:()=>et,ZeroFactor:()=>200,ZeroSlopeEnding:()=>tt,ZeroStencilOp:()=>0,abs:()=>Av,acesFilmicToneMapping:()=>Xj,acos:()=>Ov,add:()=>L_,addMethodChaining:()=>z,addNodeElement:()=>sb,afterImage:()=>Ok,agxToneMapping:()=>eM,all:()=>lv,alphaT:()=>h_,anaglyphPass:()=>FA,anamorphic:()=>Rk,and:()=>J_,anisotropy:()=>g_,anisotropyB:()=>v_,anisotropyT:()=>__,any:()=>uv,ao:()=>rA,append:()=>Og,arrayBuffer:()=>Wg,asin:()=>Dv,assign:()=>N_,atan:()=>kv,atan2:()=>Uv,atomicAdd:()=>yM,atomicAnd:()=>CM,atomicFunc:()=>_M,atomicMax:()=>xM,atomicMin:()=>SM,atomicOr:()=>wM,atomicStore:()=>vM,atomicSub:()=>bM,atomicXor:()=>TM,attenuationColor:()=>A_,attenuationDistance:()=>k_,attribute:()=>lb,backgroundBlurriness:()=>ZO,backgroundIntensity:()=>QO,batch:()=>ZS,billboarding:()=>Aj,bitAnd:()=>Q_,bitNot:()=>$_,bitOr:()=>ev,bitXor:()=>tv,bitangentGeometry:()=>Lx,bitangentLocal:()=>Rx,bitangentView:()=>zx,bitangentWorld:()=>Bx,bitcast:()=>Vv,bleach:()=>Hj,bloom:()=>_A,blur:()=>JT,bool:()=>Ag,buffer:()=>yx,bufferAttribute:()=>Hy,bumpMap:()=>$x,burn:()=>Lj,bvec2:()=>Ng,bvec3:()=>Ig,bvec4:()=>zg,bypass:()=>Zy,cache:()=>Yy,call:()=>F_,cameraFar:()=>bb,cameraLogDepth:()=>xb,cameraNear:()=>yb,cameraNormalMatrix:()=>Eb,cameraPosition:()=>Db,cameraProjectionMatrix:()=>Sb,cameraProjectionMatrixInverse:()=>Cb,cameraViewMatrix:()=>wb,cameraWorldMatrix:()=>Tb,cbrt:()=>iy,ceil:()=>xv,checker:()=>EM,cineonToneMapping:()=>Jj,clamp:()=>sy,clearcoat:()=>c_,clearcoatRoughness:()=>l_,code:()=>qE,color:()=>kg,colorSpaceToWorking:()=>My,colorToDirection:()=>dw,compute:()=>qy,cond:()=>gy,context:()=>vy,convert:()=>Kg,convertToTexture:()=>GO,cos:()=>Tv,createCanvasElement:()=>hn,cross:()=>Qv,cubeTexture:()=>_x,dFdx:()=>Fv,dFdy:()=>Iv,dashSize:()=>C_,defaultBuildStages:()=>Nh,defaultShaderStages:()=>Mh,defined:()=>bg,degrees:()=>pv,denoise:()=>sA,densityFog:()=>QA,depth:()=>YC,depthPass:()=>bk,difference:()=>Xv,diffuseColor:()=>i_,directionToColor:()=>uw,dispersion:()=>j_,distance:()=>Yv,div:()=>B_,dodge:()=>Rj,dof:()=>Hk,dot:()=>Zv,dotScreen:()=>Wk,drawIndex:()=>qS,dynamicBufferAttribute:()=>Uy,element:()=>Gg,emissive:()=>a_,equal:()=>H_,equals:()=>dv,equirectUV:()=>hw,exp:()=>mv,exp2:()=>hv,expression:()=>nb,faceDirection:()=>ex,faceForward:()=>dy,film:()=>Jk,float:()=>G,floor:()=>bv,fog:()=>JA,fract:()=>Cv,frameGroup:()=>Zg,frameId:()=>uO,frontFacing:()=>$b,fwidth:()=>Bv,fxaa:()=>lA,gain:()=>Sj,gapSize:()=>w_,gaussianBlur:()=>wk,getColorSpaceMethod:()=>Dy,getConstNodeType:()=>xg,getCurrentStack:()=>Dg,getDirection:()=>WT,getDistanceAttenuation:()=>pj,getGeometryRoughness:()=>zw,getRoughness:()=>Bw,getShIrradianceAt:()=>jN,getTextureIndex:()=>eO,global:()=>WA,glsl:()=>XE,glslFn:()=>$E,grayscale:()=>kk,greaterThan:()=>G_,greaterThanEqual:()=>q_,hash:()=>bj,highPrecisionModelNormalViewMatrix:()=>Wb,highPrecisionModelViewMatrix:()=>Ub,hue:()=>Mk,instance:()=>YS,instanceIndex:()=>US,instancedBufferAttribute:()=>Wy,instancedDynamicBufferAttribute:()=>Gy,int:()=>K,inverseSqrt:()=>yv,invocationLocalIndex:()=>KS,invocationSubgroupIndex:()=>GS,ior:()=>E_,iridescence:()=>f_,iridescenceIOR:()=>p_,iridescenceThickness:()=>m_,ivec2:()=>jg,ivec3:()=>Pg,ivec4:()=>Lg,js:()=>JE,label:()=>yy,length:()=>Mv,lengthSq:()=>ay,lessThan:()=>W_,lessThanEqual:()=>K_,lightPosition:()=>gj,lightTargetDirection:()=>yj,lightTargetPosition:()=>_j,lightViewPosition:()=>vj,lightingContext:()=>xC,lights:()=>_C,linearDepth:()=>XC,linearSRGBTosRGB:()=>Gj,linearToneMapping:()=>Kj,localId:()=>oM,log:()=>gv,log2:()=>_v,loop:()=>oC,luminance:()=>Pk,lut3D:()=>Xk,mat2:()=>Bg,mat3:()=>Vg,mat4:()=>Hg,matcapUV:()=>vE,materialAOMap:()=>LS,materialAlphaTest:()=>tS,materialAnisotropy:()=>bS,materialAnisotropyVector:()=>RS,materialAttenuationColor:()=>OS,materialAttenuationDistance:()=>DS,materialClearcoat:()=>mS,materialClearcoatNormal:()=>gS,materialClearcoatRoughness:()=>hS,materialColor:()=>nS,materialDispersion:()=>FS,materialEmissive:()=>iS,materialIOR:()=>ES,materialIridescence:()=>xS,materialIridescenceIOR:()=>SS,materialIridescenceThickness:()=>CS,materialLightMap:()=>IS,materialLineDashOffset:()=>NS,materialLineDashSize:()=>AS,materialLineGapSize:()=>jS,materialLineScale:()=>kS,materialLineWidth:()=>MS,materialMetalness:()=>fS,materialNormal:()=>pS,materialOpacity:()=>aS,materialPointWidth:()=>PS,materialReference:()=>kx,materialReflectivity:()=>uS,materialRefractionRatio:()=>dx,materialRotation:()=>_S,materialRoughness:()=>dS,materialSheen:()=>vS,materialSheenRoughness:()=>yS,materialShininess:()=>rS,materialSpecular:()=>oS,materialSpecularColor:()=>cS,materialSpecularIntensity:()=>sS,materialSpecularStrength:()=>lS,materialThickness:()=>TS,materialTransmission:()=>wS,max:()=>Gv,maxMipLevel:()=>mb,metalness:()=>s_,min:()=>Wv,mix:()=>oy,mixElement:()=>py,mod:()=>Kv,modInt:()=>V_,modelDirection:()=>Fb,modelNormalMatrix:()=>Bb,modelPosition:()=>Lb,modelScale:()=>Rb,modelViewMatrix:()=>Hb,modelViewPosition:()=>zb,modelViewProjection:()=>BS,modelWorldMatrix:()=>Ib,modelWorldMatrixInverse:()=>Vb,morphReference:()=>fC,motionBlur:()=>Vj,mrt:()=>nO,mul:()=>z_,mx_aastep:()=>uN,mx_cell_noise_float:()=>EN,mx_contrast:()=>yN,mx_fractal_noise_float:()=>DN,mx_fractal_noise_vec2:()=>ON,mx_fractal_noise_vec3:()=>kN,mx_fractal_noise_vec4:()=>AN,mx_hsvtorgb:()=>sN,mx_noise_float:()=>bN,mx_noise_vec3:()=>xN,mx_noise_vec4:()=>SN,mx_ramplr:()=>fN,mx_ramptb:()=>pN,mx_rgbtohsv:()=>cN,mx_safepower:()=>vN,mx_splitlr:()=>hN,mx_splittb:()=>gN,mx_srgb_texture_to_lin_rec709:()=>lN,mx_transform_uv:()=>_N,mx_worley_noise_float:()=>CN,mx_worley_noise_vec2:()=>wN,mx_worley_noise_vec3:()=>TN,negate:()=>Nv,neutralToneMapping:()=>tM,nodeArray:()=>wg,nodeImmutable:()=>H,nodeObject:()=>B,nodeObjects:()=>Cg,nodeProxy:()=>V,normalFlat:()=>rx,normalGeometry:()=>tx,normalLocal:()=>nx,normalMap:()=>Yx,normalView:()=>ix,normalWorld:()=>ax,normalize:()=>Sv,not:()=>X_,notEqual:()=>U_,numWorkgroups:()=>iM,objectDirection:()=>kb,objectGroup:()=>$g,objectPosition:()=>jb,objectScale:()=>Mb,objectViewPosition:()=>Nb,objectWorldMatrix:()=>Ab,oneMinus:()=>Pv,or:()=>Y_,orthographicDepthToViewZ:()=>GC,oscSawtooth:()=>hO,oscSine:()=>fO,oscSquare:()=>pO,oscTriangle:()=>mO,output:()=>S_,outputStruct:()=>$D,overlay:()=>Bj,overloadingFn:()=>aO,parabola:()=>xj,parallaxBarrierPass:()=>LA,parallaxDirection:()=>Wx,parallaxUV:()=>Gx,parameter:()=>GE,pass:()=>vk,passTexture:()=>yk,pcurve:()=>Cj,perspectiveDepthToViewZ:()=>qC,pixelationPass:()=>CA,pmremTexture:()=>nE,pointUV:()=>YO,pointWidth:()=>T_,positionGeometry:()=>Gb,positionLocal:()=>Kb,positionPrevious:()=>qb,positionView:()=>Xb,positionViewDirection:()=>Zb,positionWorld:()=>Jb,positionWorldDirection:()=>Yb,posterize:()=>uk,pow:()=>$v,pow2:()=>ey,pow3:()=>ty,pow4:()=>ny,property:()=>n_,radians:()=>fv,rand:()=>fy,range:()=>nj,rangeFog:()=>XA,reciprocal:()=>Rv,reference:()=>Ex,referenceBuffer:()=>Dx,reflect:()=>Jv,reflectVector:()=>mx,reflectView:()=>fx,reflector:()=>RO,refract:()=>ly,refractVector:()=>hx,refractView:()=>px,reinhardToneMapping:()=>qj,remainder:()=>iv,remap:()=>$y,remapClamp:()=>eb,renderGroup:()=>Qg,renderOutput:()=>ob,rendererReference:()=>Ly,rgbShift:()=>Kk,rotate:()=>wE,rotateUV:()=>Oj,roughness:()=>o_,round:()=>Lv,rtt:()=>WO,sRGBToLinearSRGB:()=>Wj,sampler:()=>vb,saturate:()=>cy,saturation:()=>Ak,screen:()=>zj,screenCoordinate:()=>OC,screenSize:()=>DC,screenUV:()=>EC,scriptable:()=>KA,scriptableValue:()=>VA,select:()=>hy,sepia:()=>Uj,setCurrentStack:()=>Eg,shaderStages:()=>Ph,sharedUniformGroup:()=>Xg,sheen:()=>u_,sheenRoughness:()=>d_,shiftLeft:()=>nv,shiftRight:()=>rv,shininess:()=>x_,sign:()=>jv,sin:()=>wv,sinc:()=>wj,skinning:()=>eC,skinningReference:()=>tC,smoothstep:()=>uy,smoothstepElement:()=>my,sobel:()=>Bk,specularColor:()=>y_,specularF90:()=>b_,spherizeUV:()=>kj,split:()=>qg,spritesheetUV:()=>_O,sqrt:()=>vv,ssaaPass:()=>DA,stack:()=>_D,step:()=>qv,stereoPass:()=>AA,storage:()=>nk,storageBarrier:()=>uM,storageObject:()=>rk,storageTexture:()=>ak,string:()=>Ug,sub:()=>R_,subgroupIndex:()=>WS,subgroupSize:()=>sM,tan:()=>Ev,tangentGeometry:()=>Ax,tangentLocal:()=>jx,tangentView:()=>Mx,tangentWorld:()=>Nx,temp:()=>xy,texture:()=>gb,texture3D:()=>ME,textureBarrier:()=>dM,textureBicubic:()=>pT,textureCubeUV:()=>GT,textureLoad:()=>_b,textureSize:()=>fb,textureStore:()=>ok,thickness:()=>O_,threshold:()=>Fk,timerDelta:()=>lO,timerGlobal:()=>cO,timerLocal:()=>sO,toOutputColorSpace:()=>ky,toWorkingColorSpace:()=>Ay,toneMapping:()=>zy,toneMappingExposure:()=>By,toonOutlinePass:()=>zA,transformDirection:()=>ry,transformNormal:()=>lx,transformNormalToView:()=>ux,transformedBentNormalView:()=>Kx,transformedBitangentView:()=>Vx,transformedBitangentWorld:()=>Hx,transformedClearcoatNormalView:()=>cx,transformedNormalView:()=>ox,transformedNormalWorld:()=>sx,transformedTangentView:()=>Px,transformedTangentWorld:()=>Fx,transition:()=>yA,transmission:()=>D_,transpose:()=>Hv,tri:()=>Tj,tri3:()=>Ej,triNoise3D:()=>Dj,triplanarTexture:()=>SO,triplanarTextures:()=>xO,trunc:()=>zv,tslFn:()=>Tg,uint:()=>q,uniform:()=>Z,uniformArray:()=>Sx,uniformGroup:()=>Yg,uniforms:()=>Cx,userData:()=>ck,uv:()=>ub,uvec2:()=>Mg,uvec3:()=>Fg,uvec4:()=>Rg,varying:()=>Cy,varyingProperty:()=>r_,vec2:()=>J,vec3:()=>Y,vec4:()=>X,vectorComponents:()=>Fh,velocity:()=>Ij,vertexColor:()=>qO,vertexIndex:()=>HS,vibrance:()=>jk,viewZToOrthographicDepth:()=>WC,viewZToPerspectiveDepth:()=>KC,viewport:()=>kC,viewportBottomLeft:()=>FC,viewportCoordinate:()=>jC,viewportDepthTexture:()=>HC,viewportLinearDepth:()=>ZC,viewportMipTexture:()=>zC,viewportResolution:()=>NC,viewportSafeUV:()=>jj,viewportSharedTexture:()=>pk,viewportSize:()=>AC,viewportTexture:()=>RC,viewportTopLeft:()=>PC,viewportUV:()=>MC,wgsl:()=>YE,wgslFn:()=>eD,workgroupArray:()=>mM,workgroupBarrier:()=>lM,workgroupId:()=>aM,workingToColorSpace:()=>jy,xor:()=>Z_}),n=`169.19`,r={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},a=`attached`,o=`detached`,s=1e3,c=1001,l=1002,u=1003,d=1004,f=1004,p=1005,m=1005,h=1006,g=1007,_=1007,v=1008,y=1008,b=1009,x=1010,S=1011,C=1012,w=1013,T=1014,E=1015,D=1016,ee=1017,O=1018,te=1020,ne=35902,re=35899,ie=1021,ae=1022,oe=1023,se=1024,ce=1025,le=1026,ue=1027,de=1028,fe=1029,pe=1030,me=1031,he=1032,ge=1033,_e=33776,ve=33777,ye=33778,be=33779,xe=35840,Se=35841,k=35842,Ce=35843,we=36196,Te=37492,Ee=37496,De=37808,Oe=37809,ke=37810,Ae=37811,je=37812,Me=37813,Ne=37814,Pe=37815,Fe=37816,Ie=37817,Le=37818,Re=37819,ze=37820,Be=37821,Ve=36492,He=36494,Ue=36495,We=36283,Ge=36284,Ke=36285,qe=36286,Je=2200,Ye=2201,Xe=2202,Ze=2300,Qe=2301,$e=2302,et=2400,tt=2401,nt=2402,rt=2500,it=2501,at=3200,ot=3201,st=3202,ct=3203,lt=`srgb`,ut=`srgb-linear`,dt=`display-p3`,ft=`display-p3-linear`,pt=`linear`,mt=`srgb`,ht=`rec709`,gt=7680,_t=7681,vt=7682,yt=7683,bt=34055,xt=34056,St=5386,Ct=35044,wt=35048,Tt=35040,Et=35045,Dt=35049,Ot=35041,kt=35046,At=35050,jt=35042,Mt=`300 es`,Nt=2e3,Pt=2001,Ft=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}},It=`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`.split(`.`),Lt=1234567,Rt=Math.PI/180,zt=180/Math.PI;function Bt(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(It[e&255]+It[e>>8&255]+It[e>>16&255]+It[e>>24&255]+`-`+It[t&255]+It[t>>8&255]+`-`+It[t>>16&15|64]+It[t>>24&255]+`-`+It[n&63|128]+It[n>>8&255]+`-`+It[n>>16&255]+It[n>>24&255]+It[r&255]+It[r>>8&255]+It[r>>16&255]+It[r>>24&255]).toLowerCase()}function Vt(e,t,n){return Math.max(t,Math.min(n,e))}function Ht(e,t){return(e%t+t)%t}function Ut(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Wt(e,t,n){return e===t?0:(n-e)/(t-e)}function Gt(e,t,n){return(1-n)*e+n*t}function Kt(e,t,n,r){return Gt(e,t,1-Math.exp(-n*r))}function qt(e,t=1){return t-Math.abs(Ht(e,t*2)-t)}function Jt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Yt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Xt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Zt(e,t){return e+Math.random()*(t-e)}function Qt(e){return e*(.5-Math.random())}function $t(e){e!==void 0&&(Lt=e);let t=Lt+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function en(e){return e*Rt}function tn(e){return e*zt}function nn(e){return(e&e-1)==0&&e!==0}function rn(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function an(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function on(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function sn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function cn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var ln={DEG2RAD:Rt,RAD2DEG:zt,generateUUID:Bt,clamp:Vt,euclideanModulo:Ht,mapLinear:Ut,inverseLerp:Wt,lerp:Gt,damp:Kt,pingpong:qt,smoothstep:Jt,smootherstep:Yt,randInt:Xt,randFloat:Zt,randFloatSpread:Qt,seededRandom:$t,degToRad:en,radToDeg:tn,isPowerOfTwo:nn,ceilPowerOfTwo:rn,floorPowerOfTwo:an,setQuaternionFromProperEuler:on,normalize:cn,denormalize:sn},A=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Vt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},j=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(un.makeScale(e,t)),this}rotate(e){return this.premultiply(un.makeRotation(-e)),this}translate(e,t){return this.premultiply(un.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},un=new j;function dn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var fn={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function pn(e,t){return new fn[e](t)}function mn(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function hn(){let e=mn(`canvas`);return e.style.display=`block`,e}var gn={};function _n(e){e in gn||(gn[e]=!0,console.warn(e))}function vn(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}function yn(e){let t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function bn(e){let t=e.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}var xn=new j().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Sn=new j().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Cn={[ut]:{transfer:pt,primaries:ht,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e,fromReference:e=>e},[lt]:{transfer:mt,primaries:ht,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[ft]:{transfer:pt,primaries:`p3`,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.applyMatrix3(Sn),fromReference:e=>e.applyMatrix3(xn)},[dt]:{transfer:mt,primaries:`p3`,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.convertSRGBToLinear().applyMatrix3(Sn),fromReference:e=>e.applyMatrix3(xn).convertLinearToSRGB()}},wn=new Set([ut,ft]),Tn={enabled:!0,_workingColorSpace:ut,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!wn.has(e))throw Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(this.enabled===!1||t===n||!t||!n)return e;let r=Cn[t].toReference,i=Cn[n].fromReference;return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return Cn[e].primaries},getTransfer:function(e){return e===``?pt:Cn[e].transfer},getLuminanceCoefficients:function(e,t=this._workingColorSpace){return e.fromArray(Cn[t].luminanceCoefficients)}};function En(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Dn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var On,kn=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{On===void 0&&(On=mn(`canvas`)),On.width=e.width,On.height=e.height;let n=On.getContext(`2d`);e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=On}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=mn(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=En(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(En(t[e]/255)*255):t[e]=En(t[e]);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}},An=0,jn=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:An++}),this.uuid=Bt(),this.data=e,this.dataReady=!0,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 n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Mn(r[t].image)):e.push(Mn(r[t]))}else e=Mn(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Mn(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?kn.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}var Nn=0,Pn=class e extends Ft{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=c,i=c,a=h,o=v,s=oe,l=b,u=e.DEFAULT_ANISOTROPY,d=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:Nn++}),this.uuid=Bt(),this.name=``,this.source=new jn(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=s,this.internalFormat=null,this.type=l,this.offset=new A(0,0),this.repeat=new A(1,1),this.center=new A(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new j,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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 n={metadata:{version:4.6,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case s:e.x-=Math.floor(e.x);break;case c:e.x=e.x<0?0:1;break;case l:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case s:e.y-=Math.floor(e.y);break;case c:e.y=e.y<0?0:1;break;case l:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Pn.DEFAULT_IMAGE=null,Pn.DEFAULT_MAPPING=300,Pn.DEFAULT_ANISOTROPY=4;var Fn=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},In=class extends Ft{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Fn(0,0,e,t),this.scissorTest=!1,this.viewport=new Fn(0,0,e,t);let r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:h,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let i=new Pn(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);i.flipY=!1,i.generateMipmaps=n.generateMipmaps,i.internalFormat=n.internalFormat,this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++)this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new jn(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},Ln=class extends In{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Rn=class extends Pn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=u,this.minFilter=u,this.wrapR=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},zn=class extends Ln{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Rn(null,e,t,n),this.texture.isRenderTargetTexture=!0}},Bn=class extends Pn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=u,this.minFilter=u,this.wrapR=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Vn=class extends Ln{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Bn(null,e,t,n),this.texture.isRenderTargetTexture=!0}},Hn=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Vt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},M=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wn.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Un.copy(this).projectOnVector(e),this.sub(Un)}reflect(e){return this.sub(Un.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Vt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Un=new M,Wn=new Hn,Gn=class{constructor(e=new M(1/0,1/0,1/0),t=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(qn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=qn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,qn):qn.fromBufferAttribute(r,t),qn.applyMatrix4(e.matrixWorld),this.expandByPoint(qn);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),Jn.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Jn.copy(e.boundingBox)),Jn.applyMatrix4(e.matrixWorld),this.union(Jn)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],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,qn),qn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(tr),nr.subVectors(this.max,tr),Yn.subVectors(e.a,tr),Xn.subVectors(e.b,tr),Zn.subVectors(e.c,tr),Qn.subVectors(Xn,Yn),$n.subVectors(Zn,Xn),er.subVectors(Yn,Zn);let t=[0,-Qn.z,Qn.y,0,-$n.z,$n.y,0,-er.z,er.y,Qn.z,0,-Qn.x,$n.z,0,-$n.x,er.z,0,-er.x,-Qn.y,Qn.x,0,-$n.y,$n.x,0,-er.y,er.x,0];return!ar(t,Yn,Xn,Zn,nr)||(t=[1,0,0,0,1,0,0,0,1],!ar(t,Yn,Xn,Zn,nr))?!1:(rr.crossVectors(Qn,$n),t=[rr.x,rr.y,rr.z],ar(t,Yn,Xn,Zn,nr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qn).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:(Kn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Kn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Kn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Kn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Kn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Kn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Kn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Kn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Kn),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)}},Kn=[new M,new M,new M,new M,new M,new M,new M,new M],qn=new M,Jn=new Gn,Yn=new M,Xn=new M,Zn=new M,Qn=new M,$n=new M,er=new M,tr=new M,nr=new M,rr=new M,ir=new M;function ar(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){ir.fromArray(e,a);let o=i.x*Math.abs(ir.x)+i.y*Math.abs(ir.y)+i.z*Math.abs(ir.z),s=t.dot(ir),c=n.dot(ir),l=r.dot(ir);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var or=new Gn,sr=new M,cr=new M,lr=class{constructor(e=new M,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?or.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));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 n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=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;sr.subVectors(e,this.center);let t=sr.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(sr,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(cr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(sr.copy(e.center).add(cr)),this.expandByPoint(sr.copy(e.center).sub(cr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},ur=new M,dr=new M,fr=new M,pr=new M,mr=new M,hr=new M,gr=new M,_r=class{constructor(e=new M,t=new M(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,ur)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ur.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ur.copy(this.origin).addScaledVector(this.direction,t),ur.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){dr.copy(e).add(t).multiplyScalar(.5),fr.copy(t).sub(e).normalize(),pr.copy(this.origin).sub(dr);let i=e.distanceTo(t)*.5,a=-this.direction.dot(fr),o=pr.dot(this.direction),s=-pr.dot(fr),c=pr.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(dr).addScaledVector(fr,d),f}intersectSphere(e,t){ur.subVectors(e.center,this.origin);let n=ur.dot(this.direction),r=ur.dot(ur)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ur)!==null}intersectTriangle(e,t,n,r,i){mr.subVectors(t,e),hr.subVectors(n,e),gr.crossVectors(mr,hr);let a=this.direction.dot(gr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;pr.subVectors(this.origin,e);let s=o*this.direction.dot(hr.crossVectors(pr,hr));if(s<0)return null;let c=o*this.direction.dot(mr.cross(pr));if(c<0||s+c>a)return null;let l=-o*pr.dot(gr);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},N=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/vr.setFromMatrixColumn(e,0).length(),i=1/vr.setFromMatrixColumn(e,1).length(),a=1/vr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(br,e,xr)}lookAt(e,t,n){let r=this.elements;return wr.subVectors(e,t),wr.lengthSq()===0&&(wr.z=1),wr.normalize(),Sr.crossVectors(n,wr),Sr.lengthSq()===0&&(Math.abs(n.z)===1?wr.x+=1e-4:wr.z+=1e-4,wr.normalize(),Sr.crossVectors(n,wr)),Sr.normalize(),Cr.crossVectors(wr,Sr),r[0]=Sr.x,r[4]=Cr.x,r[8]=wr.x,r[1]=Sr.y,r[5]=Cr.y,r[9]=wr.y,r[2]=Sr.z,r[6]=Cr.z,r[10]=wr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],ee=r[13],O=r[2],te=r[6],ne=r[10],re=r[14],ie=r[3],ae=r[7],oe=r[11],se=r[15];return i[0]=a*x+o*T+s*O+c*ie,i[4]=a*S+o*E+s*te+c*ae,i[8]=a*C+o*D+s*ne+c*oe,i[12]=a*w+o*ee+s*re+c*se,i[1]=l*x+u*T+d*O+f*ie,i[5]=l*S+u*E+d*te+f*ae,i[9]=l*C+u*D+d*ne+f*oe,i[13]=l*w+u*ee+d*re+f*se,i[2]=p*x+m*T+h*O+g*ie,i[6]=p*S+m*E+h*te+g*ae,i[10]=p*C+m*D+h*ne+g*oe,i[14]=p*w+m*ee+h*re+g*se,i[3]=_*x+v*T+y*O+b*ie,i[7]=_*S+v*E+y*te+b*ae,i[11]=_*C+v*D+y*ne+b*oe,i[15]=_*w+v*ee+y*re+b*se,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=vr.set(r[0],r[1],r[2]).length(),a=vr.set(r[4],r[5],r[6]).length(),o=vr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],yr.copy(this);let s=1/i,c=1/a,l=1/o;return yr.elements[0]*=s,yr.elements[1]*=s,yr.elements[2]*=s,yr.elements[4]*=c,yr.elements[5]*=c,yr.elements[6]*=c,yr.elements[8]*=l,yr.elements[9]*=l,yr.elements[10]*=l,t.setFromRotationMatrix(yr),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Nt){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===2e3)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===2001)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Nt){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===2e3)p=(a+i)*u,m=-2*u;else if(o===2001)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},vr=new M,yr=new N,br=new M(0,0,0),xr=new M(1,1,1),Sr=new M,Cr=new M,wr=new M,Tr=new N,Er=new Hn,Dr=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(Vt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-Vt(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(Vt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-Vt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(Vt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-Vt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Tr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Tr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Er.setFromEuler(this),this.setFromQuaternion(Er,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}};Dr.DEFAULT_ORDER=`XYZ`;var Or=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}},kr=0,Ar=new M,jr=new Hn,Mr=new N,Nr=new M,Pr=new M,Fr=new M,Ir=new Hn,Lr=new M(1,0,0),Rr=new M(0,1,0),zr=new M(0,0,1),Br={type:`added`},Vr={type:`removed`},Hr={type:`childadded`,child:null},Ur={type:`childremoved`,child:null},Wr=class e extends Ft{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:kr++}),this.uuid=Bt(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new M,n=new Dr,r=new Hn,i=new M(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new N},normalMatrix:{value:new j}}),this.matrix=new N,this.matrixWorld=new N,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Or,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 jr.setFromAxisAngle(e,t),this.quaternion.multiply(jr),this}rotateOnWorldAxis(e,t){return jr.setFromAxisAngle(e,t),this.quaternion.premultiply(jr),this}rotateX(e){return this.rotateOnAxis(Lr,e)}rotateY(e){return this.rotateOnAxis(Rr,e)}rotateZ(e){return this.rotateOnAxis(zr,e)}translateOnAxis(e,t){return Ar.copy(e).applyQuaternion(this.quaternion),this.position.add(Ar.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Lr,e)}translateY(e){return this.translateOnAxis(Rr,e)}translateZ(e){return this.translateOnAxis(zr,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Mr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Nr.copy(e):Nr.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Pr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mr.lookAt(Pr,Nr,this.up):Mr.lookAt(Nr,Pr,this.up),this.quaternion.setFromRotationMatrix(Mr),r&&(Mr.extractRotation(r.matrixWorld),jr.setFromRotationMatrix(Mr),this.quaternion.premultiply(jr.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);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.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Br),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Vr),Ur.child=e,this.dispatchEvent(Ur),Ur.child=null),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),Mr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Mr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Mr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Br),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pr,e,Fr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pr,Ir,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 n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].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.matrixWorldAutoUpdate===!0&&(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 n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:`Object`,generator:`Object3D.toJSON`});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(e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Wr.DEFAULT_UP=new M(0,1,0),Wr.DEFAULT_MATRIX_AUTO_UPDATE=!0,Wr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Gr=new M,Kr=new M,qr=new M,Jr=new M,Yr=new M,Xr=new M,Zr=new M,Qr=new M,$r=new M,ei=new M,ti=new Fn,ni=new Fn,ri=new Fn,ii=class e{constructor(e=new M,t=new M,n=new M){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Gr.subVectors(e,t),r.cross(Gr);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Gr.subVectors(r,t),Kr.subVectors(n,t),qr.subVectors(e,t);let a=Gr.dot(Gr),o=Gr.dot(Kr),s=Gr.dot(qr),c=Kr.dot(Kr),l=Kr.dot(qr),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Jr)===null?!1:Jr.x>=0&&Jr.y>=0&&Jr.x+Jr.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Jr)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Jr.x),s.addScaledVector(a,Jr.y),s.addScaledVector(o,Jr.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ti.setScalar(0),ni.setScalar(0),ri.setScalar(0),ti.fromBufferAttribute(e,t),ni.fromBufferAttribute(e,n),ri.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ti,i.x),a.addScaledVector(ni,i.y),a.addScaledVector(ri,i.z),a}static isFrontFacing(e,t,n,r){return Gr.subVectors(n,t),Kr.subVectors(e,t),Gr.cross(Kr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Gr.subVectors(this.c,this.b),Kr.subVectors(this.a,this.b),Gr.cross(Kr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Yr.subVectors(r,n),Xr.subVectors(i,n),Qr.subVectors(e,n);let s=Yr.dot(Qr),c=Xr.dot(Qr);if(s<=0&&c<=0)return t.copy(n);$r.subVectors(e,r);let l=Yr.dot($r),u=Xr.dot($r);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Yr,a);ei.subVectors(e,i);let f=Yr.dot(ei),p=Xr.dot(ei);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Xr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Zr.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Zr,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Yr,a).addScaledVector(Xr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ai={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},oi={h:0,s:0,l:0},si={h:0,s:0,l:0};function ci(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var P=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Tn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Tn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Tn.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Tn.workingColorSpace){if(e=Ht(e,1),t=Vt(t,0,1),n=Vt(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=ci(i,r,e+1/3),this.g=ci(i,r,e),this.b=ci(i,r,e-1/3)}return Tn.toWorkingColorSpace(this,r),this}setStyle(e,t=lt){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=lt){let n=ai[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=En(e.r),this.g=En(e.g),this.b=En(e.b),this}copyLinearToSRGB(e){return this.r=Dn(e.r),this.g=Dn(e.g),this.b=Dn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=lt){return Tn.fromWorkingColorSpace(li.copy(this),e),Math.round(Vt(li.r*255,0,255))*65536+Math.round(Vt(li.g*255,0,255))*256+Math.round(Vt(li.b*255,0,255))}getHexString(e=lt){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Tn.workingColorSpace){Tn.fromWorkingColorSpace(li.copy(this),t);let n=li.r,r=li.g,i=li.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Tn.workingColorSpace){return Tn.fromWorkingColorSpace(li.copy(this),t),e.r=li.r,e.g=li.g,e.b=li.b,e}getStyle(e=lt){Tn.fromWorkingColorSpace(li.copy(this),e);let t=li.r,n=li.g,r=li.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(oi),this.setHSL(oi.h+e,oi.s+t,oi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(oi),e.getHSL(si);let n=Gt(oi.h,si.h,t),r=Gt(oi.s,si.s,t),i=Gt(oi.l,si.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[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}},li=new P;P.NAMES=ai;var ui=0,di=class extends Ft{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:ui++}),this.uuid=Bt(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new P(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gt,this.stencilZFail=gt,this.stencilZPass=gt,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 n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},fi=class extends di{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new P(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},pi=mi();function mi(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function hi(e){Math.abs(e)>65504&&console.warn(`THREE.DataUtils.toHalfFloat(): Value out of range.`),e=Vt(e,-65504,65504),pi.floatView[0]=e;let t=pi.uint32View[0],n=t>>23&511;return pi.baseTable[n]+((t&8388607)>>pi.shiftTable[n])}function gi(e){let t=e>>10;return pi.uint32View[0]=pi.mantissaTable[pi.offsetTable[t]+(e&1023)]+pi.exponentTable[t],pi.floatView[0]}var _i={toHalfFloat:hi,fromHalfFloat:gi},vi=new M,yi=new A,bi=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Ct,this.updateRanges=[],this.gpuType=E,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)yi.fromBufferAttribute(this,t),yi.applyMatrix3(e),this.setXY(t,yi.x,yi.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)vi.fromBufferAttribute(this,t),vi.applyMatrix3(e),this.setXYZ(t,vi.x,vi.y,vi.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)vi.fromBufferAttribute(this,t),vi.applyMatrix4(e),this.setXYZ(t,vi.x,vi.y,vi.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)vi.fromBufferAttribute(this,t),vi.applyNormalMatrix(e),this.setXYZ(t,vi.x,vi.y,vi.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)vi.fromBufferAttribute(this,t),vi.transformDirection(e),this.setXYZ(t,vi.x,vi.y,vi.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=sn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cn(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=cn(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=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cn(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=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array),i=cn(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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!==35044&&(e.usage=this.usage),e}},xi=class extends bi{constructor(e,t,n){super(new Int8Array(e),t,n)}},Si=class extends bi{constructor(e,t,n){super(new Uint8Array(e),t,n)}},Ci=class extends bi{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},wi=class extends bi{constructor(e,t,n){super(new Int16Array(e),t,n)}},Ti=class extends bi{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Ei=class extends bi{constructor(e,t,n){super(new Int32Array(e),t,n)}},Di=class extends bi{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Oi=class extends bi{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=gi(this.array[e*this.itemSize]);return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize]=hi(t),this}getY(e){let t=gi(this.array[e*this.itemSize+1]);return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize+1]=hi(t),this}getZ(e){let t=gi(this.array[e*this.itemSize+2]);return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize+2]=hi(t),this}getW(e){let t=gi(this.array[e*this.itemSize+3]);return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=cn(t,this.array)),this.array[e*this.itemSize+3]=hi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array)),this.array[e+0]=hi(t),this.array[e+1]=hi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array)),this.array[e+0]=hi(t),this.array[e+1]=hi(n),this.array[e+2]=hi(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array),i=cn(i,this.array)),this.array[e+0]=hi(t),this.array[e+1]=hi(n),this.array[e+2]=hi(r),this.array[e+3]=hi(i),this}},F=class extends bi{constructor(e,t,n){super(new Float32Array(e),t,n)}},ki=0,Ai=new N,ji=new Wr,Mi=new M,Ni=new Gn,Pi=new Gn,Fi=new M,Ii=class e extends Ft{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:ki++}),this.uuid=Bt(),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(dn(e)?Di:Ti)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new j().getNormalMatrix(e);n.applyNormalMatrix(t),n.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 Ai.makeRotationFromQuaternion(e),this.applyMatrix4(Ai),this}rotateX(e){return Ai.makeRotationX(e),this.applyMatrix4(Ai),this}rotateY(e){return Ai.makeRotationY(e),this.applyMatrix4(Ai),this}rotateZ(e){return Ai.makeRotationZ(e),this.applyMatrix4(Ai),this}translate(e,t,n){return Ai.makeTranslation(e,t,n),this.applyMatrix4(Ai),this}scale(e,t,n){return Ai.makeScale(e,t,n),this.applyMatrix4(Ai),this}lookAt(e){return ji.lookAt(e),ji.updateMatrix(),this.applyMatrix4(ji.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mi).negate(),this.translate(Mi.x,Mi.y,Mi.z),this}setFromPoints(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute(`position`,new F(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ni.setFromBufferAttribute(n),this.morphTargetsRelative?(Fi.addVectors(this.boundingBox.min,Ni.min),this.boundingBox.expandByPoint(Fi),Fi.addVectors(this.boundingBox.max,Ni.max),this.boundingBox.expandByPoint(Fi)):(this.boundingBox.expandByPoint(Ni.min),this.boundingBox.expandByPoint(Ni.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 lr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new M,1/0);return}if(e){let n=this.boundingSphere.center;if(Ni.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Pi.setFromBufferAttribute(n),this.morphTargetsRelative?(Fi.addVectors(Ni.min,Pi.min),Ni.expandByPoint(Fi),Fi.addVectors(Ni.max,Pi.max),Ni.expandByPoint(Fi)):(Ni.expandByPoint(Pi.min),Ni.expandByPoint(Pi.max))}Ni.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Fi.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Fi));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Fi.fromBufferAttribute(a,t),o&&(Mi.fromBufferAttribute(e,t),Fi.add(Mi)),r=Math.max(r,n.distanceToSquared(Fi))}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 n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new bi(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new M,s[e]=new M;let c=new M,l=new M,u=new M,d=new A,f=new A,p=new A,m=new M,h=new M;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new M,y=new M,b=new M,x=new M;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new bi(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new M,i=new M,a=new M,o=new M,s=new M,c=new M,l=new M,u=new M;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Fi.fromBufferAttribute(e,t),Fi.normalize(),e.setXYZ(t,Fi.x,Fi.y,Fi.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new bi(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}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 t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Li=new N,Ri=new _r,zi=new lr,Bi=new M,Vi=new M,Hi=new M,Ui=new M,Wi=new M,Gi=new M,Ki=new M,qi=new M,Ji=class extends Wr{constructor(e=new Ii,t=new fi){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 e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Gi.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Wi.fromBufferAttribute(s,e),a?Gi.addScaledVector(Wi,r):Gi.addScaledVector(Wi.sub(t),r))}t.add(Gi)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),zi.copy(n.boundingSphere),zi.applyMatrix4(i),Ri.copy(e.ray).recast(e.near),!(zi.containsPoint(Ri.origin)===!1&&(Ri.intersectSphere(zi,Bi)===null||Ri.origin.distanceToSquared(Bi)>(e.far-e.near)**2))&&(Li.copy(i).invert(),Ri.copy(e.ray).applyMatrix4(Li),!(n.boundingBox!==null&&Ri.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ri)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Xi(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Xi(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Xi(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Xi(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Yi(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;qi.copy(s),qi.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(qi);return l<n.near||l>n.far?null:{distance:l,point:qi.clone(),object:e}}function Xi(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Vi),e.getVertexPosition(c,Hi),e.getVertexPosition(l,Ui);let u=Yi(e,t,n,r,Vi,Hi,Ui,Ki);if(u){let e=new M;ii.getBarycoord(Ki,Vi,Hi,Ui,e),i&&(u.uv=ii.getInterpolatedAttribute(i,s,c,l,e,new A)),a&&(u.uv1=ii.getInterpolatedAttribute(a,s,c,l,e,new A)),o&&(u.normal=ii.getInterpolatedAttribute(o,s,c,l,e,new M),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new M,materialIndex:0};ii.getNormal(Vi,Hi,Ui,t.normal),u.face=t,u.barycoord=e}return u}var Zi=class e extends Ii{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new F(c,3)),this.setAttribute(`normal`,new F(l,3)),this.setAttribute(`uv`,new F(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new M;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function Qi(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function $i(e){let t={};for(let n=0;n<e.length;n++){let r=Qi(e[n]);for(let e in r)t[e]=r[e]}return t}function ea(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function ta(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Tn.workingColorSpace}var na={clone:Qi,merge:$i},ra=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,ia=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,aa=class extends di{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ra,this.fragmentShader=ia,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Qi(e.uniforms),this.uniformsGroups=ea(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 n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}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 n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},oa=new M,sa=new Hn,ca=new M,la=class extends Wr{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new N,this.projectionMatrix=new N,this.projectionMatrixInverse=new N,this.coordinateSystem=Nt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(oa,sa,ca),ca.x===1&&ca.y===1&&ca.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(oa,sa,ca.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(oa,sa,ca),ca.x===1&&ca.y===1&&ca.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(oa,sa,ca.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ua=new M,da=new A,fa=new A,pa=class extends la{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=zt*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Rt*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return zt*2*Math.atan(Math.tan(Rt*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ua.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ua.x,ua.y).multiplyScalar(-e/ua.z),ua.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ua.x,ua.y).multiplyScalar(-e/ua.z)}getViewSize(e,t){return this.getViewBounds(e,da,fa),t.subVectors(fa,da)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Rt*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},ma=-90,ha=1,ga=class extends Wr{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new pa(ma,ha,e,t);r.layers=this.layers,this.add(r);let i=new pa(ma,ha,e,t);i.layers=this.layers,this.add(i);let a=new pa(ma,ha,e,t);a.layers=this.layers,this.add(a);let o=new pa(ma,ha,e,t);o.layers=this.layers,this.add(o);let s=new pa(ma,ha,e,t);s.layers=this.layers,this.add(s);let c=new pa(ma,ha,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,s),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},_a=class extends Pn{constructor(e,t,n,r,i,a,o,s,c,l){e=e===void 0?[]:e,t=t===void 0?301:t,super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},va=class extends Ln{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1};this.texture=new _a([n,n,n,n,n,n],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?!1:t.generateMipmaps,this.texture.minFilter=t.minFilter===void 0?h:t.minFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <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 Zi(5,5,5),i=new aa({name:`CubemapFromEquirect`,uniforms:Qi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Ji(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=h),new ga(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},ya=new M,ba=new M,xa=new j,Sa=class{constructor(e=new M(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=ya.subVectors(n,t).cross(ba.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(ya),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||xa.getNormalMatrix(e),r=this.coplanarPoint(ya).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Ca=new lr,wa=new M,Ta=class{constructor(e=new Sa,t=new Sa,n=new Sa,r=new Sa,i=new Sa,a=new Sa){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Nt){let n=this.planes,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=r[8],p=r[9],m=r[10],h=r[11],g=r[12],_=r[13],v=r[14],y=r[15];if(n[0].setComponents(s-i,d-c,h-f,y-g).normalize(),n[1].setComponents(s+i,d+c,h+f,y+g).normalize(),n[2].setComponents(s+a,d+l,h+p,y+_).normalize(),n[3].setComponents(s-a,d-l,h-p,y-_).normalize(),n[4].setComponents(s-o,d-u,h-m,y-v).normalize(),t===2e3)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===2001)n[5].setComponents(o,u,m,v).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ca.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ca.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ca)}intersectsSprite(e){return Ca.center.set(0,0,0),Ca.radius=.7071067811865476,Ca.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ca)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(wa.x=r.normal.x>0?e.max.x:e.min.x,wa.y=r.normal.y>0?e.max.y:e.min.y,wa.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(wa)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Ea(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Da(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)}function a(n){n.isInterleavedBufferAttribute&&(n=n.data);let r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))}function o(e,i){if(e.isInterleavedBufferAttribute&&(e=e.data),e.isGLBufferAttribute){let n=t.get(e);(!n||n.version<e.version)&&t.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}let a=t.get(e);if(a===void 0)t.set(e,n(e,i));else if(a.version<e.version){if(a.size!==e.array.byteLength)throw Error(`THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.`);r(a.buffer,e,i),a.version=e.version}}return{get:i,remove:a,update:o}}var Oa=class e extends Ii{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new F(p,3)),this.setAttribute(`normal`,new F(m,3)),this.setAttribute(`uv`,new F(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},ka={alphahash_fragment:`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,alphahash_pars_fragment:`#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`,alphamap_fragment:`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,alphamap_pars_fragment:`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,alphatest_fragment:`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
#endif`,alphatest_pars_fragment:`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,aomap_fragment:`#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`,aomap_pars_fragment:`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,batching_pars_vertex:`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
#endif
uniform highp sampler2D batchingTexture;
uniform highp usampler2D batchingIdTexture;
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 );
}
float getIndirectIndex( const in int i ) {
int size = textureSize( batchingIdTexture, 0 ).x;
int x = i % size;
int y = i / size;
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
}
#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec3 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
}
#endif`,batching_vertex:`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,begin_vertex:`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,beginnormal_vertex:`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,bsdfs:`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`,iridescence_fragment:`#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`,bumpmap_pars_fragment:`#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`,clipping_planes_fragment:`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
float clipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
if ( clipOpacity == 0.0 ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
float unionClipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
}
#pragma unroll_loop_end
clipOpacity *= 1.0 - unionClipOpacity;
#endif
diffuseColor.a *= clipOpacity;
if ( diffuseColor.a == 0.0 ) discard;
#else
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,color_fragment:`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,color_pars_fragment:`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,color_pars_vertex:`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,color_vertex:`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
vColor.xyz *= batchingColor.xyz;
#endif`,common:`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
vec3( 0.8224621, 0.177538, 0.0 ),
vec3( 0.0331941, 0.9668058, 0.0 ),
vec3( 0.0170827, 0.0723974, 0.9105199 )
);
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
vec3( 1.2249401, - 0.2249404, 0.0 ),
vec3( - 0.0420569, 1.0420571, 0.0 ),
vec3( - 0.0196376, - 0.0786361, 1.0982735 )
);
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
}
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
}
vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,envmap_fragment:`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,envmap_vertex:`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,fog_vertex:`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,fog_pars_vertex:`#ifdef USE_FOG
varying float vFogDepth;
#endif`,fog_fragment:`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,fog_pars_fragment:`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,lights_lambert_fragment:`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif`,lights_toon_fragment:`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,lights_physical_pars_fragment:`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
float v = 0.5 / ( gv + gl );
return saturate(v);
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColor;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
vec4 r = roughness * c0 + c1;
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
vec2 fab = DFGApprox( normal, viewDir, roughness );
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,lights_fragment_begin:`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,logdepthbuf_fragment:`#if defined( USE_LOGDEPTHBUF )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGDEPTHBUF )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGDEPTHBUF
varying float vFragDepth;
varying float vIsPerspective;
#endif`,logdepthbuf_vertex:`#ifdef USE_LOGDEPTHBUF
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,map_fragment:`#ifdef USE_MAP
#ifdef USE_MIPMAP_BIAS
vec4 sampledDiffuseColor = texture2D( map, vMapUv, mipmapBias );
#else
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#endif
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,map_pars_fragment:`#ifdef USE_MAP
uniform sampler2D map;
#ifdef USE_MIPMAP_BIAS
uniform float mipmapBias;
#endif
#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,metalnessmap_fragment:`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,normal_vertex:`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,opaque_fragment:`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in 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( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * depth - far );
}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,dithering_pars_fragment:`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,roughnessmap_fragment:`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
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 shadowIntensity;
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 shadowIntensity;
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 shadowIntensity, 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 mix( 1.0, shadow, shadowIntensity );
}
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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
float lightToPositionLength = length( lightToPosition );
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
shadow = (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
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 shadowIntensity;
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 shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,shadowmask_pars_fragment:`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,skinbase_vertex:`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
mat4 getBoneMatrix( const in float i ) {
int size = textureSize( boneTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,skinning_vertex:`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,skinnormal_vertex:`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,specularmap_fragment:`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,tonemapping_pars_fragment:`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
vec3( 1.6605, - 0.1246, - 0.0182 ),
vec3( - 0.5876, 1.1329, - 0.1006 ),
vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
vec3( 0.6274, 0.0691, 0.0164 ),
vec3( 0.3293, 0.9195, 0.0880 ),
vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
color *= toneMappingExposure;
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
color = max( color, 1e-10 ); color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
color = agxDefaultContrastApprox( color );
color = AgXOutsetMatrix * color;
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
color = clamp( color, 0.0, 1.0 );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
const float StartCompression = 0.8 - 0.04;
const float Desaturation = 0.15;
color *= toneMappingExposure;
float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max( color.r, max( color.g, color.b ) );
if ( peak < StartCompression ) return color;
float d = 1. - StartCompression;
float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
}
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return vec3( 1.0 );
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec4 transmittedLight;
vec3 transmittance;
#ifdef USE_DISPERSION
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
for ( int i = 0; i < 3; i ++ ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
transmittedLight[ i ] = transmissionSample[ i ];
transmittedLight.a += transmissionSample.a;
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
}
transmittedLight.a /= 3.0;
#else
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
#endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
uniform mat3 mapTransform;
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
uniform mat3 alphaMapTransform;
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
uniform mat3 lightMapTransform;
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
uniform mat3 aoMapTransform;
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
uniform mat3 bumpMapTransform;
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
uniform mat3 normalMapTransform;
varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
uniform mat3 displacementMapTransform;
varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapTransform;
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
uniform mat3 metalnessMapTransform;
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
uniform mat3 roughnessMapTransform;
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
uniform mat3 anisotropyMapTransform;
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
uniform mat3 clearcoatMapTransform;
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform mat3 clearcoatNormalMapTransform;
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform mat3 clearcoatRoughnessMapTransform;
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
uniform mat3 sheenColorMapTransform;
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform mat3 sheenRoughnessMapTransform;
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
uniform mat3 iridescenceMapTransform;
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform mat3 iridescenceThicknessMapTransform;
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
uniform mat3 specularMapTransform;
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
uniform mat3 specularColorMapTransform;
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform mat3 specularIntensityMapTransform;
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
#endif
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`,background_vert:`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,background_frag:`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,cube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,cube_frag:`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,depth_vert:`#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>
#include <morphinstance_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;
}`,depth_frag:`#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() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#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 );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,distanceRGBA_vert:`#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>
#include <morphinstance_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;
}`,distanceRGBA_frag:`#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 () {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#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 );
}`,equirect_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,equirect_frag:`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>
}`,linedashed_vert:`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 <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,linedashed_frag:`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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#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>
}`,meshbasic_vert:`#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 <morphinstance_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>
}`,meshbasic_frag:`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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#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>
}`,meshlambert_vert:`#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 <morphinstance_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>
}`,meshlambert_frag:`#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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
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>
}`,meshmatcap_vert:`#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 <morphinstance_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;
}`,meshmatcap_frag:`#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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#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>
}`,meshnormal_vert:`#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 <morphinstance_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
}`,meshnormal_frag:`#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() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,meshphong_vert:`#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 <morphinstance_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>
}`,meshphong_frag:`#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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
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>
}`,meshphysical_vert:`#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 <morphinstance_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
}`,meshphysical_frag:`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
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>
}`,meshtoon_vert:`#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 <morphinstance_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>
}`,meshtoon_frag:`#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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
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>
}`,points_vert:`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 <morphinstance_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>
}`,points_frag:`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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#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>
}`,shadow_vert:`#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 <morphinstance_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>
}`,shadow_frag:`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>
}`,sprite_vert:`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[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#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>
}`,sprite_frag:`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() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#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>
}`},I={common:{diffuse:{value:new P(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new j},alphaMap:{value:null},alphaMapTransform:{value:new j},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new j}},envmap:{envMap:{value:null},envMapRotation:{value:new j},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new j}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new j}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new j},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new j},normalScale:{value:new A(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new j},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new j}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new j}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new j}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new P(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new P(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new j},alphaTest:{value:0},uvTransform:{value:new j}},sprite:{diffuse:{value:new P(16777215)},opacity:{value:1},center:{value:new A(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new j},alphaMap:{value:null},alphaMapTransform:{value:new j},alphaTest:{value:0}}},Aa={basic:{uniforms:$i([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.fog]),vertexShader:ka.meshbasic_vert,fragmentShader:ka.meshbasic_frag},lambert:{uniforms:$i([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.fog,I.lights,{emissive:{value:new P(0)}}]),vertexShader:ka.meshlambert_vert,fragmentShader:ka.meshlambert_frag},phong:{uniforms:$i([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.fog,I.lights,{emissive:{value:new P(0)},specular:{value:new P(1118481)},shininess:{value:30}}]),vertexShader:ka.meshphong_vert,fragmentShader:ka.meshphong_frag},standard:{uniforms:$i([I.common,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.roughnessmap,I.metalnessmap,I.fog,I.lights,{emissive:{value:new P(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ka.meshphysical_vert,fragmentShader:ka.meshphysical_frag},toon:{uniforms:$i([I.common,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.gradientmap,I.fog,I.lights,{emissive:{value:new P(0)}}]),vertexShader:ka.meshtoon_vert,fragmentShader:ka.meshtoon_frag},matcap:{uniforms:$i([I.common,I.bumpmap,I.normalmap,I.displacementmap,I.fog,{matcap:{value:null}}]),vertexShader:ka.meshmatcap_vert,fragmentShader:ka.meshmatcap_frag},points:{uniforms:$i([I.points,I.fog]),vertexShader:ka.points_vert,fragmentShader:ka.points_frag},dashed:{uniforms:$i([I.common,I.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ka.linedashed_vert,fragmentShader:ka.linedashed_frag},depth:{uniforms:$i([I.common,I.displacementmap]),vertexShader:ka.depth_vert,fragmentShader:ka.depth_frag},normal:{uniforms:$i([I.common,I.bumpmap,I.normalmap,I.displacementmap,{opacity:{value:1}}]),vertexShader:ka.meshnormal_vert,fragmentShader:ka.meshnormal_frag},sprite:{uniforms:$i([I.sprite,I.fog]),vertexShader:ka.sprite_vert,fragmentShader:ka.sprite_frag},background:{uniforms:{uvTransform:{value:new j},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ka.background_vert,fragmentShader:ka.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new j}},vertexShader:ka.backgroundCube_vert,fragmentShader:ka.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ka.cube_vert,fragmentShader:ka.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ka.equirect_vert,fragmentShader:ka.equirect_frag},distanceRGBA:{uniforms:$i([I.common,I.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ka.distanceRGBA_vert,fragmentShader:ka.distanceRGBA_frag},shadow:{uniforms:$i([I.lights,I.fog,{color:{value:new P(0)},opacity:{value:1}}]),vertexShader:ka.shadow_vert,fragmentShader:ka.shadow_frag}};Aa.physical={uniforms:$i([Aa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new j},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new j},clearcoatNormalScale:{value:new A(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new j},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new j},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new j},sheen:{value:0},sheenColor:{value:new P(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new j},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new j},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new j},transmissionSamplerSize:{value:new A},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new j},attenuationDistance:{value:0},attenuationColor:{value:new P(0)},specularColor:{value:new P(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new j},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new j},anisotropyVector:{value:new A},anisotropyMap:{value:null},anisotropyMapTransform:{value:new j}}]),vertexShader:ka.meshphysical_vert,fragmentShader:ka.meshphysical_frag};var ja={r:0,b:0,g:0},Ma=new Dr,Na=new N;function Pa(e,t,n,r,i,a,o){let s=new P(0),c=a===!0?0:1,l,u,d=null,f=0,p=null;function m(e){let r=e.isScene===!0?e.background:null;return r&&r.isTexture&&(r=(e.backgroundBlurriness>0?n:t).get(r)),r}function h(t){let n=!1,i=m(t);i===null?_(s,c):i&&i.isColor&&(_(i,1),n=!0);let a=e.xr.getEnvironmentBlendMode();a===`additive`?r.buffers.color.setClear(0,0,0,1,o):a===`alpha-blend`&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||n)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function g(t,n){let r=m(n);r&&(r.isCubeTexture||r.mapping===306)?(u===void 0&&(u=new Ji(new Zi(1,1,1),new aa({name:`BackgroundCubeMaterial`,uniforms:Qi(Aa.backgroundCube.uniforms),vertexShader:Aa.backgroundCube.vertexShader,fragmentShader:Aa.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute(`normal`),u.geometry.deleteAttribute(`uv`),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,`envMap`,{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Ma.copy(n.backgroundRotation),Ma.x*=-1,Ma.y*=-1,Ma.z*=-1,r.isCubeTexture&&r.isRenderTargetTexture===!1&&(Ma.y*=-1,Ma.z*=-1),u.material.uniforms.envMap.value=r,u.material.uniforms.flipEnvMap.value=r.isCubeTexture&&r.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Na.makeRotationFromEuler(Ma)),u.material.toneMapped=Tn.getTransfer(r.colorSpace)!==mt,(d!==r||f!==r.version||p!==e.toneMapping)&&(u.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),u.layers.enableAll(),t.unshift(u,u.geometry,u.material,0,0,null)):r&&r.isTexture&&(l===void 0&&(l=new Ji(new Oa(2,2),new aa({name:`BackgroundMaterial`,uniforms:Qi(Aa.background.uniforms),vertexShader:Aa.background.vertexShader,fragmentShader:Aa.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute(`normal`),Object.defineProperty(l.material,`map`,{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=r,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Tn.getTransfer(r.colorSpace)!==mt,r.matrixAutoUpdate===!0&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),(d!==r||f!==r.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))}function _(t,n){t.getRGB(ja,ta(e)),r.buffers.color.setClear(ja.r,ja.g,ja.b,n,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,_(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,_(s,c)},render:h,addToRenderList:g}}function Fa(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n){let i=n.wireframe===!0,a=r[e.id];a===void 0&&(a={},r[e.id]=a);let o=a[t.id];o===void 0&&(o={},a[t.id]=o);let s=o[i];return s===void 0&&(s=f(c()),o[i]=s),s}function f(e){let t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function p(e,t,n,r){let i=a.attributes,o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function g(e){_(e,0)}function _(t,n){let r=a.newAttributes,i=a.enabledAttributes,o=a.attributeDivisors;r[t]=1,i[t]===0&&(e.enableVertexAttribArray(t),i[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function v(){let t=a.newAttributes,n=a.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,r,i,a,o,s){s===!0?e.vertexAttribIPointer(t,n,r,a,o):e.vertexAttribPointer(t,n,r,i,a,o)}function b(n,r,i,a){h();let o=a.attributes,s=i.getAttributes(),c=r.defaultAttributeValues;for(let r in s){let i=s[r];if(i.location>=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)_(i.location+e,t.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,c*d,(p+o/i.locationSize*e)*d,f)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)_(i.location+e,s.meshPerAttribute);n.isInstancedMesh!==!0&&a._maxInstanceCount===void 0&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<i.locationSize;e++)g(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,l);for(let e=0;e<i.locationSize;e++)y(i.location+e,o/i.locationSize,u,r,o*d,o/i.locationSize*e*d,f)}}else if(c!==void 0){let t=c[r];if(t!==void 0)switch(t.length){case 2:e.vertexAttrib2fv(i.location,t);break;case 3:e.vertexAttrib3fv(i.location,t);break;case 4:e.vertexAttrib4fv(i.location,t);break;default:e.vertexAttrib1fv(i.location,t)}}}}v()}function x(){w();for(let e in r){let t=r[e];for(let e in t){let n=t[e];for(let e in n)u(n[e].object),delete n[e];delete t[e]}delete r[e]}}function S(e){if(r[e.id]===void 0)return;let t=r[e.id];for(let e in t){let n=t[e];for(let e in n)u(n[e].object),delete n[e];delete t[e]}delete r[e.id]}function C(e){for(let t in r){let n=r[t];if(n[e.id]===void 0)continue;let i=n[e.id];for(let e in i)u(i[e].object),delete i[e];delete n[e.id]}}function w(){T(),o=!0,a!==i&&(a=i,l(a.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:s,reset:w,resetDefaultState:T,dispose:x,releaseStatesOfGeometry:S,releaseStatesOfProgram:C,initAttributes:h,enableAttribute:g,disableUnusedAttributes:v}}function Ia(e,t,n){let r;function i(e){r=e}function a(t,i){e.drawArrays(r,t,i),n.update(i,r,1)}function o(t,i,a){a!==0&&(e.drawArraysInstanced(r,t,i,a),n.update(i,r,a))}function s(e,i,a){if(a===0)return;t.get(`WEBGL_multi_draw`).multiDrawArraysWEBGL(r,e,0,i,0,a);let o=0;for(let e=0;e<a;e++)o+=i[e];n.update(o,r,1)}function c(e,i,a,s){if(a===0)return;let c=t.get(`WEBGL_multi_draw`);if(c===null)for(let t=0;t<e.length;t++)o(e[t],i[t],s[t]);else{c.multiDrawArraysInstancedWEBGL(r,e,0,i,0,s,0,a);let t=0;for(let e=0;e<a;e++)t+=i[e];for(let e=0;e<s.length;e++)n.update(t,r,s[e])}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=s,this.renderMultiDrawInstances=c}function La(e,t,n,r){let i;function a(){if(i!==void 0)return i;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(t){return!(t!==1023&&r.convert(t)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))}function s(n){let i=n===1016&&(t.has(`EXT_color_buffer_half_float`)||t.has(`EXT_color_buffer_float`));return!(n!==1009&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==1015&&!i)}function c(t){if(t===`highp`){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(console.warn(`THREE.WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reverseDepthBuffer===!0&&t.has(`EXT_clip_control`);if(f===!0){let e=t.get(`EXT_clip_control`);e.clipControlEXT(e.LOWER_LEFT_EXT,e.ZERO_TO_ONE_EXT)}let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=m>0,S=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reverseDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,vertexTextures:x,maxSamples:S}}function Ra(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Sa,s=new j,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length<t)&&(l=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}c.value=l,c.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,l}}function za(e){let t=new WeakMap;function n(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function r(r){if(r&&r.isTexture){let a=r.mapping;if(a===303||a===304)if(t.has(r)){let e=t.get(r).texture;return n(e,r.mapping)}else{let a=r.image;if(a&&a.height>0){let o=new va(a.height);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener(`dispose`,i),n(o.texture,r.mapping)}else return null}}return r}function i(e){let n=e.target;n.removeEventListener(`dispose`,i);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var Ba=class extends la{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Va=4,Ha=[.125,.215,.35,.446,.526,.582],Ua=20,Wa=new Ba,Ga=new P,Ka=null,qa=0,Ja=0,Ya=!1,Xa=(1+Math.sqrt(5))/2,Za=1/Xa,Qa=[new M(-Xa,Za,0),new M(Xa,Za,0),new M(-Za,0,Xa),new M(Za,0,Xa),new M(0,Xa,-Za),new M(0,Xa,Za),new M(-1,1,-1),new M(1,1,-1),new M(-1,1,1),new M(1,1,1)],$a=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){Ka=this._renderer.getRenderTarget(),qa=this._renderer.getActiveCubeFace(),Ja=this._renderer.getActiveMipmapLevel(),Ya=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ao(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=io(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ka,qa,Ja),this._renderer.xr.enabled=Ya,e.scissorTest=!1,no(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ka=this._renderer.getRenderTarget(),qa=this._renderer.getActiveCubeFace(),Ja=this._renderer.getActiveMipmapLevel(),Ya=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:h,minFilter:h,generateMipmaps:!1,type:D,format:oe,colorSpace:ut,depthBuffer:!1},r=to(e,t,n),{_lodMax:i}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eo(i),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=to(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eo(r)),this._blurMaterial=ro(r,e,t)}return r}_compileMaterial(e){let t=new Ji(this._lodPlanes[0],e);this._renderer.compile(t,Wa)}_sceneToCubeUV(e,t,n,r){let i=new pa(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,c=s.autoClear,l=s.toneMapping;s.getClearColor(Ga),s.toneMapping=0,s.autoClear=!1;let u=new fi({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1}),d=new Ji(new Zi,u),f=!1,p=e.background;p?p.isColor&&(u.color.copy(p),e.background=null,f=!0):(u.color.copy(Ga),f=!0);for(let t=0;t<6;t++){let n=t%3;n===0?(i.up.set(0,a[t],0),i.lookAt(o[t],0,0)):n===1?(i.up.set(0,0,a[t]),i.lookAt(0,o[t],0)):(i.up.set(0,a[t],0),i.lookAt(0,0,o[t]));let c=this._cubeSize;no(r,n*c,t>2?c:0,c,c),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ao()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=io());let i=r?this._cubemapMaterial:this._equirectMaterial,a=new Ji(this._lodPlanes[0],i),o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;no(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Wa)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=Qa[(r-t-1)%Qa.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=new Ji(this._lodPlanes[r],c),u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*Ua-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):Ua;m>Ua&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ua}`);let h=[],g=0;for(let e=0;e<Ua;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=h,u.latitudinal.value=a===`latitudinal`,o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r];no(t,3*v*(r>_-Va?r-_+Va:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Wa)}};function eo(e){let t=[],n=[],r=[],i=e,a=e-Va+1+Ha.length;for(let o=0;o<a;o++){let a=2**i;n.push(a);let s=1/a;o>e-Va?s=Ha[o-e+Va-1]:o===0&&(s=0),r.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Ii;h.setAttribute(`position`,new bi(f,3)),h.setAttribute(`uv`,new bi(p,2)),h.setAttribute(`faceIndex`,new bi(m,1)),t.push(h),i>Va&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}function to(e,t,n){let r=new Ln(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function no(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function ro(e,t,n){let r=new Float32Array(Ua),i=new M(0,1,0);return new aa({name:`SphericalGaussianBlur`,defines:{n:Ua,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:oo(),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:0,depthTest:!1,depthWrite:!1})}function io(){return new aa({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:oo(),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:0,depthTest:!1,depthWrite:!1})}function ao(){return new aa({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:oo(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:0,depthTest:!1,depthWrite:!1})}function oo(){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 so(e){let t=new WeakMap,n=null;function r(r){if(r&&r.isTexture){let o=r.mapping,s=o===303||o===304,c=o===301||o===302;if(s||c){let o=t.get(r),l=o===void 0?0:o.texture.pmremVersion;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return n===null&&(n=new $a(e)),o=s?n.fromEquirectangular(r,o):n.fromCubemap(r,o),o.texture.pmremVersion=r.pmremVersion,t.set(r,o),o.texture;if(o!==void 0)return o.texture;{let l=r.image;return s&&l&&l.height>0||c&&l&&i(l)?(n=new $a(e),o=s?n.fromEquirectangular(r):n.fromCubemap(r),o.texture.pmremVersion=r.pmremVersion,t.set(r,o),r.addEventListener(`dispose`,a),o.texture):null}}}return r}function i(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function a(e){let n=e.target;n.removeEventListener(`dispose`,a);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function o(){t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function co(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r;switch(n){case`WEBGL_depth_texture`:r=e.getExtension(`WEBGL_depth_texture`)||e.getExtension(`MOZ_WEBGL_depth_texture`)||e.getExtension(`WEBKIT_WEBGL_depth_texture`);break;case`EXT_texture_filter_anisotropic`:r=e.getExtension(`EXT_texture_filter_anisotropic`)||e.getExtension(`MOZ_EXT_texture_filter_anisotropic`)||e.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`);break;case`WEBGL_compressed_texture_s3tc`:r=e.getExtension(`WEBGL_compressed_texture_s3tc`)||e.getExtension(`MOZ_WEBGL_compressed_texture_s3tc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_s3tc`);break;case`WEBGL_compressed_texture_pvrtc`:r=e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`);break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&_n(`THREE.WebGLRenderer: `+e+` extension not supported.`),t}}}function lo(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);for(let e in s.morphAttributes){let n=s.morphAttributes[e];for(let e=0,r=n.length;e<r;e++)t.remove(n[e])}s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER);let i=n.morphAttributes;for(let n in i){let r=i[n];for(let n=0,i=r.length;n<i;n++)t.update(r[n],e.ARRAY_BUFFER)}}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){let r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else if(i!==void 0){let e=i.array;o=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){let e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}else return;let s=new(dn(n)?Di:Ti)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.version<n.version&&l(e)}else l(e);return a.get(e)}return{get:s,update:c,getWireframeAttribute:u}}function uo(e,t,n){let r;function i(e){r=e}let a,o;function s(e){a=e.type,o=e.bytesPerElement}function c(t,i){e.drawElements(r,i,a,t*o),n.update(i,r,1)}function l(t,i,s){s!==0&&(e.drawElementsInstanced(r,i,a,t*o,s),n.update(i,r,s))}function u(e,i,o){if(o===0)return;t.get(`WEBGL_multi_draw`).multiDrawElementsWEBGL(r,i,0,a,e,0,o);let s=0;for(let e=0;e<o;e++)s+=i[e];n.update(s,r,1)}function d(e,i,s,c){if(s===0)return;let u=t.get(`WEBGL_multi_draw`);if(u===null)for(let t=0;t<e.length;t++)l(e[t]/o,i[t],c[t]);else{u.multiDrawElementsInstancedWEBGL(r,i,0,a,e,0,c,0,s);let t=0;for(let e=0;e<s;e++)t+=i[e];for(let e=0;e<c.length;e++)n.update(t,r,c[e])}}this.setMode=i,this.setIndex=s,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function fo(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(t,r,i){switch(n.calls++,r){case e.TRIANGLES:n.triangles+=t/3*i;break;case e.LINES:n.lines+=t/2*i;break;case e.LINE_STRIP:n.lines+=i*(t-1);break;case e.LINE_LOOP:n.lines+=i*t;break;case e.POINTS:n.points+=i*t;break;default:console.error(`THREE.WebGLInfo: Unknown draw mode:`,r);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:i,update:r}}function po(e,t,n){let r=new WeakMap,i=new Fn;function a(a,o,s){let c=a.morphTargetInfluences,l=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=l===void 0?0:l.length,d=r.get(o);if(d===void 0||d.count!==u){d!==void 0&&d.texture.dispose();let e=o.morphAttributes.position!==void 0,n=o.morphAttributes.normal!==void 0,a=o.morphAttributes.color!==void 0,s=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],l=o.morphAttributes.color||[],f=0;e===!0&&(f=1),n===!0&&(f=2),a===!0&&(f=3);let p=o.attributes.position.count*f,m=1;p>t.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Rn(h,p,m,u);g.type=E,g.needsUpdate=!0;let _=f*4;for(let t=0;t<u;t++){let r=s[t],o=c[t],u=l[t],d=p*m*4*t;for(let t=0;t<r.count;t++){let s=t*_;e===!0&&(i.fromBufferAttribute(r,t),h[d+s+0]=i.x,h[d+s+1]=i.y,h[d+s+2]=i.z,h[d+s+3]=0),n===!0&&(i.fromBufferAttribute(o,t),h[d+s+4]=i.x,h[d+s+5]=i.y,h[d+s+6]=i.z,h[d+s+7]=0),a===!0&&(i.fromBufferAttribute(u,t),h[d+s+8]=i.x,h[d+s+9]=i.y,h[d+s+10]=i.z,h[d+s+11]=u.itemSize===4?i.w:1)}}d={count:u,texture:g,size:new A(p,m)},r.set(o,d);function v(){g.dispose(),r.delete(o),o.removeEventListener(`dispose`,v)}o.addEventListener(`dispose`,v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)s.getUniforms().setValue(e,`morphTexture`,a.morphTexture,n);else{let t=0;for(let e=0;e<c.length;e++)t+=c[e];let n=o.morphTargetsRelative?1:1-t;s.getUniforms().setValue(e,`morphTargetBaseInfluence`,n),s.getUniforms().setValue(e,`morphTargetInfluences`,c)}s.getUniforms().setValue(e,`morphTargetsTexture`,d.texture,n),s.getUniforms().setValue(e,`morphTargetsTextureSize`,d.size)}return{update:a}}function mo(e,t,n,r){let i=new WeakMap;function a(a){let o=r.render.frame,c=a.geometry,l=t.get(a,c);if(i.get(l)!==o&&(t.update(l),i.set(l,o)),a.isInstancedMesh&&(a.hasEventListener(`dispose`,s)===!1&&a.addEventListener(`dispose`,s),i.get(a)!==o&&(n.update(a.instanceMatrix,e.ARRAY_BUFFER),a.instanceColor!==null&&n.update(a.instanceColor,e.ARRAY_BUFFER),i.set(a,o))),a.isSkinnedMesh){let e=a.skeleton;i.get(e)!==o&&(e.update(),i.set(e,o))}return l}function o(){i=new WeakMap}function s(e){let t=e.target;t.removeEventListener(`dispose`,s),n.remove(t.instanceMatrix),t.instanceColor!==null&&n.remove(t.instanceColor)}return{update:a,dispose:o}}var ho=class extends Pn{constructor(e,t,n,r,i,a,o,s,c,l=le){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);n===void 0&&l===1026&&(n=T),n===void 0&&l===1027&&(n=te),super(null,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o===void 0?u:o,this.minFilter=s===void 0?u:s,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}},go=new Pn,_o=new ho(1,1),vo=new Rn,yo=new Bn,bo=new _a,xo=[],So=[],Co=new Float32Array(16),wo=new Float32Array(9),To=new Float32Array(4);function Eo(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=xo[i];if(a===void 0&&(a=new Float32Array(i),xo[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Do(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function Oo(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function ko(e,t){let n=So[t];n===void 0&&(n=new Int32Array(t),So[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function Ao(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function jo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Do(n,t))return;e.uniform2fv(this.addr,t),Oo(n,t)}}function Mo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(t.r!==void 0)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Do(n,t))return;e.uniform3fv(this.addr,t),Oo(n,t)}}function No(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Do(n,t))return;e.uniform4fv(this.addr,t),Oo(n,t)}}function Po(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Do(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Oo(n,t)}else{if(Do(n,r))return;To.set(r),e.uniformMatrix2fv(this.addr,!1,To),Oo(n,r)}}function Fo(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Do(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Oo(n,t)}else{if(Do(n,r))return;wo.set(r),e.uniformMatrix3fv(this.addr,!1,wo),Oo(n,r)}}function Io(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Do(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Oo(n,t)}else{if(Do(n,r))return;Co.set(r),e.uniformMatrix4fv(this.addr,!1,Co),Oo(n,r)}}function Lo(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Ro(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Do(n,t))return;e.uniform2iv(this.addr,t),Oo(n,t)}}function zo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Do(n,t))return;e.uniform3iv(this.addr,t),Oo(n,t)}}function Bo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Do(n,t))return;e.uniform4iv(this.addr,t),Oo(n,t)}}function Vo(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Ho(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Do(n,t))return;e.uniform2uiv(this.addr,t),Oo(n,t)}}function Uo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Do(n,t))return;e.uniform3uiv(this.addr,t),Oo(n,t)}}function Wo(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Do(n,t))return;e.uniform4uiv(this.addr,t),Oo(n,t)}}function Go(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i);let a;this.type===e.SAMPLER_2D_SHADOW?(_o.compareFunction=515,a=_o):a=go,n.setTexture2D(t||a,i)}function Ko(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||yo,i)}function qo(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||bo,i)}function Jo(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||vo,i)}function Yo(e){switch(e){case 5126:return Ao;case 35664:return jo;case 35665:return Mo;case 35666:return No;case 35674:return Po;case 35675:return Fo;case 35676:return Io;case 5124:case 35670:return Lo;case 35667:case 35671:return Ro;case 35668:case 35672:return zo;case 35669:case 35673:return Bo;case 5125:return Vo;case 36294:return Ho;case 36295:return Uo;case 36296:return Wo;case 35678:case 36198:case 36298:case 36306:case 35682:return Go;case 35679:case 36299:case 36307:return Ko;case 35680:case 36300:case 36308:case 36293:return qo;case 36289:case 36303:case 36311:case 36292:return Jo}}function Xo(e,t){e.uniform1fv(this.addr,t)}function Zo(e,t){let n=Eo(t,this.size,2);e.uniform2fv(this.addr,n)}function Qo(e,t){let n=Eo(t,this.size,3);e.uniform3fv(this.addr,n)}function $o(e,t){let n=Eo(t,this.size,4);e.uniform4fv(this.addr,n)}function es(e,t){let n=Eo(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function ts(e,t){let n=Eo(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function ns(e,t){let n=Eo(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function rs(e,t){e.uniform1iv(this.addr,t)}function is(e,t){e.uniform2iv(this.addr,t)}function as(e,t){e.uniform3iv(this.addr,t)}function os(e,t){e.uniform4iv(this.addr,t)}function ss(e,t){e.uniform1uiv(this.addr,t)}function cs(e,t){e.uniform2uiv(this.addr,t)}function ls(e,t){e.uniform3uiv(this.addr,t)}function us(e,t){e.uniform4uiv(this.addr,t)}function ds(e,t,n){let r=this.cache,i=t.length,a=ko(n,i);Do(r,a)||(e.uniform1iv(this.addr,a),Oo(r,a));for(let e=0;e!==i;++e)n.setTexture2D(t[e]||go,a[e])}function fs(e,t,n){let r=this.cache,i=t.length,a=ko(n,i);Do(r,a)||(e.uniform1iv(this.addr,a),Oo(r,a));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||yo,a[e])}function ps(e,t,n){let r=this.cache,i=t.length,a=ko(n,i);Do(r,a)||(e.uniform1iv(this.addr,a),Oo(r,a));for(let e=0;e!==i;++e)n.setTextureCube(t[e]||bo,a[e])}function ms(e,t,n){let r=this.cache,i=t.length,a=ko(n,i);Do(r,a)||(e.uniform1iv(this.addr,a),Oo(r,a));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||vo,a[e])}function hs(e){switch(e){case 5126:return Xo;case 35664:return Zo;case 35665:return Qo;case 35666:return $o;case 35674:return es;case 35675:return ts;case 35676:return ns;case 5124:case 35670:return rs;case 35667:case 35671:return is;case 35668:case 35672:return as;case 35669:case 35673:return os;case 5125:return ss;case 36294:return cs;case 36295:return ls;case 36296:return us;case 35678:case 36198:case 36298:case 36306:case 35682:return ds;case 35679:case 36299:case 36307:return fs;case 35680:case 36300:case 36308:case 36293:return ps;case 36289:case 36303:case 36311:case 36292:return ms}}var gs=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Yo(t.type)}},_s=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=hs(t.type)}},vs=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let i=0,a=r.length;i!==a;++i){let a=r[i];a.setValue(e,t[a.id],n)}}},ys=/(\w+)(\])?(\[|\.)?/g;function bs(e,t){e.seq.push(t),e.map[t.id]=t}function xs(e,t,n){let r=e.name,i=r.length;for(ys.lastIndex=0;;){let a=ys.exec(r),o=ys.lastIndex,s=a[1],c=a[2]===`]`,l=a[3];if(c&&(s|=0),l===void 0||l===`[`&&o+2===i){bs(n,l===void 0?new gs(s,e,t):new _s(s,e,t));break}else{let e=n.map[s];e===void 0&&(e=new vs(s),bs(n,e)),n=e}}}var Ss=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let n=e.getActiveUniform(t,r);xs(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function Cs(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var ws=37297,Ts=0;function Es(e,t){let n=e.split(`
`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`
`)}function Ds(e){let t=Tn.getPrimaries(Tn.workingColorSpace),n=Tn.getPrimaries(e),r;switch(t===n?r=``:t===`p3`&&n===`rec709`?r=`LinearDisplayP3ToLinearSRGB`:t===`rec709`&&n===`p3`&&(r=`LinearSRGBToLinearDisplayP3`),e){case ut:case ft:return[r,`LinearTransferOETF`];case lt:case dt:return[r,`sRGBTransferOETF`];default:return console.warn(`THREE.WebGLProgram: Unsupported color space:`,e),[r,`LinearTransferOETF`]}}function Os(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+`
`+i+`
`+Es(e.getShaderSource(t),r)}else return i}function ks(e,t){let n=Ds(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function As(e,t){let n;switch(t){case 1:n=`Linear`;break;case 2:n=`Reinhard`;break;case 3:n=`Cineon`;break;case 4:n=`ACESFilmic`;break;case 6:n=`AgX`;break;case 7:n=`Neutral`;break;case 5:n=`Custom`;break;default:console.warn(`THREE.WebGLProgram: Unsupported toneMapping:`,t),n=`Linear`}return`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var js=new M;function Ms(){return Tn.getLuminanceCoefficients(js),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${js.x.toFixed(4)}, ${js.y.toFixed(4)}, ${js.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(`
`)}function Ns(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(Is).join(`
`)}function Ps(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(`
`)}function Fs(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i),a=r.name,o=1;r.type===e.FLOAT_MAT2&&(o=2),r.type===e.FLOAT_MAT3&&(o=3),r.type===e.FLOAT_MAT4&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function Is(e){return e!==``}function Ls(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Rs(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var zs=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bs(e){return e.replace(zs,Hs)}var Vs=new Map;function Hs(e,t){let n=ka[t];if(n===void 0){let e=Vs.get(t);if(e!==void 0)n=ka[e],console.warn(`THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return Bs(n)}var Us=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Ws(e){return e.replace(Us,Gs)}function Gs(e,t,n,r){let i=``;for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,`[ `+e+` ]`).replace(/UNROLLED_LOOP_INDEX/g,e);return i}function Ks(e){let t=`precision ${e.precision} float;
precision ${e.precision} int;
precision ${e.precision} sampler2D;
precision ${e.precision} samplerCube;
precision ${e.precision} sampler3D;
precision ${e.precision} sampler2DArray;
precision ${e.precision} sampler2DShadow;
precision ${e.precision} samplerCubeShadow;
precision ${e.precision} sampler2DArrayShadow;
precision ${e.precision} isampler2D;
precision ${e.precision} isampler3D;
precision ${e.precision} isamplerCube;
precision ${e.precision} isampler2DArray;
precision ${e.precision} usampler2D;
precision ${e.precision} usampler3D;
precision ${e.precision} usamplerCube;
precision ${e.precision} usampler2DArray;
`;return e.precision===`highp`?t+=`
#define HIGH_PRECISION`:e.precision===`mediump`?t+=`
#define MEDIUM_PRECISION`:e.precision===`lowp`&&(t+=`
#define LOW_PRECISION`),t}function qs(e){let t=`SHADOWMAP_TYPE_BASIC`;return e.shadowMapType===1?t=`SHADOWMAP_TYPE_PCF`:e.shadowMapType===2?t=`SHADOWMAP_TYPE_PCF_SOFT`:e.shadowMapType===3&&(t=`SHADOWMAP_TYPE_VSM`),t}function Js(e){let t=`ENVMAP_TYPE_CUBE`;if(e.envMap)switch(e.envMapMode){case 301:case 302:t=`ENVMAP_TYPE_CUBE`;break;case 306:t=`ENVMAP_TYPE_CUBE_UV`;break}return t}function Ys(e){let t=`ENVMAP_MODE_REFLECTION`;if(e.envMap)switch(e.envMapMode){case 302:t=`ENVMAP_MODE_REFRACTION`;break}return t}function Xs(e){let t=`ENVMAP_BLENDING_NONE`;if(e.envMap)switch(e.combine){case 0:t=`ENVMAP_BLENDING_MULTIPLY`;break;case 1:t=`ENVMAP_BLENDING_MIX`;break;case 2:t=`ENVMAP_BLENDING_ADD`;break}return t}function Zs(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(2**n,112)),texelHeight:r,maxMip:n}}function Qs(e,t,n,r){let i=e.getContext(),a=n.defines,o=n.vertexShader,s=n.fragmentShader,c=qs(n),l=Js(n),u=Ys(n),d=Xs(n),f=Zs(n),p=Ns(n),m=Ps(a),h=i.createProgram(),g,_,v=n.glslVersion?`#version `+n.glslVersion+`
`:``;n.isRawShaderMaterial?(g=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Is).join(`
`),g.length>0&&(g+=`
`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Is).join(`
`),_.length>0&&(_+=`
`)):(g=[Ks(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.reverseDepthBuffer?`#define USE_REVERSEDEPTHBUF`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,`
`].filter(Is).join(`
`),_=[Ks(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor||n.batchingColor?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.reverseDepthBuffer?`#define USE_REVERSEDEPTHBUF`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:ka.tonemapping_pars_fragment,n.toneMapping===0?``:As(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,ka.colorspace_pars_fragment,ks(`linearToOutputTexel`,n.outputColorSpace),Ms(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,`
`].filter(Is).join(`
`)),o=Bs(o),o=Ls(o,n),o=Rs(o,n),s=Bs(s),s=Ls(s,n),s=Rs(s,n),o=Ws(o),s=Ws(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(`
`)+`
`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(`
`)+`
`+_);let y=v+g+o,b=v+_+s,x=Cs(i,i.VERTEX_SHADER,y),S=Cs(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h).trim(),r=i.getShaderInfoLog(x).trim(),a=i.getShaderInfoLog(S).trim(),o=!0,s=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(o=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Os(i,x,`vertex`),r=Os(i,S,`fragment`);console.error(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+`
Material Name: `+t.name+`
Material Type: `+t.type+`
Program Info Log: `+n+`
`+e+`
`+r)}else n===``?(r===``||a===``)&&(s=!1):console.warn(`THREE.WebGLProgram: Program Info Log:`,n);s&&(t.diagnostics={runnable:o,programLog:n,vertexShader:{log:r,prefix:g},fragmentShader:{log:a,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new Ss(i,h),T=Fs(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,ws)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Ts++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var $s=0,ec=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new tc(e),t.set(e,n)),n}},tc=class{constructor(e){this.id=$s++,this.code=e,this.usedTimes=0}};function nc(e,t,n,r,i,a,o){let s=new Or,c=new ec,l=new Set,u=[],d=i.logarithmicDepthBuffer,f=i.reverseDepthBuffer,p=i.vertexTextures,m=i.precision,h={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 g(e){return l.add(e),e===0?`uv`:`uv${e}`}function _(a,s,u,_,v){let y=_.fog,b=v.geometry,x=a.isMeshStandardMaterial?_.environment:null,S=(a.isMeshStandardMaterial?n:t).get(a.envMap||x),C=S&&S.mapping===306?S.image.height:null,w=h[a.type];a.precision!==null&&(m=i.getMaxPrecision(a.precision),m!==a.precision&&console.warn(`THREE.WebGLProgram.getParameters:`,a.precision,`not supported, using`,m,`instead.`));let T=b.morphAttributes.position||b.morphAttributes.normal||b.morphAttributes.color,E=T===void 0?0:T.length,D=0;b.morphAttributes.position!==void 0&&(D=1),b.morphAttributes.normal!==void 0&&(D=2),b.morphAttributes.color!==void 0&&(D=3);let ee,O,te,ne;if(w){let e=Aa[w];ee=e.vertexShader,O=e.fragmentShader}else ee=a.vertexShader,O=a.fragmentShader,c.update(a),te=c.getVertexShaderID(a),ne=c.getFragmentShaderID(a);let re=e.getRenderTarget(),ie=v.isInstancedMesh===!0,ae=v.isBatchedMesh===!0,oe=!!a.map,se=!!a.matcap,ce=!!S,le=!!a.aoMap,ue=!!a.lightMap,de=!!a.bumpMap,fe=!!a.normalMap,pe=!!a.displacementMap,me=!!a.emissiveMap,he=!!a.metalnessMap,ge=!!a.roughnessMap,_e=a.anisotropy>0,ve=a.clearcoat>0,ye=a.dispersion>0,be=a.iridescence>0,xe=a.sheen>0,Se=a.transmission>0,k=_e&&!!a.anisotropyMap,Ce=ve&&!!a.clearcoatMap,we=ve&&!!a.clearcoatNormalMap,Te=ve&&!!a.clearcoatRoughnessMap,Ee=be&&!!a.iridescenceMap,De=be&&!!a.iridescenceThicknessMap,Oe=xe&&!!a.sheenColorMap,ke=xe&&!!a.sheenRoughnessMap,Ae=!!a.specularMap,je=!!a.specularColorMap,Me=!!a.specularIntensityMap,Ne=Se&&!!a.transmissionMap,Pe=Se&&!!a.thicknessMap,Fe=!!a.gradientMap,Ie=!!a.alphaMap,Le=a.alphaTest>0,Re=!!a.alphaHash,ze=!!a.extensions,Be=0;a.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(Be=e.toneMapping);let Ve={shaderID:w,shaderType:a.type,shaderName:a.name,vertexShader:ee,fragmentShader:O,defines:a.defines,customVertexShaderID:te,customFragmentShaderID:ne,isRawShaderMaterial:a.isRawShaderMaterial===!0,glslVersion:a.glslVersion,precision:m,batching:ae,batchingColor:ae&&v._colorsTexture!==null,instancing:ie,instancingColor:ie&&v.instanceColor!==null,instancingMorph:ie&&v.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:re===null?e.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:ut,alphaToCoverage:!!a.alphaToCoverage,map:oe,matcap:se,envMap:ce,envMapMode:ce&&S.mapping,envMapCubeUVHeight:C,aoMap:le,lightMap:ue,bumpMap:de,normalMap:fe,displacementMap:p&&pe,emissiveMap:me,normalMapObjectSpace:fe&&a.normalMapType===1,normalMapTangentSpace:fe&&a.normalMapType===0,metalnessMap:he,roughnessMap:ge,anisotropy:_e,anisotropyMap:k,clearcoat:ve,clearcoatMap:Ce,clearcoatNormalMap:we,clearcoatRoughnessMap:Te,dispersion:ye,iridescence:be,iridescenceMap:Ee,iridescenceThicknessMap:De,sheen:xe,sheenColorMap:Oe,sheenRoughnessMap:ke,specularMap:Ae,specularColorMap:je,specularIntensityMap:Me,transmission:Se,transmissionMap:Ne,thicknessMap:Pe,gradientMap:Fe,opaque:a.transparent===!1&&a.blending===1&&a.alphaToCoverage===!1,alphaMap:Ie,alphaTest:Le,alphaHash:Re,combine:a.combine,mapUv:oe&&g(a.map.channel),aoMapUv:le&&g(a.aoMap.channel),lightMapUv:ue&&g(a.lightMap.channel),bumpMapUv:de&&g(a.bumpMap.channel),normalMapUv:fe&&g(a.normalMap.channel),displacementMapUv:pe&&g(a.displacementMap.channel),emissiveMapUv:me&&g(a.emissiveMap.channel),metalnessMapUv:he&&g(a.metalnessMap.channel),roughnessMapUv:ge&&g(a.roughnessMap.channel),anisotropyMapUv:k&&g(a.anisotropyMap.channel),clearcoatMapUv:Ce&&g(a.clearcoatMap.channel),clearcoatNormalMapUv:we&&g(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&g(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&g(a.iridescenceMap.channel),iridescenceThicknessMapUv:De&&g(a.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&g(a.sheenColorMap.channel),sheenRoughnessMapUv:ke&&g(a.sheenRoughnessMap.channel),specularMapUv:Ae&&g(a.specularMap.channel),specularColorMapUv:je&&g(a.specularColorMap.channel),specularIntensityMapUv:Me&&g(a.specularIntensityMap.channel),transmissionMapUv:Ne&&g(a.transmissionMap.channel),thicknessMapUv:Pe&&g(a.thicknessMap.channel),alphaMapUv:Ie&&g(a.alphaMap.channel),vertexTangents:!!b.attributes.tangent&&(fe||_e),vertexColors:a.vertexColors,vertexAlphas:a.vertexColors===!0&&!!b.attributes.color&&b.attributes.color.itemSize===4,pointsUvs:v.isPoints===!0&&!!b.attributes.uv&&(oe||Ie),fog:!!y,useFog:a.fog===!0,fogExp2:!!y&&y.isFogExp2,flatShading:a.flatShading===!0,sizeAttenuation:a.sizeAttenuation===!0,logarithmicDepthBuffer:d,reverseDepthBuffer:f,skinning:v.isSkinnedMesh===!0,morphTargets:b.morphAttributes.position!==void 0,morphNormals:b.morphAttributes.normal!==void 0,morphColors:b.morphAttributes.color!==void 0,morphTargetsCount:E,morphTextureStride:D,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:Be,decodeVideoTexture:oe&&a.map.isVideoTexture===!0&&Tn.getTransfer(a.map.colorSpace)===`srgb`,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===2,flipSided:a.side===1,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ze&&a.extensions.clipCullDistance===!0&&r.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(ze&&a.extensions.multiDraw===!0||ae)&&r.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:r.has(`KHR_parallel_shader_compile`),customProgramCacheKey:a.customProgramCacheKey()};return Ve.vertexUv1s=l.has(1),Ve.vertexUv2s=l.has(2),Ve.vertexUv3s=l.has(3),l.clear(),Ve}function v(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(y(n,t),b(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function y(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function b(e,t){s.disableAll(),t.supportsVertexTextures&&s.enable(0),t.instancing&&s.enable(1),t.instancingColor&&s.enable(2),t.instancingMorph&&s.enable(3),t.matcap&&s.enable(4),t.envMap&&s.enable(5),t.normalMapObjectSpace&&s.enable(6),t.normalMapTangentSpace&&s.enable(7),t.clearcoat&&s.enable(8),t.iridescence&&s.enable(9),t.alphaTest&&s.enable(10),t.vertexColors&&s.enable(11),t.vertexAlphas&&s.enable(12),t.vertexUv1s&&s.enable(13),t.vertexUv2s&&s.enable(14),t.vertexUv3s&&s.enable(15),t.vertexTangents&&s.enable(16),t.anisotropy&&s.enable(17),t.alphaHash&&s.enable(18),t.batching&&s.enable(19),t.dispersion&&s.enable(20),t.batchingColor&&s.enable(21),e.push(s.mask),s.disableAll(),t.fog&&s.enable(0),t.useFog&&s.enable(1),t.flatShading&&s.enable(2),t.logarithmicDepthBuffer&&s.enable(3),t.reverseDepthBuffer&&s.enable(4),t.skinning&&s.enable(5),t.morphTargets&&s.enable(6),t.morphNormals&&s.enable(7),t.morphColors&&s.enable(8),t.premultipliedAlpha&&s.enable(9),t.shadowMapEnabled&&s.enable(10),t.doubleSided&&s.enable(11),t.flipSided&&s.enable(12),t.useDepthPacking&&s.enable(13),t.dithering&&s.enable(14),t.transmission&&s.enable(15),t.sheen&&s.enable(16),t.opaque&&s.enable(17),t.pointsUvs&&s.enable(18),t.decodeVideoTexture&&s.enable(19),t.alphaToCoverage&&s.enable(20),e.push(s.mask)}function x(e){let t=h[e.type],n;if(t){let e=Aa[t];n=na.clone(e.uniforms)}else n=e.uniforms;return n}function S(t,n){let r;for(let e=0,t=u.length;e<t;e++){let t=u[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return r===void 0&&(r=new Qs(e,n,t,a),u.push(r)),r}function C(e){if(--e.usedTimes===0){let t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),e.destroy()}}function w(e){c.remove(e)}function T(){c.dispose()}return{getParameters:_,getProgramCacheKey:v,getUniforms:x,acquireProgram:S,releaseProgram:C,releaseShaderCache:w,programs:u,dispose:T}}function rc(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function ic(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.z===t.z?e.id-t.id:e.z-t.z:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function ac(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function oc(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(n,r,i,a,o,s){let c=e[t];return c===void 0?(c={id:n.id,object:n,geometry:r,material:i,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=c):(c.id=n.id,c.object=n,c.geometry=r,c.material=i,c.groupOrder=a,c.renderOrder=n.renderOrder,c.z=o,c.group=s),t++,c}function s(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);e.onBeforeRenderListPush?.(e,t,a,l),a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u),e.onAfterRenderListPush?.(e,t,a,l)}function c(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function l(e,t){n.length>1&&n.sort(e||ic),r.length>1&&r.sort(t||ac),i.length>1&&i.sort(t||ac)}function u(){for(let n=t,r=e.length;n<r;n++){let t=e[n];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:s,unshift:c,finish:u,sort:l}}function sc(){let e=new WeakMap;function t(t,n){let r=e.get(t),i;return r===void 0?(i=new oc,e.set(t,[i])):n>=r.length?(i=new oc,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function cc(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new M,color:new P};break;case`SpotLight`:n={position:new M,direction:new M,color:new P,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new M,color:new P,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new M,skyColor:new P,groundColor:new P};break;case`RectAreaLight`:n={color:new P,position:new M,halfWidth:new M,halfHeight:new M};break}return e[t.id]=n,n}}}function lc(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new A};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new A};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new A,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var uc=0;function dc(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function fc(e){let t=new cc,n=lc(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new M);let i=new M,a=new N,o=new N;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(dc);for(let e=0,y=i.length;e<y;e++){let y=i[e],b=y.color,x=y.intensity,S=y.distance,C=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)a+=b.r*x,o+=b.g*x,s+=b.b*x;else if(y.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(y.sh.coefficients[e],x);v++}else if(y.isDirectionalLight){let e=t.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){let e=y.shadow,t=n.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[c]=t,r.directionalShadowMap[c]=C,r.directionalShadowMatrix[c]=y.shadow.matrix,p++}r.directional[c]=e,c++}else if(y.isSpotLight){let e=t.get(y);e.position.setFromMatrixPosition(y.matrixWorld),e.color.copy(b).multiplyScalar(x),e.distance=S,e.coneCos=Math.cos(y.angle),e.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),e.decay=y.decay,r.spot[u]=e;let i=y.shadow;if(y.map&&(r.spotLightMap[g]=y.map,g++,i.updateMatrices(y),y.castShadow&&_++),r.spotLightMatrix[u]=i.matrix,y.castShadow){let e=n.get(y);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[u]=e,r.spotShadowMap[u]=C,h++}u++}else if(y.isRectAreaLight){let e=t.get(y);e.color.copy(b).multiplyScalar(x),e.halfWidth.set(y.width*.5,0,0),e.halfHeight.set(0,y.height*.5,0),r.rectArea[d]=e,d++}else if(y.isPointLight){let e=t.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),e.distance=y.distance,e.decay=y.decay,y.castShadow){let e=y.shadow,t=n.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[l]=t,r.pointShadowMap[l]=C,r.pointShadowMatrix[l]=y.shadow.matrix,m++}r.point[l]=e,l++}else if(y.isHemisphereLight){let e=t.get(y);e.skyColor.copy(y.color).multiplyScalar(x),e.groundColor.copy(y.groundColor).multiplyScalar(x),r.hemi[f]=e,f++}}d>0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=I.LTC_FLOAT_1,r.rectAreaLTC2=I.LTC_FLOAT_2):(r.rectAreaLTC1=I.LTC_HALF_1,r.rectAreaLTC2=I.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=uc++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){let f=e[t];if(f.isDirectionalLight){let e=r.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),i.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(d),n++}else if(f.isSpotLight){let e=r.spot[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(f.matrixWorld),i.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(d),c++}else if(f.isRectAreaLight){let e=r.rectArea[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),o.identity(),a.copy(f.matrixWorld),a.premultiply(d),o.extractRotation(a),e.halfWidth.set(f.width*.5,0,0),e.halfHeight.set(0,f.height*.5,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),l++}else if(f.isPointLight){let e=r.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),s++}else if(f.isHemisphereLight){let e=r.hemi[u];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(d),u++}}}return{setup:s,setupView:c,state:r}}function pc(e){let t=new fc(e),n=[],r=[];function i(e){l.camera=e,n.length=0,r.length=0}function a(e){n.push(e)}function o(e){r.push(e)}function s(){t.setup(n)}function c(e){t.setupView(n,e)}let l={lightsArray:n,shadowsArray:r,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:l,setupLights:s,setupLightsView:c,pushLight:a,pushShadow:o}}function mc(e){let t=new WeakMap;function n(n,r=0){let i=t.get(n),a;return i===void 0?(a=new pc(e),t.set(n,[a])):r>=i.length?(a=new pc(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var hc=class extends di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=at,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}},gc=class extends di{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}},_c=`void main() {
gl_Position = vec4( position, 1.0 );
}`,vc=`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 ) );
}`;function yc(e,t,n){let r=new Ta,i=new A,a=new A,o=new Fn,s=new hc({depthPacking:ot}),c=new gc,l={},d=n.maxTextureSize,f={0:1,1:0,2:2},p=new aa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new A},radius:{value:4}},vertexShader:_c,fragmentShader:vc}),m=p.clone();m.defines.HORIZONTAL_PASS=1;let h=new Ii;h.setAttribute(`position`,new bi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new Ji(h,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;this.render=function(t,n,s){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||t.length===0)return;let c=e.getRenderTarget(),l=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);let m=v!==3&&this.type===3,h=v===3&&this.type!==3;for(let c=0,l=t.length;c<l;c++){let l=t[c],f=l.shadow;if(f===void 0){console.warn(`THREE.WebGLShadowMap:`,l,`has no shadow.`);continue}if(f.autoUpdate===!1&&f.needsUpdate===!1)continue;i.copy(f.mapSize);let g=f.getFrameExtents();if(i.multiply(g),a.copy(f.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/g.x),i.x=a.x*g.x,f.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/g.y),i.y=a.y*g.y,f.mapSize.y=a.y)),f.map===null||m===!0||h===!0){let e=this.type===3?{}:{minFilter:u,magFilter:u};f.map!==null&&f.map.dispose(),f.map=new Ln(i.x,i.y,e),f.map.texture.name=l.name+`.shadowMap`,f.camera.updateProjectionMatrix()}e.setRenderTarget(f.map),e.clear();let _=f.getViewportCount();for(let e=0;e<_;e++){let t=f.getViewport(e);o.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),p.viewport(o),f.updateMatrices(l,e),r=f.getFrustum(),x(n,s,f.camera,l,this.type)}f.isPointLightShadow!==!0&&this.type===3&&y(f,s),f.needsUpdate=!1}v=this.type,_.needsUpdate=!1,e.setRenderTarget(c,l,f)};function y(n,r){let a=t.update(g);p.defines.VSM_SAMPLES!==n.blurSamples&&(p.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),n.mapPass===null&&(n.mapPass=new Ln(i.x,i.y)),p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,p,g,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,m,g,null)}function b(t,n,r,i){let a=null,o=r.isPointLight===!0?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=r.isPointLight===!0?c:s,e.localClippingEnabled&&n.clipShadows===!0&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,S)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?f[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function x(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l<u;l++){let u=t[l],d=c[u.materialIndex];if(d&&d.visible){let t=b(n,d,o,s);n.onBeforeShadow(e,n,i,a,r,t,u),e.renderBufferDirect(a,null,r,t,n,u),n.onAfterShadow(e,n,i,a,r,t,u)}}}else if(c.visible){let t=b(n,c,o,s);n.onBeforeShadow(e,n,i,a,r,t,null),e.renderBufferDirect(a,null,r,t,n,null),n.onAfterShadow(e,n,i,a,r,t,null)}}let c=n.children;for(let e=0,t=c.length;e<t;e++)x(c[e],i,a,o,s)}function S(e){e.target.removeEventListener(`dispose`,S);for(let t in l){let n=l[t],r=e.target.uuid;r in n&&(n[r].dispose(),delete n[r])}}}var bc={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3};function xc(e){function t(){let t=!1,n=new Fn,r=null,i=new Fn(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function n(){let t=!1,n=!1,r=null,i=null,a=null;return{setReversed:function(e){n=e},setTest:function(t){t?pe(e.DEPTH_TEST):me(e.DEPTH_TEST)},setMask:function(n){r!==n&&!t&&(e.depthMask(n),r=n)},setFunc:function(t){if(n&&(t=bc[t]),i!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){a!==t&&(e.clearDepth(t),a=t)},reset:function(){t=!1,r=null,i=null,a=null}}}function r(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(n){t||(n?pe(e.STENCIL_TEST):me(e.STENCIL_TEST))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let i=new t,a=new n,o=new r,s=new WeakMap,c=new WeakMap,l={},u={},d=new WeakMap,f=[],p=null,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null,S=new P(0,0,0),C=0,w=!1,T=null,E=null,D=null,ee=null,O=null,te=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ne=!1,re=0,ie=e.getParameter(e.VERSION);ie.indexOf(`WebGL`)===-1?ie.indexOf(`OpenGL ES`)!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),ne=re>=2):(re=parseFloat(/^WebGL (\d)/.exec(ie)[1]),ne=re>=1);let ae=null,oe={},se=e.getParameter(e.SCISSOR_BOX),ce=e.getParameter(e.VIEWPORT),le=new Fn().fromArray(se),ue=new Fn().fromArray(ce);function de(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}let fe={};fe[e.TEXTURE_2D]=de(e.TEXTURE_2D,e.TEXTURE_2D,1),fe[e.TEXTURE_CUBE_MAP]=de(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[e.TEXTURE_2D_ARRAY]=de(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),fe[e.TEXTURE_3D]=de(e.TEXTURE_3D,e.TEXTURE_3D,1,1),i.setClear(0,0,0,1),a.setClear(1),o.setClear(0),pe(e.DEPTH_TEST),a.setFunc(3),Se(!1),k(1),pe(e.CULL_FACE),be(0);function pe(t){l[t]!==!0&&(e.enable(t),l[t]=!0)}function me(t){l[t]!==!1&&(e.disable(t),l[t]=!1)}function he(t,n){return u[t]===n?!1:(e.bindFramebuffer(t,n),u[t]=n,t===e.DRAW_FRAMEBUFFER&&(u[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(u[e.DRAW_FRAMEBUFFER]=n),!0)}function ge(t,n){let r=f,i=!1;if(t){r=d.get(n),r===void 0&&(r=[],d.set(n,r));let a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)}function _e(t){return p===t?!1:(e.useProgram(t),p=t,!0)}let ve={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};ve[103]=e.MIN,ve[104]=e.MAX;let ye={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function be(t,n,r,i,a,o,s,c,l,u){if(t===0){m===!0&&(me(e.BLEND),m=!1);return}if(m===!1&&(pe(e.BLEND),m=!0),t!==5){if(t!==h||u!==w){if((g!==100||y!==100)&&(e.blendEquation(e.FUNC_ADD),g=100,y=100),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error(`THREE.WebGLState: Invalid blending: `,t);break}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error(`THREE.WebGLState: Invalid blending: `,t);break}_=null,v=null,b=null,x=null,S.set(0,0,0),C=0,h=t,w=u}return}a||=n,o||=r,s||=i,(n!==g||a!==y)&&(e.blendEquationSeparate(ve[n],ve[a]),g=n,y=a),(r!==_||i!==v||o!==b||s!==x)&&(e.blendFuncSeparate(ye[r],ye[i],ye[o],ye[s]),_=r,v=i,b=o,x=s),(c.equals(S)===!1||l!==C)&&(e.blendColor(c.r,c.g,c.b,l),S.copy(c),C=l),h=t,w=!1}function xe(t,n){t.side===2?me(e.CULL_FACE):pe(e.CULL_FACE);let r=t.side===1;n&&(r=!r),Se(r),t.blending===1&&t.transparent===!1?be(0):be(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),i.setMask(t.colorWrite);let s=t.stencilWrite;o.setTest(s),s&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),we(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),t.alphaToCoverage===!0?pe(e.SAMPLE_ALPHA_TO_COVERAGE):me(e.SAMPLE_ALPHA_TO_COVERAGE)}function Se(t){T!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),T=t)}function k(t){t===0?me(e.CULL_FACE):(pe(e.CULL_FACE),t!==E&&(t===1?e.cullFace(e.BACK):t===2?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))),E=t}function Ce(t){t!==D&&(ne&&e.lineWidth(t),D=t)}function we(t,n,r){t?(pe(e.POLYGON_OFFSET_FILL),(ee!==n||O!==r)&&(e.polygonOffset(n,r),ee=n,O=r)):me(e.POLYGON_OFFSET_FILL)}function Te(t){t?pe(e.SCISSOR_TEST):me(e.SCISSOR_TEST)}function Ee(t){t===void 0&&(t=e.TEXTURE0+te-1),ae!==t&&(e.activeTexture(t),ae=t)}function De(t,n,r){r===void 0&&(r=ae===null?e.TEXTURE0+te-1:ae);let i=oe[r];i===void 0&&(i={type:void 0,texture:void 0},oe[r]=i),(i.type!==t||i.texture!==n)&&(ae!==r&&(e.activeTexture(r),ae=r),e.bindTexture(t,n||fe[t]),i.type=t,i.texture=n)}function Oe(){let t=oe[ae];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function ke(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Ae(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function je(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Me(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Ne(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Pe(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Fe(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Ie(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Le(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function Re(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function ze(t){le.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),le.copy(t))}function Be(t){ue.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),ue.copy(t))}function Ve(t,n){let r=c.get(n);r===void 0&&(r=new WeakMap,c.set(n,r));let i=r.get(t);i===void 0&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))}function He(t,n){let r=c.get(n).get(t);s.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),s.set(n,r))}function Ue(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),l={},ae=null,oe={},u={},d=new WeakMap,f=[],p=null,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null,S=new P(0,0,0),C=0,w=!1,T=null,E=null,D=null,ee=null,O=null,le.set(0,0,e.canvas.width,e.canvas.height),ue.set(0,0,e.canvas.width,e.canvas.height),i.reset(),a.reset(),o.reset()}return{buffers:{color:i,depth:a,stencil:o},enable:pe,disable:me,bindFramebuffer:he,drawBuffers:ge,useProgram:_e,setBlending:be,setMaterial:xe,setFlipSided:Se,setCullFace:k,setLineWidth:Ce,setPolygonOffset:we,setScissorTest:Te,activeTexture:Ee,bindTexture:De,unbindTexture:Oe,compressedTexImage2D:ke,compressedTexImage3D:Ae,texImage2D:Le,texImage3D:Re,updateUBOMapping:Ve,uniformBlockBinding:He,texStorage2D:Fe,texStorage3D:Ie,texSubImage2D:je,texSubImage3D:Me,compressedTexSubImage2D:Ne,compressedTexSubImage3D:Pe,scissor:ze,viewport:Be,reset:Ue}}function Sc(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Cc(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function wc(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function Tc(e,t,n,r){let i=Ec(r);switch(n){case ie:return e*t;case se:return e*t;case ce:return e*t*2;case de:return e*t/i.components*i.byteLength;case fe:return e*t/i.components*i.byteLength;case pe:return e*t*2/i.components*i.byteLength;case me:return e*t*2/i.components*i.byteLength;case ae:return e*t*3/i.components*i.byteLength;case oe:return e*t*4/i.components*i.byteLength;case ge:return e*t*4/i.components*i.byteLength;case _e:case ve:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case ye:case be:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Se:case Ce:return Math.max(e,16)*Math.max(t,8)/4;case xe:case k:return Math.max(e,8)*Math.max(t,8)/2;case we:case Te:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ee:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case De:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Oe:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case ke:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Ae:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case je:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Me:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Ne:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Pe:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Fe:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Ie:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case Le:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case Re:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case ze:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case Be:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Ve:case He:case Ue:return Math.ceil(e/4)*Math.ceil(t/4)*16;case We:case Ge:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Ke:case qe:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Ec(e){switch(e){case b:case x:return{byteLength:1,components:1};case C:case S:case D:return{byteLength:2,components:1};case ee:case O:return{byteLength:2,components:4};case T:case w:case E:return{byteLength:4,components:1};case ne:case re:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}var Dc={contain:Sc,cover:Cc,fill:wc,getByteLength:Tc};function Oc(e,t,n,r,i,a,o){let f=t.has(`WEBGL_multisampled_render_to_texture`)?t.get(`WEBGL_multisampled_render_to_texture`):null,m=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),_=new A,y=new WeakMap,b,x=new WeakMap,S=!1;try{S=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function C(e,t){return S?new OffscreenCanvas(e,t):mn(`canvas`)}function w(e,t,n){let r=1,i=Fe(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);b===void 0&&(b=C(n,a));let o=t?C(n,a):b;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),console.warn(`THREE.WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&console.warn(`THREE.WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function T(e){return e.generateMipmaps&&e.minFilter!==1003&&e.minFilter!==1006}function E(t){e.generateMipmap(t)}function D(n,r,i,a,o=!1){if(n!==null){if(e[n]!==void 0)return e[n];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let s=r;if(r===e.RED&&(i===e.FLOAT&&(s=e.R32F),i===e.HALF_FLOAT&&(s=e.R16F),i===e.UNSIGNED_BYTE&&(s=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.R8UI),i===e.UNSIGNED_SHORT&&(s=e.R16UI),i===e.UNSIGNED_INT&&(s=e.R32UI),i===e.BYTE&&(s=e.R8I),i===e.SHORT&&(s=e.R16I),i===e.INT&&(s=e.R32I)),r===e.RG&&(i===e.FLOAT&&(s=e.RG32F),i===e.HALF_FLOAT&&(s=e.RG16F),i===e.UNSIGNED_BYTE&&(s=e.RG8)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RG8UI),i===e.UNSIGNED_SHORT&&(s=e.RG16UI),i===e.UNSIGNED_INT&&(s=e.RG32UI),i===e.BYTE&&(s=e.RG8I),i===e.SHORT&&(s=e.RG16I),i===e.INT&&(s=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RGB8UI),i===e.UNSIGNED_SHORT&&(s=e.RGB16UI),i===e.UNSIGNED_INT&&(s=e.RGB32UI),i===e.BYTE&&(s=e.RGB8I),i===e.SHORT&&(s=e.RGB16I),i===e.INT&&(s=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(s=e.RGBA16UI),i===e.UNSIGNED_INT&&(s=e.RGBA32UI),i===e.BYTE&&(s=e.RGBA8I),i===e.SHORT&&(s=e.RGBA16I),i===e.INT&&(s=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(s=e.R11F_G11F_B10F)),r===e.RGBA){let t=o?pt:Tn.getTransfer(a);i===e.FLOAT&&(s=e.RGBA32F),i===e.HALF_FLOAT&&(s=e.RGBA16F),i===e.UNSIGNED_BYTE&&(s=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}return(s===e.R16F||s===e.R32F||s===e.RG16F||s===e.RG32F||s===e.RGBA16F||s===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),s}function ee(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,console.warn(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function O(e,t){return T(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function te(e){let t=e.target;t.removeEventListener(`dispose`,te),re(t),t.isVideoTexture&&y.delete(t)}function ne(e){let t=e.target;t.removeEventListener(`dispose`,ne),ae(t)}function re(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=x.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&ie(e),Object.keys(i).length===0&&x.delete(n)}r.remove(e)}function ie(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=x.get(i);delete a[n.__cacheKey],o.memory.textures--}function ae(t){let n=r.get(t);if(t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let i=t.textures;for(let t=0,n=i.length;t<n;t++){let n=r.get(i[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),r.remove(i[t])}r.remove(t)}let oe=0;function se(){oe=0}function ce(){let e=oe;return e>=i.maxTextures&&console.warn(`THREE.WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),oe+=1,e}function le(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function de(t,i){let a=r.get(t);if(t.isVideoTexture&&Ne(t),t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)console.warn(`THREE.WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)console.warn(`THREE.WebGLRenderer: Texture marked for update but image is incomplete`);else{be(a,t,i);return}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function fe(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){be(a,t,i);return}n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function pe(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){be(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function me(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){xe(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let he={[s]:e.REPEAT,[c]:e.CLAMP_TO_EDGE,[l]:e.MIRRORED_REPEAT},ge={[u]:e.NEAREST,[d]:e.NEAREST_MIPMAP_NEAREST,[p]:e.NEAREST_MIPMAP_LINEAR,[h]:e.LINEAR,[g]:e.LINEAR_MIPMAP_NEAREST,[v]:e.LINEAR_MIPMAP_LINEAR},_e={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ve(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&console.warn(`THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,he[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,he[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,he[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,ge[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,ge[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,_e[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function ye(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,te));let i=n.source,a=x.get(i);a===void 0&&(a={},x.set(i,a));let s=le(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&ie(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function be(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=ye(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let d=r.get(u);if(u.version!==d.__version||l===!0){n.activeTexture(e.TEXTURE0+s);let t=Tn.getPrimaries(Tn.workingColorSpace),r=o.colorSpace===``?null:Tn.getPrimaries(o.colorSpace),f=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let p=w(o.image,!1,i.maxTextureSize);p=Pe(o,p);let m=a.convert(o.format,o.colorSpace),h=a.convert(o.type),g=D(o.internalFormat,m,h,o.colorSpace,o.isVideoTexture);ve(c,o);let _,v=o.mipmaps,y=o.isVideoTexture!==!0,b=d.__version===void 0||l===!0,x=u.dataReady,S=O(o,p);if(o.isDepthTexture)g=ee(o.format===ue,o.type),b&&(y?n.texStorage2D(e.TEXTURE_2D,1,g,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,g,p.width,p.height,0,m,h,null));else if(o.isDataTexture)if(v.length>0){y&&b&&n.texStorage2D(e.TEXTURE_2D,S,g,v[0].width,v[0].height);for(let t=0,r=v.length;t<r;t++)_=v[t],y?x&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,_.width,_.height,m,h,_.data):n.texImage2D(e.TEXTURE_2D,t,g,_.width,_.height,0,m,h,_.data);o.generateMipmaps=!1}else y?(b&&n.texStorage2D(e.TEXTURE_2D,S,g,p.width,p.height),x&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,p.width,p.height,m,h,p.data)):n.texImage2D(e.TEXTURE_2D,0,g,p.width,p.height,0,m,h,p.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){y&&b&&n.texStorage3D(e.TEXTURE_2D_ARRAY,S,g,v[0].width,v[0].height,p.depth);for(let t=0,r=v.length;t<r;t++)if(_=v[t],o.format!==1023)if(m!==null)if(y){if(x)if(o.layerUpdates.size>0){let r=Tc(_.width,_.height,o.format,o.type);for(let i of o.layerUpdates){let a=_.data.subarray(i*r/_.data.BYTES_PER_ELEMENT,(i+1)*r/_.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,i,_.width,_.height,1,m,a,0,0)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,_.width,_.height,p.depth,m,_.data,0,0)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,g,_.width,_.height,p.depth,0,_.data,0,0);else console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else y?x&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,_.width,_.height,p.depth,m,h,_.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,g,_.width,_.height,p.depth,0,m,h,_.data)}else{y&&b&&n.texStorage2D(e.TEXTURE_2D,S,g,v[0].width,v[0].height);for(let t=0,r=v.length;t<r;t++)_=v[t],o.format===1023?y?x&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,_.width,_.height,m,h,_.data):n.texImage2D(e.TEXTURE_2D,t,g,_.width,_.height,0,m,h,_.data):m===null?console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):y?x&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,_.width,_.height,m,_.data):n.compressedTexImage2D(e.TEXTURE_2D,t,g,_.width,_.height,0,_.data)}else if(o.isDataArrayTexture)if(y){if(b&&n.texStorage3D(e.TEXTURE_2D_ARRAY,S,g,p.width,p.height,p.depth),x)if(o.layerUpdates.size>0){let t=Tc(p.width,p.height,o.format,o.type);for(let r of o.layerUpdates){let i=p.data.subarray(r*t/p.data.BYTES_PER_ELEMENT,(r+1)*t/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,p.width,p.height,1,m,h,i)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,h,p.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,g,p.width,p.height,p.depth,0,m,h,p.data);else if(o.isData3DTexture)y?(b&&n.texStorage3D(e.TEXTURE_3D,S,g,p.width,p.height,p.depth),x&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,h,p.data)):n.texImage3D(e.TEXTURE_3D,0,g,p.width,p.height,p.depth,0,m,h,p.data);else if(o.isFramebufferTexture){if(b)if(y)n.texStorage2D(e.TEXTURE_2D,S,g,p.width,p.height);else{let t=p.width,r=p.height;for(let i=0;i<S;i++)n.texImage2D(e.TEXTURE_2D,i,g,t,r,0,m,h,null),t>>=1,r>>=1}}else if(v.length>0){if(y&&b){let t=Fe(v[0]);n.texStorage2D(e.TEXTURE_2D,S,g,t.width,t.height)}for(let t=0,r=v.length;t<r;t++)_=v[t],y?x&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,m,h,_):n.texImage2D(e.TEXTURE_2D,t,g,m,h,_);o.generateMipmaps=!1}else if(y){if(b){let t=Fe(p);n.texStorage2D(e.TEXTURE_2D,S,g,t.width,t.height)}x&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,m,h,p)}else n.texImage2D(e.TEXTURE_2D,0,g,m,h,p);T(o)&&E(c),d.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function xe(t,o,s){if(o.image.length!==6)return;let c=ye(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||c===!0){n.activeTexture(e.TEXTURE0+s);let t=Tn.getPrimaries(Tn.workingColorSpace),r=o.colorSpace===``?null:Tn.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)!f&&!p?m[e]=w(o.image[e],!0,i.maxCubemapSize):m[e]=p?o.image[e].image:o.image[e],m[e]=Pe(o,m[e]);let h=m[0],g=a.convert(o.format,o.colorSpace),_=a.convert(o.type),v=D(o.internalFormat,g,_,o.colorSpace),y=o.isVideoTexture!==!0,b=u.__version===void 0||c===!0,x=l.dataReady,S=O(o,h);ve(e.TEXTURE_CUBE_MAP,o);let C;if(f){y&&b&&n.texStorage2D(e.TEXTURE_CUBE_MAP,S,v,h.width,h.height);for(let t=0;t<6;t++){C=m[t].mipmaps;for(let r=0;r<C.length;r++){let i=C[r];o.format===1023?y?x&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,v,i.width,i.height,0,g,_,i.data):g===null?console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):y?x&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,v,i.width,i.height,0,i.data)}}}else{if(C=o.mipmaps,y&&b){C.length>0&&S++;let t=Fe(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,S,v,t.width,t.height)}for(let t=0;t<6;t++)if(p){y?x&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,g,_,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,m[t].width,m[t].height,0,g,_,m[t].data);for(let r=0;r<C.length;r++){let i=C[r].image[t].image;y?x&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,v,i.width,i.height,0,g,_,i.data)}}else{y?x&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,_,m[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,g,_,m[t]);for(let r=0;r<C.length;r++){let i=C[r];y?x&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,g,_,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,v,g,_,i.image[t])}}}T(o)&&E(e.TEXTURE_CUBE_MAP),u.__version=l.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function Se(t,i,o,s,c,l){let u=a.convert(o.format,o.colorSpace),d=a.convert(o.type),p=D(o.internalFormat,u,d,o.colorSpace);if(!r.get(i).__hasExternalTextures){let t=Math.max(1,i.width>>l),r=Math.max(1,i.height>>l);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,l,p,t,r,i.depth,0,u,d,null):n.texImage2D(c,l,p,t,r,0,u,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),Me(i)?f.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,0,je(i)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,l),n.bindFramebuffer(e.FRAMEBUFFER,null)}function k(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=ee(n.stencilBuffer,a),s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=je(n);Me(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i<t.length;i++){let o=t[i],s=a.convert(o.format,o.colorSpace),c=a.convert(o.type),l=D(o.internalFormat,s,c,o.colorSpace),u=je(n);r&&Me(n)===!1?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,n.width,n.height):Me(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,l,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,l,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ce(t,i){if(i&&i.isWebGLCubeRenderTarget)throw Error(`Depth Texture with cube render targets is not supported`);if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(i.depthTexture&&i.depthTexture.isDepthTexture))throw Error(`renderTarget.depthTexture must be an instance of THREE.DepthTexture`);(!r.get(i.depthTexture).__webglTexture||i.depthTexture.image.width!==i.width||i.depthTexture.image.height!==i.height)&&(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),de(i.depthTexture,0);let a=r.get(i.depthTexture).__webglTexture,o=je(i);if(i.depthTexture.format===1026)Me(i)?f.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else if(i.depthTexture.format===1027)Me(i)?f.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0);else throw Error(`Unknown depthTexture format`)}function we(t){let i=r.get(t),a=t.isWebGLCubeRenderTarget===!0;if(i.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(i.__depthDisposeCallback&&i.__depthDisposeCallback(),e){let t=()=>{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)throw Error(`target.depthTexture not supported in Cube render targets`);Ce(i.__webglFramebuffer,t)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),k(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),k(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function Te(t,n,i){let a=r.get(t);n!==void 0&&Se(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&we(t)}function Ee(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,ne);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=l.length;t<n;t++){let n=r.get(l[t]);n.__webglTexture===void 0&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&Me(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<l.length;n++){let r=l[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let i=a.convert(r.format,r.colorSpace),o=a.convert(r.type),c=D(r.internalFormat,i,o,r.colorSpace,t.isXRRenderTarget===!0),u=je(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),k(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),ve(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps&&i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)Se(s.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else Se(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);T(i)&&E(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let i=0,a=l.length;i<a;i++){let a=l[i],o=r.get(a);n.bindTexture(e.TEXTURE_2D,o.__webglTexture),ve(e.TEXTURE_2D,a),Se(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+i,e.TEXTURE_2D,0),T(a)&&E(e.TEXTURE_2D)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,c.__webglTexture),ve(r,i),i.mipmaps&&i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)Se(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else Se(s.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);T(i)&&E(r),n.unbindTexture()}t.depthBuffer&&we(t)}function De(t){let i=t.textures;for(let a=0,o=i.length;a<o;a++){let o=i[a];if(T(o)){let i=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=r.get(o).__webglTexture;n.bindTexture(i,a),E(i),n.unbindTexture()}}}let Oe=[],ke=[];function Ae(t){if(t.samples>0){if(Me(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,l=r.get(t),u=i.length>1;if(u)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,l.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,l.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,l.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,l.__webglColorRenderbuffer[n]);let t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),m===!0&&(Oe.length=0,ke.length=0,Oe.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&t.resolveDepthBuffer===!1&&(Oe.push(c),ke.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,ke)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Oe))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,l.__webglColorRenderbuffer[t]);let a=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,l.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,l.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&t.resolveDepthBuffer===!1&&m){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}}function je(e){return Math.min(i.maxSamples,e.samples)}function Me(e){let n=r.get(e);return e.samples>0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function Ne(e){let t=o.render.frame;y.get(e)!==t&&(y.set(e,t),e.update())}function Pe(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Tn.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&console.warn(`THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):console.error(`THREE.WebGLTextures: Unsupported texture color space:`,n)),t}function Fe(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(_.width=e.naturalWidth||e.width,_.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(_.width=e.displayWidth,_.height=e.displayHeight):(_.width=e.width,_.height=e.height),_}this.allocateTextureUnit=ce,this.resetTextureUnits=se,this.setTexture2D=de,this.setTexture2DArray=fe,this.setTexture3D=pe,this.setTextureCube=me,this.rebindTextures=Te,this.setupRenderTarget=Ee,this.updateRenderTargetMipmap=De,this.updateMultisampleRenderTarget=Ae,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=Me}function kc(e,t){function n(n,r=``){let i,a=Tn.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1024)return e.LUMINANCE;if(n===1025)return e.LUMINANCE_ALPHA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36492)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var Ac=class extends pa{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},jc=class extends Wr{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Mc={type:`move`},Nc=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jc,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 jc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Mc)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new jc;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Pc=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,Fc=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
void main() {
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
if ( coord.x >= 1.0 ) {
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
} else {
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
}
}`,Ic=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let r=new Pn,i=e.properties.get(r);i.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new aa({vertexShader:Pc,fragmentShader:Fc,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ji(new Oa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Lc=class extends Ft{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=new Ic,h=t.getContextAttributes(),g=null,_=null,v=[],y=[],x=new A,S=null,C=new pa;C.layers.enable(1),C.viewport=new Fn;let w=new pa;w.layers.enable(2),w.viewport=new Fn;let E=[C,w],D=new Ac;D.layers.enable(1),D.layers.enable(2);let ee=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(e){let t=v[e];return t===void 0&&(t=new Nc,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return t===void 0&&(t=new Nc,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return t===void 0&&(t=new Nc,v[e]=t),t.getHandSpace()};function ne(e){let t=y.indexOf(e.inputSource);if(t===-1)return;let n=v[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function re(){r.removeEventListener(`select`,ne),r.removeEventListener(`selectstart`,ne),r.removeEventListener(`selectend`,ne),r.removeEventListener(`squeeze`,ne),r.removeEventListener(`squeezestart`,ne),r.removeEventListener(`squeezeend`,ne),r.removeEventListener(`end`,re),r.removeEventListener(`inputsourceschange`,ie);for(let e=0;e<v.length;e++){let t=y[e];t!==null&&(y[e]=null,v[e]&&v[e].disconnect(t))}ee=null,O=null,m.reset(),e.setRenderTarget(g),f=null,d=null,u=null,r=null,_=null,he.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(x.width,x.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(g=e.getRenderTarget(),r.addEventListener(`select`,ne),r.addEventListener(`selectstart`,ne),r.addEventListener(`selectend`,ne),r.addEventListener(`squeeze`,ne),r.addEventListener(`squeezestart`,ne),r.addEventListener(`squeezeend`,ne),r.addEventListener(`end`,re),r.addEventListener(`inputsourceschange`,ie),h.xrCompatible!==!0&&await t.makeXRCompatible(),S=e.getPixelRatio(),e.getSize(x),typeof XRWebGLBinding<`u`&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;h.depth&&(o=h.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=h.stencil?ue:le,a=h.stencil?te:T);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new Ln(d.textureWidth,d.textureHeight,{format:oe,type:b,depthTexture:new ho(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:h.stencil,colorSpace:e.outputColorSpace,samples:h.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:h.antialias,alpha:!0,depth:h.depth,stencil:h.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new Ln(f.framebufferWidth,f.framebufferHeight,{format:oe,type:b,colorSpace:e.outputColorSpace,stencilBuffer:h.stencil})}_.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),he.setContext(r),he.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ie(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=y.indexOf(n);r>=0&&(y[r]=null,v[r]&&v[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=y.indexOf(n);if(r===-1){for(let e=0;e<v.length;e++)if(e>=y.length){y.push(n),r=e;break}else if(y[e]===null){y[e]=n,r=e;break}if(r===-1)break}let i=v[r];i&&i.connect(n)}}let ae=new M,se=new M;function ce(e,t,n){ae.setFromMatrixPosition(t.matrixWorld),se.setFromMatrixPosition(n.matrixWorld);let r=ae.distanceTo(se),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function de(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;m.texture!==null&&(m.depthNear>0&&(t=m.depthNear),m.depthFar>0&&(n=m.depthFar)),D.near=w.near=C.near=t,D.far=w.far=C.far=n,(ee!==D.near||O!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),ee=D.near,O=D.far);let i=e.parent,a=D.cameras;de(D,i);for(let e=0;e<a.length;e++)de(a[e],i);a.length===2?ce(D,C,w):D.projectionMatrix.copy(C.projectionMatrix),fe(e,D,i)};function fe(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=zt*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(D)};let pe=null;function me(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let n=!1;t.length!==D.cameras.length&&(D.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){let i=t[r],a=null;if(f!==null)a=f.getViewport(i);else{let t=u.getViewSubImage(d,i);a=t.viewport,r===0&&(e.setRenderTargetTextures(_,t.colorTexture,d.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(_))}let o=E[r];o===void 0&&(o=new pa,o.layers.enable(r),o.viewport=new Fn,E[r]=o),o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(i.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),r===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),n===!0&&D.cameras.push(o)}let i=r.enabledFeatures;if(i&&i.includes(`depth-sensing`)){let n=u.getDepthInformation(t[0]);n&&n.isValid&&n.texture&&m.init(e,n,r.renderState)}}if(n.controllerAutoUpdate)for(let e=0;e<v.length;e++){let t=y[e],n=v[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}pe&&pe(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let he=new Ea;he.setAnimationLoop(me),this.setAnimationLoop=function(e){pe=e},this.dispose=function(){}}},Rc=new Dr,zc=new N;function Bc(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,ta(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial||t.isMeshLambertMaterial?a(e,t):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,Rc.copy(o),Rc.x*=-1,Rc.y*=-1,Rc.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(Rc.y*=-1,Rc.z*=-1),e.envMapRotation.value.setFromMatrix4(zc.makeRotationFromEuler(Rc)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Vc(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return console.error(`THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var Hc=class{constructor(e={}){let{canvas:t=hn(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:s=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u=`default`,failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;if(r!==null){if(typeof WebGLRenderingContext<`u`&&r instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);f=r.getContextAttributes().alpha}else f=o;let p=new Uint32Array(4),m=new Int32Array(4),h=null,g=null,_=[],y=[];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.toneMapping=0,this.toneMappingExposure=1;let x=this,S=!1,C=0,w=0,T=null,E=-1,ee=null,O=new Fn,te=new Fn,ne=null,re=new P(0),ie=0,ae=t.width,oe=t.height,se=1,ce=null,le=null,ue=new Fn(0,0,ae,oe),de=new Fn(0,0,ae,oe),fe=!1,pe=new Ta,me=!1,he=!1,ge=new N,_e=new N,ve=new M,ye=new Fn,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},xe=!1;function Se(){return T===null?se:1}let k=r;function Ce(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:i,stencil:a,antialias:s,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r${n}`),t.addEventListener(`webglcontextlost`,Xe,!1),t.addEventListener(`webglcontextrestored`,Ze,!1),t.addEventListener(`webglcontextcreationerror`,Qe,!1),k===null){let t=`webgl2`;if(k=Ce(t,e),k===null)throw Ce(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw console.error(`THREE.WebGLRenderer: `+e.message),e}let we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe;function Je(){we=new co(k),we.init(),Ge=new kc(k,we),Te=new La(k,we,e,Ge),Ee=new xc(k),Te.reverseDepthBuffer&&Ee.buffers.depth.setReversed(!0),De=new fo(k),Oe=new rc,ke=new Oc(k,we,Ee,Oe,Te,Ge,De),Ae=new za(x),je=new so(x),Me=new Da(k),Ke=new Fa(k,Me),Ne=new lo(k,Me,De,Ke),Pe=new mo(k,Ne,Me,De),He=new po(k,Te,ke),ze=new Ra(Oe),Fe=new nc(x,Ae,je,we,Te,Ke,ze),Ie=new Bc(x,Oe),Le=new sc,Re=new mc(we),Ve=new Pa(x,Ae,je,Ee,Pe,f,c),Be=new yc(x,Pe,Te),qe=new Vc(k,De,Te,Ee),Ue=new Ia(k,we,De),We=new uo(k,we,De),De.programs=Fe.programs,x.capabilities=Te,x.extensions=we,x.properties=Oe,x.renderLists=Le,x.shadowMap=Be,x.state=Ee,x.info=De}Je();let Ye=new Lc(x,k);this.xr=Ye,this.getContext=function(){return k},this.getContextAttributes=function(){return k.getContextAttributes()},this.forceContextLoss=function(){let e=we.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=we.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(e){e!==void 0&&(se=e,this.setSize(ae,oe,!1))},this.getSize=function(e){return e.set(ae,oe)},this.setSize=function(e,n,r=!0){if(Ye.isPresenting){console.warn(`THREE.WebGLRenderer: Can't change size while VR device is presenting.`);return}ae=e,oe=n,t.width=Math.floor(e*se),t.height=Math.floor(n*se),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ae*se,oe*se).floor()},this.setDrawingBufferSize=function(e,n,r){ae=e,oe=n,se=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(ue)},this.setViewport=function(e,t,n,r){e.isVector4?ue.set(e.x,e.y,e.z,e.w):ue.set(e,t,n,r),Ee.viewport(O.copy(ue).multiplyScalar(se).round())},this.getScissor=function(e){return e.copy(de)},this.setScissor=function(e,t,n,r){e.isVector4?de.set(e.x,e.y,e.z,e.w):de.set(e,t,n,r),Ee.scissor(te.copy(de).multiplyScalar(se).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(e){Ee.setScissorTest(fe=e)},this.setOpaqueSort=function(e){ce=e},this.setTransparentSort=function(e){le=e},this.getClearColor=function(e){return e.copy(Ve.getClearColor())},this.setClearColor=function(){Ve.setClearColor.apply(Ve,arguments)},this.getClearAlpha=function(){return Ve.getClearAlpha()},this.setClearAlpha=function(){Ve.setClearAlpha.apply(Ve,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(T!==null){let t=T.texture.format;e=t===1033||t===1031||t===1029}if(e){let e=T.texture.type,t=e===1009||e===1014||e===1012||e===1020||e===1017||e===1018,n=Ve.getClearColor(),r=Ve.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(p[0]=i,p[1]=a,p[2]=o,p[3]=r,k.clearBufferuiv(k.COLOR,0,p)):(m[0]=i,m[1]=a,m[2]=o,m[3]=r,k.clearBufferiv(k.COLOR,0,m))}else r|=k.COLOR_BUFFER_BIT}t&&(r|=k.DEPTH_BUFFER_BIT,k.clearDepth(+!this.capabilities.reverseDepthBuffer)),n&&(r|=k.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),k.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Xe,!1),t.removeEventListener(`webglcontextrestored`,Ze,!1),t.removeEventListener(`webglcontextcreationerror`,Qe,!1),Le.dispose(),Re.dispose(),Oe.dispose(),Ae.dispose(),je.dispose(),Pe.dispose(),Ke.dispose(),qe.dispose(),Fe.dispose(),Ye.dispose(),Ye.removeEventListener(`sessionstart`,at),Ye.removeEventListener(`sessionend`,ot),st.stop()};function Xe(e){e.preventDefault(),console.log(`THREE.WebGLRenderer: Context Lost.`),S=!0}function Ze(){console.log(`THREE.WebGLRenderer: Context Restored.`),S=!1;let e=De.autoReset,t=Be.enabled,n=Be.autoUpdate,r=Be.needsUpdate,i=Be.type;Je(),De.autoReset=e,Be.enabled=t,Be.autoUpdate=n,Be.needsUpdate=r,Be.type=i}function Qe(e){console.error(`THREE.WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function $e(e){let t=e.target;t.removeEventListener(`dispose`,$e),et(t)}function et(e){tt(e),Oe.remove(e)}function tt(e){let t=Oe.get(e).programs;t!==void 0&&(t.forEach(function(e){Fe.releaseProgram(e)}),e.isShaderMaterial&&Fe.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=be);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=vt(e,t,n,r,i);Ee.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=Ne.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ke.setup(i,r,s,n,c);let h,g=Ue;if(c!==null&&(h=Me.get(c),g=We,g.setIndex(h)),i.isMesh)r.wireframe===!0?(Ee.setLineWidth(r.wireframeLinewidth*Se()),g.setMode(k.LINES)):g.setMode(k.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),Ee.setLineWidth(e*Se()),i.isLineSegments?g.setMode(k.LINES):i.isLineLoop?g.setMode(k.LINE_LOOP):g.setMode(k.LINE_STRIP)}else i.isPoints?g.setMode(k.POINTS):i.isSprite&&g.setMode(k.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(we.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?Me.get(c).bytesPerElement:1,o=Oe.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(k,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function nt(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,ht(e,t,n),e.side=0,e.needsUpdate=!0,ht(e,t,n),e.side=2):ht(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),g=Re.get(n),g.init(t),y.push(g),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(g.pushLight(e),e.castShadow&&g.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(g.pushLight(e),e.castShadow&&g.pushShadow(e))}),g.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];nt(a,n,e),r.add(a)}else nt(t,n,e),r.add(t)}),y.pop(),g=null,r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){Oe.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}we.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let rt=null;function it(e){rt&&rt(e)}function at(){st.stop()}function ot(){st.start()}let st=new Ea;st.setAnimationLoop(it),typeof self<`u`&&st.setContext(self),this.setAnimationLoop=function(e){rt=e,Ye.setAnimationLoop(e),e===null?st.stop():st.start()},Ye.addEventListener(`sessionstart`,at),Ye.addEventListener(`sessionend`,ot),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(S===!0)return;if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ye.enabled===!0&&Ye.isPresenting===!0&&(Ye.cameraAutoUpdate===!0&&Ye.updateCamera(t),t=Ye.getCamera()),e.isScene===!0&&e.onBeforeRender(x,e,t,T),g=Re.get(e,y.length),g.init(t),y.push(g),_e.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),pe.setFromProjectionMatrix(_e),he=this.localClippingEnabled,me=ze.init(this.clippingPlanes,he),h=Le.get(e,_.length),h.init(),_.push(h),Ye.enabled===!0&&Ye.isPresenting===!0){let e=x.xr.getDepthSensingMesh();e!==null&&ct(e,t,-1/0,x.sortObjects)}ct(e,t,0,x.sortObjects),h.finish(),x.sortObjects===!0&&h.sort(ce,le),xe=Ye.enabled===!1||Ye.isPresenting===!1||Ye.hasDepthSensing()===!1,xe&&Ve.addToRenderList(h,e),this.info.render.frame++,me===!0&&ze.beginShadows();let n=g.state.shadowsArray;Be.render(n,e,t),me===!0&&ze.endShadows(),this.info.autoReset===!0&&this.info.reset();let r=h.opaque,i=h.transmissive;if(g.setupLights(),t.isArrayCamera){let n=t.cameras;if(i.length>0)for(let t=0,a=n.length;t<a;t++){let a=n[t];ft(r,i,e,a)}xe&&Ve.render(e);for(let t=0,r=n.length;t<r;t++){let r=n[t];dt(h,e,r,r.viewport)}}else i.length>0&&ft(r,i,e,t),xe&&Ve.render(e),dt(h,e,t);T!==null&&(ke.updateMultisampleRenderTarget(T),ke.updateRenderTargetMipmap(T)),e.isScene===!0&&e.onAfterRender(x,e,t),Ke.resetDefaultState(),E=-1,ee=null,y.pop(),y.length>0?(g=y[y.length-1],me===!0&&ze.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,_.pop(),h=_.length>0?_[_.length-1]:null};function ct(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)g.pushLight(e),e.castShadow&&g.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||pe.intersectsSprite(e)){r&&ye.setFromMatrixPosition(e.matrixWorld).applyMatrix4(_e);let t=Pe.update(e),i=e.material;i.visible&&h.push(e,t,i,n,ye.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||pe.intersectsObject(e))){let t=Pe.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ye.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ye.copy(e.boundingSphere.center)),ye.applyMatrix4(e.matrixWorld).applyMatrix4(_e)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&h.push(e,t,s,n,ye.z,o)}}else i.visible&&h.push(e,t,i,n,ye.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)ct(i[e],t,n,r)}function dt(e,t,n,r){let i=e.opaque,a=e.transmissive,o=e.transparent;g.setupLightsView(n),me===!0&&ze.setGlobalState(x.clippingPlanes,n),r&&Ee.viewport(O.copy(r)),i.length>0&&pt(i,t,n),a.length>0&&pt(a,t,n),o.length>0&&pt(o,t,n),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function ft(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[r.id]===void 0&&(g.state.transmissionRenderTarget[r.id]=new Ln(1,1,{generateMipmaps:!0,type:we.has(`EXT_color_buffer_half_float`)||we.has(`EXT_color_buffer_float`)?D:b,minFilter:v,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Tn.workingColorSpace}));let i=g.state.transmissionRenderTarget[r.id],o=r.viewport||O;i.setSize(o.z,o.w);let s=x.getRenderTarget();x.setRenderTarget(i),x.getClearColor(re),ie=x.getClearAlpha(),ie<1&&x.setClearColor(16777215,.5),x.clear(),xe&&Ve.render(n);let c=x.toneMapping;x.toneMapping=0;let l=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),g.setupLightsView(r),me===!0&&ze.setGlobalState(x.clippingPlanes,r),pt(e,n,r),ke.updateMultisampleRenderTarget(i),ke.updateRenderTargetMipmap(i),we.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=a.object,s=a.geometry,c=a.material,l=a.group;if(c.side===2&&o.layers.test(r.layers)){let t=c.side;c.side=1,c.needsUpdate=!0,mt(o,n,r,s,c,l),c.side=t,c.needsUpdate=!0,e=!0}}e===!0&&(ke.updateMultisampleRenderTarget(i),ke.updateRenderTargetMipmap(i))}x.setRenderTarget(s),x.setClearColor(re,ie),l!==void 0&&(r.viewport=l),x.toneMapping=c}function pt(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=a.object,s=a.geometry,c=r===null?a.material:r,l=a.group;o.layers.test(n.layers)&&mt(o,t,n,s,c,l)}}function mt(e,t,n,r,i,a){e.onBeforeRender(x,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(x,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,x.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,x.renderBufferDirect(n,t,r,i,e,a),i.side=2):x.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(x,t,n,r,i,a)}function ht(e,t,n){t.isScene!==!0&&(t=be);let r=Oe.get(e),i=g.state.lights,a=g.state.shadowsArray,o=i.state.version,s=Fe.getParameters(e,i.state,a,t,n),c=Fe.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?je:Ae).get(e.envMap||r.environment),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,$e),l=new Map,r.programs=l);let u=l.get(c);if(u!==void 0){if(r.currentProgram===u&&r.lightsStateVersion===o)return _t(e,s),u}else s.uniforms=Fe.getUniforms(e),e.onBuild(n,s,x),e.onBeforeCompile(s,x),u=Fe.acquireProgram(s,c),l.set(c,u),r.uniforms=s.uniforms;let d=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(d.clippingPlanes=ze.uniform),_t(e,s),r.needsLights=bt(e),r.lightsStateVersion=o,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotLightMatrix.value=i.state.spotLightMatrix,d.spotLightMap.value=i.state.spotLightMap,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=u,r.uniformsList=null,u}function gt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Ss.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function _t(e,t){let n=Oe.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function vt(e,t,n,r,i){t.isScene!==!0&&(t=be),ke.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=T===null?x.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:ut,c=(r.isMeshStandardMaterial?je:Ae).get(r.envMap||o),l=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,u=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(m=x.toneMapping);let h=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=h===void 0?0:h.length,v=Oe.get(r),y=g.state.lights;if(me===!0&&(he===!0||e!==ee)){let t=e===ee&&r.id===E;ze.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===c?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==ze.numPlanes||v.numIntersection!==ze.numIntersection)?b=!0:v.vertexAlphas===l&&v.vertexTangents===u&&v.morphTargets===d&&v.morphNormals===f&&v.morphColors===p&&v.toneMapping===m?v.morphTargetsCount!==_&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=ht(r,t,i));let C=!1,w=!1,D=!1,O=S.getUniforms(),te=v.uniforms;if(Ee.useProgram(S.program)&&(C=!0,w=!0,D=!0),(r.id!==E||r._forceRefresh)&&(E=r.id,w=!0,r._forceRefresh=!1),C||ee!==e){Te.reverseDepthBuffer?(ge.copy(e.projectionMatrix),yn(ge),bn(ge),O.setValue(k,`projectionMatrix`,ge)):O.setValue(k,`projectionMatrix`,e.projectionMatrix),O.setValue(k,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(k,ve.setFromMatrixPosition(e.matrixWorld)),Te.logarithmicDepthBuffer&&O.setValue(k,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(k,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,D=!0)}if(i.isSkinnedMesh){O.setOptional(k,i,`bindMatrix`),O.setOptional(k,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(k,`boneTexture`,e.boneTexture,ke))}i.isBatchedMesh&&(O.setOptional(k,i,`batchingTexture`),O.setValue(k,`batchingTexture`,i._matricesTexture,ke),O.setOptional(k,i,`batchingIdTexture`),O.setValue(k,`batchingIdTexture`,i._indirectTexture,ke),O.setOptional(k,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(k,`batchingColorTexture`,i._colorsTexture,ke));let ne=n.morphAttributes;if((ne.position!==void 0||ne.normal!==void 0||ne.color!==void 0)&&He.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(k,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(te.envMap.value=c,te.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),r.isMeshStandardMaterial&&r.envMap===null&&t.environment!==null&&(te.envMapIntensity.value=t.environmentIntensity),w&&(O.setValue(k,`toneMappingExposure`,x.toneMappingExposure),v.needsLights&&yt(te,D),a&&r.fog===!0&&Ie.refreshFogUniforms(te,a),Ie.refreshMaterialUniforms(te,r,se,oe,g.state.transmissionRenderTarget[e.id]),Ss.upload(k,gt(v),te,ke)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Ss.upload(k,gt(v),te,ke),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(k,`center`,i.center),O.setValue(k,`modelViewMatrix`,i.modelViewMatrix),O.setValue(k,`normalMatrix`,i.normalMatrix),O.setValue(k,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];qe.update(n,S),qe.bind(n,S)}}return S}function yt(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function bt(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){Oe.get(e.texture).__webglTexture=t,Oe.get(e.depthTexture).__webglTexture=n;let r=Oe.get(e);r.__hasExternalTextures=!0,r.__autoAllocateDepthBuffer=n===void 0,r.__autoAllocateDepthBuffer||we.has(`WEBGL_multisampled_render_to_texture`)===!0&&(console.warn(`THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided`),r.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){let n=Oe.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0},this.setRenderTarget=function(e,t=0,n=0){T=e,C=t,w=n;let r=!0,i=null,a=!1,o=!1;if(e){let s=Oe.get(e);if(s.__useDefaultFramebuffer!==void 0)Ee.bindFramebuffer(k.FRAMEBUFFER,null),r=!1;else if(s.__webglFramebuffer===void 0)ke.setupRenderTarget(e);else if(s.__hasExternalTextures)ke.rebindTextures(e,Oe.get(e.texture).__webglTexture,Oe.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(s.__boundDepthTexture!==t){if(t!==null&&Oe.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);ke.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(o=!0);let l=Oe.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],a=!0):i=e.samples>0&&ke.useMultisampledRTT(e)===!1?Oe.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),te.copy(e.scissor),ne=e.scissorTest}else O.copy(ue).multiplyScalar(se).floor(),te.copy(de).multiplyScalar(se).floor(),ne=fe;if(Ee.bindFramebuffer(k.FRAMEBUFFER,i)&&r&&Ee.drawBuffers(e,i),Ee.viewport(O),Ee.scissor(te),Ee.setScissorTest(ne),a){let r=Oe.get(e.texture);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=Oe.get(e.texture),i=t||0;k.framebufferTextureLayer(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}E=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let s=Oe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){Ee.bindFramebuffer(k.FRAMEBUFFER,s);try{let o=e.texture,s=o.format,c=o.type;if(!Te.textureFormatReadable(s)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!Te.textureTypeReadable(c)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&k.readPixels(t,n,r,i,Ge.convert(s),Ge.convert(c),a)}finally{let e=T===null?null:Oe.get(T).__webglFramebuffer;Ee.bindFramebuffer(k.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let s=Oe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){let o=e.texture,c=o.format,l=o.type;if(!Te.textureFormatReadable(c))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Te.textureTypeReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){Ee.bindFramebuffer(k.FRAMEBUFFER,s);let e=k.createBuffer();k.bindBuffer(k.PIXEL_PACK_BUFFER,e),k.bufferData(k.PIXEL_PACK_BUFFER,a.byteLength,k.STREAM_READ),k.readPixels(t,n,r,i,Ge.convert(c),Ge.convert(l),0);let o=T===null?null:Oe.get(T).__webglFramebuffer;Ee.bindFramebuffer(k.FRAMEBUFFER,o);let u=k.fenceSync(k.SYNC_GPU_COMMANDS_COMPLETE,0);return k.flush(),await vn(k,u,4),k.bindBuffer(k.PIXEL_PACK_BUFFER,e),k.getBufferSubData(k.PIXEL_PACK_BUFFER,0,a),k.deleteBuffer(e),k.deleteSync(u),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){e.isTexture!==!0&&(_n(`WebGLRenderer: copyFramebufferToTexture function signature has changed.`),t=arguments[0]||null,e=arguments[1]);let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;ke.setTexture2D(e,0),k.copyTexSubImage2D(k.TEXTURE_2D,n,0,0,o,s,i,a),Ee.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0){e.isTexture!==!0&&(_n(`WebGLRenderer: copyTextureToTexture function signature has changed.`),r=arguments[0]||null,e=arguments[1],t=arguments[2],i=arguments[3]||0,n=null);let a,o,s,c,l,u;n===null?(a=e.image.width,o=e.image.height,s=0,c=0):(a=n.max.x-n.min.x,o=n.max.y-n.min.y,s=n.min.x,c=n.min.y),r===null?(l=0,u=0):(l=r.x,u=r.y);let d=Ge.convert(t.format),f=Ge.convert(t.type);ke.setTexture2D(t,0),k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,t.flipY),k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),k.pixelStorei(k.UNPACK_ALIGNMENT,t.unpackAlignment);let p=k.getParameter(k.UNPACK_ROW_LENGTH),m=k.getParameter(k.UNPACK_IMAGE_HEIGHT),h=k.getParameter(k.UNPACK_SKIP_PIXELS),g=k.getParameter(k.UNPACK_SKIP_ROWS),_=k.getParameter(k.UNPACK_SKIP_IMAGES),v=e.isCompressedTexture?e.mipmaps[i]:e.image;k.pixelStorei(k.UNPACK_ROW_LENGTH,v.width),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,v.height),k.pixelStorei(k.UNPACK_SKIP_PIXELS,s),k.pixelStorei(k.UNPACK_SKIP_ROWS,c),e.isDataTexture?k.texSubImage2D(k.TEXTURE_2D,i,l,u,a,o,d,f,v.data):e.isCompressedTexture?k.compressedTexSubImage2D(k.TEXTURE_2D,i,l,u,v.width,v.height,d,v.data):k.texSubImage2D(k.TEXTURE_2D,i,l,u,a,o,d,f,v),k.pixelStorei(k.UNPACK_ROW_LENGTH,p),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,m),k.pixelStorei(k.UNPACK_SKIP_PIXELS,h),k.pixelStorei(k.UNPACK_SKIP_ROWS,g),k.pixelStorei(k.UNPACK_SKIP_IMAGES,_),i===0&&t.generateMipmaps&&k.generateMipmap(k.TEXTURE_2D),Ee.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n=null,r=null,i=0){e.isTexture!==!0&&(_n(`WebGLRenderer: copyTextureToTexture3D function signature has changed.`),n=arguments[0]||null,r=arguments[1]||null,e=arguments[2],t=arguments[3],i=arguments[4]||0);let a,o,s,c,l,u,d,f,p,m=e.isCompressedTexture?e.mipmaps[i]:e.image;n===null?(a=m.width,o=m.height,s=m.depth,c=0,l=0,u=0):(a=n.max.x-n.min.x,o=n.max.y-n.min.y,s=n.max.z-n.min.z,c=n.min.x,l=n.min.y,u=n.min.z),r===null?(d=0,f=0,p=0):(d=r.x,f=r.y,p=r.z);let h=Ge.convert(t.format),g=Ge.convert(t.type),_;if(t.isData3DTexture)ke.setTexture3D(t,0),_=k.TEXTURE_3D;else if(t.isDataArrayTexture||t.isCompressedArrayTexture)ke.setTexture2DArray(t,0),_=k.TEXTURE_2D_ARRAY;else{console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.`);return}k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,t.flipY),k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),k.pixelStorei(k.UNPACK_ALIGNMENT,t.unpackAlignment);let v=k.getParameter(k.UNPACK_ROW_LENGTH),y=k.getParameter(k.UNPACK_IMAGE_HEIGHT),b=k.getParameter(k.UNPACK_SKIP_PIXELS),x=k.getParameter(k.UNPACK_SKIP_ROWS),S=k.getParameter(k.UNPACK_SKIP_IMAGES);k.pixelStorei(k.UNPACK_ROW_LENGTH,m.width),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,m.height),k.pixelStorei(k.UNPACK_SKIP_PIXELS,c),k.pixelStorei(k.UNPACK_SKIP_ROWS,l),k.pixelStorei(k.UNPACK_SKIP_IMAGES,u),e.isDataTexture||e.isData3DTexture?k.texSubImage3D(_,i,d,f,p,a,o,s,h,g,m.data):t.isCompressedArrayTexture?k.compressedTexSubImage3D(_,i,d,f,p,a,o,s,h,m.data):k.texSubImage3D(_,i,d,f,p,a,o,s,h,g,m),k.pixelStorei(k.UNPACK_ROW_LENGTH,v),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,y),k.pixelStorei(k.UNPACK_SKIP_PIXELS,b),k.pixelStorei(k.UNPACK_SKIP_ROWS,x),k.pixelStorei(k.UNPACK_SKIP_IMAGES,S),i===0&&t.generateMipmaps&&k.generateMipmap(_),Ee.unbindTexture()},this.initRenderTarget=function(e){Oe.get(e).__webglFramebuffer===void 0&&ke.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ke.setTextureCube(e,0):e.isData3DTexture?ke.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ke.setTexture2DArray(e,0):ke.setTexture2D(e,0),Ee.unbindTexture()},this.resetState=function(){C=0,w=0,T=null,Ee.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Nt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===`display-p3`?`display-p3`:`srgb`,t.unpackColorSpace=Tn.workingColorSpace===`display-p3-linear`?`display-p3`:`srgb`}},Uc=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new P(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Wc=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new P(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Gc=class extends Wr{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Dr,this.environmentIntensity=1,this.environmentRotation=new Dr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Kc=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Ct,this.updateRanges=[],this.version=0,this.uuid=Bt()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+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=Bt()),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]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bt()),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}}},qc=new M,Jc=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)qc.fromBufferAttribute(this,t),qc.applyMatrix4(e),this.setXYZ(t,qc.x,qc.y,qc.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qc.fromBufferAttribute(this,t),qc.applyNormalMatrix(e),this.setXYZ(t,qc.x,qc.y,qc.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qc.fromBufferAttribute(this,t),qc.transformDirection(e),this.setXYZ(t,qc.x,qc.y,qc.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=sn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cn(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=cn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=cn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=cn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=cn(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=sn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=sn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=sn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=sn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=cn(t,this.array),n=cn(n,this.array),r=cn(r,this.array),i=cn(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new bi(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.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 e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,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}}},Yc=class extends di{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new P(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}},Xc,Zc=new M,Qc=new M,$c=new M,el=new A,tl=new A,nl=new N,rl=new M,il=new M,al=new M,ol=new A,sl=new A,cl=new A,ll=class extends Wr{constructor(e=new Yc){if(super(),this.isSprite=!0,this.type=`Sprite`,Xc===void 0){Xc=new Ii;let e=new Kc(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Xc.setIndex([0,1,2,0,2,3]),Xc.setAttribute(`position`,new Jc(e,3,0,!1)),Xc.setAttribute(`uv`,new Jc(e,2,3,!1))}this.geometry=Xc,this.material=e,this.center=new A(.5,.5)}raycast(e,t){e.camera===null&&console.error(`THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Qc.setFromMatrixScale(this.matrixWorld),nl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$c.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Qc.multiplyScalar(-$c.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;ul(rl.set(-.5,-.5,0),$c,a,Qc,r,i),ul(il.set(.5,-.5,0),$c,a,Qc,r,i),ul(al.set(.5,.5,0),$c,a,Qc,r,i),ol.set(0,0),sl.set(1,0),cl.set(1,1);let o=e.ray.intersectTriangle(rl,il,al,!1,Zc);if(o===null&&(ul(il.set(-.5,.5,0),$c,a,Qc,r,i),sl.set(0,1),o=e.ray.intersectTriangle(rl,al,il,!1,Zc),o===null))return;let s=e.ray.origin.distanceTo(Zc);s<e.near||s>e.far||t.push({distance:s,point:Zc.clone(),uv:ii.getInterpolation(Zc,rl,il,al,ol,sl,cl,new A),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function ul(e,t,n,r,i,a){el.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?tl.copy(el):(tl.x=a*el.x-i*el.y,tl.y=i*el.x+a*el.y),e.copy(t),e.x+=tl.x,e.y+=tl.y,e.applyMatrix4(nl)}var dl=new M,fl=new M,pl=class extends Wr{constructor(){super(),this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){dl.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(dl);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){dl.setFromMatrixPosition(e.matrixWorld),fl.setFromMatrixPosition(this.matrixWorld);let n=dl.distanceTo(fl)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),n>=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}},ml=new M,hl=new Fn,gl=new Fn,_l=new M,vl=new N,yl=new M,bl=new lr,xl=new N,Sl=new _r,Cl=class extends Ji{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=a,this.bindMatrix=new N,this.bindMatrixInverse=new N,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Gn),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,yl),this.boundingBox.expandByPoint(yl)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new lr),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,yl),this.boundingSphere.expandByPoint(yl)}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 n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bl.copy(this.boundingSphere),bl.applyMatrix4(r),e.ray.intersectsSphere(bl)!==!1&&(xl.copy(r).invert(),Sl.copy(e.ray).applyMatrix4(xl),!(this.boundingBox!==null&&Sl.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Sl)))}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 Fn,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn(`THREE.SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;hl.fromBufferAttribute(r.attributes.skinIndex,e),gl.fromBufferAttribute(r.attributes.skinWeight,e),ml.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=gl.getComponent(e);if(r!==0){let i=hl.getComponent(e);vl.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(_l.copy(ml).applyMatrix4(vl),r)}}return t.applyMatrix4(this.bindMatrixInverse)}},wl=class extends Wr{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Tl=class extends Pn{constructor(e=null,t=1,n=1,r,i,a,o,s,c=u,l=u,d,f){super(null,a,o,s,c,l,r,i,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},El=new N,Dl=new N,Ol=class e{constructor(e=[],t=[]){this.uuid=Bt(),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 e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new N)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new N;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Dl;El.multiplyMatrices(i,t[r]),El.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(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 n=new Tl(t,e,e,oe,E);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(console.warn(`THREE.Skeleton: No bone found with UUID:`,r),i=new wl),this.bones.push(i),this.boneInverses.push(new N().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},kl=class extends bi{constructor(e,t,n,r=1){super(e,t,n),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}},Al=new N,jl=new N,Ml=[],Nl=new Gn,Pl=new N,Fl=new Ji,Il=new lr,Ll=class extends Ji{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new kl(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,Pl)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Gn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Al),Nl.copy(e.boundingBox).applyMatrix4(Al),this.boundingBox.union(Nl)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new lr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Al),Il.copy(e.boundingSphere).applyMatrix4(Al),this.boundingSphere.union(Il)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),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)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(Fl.geometry=this.geometry,Fl.material=this.material,Fl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Il.copy(this.boundingSphere),Il.applyMatrix4(n),e.ray.intersectsSphere(Il)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Al),jl.multiplyMatrices(n,Al),Fl.matrixWorld=jl,Fl.raycast(e,Ml);for(let e=0,n=Ml.length;e<n;e++){let n=Ml[e];n.instanceId=i,n.object=this,t.push(n)}Ml.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new kl(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Tl(new Float32Array(r*this.count),r,this.count,de,E));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;i[s]=o,i.set(n,s+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};function Rl(e,t){return e.z-t.z}function zl(e,t){return t.z-e.z}var Bl=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n){let r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=n}reset(){this.list.length=0,this.index=0}},Vl=new N,Hl=new N,Ul=new N,Wl=new P(1,1,1),Gl=new N,Kl=new Ta,ql=new Gn,Jl=new lr,Yl=new M,Xl=new M,Zl=new M,Ql=new Bl,$l=new Ji,eu=[];function tu(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a<i;a++)for(let i=0;i<r;i++)t.setComponent(a+n,i,e.getComponent(a,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}var nu=class extends Ji{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,n=t*2,r){super(new Ii,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4),this._matricesTexture=new Tl(new Float32Array(e*e*4),e,e,oe,E)}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e),this._indirectTexture=new Tl(new Uint32Array(e*e),e,e,fe,T)}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Tl(new Float32Array(e*e*4).fill(1),e,e,oe,E);t.colorSpace=Tn.workingColorSpace,this._colorsTexture=t}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in e.attributes){let{array:i,itemSize:a,normalized:o}=e.getAttribute(r),s=new bi(new i.constructor(n*a),a,o);t.setAttribute(r,s)}if(e.getIndex()!==null){let e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new bi(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gn);let e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Vl),this.getBoundingBoxAt(r,ql).applyMatrix4(Vl),e.union(ql)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new lr);let e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Vl),this.getBoundingSphereAt(r,Jl).applyMatrix4(Vl),e.union(Jl)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(n=this._availableInstanceIds.pop(),this._drawInfo[n]=t):(n=this._drawInfo.length,this._drawInfo.push(t));let r=this._matricesTexture,i=r.image.data;Ul.toArray(i,n*16),r.needsUpdate=!0;let a=this._colorsTexture;return a&&(Wl.toArray(a.image.data,n*4),a.needsUpdate=!0),n}addGeometry(e,t=-1,n=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw Error(`BatchedMesh: Maximum item count reached.`);let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},i=null,a=this._reservedRanges,o=this._drawRanges,s=this._bounds;this._geometryCount!==0&&(i=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute(`position`).count:r.vertexCount=t,i===null?r.vertexStart=0:r.vertexStart=i.vertexStart+i.vertexCount;let c=e.getIndex(),l=c!==null;if(l&&(n===-1?r.indexCount=c.count:r.indexCount=n,i===null?r.indexStart=0:r.indexStart=i.indexStart+i.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw Error(`BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let u=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:l?r.indexStart:r.vertexStart,count:-1}),s.push({boxInitialized:!1,box:new Gn,sphereInitialized:!1,sphere:new lr}),this.setGeometryAt(u,e),u}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw Error(`BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.vertexCount;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);tu(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e<t;e++){let t=s+e;for(let e=0;e<a;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(s*a,c*a)}if(r){let e=o.indexStart;for(let t=0;t<a.count;t++)i.setX(e+t,s+a.getX(t));for(let t=a.count,n=o.indexCount;t<n;t++)i.setX(e+t,s);i.needsUpdate=!0,i.addUpdateRange(e,o.indexCount)}let l=this._bounds[e];t.boundingBox===null?l.boxInitialized=!1:(l.box.copy(t.boundingBox),l.boxInitialized=!0),t.boundingSphere===null?l.sphereInitialized=!1:(l.sphere.copy(t.boundingSphere),l.sphereInitialized=!0);let u=this._drawRanges[e],d=t.getAttribute(`position`);return u.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){let t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this._bounds[e],r=n.box,i=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();let t=i.index,a=i.attributes.position,o=this._drawRanges[e];for(let e=o.start,n=o.start+o.count;e<n;e++){let n=e;t&&(n=t.getX(n)),r.expandByPoint(Yl.fromBufferAttribute(a,n))}n.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this._bounds[e],r=n.sphere,i=this.geometry;if(n.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,ql),ql.getCenter(r.center);let t=i.index,a=i.attributes.position,o=this._drawRanges[e],s=0;for(let e=o.start,n=o.start+o.count;e<n;e++){let n=e;t&&(n=t.getX(n)),Yl.fromBufferAttribute(a,n),s=Math.max(s,r.center.distanceToSquared(Yl))}r.radius=Math.sqrt(s),n.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){let n=this._drawInfo,r=this._matricesTexture,i=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?this:(t.toArray(i,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let n=this._drawInfo,r=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();let n=this._colorsTexture,r=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||i[e].active===!1?this:(t.toArray(r,e*4),n.needsUpdate=!0,this)}getColorAt(e,t){let n=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(n,e*4)}setVisibleAt(e,t){let n=this._drawInfo;return e>=n.length||n[e].active===!1||n[e].visible===t?this:(n[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){let n=this._drawInfo;return e>=n.length||n[e].active===!1||t<0||t>=this._geometryCount?null:(n[e].geometryIndex=t,this)}getGeometryIdAt(e){let t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;let n=this._drawRanges[e];return t.start=n.start,t.count=n.count,t}raycast(e,t){let n=this._drawInfo,r=this._drawRanges,i=this.matrixWorld,a=this.geometry;$l.material=this.material,$l.geometry.index=a.index,$l.geometry.attributes=a.attributes,$l.geometry.boundingBox===null&&($l.geometry.boundingBox=new Gn),$l.geometry.boundingSphere===null&&($l.geometry.boundingSphere=new lr);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;let o=n[a].geometryIndex,s=r[o];$l.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(a,$l.matrixWorld).premultiply(i),this.getBoundingBoxAt(o,$l.geometry.boundingBox),this.getBoundingSphereAt(o,$l.geometry.boundingSphere),$l.raycast(e,eu);for(let e=0,n=eu.length;e<n;e++){let n=eu[e];n.object=this,n.batchId=a,t.push(n)}eu.length=0}$l.material=null,$l.geometry.index=null,$l.geometry.attributes={},$l.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?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this._drawRanges=e._drawRanges.map(e=>({...e})),this._reservedRanges=e._reservedRanges.map(e=>({...e})),this._drawInfo=e._drawInfo.map(e=>({...e})),this._bounds=e._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,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.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=this._drawInfo,c=this._multiDrawStarts,l=this._multiDrawCounts,u=this._drawRanges,d=this.perObjectFrustumCulled,f=this._indirectTexture,p=f.image.data;d&&(Gl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Kl.setFromProjectionMatrix(Gl,e.coordinateSystem));let m=0;if(this.sortObjects){Hl.copy(this.matrixWorld).invert(),Yl.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Hl),Xl.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Hl);for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex;this.getMatrixAt(e,Vl),this.getBoundingSphereAt(t,Jl).applyMatrix4(Vl);let n=!1;if(d&&(n=!Kl.intersectsSphere(Jl)),!n){let n=Zl.subVectors(Jl.center,Yl).dot(Xl);Ql.push(u[t],n,e)}}let e=Ql.list,t=this.customSort;t===null?e.sort(i.transparent?zl:Rl):t.call(this,e,n);for(let t=0,n=e.length;t<n;t++){let n=e[t];c[m]=n.start*o,l[m]=n.count,p[m]=n.index,m++}Ql.reset()}else for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex,n=!1;if(d&&(this.getMatrixAt(e,Vl),this.getBoundingSphereAt(t,Jl).applyMatrix4(Vl),n=!Kl.intersectsSphere(Jl)),!n){let n=u[t];c[m]=n.start*o,l[m]=n.count,p[m]=e,m++}}f.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,i,a){this.onBeforeRender(e,null,r,i,a)}},ru=class extends di{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new P(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}},iu=new M,au=new M,ou=new N,su=new _r,cu=new lr,lu=new M,uu=new M,du=class extends Wr{constructor(e=new Ii,t=new ru){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,n=[0];for(let e=1,r=t.count;e<r;e++)iu.fromBufferAttribute(t,e-1),au.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=iu.distanceTo(au);e.setAttribute(`lineDistance`,new F(n,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cu.copy(n.boundingSphere),cu.applyMatrix4(r),cu.radius+=i,e.ray.intersectsSphere(cu)===!1)return;ou.copy(r).invert(),su.copy(e.ray).applyMatrix4(ou);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=fu(this,e,su,s,n,r);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=fu(this,e,su,s,i,a);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=fu(this,e,su,s,i,i+1);n&&t.push(n)}if(this.isLineLoop){let i=fu(this,e,su,s,r-1,n);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function fu(e,t,n,r,i,a){let o=e.geometry.attributes.position;if(iu.fromBufferAttribute(o,i),au.fromBufferAttribute(o,a),n.distanceSqToSegment(iu,au,lu,uu)>r)return;lu.applyMatrix4(e.matrixWorld);let s=t.ray.origin.distanceTo(lu);if(!(s<t.near||s>t.far))return{distance:s,point:uu.clone().applyMatrix4(e.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:e}}var pu=new M,mu=new M,hu=class extends du{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)pu.fromBufferAttribute(t,e),mu.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+pu.distanceTo(mu);e.setAttribute(`lineDistance`,new F(n,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},gu=class extends du{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},_u=class extends di{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new P(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}},vu=new N,yu=new _r,bu=new lr,xu=new M,Su=class extends Wr{constructor(e=new Ii,t=new _u){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 n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),bu.copy(n.boundingSphere),bu.applyMatrix4(r),bu.radius+=i,e.ray.intersectsSphere(bu)===!1)return;vu.copy(r).invert(),yu.copy(e.ray).applyMatrix4(vu);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);xu.fromBufferAttribute(l,n),Cu(xu,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)xu.fromBufferAttribute(l,a),Cu(xu,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Cu(e,t,n,r,i,a,o){let s=yu.distanceSqToPoint(e);if(s<n){let n=new M;yu.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var wu=class extends Pn{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.minFilter=a===void 0?h:a,this.magFilter=i===void 0?h:i,this.generateMipmaps=!1;let l=this;function u(){l.needsUpdate=!0,e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Tu=class extends Pn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=u,this.minFilter=u,this.generateMipmaps=!1,this.needsUpdate=!0}},Eu=class extends Pn{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Du=class extends Eu{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=c,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Ou=class extends Eu{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},ku=class extends Pn{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Au=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200}getPoint(){return console.warn(`THREE.Curve: .getPoint() not implemented.`),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new A:new M);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new M,r=[],i=[],a=[],o=new M,s=new N;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new M)}i[0]=new M,a[0]=new M;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(Vt(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(Vt(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ju=class extends Au{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new A){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Mu=class extends ju{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Nu(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Pu=new M,Fu=new Nu,Iu=new Nu,Lu=new Nu,Ru=class extends Au{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new M){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Pu.subVectors(r[0],r[1]).add(r[0]),c=Pu);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Pu.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Pu),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Fu.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Iu.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Lu.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Fu.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Iu.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Lu.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Fu.calc(s),Iu.calc(s),Lu.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.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,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.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,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new M().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function zu(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Bu(e,t){let n=1-e;return n*n*t}function Vu(e,t){return 2*(1-e)*e*t}function Hu(e,t){return e*e*t}function Uu(e,t,n,r){return Bu(e,t)+Vu(e,n)+Hu(e,r)}function Wu(e,t){let n=1-e;return n*n*n*t}function Gu(e,t){let n=1-e;return 3*n*n*e*t}function Ku(e,t){return 3*(1-e)*e*e*t}function qu(e,t){return e*e*e*t}function Ju(e,t,n,r,i){return Wu(e,t)+Gu(e,n)+Ku(e,r)+qu(e,i)}var Yu=class extends Au{constructor(e=new A,t=new A,n=new A,r=new A){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new A){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Ju(e,r.x,i.x,a.x,o.x),Ju(e,r.y,i.y,a.y,o.y)),n}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}},Xu=class extends Au{constructor(e=new M,t=new M,n=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new M){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Ju(e,r.x,i.x,a.x,o.x),Ju(e,r.y,i.y,a.y,o.y),Ju(e,r.z,i.z,a.z,o.z)),n}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}},Zu=class extends Au{constructor(e=new A,t=new A){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new A){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}},Qu=class extends Au{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new M){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new M){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}},$u=class extends Au{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Uu(e,r.x,i.x,a.x),Uu(e,r.y,i.y,a.y)),n}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}},ed=class extends Au{constructor(e=new M,t=new M,n=new M){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new M){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Uu(e,r.x,i.x,a.x),Uu(e,r.y,i.y,a.y),Uu(e,r.z,i.z,a.z)),n}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}},td=class extends Au{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new A){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(zu(o,s.x,c.x,l.x,u.x),zu(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new A().fromArray(n))}return this}},nd=Object.freeze({__proto__:null,ArcCurve:Mu,CatmullRomCurve3:Ru,CubicBezierCurve:Yu,CubicBezierCurve3:Xu,EllipseCurve:ju,LineCurve:Zu,LineCurve3:Qu,QuadraticBezierCurve:$u,QuadraticBezierCurve3:ed,SplineCurve:td}),rd=class extends Au{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 n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new nd[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}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,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new nd[n.type]().fromJSON(n))}return this}},id=class extends rd{constructor(e){super(),this.type=`Path`,this.currentPoint=new A,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;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 n=new Zu(this.currentPoint.clone(),new A(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new $u(this.currentPoint.clone(),new A(e,t),new A(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new Yu(this.currentPoint.clone(),new A(e,t),new A(n,r),new A(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new td([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new ju(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ad=class e extends Ii{constructor(e=[new A(0,-.5),new A(.5,0),new A(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type=`LatheGeometry`,this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Vt(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new M,d=new A,f=new M,p=new M,m=new M,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){let r=t+n*e.length,a=r,o=r+e.length,s=r+e.length+1,c=r+1;i.push(a,o,c),i.push(s,c,o)}this.setIndex(i),this.setAttribute(`position`,new F(a,3)),this.setAttribute(`uv`,new F(o,2)),this.setAttribute(`normal`,new F(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.points,t.segments,t.phiStart,t.phiLength)}},od=class e extends ad{constructor(e=1,t=1,n=4,r=8){let i=new id;i.absarc(0,-t/2,e,Math.PI*1.5,0),i.absarc(0,t/2,e,0,Math.PI*.5),super(i.getPoints(n),r),this.type=`CapsuleGeometry`,this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(t){return new e(t.radius,t.length,t.capSegments,t.radialSegments)}},sd=class e extends Ii{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type=`CircleGeometry`,this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let i=[],a=[],o=[],s=[],c=new M,l=new A;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new F(a,3)),this.setAttribute(`normal`,new F(o,3)),this.setAttribute(`uv`,new F(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},cd=class e extends Ii{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new F(u,3)),this.setAttribute(`normal`,new F(d,3)),this.setAttribute(`uv`,new F(f,2));function _(){let a=new M,_=new M,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let i=m[r][n],a=m[r+1][n],o=m[r+1][n+1],s=m[r][n+1];e>0&&(l.push(i,a,s),v+=3),t>0&&(l.push(a,o,s),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new A,m=new M,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ld=class e extends cd{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ud=class e extends Ii{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];o(r),c(n),l(),this.setAttribute(`position`,new F(i,3)),this.setAttribute(`normal`,new F(i.slice(),3)),this.setAttribute(`uv`,new F(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(e){let n=new M,r=new M,i=new M;for(let a=0;a<t.length;a+=3)f(t[a+0],n),f(t[a+1],r),f(t[a+2],i),s(n,r,i,e)}function s(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)e===0&&r===i?a[r][e]=o:a[r][e]=o.clone().lerp(s,e/c)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){let n=Math.floor(t/2);t%2==0?(d(a[e][n+1]),d(a[e+1][n]),d(a[e][n])):(d(a[e][n+1]),d(a[e+1][n+1]),d(a[e+1][n]))}}function c(e){let t=new M;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}function l(){let e=new M;for(let t=0;t<i.length;t+=3){e.x=i[t+0],e.y=i[t+1],e.z=i[t+2];let n=h(e)/2/Math.PI+.5,r=g(e)/Math.PI+.5;a.push(n,1-r)}p(),u()}function u(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],r=a[e+4];Math.max(t,n,r)>.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new M,t=new M,n=new M,r=new M,o=new A,s=new A,c=new A;for(let l=0,u=0;l<i.length;l+=9,u+=6){e.set(i[l+0],i[l+1],i[l+2]),t.set(i[l+3],i[l+4],i[l+5]),n.set(i[l+6],i[l+7],i[l+8]),o.set(a[u+0],a[u+1]),s.set(a[u+2],a[u+3]),c.set(a[u+4],a[u+5]),r.copy(e).add(t).add(n).divideScalar(3);let d=h(r);m(o,u+0,e,d),m(s,u+2,t,d),m(c,u+4,n,d)}}function m(e,t,n,r){r<0&&e.x===1&&(a[t]=e.x-1),n.x===0&&n.z===0&&(a[t]=r/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}function g(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.details)}},dd=class e extends ud{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,i=[-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,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];super(i,[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],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},fd=new M,pd=new M,md=new M,hd=new ii,gd=class extends Ii{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=10**4,r=Math.cos(Rt*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u={},d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=hd;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),hd.getNormal(md),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,!(l[0]===l[1]||l[1]===l[2]||l[2]===l[0]))for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=hd[c[e]],o=hd[c[t]],f=`${n}_${i}`,p=`${i}_${n}`;p in u&&u[p]?(md.dot(u[p].normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u[p]=null):f in u||(u[f]={index0:s[e],index1:s[t],normal:md.clone()})}}for(let e in u)if(u[e]){let{index0:t,index1:n}=u[e];fd.fromBufferAttribute(a,t),pd.fromBufferAttribute(a,n),d.push(fd.x,fd.y,fd.z),d.push(pd.x,pd.y,pd.z)}this.setAttribute(`position`,new F(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},_d=class extends id{constructor(e){super(e),this.uuid=Bt(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new id().fromJSON(n))}return this}},vd={triangulate:function(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=yd(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l,u,d,f,p;if(r&&(a=Ed(e,t,a,n)),e.length>80*n){s=l=e[0],c=u=e[1];for(let t=n;t<i;t+=n)d=e[t],f=e[t+1],d<s&&(s=d),f<c&&(c=f),d>l&&(l=d),f>u&&(u=f);p=Math.max(l-s,u-c),p=p===0?0:32767/p}return xd(a,o,n,s,c,p,0),o}};function yd(e,t,n,r,i){let a,o;if(i===Yd(e,t,n,r)>0)for(a=t;a<n;a+=r)o=Kd(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=Kd(a,e[a],e[a+1],o);return o&&Rd(o,o.next)&&(qd(o),o=o.next),o}function bd(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Rd(n,n.next)||Ld(n.prev,n,n.next)===0)){if(qd(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function xd(e,t,n,r,i,a,o){if(!e)return;!o&&a&&jd(e,r,i,a);let s=e,c,l;for(;e.prev!==e.next;){if(c=e.prev,l=e.next,a?Cd(e,r,i,a):Sd(e)){t.push(c.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),qd(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=wd(bd(e),t,n),xd(e,t,n,r,i,a,2)):o===2&&Td(e,t,n,r,i,a):xd(bd(e),t,n,r,i,a,1);break}}}function Sd(e){let t=e.prev,n=e,r=e.next;if(Ld(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,d=s<c?s<l?s:l:c<l?c:l,f=i>a?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Fd(i,s,a,c,o,l,m.x,m.y)&&Ld(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Cd(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Ld(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=s<c?s<l?s:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,h=s>c?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,_=Nd(p,m,t,n,r),v=Nd(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Fd(s,u,c,d,l,f,y.x,y.y)&&Ld(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Fd(s,u,c,d,l,f,b.x,b.y)&&Ld(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Fd(s,u,c,d,l,f,y.x,y.y)&&Ld(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Fd(s,u,c,d,l,f,b.x,b.y)&&Ld(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function wd(e,t,n){let r=e;do{let i=r.prev,a=r.next.next;!Rd(i,a)&&zd(i,r,r.next,a)&&Ud(i,a)&&Ud(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),qd(r),qd(r.next),r=e=a),r=r.next}while(r!==e);return bd(r)}function Td(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Id(o,e)){let s=Gd(o,e);o=bd(o,o.next),s=bd(s,s.next),xd(o,t,n,r,i,a,0),xd(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Ed(e,t,n,r){let i=[],a,o,s,c,l;for(a=0,o=t.length;a<o;a++)s=t[a]*r,c=a<o-1?t[a+1]*r:e.length,l=yd(e,s,c,r,!1),l===l.next&&(l.steiner=!0),i.push(Pd(l));for(i.sort(Dd),a=0;a<i.length;a++)n=Od(i[a],n);return n}function Dd(e,t){return e.x-t.x}function Od(e,t){let n=kd(e,t);if(!n)return t;let r=Gd(n,e);return bd(r,r.next),bd(n,n.next)}function kd(e,t){let n=t,r=-1/0,i,a=e.x,o=e.y;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let e=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=a&&e>r&&(r=e,i=n.x<n.next.x?n:n.next,e===a))return i}n=n.next}while(n!==t);if(!i)return null;let s=i,c=i.x,l=i.y,u=1/0,d;n=i;do a>=n.x&&n.x>=c&&a!==n.x&&Fd(o<l?a:r,o,c,l,o<l?r:a,o,n.x,n.y)&&(d=Math.abs(o-n.y)/(a-n.x),Ud(n,e)&&(d<u||d===u&&(n.x>i.x||n.x===i.x&&Ad(i,n)))&&(i=n,u=d)),n=n.next;while(n!==s);return i}function Ad(e,t){return Ld(e.prev,e,t.prev)<0&&Ld(t.next,e,e.next)<0}function jd(e,t,n,r){let i=e;do i.z===0&&(i.z=Nd(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Md(i)}function Md(e){let t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(c=l;s>0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function Nd(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Pd(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Fd(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Id(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Hd(e,t)&&(Ud(e,t)&&Ud(t,e)&&Wd(e,t)&&(Ld(e.prev,e,t.prev)||Ld(e,t.prev,t))||Rd(e,t)&&Ld(e.prev,e,e.next)>0&&Ld(t.prev,t,t.next)>0)}function Ld(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Rd(e,t){return e.x===t.x&&e.y===t.y}function zd(e,t,n,r){let i=Vd(Ld(e,t,n)),a=Vd(Ld(e,t,r)),o=Vd(Ld(n,r,e)),s=Vd(Ld(n,r,t));return!!(i!==a&&o!==s||i===0&&Bd(e,n,t)||a===0&&Bd(e,r,t)||o===0&&Bd(n,e,r)||s===0&&Bd(n,t,r))}function Bd(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Vd(e){return e>0?1:e<0?-1:0}function Hd(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&zd(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ud(e,t){return Ld(e.prev,e,e.next)<0?Ld(e,t,e.next)>=0&&Ld(e,e.prev,t)>=0:Ld(e,t,e.prev)<0||Ld(e,e.next,t)<0}function Wd(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Gd(e,t){let n=new Jd(e.i,e.x,e.y),r=new Jd(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Kd(e,t,n,r){let i=new Jd(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function qd(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Jd(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Yd(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Xd=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Zd(e),Qd(n,e);let a=e.length;t.forEach(Zd);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Qd(n,t[e]);let o=vd.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Zd(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Qd(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var $d=class e extends Ii{constructor(e=new _d([new A(.5,.5),new A(-.5,.5),new A(-.5,-.5),new A(.5,-.5)]),t={}){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new F(r,3)),this.setAttribute(`uv`,new F(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?1:t.depth,l=t.bevelEnabled===void 0?!0:t.bevelEnabled,u=t.bevelThickness===void 0?.2:t.bevelThickness,d=t.bevelSize===void 0?u-.1:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?ef:t.UVGenerator,g,_=!1,v,y,b,x;m&&(g=m.getSpacedPoints(s),_=!0,l=!1,v=m.computeFrenetFrames(s,!1),y=new M,b=new M,x=new M),l||(p=0,u=0,d=0,f=0);let S=e.extractPoints(o),C=S.shape,w=S.holes;if(!Xd.isClockWise(C)){C=C.reverse();for(let e=0,t=w.length;e<t;e++){let t=w[e];Xd.isClockWise(t)&&(w[e]=t.reverse())}}let T=Xd.triangulateShape(C,w),E=C;for(let e=0,t=w.length;e<t;e++){let t=w[e];C=C.concat(t)}function D(e,t,n){return t||console.error(`THREE.ExtrudeGeometry: vec does not exist`),e.clone().addScaledVector(t,n)}let ee=C.length,O=T.length;function te(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new A(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new A(r/a,i/a)}let ne=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),ne[e]=te(E[e],E[n],E[r]);let re=[],ie,ae=ne.concat();for(let e=0,t=w.length;e<t;e++){let t=w[e];ie=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),ie[e]=te(t[e],t[r],t[i]);re.push(ie),ae=ae.concat(ie)}for(let e=0;e<p;e++){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){let t=D(E[e],ne[e],r);ue(t.x,t.y,-n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];ie=re[e];for(let e=0,i=t.length;e<i;e++){let i=D(t[e],ie[e],r);ue(i.x,i.y,-n)}}}let oe=d+f;for(let e=0;e<ee;e++){let t=l?D(C[e],ae[e],oe):C[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),ue(x.x,x.y,x.z)):ue(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<ee;t++){let n=l?D(C[t],ae[t],oe):C[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),ue(x.x,x.y,x.z)):ue(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){let t=D(E[e],ne[e],r);ue(t.x,t.y,c+n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];ie=re[e];for(let e=0,i=t.length;e<i;e++){let i=D(t[e],ie[e],r);_?ue(i.x,i.y+g[s-1].y,g[s-1].x+n):ue(i.x,i.y,c+n)}}}se(),ce();function se(){let e=r.length/3;if(l){let e=0,t=ee*e;for(let e=0;e<O;e++){let n=T[e];de(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=ee*e;for(let e=0;e<O;e++){let n=T[e];de(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<O;e++){let t=T[e];de(t[2],t[1],t[0])}for(let e=0;e<O;e++){let t=T[e];de(t[0]+ee*s,t[1]+ee*s,t[2]+ee*s)}}n.addGroup(e,r.length/3-e,0)}function ce(){let e=r.length/3,t=0;le(E,t),t+=E.length;for(let e=0,n=w.length;e<n;e++){let n=w[e];le(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function le(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=ee*e,a=ee*(e+1);fe(t+r+n,t+i+n,t+i+a,t+r+a)}}}function ue(e,t,n){a.push(e),a.push(t),a.push(n)}function de(e,t,i){pe(e),pe(t),pe(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);me(o[0]),me(o[1]),me(o[2])}function fe(e,t,i,a){pe(e),pe(t),pe(a),pe(t),pe(i),pe(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);me(s[0]),me(s[1]),me(s[3]),me(s[1]),me(s[2]),me(s[3])}function pe(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function me(e){i.push(e.x),i.push(e.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return tf(t,n,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new nd[i.type]().fromJSON(i)),new e(r,t.options)}},ef={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new A(a,o),new A(s,c),new A(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<Math.abs(o-l)?[new A(o,1-c),new A(l,1-d),new A(f,1-m),new A(h,1-_)]:[new A(s,1-c),new A(u,1-d),new A(p,1-m),new A(g,1-_)]}};function tf(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}var nf=class e extends ud{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];super(r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type=`IcosahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},rf=class e extends ud{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=`OctahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},af=class e extends Ii{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new M,p=new A;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new F(s,3)),this.setAttribute(`normal`,new F(c,3)),this.setAttribute(`uv`,new F(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},of=class e extends Ii{constructor(e=new _d([new A(0,.5),new A(-.5,-.5),new A(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new F(r,3)),this.setAttribute(`normal`,new F(i,3)),this.setAttribute(`uv`,new F(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Xd.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Xd.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Xd.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return sf(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function sf(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var cf=class e extends Ii{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new M,d=new M,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new F(p,3)),this.setAttribute(`normal`,new F(m,3)),this.setAttribute(`uv`,new F(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},lf=class e extends ud{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=`TetrahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},uf=class e extends Ii{constructor(e=1,t=.4,n=12,r=48,i=Math.PI*2){super(),this.type=`TorusGeometry`,this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},n=Math.floor(n),r=Math.floor(r);let a=[],o=[],s=[],c=[],l=new M,u=new M,d=new M;for(let a=0;a<=n;a++)for(let f=0;f<=r;f++){let p=f/r*i,m=a/n*Math.PI*2;u.x=(e+t*Math.cos(m))*Math.cos(p),u.y=(e+t*Math.cos(m))*Math.sin(p),u.z=t*Math.sin(m),o.push(u.x,u.y,u.z),l.x=e*Math.cos(p),l.y=e*Math.sin(p),d.subVectors(u,l).normalize(),s.push(d.x,d.y,d.z),c.push(f/r),c.push(a/n)}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,o=(r+1)*(e-1)+t,s=(r+1)*e+t;a.push(n,i,s),a.push(i,o,s)}this.setIndex(a),this.setAttribute(`position`,new F(o,3)),this.setAttribute(`normal`,new F(s,3)),this.setAttribute(`uv`,new F(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},df=class e extends Ii{constructor(e=1,t=.4,n=64,r=8,i=2,a=3){super(),this.type=`TorusKnotGeometry`,this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},n=Math.floor(n),r=Math.floor(r);let o=[],s=[],c=[],l=[],u=new M,d=new M,f=new M,p=new M,m=new M,h=new M,g=new M;for(let o=0;o<=n;++o){let v=o/n*i*Math.PI*2;_(v,i,a,e,f),_(v+.01,i,a,e,p),h.subVectors(p,f),g.addVectors(p,f),m.crossVectors(h,g),g.crossVectors(m,h),m.normalize(),g.normalize();for(let e=0;e<=r;++e){let i=e/r*Math.PI*2,a=-t*Math.cos(i),p=t*Math.sin(i);u.x=f.x+(a*g.x+p*m.x),u.y=f.y+(a*g.y+p*m.y),u.z=f.z+(a*g.z+p*m.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),l.push(o/n),l.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,s=(r+1)*(e-1)+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute(`position`,new F(s,3)),this.setAttribute(`normal`,new F(c,3)),this.setAttribute(`uv`,new F(l,2));function _(e,t,n,r,i){let a=Math.cos(e),o=Math.sin(e),s=n/t*e,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},ff=class e extends Ii{constructor(e=new ed(new M(-1,-1,0),new M(-1,1,0),new M(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type=`TubeGeometry`,this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};let a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new M,s=new M,c=new A,l=new M,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute(`position`,new F(u,3)),this.setAttribute(`normal`,new F(d,3)),this.setAttribute(`uv`,new F(f,2));function m(){for(let e=0;e<t;e++)h(e);h(i===!1?t:0),_(),g()}function h(i){l=e.getPointAt(i/t,l);let c=a.normals[i],f=a.binormals[i];for(let e=0;e<=r;e++){let t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*c.x+i*f.x,s.y=a*c.y+i*f.y,s.z=a*c.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,u.push(o.x,o.y,o.z)}}function g(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;p.push(n,i,o),p.push(i,a,o)}}function _(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)c.x=e/t,c.y=n/r,f.push(c.x,c.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(t){return new e(new nd[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},pf=class extends Ii{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new M,i=new M;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),mf(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),mf(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new F(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function mf(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}var hf=Object.freeze({__proto__:null,BoxGeometry:Zi,CapsuleGeometry:od,CircleGeometry:sd,ConeGeometry:ld,CylinderGeometry:cd,DodecahedronGeometry:dd,EdgesGeometry:gd,ExtrudeGeometry:$d,IcosahedronGeometry:nf,LatheGeometry:ad,OctahedronGeometry:rf,PlaneGeometry:Oa,PolyhedronGeometry:ud,RingGeometry:af,ShapeGeometry:of,SphereGeometry:cf,TetrahedronGeometry:lf,TorusGeometry:uf,TorusKnotGeometry:df,TubeGeometry:ff,WireframeGeometry:pf}),gf=class extends di{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new P(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}},_f=class extends aa{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},vf=class extends di{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:``},this.type=`MeshStandardMaterial`,this.color=new P(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 P(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},yf=class extends vf{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 A(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,`reflectivity`,{get:function(){return Vt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new P(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 P(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new P(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},bf=class extends di{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new P(16777215),this.specular=new P(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new P(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},xf=class extends di{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new P(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new P(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(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}},Sf=class extends di{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(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}},Cf=class extends di{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new P(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new P(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wf=class extends di{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new P(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new A(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}},Tf=class extends ru{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function Ef(e,t,n){return!e||!n&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Df(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Of(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function kf(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Af(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push.apply(n,o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}function jf(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=Ef(c,t.times.constructor),t.values=Ef(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a}function Mf(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=e.resultBuffer.slice(t,n)}i===`quaternion`&&new Hn().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)Hn.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=it,e}var Nf={convertArray:Ef,isTypedArray:Df,getKeyframeOrder:Of,sortedArray:kf,flattenJSON:Af,subclip:jf,makeClipAdditive:Mf},Pf=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},Ff=class extends Pf{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:et,endingEnd:et}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case tt:i=e,o=2*t-n;break;case nt:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case tt:a=e,s=2*n-t;break;case nt:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},If=class extends Pf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Lf=class extends Pf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Rf=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=Ef(t,this.TimeBufferType),this.values=Ef(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ef(e.times,Array),values:Ef(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Lf(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new If(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ff(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ze:t=this.InterpolantFactoryMethodDiscrete;break;case Qe:t=this.InterpolantFactoryMethodLinear;break;case $e:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`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 Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ze;case this.InterpolantFactoryMethodLinear:return Qe;case this.InterpolantFactoryMethodSmooth:return $e}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Df(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===$e,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Rf.prototype.TimeBufferType=Float32Array,Rf.prototype.ValueBufferType=Float32Array,Rf.prototype.DefaultInterpolation=Qe;var zf=class extends Rf{constructor(e,t,n){super(e,t,n)}};zf.prototype.ValueTypeName=`bool`,zf.prototype.ValueBufferType=Array,zf.prototype.DefaultInterpolation=Ze,zf.prototype.InterpolantFactoryMethodLinear=void 0,zf.prototype.InterpolantFactoryMethodSmooth=void 0;var Bf=class extends Rf{};Bf.prototype.ValueTypeName=`color`;var Vf=class extends Rf{};Vf.prototype.ValueTypeName=`number`;var Hf=class extends Pf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Hn.slerpFlat(i,0,a,c-o,a,c,s);return i}},Uf=class extends Rf{InterpolantFactoryMethodLinear(e){return new Hf(this.times,this.values,this.getValueSize(),e)}};Uf.prototype.ValueTypeName=`quaternion`,Uf.prototype.InterpolantFactoryMethodSmooth=void 0;var Wf=class extends Rf{constructor(e,t,n){super(e,t,n)}};Wf.prototype.ValueTypeName=`string`,Wf.prototype.ValueBufferType=Array,Wf.prototype.DefaultInterpolation=Ze,Wf.prototype.InterpolantFactoryMethodLinear=void 0,Wf.prototype.InterpolantFactoryMethodSmooth=void 0;var Gf=class extends Rf{};Gf.prototype.ValueTypeName=`vector`;var Kf=class{constructor(e=``,t=-1,n=[],r=rt){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Bt(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(Jf(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(Rf.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e<i;e++){let o=[],s=[];o.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);let c=Of(o);o=kf(o,1,c),s=kf(s,1,c),!r&&o[0]===0&&(o.push(i),s.push(s[0])),a.push(new Vf(`.morphTargetInfluences[`+t[e].name+`]`,o,s).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.name.match(i);if(a&&a.length>1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error(`THREE.AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];Af(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e<c.length;e++){let i=c[e].keys;if(!(!i||i.length===0))if(i[0].morphTargets){let e={},t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(let n in e){let e=[],a=[];for(let r=0;r!==i[t].morphTargets.length;++r){let r=i[t];e.push(r.time),a.push(+(r.morphTarget===n))}r.push(new Vf(`.morphTargetInfluence[`+n+`]`,e,a))}s=e.length*a}else{let a=`.bones[`+t[e].name+`]`;n(Gf,a+`.position`,i,`pos`,r),n(Uf,a+`.quaternion`,i,`rot`,r),n(Gf,a+`.scale`,i,`scl`,r)}}return r.length===0?null:new this(i,s,r,o)}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.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&&=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)}};function qf(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return Vf;case`vector`:case`vector2`:case`vector3`:case`vector4`:return Gf;case`color`:return Bf;case`quaternion`:return Uf;case`bool`:case`boolean`:return zf;case`string`:return Wf}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function Jf(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=qf(e.type);if(e.times===void 0){let t=[],n=[];Af(e.keys,t,n,`value`),e.times=t,e.values=n}return t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e)}var Yf={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Xf=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}},Zf=new Xf,Qf=class{constructor(e){this.manager=e===void 0?Zf:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}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}};Qf.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var $f={},ep=class extends Error{constructor(e,t){super(e),this.response=t}},tp=class extends Qf{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=Yf.get(e);if(i!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(i),this.manager.itemEnd(e)},0),i;if($f[e]!==void 0){$f[e].push({onLoad:t,onProgress:n,onError:r});return}$f[e]=[],$f[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&console.warn(`THREE.FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=$f[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}},t=>{e.error(t)})}}});return new Response(c)}else throw new ep(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===void 0)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{Yf.add(e,t);let n=$f[e];delete $f[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{let n=$f[e];if(n===void 0)throw this.manager.itemError(e),t;delete $f[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}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}},np=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new tp(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n<e.length;n++){let r=Kf.parse(e[n]);t.push(r)}return t}},rp=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=[],o=new Eu,s=new tp(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let c=0;function l(l){s.load(e[l],function(e){let n=i.parse(e,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},c+=1,c===6&&(n.mipmapCount===1&&(o.minFilter=h),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)l(t);else s.load(e,function(e){let n=i.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}o.image=a}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;n.mipmapCount===1&&(o.minFilter=h),o.format=n.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}},ip=class extends Qf{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Yf.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;let o=mn(`img`);function s(){l(),Yf.add(e,this),t&&t(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}},ap=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=new _a;i.colorSpace=lt;let a=new ip(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],function(e){i.images[n]=e,o++,o===6&&(i.needsUpdate=!0,t&&t(i))},void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}},op=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new Tl,o=new tp(this.manager);return o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){let n;try{n=i.parse(e)}catch(e){if(r!==void 0)r(e);else{console.error(e);return}}n.image===void 0?n.data!==void 0&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data):a.image=n.image,a.wrapS=n.wrapS===void 0?c:n.wrapS,a.wrapT=n.wrapT===void 0?c:n.wrapT,a.magFilter=n.magFilter===void 0?h:n.magFilter,a.minFilter=n.minFilter===void 0?h:n.minFilter,a.anisotropy=n.anisotropy===void 0?1:n.anisotropy,n.colorSpace!==void 0&&(a.colorSpace=n.colorSpace),n.flipY!==void 0&&(a.flipY=n.flipY),n.format!==void 0&&(a.format=n.format),n.type!==void 0&&(a.type=n.type),n.mipmaps!==void 0&&(a.mipmaps=n.mipmaps,a.minFilter=v),n.mipmapCount===1&&(a.minFilter=h),n.generateMipmaps!==void 0&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)},n,r),a}},sp=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=new Pn,a=new ip(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},cp=class extends Wr{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new P(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()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},lp=class extends cp{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(Wr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new P(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},up=new N,dp=new M,fp=new M,pp=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new A(512,512),this.map=null,this.mapPass=null,this.matrix=new N,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ta,this._frameExtents=new A(1,1),this._viewportCount=1,this._viewports=[new Fn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;dp.setFromMatrixPosition(e.matrixWorld),t.position.copy(dp),fp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(fp),t.updateMatrixWorld(),up.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(up),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(up)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},mp=class extends pp{constructor(){super(new pa(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=zt*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},hp=class extends cp{constructor(e,t,n=0,r=Math.PI/3,i=0,a=2){super(e,t),this.isSpotLight=!0,this.type=`SpotLight`,this.position.copy(Wr.DEFAULT_UP),this.updateMatrix(),this.target=new Wr,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new mp}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}},gp=new N,_p=new M,vp=new M,yp=class extends pp{constructor(){super(new pa(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new A(4,2),this._viewportCount=6,this._viewports=[new Fn(2,1,1,1),new Fn(0,1,1,1),new Fn(3,1,1,1),new Fn(1,1,1,1),new Fn(3,0,1,1),new Fn(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),_p.setFromMatrixPosition(e.matrixWorld),n.position.copy(_p),vp.copy(n.position),vp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(vp),n.updateMatrixWorld(),r.makeTranslation(-_p.x,-_p.y,-_p.z),gp.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gp)}},bp=class extends cp{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type=`PointLight`,this.distance=n,this.decay=r,this.shadow=new yp}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}},xp=class extends pp{constructor(){super(new Ba(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Sp=class extends cp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(Wr.DEFAULT_UP),this.updateMatrix(),this.target=new Wr,this.shadow=new xp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Cp=class extends cp{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},wp=class extends cp{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type=`RectAreaLight`,this.width=n,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}},Tp=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new M)}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 n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*i),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],2*.429043*n*i),t.addScaledVector(a[8],.429043*(n*n-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 n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],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 n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},Ep=class extends cp{constructor(e=new Tp,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}},Dp=class e extends Qf{constructor(e){super(e),this.textures={}}load(e,t,n,r){let i=this,a=new tp(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t=this.textures;function n(e){return t[e]===void 0&&console.warn(`THREE.MaterialLoader: Undefined texture`,e),t[e]}let r=this.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 P().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.dispersion!==void 0&&(r.dispersion=e.dispersion),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 t in e.uniforms){let i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case`t`:r.uniforms[t].value=n(i.value);break;case`c`:r.uniforms[t].value=new P().setHex(i.value);break;case`v2`:r.uniforms[t].value=new A().fromArray(i.value);break;case`v3`:r.uniforms[t].value=new M().fromArray(i.value);break;case`v4`:r.uniforms[t].value=new Fn().fromArray(i.value);break;case`m3`:r.uniforms[t].value=new j().fromArray(i.value);break;case`m4`:r.uniforms[t].value=new N().fromArray(i.value);break;default:r.uniforms[t].value=i.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 t in e.extensions)r.extensions[t]=e.extensions[t];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=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),r.normalScale=new A().fromArray(t)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),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=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new A().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(t){return e.createMaterialFromType(t)}static createMaterialFromType(e){return new{ShadowMaterial:gf,SpriteMaterial:Yc,RawShaderMaterial:_f,ShaderMaterial:aa,PointsMaterial:_u,MeshPhysicalMaterial:yf,MeshStandardMaterial:vf,MeshPhongMaterial:bf,MeshToonMaterial:xf,MeshNormalMaterial:Sf,MeshLambertMaterial:Cf,MeshDepthMaterial:hc,MeshDistanceMaterial:gc,MeshBasicMaterial:fi,MeshMatcapMaterial:wf,LineDashedMaterial:Tf,LineBasicMaterial:ru,Material:di}[e]}},Op=class{static decodeText(e){if(console.warn(`THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.`),typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``;for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);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)}},kp=class extends Ii{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}},Ap=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new tp(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(e,n){if(t[n]!==void 0)return t[n];let r=e.interleavedBuffers[n],a=i(e,r.buffer),o=new Kc(pn(r.type,a),r.stride);return o.uuid=r.uuid,t[n]=o,o}function i(e,t){if(n[t]!==void 0)return n[t];let r=e.arrayBuffers[t],i=new Uint32Array(r).buffer;return n[t]=i,i}let a=e.isInstancedBufferGeometry?new kp:new Ii,o=e.data.index;if(o!==void 0){let e=pn(o.type,o.array);a.setIndex(new bi(e,1))}let s=e.data.attributes;for(let t in s){let n=s[t],i;if(n.isInterleavedBufferAttribute)i=new Jc(r(e.data,n.data),n.itemSize,n.offset,n.normalized);else{let e=pn(n.type,n.array);i=new(n.isInstancedBufferAttribute?kl:bi)(e,n.itemSize,n.normalized)}n.name!==void 0&&(i.name=n.name),n.usage!==void 0&&i.setUsage(n.usage),a.setAttribute(t,i)}let c=e.data.morphAttributes;if(c)for(let t in c){let n=c[t],i=[];for(let t=0,a=n.length;t<a;t++){let a=n[t],o;o=a.isInterleavedBufferAttribute?new Jc(r(e.data,a.data),a.itemSize,a.offset,a.normalized):new bi(pn(a.type,a.array),a.itemSize,a.normalized),a.name!==void 0&&(o.name=a.name),i.push(o)}a.morphAttributes[t]=i}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(l!==void 0)for(let e=0,t=l.length;e!==t;++e){let t=l[e];a.addGroup(t.start,t.count,t.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let e=new M;u.center!==void 0&&e.fromArray(u.center),a.boundingSphere=new lr(e,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},jp=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=this.path===``?Op.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let o=new tp(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){let a=null;try{a=JSON.parse(n)}catch(t){r!==void 0&&r(t),console.error(`THREE:ObjectLoader: Can't parse `+e+`.`,t.message);return}let o=a.metadata;if(o===void 0||o.type===void 0||o.type.toLowerCase()===`geometry`){r!==void 0&&r(Error(`THREE.ObjectLoader: Can't load `+e)),console.error(`THREE.ObjectLoader: Can't load `+e);return}i.parse(a,t)},n,r)}async loadAsync(e,t){let n=this,r=this.path===``?Op.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let i=new tp(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);let a=await i.loadAsync(e,t),o=JSON.parse(a),s=o.metadata;if(s===void 0||s.type===void 0||s.type.toLowerCase()===`geometry`)throw Error(`THREE.ObjectLoader: Can't load `+e);return await n.parseAsync(o)}parse(e,t){let n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),s=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,s,o,n),l=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,l),this.bindLightTargets(c),t!==void 0){let e=!1;for(let t in a)if(a[t].data instanceof HTMLImageElement){e=!0;break}e===!1&&t(c)}return c}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,c),this.bindLightTargets(s),s}parseShapes(e){let t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){let r=new _d().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){let n={},r={};if(t.traverse(function(e){e.isBone&&(r[e.uuid]=e)}),e!==void 0)for(let t=0,i=e.length;t<i;t++){let i=new Ol().fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){let n={};if(e!==void 0){let r=new Ap;for(let i=0,a=e.length;i<a;i++){let a,o=e[i];switch(o.type){case`BufferGeometry`:case`InstancedBufferGeometry`:a=r.parse(o);break;default:o.type in hf?a=hf[o.type].fromJSON(o,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${o.type}"`)}a.uuid=o.uuid,o.name!==void 0&&(a.name=o.name),o.userData!==void 0&&(a.userData=o.userData),n[o.uuid]=a}}return n}parseMaterials(e,t){let n={},r={};if(e!==void 0){let i=new Dp;i.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];n[a.uuid]===void 0&&(n[a.uuid]=i.parse(a)),r[a.uuid]=n[a.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let n=0;n<e.length;n++){let r=e[n],i=Kf.parse(r);t[i.uuid]=i}return t}parseImages(e,t){let n=this,r={},i;function a(e){return n.manager.itemStart(e),i.load(e,function(){n.manager.itemEnd(e)},void 0,function(){n.manager.itemError(e),n.manager.itemEnd(e)})}function o(e){if(typeof e==`string`){let t=e;return a(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}else if(e.data)return{data:pn(e.type,e.data),width:e.width,height:e.height};else return null}if(e!==void 0&&e.length>0){i=new ip(new Xf(t)),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.url;if(Array.isArray(i)){let e=[];for(let t=0,n=i.length;t<n;t++){let n=i[t],r=o(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new Tl(r.data,r.width,r.height)))}r[n.uuid]=new jn(e)}else{let e=o(n.url);r[n.uuid]=new jn(e)}}}return r}async parseImagesAsync(e){let t=this,n={},r;async function i(e){if(typeof e==`string`){let n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}else if(e.data)return{data:pn(e.type,e.data),width:e.width,height:e.height};else return null}if(e!==void 0&&e.length>0){r=new ip(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){let r=e[t],a=r.url;if(Array.isArray(a)){let e=[];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=await i(n);r!==null&&(r instanceof HTMLImageElement?e.push(r):e.push(new Tl(r.data,r.width,r.height)))}n[r.uuid]=new jn(e)}else{let e=await i(r.url);n[r.uuid]=new jn(e)}}}return n}parseTextures(e,t){function n(e,t){return typeof e==`number`?e:(console.warn(`THREE.ObjectLoader.parseTexture: Constant should be in numeric form.`,e),t[e])}let r={};if(e!==void 0)for(let i=0,a=e.length;i<a;i++){let a=e[i];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 o=t[a.image],s=o.data,c;Array.isArray(s)?(c=new _a,s.length===6&&(c.needsUpdate=!0)):(c=s&&s.data?new Tl:new Pn,s&&(c.needsUpdate=!0)),c.source=o,c.uuid=a.uuid,a.name!==void 0&&(c.name=a.name),a.mapping!==void 0&&(c.mapping=n(a.mapping,Mp)),a.channel!==void 0&&(c.channel=a.channel),a.offset!==void 0&&c.offset.fromArray(a.offset),a.repeat!==void 0&&c.repeat.fromArray(a.repeat),a.center!==void 0&&c.center.fromArray(a.center),a.rotation!==void 0&&(c.rotation=a.rotation),a.wrap!==void 0&&(c.wrapS=n(a.wrap[0],Np),c.wrapT=n(a.wrap[1],Np)),a.format!==void 0&&(c.format=a.format),a.internalFormat!==void 0&&(c.internalFormat=a.internalFormat),a.type!==void 0&&(c.type=a.type),a.colorSpace!==void 0&&(c.colorSpace=a.colorSpace),a.minFilter!==void 0&&(c.minFilter=n(a.minFilter,Pp)),a.magFilter!==void 0&&(c.magFilter=n(a.magFilter,Pp)),a.anisotropy!==void 0&&(c.anisotropy=a.anisotropy),a.flipY!==void 0&&(c.flipY=a.flipY),a.generateMipmaps!==void 0&&(c.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(c.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(c.compareFunction=a.compareFunction),a.userData!==void 0&&(c.userData=a.userData),r[a.uuid]=c}return r}parseObject(e,t,n,r,i){let a;function o(e){return t[e]===void 0&&console.warn(`THREE.ObjectLoader: Undefined geometry`,e),t[e]}function s(e){if(e!==void 0){if(Array.isArray(e)){let t=[];for(let r=0,i=e.length;r<i;r++){let i=e[r];n[i]===void 0&&console.warn(`THREE.ObjectLoader: Undefined material`,i),t.push(n[i])}return t}return n[e]===void 0&&console.warn(`THREE.ObjectLoader: Undefined material`,e),n[e]}}function c(e){return r[e]===void 0&&console.warn(`THREE.ObjectLoader: Undefined texture`,e),r[e]}let l,u;switch(e.type){case`Scene`:a=new Gc,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new P(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type===`Fog`?a.fog=new Wc(e.fog.color,e.fog.near,e.fog.far):e.fog.type===`FogExp2`&&(a.fog=new Uc(e.fog.color,e.fog.density)),e.fog.name!==``&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case`PerspectiveCamera`:a=new pa(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case`OrthographicCamera`:a=new Ba(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case`AmbientLight`:a=new Cp(e.color,e.intensity);break;case`DirectionalLight`:a=new Sp(e.color,e.intensity),a.target=e.target||``;break;case`PointLight`:a=new bp(e.color,e.intensity,e.distance,e.decay);break;case`RectAreaLight`:a=new wp(e.color,e.intensity,e.width,e.height);break;case`SpotLight`:a=new hp(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||``;break;case`HemisphereLight`:a=new lp(e.color,e.groundColor,e.intensity);break;case`LightProbe`:a=new Ep().fromJSON(e);break;case`SkinnedMesh`:l=o(e.geometry),u=s(e.material),a=new Cl(l,u),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case`Mesh`:l=o(e.geometry),u=s(e.material),a=new Ji(l,u);break;case`InstancedMesh`:l=o(e.geometry),u=s(e.material);let t=e.count,n=e.instanceMatrix,r=e.instanceColor;a=new Ll(l,u,t),a.instanceMatrix=new kl(new Float32Array(n.array),16),r!==void 0&&(a.instanceColor=new kl(new Float32Array(r.array),r.itemSize));break;case`BatchedMesh`:l=o(e.geometry),u=s(e.material),a=new nu(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,u),a.geometry=l,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(e=>{let t=new Gn;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);let n=new lr;return n.radius=e.sphereRadius,n.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:n}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case`LOD`:a=new pl;break;case`Line`:a=new du(o(e.geometry),s(e.material));break;case`LineLoop`:a=new gu(o(e.geometry),s(e.material));break;case`LineSegments`:a=new hu(o(e.geometry),s(e.material));break;case`PointCloud`:case`Points`:a=new Su(o(e.geometry),s(e.material));break;case`Sprite`:a=new ll(s(e.material));break;case`Group`:a=new jc;break;case`Bone`:a=new wl;break;default:a=new Wr}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix===void 0?(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)):(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let o=e.children;for(let e=0;e<o.length;e++)a.add(this.parseObject(o[e],t,n,r,i))}if(e.animations!==void 0){let t=e.animations;for(let e=0;e<t.length;e++){let n=t[e];a.animations.push(i[n])}}if(e.type===`LOD`){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);let t=e.levels;for(let e=0;e<t.length;e++){let n=t[e],r=a.getObjectByProperty(`uuid`,n.object);r!==void 0&&a.addLevel(r,n.distance,n.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(e){if(e.isSkinnedMesh===!0&&e.skeleton!==void 0){let n=t[e.skeleton];n===void 0?console.warn(`THREE.ObjectLoader: No skeleton found with UUID:`,e.skeleton):e.bind(n,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,r=e.getObjectByProperty(`uuid`,n);r===void 0?t.target=new Wr:t.target=r}})}},Mp={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,CubeUVReflectionMapping:306},Np={RepeatWrapping:s,ClampToEdgeWrapping:c,MirroredRepeatWrapping:l},Pp={NearestFilter:u,NearestMipmapNearestFilter:d,NearestMipmapLinearFilter:p,LinearFilter:h,LinearMipmapNearestFilter:g,LinearMipmapLinearFilter:v},Fp=class extends Qf{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>`u`&&console.warn(`THREE.ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&console.warn(`THREE.ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Yf.get(e);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{t&&t(n),i.manager.itemEnd(e)}).catch(e=>{r&&r(e)});return}return setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:`none`}))}).then(function(n){return Yf.add(e,n),t&&t(n),i.manager.itemEnd(e),n}).catch(function(t){r&&r(t),Yf.remove(e),i.manager.itemError(e),i.manager.itemEnd(e)});Yf.add(e,s),i.manager.itemStart(e)}},Ip,Lp=class{static getContext(){return Ip===void 0&&(Ip=new(window.AudioContext||window.webkitAudioContext)),Ip}static setContext(e){Ip=e}},Rp=class extends Qf{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new tp(this.manager);a.setResponseType(`arraybuffer`),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{let n=e.slice(0);Lp.getContext().decodeAudioData(n,function(e){t(e)}).catch(o)}catch(e){o(e)}},n,r);function o(t){r?r(t):console.error(t),i.manager.itemError(e)}}},zp=new N,Bp=new N,Vp=new N,Hp=class{constructor(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new pa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new pa,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,Vp.copy(e.projectionMatrix);let n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(Rt*t.fov*.5)/t.zoom,a,o;Bp.elements[12]=-n,zp.elements[12]=n,a=-i*t.aspect+r,o=i*t.aspect+r,Vp.elements[0]=2*t.near/(o-a),Vp.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Vp),a=-i*t.aspect-r,o=i*t.aspect-r,Vp.elements[0]=2*t.near/(o-a),Vp.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Vp)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Bp),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(zp)}},Up=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Wp(),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=Wp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Wp(){return performance.now()}var Gp=new M,Kp=new Hn,qp=new M,Jp=new M,Yp=class extends Wr{constructor(){super(),this.type=`AudioListener`,this.context=Lp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Up}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter===null?this.gain.disconnect(this.context.destination):(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gp,Kp,qp),!(!Number.isFinite(Gp.x)||!Number.isFinite(Gp.y)||!Number.isFinite(Gp.z)))if(Jp.set(0,0,-1).applyQuaternion(Kp),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gp.x,e),t.positionY.linearRampToValueAtTime(Gp.y,e),t.positionZ.linearRampToValueAtTime(Gp.z,e),t.forwardX.linearRampToValueAtTime(Jp.x,e),t.forwardY.linearRampToValueAtTime(Jp.y,e),t.forwardZ.linearRampToValueAtTime(Jp.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Gp.x,Gp.y,Gp.z),t.setOrientation(Jp.x,Jp.y,Jp.z,n.x,n.y,n.z)}},Xp=class extends Wr{constructor(e){super(),this.type=`Audio`,this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType=`empty`,this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType=`audioNode`,this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaNode`,this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaStreamNode`,this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType=`buffer`,this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn(`THREE.Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress%=this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){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.context.currentTime+e),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||=[],this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 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}},Zp=new M,Qp=new Hn,$p=new M,em=new M,tm=class extends Xp{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,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Zp,Qp,$p),em.set(0,0,1).applyQuaternion(Qp);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Zp.x,e),t.positionY.linearRampToValueAtTime(Zp.y,e),t.positionZ.linearRampToValueAtTime(Zp.z,e),t.orientationX.linearRampToValueAtTime(em.x,e),t.orientationY.linearRampToValueAtTime(em.y,e),t.orientationZ.linearRampToValueAtTime(em.z,e)}else t.setPosition(Zp.x,Zp.y,Zp.z),t.setOrientation(em.x,em.y,em.z)}},nm=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 n=0;n<t.length;n++)e+=t[n];return e/t.length}},rm=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case`quaternion`:r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case`string`:case`bool`:r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(a===0){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=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 n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){Hn.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;Hn.multiplyQuaternionsFlat(e,a,e,t,e,n),Hn.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},im=`\\[\\]\\.:\\/`,am=RegExp(`[`+im+`]`,`g`),om=`[^`+im+`]`,sm=`[^`+im.replace(`\\.`,``)+`]`,cm=`((?:WC+[\\/:])*)`.replace(`WC`,om),lm=`(WCOD+)?`.replace(`WCOD`,sm),um=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,om),dm=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,om),fm=RegExp(`^`+cm+lm+um+dm+`$`),pm=[`material`,`materials`,`bones`,`map`],mm=class{constructor(e,t,n){let r=n||hm.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},hm=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(am,``)}static parseTrackName(e){let t=fm.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);pm.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e,r){for(let i=0;i<e.length;i++){let a=e[i];if(!r&&(a.name===t||a.uuid===t)||r&&a.userData&&a.userData.name===t)return a;let o=n(a.children,r);if(o)return o}return null},r=n(e.children);if(r)return r;{let t=n(e.children,!0);if(t)return t}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[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 n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[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 t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.needsUpdate===void 0?t.matrixWorldNeedsUpdate!==void 0&&(s=this.Versioning.MatrixWorldNeedsUpdate):s=this.Versioning.NeedsUpdate;let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}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=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};hm.Composite=mm,hm.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},hm.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},hm.prototype.GetterByBindingType=[hm.prototype._getValue_direct,hm.prototype._getValue_array,hm.prototype._getValue_arrayElement,hm.prototype._getValue_toArray],hm.prototype.SetterByBindingTypeAndVersioning=[[hm.prototype._setValue_direct,hm.prototype._setValue_direct_setNeedsUpdate,hm.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[hm.prototype._setValue_array,hm.prototype._setValue_array_setNeedsUpdate,hm.prototype._setValue_array_setMatrixWorldNeedsUpdate],[hm.prototype._setValue_arrayElement,hm.prototype._setValue_arrayElement_setNeedsUpdate,hm.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[hm.prototype._setValue_fromArray,hm.prototype._setValue_fromArray_setNeedsUpdate,hm.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var gm=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Bt(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;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,n=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length,o,s=e.length,c=this.nCachedObjects_;for(let l=0,u=arguments.length;l!==u;++l){let u=arguments[l],d=u.uuid,f=t[d];if(f===void 0){f=s++,t[d]=f,e.push(u);for(let e=0,t=a;e!==t;++e)i[e].push(new hm(u,n[e],r[e]))}else if(f<c){o=e[f];let s=--c,l=e[s];t[l.uuid]=f,e[f]=l,t[d]=s,e[s]=u;for(let e=0,t=a;e!==t;++e){let t=i[e],a=t[s],o=t[f];t[f]=a,o===void 0&&(o=new hm(u,n[e],r[e])),t[s]=o}}else e[f]!==o&&console.error(`THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.`)}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],s=o.uuid,c=t[s];if(c!==void 0&&c>=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0)if(delete t[s],c<i){let o=--i,s=e[o],l=--a,u=e[l];t[s.uuid]=c,e[c]=s,t[u.uuid]=o,e[o]=u,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[o],i=t[l];t[c]=r,t[o]=i,t.pop()}}else{let i=--a,o=e[i];i>0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new hm(r,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}},_m=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:et,endingEnd:et};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ye,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let r=(e-i)*n;r<0||n===0?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case it:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case rt:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===Xe;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=tt,r.endingEnd=tt):(e?r.endingStart=this.zeroSlopeAtStart?tt:et:r.endingStart=nt,t?r.endingEnd=this.zeroSlopeAtEnd?tt:et:r.endingEnd=nt)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},vm=new Float32Array(1),ym=class extends Ft{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new rm(hm.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,i=this._actionsByClip,a=i[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],s.length===0&&delete a[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,i=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],c=e._cacheIndex;s._cacheIndex=c,t[c]=s,t.pop(),delete o[i],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new If(new Float32Array(2),new Float32Array(2),1,vm),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){let r=t||this._root,i=r.uuid,a=typeof e==`string`?Kf.findByName(r,e):e,o=a===null?e:a.uuid,s=this._actionsByClip[o],c=null;if(n===void 0&&(n=a===null?rt:a.blendMode),s!==void 0){let e=s.actionByRoot[i];if(e!==void 0&&e.blendMode===n)return e;c=s.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let l=new _m(this,a,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,i),l}existingAction(e,t){let n=t||this._root,r=n.uuid,i=typeof e==`string`?Kf.findByName(n,e):e,a=i?i.uuid:e,o=this._actionsByClip[a];return o===void 0?null:o.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(i!==void 0){let e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){let r=e[n];this._deactivateAction(r);let i=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=i,t[i]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let e in n){let r=n[e].actionByRoot[t];r!==void 0&&(this._deactivateAction(r),this._removeInactiveAction(r))}let r=this._bindingsByRootAndName[t];if(r!==void 0)for(let e in r){let t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},bm=class e{constructor(e){this.value=e}clone(){return new e(this.value.clone===void 0?this.value:this.value.clone())}},xm=0,Sm=class extends Ft{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,`id`,{value:xm++}),this.name=``,this.usage=Ct,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 e=0,n=t.length;e<n;e++){let n=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<n.length;e++)this.uniforms.push(n[e].clone())}return this}clone(){return new this.constructor().copy(this)}},Cm=class extends Kc{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}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}},wm=class{constructor(e,t,n,r,i){this.isGLBufferAttribute=!0,this.name=``,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,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}},Tm=new N,Em=class{constructor(e,t,n=0,r=1/0){this.ray=new _r(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Or,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)}setFromXRController(e){return Tm.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Tm),this}intersectObject(e,t=!0,n=[]){return Om(e,this,n,t),n.sort(Dm),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)Om(e[r],this,n,t);return n.sort(Dm),n}};function Dm(e,t){return e.distance-t.distance}function Om(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Om(r[e],t,n,!0)}}var km=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){let e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Vt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Am=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,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,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}},jm=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},Mm=new A,Nm=class{constructor(e=new A(1/0,1/0),t=new A(-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,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Mm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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,Mm).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)}},Pm=new M,Fm=new M,Im=class{constructor(e=new M,t=new M){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){Pm.subVectors(e,this.start),Fm.subVectors(this.end,this.start);let n=Fm.dot(Fm),r=Fm.dot(Pm)/n;return t&&(r=Vt(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Lm=new M,Rm=class extends Wr{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type=`SpotLightHelper`;let n=new Ii,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){let n=e/32*Math.PI*2,i=t/32*Math.PI*2;r.push(Math.cos(n),Math.sin(n),1,Math.cos(i),Math.sin(i),1)}n.setAttribute(`position`,new F(r,3)),this.cone=new hu(n,new ru({fog:!1,toneMapped:!1})),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Lm.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lm),this.color===void 0?this.cone.material.color.copy(this.light.color):this.cone.material.color.set(this.color)}},zm=new M,Bm=new N,Vm=new N,Hm=class extends hu{constructor(e){let t=Um(e),n=new Ii,r=[],i=[],a=new P(0,0,1),o=new P(0,1,0);for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}n.setAttribute(`position`,new F(r,3)),n.setAttribute(`color`,new F(i,3));let s=new ru({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,s),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,n=this.geometry,r=n.getAttribute(`position`);Vm.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){let i=t[e];i.parent&&i.parent.isBone&&(Bm.multiplyMatrices(Vm,i.matrixWorld),zm.setFromMatrixPosition(Bm),r.setXYZ(n,zm.x,zm.y,zm.z),Bm.multiplyMatrices(Vm,i.parent.matrixWorld),zm.setFromMatrixPosition(Bm),r.setXYZ(n+1,zm.x,zm.y,zm.z),n+=2)}n.getAttribute(`position`).needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function Um(e){let t=[];e.isBone===!0&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,Um(e.children[n]));return t}var Wm=class extends Ji{constructor(e,t,n){let r=new cf(t,4,2),i=new fi({wireframe:!0,fog:!1,toneMapped:!1});super(r,i),this.light=e,this.color=n,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.copy(this.light.color):this.material.color.set(this.color)}},Gm=new M,Km=new P,qm=new P,Jm=class extends Wr{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type=`HemisphereLightHelper`;let r=new rf(t);r.rotateY(Math.PI*.5),this.material=new fi({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let i=r.getAttribute(`position`),a=new Float32Array(i.count*3);r.setAttribute(`color`,new bi(a,3)),this.add(new Ji(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`);Km.copy(this.light.color),qm.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let r=e<n/2?Km:qm;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Gm.setFromMatrixPosition(this.light.matrixWorld).negate())}},Ym=class extends hu{constructor(e=10,t=10,n=4473924,r=8947848){n=new P(n),r=new P(r);let i=t/2,a=e/t,o=e/2,s=[],c=[];for(let e=0,l=0,u=-o;e<=t;e++,u+=a){s.push(-o,0,u,o,0,u),s.push(u,0,-o,u,0,o);let t=e===i?n:r;t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3}let l=new Ii;l.setAttribute(`position`,new F(s,3)),l.setAttribute(`color`,new F(c,3));let u=new ru({vertexColors:!0,toneMapped:!1});super(l,u),this.type=`GridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},Xm=class extends hu{constructor(e=10,t=16,n=8,r=64,i=4473924,a=8947848){i=new P(i),a=new P(a);let o=[],s=[];if(t>1)for(let n=0;n<t;n++){let r=n/t*(Math.PI*2),c=Math.sin(r)*e,l=Math.cos(r)*e;o.push(0,0,0),o.push(c,0,l);let u=n&1?i:a;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){let c=t&1?i:a,l=e-e/n*t;for(let e=0;e<r;e++){let t=e/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l;o.push(n,0,i),s.push(c.r,c.g,c.b),t=(e+1)/r*(Math.PI*2),n=Math.sin(t)*l,i=Math.cos(t)*l,o.push(n,0,i),s.push(c.r,c.g,c.b)}}let c=new Ii;c.setAttribute(`position`,new F(o,3)),c.setAttribute(`color`,new F(s,3));let l=new ru({vertexColors:!0,toneMapped:!1});super(c,l),this.type=`PolarGridHelper`}dispose(){this.geometry.dispose(),this.material.dispose()}},Zm=new M,Qm=new M,$m=new M,eh=class extends Wr{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type=`DirectionalLightHelper`,t===void 0&&(t=1);let r=new Ii;r.setAttribute(`position`,new F([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let i=new ru({fog:!1,toneMapped:!1});this.lightPlane=new du(r,i),this.add(this.lightPlane),r=new Ii,r.setAttribute(`position`,new F([0,0,0,0,0,1],3)),this.targetLine=new du(r,i),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),Zm.setFromMatrixPosition(this.light.matrixWorld),Qm.setFromMatrixPosition(this.light.target.matrixWorld),$m.subVectors(Qm,Zm),this.lightPlane.lookAt(Qm),this.color===void 0?(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)):(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)),this.targetLine.lookAt(Qm),this.targetLine.scale.z=$m.length()}},th=new M,nh=new la,rh=class extends hu{constructor(e){let t=new Ii,n=new ru({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],a={};o(`n1`,`n2`),o(`n2`,`n4`),o(`n4`,`n3`),o(`n3`,`n1`),o(`f1`,`f2`),o(`f2`,`f4`),o(`f4`,`f3`),o(`f3`,`f1`),o(`n1`,`f1`),o(`n2`,`f2`),o(`n3`,`f3`),o(`n4`,`f4`),o(`p`,`n1`),o(`p`,`n2`),o(`p`,`n3`),o(`p`,`n4`),o(`u1`,`u2`),o(`u2`,`u3`),o(`u3`,`u1`),o(`c`,`t`),o(`p`,`c`),o(`cn1`,`cn2`),o(`cn3`,`cn4`),o(`cf1`,`cf2`),o(`cf3`,`cf4`);function o(e,t){s(e),s(t)}function s(e){r.push(0,0,0),i.push(0,0,0),a[e]===void 0&&(a[e]=[]),a[e].push(r.length/3-1)}t.setAttribute(`position`,new F(r,3)),t.setAttribute(`color`,new F(i,3)),super(t,n),this.type=`CameraHelper`,this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let c=new P(16755200),l=new P(16711680),u=new P(43775),d=new P(16777215),f=new P(3355443);this.setColors(c,l,u,d,f)}setColors(e,t,n,r,i){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,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,i.r,i.g,i.b),a.setXYZ(41,i.r,i.g,i.b),a.setXYZ(42,i.r,i.g,i.b),a.setXYZ(43,i.r,i.g,i.b),a.setXYZ(44,i.r,i.g,i.b),a.setXYZ(45,i.r,i.g,i.b),a.setXYZ(46,i.r,i.g,i.b),a.setXYZ(47,i.r,i.g,i.b),a.setXYZ(48,i.r,i.g,i.b),a.setXYZ(49,i.r,i.g,i.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap;nh.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ih(`c`,t,e,nh,0,0,-1),ih(`t`,t,e,nh,0,0,1),ih(`n1`,t,e,nh,-1,-1,-1),ih(`n2`,t,e,nh,1,-1,-1),ih(`n3`,t,e,nh,-1,1,-1),ih(`n4`,t,e,nh,1,1,-1),ih(`f1`,t,e,nh,-1,-1,1),ih(`f2`,t,e,nh,1,-1,1),ih(`f3`,t,e,nh,-1,1,1),ih(`f4`,t,e,nh,1,1,1),ih(`u1`,t,e,nh,1*.7,1*1.1,-1),ih(`u2`,t,e,nh,-1*.7,1*1.1,-1),ih(`u3`,t,e,nh,0,2,-1),ih(`cf1`,t,e,nh,-1,0,1),ih(`cf2`,t,e,nh,1,0,1),ih(`cf3`,t,e,nh,0,-1,1),ih(`cf4`,t,e,nh,0,1,1),ih(`cn1`,t,e,nh,-1,0,-1),ih(`cn2`,t,e,nh,1,0,-1),ih(`cn3`,t,e,nh,0,-1,-1),ih(`cn4`,t,e,nh,0,1,-1),e.getAttribute(`position`).needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ih(e,t,n,r,i,a,o){th.set(i,a,o).unproject(r);let s=t[e];if(s!==void 0){let e=n.getAttribute(`position`);for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],th.x,th.y,th.z)}}var ah=new Gn,oh=class extends hu{constructor(e,t=16776960){let n=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),i=new Ii;i.setIndex(new bi(n,1)),i.setAttribute(`position`,new bi(r,3)),super(i,new ru({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&&ah.setFromObject(this.object),ah.isEmpty())return;let t=ah.min,n=ah.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[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()}},sh=class extends hu{constructor(e,t=16776960){let n=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],i=new Ii;i.setIndex(new bi(n,1)),i.setAttribute(`position`,new F(r,3)),super(i,new ru({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()}},ch=class extends du{constructor(e,t=1,n=16776960){let r=n,i=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Ii;a.setAttribute(`position`,new F(i,3)),a.computeBoundingSphere(),super(a,new ru({color:r,toneMapped:!1})),this.type=`PlaneHelper`,this.plane=e,this.size=t;let o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],s=new Ii;s.setAttribute(`position`,new F(o,3)),s.computeBoundingSphere(),this.add(new Ji(s,new fi({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()}},lh=new M,uh,dh,fh=class extends Wr{constructor(e=new M(0,0,1),t=new M(0,0,0),n=1,r=16776960,i=n*.2,a=i*.2){super(),this.type=`ArrowHelper`,uh===void 0&&(uh=new Ii,uh.setAttribute(`position`,new F([0,0,0,0,1,0],3)),dh=new cd(0,.5,1,5,1),dh.translate(0,-.5,0)),this.position.copy(t),this.line=new du(uh,new ru({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ji(dh,new fi({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,a)}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{lh.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(lh,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},ph=class extends hu{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ii;r.setAttribute(`position`,new F(t,3)),r.setAttribute(`color`,new F(n,3));let i=new ru({vertexColors:!0,toneMapped:!1});super(r,i),this.type=`AxesHelper`}setColors(e,t,n){let r=new P,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},mh=class{constructor(){this.type=`ShapePath`,this.color=new P,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new id,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n],i=new _d;i.curves=r.curves,t.push(i)}return t}function n(e,t){let n=t.length,r=!1;for(let i=n-1,a=0;a<n;i=a++){let n=t[i],o=t[a],s=o.x-n.x,c=o.y-n.y;if(Math.abs(c)>2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.y<n.y||e.y>o.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=c*(e.x-n.x)-s*(e.y-n.y);if(t===0)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}let r=Xd.isClockWise,i=this.subPaths;if(i.length===0)return[];let a,o,s,c=[];if(i.length===1)return o=i[0],s=new _d,s.curves=o.curves,c.push(s),c;let l=!r(i[0].getPoints());l=e?!l:l;let u=[],d=[],f=[],p=0,m;d[p]=void 0,f[p]=[];for(let t=0,n=i.length;t<n;t++)o=i[t],m=o.getPoints(),a=r(m),a=e?!a:a,a?(!l&&d[p]&&p++,d[p]={s:new _d,p:m},d[p].s.curves=o.curves,l&&p++,f[p]=[]):f[p].push({h:o,p:m[0]});if(!d[0])return t(i);if(d.length>1){let e=!1,t=0;for(let e=0,t=d.length;e<t;e++)u[e]=[];for(let r=0,i=d.length;r<i;r++){let i=f[r];for(let a=0;a<i.length;a++){let o=i[a],s=!0;for(let i=0;i<d.length;i++)n(o.p,d[i].p)&&(r!==i&&t++,s?(s=!1,u[i].push(o)):e=!0);s&&u[r].push(o)}}t>0&&e===!1&&(f=u)}let h;for(let e=0,t=d.length;e<t;e++){s=d[e].s,c.push(s),h=f[e];for(let e=0,t=h.length;e<t;e++)s.holes.push(h[e].h)}return c}},hh=class extends Ft{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}},gh=class extends Ln{constructor(e=1,t=1,n=1,r={}){console.warn(`THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.`),super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}},_h=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveMap.envMap.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),vh=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=_h,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){let{object:t,material:n}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;let i=r.material;for(let e in i){let t=i[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return i[e]=r,!1}if(r.morphTargetInfluences){let e=!1;for(let n=0;n<r.morphTargetInfluences.length;n++)r.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||i?!1:this.equals(e)!==!0}};function yh(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var bh=e=>yh(e),xh=e=>yh(e),Sh=(...e)=>yh(e);function Ch(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of wh(e))n.push(n,yh(r.slice(0,-4)),i.getCacheKey(t));return yh(n)}function*wh(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function Th(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Eh(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new P(...t):n===`vec2`?new A(...t):n===`vec3`?new M(...t):n===`vec4`?new Fn(...t):n===`mat3`?new j(...t):n===`mat4`?new N(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Oh(t[0]):null}function Dh(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Oh(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var kh=Object.freeze({__proto__:null,arrayBufferToBase64:Dh,base64ToArrayBuffer:Oh,getCacheKey:Ch,getNodeChildren:wh,getValueFromType:Eh,getValueType:Th,hash:Sh,hashArray:xh,hashString:bh}),Ah={VERTEX:`vertex`,FRAGMENT:`fragment`},L={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},jh={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},Mh=[`fragment`,`vertex`],Nh=[`setup`,`analyze`,`generate`],Ph=[...Mh,`compute`],Fh=[`x`,`y`,`z`,`w`],Ih=0,R=class extends Ft{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=L.NONE,this.updateBeforeType=L.NONE,this.updateAfterType=L.NONE,this.uuid=ln.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,`id`,{value:Ih++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,L.FRAME)}onRenderUpdate(e){return this.onUpdate(e,L.RENDER)}onObjectUpdate(e){return this.onUpdate(e,L.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of wh(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Ch(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return null}analyze(e){if(e.increaseUsage(this)===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null,i=e.getBuildStage();if(i===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){e.stack.nodes.length,t.initialized=!0,t.outputNode=this.setup(e),t.outputNode!==null&&e.stack.nodes.length;for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e)}}else if(i===`analyze`)this.analyze(e);else if(i===`generate`)if(this.generate.length===1){let n=this.getNodeType(e),i=e.getDataFromNode(this);r=i.snippet,r===void 0?(r=this.generate(e)||``,i.snippet=r):i.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,n,t)}else r=this.generate(e,t)||``;return e.removeChain(this),r}getSerializeChildren(){return wh(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else this[n]=t[e.inputNodes[n]]}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.6,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},Lh=class extends R{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){return`${this.node.build(e)}[ ${this.indexNode.build(e,`uint`)} ]`}},Rh=class extends R{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},zh=class extends R{static get type(){return`TempNode`}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Bh=class extends zh{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=this.nodes,i=e.getComponentType(n),a=[];for(let t of r){let n=t.build(e),r=e.getComponentType(t.getNodeType(e));r!==i&&(n=e.format(n,r,i)),a.push(n)}let o=`${e.getType(n)}( ${a.join(`, `)} )`;return e.format(o,n,t)}},Vh=Fh.join(``),Hh=class extends R{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Fh.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===Vh.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},Uh=class extends zh{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getTypeFromLength(n.length,r.getNodeType(e)),o=r.build(e,a),s=t.build(e,i),c=e.getTypeLength(i),l=[];for(let e=0;e<c;e++){let t=Fh[e];t===n[0]?(l.push(o),e+=n.length-1):l.push(s+`.`+t)}return`${e.getType(i)}( ${l.join(`, `)} )`}},Wh=class extends zh{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Fh[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Gh=class extends R{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Th(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Th(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=Dh(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Eh(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},Kh=class extends Gh{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return e.format(this.generateConst(e),n,t)}},qh=null,Jh=new Map;function z(e,t){if(Jh.has(e)){console.warn(`Redefinition of method chaining ${e}`);return}if(typeof t!=`function`)throw Error(`Node element ${e} is not a function`);Jh.set(e,t)}var Yh=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),Xh=e=>Yh(e).split(``).sort().join(``),Zh={setup(e,t){return e(Cg(t.shift()),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(qh.assign(n,...e),n);if(Jh.has(t)){let r=Jh.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&Jh.has(t.slice(0,t.length-6))){let r=Jh.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=Yh(t),B(new Hh(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xh(t.slice(3).toLowerCase()),n=>B(new Uh(e,t,n));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xh(t.slice(4).toLowerCase()),()=>B(new Wh(B(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),B(new Hh(e,t));else if(/^\d+$/.test(t)===!0)return B(new Lh(n,new Kh(Number(t),`uint`)))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},Qh=new WeakMap,$h=new WeakMap,eg=function(e,t=null){let n=Th(e);if(n===`node`){let t=Qh.get(e);return t===void 0&&(t=new Proxy(e,Zh),Qh.set(e,t),Qh.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return B(_g(e,t));else if(n===`shader`)return U(e);return e},tg=function(e,t=null){for(let n in e)e[n]=B(e[n],t);return e},ng=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=B(e[r],t);return e},rg=function(e,t=null,n=null,r=null){let i=e=>B(r===null?e:Object.assign(e,r));return t===null?(...t)=>i(new e(...wg(t))):n===null?(...n)=>i(new e(t,...wg(n))):(n=B(n),(...r)=>i(new e(t,...wg(r),n)))},ig=function(e,...t){return B(new e(...wg(t)))},ag=class extends R{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let i=null;if(t.layout){let r=$h.get(e.constructor);r===void 0&&(r=new WeakMap,$h.set(e.constructor,r));let a=r.get(t);a===void 0&&(a=B(e.buildFunctionNode(t)),r.set(t,a)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(a),i=B(a.call(n))}else{let r=t.jsFunc;i=B(n===null?r(e):r(n,e))}return t.once&&(r.onceOutput=i),i}getOutputNode(e){let t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}},og=class extends R{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Cg(e),B(new ag(this,e))}setup(){return this.call()}},sg=[!1,!0],cg=[0,1,2,3],lg=[-1,-2],ug=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],dg=new Map;for(let e of sg)dg.set(e,new Kh(e));var fg=new Map;for(let e of cg)fg.set(e,new Kh(e,`uint`));var pg=new Map([...fg].map(e=>new Kh(e.value,`int`)));for(let e of lg)pg.set(e,new Kh(e,`int`));var mg=new Map([...pg].map(e=>new Kh(e.value)));for(let e of ug)mg.set(e,new Kh(e));for(let e of ug)mg.set(-e,new Kh(-e));var hg={bool:dg,uint:fg,ints:pg,float:mg},gg=new Map([...dg,...mg]),_g=(e,t)=>gg.has(e)?gg.get(e):e.isNode===!0?e:new Kh(e,t),vg=e=>{try{return e.getNodeType()}catch{return}},yg=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[Eh(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return B(t.get(n[0]));if(n.length===1){let t=_g(n[0],e);return vg(t)===e?B(t):B(new Rh(t,e))}return B(new Bh(n.map(e=>_g(e)),e))}},bg=e=>typeof e==`object`&&e?e.value:e,xg=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function Sg(e,t){return new Proxy(new og(e,t),Zh)}var B=(e,t=null)=>eg(e,t),Cg=(e,t=null)=>new tg(e,t),wg=(e,t=null)=>new ng(e,t),V=(...e)=>new rg(...e),H=(...e)=>new ig(...e),U=(e,t)=>{let n=new Sg(e,t),r=(...e)=>{let t;return Cg(e),t=e[0]&&e[0].isNode?[...e]:e[0],n.call(t)};return r.shaderNode=n,r.setLayout=e=>(n.setLayout(e),r),r.once=()=>(n.once=!0,r),r},Tg=(...e)=>(console.warn(`TSL.ShaderNode: tslFn() has been renamed to Fn().`),U(...e));z(`toGlobal`,e=>(e.global=!0,e));var Eg=e=>{qh=e},Dg=()=>qh,W=(...e)=>qh.If(...e);function Og(e){return qh&&qh.add(e),e}z(`append`,Og);var kg=new yg(`color`),G=new yg(`float`,hg.float),K=new yg(`int`,hg.ints),q=new yg(`uint`,hg.uint),Ag=new yg(`bool`,hg.bool),J=new yg(`vec2`),jg=new yg(`ivec2`),Mg=new yg(`uvec2`),Ng=new yg(`bvec2`),Y=new yg(`vec3`),Pg=new yg(`ivec3`),Fg=new yg(`uvec3`),Ig=new yg(`bvec3`),X=new yg(`vec4`),Lg=new yg(`ivec4`),Rg=new yg(`uvec4`),zg=new yg(`bvec4`),Bg=new yg(`mat2`),Vg=new yg(`mat3`),Hg=new yg(`mat4`),Ug=(e=``)=>B(new Kh(e,`string`)),Wg=e=>B(new Kh(e,`ArrayBuffer`));z(`toColor`,kg),z(`toFloat`,G),z(`toInt`,K),z(`toUint`,q),z(`toBool`,Ag),z(`toVec2`,J),z(`toIVec2`,jg),z(`toUVec2`,Mg),z(`toBVec2`,Ng),z(`toVec3`,Y),z(`toIVec3`,Pg),z(`toUVec3`,Fg),z(`toBVec3`,Ig),z(`toVec4`,X),z(`toIVec4`,Lg),z(`toUVec4`,Rg),z(`toBVec4`,zg),z(`toMat2`,Bg),z(`toMat3`,Vg),z(`toMat4`,Hg);var Gg=V(Lh),Kg=(e,t)=>B(new Rh(B(e),t)),qg=(e,t)=>B(new Hh(B(e),t));z(`element`,Gg),z(`convert`,Kg);var Jg=class extends R{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.version=0,this.shared=t,this.order=n,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},Yg=e=>new Jg(e),Xg=(e,t=0)=>new Jg(e,!0,t),Zg=Xg(`frame`),Qg=Xg(`render`),$g=Yg(`object`),e_=class extends Gh{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=$g}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}},Z=(e,t)=>{let n=xg(t||e);return B(new e_(e&&e.isNode===!0?e.node&&e.node.value||e.value:e,n))},t_=class extends R{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}},n_=(e,t)=>B(new t_(e,t)),r_=(e,t)=>B(new t_(e,t,!0)),i_=H(t_,`vec4`,`DiffuseColor`),a_=H(t_,`vec3`,`EmissiveColor`),o_=H(t_,`float`,`Roughness`),s_=H(t_,`float`,`Metalness`),c_=H(t_,`float`,`Clearcoat`),l_=H(t_,`float`,`ClearcoatRoughness`),u_=H(t_,`vec3`,`Sheen`),d_=H(t_,`float`,`SheenRoughness`),f_=H(t_,`float`,`Iridescence`),p_=H(t_,`float`,`IridescenceIOR`),m_=H(t_,`float`,`IridescenceThickness`),h_=H(t_,`float`,`AlphaT`),g_=H(t_,`float`,`Anisotropy`),__=H(t_,`vec3`,`AnisotropyT`),v_=H(t_,`vec3`,`AnisotropyB`),y_=H(t_,`color`,`SpecularColor`),b_=H(t_,`float`,`SpecularF90`),x_=H(t_,`float`,`Shininess`),S_=H(t_,`vec4`,`Output`),C_=H(t_,`float`,`dashSize`),w_=H(t_,`float`,`gapSize`),T_=H(t_,`float`,`pointWidth`),E_=H(t_,`float`,`IOR`),D_=H(t_,`float`,`Transmission`),O_=H(t_,`float`,`Thickness`),k_=H(t_,`float`,`AttenuationDistance`),A_=H(t_,`color`,`AttenuationColor`),j_=H(t_,`float`,`Dispersion`),M_=class extends zh{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return Fh.join(``).slice(0,n)!==t.components}return!1}generate(e,t){let{targetNode:n,sourceNode:r}=this,i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.context({assign:!0}).build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node.context({assign:!0}).build(e);for(let t=0;t<n.components.length;t++){let r=n.components[t];e.addLineFlowCode(`${c}.${r} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}},N_=V(M_);z(`assign`,N_);var P_=class extends zh{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters;if(Array.isArray(i))for(let n=0;n<i.length;n++){let a=r[n],o=i[n];t.push(o.build(e,a.type))}else for(let n of r){let r=i[n.name];if(r!==void 0)t.push(r.build(e,n.type));else throw Error(`FunctionCallNode: Input '${n.name}' not found in FunctionNode.`)}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}},F_=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?wg(t):Cg(t[0]),B(new P_(B(e),t)));z(`call`,F_);var I_=class e extends zh{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r}getNodeType(e,t){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i===void 0?null:i.getNodeType(e);if(a===`void`||o===`void`)return`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`!`||n===`==`||n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`<`||n===`>`||n===`<=`||n===`>=`){let n=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return n>1?`bvec${n}`:`bool`}else return a===`float`&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){let n=this.op,r=this.aNode,i=this.bNode,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i===void 0?null:i.getNodeType(e),n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`?e.isVector(o)?s=o:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):e.isMatrix(o)&&e.isVector(s)?s=e.getVectorFromMatrix(o):o=e.isVector(o)&&e.isMatrix(s)?e.getVectorFromMatrix(s):s=a);let c=r.build(e,o),l=i===void 0?null:i.build(e,s),u=e.getTypeLength(t),d=e.getFunctionOperator(n);if(t!==`void`)return n===`<`&&u>1?e.useComparisonMethod?e.format(`${e.getMethod(`lessThan`,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} < ${l} )`,a,t):n===`<=`&&u>1?e.useComparisonMethod?e.format(`${e.getMethod(`lessThanEqual`,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} <= ${l} )`,a,t):n===`>`&&u>1?e.useComparisonMethod?e.format(`${e.getMethod(`greaterThan`,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} > ${l} )`,a,t):n===`>=`&&u>1?e.useComparisonMethod?e.format(`${e.getMethod(`greaterThanEqual`,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} >= ${l} )`,a,t):n===`!`||n===`~`?e.format(`(${n}${c})`,o,t):d?e.format(`${d}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(o!==`void`)return d?e.format(`${d}( ${c}, ${l} )`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},L_=V(I_,`+`),R_=V(I_,`-`),z_=V(I_,`*`),B_=V(I_,`/`),V_=V(I_,`%`),H_=V(I_,`==`),U_=V(I_,`!=`),W_=V(I_,`<`),G_=V(I_,`>`),K_=V(I_,`<=`),q_=V(I_,`>=`),J_=V(I_,`&&`),Y_=V(I_,`||`),X_=V(I_,`!`),Z_=V(I_,`^^`),Q_=V(I_,`&`),$_=V(I_,`~`),ev=V(I_,`|`),tv=V(I_,`^`),nv=V(I_,`<<`),rv=V(I_,`>>`);z(`add`,L_),z(`sub`,R_),z(`mul`,z_),z(`div`,B_),z(`modInt`,V_),z(`equal`,H_),z(`notEqual`,U_),z(`lessThan`,W_),z(`greaterThan`,G_),z(`lessThanEqual`,K_),z(`greaterThanEqual`,q_),z(`and`,J_),z(`or`,Y_),z(`not`,X_),z(`xor`,Z_),z(`bitAnd`,Q_),z(`bitNot`,$_),z(`bitOr`,ev),z(`bitXor`,tv),z(`shiftLeft`,nv),z(`shiftRight`,rv);var iv=(...e)=>(console.warn(`TSL.OperatorNode: .remainder() has been renamed to .modInt().`),V_(...e));z(`remainder`,iv);var Q=class e extends zh{static get type(){return`MathNode`}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):n===e.MOD?this.aNode.getNodeType(t):this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.isWebGLRenderer===!0;if(r===e.TRANSFORM_DIRECTION){let e=o,r=s;t.isMatrix(e.getNodeType(t))?r=X(Y(r),0):e=X(Y(e),0);let i=z_(e,r).xyz;return Sv(i).build(t,n)}else if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);else if(r===e.ONE_MINUS)return R_(1,o).build(t,n);else if(r===e.RECIPROCAL)return B_(1,o).build(t,n);else if(r===e.DIFFERENCE)return Av(R_(o,s)).build(t,n);else{let u=[];return r===e.CROSS||r===e.MOD?u.push(o.build(t,i),s.build(t,i)):l&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l&&(r===e.MIN||r===e.MAX)||r===e.MOD?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Q.ALL=`all`,Q.ANY=`any`,Q.EQUALS=`equals`,Q.RADIANS=`radians`,Q.DEGREES=`degrees`,Q.EXP=`exp`,Q.EXP2=`exp2`,Q.LOG=`log`,Q.LOG2=`log2`,Q.SQRT=`sqrt`,Q.INVERSE_SQRT=`inversesqrt`,Q.FLOOR=`floor`,Q.CEIL=`ceil`,Q.NORMALIZE=`normalize`,Q.FRACT=`fract`,Q.SIN=`sin`,Q.COS=`cos`,Q.TAN=`tan`,Q.ASIN=`asin`,Q.ACOS=`acos`,Q.ATAN=`atan`,Q.ABS=`abs`,Q.SIGN=`sign`,Q.LENGTH=`length`,Q.NEGATE=`negate`,Q.ONE_MINUS=`oneMinus`,Q.DFDX=`dFdx`,Q.DFDY=`dFdy`,Q.ROUND=`round`,Q.RECIPROCAL=`reciprocal`,Q.TRUNC=`trunc`,Q.FWIDTH=`fwidth`,Q.BITCAST=`bitcast`,Q.TRANSPOSE=`transpose`,Q.ATAN2=`atan2`,Q.MIN=`min`,Q.MAX=`max`,Q.MOD=`mod`,Q.STEP=`step`,Q.REFLECT=`reflect`,Q.DISTANCE=`distance`,Q.DIFFERENCE=`difference`,Q.DOT=`dot`,Q.CROSS=`cross`,Q.POW=`pow`,Q.TRANSFORM_DIRECTION=`transformDirection`,Q.MIX=`mix`,Q.CLAMP=`clamp`,Q.REFRACT=`refract`,Q.SMOOTHSTEP=`smoothstep`,Q.FACEFORWARD=`faceforward`;var av=G(1e-6),ov=G(1e6),sv=G(Math.PI),cv=G(Math.PI*2),lv=V(Q,Q.ALL),uv=V(Q,Q.ANY),dv=V(Q,Q.EQUALS),fv=V(Q,Q.RADIANS),pv=V(Q,Q.DEGREES),mv=V(Q,Q.EXP),hv=V(Q,Q.EXP2),gv=V(Q,Q.LOG),_v=V(Q,Q.LOG2),vv=V(Q,Q.SQRT),yv=V(Q,Q.INVERSE_SQRT),bv=V(Q,Q.FLOOR),xv=V(Q,Q.CEIL),Sv=V(Q,Q.NORMALIZE),Cv=V(Q,Q.FRACT),wv=V(Q,Q.SIN),Tv=V(Q,Q.COS),Ev=V(Q,Q.TAN),Dv=V(Q,Q.ASIN),Ov=V(Q,Q.ACOS),kv=V(Q,Q.ATAN),Av=V(Q,Q.ABS),jv=V(Q,Q.SIGN),Mv=V(Q,Q.LENGTH),Nv=V(Q,Q.NEGATE),Pv=V(Q,Q.ONE_MINUS),Fv=V(Q,Q.DFDX),Iv=V(Q,Q.DFDY),Lv=V(Q,Q.ROUND),Rv=V(Q,Q.RECIPROCAL),zv=V(Q,Q.TRUNC),Bv=V(Q,Q.FWIDTH),Vv=V(Q,Q.BITCAST),Hv=V(Q,Q.TRANSPOSE),Uv=V(Q,Q.ATAN2),Wv=V(Q,Q.MIN),Gv=V(Q,Q.MAX),Kv=V(Q,Q.MOD),qv=V(Q,Q.STEP),Jv=V(Q,Q.REFLECT),Yv=V(Q,Q.DISTANCE),Xv=V(Q,Q.DIFFERENCE),Zv=V(Q,Q.DOT),Qv=V(Q,Q.CROSS),$v=V(Q,Q.POW),ey=V(Q,Q.POW,2),ty=V(Q,Q.POW,3),ny=V(Q,Q.POW,4),ry=V(Q,Q.TRANSFORM_DIRECTION),iy=e=>z_(jv(e),$v(Av(e),1/3)),ay=e=>Zv(e,e),oy=V(Q,Q.MIX),sy=(e,t=0,n=1)=>B(new Q(Q.CLAMP,B(e),B(t),B(n))),cy=e=>sy(e),ly=V(Q,Q.REFRACT),uy=V(Q,Q.SMOOTHSTEP),dy=V(Q,Q.FACEFORWARD),fy=U(([e])=>Cv(wv(Kv(Zv(e.xy,J(12.9898,78.233)),sv)).mul(43758.5453))),py=(e,t,n)=>oy(t,n,e),my=(e,t,n)=>uy(t,n,e);z(`all`,lv),z(`any`,uv),z(`equals`,dv),z(`radians`,fv),z(`degrees`,pv),z(`exp`,mv),z(`exp2`,hv),z(`log`,gv),z(`log2`,_v),z(`sqrt`,vv),z(`inverseSqrt`,yv),z(`floor`,bv),z(`ceil`,xv),z(`normalize`,Sv),z(`fract`,Cv),z(`sin`,wv),z(`cos`,Tv),z(`tan`,Ev),z(`asin`,Dv),z(`acos`,Ov),z(`atan`,kv),z(`abs`,Av),z(`sign`,jv),z(`length`,Mv),z(`lengthSq`,ay),z(`negate`,Nv),z(`oneMinus`,Pv),z(`dFdx`,Fv),z(`dFdy`,Iv),z(`round`,Lv),z(`reciprocal`,Rv),z(`trunc`,zv),z(`fwidth`,Bv),z(`atan2`,Uv),z(`min`,Wv),z(`max`,Gv),z(`mod`,Kv),z(`step`,qv),z(`reflect`,Jv),z(`distance`,Yv),z(`dot`,Zv),z(`cross`,Qv),z(`pow`,$v),z(`pow2`,ey),z(`pow3`,ty),z(`pow4`,ny),z(`transformDirection`,ry),z(`mix`,py),z(`clamp`,sy),z(`refract`,ly),z(`smoothstep`,my),z(`faceForward`,dy),z(`difference`,Xv),z(`saturate`,cy),z(`cbrt`,iy),z(`transpose`,Hv),z(`rand`,fy);var hy=V(class extends R{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let t=this.ifNode.getNodeType(e);if(this.elseNode!==null){let n=this.elseNode.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(t))return n}return t}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=t!==`void`,c=s?n_(n).build(e):``;r.nodeProperty=c;let l=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${l} ) {\n\n`).addFlowTab();let u=a.build(e,n);if(u&&=s?c+` = `+u+`;`:`return `+u+`;`,e.removeFlowTab().addFlowCode(e.tab+` `+u+`
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
`).addFlowTab();let t=o.build(e,n);t&&=s?c+` = `+t+`;`:`return `+t+`;`,e.removeFlowTab().addFlowCode(e.tab+` `+t+`
`+e.tab+`}
`)}else e.addFlowCode(`
`);return e.format(c,n,t)}});z(`select`,hy);var gy=(...e)=>(console.warn(`TSL.ConditionalNode: cond() has been renamed to select().`),hy(...e));z(`cond`,gy);var _y=class extends R{static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value});let n=this.node.build(e);return e.setContext(t),n}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}},vy=V(_y),yy=(e,t)=>vy(e,{label:t});z(`context`,vy),z(`label`,yy);var by=class extends R{static get type(){return`VarNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),i=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${i} = ${a}`,this),i}},xy=V(by);z(`temp`,xy),z(`toVar`,(...e)=>xy(...e).append());var Sy=class extends R{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,i),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,Ah.VERTEX);e.flowNodeFromShaderStage(Ah.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}},Cy=V(Sy);z(`varying`,Cy);var wy=`WorkingColorSpace`,Ty=`OutputColorSpace`;function Ey(e){let t=null;return e===`srgb-linear`?t=`Linear`:e===`srgb`&&(t=`sRGB`),t}function Dy(e,t){return Ey(e)+`To`+Ey(t)}var Oy=class extends zh{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}getColorSpace(e,t){return t===wy?Tn.workingColorSpace:t===Ty?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{renderer:t}=e,{colorNode:n}=this,r=this.getColorSpace(e,this.source),i=this.getColorSpace(e,this.target);if(r===i)return n;let a=Dy(r,i),o=null,s=t.nodes.library.getColorSpaceFunction(a);return s===null?(console.error(`ColorSpaceNode: Unsupported Color Space configuration.`,a),o=n):o=X(s(n.rgb),n.a),o}},ky=e=>B(new Oy(B(e),wy,Ty)),Ay=e=>B(new Oy(B(e),Ty,wy)),jy=(e,t)=>B(new Oy(B(e),wy,t)),My=(e,t)=>B(new Oy(B(e),t,wy));z(`toOutputColorSpace`,ky),z(`toWorkingColorSpace`,Ay),z(`workingToColorSpace`,jy),z(`colorSpaceToWorking`,My);var Ny=class extends Lh{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},Py=class extends R{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=L.OBJECT}setGroup(e){return this.group=e,this}element(e){return B(new Ny(this,B(e)))}setNodeType(e){let t=Z(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},Fy=(e,t,n)=>B(new Py(e,t,n)),Iy=class extends Py{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Qg)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},Ly=(e,t,n)=>B(new Iy(e,t,n)),Ry=class extends zh{static get type(){return`ToneMappingNode`}constructor(e,t=By,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}getCacheKey(){return Sh(super.getCacheKey(),this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===0)return t;let r=null,i=e.renderer.nodes.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=X(i(t.rgb,this.exposureNode),t.a),r}},zy=(e,t,n)=>B(new Ry(e,B(t),B(n))),By=Ly(`toneMappingExposure`,`float`);z(`toneMapping`,(e,t,n)=>zy(t,n,e));var Vy=class extends Gh{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Ct,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new Kc(n,i),s=new Jc(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;return e.shaderStage===`vertex`||e.shaderStage===`compute`?(this.name=r,i=r):i=Cy(this).build(e,t),i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}},Hy=(e,t,n,r)=>B(new Vy(e,t,n,r)),Uy=(e,t,n,r)=>Hy(e,t,n,r).setUsage(wt),Wy=(e,t,n,r)=>Hy(e,t,n,r).setInstanced(!0),Gy=(e,t,n,r)=>Uy(e,t,n,r).setInstanced(!0);z(`toAttribute`,e=>Hy(e.value));var Ky=class extends R{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.updateBeforeType=L.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){let{shaderStage:t}=e;if(t===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}}},qy=(e,t,n)=>B(new Ky(B(e),t,n));z(`compute`,qy);var Jy=class extends R{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}},Yy=(e,...t)=>B(new Jy(B(e),...t));z(`cache`,Yy);var Xy=class extends R{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}},Zy=V(Xy);z(`bypass`,Zy);var Qy=class extends R{static get type(){return`RemapNode`}constructor(e,t,n,r=G(0),i=G(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}},$y=V(Qy,null,null,{doClamp:!1}),eb=V(Qy);z(`remap`,$y),z(`remapClamp`,eb);var tb=class extends R{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}},nb=V(tb),rb=e=>(e?hy(e,nb(`discard`)):nb(`discard`)).append(),ib=()=>nb(`return`).append();z(`discard`,rb);var ab=class extends zh{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==Tn.workingColorSpace&&(t=t.workingToColorSpace(r)),t}},ob=(e,t=null,n=null)=>B(new ab(B(e),t,n));z(`renderOutput`,ob);function sb(e){console.warn(`THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var cb=class extends R{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):Cy(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},lb=(e,t)=>B(new cb(e,t)),ub=e=>lb(`uv`+(e>0?e:``),`vec2`),db=class extends R{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}},fb=V(db),pb=class extends e_{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=L.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}},mb=V(pb),hb=class extends e_{static get type(){return`TextureNode`}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=L.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return ub(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=Z(this.value.matrix)),this._matrixUniform.mul(Y(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?L.FRAME:L.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(K(fb(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.uvNode;(n===null||e.context.forceUVContext===!0)&&e.context.getUV&&(n=e.context.getUV(this)),n||=this.getDefaultUV(),this.updateMatrix===!0&&(n=this.getTransformedUV(n)),n=this.setupUV(e,n);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=n,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=e.getNodeProperties(this),r=this.value;if(!r||r.isTexture!==!0)throw Error(`TextureNode: Need a three.js texture.`);let i=super.generate(e,`property`);if(t===`sampler`)return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:r,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=n,d=this.generateUV(e,t),f=r?r.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(s=My(nb(s,c),r.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){let t=this.clone();return t.uvNode=B(e),t.referenceNode=this.getSelf(),B(t)}blur(e){let t=this.clone();return t.biasNode=B(e).mul(mb(t)),t.referenceNode=this.getSelf(),B(t)}level(e){let t=this.clone();return t.levelNode=B(e),t.referenceNode=this.getSelf(),B(t)}size(e){return fb(this,e)}bias(e){let t=this.clone();return t.biasNode=B(e),t.referenceNode=this.getSelf(),B(t)}compare(e){let t=this.clone();return t.compareNode=B(e),t.referenceNode=this.getSelf(),B(t)}grad(e,t){let n=this.clone();return n.gradNode=[B(e),B(t)],n.referenceNode=this.getSelf(),B(n)}depth(e){let t=this.clone();return t.depthNode=B(e),t.referenceNode=this.getSelf(),B(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}},gb=V(hb),_b=(...e)=>gb(...e).setSampler(!1),vb=e=>(e.isNode===!0?e:gb(e)).convert(`sampler`),yb=Z(`float`).label(`cameraNear`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.near),bb=Z(`float`).label(`cameraFar`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.far),xb=Z(`float`).label(`cameraLogDepth`).setGroup(Qg).onRenderUpdate(({camera:e})=>2/(Math.log(e.far+1)/Math.LN2)),Sb=Z(`mat4`).label(`cameraProjectionMatrix`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.projectionMatrix),Cb=Z(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse),wb=Z(`mat4`).label(`cameraViewMatrix`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.matrixWorldInverse),Tb=Z(`mat4`).label(`cameraWorldMatrix`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.matrixWorld),Eb=Z(`mat3`).label(`cameraNormalMatrix`).setGroup(Qg).onRenderUpdate(({camera:e})=>e.normalMatrix),Db=Z(new M).label(`cameraPosition`).setGroup(Qg).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),Ob=class e extends R{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=L.OBJECT,this._uniformNode=new e_(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`}update(t){let n=this.object3d,r=this._uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new M,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new M,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new M,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new M,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this._uniformNode.nodeType=`mat4`:(n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE)&&(this._uniformNode.nodeType=`vec3`),this._uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Ob.WORLD_MATRIX=`worldMatrix`,Ob.POSITION=`position`,Ob.SCALE=`scale`,Ob.VIEW_POSITION=`viewPosition`,Ob.DIRECTION=`direction`;var kb=V(Ob,Ob.DIRECTION),Ab=V(Ob,Ob.WORLD_MATRIX),jb=V(Ob,Ob.POSITION),Mb=V(Ob,Ob.SCALE),Nb=V(Ob,Ob.VIEW_POSITION),Pb=class extends Ob{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},Fb=H(Pb,Pb.DIRECTION),Ib=H(Pb,Pb.WORLD_MATRIX),Lb=H(Pb,Pb.POSITION),Rb=H(Pb,Pb.SCALE),zb=H(Pb,Pb.VIEW_POSITION),Bb=Z(new j).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Vb=Z(new N).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),Hb=wb.mul(Ib).toVar(`modelViewMatrix_2`),Ub=U(e=>(e.context.isHighPrecisionModelViewMatrix=!0,Z(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highPrecisionModelViewMatrix`),Wb=U(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return Z(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highPrecisionModelNormalMatrix`),Gb=lb(`position`,`vec3`),Kb=Gb.varying(`positionLocal`),qb=Gb.varying(`positionPrevious`),Jb=Ib.mul(Kb).xyz.varying(`v_positionWorld`),Yb=Kb.transformDirection(Ib).varying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),Xb=Hb.mul(Kb).xyz.varying(`v_positionView`),Zb=Xb.negate().varying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`),Qb=class extends R{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===2e3&&n.side===1?`false`:e.getFrontFacing()}},$b=H(Qb),ex=G($b).mul(2).sub(1),tx=lb(`normal`,`vec3`),nx=U(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`TSL.NormalNode: Vertex attribute "normal" not found on geometry.`),Y(0,1,0)):tx,`vec3`).once()().toVar(`normalLocal`),rx=Xb.dFdx().cross(Xb.dFdy()).normalize().toVar(`normalFlat`),ix=U(e=>{let t;return t=e.material.flatShading===!0?rx:Cy(ux(nx),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),ax=Cy(ix.transformDirection(wb),`v_normalWorld`).normalize().toVar(`normalWorld`),ox=U(e=>e.context.setupNormal(),`vec3`).once()().mul(ex).toVar(`transformedNormalView`),sx=ox.transformDirection(wb).toVar(`transformedNormalWorld`),cx=U(e=>e.context.setupClearcoatNormal(),`vec3`).once()().mul(ex).toVar(`transformedClearcoatNormalView`),lx=U(([e,t=Ib])=>{let n=Vg(t),r=e.div(Y(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),ux=U(([e],t)=>{let n=t.renderer.nodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=Bb.mul(e);return wb.transformDirection(r)}),dx=Z(0).onReference(({material:e})=>e).onRenderUpdate(({material:e})=>e.refractionRatio),fx=Zb.negate().reflect(ox),px=Zb.negate().refract(ox,dx),mx=fx.transformDirection(wb).toVar(`reflectVector`),hx=px.transformDirection(wb).toVar(`reflectVector`),gx=class extends hb{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?mx:e.mapping===302?hx:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),Y(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture?Y(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,`vec3`)}},_x=V(gx),vx=class extends e_{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},yx=(e,t,n)=>B(new vx(e,t,n)),bx=class extends Lh{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType();return e.format(t,`vec4`,n)}},xx=class extends vx{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null,`vec4`),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=L.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){let{array:e,value:t}=this,n=this.getElementLength(),r=this.getElementType();if(n===1)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(r===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length;this._elementType=this.elementType===null?Th(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let n=Float32Array;return this._elementType.charAt(0)===`i`?n=Int32Array:this._elementType.charAt(0)===`u`&&(n=Uint32Array),this.value=new n(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType(`vec4`,e.getComponentType(this._elementType)),super.setup(e)}element(e){return B(new bx(this,B(e)))}},Sx=(e,t)=>B(new xx(e,t)),Cx=(e,t)=>(console.warn(`TSL.UniformArrayNode: uniforms() has been renamed to uniformArray().`),B(new xx(e,t))),wx=class extends Lh{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},Tx=class extends R{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=L.OBJECT}element(e){return B(new wx(this,B(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?Sx(null,e):e===`texture`?gb(null):e===`cubeTexture`?_x(null):Z(null,e):yx(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},Ex=(e,t,n)=>B(new Tx(e,t,n)),Dx=(e,t,n,r)=>B(new Tx(e,t,r,n)),Ox=class extends Tx{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},kx=(e,t,n)=>B(new Ox(e,t,n)),Ax=U(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),lb(`tangent`,`vec4`)))(),jx=Ax.xyz.toVar(`tangentLocal`),Mx=Hb.mul(X(jx,0)).xyz.varying(`v_tangentView`).normalize().toVar(`tangentView`),Nx=Mx.transformDirection(wb).varying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),Px=Mx.toVar(`transformedTangentView`),Fx=Px.transformDirection(wb).normalize().toVar(`transformedTangentWorld`),Ix=e=>e.mul(Ax.w).xyz,Lx=Cy(Ix(tx.cross(Ax)),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),Rx=Cy(Ix(nx.cross(jx)),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),zx=Cy(Ix(ix.cross(Mx)),`v_bitangentView`).normalize().toVar(`bitangentView`),Bx=Cy(Ix(ax.cross(Nx)),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),Vx=Ix(ox.cross(Px)).normalize().toVar(`transformedBitangentView`),Hx=Vx.transformDirection(wb).normalize().toVar(`transformedBitangentWorld`),Ux=Vg(Mx,zx,ix),Wx=Zb.mul(Ux),Gx=(e,t)=>e.sub(Wx.mul(t)),Kx=(()=>{let e=v_.cross(Zb);return e=e.cross(v_).normalize(),e=oy(e,ox,g_.mul(o_.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),qx=U(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=ex.mul(m.inverseSqrt());return L_(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()}),Jx=class extends zh{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=Y(r.xy.mul(n),r.z));let i=null;return t===1?i=ux(r):t===0&&(i=e.hasGeometryAttribute(`tangent`)===!0?Ux.mul(r).normalize():qx({eye_pos:Xb,surf_norm:ix,mapN:r,uv:ub()})),i}},Yx=V(Jx),Xx=U(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||ub()),forceUVContext:!0}),r=G(n(e=>e));return J(G(n(e=>e.add(e.dFdx()))).sub(r),G(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Zx=U(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(ex),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Qx=class extends zh{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode;return Zx({surf_pos:Xb,surf_norm:ix,dHdxy:Xx({textureNode:this.textureNode,bumpScale:e})})}},$x=V(Qx),eS=new Map,$=class e extends R{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=eS.get(e);return n===void 0&&(n=kx(e,t),eS.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?Y():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:G(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularMap?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Yx(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?$x(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):ix;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Yx(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):ix;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=Bg(RS.x,RS.y,RS.y.negate(),RS.x).mul(e.rg.mul(2).sub(J(1)).normalize().mul(e.b))}else i=RS;else if(r===e.IRIDESCENCE_THICKNESS){let e=Ex(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=Ex(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO_MAP)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};$.ALPHA_TEST=`alphaTest`,$.COLOR=`color`,$.OPACITY=`opacity`,$.SHININESS=`shininess`,$.SPECULAR=`specular`,$.SPECULAR_STRENGTH=`specularStrength`,$.SPECULAR_INTENSITY=`specularIntensity`,$.SPECULAR_COLOR=`specularColor`,$.REFLECTIVITY=`reflectivity`,$.ROUGHNESS=`roughness`,$.METALNESS=`metalness`,$.NORMAL=`normal`,$.CLEARCOAT=`clearcoat`,$.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,$.CLEARCOAT_NORMAL=`clearcoatNormal`,$.EMISSIVE=`emissive`,$.ROTATION=`rotation`,$.SHEEN=`sheen`,$.SHEEN_ROUGHNESS=`sheenRoughness`,$.ANISOTROPY=`anisotropy`,$.IRIDESCENCE=`iridescence`,$.IRIDESCENCE_IOR=`iridescenceIOR`,$.IRIDESCENCE_THICKNESS=`iridescenceThickness`,$.IOR=`ior`,$.TRANSMISSION=`transmission`,$.THICKNESS=`thickness`,$.ATTENUATION_DISTANCE=`attenuationDistance`,$.ATTENUATION_COLOR=`attenuationColor`,$.LINE_SCALE=`scale`,$.LINE_DASH_SIZE=`dashSize`,$.LINE_GAP_SIZE=`gapSize`,$.LINE_WIDTH=`linewidth`,$.LINE_DASH_OFFSET=`dashOffset`,$.POINT_WIDTH=`pointWidth`,$.DISPERSION=`dispersion`,$.LIGHT_MAP=`light`,$.AO_MAP=`ao`;var tS=H($,$.ALPHA_TEST),nS=H($,$.COLOR),rS=H($,$.SHININESS),iS=H($,$.EMISSIVE),aS=H($,$.OPACITY),oS=H($,$.SPECULAR),sS=H($,$.SPECULAR_INTENSITY),cS=H($,$.SPECULAR_COLOR),lS=H($,$.SPECULAR_STRENGTH),uS=H($,$.REFLECTIVITY),dS=H($,$.ROUGHNESS),fS=H($,$.METALNESS),pS=H($,$.NORMAL).context({getUV:null}),mS=H($,$.CLEARCOAT),hS=H($,$.CLEARCOAT_ROUGHNESS),gS=H($,$.CLEARCOAT_NORMAL).context({getUV:null}),_S=H($,$.ROTATION),vS=H($,$.SHEEN),yS=H($,$.SHEEN_ROUGHNESS),bS=H($,$.ANISOTROPY),xS=H($,$.IRIDESCENCE),SS=H($,$.IRIDESCENCE_IOR),CS=H($,$.IRIDESCENCE_THICKNESS),wS=H($,$.TRANSMISSION),TS=H($,$.THICKNESS),ES=H($,$.IOR),DS=H($,$.ATTENUATION_DISTANCE),OS=H($,$.ATTENUATION_COLOR),kS=H($,$.LINE_SCALE),AS=H($,$.LINE_DASH_SIZE),jS=H($,$.LINE_GAP_SIZE),MS=H($,$.LINE_WIDTH),NS=H($,$.LINE_DASH_OFFSET),PS=H($,$.POINT_WIDTH),FS=H($,$.DISPERSION),IS=H($,$.LIGHT_MAP),LS=H($,$.AO_MAP),RS=Z(new A).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),zS=class extends zh{static get type(){return`ModelViewProjectionNode`}constructor(e=null){super(`vec4`),this.positionNode=e}setup(e){if(e.shaderStage===`fragment`)return Cy(e.context.mvp);let t=this.positionNode||Kb,n=e.renderer.nodes.modelViewMatrix||Hb;return Sb.mul(n).mul(t)}},BS=V(zS),VS=class e extends R{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isInstanceIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:Cy(this).build(t,n),a}};VS.VERTEX=`vertex`,VS.INSTANCE=`instance`,VS.SUBGROUP=`subgroup`,VS.INVOCATION_LOCAL=`invocationLocal`,VS.INVOCATION_SUBGROUP=`invocationSubgroup`,VS.DRAW=`draw`;var HS=H(VS,VS.VERTEX),US=H(VS,VS.INSTANCE),WS=H(VS,VS.SUBGROUP),GS=H(VS,VS.INVOCATION_SUBGROUP),KS=H(VS,VS.INVOCATION_LOCAL),qS=H(VS,VS.DRAW),JS=class extends R{static get type(){return`InstanceNode`}constructor(e){super(`void`),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=L.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,n=this.instanceColorNode,r=this.instanceMesh;if(t===null){let e=r.instanceMatrix;if(r.count<=1e3)t=yx(e.array,`mat4`,Math.max(r.count,1)).element(US);else{let n=new Cm(e.array,16,1);this.buffer=n;let r=e.usage===35048?Gy:Wy;t=Hg(r(n,`vec4`,16,0),r(n,`vec4`,16,4),r(n,`vec4`,16,8),r(n,`vec4`,16,12))}this.instanceMatrixNode=t}let i=r.instanceColor;if(i&&n===null){let e=new kl(i.array,3),t=i.usage===35048?Gy:Wy;this.bufferColor=e,n=Y(t(e,`vec3`,3,0)),this.instanceColorNode=n}let a=t.mul(Kb).xyz;if(Kb.assign(a),e.hasGeometryAttribute(`normal`)){let e=lx(nx,t);nx.assign(e)}this.instanceColorNode!==null&&r_(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==35048&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==35048&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}},YS=V(JS),XS=class extends R{static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=US:this.batchingIdNode=qS);let t=U(([e])=>{let t=fb(_b(this.batchMesh._indirectTexture),0),n=K(e).modInt(K(t)),r=K(e).div(K(t));return _b(this.batchMesh._indirectTexture,jg(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]})(K(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=fb(_b(n),0),i=G(t).mul(4).toInt().toVar(),a=i.modInt(r),o=i.div(K(r)),s=Hg(_b(n,jg(a,o)),_b(n,jg(a.add(1),o)),_b(n,jg(a.add(2),o)),_b(n,jg(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){let e=U(([e])=>{let t=fb(_b(c),0).x,n=e;return _b(c,jg(n.modInt(t),n.div(t))).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]})(t);r_(`vec3`,`vBatchColor`).assign(e)}let l=Vg(s);Kb.assign(s.mul(Kb));let u=nx.div(Y(l[0].dot(l[0]),l[1].dot(l[1]),l[2].dot(l[2]))),d=l.mul(u).xyz;nx.assign(d),e.hasGeometryAttribute(`tangent`)&&jx.mulAssign(l)}},ZS=V(XS),QS=new WeakMap,$S=class extends R{static get type(){return`SkinningNode`}constructor(e,t=!1){super(`void`),this.skinnedMesh=e,this.useReference=t,this.updateType=L.OBJECT,this.skinIndexNode=lb(`skinIndex`,`uvec4`),this.skinWeightNode=lb(`skinWeight`,`vec4`);let n,r,i;t?(n=Ex(`bindMatrix`,`mat4`),r=Ex(`bindMatrixInverse`,`mat4`),i=Dx(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length)):(n=Z(e.bindMatrix,`mat4`),r=Z(e.bindMatrixInverse,`mat4`),i=yx(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=i,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Kb){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=L_(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=nx){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=L_(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Dx(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,qb)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)}setup(e){this.needsPreviousBoneMatrices(e)&&qb.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(Kb.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();nx.assign(t),e.hasGeometryAttribute(`tangent`)&&jx.assign(t)}}generate(e,t){if(t!==`void`)return Kb.build(e,t)}update(e){let t=(this.useReference?e.object:this.skinnedMesh).skeleton;QS.get(t)!==e.frameId&&(QS.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}},eC=e=>B(new $S(e)),tC=e=>B(new $S(e,!0)),nC=class extends R{static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=nb(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack();return t.returnsNode=this.params[this.params.length-1](n,r,e),t.stackNode=r,e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let t=0,r=n.length-1;t<r;t++){let r=n[t],i=null,a=null,o=null,s=null,c=null,l=null;r.isNode?(s=`int`,o=this.getVarName(t),i=`0`,a=r.build(e,s),c=`<`):(s=r.type||`int`,o=r.name||this.getVarName(t),i=r.start,a=r.end,c=r.condition,l=r.update,typeof i==`number`?i=i.toString():i&&i.isNode&&(i=i.build(e,s)),typeof a==`number`?a=a.toString():a&&a.isNode&&(a=a.build(e,s)),i!==void 0&&a===void 0?(i+=` - 1`,a=`0`,c=`>=`):a!==void 0&&i===void 0&&(i=`0`,c=`<`),c===void 0&&(c=Number(i)>Number(a)?`>=`:`<`));let u={start:i,end:a},d=u.start,f=u.end,p=``,m=``,h=``;l||=s===`int`||s===`uint`?c.includes(`<`)?`++`:`--`:c.includes(`<`)?`+= 1.`:`-= 1.`,p+=e.getVar(s,o)+` = `+d,m+=o+` `+c+` `+f,h+=o+` `+l;let g=`for ( ${p}; ${m}; ${h} )`;e.addFlowCode((t===0?`
`:``)+e.tab+g+` {
`).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
`).removeFlowTab();return e.addFlowTab(),a}},rC=(...e)=>B(new nC(wg(e,`int`))).append(),iC=()=>nb(`continue`).append(),aC=()=>nb(`break`).append(),oC=(...e)=>(console.warn(`TSL.LoopNode: loop() has been renamed to Loop().`),rC(...e)),sC=new WeakMap,cC=new Fn,lC=U(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=K(HS).mul(n).add(a),s=o.div(r);return _b(e,jg(o.sub(s.mul(r)),s)).depth(i).mul(t)});function uC(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=sC.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Rn(p,u,d,a);m.type=E,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(cC.fromBufferAttribute(a,e),p[f+i+0]=cC.x,p[f+i+1]=cC.y,p[f+i+2]=cC.z,p[f+i+3]=0),n===!0&&(cC.fromBufferAttribute(o,e),p[f+i+4]=cC.x,p[f+i+5]=cC.y,p[f+i+6]=cC.z,p[f+i+7]=0),r===!0&&(cC.fromBufferAttribute(l,e),p[f+i+8]=cC.x,p[f+i+9]=cC.y,p[f+i+10]=cC.z,p[f+i+11]=l.itemSize===4?cC.w:1)}}o={count:a,texture:m,stride:l,size:new A(u,d)},sC.set(e,o);function g(){m.dispose(),sC.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var dC=class extends R{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=Z(1),this.updateType=L.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=uC(t);n===!0&&Kb.mulAssign(this.morphBaseInfluence),r===!0&&nx.mulAssign(this.morphBaseInfluence);let l=K(c.width);rC(a,({i:e})=>{let t=G(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(_b(this.mesh.morphTexture,jg(K(e).add(1),K(US))).r):t.assign(Ex(`morphTargetInfluences`,`float`).element(e).toVar()),n===!0&&Kb.addAssign(lC({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:K(0)})),r===!0&&nx.addAssign(lC({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:K(1)}))})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}},fC=V(dC),pC=e=>e.sort((e,t)=>e.id-t.id),mC=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},hC=new WeakMap,gC=class extends R{static get type(){return`LightsNode`}constructor(e=[]){super(`vec3`),this.totalDiffuseNode=Y().toVar(`totalDiffuse`),this.totalSpecularNode=Y().toVar(`totalSpecular`),this.outgoingLightNode=Y().toVar(`outgoingLight`),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getDataFromNode(this);for(let n of t.nodes)n.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=pC(this._lights),i=e.renderer.nodes.library;for(let e of r)if(e.isNode)t.push(B(e));else{let r=null;if(n!==null&&(r=mC(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;hC.has(e)?r=hC.get(e):(r=new n(e),hC.set(e,r)),t.push(r)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);let t=e.context,n=t.lightingModel,r=this.outgoingLightNode;if(n){let{_lightNodes:i,totalDiffuseNode:a,totalSpecularNode:o}=this;t.outgoingLight=r;let s=e.addStack(),c=e.getDataFromNode(this);c.nodes=s.nodes,n.start(t,s,e);for(let t of i)t.build(e);n.indirect(t,s,e);let{backdrop:l,backdropAlpha:u}=t,{directDiffuse:d,directSpecular:f,indirectDiffuse:p,indirectSpecular:m}=t.reflectedLight,h=d.add(p);l!==null&&(h=Y(u===null?l:u.mix(h,l)),t.material.transparent=!0),a.assign(h),o.assign(f.add(m)),r.assign(a.add(o)),n.finish(t,s,e),r=r.bypass(e.removeStack())}return r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}},_C=V(gC),vC=class extends R{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}generate(){console.warn(`Abstract function.`)}},yC=class extends vC{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},bC=class extends _y{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n={directDiffuse:Y().toVar(`directDiffuse`),directSpecular:Y().toVar(`directSpecular`),indirectDiffuse:Y().toVar(`indirectDiffuse`),indirectSpecular:Y().toVar(`indirectSpecular`)};return{radiance:Y().toVar(`radiance`),irradiance:Y().toVar(`irradiance`),iblIrradiance:Y().toVar(`iblIrradiance`),ambientOcclusion:G(1).toVar(`ambientOcclusion`),reflectedLight:n,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}},xC=V(bC),SC=class extends vC{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},CC,wC,TC=class e extends R{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=L.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=L.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(wC),wC.multiplyScalar(t.getPixelRatio())):wC.copy(n.viewport):n===null?t.getDrawingBufferSize(CC):(CC.width=n.width,CC.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?Z(CC||=new A):t===e.VIEWPORT?Z(wC||=new Fn):J(OC.div(DC)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(DC).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};TC.COORDINATE=`coordinate`,TC.VIEWPORT=`viewport`,TC.SIZE=`size`,TC.UV=`uv`;var EC=H(TC,TC.UV),DC=H(TC,TC.SIZE),OC=H(TC,TC.COORDINATE),kC=H(TC,TC.VIEWPORT),AC=kC.zw,jC=OC.sub(kC.xy),MC=jC.div(AC),NC=U(()=>(console.warn(`TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.`),DC),`vec2`).once()(),PC=U(()=>(console.warn(`TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),EC),`vec2`).once()(),FC=U(()=>(console.warn(`TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),EC.flipY()),`vec2`).once()(),IC=new A,LC=class extends hb{static get type(){return`ViewportTextureNode`}constructor(e=EC,t=null,n=null){n===null&&(n=new Tu,n.minFilter=v),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=L.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(IC);let n=this.value;(n.image.width!==IC.width||n.image.height!==IC.height)&&(n.image.width=IC.width,n.image.height=IC.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},RC=V(LC),zC=V(LC,null,null,{generateMipmaps:!0}),BC=null,VC=class extends LC{static get type(){return`ViewportDepthTextureNode`}constructor(e=EC,t=null){BC===null&&(BC=new ho),super(e,t,BC)}},HC=V(VC),UC=class e extends R{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=JC().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?KC(Xb.z,yb,bb):WC(Xb.z,yb,bb):n===e.LINEAR_DEPTH&&(i=r===null?WC(Xb.z,yb,bb):t.isPerspectiveCamera?WC(qC(r,yb,bb),yb,bb):r),i}};UC.DEPTH_BASE=`depthBase`,UC.DEPTH=`depth`,UC.LINEAR_DEPTH=`linearDepth`;var WC=(e,t,n)=>e.add(t).div(t.sub(n)),GC=(e,t,n)=>t.sub(n).mul(e).sub(t),KC=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),qC=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),JC=V(UC,UC.DEPTH_BASE),YC=H(UC,UC.DEPTH),XC=V(UC,UC.LINEAR_DEPTH),ZC=XC(HC());YC.assign=e=>JC(e);var QC=class e extends R{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{localClipIntersection:r,localClippingCount:i,globalClippingCount:a}=n,o=a+i,s=r?o-i:o;return this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n.planes,o,s):this.setupDefault(n.planes,o,s)}setupAlphaToCoverage(e,t,n){return U(()=>{let r=Sx(e),i=n_(`float`,`distanceToPlane`),a=n_(`float`,`distanceToGradient`),o=n_(`float`,`clipOpacity`);o.assign(1);let s;if(rC(n,({i:e})=>{s=r.element(e),i.assign(Xb.dot(s.xyz).negate().add(s.w)),a.assign(i.fwidth().div(2)),o.mulAssign(uy(a.negate(),a,i)),o.equal(0).discard()}),n<t){let e=n_(`float`,`unionclipOpacity`);e.assign(1),rC({start:n,end:t},({i:t})=>{s=r.element(t),i.assign(Xb.dot(s.xyz).negate().add(s.w)),a.assign(i.fwidth().div(2)),e.mulAssign(uy(a.negate(),a,i).oneMinus())}),o.mulAssign(e.oneMinus())}i_.a.mulAssign(o),i_.a.equal(0).discard()})()}setupDefault(e,t,n){return U(()=>{let r=Sx(e),i;if(rC(n,({i:e})=>{i=r.element(e),Xb.dot(i.xyz).greaterThan(i.w).discard()}),n<t){let e=n_(`bool`,`clipped`);e.assign(!0),rC({start:n,end:t},({i:t})=>{i=r.element(t),e.assign(Xb.dot(i.xyz).greaterThan(i.w).and(e))}),e.discard()}})()}};QC.ALPHA_TO_COVERAGE=`alphaToCoverage`,QC.DEFAULT=`default`;var $C=()=>B(new QC),ew=()=>B(new QC(QC.ALPHA_TO_COVERAGE)),tw=class extends di{static get type(){return`NodeMaterial`}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+Ch(this)}build(e){this.setup(e)}setupObserver(e){return new vh(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow(`vertex`,e.removeStack()),e.addStack();let t,n=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);n!==null&&e.stack.add(n);let i=X(r,i_.a).max(0);if(t=this.setupOutput(e,i),S_.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){let n=e.renderer.getMRT(),r=this.mrtNode;n===null?r!==null&&(t=r):(t=n,r!==null&&(t=n.merge(r)))}}else{let n=this.fragmentNode;n.isOutputStructNode!==!0&&(n=X(n)),t=this.setupOutput(e,n)}e.stack.outputNode=t,e.addFlow(`fragment`,e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{globalClippingCount:t,localClippingCount:n}=e.clippingContext,r=null;if(t||n){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=ew():e.stack.add($C())}return r}setupDepth(e){let{renderer:t}=e,n=this.depthNode;if(n===null){let e=`getMRT`in t&&t.getMRT();e&&e.has(`depth`)?n=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(n=BS().w.add(1).log2().mul(xb).mul(.5))}n!==null&&YC.assign(n).append()}setupPosition(e){let{object:t}=e,n=t.geometry;if(e.addStack(),(n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&fC(t).append(),t.isSkinnedMesh===!0&&tC(t).append(),this.displacementMap){let e=kx(`displacementMap`,`texture`),t=kx(`displacementScale`,`float`),n=kx(`displacementBias`,`float`);Kb.addAssign(nx.normalize().mul(e.x.mul(t).add(n)))}t.isBatchedMesh&&ZS(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&YS(t).append(),this.positionNode!==null&&Kb.assign(this.positionNode);let r=BS();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?X(this.colorNode):nS;this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=X(n.xyz.mul(lb(`color`,`vec3`)),n.a)),e.instanceColor&&(n=r_(`vec3`,`vInstanceColor`).mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=r_(`vec3`,`vBatchColor`).mul(n)),i_.assign(n);let r=this.opacityNode?G(this.opacityNode):aS;if(i_.a.assign(i_.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){let e=this.alphaTestNode===null?tS:G(this.alphaTestNode);i_.a.lessThanEqual(e).discard()}this.transparent===!1&&this.blending===1&&this.alphaToCoverage===!1&&i_.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Y(0):i_.rgb}setupNormal(){return this.normalNode?Y(this.normalNode):pS}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?kx(`envMap`,`cubeTexture`):kx(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new SC(IS)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?LS:this.aoNode;t.push(new yC(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=_C([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,o=this.setupOutgoingLight(e);return a&&a.getScope().getLights().length>0?o=xC(a,this.setupLightingModel(e),n,r):n!==null&&(o=Y(r===null?n:oy(o,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(a_.assign(Y(i||iS)),o=o.add(a_)),o}setupOutput(e,t){if(this.fog===!0){let n=e.fogNode;n&&(t=X(n.mix(t.rgb,n.colorNode),t.a))}return t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=di.prototype.toJSON.call(this,e),r=wh(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}},nw=new _u,rw=class extends tw{static get type(){return`InstancedPointsNodeMaterial`}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(nw),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){let t=this.alphaToCoverage,n=this.useColor;this.vertexNode=U(()=>{let e=lb(`instancePosition`).xyz,t=X(Hb.mul(X(e,1))),n=kC.z.div(kC.w),r=Sb.mul(t),i=Gb.xy.toVar();return i.mulAssign(this.pointWidthNode?this.pointWidthNode:PS),i.assign(i.div(kC.z)),i.y.assign(i.y.mul(n)),i.assign(i.mul(r.w)),r.addAssign(X(i,0,0)),r})(),this.fragmentNode=U(()=>{let r=G(1).toVar(),i=ay(ub().mul(2).sub(1));if(t&&e.samples>1){let e=G(i.fwidth()).toVar();r.assign(uy(e.oneMinus(),e.add(1),i).oneMinus())}else i.greaterThan(1).discard();let a;return a=this.pointColorNode?this.pointColorNode:n?lb(`instanceColor`).mul(nS):nS,r.mulAssign(aS),X(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}},iw=new ru,aw=class extends tw{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(iw),this.setValues(e)}},ow=new Tf,sw=class extends tw{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(ow),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode,t=this.dashScaleNode?G(this.dashScaleNode):kS,n=this.dashSizeNode?G(this.dashSizeNode):AS,r=this.dashSizeNode?G(this.dashGapNode):jS;C_.assign(n),w_.assign(r);let i=Cy(lb(`lineDistance`).mul(t));(e?i.add(e):i).mod(C_.add(w_)).greaterThan(C_).discard()}},cw=new Tf,lw=class extends tw{static get type(){return`Line2NodeMaterial`}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(cw),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){let t=this.alphaToCoverage,n=this.useColor,r=this.dashed,i=this.worldUnits,a=U(({start:e,end:t})=>{let n=Sb.element(2).element(2),r=Sb.element(3).element(2).mul(-.5).div(n).sub(e.z).div(t.z.sub(e.z));return X(oy(e.xyz,t.xyz,r),t.w)}).setLayout({name:`trimSegment`,type:`vec4`,inputs:[{name:`start`,type:`vec4`},{name:`end`,type:`vec4`}]});this.vertexNode=U(()=>{let e=lb(`instanceStart`),t=lb(`instanceEnd`),n=X(Hb.mul(X(e,1))).toVar(`start`),o=X(Hb.mul(X(t,1))).toVar(`end`);i&&(r_(`vec3`,`worldStart`).assign(n.xyz),r_(`vec3`,`worldEnd`).assign(o.xyz));let s=kC.z.div(kC.w);W(Sb.element(2).element(3).equal(-1),()=>{W(n.z.lessThan(0).and(o.z.greaterThan(0)),()=>{o.assign(a({start:n,end:o}))}).ElseIf(o.z.lessThan(0).and(n.z.greaterThanEqual(0)),()=>{n.assign(a({start:o,end:n}))})});let c=Sb.mul(n),l=Sb.mul(o),u=c.xyz.div(c.w),d=l.xyz.div(l.w),f=d.xy.sub(u.xy).toVar();f.x.assign(f.x.mul(s)),f.assign(f.normalize());let p=X().toVar();if(i){let e=o.xyz.sub(n.xyz).normalize(),t=oy(n.xyz,o.xyz,.5).normalize(),i=e.cross(t).normalize(),a=e.cross(i),s=r_(`vec4`,`worldPos`);s.assign(Gb.y.lessThan(.5).select(n,o));let c=MS.mul(.5);s.addAssign(X(Gb.x.lessThan(0).select(i.mul(c),i.mul(c).negate()),0)),r||(s.addAssign(X(Gb.y.lessThan(.5).select(e.mul(c).negate(),e.mul(c)),0)),s.addAssign(X(a.mul(c),0)),W(Gb.y.greaterThan(1).or(Gb.y.lessThan(0)),()=>{s.subAssign(X(a.mul(2).mul(c),0))})),p.assign(Sb.mul(s));let l=Y().toVar();l.assign(Gb.y.lessThan(.5).select(u,d)),p.z.assign(l.z.mul(p.w))}else{let e=J(f.y,f.x.negate()).toVar(`offset`);f.x.assign(f.x.div(s)),e.x.assign(e.x.div(s)),e.assign(Gb.x.lessThan(0).select(e.negate(),e)),W(Gb.y.lessThan(0),()=>{e.assign(e.sub(f))}).ElseIf(Gb.y.greaterThan(1),()=>{e.assign(e.add(f))}),e.assign(e.mul(MS)),e.assign(e.div(kC.w)),p.assign(Gb.y.lessThan(.5).select(c,l)),e.assign(e.mul(p.w)),p.assign(p.add(X(e,0,0)))}return p})();let o=U(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return J(f,s.add(c.mul(f)).div(u).clamp())});this.fragmentNode=U(()=>{let a=ub();if(r){let e=this.offsetNode?G(this.offsetNodeNode):NS,t=this.dashScaleNode?G(this.dashScaleNode):kS,n=this.dashSizeNode?G(this.dashSizeNode):AS,r=this.dashSizeNode?G(this.dashGapNode):jS;C_.assign(n),w_.assign(r);let i=lb(`instanceDistanceStart`),o=lb(`instanceDistanceEnd`),s=Cy(Gb.y.lessThan(.5).select(t.mul(i),kS.mul(o)).add(NS)),c=e?s.add(e):s;a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),c.mod(C_.add(w_)).greaterThan(C_).discard()}let s=G(1).toVar(`alpha`);if(i){let n=r_(`vec3`,`worldStart`),i=r_(`vec3`,`worldEnd`),a=r_(`vec4`,`worldPos`).xyz.normalize().mul(1e5),c=i.sub(n),l=o({p1:n,p2:i,p3:Y(0,0,0),p4:a}),u=n.add(c.mul(l.x)),d=a.mul(l.y),f=u.sub(d).length().div(MS);if(!r)if(t&&e.samples>1){let e=f.fwidth();s.assign(uy(e.negate().add(.5),e.add(.5),f).oneMinus())}else f.greaterThan(.5).discard()}else if(t&&e.samples>1){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),n=e.mul(e).add(t.mul(t)),r=G(n.fwidth()).toVar(`dlen`);W(a.y.abs().greaterThan(1),()=>{s.assign(uy(r.oneMinus(),r.add(1),n).oneMinus())})}else W(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});let c;if(this.lineColorNode)c=this.lineColorNode;else if(n){let e=lb(`instanceColorStart`),t=lb(`instanceColorEnd`);c=Gb.y.lessThan(.5).select(e,t).mul(nS)}else c=nS;return X(c,s)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}},uw=e=>B(e).mul(.5).add(.5),dw=e=>B(e).mul(2).sub(1),fw=new Sf,pw=class extends tw{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(fw),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?G(this.opacityNode):aS;i_.assign(X(uw(ox),e))}},mw=class extends zh{static get type(){return`EquirectUVNode`}constructor(e=Yb){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode;return J(e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))}},hw=V(mw),gw=class extends va{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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=new Zi(5,5,5),a=hw(Yb),o=new tw;o.colorNode=gb(t,a,0),o.side=1,o.blending=0;let s=new Ji(i,o),c=new Gc;c.add(s),t.minFilter===1008&&(t.minFilter=h);let l=new ga(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.currentGenerateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}},_w=new WeakMap,vw=class extends zh{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=_x();let t=new _a;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=L.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(_w.has(e)){let t=_w.get(e);xw(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(yw(n)){let r=new gw(n.height);r.fromEquirectangularTexture(t,e),xw(r.texture,e.mapping),this._cubeTexture=r.texture,_w.set(e,r.texture),e.addEventListener(`dispose`,bw)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function yw(e){return e==null?!1:e.height>0}function bw(e){let t=e.target;t.removeEventListener(`dispose`,bw);let n=_w.get(t);n!==void 0&&(_w.delete(t),n.dispose())}function xw(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var Sw=V(vw),Cw=class extends vC{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Sw(this.envNode)}},ww=class extends vC{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=G(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},Tw=class{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},Ew=class extends Tw{constructor(){super()}indirect(e,t,n){let r=e.ambientOcclusion,i=e.reflectedLight,a=n.context.irradianceLightMap;i.indirectDiffuse.assign(X(0)),a?i.indirectDiffuse.addAssign(a):i.indirectDiffuse.addAssign(X(1,1,1,0)),i.indirectDiffuse.mulAssign(r),i.indirectDiffuse.mulAssign(i_.rgb)}finish(e,t,n){let r=n.material,i=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case 0:i.rgb.assign(oy(i.rgb,i.rgb.mul(a.rgb),lS.mul(uS)));break;case 1:i.rgb.assign(oy(i.rgb,a.rgb,lS.mul(uS)));break;case 2:i.rgb.addAssign(a.rgb.mul(lS.mul(uS)));break;default:console.warn(`THREE.BasicLightingModel: Unsupported .combine value:`,r.combine);break}}},Dw=new fi,Ow=class extends tw{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Dw),this.setValues(e)}setupNormal(){return ix}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cw(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ww(IS)),t}setupOutgoingLight(){return i_.rgb}setupLightingModel(){return new Ew}},kw=U(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Aw=U(e=>e.diffuseColor.mul(1/Math.PI)),jw=()=>G(.25),Mw=U(({dotNH:e})=>x_.mul(G(.5)).add(1).mul(G(1/Math.PI)).mul(e.pow(x_))),Nw=U(({lightDirection:e})=>{let t=e.add(Zb).normalize(),n=ox.dot(t).clamp(),r=kw({f0:y_,f90:1,dotVH:Zb.dot(t).clamp()}),i=jw(),a=Mw({dotNH:n});return r.mul(i).mul(a)}),Pw=class extends Ew{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ox.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(Aw({diffuseColor:i_.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(Nw({lightDirection:e})).mul(lS))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(Aw({diffuseColor:i_}))),n.indirectDiffuse.mulAssign(e)}},Fw=new Cf,Iw=class extends tw{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Fw),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cw(t):null}setupLightingModel(){return new Pw(!1)}},Lw=new bf,Rw=class extends tw{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Lw),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cw(t):null}setupLightingModel(){return new Pw}setupVariants(){let e=(this.shininessNode?G(this.shininessNode):rS).max(1e-4);x_.assign(e);let t=this.specularNode||oS;y_.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}},zw=U(()=>{let e=ix.dFdx().abs().max(ix.dFdy().abs());return e.x.max(e.y).max(e.z)}),Bw=U(e=>{let{roughness:t}=e,n=zw(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),Vw=U(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return B_(.5,i.add(a).max(av))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Hw=U(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(Y(e.mul(n),t.mul(r),o).length()),l=o.mul(Y(e.mul(i),t.mul(a),s).length());return B_(.5,c.add(l)).saturate()}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),Uw=U(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Ww=G(1/Math.PI),Gw=U(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=Y(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Ww.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Kw=U(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||ox,l=i.pow2(),u=t.add(Zb).normalize(),d=c.dot(t).clamp(),f=c.dot(Zb).clamp(),p=c.dot(u).clamp(),m=kw({f0:n,f90:r,dotVH:Zb.dot(u).clamp()}),h,g;if(bg(o)&&(m=f_.mix(m,a)),bg(s)){let e=__.dot(t),n=__.dot(Zb),r=__.dot(u),i=v_.dot(t),a=v_.dot(Zb),o=v_.dot(u);h=Hw({alphaT:h_,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),g=Gw({alphaT:h_,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else h=Vw({alpha:l,dotNL:d,dotNV:f}),g=Uw({alpha:l,dotNH:p});return m.mul(h).mul(g)}),qw=U(({roughness:e,dotNV:t})=>{let n=X(-1,-.0275,-.572,.022),r=X(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return J(-1.04,1.04).mul(a).add(i.zw)}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Jw=U(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=qw({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),Yw=U(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(Y(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),Xw=U(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=G(1).div(n),i=t.pow2().oneMinus().max(.0078125);return G(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),Zw=U(({dotNV:e,dotNL:t})=>G(1).div(G(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),Qw=U(({lightDirection:e})=>{let t=e.add(Zb).normalize(),n=ox.dot(e).clamp(),r=ox.dot(Zb).clamp(),i=Xw({roughness:d_,dotNH:ox.dot(t).clamp()}),a=Zw({dotNV:r,dotNL:n});return u_.mul(i).mul(a)}),$w=U(({N:e,V:t,roughness:n})=>{let r=J(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),eT=U(({f:e})=>{let t=e.length();return Gv(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),tT=U(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,Gv(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),nT=U(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=Y().toVar();return W(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(Vg(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=Y(0).toVar();g.addAssign(tT({v1:f,v2:p})),g.addAssign(tT({v1:p,v2:m})),g.addAssign(tT({v1:m,v2:h})),g.addAssign(tT({v1:h,v2:f})),d.assign(Y(eT({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),rT=1/6,iT=e=>z_(rT,z_(e,z_(e,e.negate().add(3)).sub(3)).add(1)),aT=e=>z_(rT,z_(e,z_(e,z_(3,e).sub(6))).add(4)),oT=e=>z_(rT,z_(e,z_(e,z_(-3,e).add(3)).add(3)).add(1)),sT=e=>z_(rT,$v(e,3)),cT=e=>iT(e).add(aT(e)),lT=e=>oT(e).add(sT(e)),uT=e=>L_(-1,aT(e).div(iT(e).add(aT(e)))),dT=e=>L_(1,sT(e).div(oT(e).add(sT(e)))),fT=(e,t,n)=>{let r=e.uvNode,i=z_(r,t.zw).add(.5),a=bv(i),o=Cv(i),s=cT(o.x),c=lT(o.x),l=uT(o.x),u=dT(o.x),d=uT(o.y),f=dT(o.y),p=J(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=J(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=J(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=J(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=cT(o.y).mul(L_(s.mul(e.uv(p).level(n)),c.mul(e.uv(m).level(n)))),v=lT(o.y).mul(L_(s.mul(e.uv(h).level(n)),c.mul(e.uv(g).level(n))));return _.add(v)},pT=U(([e,t=G(3)])=>{let n=J(e.size(K(t))),r=J(e.size(K(t.add(1)))),i=B_(1,n),a=B_(1,r),o=fT(e,X(i,n),bv(t)),s=fT(e,X(a,r),xv(t));return Cv(t).mix(o,s)}),mT=U(([e,t,n,r,i])=>{let a=Y(ly(t.negate(),Sv(e),B_(1,r))),o=Y(Mv(i[0].xyz),Mv(i[1].xyz),Mv(i[2].xyz));return Sv(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),hT=U(([e,t])=>e.mul(sy(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),gT=zC(),_T=U(([e,t,n])=>pT(gT.uv(e),_v(G(DC.x)).mul(hT(t,n)))),vT=U(([e,t,n])=>(W(n.notEqual(0),()=>mv(gv(t).negate().div(n).negate().mul(e))),Y(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),yT=U(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=X().toVar(),g=Y().toVar();let i=u.sub(1).mul(m.mul(.025)),a=Y(u.sub(i),u,u.add(i));rC({start:0,end:3},({i})=>{let u=a.element(i),m=mT(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(X(_,1))),y=J(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(J(y.x,y.y.oneMinus()));let b=_T(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(vT(Mv(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=mT(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(X(a,1))),_=J(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(J(_.x,_.y.oneMinus())),h=_T(_,n,u),g=r.mul(vT(Mv(i),f,p))}let _=g.rgb.mul(h.rgb),v=Y(Jw({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return X(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),bT=Vg(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),xT=e=>{let t=e.sqrt();return Y(1).add(t).div(Y(1).sub(t))},ST=(e,t)=>e.sub(t).div(e.add(t)).pow2(),CT=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=Y(54856e-17,44201e-17,52481e-17),i=Y(1681e3,1795300,2208400),a=Y(43278e5,93046e5,66121e5),o=G(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=Y(s.x.add(o),s.y,s.z).div(1.0685e-7),bT.mul(s)},wT=U(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=oy(e,t,uy(0,.03,r)),o=e.div(a).pow2().mul(G(1).sub(n.pow2())),s=G(1).sub(o).sqrt(),c=kw({f0:ST(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=G(Math.PI).sub(u),f=xT(i.clamp(0,.9999)),p=kw({f0:ST(f,a.toVec3()),f90:1,dotVH:s}),m=Y(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=Y(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(Y(1).sub(_)),b=c.add(y),x=y.sub(l);for(let e=1;e<=2;++e){x=x.mul(v);let t=CT(G(e).mul(h),G(e).mul(g)).mul(2);b=b.add(x.mul(t))}return b.max(Y(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),TT=U(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.pow2(),a=hy(n.lessThan(.25),G(-339.2).mul(i).add(G(161.4).mul(n)).sub(25.9),G(-8.48).mul(i).add(G(14.3).mul(n)).sub(9.95)),o=hy(n.lessThan(.25),G(44).mul(i).sub(G(23.7).mul(n)).add(3.26),G(1.97).mul(i).sub(G(3.27).mul(n)).add(.72));return hy(n.lessThan(.25),0,G(.1).mul(n).sub(.025)).add(a.mul(r).add(o).exp()).mul(1/Math.PI).saturate()}),ET=Y(.04),DT=G(1),OT=class extends Tw{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Y().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=Y().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=Y().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=Y().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=Y().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=ox.dot(Zb).clamp();this.iridescenceFresnel=wT({outsideIOR:G(1),eta2:p_,cosTheta1:e,thinFilmThickness:m_,baseF0:y_}),this.iridescenceF0=Yw({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(this.transmission===!0){let t=Jb;e.backdrop=yT(sx,Db.sub(Jb).normalize(),o_,i_,y_,b_,t,Ib,wb,Sb,E_,O_,A_,k_,this.dispersion?j_:null),e.backdropAlpha=D_,i_.a.mulAssign(oy(1,e.backdrop.a,D_))}}computeMultiscattering(e,t,n){let r=qw({roughness:o_,dotNV:ox.dot(Zb).clamp()}),i=(this.iridescenceF0?f_.mix(y_,this.iridescenceF0):y_).mul(r.x).add(n.mul(r.y)),a=r.x.add(r.y).oneMinus(),o=y_.add(y_.oneMinus().mul(.047619)),s=i.mul(o).div(a.mul(o).oneMinus());e.addAssign(i),t.addAssign(s.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ox.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(Qw({lightDirection:e}))),this.clearcoat===!0){let n=cx.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(Kw({lightDirection:e,f0:ET,f90:DT,roughness:l_,normalView:cx})))}n.directDiffuse.addAssign(r.mul(Aw({diffuseColor:i_.rgb}))),n.directSpecular.addAssign(r.mul(Kw({lightDirection:e,f0:y_,f90:1,roughness:o_,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=ox,f=Zb,p=Xb.toVar(),m=$w({N:d,V:f,roughness:o_}),h=a.uv(m).toVar(),g=o.uv(m).toVar(),_=Vg(Y(h.x,0,h.y),Y(0,1,0),Y(h.z,0,h.w)).toVar(),v=y_.mul(g.x).add(y_.oneMinus().mul(g.y)).toVar();i.directSpecular.addAssign(e.mul(v).mul(nT({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(i_).mul(nT({N:d,V:f,P:p,mInv:Vg(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(Aw({diffuseColor:i_})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(u_,TT({normal:ox,viewDir:Zb,roughness:d_}))),this.clearcoat===!0){let e=Jw({dotNV:cx.dot(Zb).clamp(),specularColor:ET,specularF90:DT,roughness:l_});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let r=Y().toVar(`singleScattering`),i=Y().toVar(`multiScattering`),a=t.mul(1/Math.PI);this.computeMultiscattering(r,i,b_);let o=r.add(i),s=i_.mul(o.r.max(o.g).max(o.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(i.mul(a)),n.indirectDiffuse.addAssign(s.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){let n=ox.dot(Zb).clamp().add(e),r=o_.mul(-16).oneMinus().negate().exp2(),i=e.sub(n.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(i)}finish(e){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=kw({dotVH:cx.dot(Zb).clamp(),f0:ET,f90:DT}),n=t.mul(c_.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(c_));t.assign(n)}if(this.sheen===!0){let e=u_.r.max(u_.g).max(u_.b).mul(.157).oneMinus(),n=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}},kT=G(1),AT=G(-2),jT=G(.8),MT=G(-1),NT=G(.4),PT=G(2),FT=G(.305),IT=G(3),LT=G(.21),RT=G(4),zT=G(4),BT=G(16),VT=U(([e])=>{let t=Y(Av(e)).toVar(),n=G(-1).toVar();return W(t.x.greaterThan(t.z),()=>{W(t.x.greaterThan(t.y),()=>{n.assign(hy(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(hy(e.y.greaterThan(0),1,4))})}).Else(()=>{W(t.z.greaterThan(t.y),()=>{n.assign(hy(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(hy(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),HT=U(([e,t])=>{let n=J().toVar();return W(t.equal(0),()=>{n.assign(J(e.z,e.y).div(Av(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(J(e.x.negate(),e.z.negate()).div(Av(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(J(e.x.negate(),e.y).div(Av(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(J(e.z.negate(),e.y).div(Av(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(J(e.x.negate(),e.z).div(Av(e.y)))}).Else(()=>{n.assign(J(e.x,e.y).div(Av(e.z)))}),z_(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),UT=U(([e])=>{let t=G(0).toVar();return W(e.greaterThanEqual(jT),()=>{t.assign(kT.sub(e).mul(MT.sub(AT)).div(kT.sub(jT)).add(AT))}).ElseIf(e.greaterThanEqual(NT),()=>{t.assign(jT.sub(e).mul(PT.sub(MT)).div(jT.sub(NT)).add(MT))}).ElseIf(e.greaterThanEqual(FT),()=>{t.assign(NT.sub(e).mul(IT.sub(PT)).div(NT.sub(FT)).add(PT))}).ElseIf(e.greaterThanEqual(LT),()=>{t.assign(FT.sub(e).mul(RT.sub(IT)).div(FT.sub(LT)).add(IT))}).Else(()=>{t.assign(G(-2).mul(_v(z_(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),WT=U(([e,t])=>{let n=e.toVar();n.assign(z_(2,n).sub(1));let r=Y(n,1).toVar();return W(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),GT=U(([e,t,n,r,i,a])=>{let o=G(n),s=Y(t),c=sy(UT(o),AT,a),l=Cv(c),u=bv(c),d=Y(KT(e,s,u,r,i,a)).toVar();return W(l.notEqual(0),()=>{let t=Y(KT(e,s,u.add(1),r,i,a)).toVar();d.assign(oy(d,t,l))}),d}),KT=U(([e,t,n,r,i,a])=>{let o=G(n).toVar(),s=Y(t),c=G(VT(s)).toVar(),l=G(Gv(zT.sub(o),0)).toVar();o.assign(Gv(o,zT));let u=G(hv(o)).toVar(),d=J(HT(s,c).mul(u.sub(2)).add(1)).toVar();return W(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(z_(3,BT))),d.y.addAssign(z_(4,hv(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.uv(d).grad(J(),J())}),qT=U(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=Tv(r);return KT(e,n.mul(c).add(i.cross(n).mul(wv(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),JT=U(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=Y(hy(t,n,Qv(n,r))).toVar();W(lv(f.equals(Y(0))),()=>{f.assign(Y(r.z,0,r.x.negate()))}),f.assign(Sv(f));let p=Y().toVar();return p.addAssign(i.element(K(0)).mul(qT({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),rC({start:K(1),end:e},({i:e})=>{W(e.greaterThanEqual(a),()=>{aC()});let t=G(o.mul(G(e))).toVar();p.addAssign(i.element(e).mul(qT({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(qT({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),X(p,1)}),YT=null,XT=new WeakMap;function ZT(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function QT(e){let t=XT.get(e);if((t===void 0?-1:t.pmremVersion)!==e.pmremVersion){let n=e.image;if(e.isCubeTexture)if(eE(n))t=YT.fromCubemap(e,t);else return null;else if(tE(n))t=YT.fromEquirectangular(e,t);else return null;t.pmremVersion=e.pmremVersion,XT.set(e,t)}return t.texture}var $T=class extends zh{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Pn;r.isRenderTargetTexture=!0,this._texture=gb(r),this._width=Z(0),this._height=Z(0),this._maxMip=Z(0),this.updateBeforeType=L.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=ZT(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem,t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(e=n.isPMREMTexture===!0?n:QT(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){YT===null&&(YT=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));let n=this.value;e.renderer.coordinateSystem===2e3&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Y(t.x.negate(),t.yz));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),GT(this._texture,t,r,this._width,this._height,this._maxMip)}};function eE(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function tE(e){return e==null?!1:e.height>0}var nE=V($T),rE=new WeakMap,iE=class extends vC{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let e=n.isTextureNode?n.value:t[n.property],r=rE.get(e);r===void 0&&(r=nE(e),rE.set(e,r)),n=r}let r=t.envMap?Ex(`envMapIntensity`,`float`,e.material):Ex(`environmentIntensity`,`float`,e.scene),i=t.useAnisotropy===!0||t.anisotropy>0?Kx:ox,a=n.context(aE(o_,i)).mul(r),o=n.context(oE(sx)).mul(Math.PI).mul(r),s=Yy(a),c=Yy(o);e.context.radiance.addAssign(s),e.context.iblIrradiance.addAssign(c);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=Yy(n.context(aE(l_,cx)).mul(r));l.addAssign(e)}}},aE=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=Zb.negate().reflect(t),n=e.mul(e).mix(n,t).normalize(),n=n.transformDirection(wb)),n),getTextureLevel:()=>e}},oE=e=>({getUV:()=>e,getTextureLevel:()=>G(1)}),sE=new vf,cE=class extends tw{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(sE),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new iE(t):null}setupLightingModel(){return new OT}setupSpecular(){let e=oy(Y(.04),i_.rgb,s_);y_.assign(e),b_.assign(1)}setupVariants(){let e=this.metalnessNode?G(this.metalnessNode):fS;s_.assign(e);let t=this.roughnessNode?G(this.roughnessNode):dS;t=Bw({roughness:t}),o_.assign(t),this.setupSpecular(),i_.assign(X(i_.rgb.mul(e.oneMinus()),i_.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}},lE=new yf,uE=class extends cE{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(lE),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?G(this.iorNode):ES;E_.assign(e),y_.assign(oy(Wv(ey(E_.sub(1).div(E_.add(1))).mul(cS),Y(1)).mul(sS),i_.rgb,s_)),b_.assign(oy(sS,1,s_))}setupLightingModel(){return new OT(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?G(this.clearcoatNode):mS,t=this.clearcoatRoughnessNode?G(this.clearcoatRoughnessNode):hS;c_.assign(e),l_.assign(Bw({roughness:t}))}if(this.useSheen){let e=this.sheenNode?Y(this.sheenNode):vS,t=this.sheenRoughnessNode?G(this.sheenRoughnessNode):yS;u_.assign(e),d_.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?G(this.iridescenceNode):xS,t=this.iridescenceIORNode?G(this.iridescenceIORNode):SS,n=this.iridescenceThicknessNode?G(this.iridescenceThicknessNode):CS;f_.assign(e),p_.assign(t),m_.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?J(this.anisotropyNode):bS).toVar();g_.assign(e.length()),W(g_.equal(0),()=>{e.assign(J(1,0))}).Else(()=>{e.divAssign(J(g_)),g_.assign(g_.saturate())}),h_.assign(g_.pow2().mix(o_.pow2(),1)),__.assign(Ux[0].mul(e.x).add(Ux[1].mul(e.y))),v_.assign(Ux[1].mul(e.x).sub(Ux[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?G(this.transmissionNode):wS,t=this.thicknessNode?G(this.thicknessNode):TS,n=this.attenuationDistanceNode?G(this.attenuationDistanceNode):DS,r=this.attenuationColorNode?Y(this.attenuationColorNode):OS;if(D_.assign(e),O_.assign(t),k_.assign(n),A_.assign(r),this.useDispersion){let e=this.dispersionNode?G(this.dispersionNode):FS;j_.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Y(this.clearcoatNormalNode):gS}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}},dE=class extends OT{constructor(e,t,n,r){super(e,t,n),this.useSSS=r}direct({lightDirection:e,lightColor:t,reflectedLight:n},r,i){if(this.useSSS===!0){let{thicknessColorNode:r,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:s,thicknessPowerNode:c,thicknessScaleNode:l}=i.material,u=e.add(ox.mul(a)).normalize(),d=Y(G(Zb.dot(u.negate()).saturate().pow(c).mul(l)).add(o).mul(r));n.directDiffuse.addAssign(d.mul(s.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},r,i)}},fE=class extends uE{static get type(){return`MeshSSSNodeMaterial`}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=G(.1),this.thicknessAmbientNode=G(0),this.thicknessAttenuationNode=G(.1),this.thicknessPowerNode=G(2),this.thicknessScaleNode=G(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new dE(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}},pE=U(({normal:e,lightDirection:t,builder:n})=>{let r=J(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return Y(kx(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return oy(Y(.7),Y(1),uy(G(.7).sub(e.x),G(.7).add(e.x),r.x))}}),mE=class extends Tw{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,i){let a=pE({normal:tx,lightDirection:e,builder:i}).mul(t);n.directDiffuse.addAssign(a.mul(Aw({diffuseColor:i_.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(Aw({diffuseColor:i_}))),n.indirectDiffuse.mulAssign(e)}},hE=new xf,gE=class extends tw{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(hE),this.setValues(e)}setupLightingModel(){return new mE}},_E=class extends zh{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=Y(Zb.z,0,Zb.x.negate()).normalize(),t=Zb.cross(e);return J(e.dot(ox),t.dot(ox)).mul(.495).add(.5)}},vE=H(_E),yE=new wf,bE=class extends tw{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(yE),this.setValues(e)}setupVariants(e){let t=vE,n;n=e.material.matcap?kx(`matcap`,`texture`).context({getUV:()=>t}):Y(oy(.2,.8,t.y)),i_.rgb.mulAssign(n.rgb)}},xE=new _u,SE=class extends tw{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(xE),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}},CE=class extends zh{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return Bg(e,r,r.negate(),e).mul(n)}else{let e=t,r=Hg(X(1,0,0,0),X(0,Tv(e.x),wv(e.x).negate(),0),X(0,wv(e.x),Tv(e.x),0),X(0,0,0,1)),i=Hg(X(Tv(e.y),0,wv(e.y),0),X(0,1,0,0),X(wv(e.y).negate(),0,Tv(e.y),0),X(0,0,0,1)),a=Hg(X(Tv(e.z),wv(e.z).negate(),0,0),X(wv(e.z),Tv(e.z),0,0),X(0,0,1,0),X(0,0,0,1));return r.mul(i).mul(a).mul(X(n,1)).xyz}}},wE=V(CE),TE=new Yc,EE=class extends tw{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(TE),this.setValues(e)}setupPosition({object:e,camera:t,context:n}){let r=this.sizeAttenuation,{positionNode:i,rotationNode:a,scaleNode:o}=this,s=Kb,c=Hb.mul(Y(i||0)),l=J(Ib[0].xyz.length(),Ib[1].xyz.length());o!==null&&(l=l.mul(o)),!r&&t.isPerspectiveCamera&&(l=l.mul(c.z.negate()));let u=s.xy;if(e.center&&e.center.isVector2===!0){let e=Fy(`center`,`vec2`);u=u.sub(e.sub(.5))}u=u.mul(l);let d=G(a||_S),f=wE(u,d);c=X(c.xy.add(f),c.zw);let p=Sb.mul(c);return n.vertex=s,p}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},DE=class extends Tw{constructor(){super(),this.shadowNode=G(1).toVar(`shadowMask`)}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){i_.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(i_.rgb)}},OE=new gf,kE=class extends tw{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(OE),this.setValues(e)}setupLightingModel(){return new DE}},AE=U(({texture:e,uv:t})=>{let n=1e-4,r=Y().toVar();return W(t.x.lessThan(n),()=>{r.assign(Y(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(Y(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(Y(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(Y(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(Y(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(Y(0,0,-1))}).Else(()=>{let n=.01,i=e.uv(t.add(Y(-n,0,0))).r.sub(e.uv(t.add(Y(n,0,0))).r),a=e.uv(t.add(Y(0,-n,0))).r.sub(e.uv(t.add(Y(0,n,0))).r),o=e.uv(t.add(Y(0,0,-n))).r.sub(e.uv(t.add(Y(0,0,n))).r);r.assign(Y(i,a,o))}),r.normalize()}),jE=class extends hb{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return Y(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return AE({texture:this,uv:e})}},ME=V(jE),NE=class extends tw{static get type(){return`VolumeNodeMaterial`}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){let t=ME(this.map,null,0),n=U(({orig:e,dir:t})=>{let n=Y(-.5),r=Y(.5),i=t.reciprocal(),a=n.sub(e).mul(i),o=r.sub(e).mul(i),s=Wv(a,o),c=Gv(a,o);return J(Gv(s.x,Gv(s.y,s.z)),Wv(c.x,Wv(c.y,c.z)))});this.fragmentNode=U(()=>{let e=Cy(Y(Vb.mul(X(Db,1)))),r=Cy(Gb.sub(e)).normalize(),i=J(n({orig:e,dir:r})).toVar();i.x.greaterThan(i.y).discard(),i.assign(J(Gv(i.x,0),i.y));let a=Y(e.add(i.x.mul(r))).toVar(),o=Y(r.abs().reciprocal()).toVar(),s=G(Wv(o.x,Wv(o.y,o.z))).toVar(`delta`);s.divAssign(kx(`steps`,`float`));let c=X(kx(`base`,`color`),0).toVar();return rC({type:`float`,start:i.x,end:i.y,update:`+= delta`},()=>{let e=n_(`float`,`d`).assign(t.uv(a.add(.5)).r);this.testNode===null?(c.a.assign(1),aC()):this.testNode({map:t,mapValue:e,probe:a,finalColor:c}).append(),a.addAssign(r.mul(s))}),c.a.equal(0).discard(),X(c)})(),super.setup(e)}},PE=class extends Qf{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,r){let i=new tp(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,n=>{try{t(this.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),this.manager.itemError(e)}},n,r)}parseNodes(e){let t={};if(e!==void 0){for(let n of e){let{uuid:e,type:r}=n;t[e]=this.createNodeFromType(r),t[e].uuid=e}let n={nodes:t,textures:this.textures};for(let r of e)r.meta=n,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){let t=this.createNodeFromType(e.type);return t.uuid=e.uuid,e.meta={nodes:this.parseNodes(e.nodes),textures:this.textures},t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error(`THREE.NodeLoader: Node type not found:`,e),G()):B(new this.nodes[e])}},FE=class extends Dp{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){let t=super.parse(e),n=this.nodes,r=e.inputNodes;for(let e in r)t[e]=n[r[e]];return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){let t=this.nodeMaterials[e];return t===void 0?super.createMaterialFromType(e):new t}},IE=class extends jp{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;let n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){let n=new PE;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){let n={};if(e!==void 0){let r=this.parseNodes(this._nodesJSON,t),i=new FE;i.setTextures(t),i.setNodes(r),i.setNodeMaterials(this.nodeMaterials);for(let t=0,r=e.length;t<r;t++){let r=e[t];n[r.uuid]=i.parse(r)}}return n}},LE=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},RE=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},zE=class{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}},BE=class extends zE{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}},VE=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}},HE=0,UE=class{constructor(e=null){this.id=HE++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},WE=class extends t_{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}},GE=(e,t)=>B(new WE(e,t)),KE=class extends R{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.code=e,this.language=n,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},qE=V(KE),JE=(e,t)=>qE(e,t,`js`),YE=(e,t)=>qE(e,t,`wgsl`),XE=(e,t)=>qE(e,t,`glsl`),ZE=class extends KE{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+`
`,t===`property`?o:e.format(`${o}()`,i,t)}},QE=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=B(new ZE(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},$E=(e,t)=>QE(e,t,`glsl`),eD=(e,t)=>QE(e,t,`wgsl`),tD=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}},nD=class extends tD{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},rD=class extends tD{constructor(e,t=new A){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},iD=class extends tD{constructor(e,t=new M){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},aD=class extends tD{constructor(e,t=new Fn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},oD=class extends tD{constructor(e,t=new P){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},sD=class extends tD{constructor(e,t=new j){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},cD=class extends tD{constructor(e,t=new N){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},lD=class extends nD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},uD=class extends rD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},dD=class extends iD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},fD=class extends aD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},pD=class extends oD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},mD=class extends sD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},hD=class extends cD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}},gD=class extends R{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}add(e){return this.nodes.push(e),this}If(e,t){return this._currentCond=hy(e,new Sg(t)),this.add(this._currentCond)}ElseIf(e,t){let n=hy(e,new Sg(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new Sg(e),this}build(e,...t){let n=Dg();Eg(this);for(let t of this.nodes)t.build(e,`void`);return Eg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`TSL.StackNode: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`TSL.StackNode: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}},_D=V(gD),vD=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},yD=4,bD=[.125,.215,.35,.446,.526,.582],xD=20,SD=new Ba(-1,1,1,-1,0,1),CD=new pa(90,1),wD=new P,TD=null,ED=0,DD=0,OD=(1+Math.sqrt(5))/2,kD=1/OD,AD=[new M(-OD,kD,0),new M(OD,kD,0),new M(-kD,0,OD),new M(kD,0,OD),new M(0,OD,-kD),new M(0,OD,kD),new M(-1,1,-1),new M(1,1,-1),new M(-1,1,1),new M(1,1,1)],jD=[3,1,5,0,4,2],MD=WT(ub(),lb(`faceIndex`)).normalize(),ND=Y(MD.x,MD.y.negate(),MD.z),PD=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,n=.1,r=100){TD=this._renderer.getRenderTarget(),ED=this._renderer.getActiveCubeFace(),DD=this._renderer.getActiveMipmapLevel(),this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=BD(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=VD(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=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(TD,ED,DD),e.scissorTest=!1,LD(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),TD=this._renderer.getRenderTarget(),ED=this._renderer.getActiveCubeFace(),DD=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:h,minFilter:h,generateMipmaps:!1,type:D,format:oe,colorSpace:ut},r=ID(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ID(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=FD(r)),this._blurMaterial=zD(r,e,t)}return r}async _compileMaterial(e){let t=new Ji(this._lodPlanes[0],e);await this._renderer.compile(t,SD)}_sceneToCubeUV(e,t,n,r){let i=CD;i.near=t,i.far=n;let a=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],s=this._renderer,c=s.autoClear;s.getClearColor(wD),s.autoClear=!1;let l=this._backgroundBox;if(l===null){let e=new fi({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1});l=new Ji(new Zi,e)}let u=!1,d=e.background;d?d.isColor&&(l.material.color.copy(d),e.background=null,u=!0):(l.material.color.copy(wD),u=!0),s.setRenderTarget(r),s.clear(),u&&s.render(l,i);for(let t=0;t<6;t++){let n=t%3;n===0?(i.up.set(0,a[t],0),i.lookAt(o[t],0,0)):n===1?(i.up.set(0,0,a[t]),i.lookAt(0,o[t],0)):(i.up.set(0,a[t],0),i.lookAt(0,0,o[t]));let c=this._cubeSize;LD(r,n*c,t>2?c:0,c,c),s.render(e,i)}s.autoClear=c,e.background=d}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=BD(e)):this._equirectMaterial===null&&(this._equirectMaterial=VD(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;LD(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,SD)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=AD[(r-t-1)%AD.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*xD-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):xD;m>xD&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${xD}`);let h=[],g=0;for(let e=0;e<xD;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=h,u.latitudinal.value=+(a===`latitudinal`),o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r];LD(t,3*v*(r>_-yD?r-_+yD:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,SD)}};function FD(e){let t=[],n=[],r=[],i=[],a=e,o=e-yD+1+bD.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-yD?c=bD[s-e+yD-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=new Float32Array(108),m=new Float32Array(72),h=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=jD[e];p.set(r,18*i),m.set(f,12*i);let a=[i,i,i,i,i,i];h.set(a,6*i)}let g=new Ii;g.setAttribute(`position`,new bi(p,3)),g.setAttribute(`uv`,new bi(m,2)),g.setAttribute(`faceIndex`,new bi(h,1)),t.push(g),i.push(new Ji(g,null)),a>yD&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function ID(e,t,n){let r=new In(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function LD(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function RD(e){let t=new tw;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function zD(e,t,n){let r=Sx(Array(xD).fill(0)),i=Z(new M(0,1,0)),a=Z(0),o=G(xD),s=Z(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:ND,dTheta:a,samples:Z(1),envMap:gb(null),mipInt:Z(0),CUBEUV_TEXEL_WIDTH:G(1/t),CUBEUV_TEXEL_HEIGHT:G(1/n),CUBEUV_MAX_MIP:G(e)},l=RD(`blur`);return l.uniforms=c,l.fragmentNode=JT({...c,latitudinal:s.equal(1)}),l}function BD(e){let t=RD(`cubemap`);return t.fragmentNode=_x(e,ND),t}function VD(e){let t=RD(`equirect`);return t.fragmentNode=gb(e,hw(ND),0),t}var HD=0,UD=class{constructor(e=``,t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=HD++}},WD=new WeakMap,GD=new Map([[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),KD=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),qD=e=>(e=Number(e),e+(e%1?``:`.0`)),JD=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:``},this.chaining=[],this.stack=_D(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new UE,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=WD.get(this.renderer);return e===void 0&&(e=new vD,WD.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new In(e,t,n)}createCubeRenderTarget(e,t){return new gw(e,t)}createPMREMGenerator(){return new PD(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){let n=this.getBindGroupsCache(),r=[],i=!0;for(let e of t)r.push(e),i&&=e.groupNode.shared!==!0;let a;return i?(a=n.get(r),a===void 0&&(a=new UD(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new UD(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of Ph)for(let r in n[e]){let i=n[e][r];(t[r]||(t[r]=[])).push(...i)}e=[];for(let n in t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(let e of this.nodes){let t=e.getUpdateType(),n=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==L.NONE&&this.updateNodes.push(e.getSelf()),n!==L.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==L.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===1006||e.magFilter===1007||e.magFilter===1005||e.magFilter===1008||e.minFilter===1006||e.minFilter===1007||e.minFilter===1005||e.minFilter===1008}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error(`NodeBuilder: Invalid node chaining!`)}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new UE(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn(`Abstract function.`)}getInstanceIndex(){console.warn(`Abstract function.`)}getDrawIndex(){console.warn(`Abstract function.`)}getFrontFacing(){console.warn(`Abstract function.`)}getFragCoord(){console.warn(`Abstract function.`)}isFlipY(){return!1}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn(`Abstract function.`)}generateTextureLod(){console.warn(`Abstract function.`)}generateConst(e,t=null){if(t===null&&(e===`float`||e===`int`||e===`uint`?t=0:e===`bool`?t=!1:e===`color`?t=new P:e===`vec2`?t=new A:e===`vec3`?t=new M:e===`vec4`&&(t=new Fn)),e===`float`)return qD(t);if(e===`int`)return`${Math.round(t)}`;if(e===`uint`)return t>=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${qD(t.r)}, ${qD(t.g)}, ${qD(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new LE(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===1013)return`int`;if(t===1014)return`uint`}return`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=GD.get(e);return(t===`float`?``:t[0])+n}getTypeFromArray(e){return KD.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof Oi)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}addStack(){return this.stack=_D(this.stack),this.stacks.push(Dg()||this.stack),Eg(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,Eg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t){let n=this.getDataFromNode(e),r=n.bufferAttribute;return r===void 0&&(r=new LE(`nodeAttribute`+ this.uniforms.index++,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r),r}getStructTypeFromNode(e,t=this.shaderStage){let n=this.getDataFromNode(e,t);return n.structType===void 0&&(e.name=`StructType${this.structs.index++}`,this.structs[t].push(e),n.structType=e),e}getUniformFromNode(e,t,n=this.shaderStage,r=null){r===`in`&&(console.warn(`NodeBuilder: "in" is a reserved word, using "inValue" instead.`,e,r),e.name=`inValue`,r=e.name);let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new RE(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){let i=this.getDataFromNode(e,r),a=i.variable;if(a===void 0){let e=this.vars[r]||(this.vars[r]=[]);t===null&&(t=`nodeVar`+e.length),a=new zE(t,n),e.push(a),i.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){let r=this.getDataFromNode(e,`any`),i=r.varying;if(i===void 0){let e=this.varyings,a=e.length;t===null&&(t=`nodeVarying`+a),i=new BE(t,n),e.push(i),r.varying=i}return i}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new VE(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`;
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){let t=new ZE,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new WE(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.cache,a=this.buildStage,o=this.stack,s={code:``};this.flow=s,this.vars={},this.cache=new UE,this.stack=_D();for(let n of Nh)this.setBuildStage(n),s.result=e.build(this,t);return s.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=i,this.stack=o,this.setBuildStage(a),s}getFunctionOperator(){return null}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.shaderStage;this.setShaderStage(e);let a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result};\n`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(i),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn(`Abstract function.`)}getVaryings(){console.warn(`Abstract function.`)}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t=``,n=this.vars[e];if(n!==void 0)for(let e of n)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+`
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn(`Abstract function.`)}build(){let{object:e,material:t,renderer:n}=this;if(t!==null){let e=n.nodes.library.fromMaterial(t);e===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new tw),e.build(this)}else this.addFlow(`compute`,e);for(let e of Nh){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.vertex);for(let t of Ph){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t===`float`||t===`int`||t===`uint`)return new lD(e);if(t===`vec2`||t===`ivec2`||t===`uvec2`)return new uD(e);if(t===`vec3`||t===`ivec3`||t===`uvec3`)return new dD(e);if(t===`vec4`||t===`ivec4`||t===`uvec4`)return new fD(e);if(t===`color`)return new pD(e);if(t===`mat3`)return new mD(e);if(t===`mat4`)return new hD(e);throw Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e=`NodeMaterial`){throw Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&i===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?this.format(`${e}.${`xyz`.slice(0,i)}`,this.getTypeFromLength(i,this.getComponentType(t)),n):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${n} - Node System\n`}},YD=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===L.FRAME){let{frameMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&t.set(n,this.frameId)}else if(t===L.RENDER){let{renderMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&t.set(n,this.renderId)}else t===L.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===L.FRAME){let{frameMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&t.set(n,this.frameId)}else if(t===L.RENDER){let{renderMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&t.set(n,this.renderId)}else t===L.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===L.FRAME){let{frameMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.frameId&&e.update(this)!==!1&&t.set(n,this.frameId)}else if(t===L.RENDER){let{renderMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.renderId&&e.update(this)!==!1&&t.set(n,this.renderId)}else t===L.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},XD=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};XD.isNodeFunctionInput=!0;var ZD=class extends R{static get type(){return`StructTypeNode`}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}},QD=class extends R{static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);let t=this.members,n=[];for(let r=0;r<t.length;r++)n.push(t[r].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new ZD(n)).name}generate(e,t){let n=e.getOutputStructName(),r=this.members,i=n===``?``:n+`.`;for(let n=0;n<r.length;n++){let a=r[n].build(e,t);e.addLineFlowCode(`${i}m${n} = ${a}`,this)}return n}},$D=V(QD);function eO(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var tO=class extends QD{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){return nO({...this.outputNodes,...e.outputNodes})}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=eO(i,e);r[n]=X(t[e])}return this.members=r,super.setup(e)}},nO=V(tO),rO=class extends R{static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let o=a.inputs;if(t.length===o.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=o[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}},iO=V(rO),aO=e=>(...t)=>iO(e,...t),oO=class e extends e_{static get type(){return`TimerNode`}constructor(t=e.LOCAL,n=1,r=0){super(r),this.scope=t,this.scale=n,this.updateType=L.FRAME}update(t){let n=this.scope,r=this.scale;n===e.LOCAL?this.value+=t.deltaTime*r:n===e.DELTA?this.value=t.deltaTime*r:n===e.FRAME?this.value=t.frameId:this.value=t.time*r}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}};oO.LOCAL=`local`,oO.GLOBAL=`global`,oO.DELTA=`delta`,oO.FRAME=`frame`;var sO=(e,t=0)=>B(new oO(oO.LOCAL,e,t)),cO=(e,t=0)=>B(new oO(oO.GLOBAL,e,t)),lO=(e,t=0)=>B(new oO(oO.DELTA,e,t)),uO=H(oO,oO.FRAME).toUint(),dO=class e extends R{static get type(){return`OscNode`}constructor(t=e.SINE,n=sO()){super(),this.method=t,this.timeNode=n}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){let t=this.method,n=B(this.timeNode),r=null;return t===e.SINE?r=n.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):t===e.SQUARE?r=n.fract().round():t===e.TRIANGLE?r=n.add(.5).fract().mul(2).sub(1).abs():t===e.SAWTOOTH&&(r=n.fract()),r}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};dO.SINE=`sine`,dO.SQUARE=`square`,dO.TRIANGLE=`triangle`,dO.SAWTOOTH=`sawtooth`;var fO=V(dO,dO.SINE),pO=V(dO,dO.SQUARE),mO=V(dO,dO.TRIANGLE),hO=V(dO,dO.SAWTOOTH),gO=class extends R{static get type(){return`SpriteSheetUVNode`}constructor(e,t=ub(),n=G(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=J(o,s);return t.add(l).mul(c)}},_O=V(gO),vO=class extends Lh{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.bufferObject===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.bufferObject===!0&&r!==!0?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},yO=V(vO),bO=class extends R{static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=G(1),i=Kb,a=nx){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(Y(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value;return L_(gb(u,s).mul(o.x),gb(d,c).mul(o.y),gb(f,l).mul(o.z))}},xO=V(bO),SO=(...e)=>xO(...e),CO=new Sa,wO=new M,TO=new M,EO=new M,DO=new N,OO=new M(0,0,-1),kO=new Fn,AO=new M,jO=new M,MO=new Fn,NO=new A,PO=new In,FO=EC.flipX(),IO=!1,LO=class extends hb{static get type(){return`ReflectorNode`}constructor(e={}){super(PO.texture,FO);let{target:t=new Wr,resolution:n=1,generateMipmaps:r=!1,bounces:i=!0}=e;this.target=t,this.resolution=n,this.generateMipmaps=r,this.bounces=i,this.updateBeforeType=i?L.RENDER:L.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(NO),e.setSize(Math.round(NO.width*n),Math.round(NO.height*n))}setup(e){return this._updateResolution(PO,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new In(0,0,{type:D}),this.generateMipmaps===!0&&(t.texture.minFilter=y,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&IO)return!1;IO=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);if(r.getDrawingBufferSize(NO),this._updateResolution(s,r),TO.setFromMatrixPosition(a.matrixWorld),EO.setFromMatrixPosition(n.matrixWorld),DO.extractRotation(a.matrixWorld),wO.set(0,0,1),wO.applyMatrix4(DO),AO.subVectors(TO,EO),AO.dot(wO)>0)return;AO.reflect(wO).negate(),AO.add(TO),DO.extractRotation(n.matrixWorld),OO.set(0,0,-1),OO.applyMatrix4(DO),OO.add(EO),jO.subVectors(TO,OO),jO.reflect(wO).negate(),jO.add(TO),o.coordinateSystem=n.coordinateSystem,o.position.copy(AO),o.up.set(0,1,0),o.up.applyMatrix4(DO),o.up.reflect(wO),o.lookAt(jO),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),CO.setFromNormalAndCoplanarPoint(wO,TO),CO.applyMatrix4(o.matrixWorldInverse),kO.set(CO.normal.x,CO.normal.y,CO.normal.z,CO.constant);let c=o.projectionMatrix;MO.x=(Math.sign(kO.x)+c.elements[8])/c.elements[0],MO.y=(Math.sign(kO.y)+c.elements[9])/c.elements[5],MO.z=-1,MO.w=(1+c.elements[10])/c.elements[14],kO.multiplyScalar(1/kO.dot(MO)),c.elements[2]=kO.x,c.elements[6]=kO.y,c.elements[10]=kO.z-0,c.elements[14]=kO.w,this.value=s.texture,i.visible=!1;let l=r.getRenderTarget(),u=r.getMRT();r.setMRT(null),r.setRenderTarget(s),r.render(t,o),r.setMRT(u),r.setRenderTarget(l),i.visible=!0,IO=!1}},RO=e=>B(new LO(e)),zO=new Ba(-1,1,1,-1,0,1),BO=new class extends Ii{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new F([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new F(t,2))}},VO=class extends Ji{constructor(e=null){super(BO,e),this.camera=zO,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,zO)}render(e){e.render(this,zO)}},HO=new A,UO=class extends hb{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:D}){let i=new In(t,n,r);super(i.texture,ub()),this.node=e,this.width=t,this.height=n,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new VO(new tw),this.updateBeforeType=L.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();let t=e.getSize(HO);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new hb(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},WO=(e,...t)=>B(new UO(B(e),...t)),GO=(e,...t)=>e.isTextureNode?e:WO(e,...t),KO=class extends cb{static get type(){return`VertexColorNode`}constructor(e=0){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new Fn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},qO=(...e)=>B(new KO(...e)),JO=class extends R{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}},YO=H(JO),XO=class e extends R{static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=Ex(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=Ex(`backgroundIntensity`,`float`,r):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};XO.BACKGROUND_BLURRINESS=`backgroundBlurriness`,XO.BACKGROUND_INTENSITY=`backgroundIntensity`;var ZO=H(XO,XO.BACKGROUND_BLURRINESS),QO=H(XO,XO.BACKGROUND_INTENSITY),$O={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},ek={WriteOnly:`write-only`,ReadOnly:`read-only`},tk=class extends vx{static get type(){return`StorageBufferNode`}constructor(e,t,n=0){super(e,t,n),this.isStorageBufferNode=!0,this.access=$O.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=n,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return`storageBuffer`}element(e){return yO(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess($O.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable(`storageBuffer`))return super.generate(e);let t=this.getNodeType(e);this._attribute===null&&(this._attribute=Hy(this.value),this._varying=Cy(this._attribute));let n=this._varying.build(e,t);return e.registerTransform(n,this._attribute),n}},nk=(e,t,n)=>B(new tk(e,t,n)),rk=(e,t,n)=>B(new tk(e,t,n).setBufferObject(!0)),ik=class extends hb{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=ek.WriteOnly}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadOnly(){return this.setAccess(ek.ReadOnly)}toWriteOnly(){return this.setAccess(ek.WriteOnly)}generateStore(e){let{uvNode:t,storeNode:n}=e.getNodeProperties(this),r=super.generate(e,`property`),i=t.build(e,`uvec2`),a=n.build(e,`vec4`),o=e.generateTextureStore(e,r,i,a);e.addLineFlowCode(o,this)}},ak=V(ik),ok=(e,t,n)=>{let r=ak(e,t,n);return n!==null&&r.append(),r},sk=class extends Tx{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},ck=(e,t,n)=>B(new sk(e,t,n)),lk=class extends zh{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}},uk=V(lk),dk=null,fk=class extends LC{static get type(){return`ViewportSharedTextureNode`}constructor(e=EC,t=null){dk===null&&(dk=new Tu),super(e,t,dk)}updateReference(){return this}},pk=V(fk),mk=new A,hk=class extends hb{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},gk=class extends hk{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},_k=class e extends zh{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new ho;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new In(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:D,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this.updateBeforeType=L.FRAME,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Z(0),this._cameraFar=Z(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(this._textureNodes[e]=t=B(new gk(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=B(new gk(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=qC(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=WC(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();let i=t.getSize(mk);this.setSize(i.width,i.height);let a=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(let e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};_k.COLOR=`color`,_k.DEPTH=`depth`;var vk=(e,t,n)=>B(new _k(_k.COLOR,e,t,n)),yk=(e,t)=>B(new hk(e,t)),bk=(e,t)=>B(new _k(_k.DEPTH,e,t)),xk=new VO,Sk=new VO,Ck=class extends zh{static get type(){return`GaussianBlurNode`}constructor(e,t=null,n=2){super(`vec4`),this.textureNode=e,this.directionNode=t,this.sigma=n,this._invSize=Z(new A),this._passDirection=Z(new A),this._horizontalRT=new In,this._horizontalRT.texture.name=`GaussianBlurNode.horizontal`,this._verticalRT=new In,this._verticalRT.texture.name=`GaussianBlurNode.vertical`,this._textureNode=yk(this,this._verticalRT.texture),this.updateBeforeType=L.RENDER,this.resolution=new A(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){let{renderer:t}=e,n=this.textureNode,r=n.value,i=t.getRenderTarget(),a=t.getMRT(),o=n.value;xk.material=this._material,Sk.material=this._material,this.setSize(r.image.width,r.image.height);let s=r.type;this._horizontalRT.texture.type=s,this._verticalRT.texture.type=s,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),xk.render(t),n.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),Sk.render(t),t.setRenderTarget(i),t.setMRT(a),n.value=o}getTextureNode(){return this._textureNode}setup(e){let t=this.textureNode;if(t.isTextureNode!==!0)return console.error(`GaussianBlurNode requires a TextureNode.`),X();let n=t.uvNode||ub(),r=J(this.directionNode||1),i=e=>t.uv(e),a=U(()=>{let e=3+2*this.sigma,t=this._getCoefficients(e),a=this._invSize,o=r.mul(this._passDirection),s=G(t[0]).toVar(),c=X(i(n).mul(s)).toVar();for(let r=1;r<e;r++){let e=G(r),l=G(t[r]),u=J(o.mul(a.mul(e))).toVar(),d=X(i(n.add(u))),f=X(i(n.sub(u)));c.addAssign(d.add(f).mul(l)),s.addAssign(z_(2,l))}return c.div(s)}),o=this._material||=new tw;o.fragmentNode=a().context(e.getSharedContext()),o.name=`Gaussian_blur`,o.needsUpdate=!0;let s=e.getNodeProperties(this);return s.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){let t=[];for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(e*e))/e);return t}},wk=(e,t,n)=>B(new Ck(GO(e),t,n)),Tk=new A,Ek=new VO,Dk=class extends zh{static get type(){return`AfterImageNode`}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=gb(),this.damp=Z(t),this._compRT=new In,this._compRT.texture.name=`AfterImageNode.comp`,this._oldRT=new In,this._oldRT.texture.name=`AfterImageNode.old`,this._textureNode=yk(this,this._compRT.texture),this.updateBeforeType=L.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){let{renderer:t}=e,n=this.textureNode,r=n.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(Tk),this.setSize(Tk.x,Tk.y);let i=t.getRenderTarget(),a=n.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),Ek.render(t);let o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(i),n.value=a}setup(e){let t=this.textureNode,n=this.textureNodeOld,r=t.uvNode||ub();n.uvNode=r;let i=e=>t.uv(e),a=U(([e,t])=>{let n=G(t).toVar();return Gv(jv(X(e).toVar().sub(n)),0)}),o=U(()=>{let e=X(n),t=X(i(r));return e.mulAssign(this.damp.mul(a(e,.1))),Gv(t,e)}),s=this._materialComposed||=new tw;s.name=`AfterImage`,s.fragmentNode=o(),Ek.material=s;let c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}},Ok=(e,t)=>B(new Dk(GO(e),t)),kk=U(([e])=>Pk(e.rgb)),Ak=U(([e,t=G(1)])=>t.mix(Pk(e.rgb),e.rgb)),jk=U(([e,t=G(1)])=>{let n=L_(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return oy(e.rgb,r,i)}),Mk=U(([e,t=G(1)])=>{let n=Y(.57735,.57735,.57735),r=t.cos();return Y(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(Zv(n,e.rgb).mul(r.oneMinus())))))}),Nk=new M,Pk=(e,t=Y(...Tn.getLuminanceCoefficients(Nk)))=>Zv(e,t),Fk=(e,t)=>oy(Y(0),e,Pk(e).sub(t).max(0)),Ik=new VO,Lk=class extends zh{static get type(){return`AnamorphicNode`}constructor(e,t,n,r){super(`vec4`),this.textureNode=e,this.tresholdNode=t,this.scaleNode=n,this.colorNode=Y(.1,0,1),this.samples=r,this.resolution=new A(1,1),this._renderTarget=new In,this._renderTarget.texture.name=`anamorphic`,this._invSize=Z(new A),this._textureNode=yk(this,this._renderTarget.texture),this.updateBeforeType=L.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){let{renderer:t}=e,n=this.textureNode,r=n.value;this._renderTarget.texture.type=r.type;let i=t.getRenderTarget(),a=n.value;Ik.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),Ik.render(t),t.setRenderTarget(i),n.value=a}setup(e){let t=this.textureNode,n=t.uvNode||ub(),r=e=>t.uv(e),i=U(()=>{let e=this.samples,t=Math.floor(e/2),i=Y(0).toVar();return rC({start:-t,end:t},({i:e})=>{let a=G(e).abs().div(t).oneMinus(),o=Fk(r(J(n.x.add(this._invSize.x.mul(e).mul(this.scaleNode)),n.y)),this.tresholdNode).mul(a);i.addAssign(o)}),i.mul(this.colorNode)}),a=this._material||=new tw;a.name=`Anamorphic`,a.fragmentNode=i();let o=e.getNodeProperties(this);return o.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}},Rk=(e,t=.9,n=3,r=32)=>B(new Lk(GO(e),B(t),B(n),r)),zk=class extends zh{static get type(){return`SobelOperatorNode`}constructor(e){super(),this.textureNode=e,this.updateBeforeType=L.RENDER,this._invSize=Z(new A)}updateBefore(){let e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){let{textureNode:e}=this,t=e.uvNode||ub(),n=t=>e.uv(t);return U(()=>{let e=this._invSize,r=Vg(-1,-2,-1,0,0,0,1,2,1),i=Vg(-1,0,1,-2,0,2,-1,0,1),a=Pk(n(t.add(e.mul(J(-1,-1)))).xyz),o=Pk(n(t.add(e.mul(J(-1,0)))).xyz),s=Pk(n(t.add(e.mul(J(-1,1)))).xyz),c=Pk(n(t.add(e.mul(J(0,-1)))).xyz),l=Pk(n(t.add(e.mul(J(0,0)))).xyz),u=Pk(n(t.add(e.mul(J(0,1)))).xyz),d=Pk(n(t.add(e.mul(J(1,-1)))).xyz),f=Pk(n(t.add(e.mul(J(1,0)))).xyz),p=Pk(n(t.add(e.mul(J(1,1)))).xyz),m=L_(r[0][0].mul(a),r[1][0].mul(c),r[2][0].mul(d),r[0][1].mul(o),r[1][1].mul(l),r[2][1].mul(f),r[0][2].mul(s),r[1][2].mul(u),r[2][2].mul(p)),h=L_(i[0][0].mul(a),i[1][0].mul(c),i[2][0].mul(d),i[0][1].mul(o),i[1][1].mul(l),i[2][1].mul(f),i[0][2].mul(s),i[1][2].mul(u),i[2][2].mul(p));return X(Y(m.mul(m).add(h.mul(h)).sqrt()),1)})()}},Bk=e=>B(new zk(GO(e))),Vk=class extends zh{static get type(){return`DepthOfFieldNode`}constructor(e,t,n,r,i){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=n,this.apertureNode=r,this.maxblurNode=i,this._aspect=Z(0),this.updateBeforeType=L.RENDER}updateBefore(){let e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){let e=this.textureNode,t=e.uvNode||ub(),n=t=>e.uv(t);return U(()=>{let e=J(1,this._aspect),r=J(sy(this.focusNode.add(this.viewZNode).mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),i=r.mul(.9),a=r.mul(.7),o=r.mul(.4),s=X(0);return s=s.add(n(t)),s=s.add(n(t.add(J(0,.4).mul(e).mul(r)))),s=s.add(n(t.add(J(.15,.37).mul(e).mul(r)))),s=s.add(n(t.add(J(.29,.29).mul(e).mul(r)))),s=s.add(n(t.add(J(-.37,.15).mul(e).mul(r)))),s=s.add(n(t.add(J(.4,0).mul(e).mul(r)))),s=s.add(n(t.add(J(.37,-.15).mul(e).mul(r)))),s=s.add(n(t.add(J(.29,-.29).mul(e).mul(r)))),s=s.add(n(t.add(J(-.15,-.37).mul(e).mul(r)))),s=s.add(n(t.add(J(0,-.4).mul(e).mul(r)))),s=s.add(n(t.add(J(-.15,.37).mul(e).mul(r)))),s=s.add(n(t.add(J(-.29,.29).mul(e).mul(r)))),s=s.add(n(t.add(J(.37,.15).mul(e).mul(r)))),s=s.add(n(t.add(J(-.4,0).mul(e).mul(r)))),s=s.add(n(t.add(J(-.37,-.15).mul(e).mul(r)))),s=s.add(n(t.add(J(-.29,-.29).mul(e).mul(r)))),s=s.add(n(t.add(J(.15,-.37).mul(e).mul(r)))),s=s.add(n(t.add(J(.15,.37).mul(e).mul(i)))),s=s.add(n(t.add(J(-.37,.15).mul(e).mul(i)))),s=s.add(n(t.add(J(.37,-.15).mul(e).mul(i)))),s=s.add(n(t.add(J(-.15,-.37).mul(e).mul(i)))),s=s.add(n(t.add(J(-.15,.37).mul(e).mul(i)))),s=s.add(n(t.add(J(.37,.15).mul(e).mul(i)))),s=s.add(n(t.add(J(-.37,-.15).mul(e).mul(i)))),s=s.add(n(t.add(J(.15,-.37).mul(e).mul(i)))),s=s.add(n(t.add(J(.29,.29).mul(e).mul(a)))),s=s.add(n(t.add(J(.4,0).mul(e).mul(a)))),s=s.add(n(t.add(J(.29,-.29).mul(e).mul(a)))),s=s.add(n(t.add(J(0,-.4).mul(e).mul(a)))),s=s.add(n(t.add(J(-.29,.29).mul(e).mul(a)))),s=s.add(n(t.add(J(-.4,0).mul(e).mul(a)))),s=s.add(n(t.add(J(-.29,-.29).mul(e).mul(a)))),s=s.add(n(t.add(J(0,.4).mul(e).mul(a)))),s=s.add(n(t.add(J(.29,.29).mul(e).mul(o)))),s=s.add(n(t.add(J(.4,0).mul(e).mul(o)))),s=s.add(n(t.add(J(.29,-.29).mul(e).mul(o)))),s=s.add(n(t.add(J(0,-.4).mul(e).mul(o)))),s=s.add(n(t.add(J(-.29,.29).mul(e).mul(o)))),s=s.add(n(t.add(J(-.4,0).mul(e).mul(o)))),s=s.add(n(t.add(J(-.29,-.29).mul(e).mul(o)))),s=s.add(n(t.add(J(0,.4).mul(e).mul(o)))),s=s.div(41),s.a=1,X(s)})()}},Hk=(e,t,n=1,r=.025,i=1)=>B(new Vk(GO(e),B(t),B(n),B(r),B(i))),Uk=class extends zh{static get type(){return`DotScreenNode`}constructor(e,t=new A(.5,.5),n=1.57,r=1){super(`vec4`),this.inputNode=e,this.center=Z(t),this.angle=Z(n),this.scale=Z(r)}setup(){let e=this.inputNode,t=U(()=>{let e=wv(this.angle),t=Tv(this.angle),n=ub().mul(DC).sub(this.center),r=J(t.mul(n.x).sub(e.mul(n.y)),e.mul(n.x).add(t.mul(n.y))).mul(this.scale);return wv(r.x).mul(wv(r.y)).mul(4)});return U(()=>{let n=e;return X(Y(L_(n.r,n.g,n.b).div(3).mul(10).sub(5).add(t())),n.a)})()}},Wk=(e,t,n,r)=>B(new Uk(B(e),t,n,r)),Gk=class extends zh{static get type(){return`RGBShiftNode`}constructor(e,t=.005,n=0){super(`vec4`),this.textureNode=e,this.amount=Z(t),this.angle=Z(n)}setup(){let{textureNode:e}=this,t=e.uvNode||ub(),n=t=>e.uv(t);return U(()=>{let e=J(Tv(this.angle),wv(this.angle)).mul(this.amount),r=n(t.add(e)),i=n(t),a=n(t.sub(e));return X(r.r,i.g,a.b,i.a)})()}},Kk=(e,t,n)=>B(new Gk(GO(e),t,n)),qk=class extends zh{static get type(){return`FilmNode`}constructor(e,t=null,n=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=n}setup(){let e=this.uvNode||ub();return U(()=>{let t=this.inputNode.rgb,n=fy(Cv(e.add(sO()))),r=t.add(t.mul(sy(n.add(.1),0,1)));return this.intensityNode!==null&&(r=oy(t,r,this.intensityNode)),X(r,this.inputNode.a)})()}},Jk=V(qk),Yk=class extends zh{static get type(){return`Lut3DNode`}constructor(e,t,n,r){super(),this.inputNode=e,this.lutNode=t,this.size=Z(n),this.intensityNode=r}setup(){let{inputNode:e,lutNode:t}=this,n=e=>t.uv(e);return U(()=>{let t=e,r=G(1).div(this.size);return X(oy(t,X(n(Y(G(.5).div(this.size)).add(t.rgb.mul(G(1).sub(r)))).rgb,t.a),this.intensityNode))})()}},Xk=(e,t,n,r)=>B(new Yk(B(e),B(t),n,B(r))),Zk=new VO,Qk=new P,$k=new A,eA=class extends zh{static get type(){return`GTAONode`}constructor(e,t,n){super(),this.depthNode=e,this.normalNode=t,this.radius=Z(.25),this.resolution=Z(new A),this.thickness=Z(1),this.distanceExponent=Z(1),this.distanceFallOff=Z(1),this.scale=Z(1),this.noiseNode=gb(tA()),this.cameraProjectionMatrix=Z(n.projectionMatrix),this.cameraProjectionMatrixInverse=Z(n.projectionMatrixInverse),this.SAMPLES=Z(16),this._aoRenderTarget=new In,this._aoRenderTarget.texture.name=`GTAONode.AO`,this._material=null,this._textureNode=yk(this,this._aoRenderTarget.texture),this.updateBeforeType=L.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){let{renderer:t}=e,n=t.getDrawingBufferSize($k),r=t.getRenderTarget(),i=t.getMRT();t.getClearColor(Qk);let a=t.getClearAlpha();Zk.material=this._material,this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),Zk.render(t),t.setRenderTarget(r),t.setMRT(i),t.setClearColor(Qk,a)}setup(e){let t=ub(),n=e=>this.depthNode.uv(e).x,r=e=>this.noiseNode.uv(e),i=U(([e])=>{let t=this.cameraProjectionMatrix.mul(X(e,1)),r=t.xy.div(t.w).mul(.5).add(.5).toVar();r=J(r.x,r.y.oneMinus());let i=n(r);return Y(r,i)}),a=U(([e,t])=>{e=J(e.x,e.y.oneMinus()).mul(2).sub(1);let n=X(Y(e,t),1),r=X(this.cameraProjectionMatrixInverse.mul(n));return r.xyz.div(r.w)}),o=U(()=>{let e=n(t);e.greaterThanEqual(1).discard();let o=a(t,e),s=this.normalNode.rgb.normalize(),c=this.radius,l=fb(this.noiseNode,0),u=J(t.x,t.y.oneMinus());u=u.mul(this.resolution.div(l));let d=r(u),f=Y(d.xyz.mul(2).sub(1).xy,0).normalize(),p=Vg(f,Y(f.y.mul(-1),f.x,0),Y(0,0,1)),m=this.SAMPLES.lessThan(30).select(3,5),h=L_(this.SAMPLES,m.sub(1)).div(m),g=G(0).toVar();return rC({start:K(0),end:m,type:`int`,condition:`<`},({i:e})=>{let t=G(e).div(G(m)).mul(sv),n=X(Tv(t),wv(t),0,L_(.5,z_(.5,d.w)));n.xyz=Sv(p.mul(n.xyz));let r=Sv(o.xyz.negate()),l=Sv(Qv(n.xyz,r)),u=Qv(l,r),f=Sv(s.sub(l.mul(Zv(s,l)))),_=Qv(f,l),v=J(Zv(r,_),Zv(r,_.negate())).toVar();rC({end:h,type:`int`,name:`j`,condition:`<`},({j:e})=>{let t=n.xyz.mul(c).mul(n.w).mul($v(B_(G(e).add(1),G(h)),this.distanceExponent)),s=i(o.add(t)),l=a(s.xy,s.z).sub(o);W(Av(l.z).lessThan(this.thickness),()=>{let t=Zv(r,Sv(l));v.x.addAssign(Gv(0,z_(t.sub(v.x),oy(1,G(2).div(G(e).add(2)),this.distanceFallOff))))});let u=i(o.sub(t)),d=a(u.xy,u.z).sub(o);W(Av(d.z).lessThan(this.thickness),()=>{let t=Zv(r,Sv(d));v.y.addAssign(Gv(0,z_(t.sub(v.y),oy(1,G(2).div(G(e).add(2)),this.distanceFallOff))))})});let y=vv(R_(1,v.mul(v))),b=Zv(f,u),x=Zv(f,r),S=z_(.5,Ov(v.y).sub(Ov(v.x)).add(y.x.mul(v.x).sub(y.y.mul(v.y)))),C=z_(.5,R_(2,v.x.mul(v.x)).sub(v.y.mul(v.y))),w=b.mul(S).add(x.mul(C));g.addAssign(w)}),g.assign(sy(g.div(m),0,1)),g.assign($v(g,this.scale)),X(Y(g),1)}),s=this._material||=new tw;return s.fragmentNode=o().context(e.getSharedContext()),s.name=`GTAO`,s.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}};function tA(e=5){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=nA(t),r=n.length,i=new Uint8Array(r*4);for(let e=0;e<r;++e){let t=n[e],a=2*Math.PI*t/r,o=new M(Math.cos(a),Math.sin(a),0).normalize();i[e*4]=(o.x*.5+.5)*255,i[e*4+1]=(o.y*.5+.5)*255,i[e*4+2]=127,i[e*4+3]=255}let a=new Tl(i,t,t);return a.wrapS=s,a.wrapT=s,a.needsUpdate=!0,a}function nA(e){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,r=Array(n).fill(0),i=Math.floor(t/2),a=t-1;for(let e=1;e<=n;){if(i===-1&&a===t?(a=t-2,i=0):(a===t&&(a=0),i<0&&(i=t-1)),r[i*t+a]!==0){a-=2,i++;continue}else r[i*t+a]=e++;a++,i--}return r}var rA=(e,t,n)=>B(new eA(B(e),B(t),n)),iA=class extends zh{static get type(){return`DenoiseNode`}constructor(e,t,n,r,i){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.noiseNode=r,this.cameraProjectionMatrixInverse=Z(i.projectionMatrixInverse),this.lumaPhi=Z(5),this.depthPhi=Z(5),this.normalPhi=Z(5),this.radius=Z(5),this.index=Z(0),this._resolution=Z(new A),this._sampleVectors=Sx(aA(16,2,1)),this.updateBeforeType=L.RENDER}updateBefore(){let e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){let e=ub(),t=e=>this.textureNode.uv(e),n=e=>this.depthNode.uv(e).x,r=e=>this.normalNode.uv(e),i=e=>this.noiseNode.uv(e),a=U(([e,t])=>{e=J(e.x,e.y.oneMinus()).mul(2).sub(1);let n=X(Y(e,t),1),r=X(this.cameraProjectionMatrixInverse.mul(n));return r.xyz.div(r.w)}),o=U(([e,i,o,s])=>{let c=t(s),l=n(s),u=r(s).rgb.normalize(),d=c.rgb,f=a(s,l),p=$v(Gv(Zv(i,u).toVar(),0),this.normalPhi).toVar(),m=Av(Pk(d).sub(Pk(e))).toVar(),h=Gv(G(1).sub(m.div(this.lumaPhi)),0).toVar(),g=Av(Zv(o.sub(f),i)).toVar(),_=Gv(G(1).sub(g.div(this.depthPhi)),0),v=h.mul(_).mul(p);return X(d.mul(v),v)}),s=U(([e])=>{let s=n(e),c=r(e).rgb.normalize(),l=t(e);W(s.greaterThanEqual(1).or(Zv(c,c).equal(0)),()=>l);let u=Y(l.rgb),d=a(e,s),f=fb(this.noiseNode,0),p=J(e.x,e.y.oneMinus());p=p.mul(this._resolution.div(f));let m=i(p),h=J(wv(m.element(this.index.mod(4).mul(2).mul(sv))),Tv(m.element(this.index.mod(4).mul(2).mul(sv)))),g=Bg(h.x,h.y.negate(),h.x,h.y),_=G(1).toVar(),v=Y(l.rgb).toVar();return rC({start:K(0),end:K(16),type:`int`,condition:`<`},({i:t})=>{let n=this._sampleVectors.element(t).toVar(),r=g.mul(n.xy.mul(G(1).add(n.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),i=o(u,c,d,e.add(r).toVar());v.addAssign(i.xyz),_.addAssign(i.w)}),W(_.greaterThan(G(0)),()=>{v.divAssign(_)}),X(v,l.a)}).setLayout({name:`denoise`,type:`vec4`,inputs:[{name:`uv`,type:`vec2`}]});return U(()=>s(e))()}};function aA(e,t,n){let r=oA(e,t,n),i=[];for(let t=0;t<e;t++){let e=r[t];i.push(e)}return i}function oA(e,t,n){let r=[];for(let i=0;i<e;i++){let a=2*Math.PI*t*i/e,o=(i/(e-1))**n;r.push(new M(Math.cos(a),Math.sin(a),o))}return r}var sA=(e,t,n,r,i)=>B(new iA(GO(e),B(t),B(n),B(r),i)),cA=class extends zh{static get type(){return`FXAANode`}constructor(e){super(),this.textureNode=e,this.updateBeforeType=L.RENDER,this._invSize=Z(new A)}updateBefore(){let e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){let e=this.textureNode.bias(-100),t=e.uvNode||ub(),n=t=>e.uv(t),r=(t,n,r)=>e.uv(t.add(n.mul(r))),i=K(5),a=U(([e,t])=>{let n=X(t).toVar(),r=X(Av(X(e).toVar().sub(n))).toVar();return Gv(Gv(Gv(r.r,r.g),r.b),r.a)}),o=U(([e,t,o,s])=>{let c=n(e).toVar(),l=r(e,J(0,-1),t.xy).toVar(),u=r(e,J(1,0),t.xy).toVar(),d=r(e,J(0,1),t.xy).toVar(),f=r(e,J(-1,0),t.xy).toVar(),p=a(c,d).toVar(),m=a(c,l).toVar(),h=a(c,u).toVar(),g=a(c,f).toVar();W(Gv(p,Gv(m,Gv(h,g))).toVar().lessThan(o),()=>c);let _=R_(p.add(m),h.add(g)).toVar();_.mulAssign(s),W(Av(_).lessThan(.3),()=>{let n=J(h.greaterThan(g).select(1,-1).toVar(),m.greaterThan(p).select(1,-1).toVar()).toVar(),i=a(c,r(e,J(n.x,n.y),t.xy)).toVar(),o=a(c,r(e,J(n.x.negate(),n.y.negate()),t.xy)).toVar();_.assign(o.sub(i)),_.mulAssign(s),W(Av(_).lessThan(.3),()=>oy(c,d.add(l).add(u).add(f).mul(.25),.4))});let v=J().toVar();W(_.lessThanEqual(0),()=>{d.assign(f),l.assign(u),v.x.assign(0),v.y.assign(t.y)}).Else(()=>{v.x.assign(t.x),v.y.assign(0)});let y=a(c,d).toVar(),b=a(c,l).toVar();W(y.lessThanEqual(b),()=>{d.assign(l)});let x=K(0).toVar(),S=K(0).toVar(),C=G(0).toVar(),w=G(0).toVar(),T=J(e).toVar(),E=J(e).toVar(),D=K(0).toVar(),ee=K(0).toVar();rC(i,({i:t})=>{let r=t.add(1).toVar();W(x.equal(0),()=>{C.addAssign(r),T.assign(e.add(v.mul(C)));let i=n(T.xy),o=a(i,c).toVar(),s=a(i,d).toVar();W(o.greaterThan(s),()=>{x.assign(1)}),D.assign(t)}),W(S.equal(0),()=>{w.addAssign(r),E.assign(e.sub(v.mul(w)));let i=n(E.xy),o=a(i,c).toVar(),s=a(i,d).toVar();W(o.greaterThan(s),()=>{S.assign(1)}),ee.assign(t)}),W(x.equal(1).or(S.equal(1)),()=>{aC()})}),W(x.equal(0).and(S.equal(0)),()=>c);let O=G(1).toVar(),te=G(1).toVar();W(x.equal(1),()=>{O.assign(G(D).div(G(i.sub(1))))}),W(S.equal(1),()=>{te.assign(G(ee).div(G(i.sub(1))))});let ne=Wv(O,te);return ne.assign($v(ne,.5)),ne.assign(G(1).sub(ne)),oy(c,d,ne.mul(.5))}).setLayout({name:`FxaaPixelShader`,type:`vec4`,inputs:[{name:`uv`,type:`vec2`},{name:`fxaaQualityRcpFrame`,type:`vec2`},{name:`fxaaQualityEdgeThreshold`,type:`float`},{name:`fxaaQualityinvEdgeThreshold`,type:`float`}]});return U(()=>{let e=G(.2),n=G(1).div(e);return o(t,this._invSize,e,n)})()}},lA=e=>B(new cA(GO(e))),uA=new VO,dA=new P(0,0,0),fA=new P,pA=new A,mA=new A(1,0),hA=new A(0,1),gA=class extends zh{static get type(){return`BloomNode`}constructor(e,t=1,n=0,r=0){super(),this.inputNode=e,this.strength=Z(t),this.radius=Z(n),this.threshold=Z(r),this.smoothWidth=Z(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new In(1,1,{type:D}),this._renderTargetBright.texture.name=`UnrealBloomPass.bright`,this._renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this._nMips;e++){let t=new In(1,1,{type:D});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(t);let n=new In(1,1,{type:D});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this._renderTargetsVertical.push(n)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=gb(this._renderTargetBright.texture),this._textureNodeBlur0=gb(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=gb(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=gb(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=gb(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=gb(this._renderTargetsVertical[4].texture),this._textureOutput=yk(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=L.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this._renderTargetBright.setSize(n,r);for(let e=0;e<this._nMips;e++)this._renderTargetsHorizontal[e].setSize(n,r),this._renderTargetsVertical[e].setSize(n,r),this._separableBlurMaterials[e].invSize.value.set(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}updateBefore(e){let{renderer:t}=e,n=t.getDrawingBufferSize(pA);this.setSize(n.width,n.height);let r=t.getRenderTarget(),i=t.getMRT();t.getClearColor(fA);let a=t.getClearAlpha();this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(dA,0),t.setRenderTarget(this._renderTargetBright),uA.material=this._highPassFilterMaterial,uA.render(t);let o=this._renderTargetBright;for(let e=0;e<this._nMips;e++)uA.material=this._separableBlurMaterials[e],this._separableBlurMaterials[e].colorTexture.value=o.texture,this._separableBlurMaterials[e].direction.value=mA,t.setRenderTarget(this._renderTargetsHorizontal[e]),t.clear(),uA.render(t),this._separableBlurMaterials[e].colorTexture.value=this._renderTargetsHorizontal[e].texture,this._separableBlurMaterials[e].direction.value=hA,t.setRenderTarget(this._renderTargetsVertical[e]),t.clear(),uA.render(t),o=this._renderTargetsVertical[e];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),uA.material=this._compositeMaterial,uA.render(t),t.setRenderTarget(r),t.setMRT(i),t.setClearColor(fA,a)}setup(e){let t=U(()=>{let e=this.inputNode,t=Pk(e.rgb),n=uy(this.threshold,this.threshold.add(this.smoothWidth),t);return oy(X(0),e,n)});this._highPassFilterMaterial=this._highPassFilterMaterial||new tw,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name=`Bloom_highPass`,this._highPassFilterMaterial.needsUpdate=!0;let n=[3,5,7,9,11];for(let t=0;t<this._nMips;t++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,n[t]));let r=Sx([1,.8,.6,.4,.2]),i=Sx([new M(1,1,1),new M(1,1,1),new M(1,1,1),new M(1,1,1),new M(1,1,1)]),a=U(([e,t])=>oy(e,G(1.2).sub(e),t)).setLayout({name:`lerpBloomFactor`,type:`float`,inputs:[{name:`factor`,type:`float`},{name:`radius`,type:`float`}]}),o=U(()=>{let e=a(r.element(0),this.radius).mul(X(i.element(0),1)).mul(this._textureNodeBlur0),t=a(r.element(1),this.radius).mul(X(i.element(1),1)).mul(this._textureNodeBlur1),n=a(r.element(2),this.radius).mul(X(i.element(2),1)).mul(this._textureNodeBlur2),o=a(r.element(3),this.radius).mul(X(i.element(3),1)).mul(this._textureNodeBlur3),s=a(r.element(4),this.radius).mul(X(i.element(4),1)).mul(this._textureNodeBlur4);return e.add(t).add(n).add(o).add(s).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new tw,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name=`Bloom_comp`,this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){let n=[];for(let e=0;e<t;e++)n.push(.39894*Math.exp(-.5*e*e/(t*t))/t);let r=gb(),i=Sx(n),a=Z(new A),o=Z(new A(.5,.5)),s=ub(),c=e=>r.uv(e),l=U(()=>{let e=i.element(0).toVar(),n=c(s).rgb.mul(e).toVar();return rC({start:K(1),end:K(t),type:`int`,condition:`<`},({i:t})=>{let r=G(t),l=i.element(t),u=o.mul(a).mul(r),d=c(s.add(u)).rgb,f=c(s.sub(u)).rgb;n.addAssign(L_(d,f).mul(l)),e.addAssign(G(2).mul(l))}),X(n.div(e),1)}),u=new tw;return u.fragmentNode=l().context(e.getSharedContext()),u.name=`Bloom_seperable`,u.needsUpdate=!0,u.colorTexture=r,u.direction=o,u.invSize=a,u}},_A=(e,t,n,r)=>B(new gA(B(e),t,n,r)),vA=class extends zh{static get type(){return`TransitionNode`}constructor(e,t,n,r,i,a){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=n,this.mixRatioNode=r,this.thresholdNode=i,this.useTextureNode=a}setup(){let{textureNodeA:e,textureNodeB:t,mixTextureNode:n,mixRatioNode:r,thresholdNode:i,useTextureNode:a}=this,o=e=>{let t=e.uvNode||ub();return e.uv(t)};return U(()=>{let s=o(e),c=o(t),l=X().toVar();return W(a.equal(K(1)),()=>{let e=o(n),t=r.mul(i.mul(2).add(1)).sub(i),a=sy(R_(e.r,t).mul(G(1).div(i)),0,1);l.assign(oy(s,c,a))}).Else(()=>{l.assign(oy(c,s,r))}),l})()}},yA=(e,t,n,r=0,i=.1,a=0)=>B(new vA(GO(e),GO(t),GO(n),B(r),B(i),B(a))),bA=class extends zh{static get type(){return`PixelationNode`}constructor(e,t,n,r,i,a){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.pixelSize=r,this.normalEdgeStrength=i,this.depthEdgeStrength=a,this._resolution=Z(new Fn),this.updateBeforeType=L.RENDER}updateBefore(){let e=this.textureNode.value,t=e.image.width,n=e.image.height;this._resolution.value.set(t,n,1/t,1/n)}setup(){let{textureNode:e,depthNode:t,normalNode:n}=this,r=e.uvNode||ub(),i=t.uvNode||ub(),a=n.uvNode||ub(),o=()=>e.uv(r),s=(e,n)=>t.uv(i.add(J(e,n).mul(this._resolution.zw))).r,c=(e,t)=>n.uv(a.add(J(e,t).mul(this._resolution.zw))).rgb.normalize(),l=e=>{let t=n_(`float`,`diff`);return t.addAssign(sy(s(1,0).sub(e))),t.addAssign(sy(s(-1,0).sub(e))),t.addAssign(sy(s(0,1).sub(e))),t.addAssign(sy(s(0,-1).sub(e))),bv(uy(.01,.02,t).mul(2)).div(2)},u=(e,t,n,r)=>{let i=s(e,t).sub(n),a=c(e,t),o=Y(1,1,1),l=sy(uy(-.01,.01,Zv(r.sub(a),o)),0,1),u=sy(jv(i.mul(.25).add(.0025)),0,1);return G(1).sub(Zv(r,a)).mul(u).mul(l)},d=(e,t)=>{let n=n_(`float`,`indicator`);return n.addAssign(u(0,-1,e,t)),n.addAssign(u(0,1,e,t)),n.addAssign(u(-1,0,e,t)),n.addAssign(u(1,0,e,t)),qv(.1,n)};return U(()=>{let e=o(),t=n_(`float`,`depth`),n=n_(`vec3`,`normal`);W(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{t.assign(s(0,0)),n.assign(c(0,0))});let r=n_(`float`,`dei`);W(this.depthEdgeStrength.greaterThan(0),()=>{r.assign(l(t))});let i=n_(`float`,`nei`);W(this.normalEdgeStrength.greaterThan(0),()=>{i.assign(d(t,n))});let a=r.greaterThan(0).select(G(1).sub(r.mul(this.depthEdgeStrength)),i.mul(this.normalEdgeStrength).add(1));return e.mul(a)})()}},xA=(e,t,n,r=6,i=.3,a=.4)=>B(new bA(GO(e),GO(t),GO(n),B(r),B(i),B(a))),SA=class extends _k{static get type(){return`PixelationPassNode`}constructor(e,t,n=6,r=.3,i=.4){super(`color`,e,t,{minFilter:u,magFilter:u}),this.pixelSize=n,this.normalEdgeStrength=r,this.depthEdgeStrength=i,this.isPixelationPassNode=!0,this._mrt=nO({output:S_,normal:ix})}setSize(e,t){let n=this.pixelSize.value?this.pixelSize.value:this.pixelSize,r=Math.floor(e/n),i=Math.floor(t/n);super.setSize(r,i)}setup(){return xA(super.getTextureNode(`output`),super.getTextureNode(`depth`),super.getTextureNode(`normal`),this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}},CA=(e,t,n,r,i)=>B(new SA(e,t,n,r,i)),wA=new A,TA=class extends _k{static get type(){return`SSAAPassNode`}constructor(e,t){super(_k.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new P(0),this.clearAlpha=0,this._currentClearColor=new P,this.sampleWeight=Z(1),this.sampleRenderTarget=null,this._quadMesh=new VO}updateBefore(e){let{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();let i=t.getSize(wA);this.setSize(i.width,i.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);let a=t.getClearAlpha(),o=t.getRenderTarget(),s=t.getMRT(),c=t.autoClear;this._cameraNear.value=r.near,this._cameraFar.value=r.far,t.setMRT(this.getMRT()),t.autoClear=!1;let l=EA[Math.max(0,Math.min(this.sampleLevel,5))],u=1/l.length,d={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},f=Object.assign({},r.view);f.enabled&&Object.assign(d,f);for(let e=0;e<l.length;e++){let i=l[e];if(r.setViewOffset&&r.setViewOffset(d.fullWidth,d.fullHeight,d.offsetX+i[0]*.0625,d.offsetY+i[1]*.0625,d.width,d.height),this.sampleWeight.value=u,this.unbiased){let t=-.5+(e+.5)/l.length;this.sampleWeight.value+=.03125*t}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(n,r),t.setRenderTarget(this.renderTarget),e===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),r.setViewOffset&&f.enabled?r.setViewOffset(f.fullWidth,f.fullHeight,f.offsetX,f.offsetY,f.width,f.height):r.clearViewOffset&&r.clearViewOffset(),t.setRenderTarget(o),t.setMRT(s),t.autoClear=c,t.setClearColor(this._currentClearColor,a)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t,n=this.getMRT();if(n!==null){let e={};for(let t in n.outputNodes){let n=eO(this.sampleRenderTarget.textures,t);n>=0&&(e[t]=gb(this.sampleRenderTarget.textures[n]).mul(this.sampleWeight))}t=nO(e)}else t=gb(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new tw,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=2,this._quadMesh.material.normals=!1,this._quadMesh.material.name=`SSAA`,super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}},EA=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],DA=(e,t)=>B(new TA(e,t)),OA=new A,kA=class extends _k{static get type(){return`StereoPassNode`}constructor(e,t){super(_k.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Hp,this.stereo.aspect=.5}updateBefore(e){let{renderer:t}=e,{scene:n,camera:r,stereo:i,renderTarget:a}=this;this._pixelRatio=t.getPixelRatio(),i.cameraL.coordinateSystem=t.coordinateSystem,i.cameraR.coordinateSystem=t.coordinateSystem,i.update(r);let o=t.getSize(OA);this.setSize(o.width,o.height);let s=t.autoClear;t.autoClear=!1;let c=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(let e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(a),t.setMRT(this._mrt),t.clear(),a.scissorTest=!0,a.scissor.set(0,0,a.width/2,a.height),a.viewport.set(0,0,a.width/2,a.height),t.render(n,i.cameraL),a.scissor.set(a.width/2,0,a.width/2,a.height),a.viewport.set(a.width/2,0,a.width/2,a.height),t.render(n,i.cameraR),a.scissorTest=!1,t.setRenderTarget(c),t.setMRT(l),t.autoClear=s}},AA=(e,t)=>B(new kA(e,t)),jA=new A,MA=new VO,NA=class extends _k{static get type(){return`StereoCompositePassNode`}constructor(e,t){super(_k.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Hp;let n={minFilter:h,magFilter:u,type:D};this._renderTargetL=new In(1,1,n),this._renderTargetR=new In(1,1,n),this._mapLeft=gb(this._renderTargetL.texture),this._mapRight=gb(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){let{renderer:t}=e,{scene:n,stereo:r,renderTarget:i}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);let a=t.getSize(jA);this.setSize(a.width,a.height);let o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(n,r.cameraL),t.setRenderTarget(this._renderTargetR),t.render(n,r.cameraR),t.setRenderTarget(i),MA.material=this._material,MA.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}},PA=class extends NA{static get type(){return`AnaglyphPassNode`}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=Z(new j().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=Z(new j().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){let t=ub(),n=U(()=>{let e=this._mapLeft.uv(t),n=this._mapRight.uv(t);return X(sy(this._colorMatrixLeft.mul(e.rgb).add(this._colorMatrixRight.mul(n.rgb))).rgb,Gv(e.a,n.a))}),r=this._material||=new tw;return r.fragmentNode=n().context(e.getSharedContext()),r.name=`Anaglyph`,r.needsUpdate=!0,super.setup(e)}},FA=(e,t)=>B(new PA(e,t)),IA=class extends NA{static get type(){return`ParallaxBarrierPassNode`}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){let t=ub(),n=U(()=>{let e=X().toVar();return W(Kv(OC.y,2).greaterThan(1),()=>{e.assign(this._mapLeft.uv(t))}).Else(()=>{e.assign(this._mapRight.uv(t))}),e}),r=this._material||=new tw;return r.fragmentNode=n().context(e.getSharedContext()),r.needsUpdate=!0,super.setup(e)}},LA=(e,t)=>B(new IA(e,t)),RA=class extends _k{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(_k.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let c=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,c,o,s)}t.renderObject(e,n,r,i,a,o,s)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new tw;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=1;let t=nx.negate(),n=Sb.mul(Hb),r=G(1),i=n.mul(X(Kb,1)),a=n.mul(X(Kb.add(t),1)),o=Sv(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=X(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},zA=(e,t,n=new P(0,0,0),r=.003,i=1)=>B(new RA(e,t,B(n),B(r),B(i))),BA=class extends R{static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new Ft,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType===`URL`&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:`change`}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:`refresh`})}getValue(){let e=this.value;if(e&&this._cache===null&&this.inputType===`URL`&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType===`URL`||this.inputType===`String`)&&typeof e.value==`string`||this.inputType===`Number`&&typeof e.value==`number`||this.inputType===`Vector2`&&e.value.isVector2||this.inputType===`Vector3`&&e.value.isVector3||this.inputType===`Vector4`&&e.value.isVector4||this.inputType===`Color`&&e.value.isColor||this.inputType===`Matrix3`&&e.value.isMatrix3||this.inputType===`Matrix4`&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):`float`}setup(){return this.value&&this.value.isNode?this.value:G()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=Dh(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?Oh(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}},VA=V(BA),HA=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},UA=class{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){let t=this.parameters[e];return t?t.getValue():null}},WA=new HA,GA=class extends R{static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new HA,this._output=VA(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:``}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=VA(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=VA(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener(`refresh`,this.onRefresh)),this}clearParameters(){for(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject()[e];if(typeof n==`function`)return n(...t)}async callAsync(e,...t){let n=this.getObject()[e];if(typeof n==`function`)return n.constructor.name===`AsyncFunction`?await n(...t):n(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new UA(this),r=WA.get(`THREE`),i=WA.get(`TSL`);this._object=this.getMethod(this.codeNode)(n,this._local,WA,e,t,r,i);let a=this._object.layout;if(a&&(a.cache===!1&&this._local.clear(),this._output.outputType=a.outputType||null,Array.isArray(a.elements)))for(let e of a.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(let e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:G()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`].join(`, `),n=`var `+t+`; var output = {};
`,r=`
return { ...output, `+t+` };`,i=n+this.codeNode.code+r;return this._method=Function(...e,i),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose==`function`&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){let t=[bh(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return xh(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call(`main`),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}},KA=V(GA),qA=class extends R{static get type(){return`FogNode`}constructor(e,t){super(`float`),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||Xb.z).negate()}setup(){return this.factorNode}},JA=V(qA),YA=class extends qA{static get type(){return`FogRangeNode`}constructor(e,t,n){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=n}setup(e){let t=this.getViewZNode(e);return uy(this.nearNode,this.farNode,t)}},XA=V(YA),ZA=class extends qA{static get type(){return`FogExp2Node`}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){let t=this.getViewZNode(e),n=this.densityNode;return n.mul(n,t,t).negate().exp().oneMinus()}},QA=V(ZA),$A=null,ej=null,tj=class extends R{static get type(){return`RangeNode`}constructor(e=G(),t=G()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(Th(this.minNode.value)),n=e.getTypeLength(Th(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(Th(r)),o=e.getTypeLength(Th(i));$A||=new Fn,ej||=new Fn,$A.setScalar(0),ej.setScalar(0),a===1?$A.setScalar(r):r.isColor?$A.set(r.r,r.g,r.b):$A.set(r.x,r.y,r.z||0,r.w||0),o===1?ej.setScalar(i):i.isColor?ej.set(i.r,i.g,i.b):ej.set(i.x,i.y,i.z||0,i.w||0);let s=4*t.count,c=new Float32Array(s);for(let e=0;e<s;e++){let t=e%4,n=$A.getComponent(t),r=ej.getComponent(t);c[e]=ln.lerp(n,r,Math.random())}let l=this.getNodeType(e);if(t.count<=4096)n=yx(c,`vec4`,t.count).element(US).convert(l);else{let t=new kl(c,4);e.geometry.setAttribute(`__range`+this.id,t),n=Wy(t).convert(l)}}else n=G(0);return n}},nj=V(tj),rj=U(({depthTexture:e,shadowCoord:t})=>gb(e,t.xy).compare(t.z)),ij=U(({depthTexture:e,shadowCoord:t,shadow:n})=>{let r=(t,n)=>gb(e,t).compare(n),i=Ex(`mapSize`,`vec2`,n).setGroup(Qg),a=Ex(`radius`,`float`,n).setGroup(Qg),o=J(1).div(i),s=o.x.negate().mul(a),c=o.y.negate().mul(a),l=o.x.mul(a),u=o.y.mul(a),d=s.div(2),f=c.div(2),p=l.div(2),m=u.div(2);return L_(r(t.xy.add(J(s,c)),t.z),r(t.xy.add(J(0,c)),t.z),r(t.xy.add(J(l,c)),t.z),r(t.xy.add(J(d,f)),t.z),r(t.xy.add(J(0,f)),t.z),r(t.xy.add(J(p,f)),t.z),r(t.xy.add(J(s,0)),t.z),r(t.xy.add(J(d,0)),t.z),r(t.xy,t.z),r(t.xy.add(J(p,0)),t.z),r(t.xy.add(J(l,0)),t.z),r(t.xy.add(J(d,m)),t.z),r(t.xy.add(J(0,m)),t.z),r(t.xy.add(J(p,m)),t.z),r(t.xy.add(J(s,u)),t.z),r(t.xy.add(J(0,u)),t.z),r(t.xy.add(J(l,u)),t.z)).mul(1/17)}),aj=U(({depthTexture:e,shadowCoord:t,shadow:n})=>{let r=(t,n)=>gb(e,t).compare(n),i=Ex(`mapSize`,`vec2`,n).setGroup(Qg),a=J(1).div(i),o=a.x,s=a.y,c=t.xy,l=Cv(c.mul(i).add(.5));return c.subAssign(l.mul(a)),L_(r(c,t.z),r(c.add(J(o,0)),t.z),r(c.add(J(0,s)),t.z),r(c.add(a),t.z),oy(r(c.add(J(o.negate(),0)),t.z),r(c.add(J(o.mul(2),0)),t.z),l.x),oy(r(c.add(J(o.negate(),s)),t.z),r(c.add(J(o.mul(2),s)),t.z),l.x),oy(r(c.add(J(0,s.negate())),t.z),r(c.add(J(0,s.mul(2))),t.z),l.y),oy(r(c.add(J(o,s.negate())),t.z),r(c.add(J(o,s.mul(2))),t.z),l.y),oy(oy(r(c.add(J(o.negate(),s.negate())),t.z),r(c.add(J(o.mul(2),s.negate())),t.z),l.x),oy(r(c.add(J(o.negate(),s.mul(2))),t.z),r(c.add(J(o.mul(2),s.mul(2))),t.z),l.x),l.y)).mul(1/9)}),oj=U(({depthTexture:e,shadowCoord:t})=>{let n=G(1).toVar(),r=gb(e).uv(t.xy).rg,i=qv(t.z,r.x);return W(i.notEqual(G(1)),()=>{let e=t.z.sub(r.x),a=Gv(0,r.y.mul(r.y)),o=a.div(a.add(e.mul(e)));o=sy(R_(o,.3).div(.6499999999999999)),n.assign(sy(Gv(i,o)))}),n}),sj=U(({samples:e,radius:t,size:n,shadowPass:r})=>{let i=G(0).toVar(),a=G(0).toVar(),o=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),s=e.lessThanEqual(G(1)).select(G(0),G(-1));return rC({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let c=s.add(G(e).mul(o)),l=r.uv(L_(OC.xy,J(0,c).mul(t)).div(n)).x;i.addAssign(l),a.addAssign(l.mul(l))}),i.divAssign(e),a.divAssign(e),J(i,vv(a.sub(i.mul(i))))}),cj=U(({samples:e,radius:t,size:n,shadowPass:r})=>{let i=G(0).toVar(),a=G(0).toVar(),o=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),s=e.lessThanEqual(G(1)).select(G(0),G(-1));return rC({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let c=s.add(G(e).mul(o)),l=r.uv(L_(OC.xy,J(c,0).mul(t)).div(n));i.addAssign(l.x),a.addAssign(L_(l.y.mul(l.y),l.x.mul(l.x)))}),i.divAssign(e),a.divAssign(e),J(i,vv(a.sub(i.mul(i))))}),lj=[rj,ij,aj,oj],uj=null,dj=new VO,fj=class extends vC{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.updateType=L.FRAME,this.light=e,this.color=new P,this.colorNode=Z(this.color).setGroup(Qg),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return Sh(super.getCacheKey(),this.light.id,+!!this.light.castShadow)}getHash(){return this.light.uuid}setupShadow(e){let{object:t,renderer:n}=e;if(n.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){uj===null&&(uj=new tw,uj.fragmentNode=X(0,0,0,1),uj.isShadowNodeMaterial=!0,uj.name=`ShadowMaterial`);let i=n.shadowMap.type,a=this.light.shadow,o=new ho;o.compareFunction=513;let s=e.createRenderTarget(a.mapSize.width,a.mapSize.height);if(s.depthTexture=o,a.camera.updateProjectionMatrix(),i===3){o.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:pe,type:D}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:pe,type:D});let t=gb(o),n=gb(this.vsmShadowMapVertical.texture),r=Ex(`blurSamples`,`float`,a).setGroup(Qg),i=Ex(`radius`,`float`,a).setGroup(Qg),s=Ex(`mapSize`,`vec2`,a).setGroup(Qg),c=this.vsmMaterialVertical||=new tw;c.fragmentNode=sj({samples:r,radius:i,size:s,shadowPass:t}).context(e.getSharedContext()),c.name=`VSMVertical`,c=this.vsmMaterialHorizontal||=new tw,c.fragmentNode=cj({samples:r,radius:i,size:s,shadowPass:n}).context(e.getSharedContext()),c.name=`VSMHorizontal`}let c=Ex(`intensity`,`float`,a).setGroup(Qg),l=Ex(`bias`,`float`,a).setGroup(Qg),u=Ex(`normalBias`,`float`,a).setGroup(Qg),d=t.material.shadowPositionNode||Jb,f=Z(a.matrix).setGroup(Qg).mul(d.add(ax.mul(u)));f=f.xyz.div(f.w);let p=f.z.add(l);n.coordinateSystem===2001&&(p=p.mul(2).sub(1)),f=Y(f.x,f.y.oneMinus(),p);let m=f.x.greaterThanEqual(0).and(f.x.lessThanEqual(1)).and(f.y.greaterThanEqual(0)).and(f.y.lessThanEqual(1)).and(f.z.lessThanEqual(1)),h=a.filterNode||lj[n.shadowMap.type]||null;if(h===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let g=gb(s.texture,f),_=m.select(h({depthTexture:i===3?this.vsmShadowMapHorizontal.texture:o,shadowCoord:f,shadow:a}),G(1));this.shadowMap=s,this.light.shadow.map=s,this.shadowNode=_,this.shadowColorNode=r=this.colorNode.mul(oy(1,_.rgb.mix(g,1),c.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=r,this.updateBeforeType=L.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){let{shadowMap:t,light:n}=this,{renderer:r,scene:i,camera:a}=e,o=r.shadowMap.type;this._depthVersionCached=t.depthTexture.version;let s=i.overrideMaterial;i.overrideMaterial=uj,t.setSize(n.shadow.mapSize.width,n.shadow.mapSize.height),n.shadow.updateMatrices(n),n.shadow.camera.layers.mask=a.layers.mask;let c=r.getRenderTarget(),l=r.getRenderObjectFunction();r.setRenderObjectFunction((e,...t)=>{(e.castShadow===!0||e.receiveShadow&&o===3)&&r.renderObject(e,...t)}),r.setRenderTarget(t),r.render(i,n.shadow.camera),r.setRenderObjectFunction(l),n.isPointLight!==!0&&o===3&&this.vsmPass(e,n),r.setRenderTarget(c),i.overrideMaterial=s}vsmPass(e,t){let{renderer:n}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),n.setRenderTarget(this.vsmShadowMapVertical),dj.material=this.vsmMaterialVertical,dj.render(n),n.setRenderTarget(this.vsmShadowMapHorizontal),dj.material=this.vsmMaterialHorizontal,dj.render(n)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=L.NONE}updateBefore(e){let t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},pj=U(e=>{let{lightDistance:t,cutoffDistance:n,decayExponent:r}=e,i=t.pow(r).max(.01).reciprocal();return n.greaterThan(0).select(i.mul(t.div(n).pow4().oneMinus().clamp().pow2()),i)}),mj;function hj(e){mj||=new WeakMap;let t=mj.get(e);return t===void 0&&mj.set(e,t={}),t}function gj(e){let t=hj(e);return t.position||=Z(new M).setGroup(Qg).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function _j(e){let t=hj(e);return t.targetPosition||=Z(new M).setGroup(Qg).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function vj(e){let t=hj(e);return t.viewPosition||=Z(new M).setGroup(Qg).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new M,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var yj=e=>wb.transformDirection(gj(e).sub(_j(e))),bj=U(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/2**32)}),xj=(e,t)=>$v(z_(4,e.mul(R_(1,e))),t),Sj=(e,t)=>e.lessThan(.5)?xj(e.mul(2),t).div(2):R_(1,xj(z_(R_(1,e),2),t).div(2)),Cj=(e,t,n)=>$v(B_($v(e,t),L_($v(e,t),$v(R_(1,e),n))),1/t),wj=(e,t)=>wv(sv.mul(t.mul(e).sub(1))).div(sv.mul(t.mul(e).sub(1))),Tj=U(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Ej=U(([e])=>Y(Tj(e.z.add(Tj(e.y.mul(1)))),Tj(e.z.add(Tj(e.x.mul(1)))),Tj(e.y.add(Tj(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Dj=U(([e,t,n])=>{let r=Y(e).toVar(),i=G(1.4).toVar(),a=G(0).toVar(),o=Y(r).toVar();return rC({start:G(0),end:G(3),type:`float`,condition:`<=`},()=>{let e=Y(Ej(o.mul(2))).toVar();r.addAssign(e.add(n.mul(G(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=G(Tj(r.z.add(Tj(r.x.add(Tj(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`spd`,type:`float`},{name:`time`,type:`float`}]}),Oj=U(([e,t,n=J(.5)])=>wE(e.sub(n),t).add(n)),kj=U(([e,t,n=J(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i).mul(t);return e.add(r.mul(a))}),Aj=U(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=Ib:(r=Ib.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=wb.mul(r);return bg(t)&&(i[0][0]=Ib[0].length(),i[0][1]=0,i[0][2]=0),bg(n)&&(i[1][0]=0,i[1][1]=Ib[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Sb.mul(i).mul(Kb)}),jj=U(([e=null])=>{let t=XC();return XC(HC(e)).sub(t).lessThan(0).select(EC,e)}),Mj=new WeakMap,Nj=class extends zh{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.updateType=L.OBJECT,this.updateAfterType=L.OBJECT,this.previousModelWorldMatrix=Z(new N),this.previousProjectionMatrix=Z(new N).setGroup(Qg),this.previousCameraViewMatrix=Z(new N)}update({frameId:e,camera:t,object:n}){let r=Fj(n);this.previousModelWorldMatrix.value.copy(r);let i=Pj(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new N,i.previousCameraViewMatrix=new N,i.currentProjectionMatrix=new N,i.currentCameraViewMatrix=new N,i.previousProjectionMatrix.copy(t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Fj(e).copy(e.matrixWorld)}setup(){let e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=Sb.mul(Hb).mul(Kb),n=this.previousProjectionMatrix.mul(e).mul(qb);return R_(t.xy.div(t.w),n.xy.div(n.w))}};function Pj(e){let t=Mj.get(e);return t===void 0&&(t={},Mj.set(e,t)),t}function Fj(e,t=0){let n=Pj(e),r=n[t];return r===void 0&&(n[t]=r=new N),r}var Ij=H(Nj),Lj=U(([e,t])=>Wv(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`burnBlend`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Rj=U(([e,t])=>Wv(e.div(t.oneMinus()),1)).setLayout({name:`dodgeBlend`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),zj=U(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`screenBlend`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Bj=U(([e,t])=>oy(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),qv(.5,e))).setLayout({name:`overlayBlend`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Vj=U(([e,t,n=K(16)])=>{let r=t=>e.uv(t),i=ub(),a=r(i).toVar(),o=G(n);return rC({start:K(1),end:n,type:`int`,condition:`<=`},({i:e})=>{let n=t.mul(G(e).div(o.sub(1)).sub(.5));a.addAssign(r(i.add(n)))}),a.divAssign(o),a}),Hj=U(([e,t=1])=>{let n=e,r=Pk(n.rgb),i=Y(r),a=Wv(1,Gv(0,G(10).mul(r.sub(.45)))),o=oy(i.mul(n.rgb).mul(2),G(2).mul(i.oneMinus()).mul(n.rgb.oneMinus()).oneMinus(),a),s=n.a.mul(t),c=s.mul(o.rgb);return c.addAssign(n.rgb.mul(s.oneMinus())),X(c,n.a)}),Uj=U(([e])=>{let t=Y(e);return X(Zv(t,Y(.393,.769,.189)),Zv(t,Y(.349,.686,.168)),Zv(t,Y(.272,.534,.131)),e.a)}),Wj=U(([e])=>oy(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBToLinearSRGB`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),Gj=U(([e])=>oy(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`linearSRGBTosRGB`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),Kj=U(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),qj=U(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Jj=U(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Yj=U(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Xj=U(([e,t])=>{let n=Vg(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=Vg(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Yj(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Zj=Vg(Y(1.6605,-.1246,-.0182),Y(-.5876,1.1329,-.1006),Y(-.0728,-.0083,1.1187)),Qj=Vg(Y(.6274,.0691,.0164),Y(.3293,.9195,.088),Y(.0433,.0113,.8956)),$j=U(([e])=>{let t=Y(e).toVar(),n=Y(t.mul(t)).toVar(),r=Y(n.mul(n)).toVar();return G(15.5).mul(r.mul(n)).sub(z_(40.14,r.mul(t))).add(z_(31.96,r).sub(z_(6.868,n.mul(t))).add(z_(.4298,n).add(z_(.1191,t).sub(.00232))))}),eM=U(([e,t])=>{let n=Y(e).toVar(),r=Vg(Y(.856627153315983,.137318972929847,.11189821299995),Y(.0951212405381588,.761241990602591,.0767994186031903),Y(.0482516061458583,.101439036467562,.811302368396859)),i=Vg(Y(1.1271005818144368,-.1413297634984383,-.14132976349843826),Y(-.11060664309660323,1.157823702216272,-.11060664309660294),Y(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=G(-12.47393),o=G(4.026069);return n.mulAssign(t),n.assign(Qj.mul(n)),n.assign(r.mul(n)),n.assign(Gv(n,1e-10)),n.assign(_v(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(sy(n,0,1)),n.assign($j(n)),n.assign(i.mul(n)),n.assign($v(Gv(Y(0),n),Y(2.2))),n.assign(Zj.mul(n)),n.assign(sy(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),tM=U(([e,t])=>{let n=G(.76),r=G(.15);e=e.mul(t);let i=Wv(e.r,Wv(e.g,e.b)),a=hy(i.lessThan(.08),i.sub(z_(6.25,i.mul(i))),.04);e.subAssign(a);let o=Gv(e.r,Gv(e.g,e.b));W(o.lessThan(n),()=>e);let s=R_(1,n),c=R_(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=R_(1,B_(1,r.mul(o.sub(c)).add(1)));return oy(e,Y(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),nM=class extends R{static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},rM=(e,t)=>B(new nM(e,t)),iM=rM(`numWorkgroups`,`uvec3`),aM=rM(`workgroupId`,`uvec3`),oM=rM(`localId`,`uvec3`),sM=rM(`subgroupSize`,`uint`),cM=V(class extends R{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),lM=()=>cM(`workgroup`).append(),uM=()=>cM(`storage`).append(),dM=()=>cM(`texture`).append(),fM=class extends Lh{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},pM=class extends R{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return B(new fM(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},mM=(e,t)=>B(new pM(`Workgroup`,e,t)),hM=class extends zh{static get type(){return`AtomicFunctionNode`}constructor(e,t,n,r=null){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=this.method,n=this.getNodeType(e),r=this.getInputType(e),i=this.pointerNode,a=this.valueNode,o=[];o.push(`&${i.build(e,r)}`),o.push(a.build(e,r));let s=`${e.getMethod(t,n)}( ${o.join(`, `)} )`;if(this.storeNode!==null){let t=this.storeNode.build(e,r);e.addLineFlowCode(`${t} = ${s}`,this)}else e.addLineFlowCode(s,this)}};hM.ATOMIC_LOAD=`atomicLoad`,hM.ATOMIC_STORE=`atomicStore`,hM.ATOMIC_ADD=`atomicAdd`,hM.ATOMIC_SUB=`atomicSub`,hM.ATOMIC_MAX=`atomicMax`,hM.ATOMIC_MIN=`atomicMin`,hM.ATOMIC_AND=`atomicAnd`,hM.ATOMIC_OR=`atomicOr`,hM.ATOMIC_XOR=`atomicXor`;var gM=V(hM),_M=(e,t,n,r)=>{let i=gM(e,t,n,r);return i.append(),i},vM=(e,t,n=null)=>_M(hM.ATOMIC_STORE,e,t,n),yM=(e,t,n=null)=>_M(hM.ATOMIC_ADD,e,t,n),bM=(e,t,n=null)=>_M(hM.ATOMIC_SUB,e,t,n),xM=(e,t,n=null)=>_M(hM.ATOMIC_MAX,e,t,n),SM=(e,t,n=null)=>_M(hM.ATOMIC_MIN,e,t,n),CM=(e,t,n=null)=>_M(hM.ATOMIC_AND,e,t,n),wM=(e,t,n=null)=>_M(hM.ATOMIC_OR,e,t,n),TM=(e,t,n=null)=>_M(hM.ATOMIC_XOR,e,t,n),EM=U(([e=ub()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor();return n.add(r).mod(2).sign()}),DM=U(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar();return hy(Ag(e).toVar(),i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),OM=U(([e,t])=>{let n=Ag(t).toVar(),r=G(e).toVar();return hy(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),kM=U(([e])=>K(bv(G(e).toVar()))).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),AM=U(([e,t])=>{let n=G(e).toVar();return t.assign(kM(n)),n.sub(G(t))}),jM=aO([U(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=G(r).toVar(),l=G(n).toVar(),u=G(t).toVar(),d=G(e).toVar(),f=G(R_(1,s)).toVar();return R_(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),U(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=Y(r).toVar(),l=Y(n).toVar(),u=Y(t).toVar(),d=Y(e).toVar(),f=G(R_(1,s)).toVar();return R_(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]})]),MM=aO([U(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=G(s).toVar(),h=G(o).toVar(),g=G(a).toVar(),_=G(i).toVar(),v=G(r).toVar(),y=G(n).toVar(),b=G(t).toVar(),x=G(e).toVar(),S=G(R_(1,p)).toVar(),C=G(R_(1,f)).toVar();return G(R_(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),U(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=Y(s).toVar(),h=Y(o).toVar(),g=Y(a).toVar(),_=Y(i).toVar(),v=Y(r).toVar(),y=Y(n).toVar(),b=Y(t).toVar(),x=Y(e).toVar(),S=G(R_(1,p)).toVar(),C=G(R_(1,f)).toVar();return G(R_(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]})]),NM=aO([U(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=q(q(e).toVar().bitAnd(q(7))).toVar(),o=G(DM(a.lessThan(q(4)),i,r)).toVar(),s=G(z_(2,DM(a.lessThan(q(4)),r,i))).toVar();return OM(o,Ag(a.bitAnd(q(1)))).add(OM(s,Ag(a.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=q(q(e).toVar().bitAnd(q(15))).toVar(),c=G(DM(s.lessThan(q(8)),o,a)).toVar(),l=G(DM(s.lessThan(q(4)),a,DM(s.equal(q(12)).or(s.equal(q(14))),o,i))).toVar();return OM(c,Ag(s.bitAnd(q(1)))).add(OM(l,Ag(s.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),PM=aO([U(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=Fg(e).toVar();return Y(NM(a.x,i,r),NM(a.y,i,r),NM(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=Fg(e).toVar();return Y(NM(s.x,o,a,i),NM(s.y,o,a,i),NM(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),FM=U(([e])=>z_(.6616,G(e).toVar())).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),IM=U(([e])=>z_(.982,G(e).toVar())).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),LM=aO([FM,U(([e])=>z_(.6616,Y(e).toVar())).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),RM=aO([IM,U(([e])=>z_(.982,Y(e).toVar())).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),zM=U(([e,t])=>{let n=K(t).toVar(),r=q(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(K(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),BM=U(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(zM(n,K(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(zM(e,K(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(zM(t,K(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(zM(n,K(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(zM(e,K(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(zM(t,K(4))),t.addAssign(e)}),VM=U(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=q(e).toVar();return r.bitXorAssign(i),r.subAssign(zM(i,K(14))),a.bitXorAssign(r),a.subAssign(zM(r,K(11))),i.bitXorAssign(a),i.subAssign(zM(a,K(25))),r.bitXorAssign(i),r.subAssign(zM(i,K(16))),a.bitXorAssign(r),a.subAssign(zM(r,K(4))),i.bitXorAssign(a),i.subAssign(zM(a,K(14))),r.bitXorAssign(i),r.subAssign(zM(i,K(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),HM=U(([e])=>G(q(e).toVar()).div(G(q(K(4294967295))))).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),UM=U(([e])=>{let t=G(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),WM=aO([U(([e])=>{let t=K(e).toVar(),n=q(q(1)).toVar(),r=q(q(K(3735928559)).add(n.shiftLeft(q(2))).add(q(13))).toVar();return VM(r.add(q(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),U(([e,t])=>{let n=K(t).toVar(),r=K(e).toVar(),i=q(q(2)).toVar(),a=q().toVar(),o=q().toVar(),s=q().toVar();return a.assign(o.assign(s.assign(q(K(3735928559)).add(i.shiftLeft(q(2))).add(q(13))))),a.addAssign(q(r)),o.addAssign(q(n)),VM(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),U(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=K(e).toVar(),o=q(q(3)).toVar(),s=q().toVar(),c=q().toVar(),l=q().toVar();return s.assign(c.assign(l.assign(q(K(3735928559)).add(o.shiftLeft(q(2))).add(q(13))))),s.addAssign(q(a)),c.addAssign(q(i)),l.addAssign(q(r)),VM(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),U(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=K(t).toVar(),s=K(e).toVar(),c=q(q(4)).toVar(),l=q().toVar(),u=q().toVar(),d=q().toVar();return l.assign(u.assign(d.assign(q(K(3735928559)).add(c.shiftLeft(q(2))).add(q(13))))),l.addAssign(q(s)),u.addAssign(q(o)),d.addAssign(q(a)),BM(l,u,d),l.addAssign(q(i)),VM(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),U(([e,t,n,r,i])=>{let a=K(i).toVar(),o=K(r).toVar(),s=K(n).toVar(),c=K(t).toVar(),l=K(e).toVar(),u=q(q(5)).toVar(),d=q().toVar(),f=q().toVar(),p=q().toVar();return d.assign(f.assign(p.assign(q(K(3735928559)).add(u.shiftLeft(q(2))).add(q(13))))),d.addAssign(q(l)),f.addAssign(q(c)),p.addAssign(q(s)),BM(d,f,p),d.addAssign(q(o)),f.addAssign(q(a)),VM(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]})]),GM=aO([U(([e,t])=>{let n=K(t).toVar(),r=q(WM(K(e).toVar(),n)).toVar(),i=Fg().toVar();return i.x.assign(r.bitAnd(K(255))),i.y.assign(r.shiftRight(K(8)).bitAnd(K(255))),i.z.assign(r.shiftRight(K(16)).bitAnd(K(255))),i}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),U(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=q(WM(K(e).toVar(),i,r)).toVar(),o=Fg().toVar();return o.x.assign(a.bitAnd(K(255))),o.y.assign(a.shiftRight(K(8)).bitAnd(K(255))),o.z.assign(a.shiftRight(K(16)).bitAnd(K(255))),o}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]})]),KM=aO([U(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(AM(t.x,n)).toVar(),a=G(AM(t.y,r)).toVar(),o=G(UM(i)).toVar(),s=G(UM(a)).toVar();return LM(G(jM(NM(WM(n,r),i,a),NM(WM(n.add(K(1)),r),i.sub(1),a),NM(WM(n,r.add(K(1))),i,a.sub(1)),NM(WM(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),U(([e])=>{let t=Y(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(AM(t.x,n)).toVar(),o=G(AM(t.y,r)).toVar(),s=G(AM(t.z,i)).toVar(),c=G(UM(a)).toVar(),l=G(UM(o)).toVar(),u=G(UM(s)).toVar();return RM(G(MM(NM(WM(n,r,i),a,o,s),NM(WM(n.add(K(1)),r,i),a.sub(1),o,s),NM(WM(n,r.add(K(1)),i),a,o.sub(1),s),NM(WM(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),NM(WM(n,r,i.add(K(1))),a,o,s.sub(1)),NM(WM(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),NM(WM(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),NM(WM(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]})]),qM=aO([U(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(AM(t.x,n)).toVar(),a=G(AM(t.y,r)).toVar(),o=G(UM(i)).toVar(),s=G(UM(a)).toVar();return LM(Y(jM(PM(GM(n,r),i,a),PM(GM(n.add(K(1)),r),i.sub(1),a),PM(GM(n,r.add(K(1))),i,a.sub(1)),PM(GM(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),U(([e])=>{let t=Y(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(AM(t.x,n)).toVar(),o=G(AM(t.y,r)).toVar(),s=G(AM(t.z,i)).toVar(),c=G(UM(a)).toVar(),l=G(UM(o)).toVar(),u=G(UM(s)).toVar();return RM(Y(MM(PM(GM(n,r,i),a,o,s),PM(GM(n.add(K(1)),r,i),a.sub(1),o,s),PM(GM(n,r.add(K(1)),i),a,o.sub(1),s),PM(GM(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),PM(GM(n,r,i.add(K(1))),a,o,s.sub(1)),PM(GM(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),PM(GM(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),PM(GM(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]})]),JM=aO([U(([e])=>HM(WM(K(kM(G(e).toVar())).toVar()))).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),U(([e])=>{let t=J(e).toVar();return HM(WM(K(kM(t.x)).toVar(),K(kM(t.y)).toVar()))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),U(([e])=>{let t=Y(e).toVar();return HM(WM(K(kM(t.x)).toVar(),K(kM(t.y)).toVar(),K(kM(t.z)).toVar()))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),U(([e])=>{let t=X(e).toVar();return HM(WM(K(kM(t.x)).toVar(),K(kM(t.y)).toVar(),K(kM(t.z)).toVar(),K(kM(t.w)).toVar()))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]})]),YM=aO([U(([e])=>{let t=K(kM(G(e).toVar())).toVar();return Y(HM(WM(t,K(0))),HM(WM(t,K(1))),HM(WM(t,K(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),U(([e])=>{let t=J(e).toVar(),n=K(kM(t.x)).toVar(),r=K(kM(t.y)).toVar();return Y(HM(WM(n,r,K(0))),HM(WM(n,r,K(1))),HM(WM(n,r,K(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),U(([e])=>{let t=Y(e).toVar(),n=K(kM(t.x)).toVar(),r=K(kM(t.y)).toVar(),i=K(kM(t.z)).toVar();return Y(HM(WM(n,r,i,K(0))),HM(WM(n,r,i,K(1))),HM(WM(n,r,i,K(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U(([e])=>{let t=X(e).toVar(),n=K(kM(t.x)).toVar(),r=K(kM(t.y)).toVar(),i=K(kM(t.z)).toVar(),a=K(kM(t.w)).toVar();return Y(HM(WM(n,r,i,a,K(0))),HM(WM(n,r,i,a,K(1))),HM(WM(n,r,i,a,K(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]})]),XM=U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar(),c=G(0).toVar(),l=G(1).toVar();return rC(o,()=>{c.addAssign(l.mul(KM(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),ZM=U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar(),c=Y(0).toVar(),l=G(1).toVar();return rC(o,()=>{c.addAssign(l.mul(qM(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),QM=U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar();return J(XM(s,o,a,i),XM(s.add(Y(K(19),K(193),K(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),$M=U(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar();return X(Y(ZM(s,o,a,i)).toVar(),G(XM(s.add(Y(K(19),K(193),K(17))),o,a,i)).toVar())}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),eN=aO([U(([e,t,n,r,i,a,o])=>{let s=K(o).toVar(),c=G(a).toVar(),l=K(i).toVar(),u=K(r).toVar(),d=K(n).toVar(),f=K(t).toVar(),p=J(e).toVar(),m=Y(YM(J(f.add(u),d.add(l)))).toVar(),h=J(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=J(J(J(G(f),G(d)).add(h)).toVar().sub(p)).toVar();return W(s.equal(K(2)),()=>Av(g.x).add(Av(g.y))),W(s.equal(K(3)),()=>Gv(Av(g.x),Av(g.y))),Zv(g,g)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),U(([e,t,n,r,i,a,o,s,c])=>{let l=K(c).toVar(),u=G(s).toVar(),d=K(o).toVar(),f=K(a).toVar(),p=K(i).toVar(),m=K(r).toVar(),h=K(n).toVar(),g=K(t).toVar(),_=Y(e).toVar(),v=Y(YM(Y(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=Y(Y(Y(G(g),G(h),G(m)).add(v)).toVar().sub(_)).toVar();return W(l.equal(K(2)),()=>Av(y.x).add(Av(y.y)).add(Av(y.z))),W(l.equal(K(3)),()=>Gv(Gv(Av(y.x),Av(y.y)),Av(y.z))),Zv(y,y)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),tN=U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(AM(a.x,o),AM(a.y,s)).toVar(),l=G(1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(eN(c,e,t,o,s,i,r)).toVar();l.assign(Wv(l,n))})}),W(r.equal(K(0)),()=>{l.assign(vv(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),nN=U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(AM(a.x,o),AM(a.y,s)).toVar(),l=J(1e6,1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(eN(c,e,t,o,s,i,r)).toVar();W(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),W(r.equal(K(0)),()=>{l.assign(vv(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),rN=U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(AM(a.x,o),AM(a.y,s)).toVar(),l=Y(1e6,1e6,1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(eN(c,e,t,o,s,i,r)).toVar();W(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),W(r.equal(K(0)),()=>{l.assign(vv(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),iN=aO([tN,U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(AM(a.x,o),AM(a.y,s),AM(a.z,c)).toVar(),u=G(1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{rC({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(eN(l,e,t,n,o,s,c,i,r)).toVar();u.assign(Wv(u,a))})})}),W(r.equal(K(0)),()=>{u.assign(vv(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),aN=aO([nN,U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(AM(a.x,o),AM(a.y,s),AM(a.z,c)).toVar(),u=J(1e6,1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{rC({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(eN(l,e,t,n,o,s,c,i,r)).toVar();W(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),W(r.equal(K(0)),()=>{u.assign(vv(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),oN=aO([rN,U(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(AM(a.x,o),AM(a.y,s),AM(a.z,c)).toVar(),u=Y(1e6,1e6,1e6).toVar();return rC({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{rC({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{rC({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(eN(l,e,t,n,o,s,c,i,r)).toVar();W(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),W(r.equal(K(0)),()=>{u.assign(vv(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),sN=U(([e])=>{let t=e.y,n=e.z,r=Y().toVar();return W(t.lessThan(1e-4),()=>{r.assign(Y(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(bv(i)).mul(6).toVar();let a=K(zv(i)),o=i.sub(G(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());W(a.equal(K(0)),()=>{r.assign(Y(n,l,s))}).ElseIf(a.equal(K(1)),()=>{r.assign(Y(c,n,s))}).ElseIf(a.equal(K(2)),()=>{r.assign(Y(s,n,l))}).ElseIf(a.equal(K(3)),()=>{r.assign(Y(s,c,n))}).ElseIf(a.equal(K(4)),()=>{r.assign(Y(l,s,n))}).Else(()=>{r.assign(Y(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),cN=U(([e])=>{let t=Y(e).toVar(),n=G(t.x).toVar(),r=G(t.y).toVar(),i=G(t.z).toVar(),a=G(Wv(n,Wv(r,i))).toVar(),o=G(Gv(n,Gv(r,i))).toVar(),s=G(o.sub(a)).toVar(),c=G().toVar(),l=G().toVar(),u=G().toVar();return u.assign(o),W(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),W(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{W(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(L_(2,i.sub(n).div(s)))}).Else(()=>{c.assign(L_(4,n.sub(r).div(s)))}),c.mulAssign(1/6),W(c.lessThan(0),()=>{c.addAssign(1)})}),Y(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),lN=U(([e])=>{let t=Y(e).toVar(),n=Ig(G_(t,Y(.04045))).toVar();return oy(Y(t.div(12.92)).toVar(),Y($v(Gv(t.add(Y(.055)),Y(0)).div(1.055),Y(2.4))).toVar(),n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),uN=(e,t)=>{e=G(e),t=G(t);let n=J(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return uy(e.sub(n),e.add(n),t)},dN=(e,t,n,r)=>oy(e,t,n[r].clamp()),fN=(e,t,n=ub())=>dN(e,t,n,`x`),pN=(e,t,n=ub())=>dN(e,t,n,`y`),mN=(e,t,n,r,i)=>oy(e,t,uN(n,r[i])),hN=(e,t,n,r=ub())=>mN(e,t,n,r,`x`),gN=(e,t,n,r=ub())=>mN(e,t,n,r,`y`),_N=(e=1,t=0,n=ub())=>n.mul(e).add(t),vN=(e,t=1)=>(e=G(e),e.abs().pow(t).mul(e.sign())),yN=(e,t=1,n=.5)=>G(e).sub(n).mul(t).add(n),bN=(e=ub(),t=1,n=0)=>KM(e.convert(`vec2|vec3`)).mul(t).add(n),xN=(e=ub(),t=1,n=0)=>qM(e.convert(`vec2|vec3`)).mul(t).add(n),SN=(e=ub(),t=1,n=0)=>(e=e.convert(`vec2|vec3`),X(qM(e),KM(e.add(J(19,73)))).mul(t).add(n)),CN=(e=ub(),t=1)=>iN(e.convert(`vec2|vec3`),t,K(1)),wN=(e=ub(),t=1)=>aN(e.convert(`vec2|vec3`),t,K(1)),TN=(e=ub(),t=1)=>oN(e.convert(`vec2|vec3`),t,K(1)),EN=(e=ub())=>JM(e.convert(`vec2|vec3`)),DN=(e=ub(),t=3,n=2,r=.5,i=1)=>XM(e,K(t),n,r).mul(i),ON=(e=ub(),t=3,n=2,r=.5,i=1)=>QM(e,K(t),n,r).mul(i),kN=(e=ub(),t=3,n=2,r=.5,i=1)=>ZM(e,K(t),n,r).mul(i),AN=(e=ub(),t=3,n=2,r=.5,i=1)=>$M(e,K(t),n,r).mul(i),jN=U(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(z_(n,n).sub(z_(r,r)))),a}),MN=class extends fj{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=Z(0).setGroup(Qg),this.decayExponentNode=Z(0).setGroup(Qg)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=e.context.lightingModel,o=vj(i).sub(Xb),s=o.normalize(),c=pj({lightDistance:o.length(),cutoffDistance:n,decayExponent:r}),l=t.mul(c),u=e.context.reflectedLight;a.direct({lightDirection:s,lightColor:l,reflectedLight:u},e.stack,e)}},NN=class extends fj{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setup(e){super.setup(e);let t=e.context.lightingModel,n=this.colorNode,r=yj(this.light),i=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:i},e.stack,e)}},PN=new N,FN=new N,IN=null,LN=class extends fj{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=Z(new M).setGroup(Qg),this.halfWidth=Z(new M).setGroup(Qg)}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;FN.identity(),PN.copy(t.matrixWorld),PN.premultiply(n),FN.extractRotation(PN),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(FN),this.halfHeight.value.applyMatrix4(FN)}setup(e){super.setup(e);let t,n;e.isAvailable(`float32Filterable`)?(t=gb(IN.LTC_FLOAT_1),n=gb(IN.LTC_FLOAT_2)):(t=gb(IN.LTC_HALF_1),n=gb(IN.LTC_HALF_2));let{colorNode:r,light:i}=this,a=e.context.lightingModel,o=vj(i),s=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:s,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){IN=e}},RN=class extends fj{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=Z(0).setGroup(Qg),this.penumbraCosNode=Z(0).setGroup(Qg),this.cutoffDistanceNode=Z(0).setGroup(Qg),this.decayExponentNode=Z(0).setGroup(Qg)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){let{coneCosNode:t,penumbraCosNode:n}=this;return uy(t,n,e)}setup(e){super.setup(e);let t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:i,light:a}=this,o=vj(a).sub(Xb),s=o.normalize(),c=s.dot(yj(a)),l=this.getSpotAttenuation(c),u=pj({lightDistance:o.length(),cutoffDistance:r,decayExponent:i}),d=n.mul(l).mul(u),f=e.context.reflectedLight;t.direct({lightDirection:s,lightColor:d,reflectedLight:f},e.stack,e)}},zN=class extends RN{static get type(){return`IESSpotLightNode`}getSpotAttenuation(e){let t=this.light.iesMap,n=null;return n=t&&t.isTexture===!0?gb(t,J(e.acos().mul(1/Math.PI),0),0).r:super.getSpotAttenuation(e),n}},BN=class extends fj{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},VN=class extends fj{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=gj(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Z(new P).setGroup(Qg)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=oy(n,t,ix.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},HN=class extends fj{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new M);this.lightProbe=Sx(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=jN(ax,this.lightProbe);e.context.irradiance.addAssign(t)}},UN=class{parseFunction(){console.warn(`Abstract function.`)}},WN=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};WN.isNodeFunction=!0;var GN=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,KN=/[a-z_0-9]+/gi,qN=`#pragma main`,JN=e=>{e=e.trim();let t=e.indexOf(qN),n=t===-1?e:e.slice(t+12),r=n.match(GN);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=KN.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c<a.length;){let e=a[c][0]===`const`;e===!0&&c++;let t=a[c][0];t===`in`||t===`out`||t===`inout`?c++:t=``;let n=a[c++][0],r=Number.parseInt(a[c][0]);Number.isNaN(r)===!1?c++:r=null;let i=a[c++][0];s.push(new XD(n,i,r,t,e))}let l=n.substring(r[0].length),u=r[3]===void 0?``:r[3];return{type:r[2],inputs:s,name:u,precision:r[1]===void 0?``:r[1],inputsCode:i,blockCode:l,headerCode:t===-1?``:e.slice(0,t)}}else throw Error(`FunctionNode: Function is not a GLSL code.`)},YN=class extends WN{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=JN(e);super(t,n,r,i),this.inputsCode=a,this.blockCode=o,this.headerCode=s}getCode(e=this.name){let t,n=this.blockCode;if(n!==``){let{type:r,inputsCode:i,headerCode:a,precision:o}=this,s=`${r} ${e} ( ${i.trim()} )`;o!==``&&(s=`${o} ${s}`),t=a+s+n}else t=``;return t}},XN=class extends UN{parseFunction(e){return new YN(e)}},ZN=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(let n in e)t[n]=e[n]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t==`function`||typeof t==`object`)throw Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t!=`function`)throw Error(`Base class ${t.name} is not a class.`);n.set(t,e)}},QN=class extends hp{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},$N=class extends ZN{constructor(){super(),this.addLight(MN,bp),this.addLight(NN,Sp),this.addLight(LN,wp),this.addLight(RN,hp),this.addLight(BN,Cp),this.addLight(VN,lp),this.addLight(HN,Ep),this.addLight(zN,QN),this.addToneMapping(Kj,1),this.addToneMapping(qj,2),this.addToneMapping(Jj,3),this.addToneMapping(Xj,4),this.addToneMapping(eM,6),this.addToneMapping(tM,7),this.addColorSpace(Gj,Dy(ut,lt)),this.addColorSpace(Wj,Dy(lt,ut))}};if(typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:n}})),typeof window<`u`){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:n}))}catch{}window.__THREE__?(console.warn(`WARNING: Multiple instances of Three.js being imported. Existing: `+window.__THREE__+`, new: 169.19`),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=n}function eP(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function tP(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}export{wt as $,ka as $n,hc as $t,P as A,je as An,M as Ar,Or as At,cd as B,Te as Bn,ut as Bt,Yf as C,hm as Cn,na as Cr,Pf as Ct,Ru as D,ot as Dn,ne as Dr,gt as Dt,ku as E,n as En,te as Er,St as Et,Eu as F,ye as Fn,Ln as Fr,hu as Ft,yt as G,_r as Gn,Ye as Gt,Tl as H,_e as Hn,Op as Ht,hh as I,be as In,Hc as Ir,h as It,le as J,s as Jn,ln as Jt,xt as K,Em as Kn,r as Kt,ga as L,ae as Ln,pf as Lr,y as Lt,Tn as M,Ee as Mn,Gf as Mr,Im as Mt,Du as N,k as Nn,wu as Nr,ru as Nt,c as O,oe as On,T as Or,Rf as Ot,Ou as P,ve as Pn,va as Pr,gu as Pt,eh as Q,Gc as Qn,fi as Qt,_a as R,Ue as Rn,t as Rr,v as Rt,Ii as S,tm as Sn,I as Sr,Jc as St,rh as T,Uf as Tn,re as Tr,Qe as Tt,op as U,pe as Un,Xf as Ut,Bn as V,xe as Vn,Qf as Vt,_i as W,_f as Wn,Je as Wt,ho as X,af as Xn,N as Xt,ue as Y,_t as Yn,j as Yt,Sp as Z,lt as Zn,Ji as Zt,Gn as _,Sa as _n,sp as _r,kl as _t,ym as a,l as an,Xd as ar,F as at,oh as b,Su as bn,Ti as br,Ll as bt,Lp as c,p as cn,jn as cr,Ta as ct,ph as d,Vf as dn,km as dr,jc as dt,Cf as en,Aa as er,gd as et,at as f,Wr as fn,hp as fr,D as ft,zf as g,pa as gn,Pn as gr,bt as gt,wl as h,$a as hn,i as hr,vt as ht,Kf as i,vf as in,mh as ir,tp as it,Bf as j,Ve as jn,Fn as jr,du as jt,Up as k,De as kn,A as kr,pl as kt,Yp as l,d as ln,lr,Mt as lt,nu as m,Ba as mn,Yc as mr,Fp as mt,tP as n,bf as nn,gf as nr,Ft as nt,Ac as o,u as on,Ol as or,E as ot,$N as p,rf as pn,ll as pr,lp as pt,Zf as q,de as qn,di as qt,Cp as r,yf as rn,_d as rr,$d as rt,Xp as s,f as sn,Cl as sr,Wc as st,eP as t,Sf as tn,aa as tr,Dr as tt,Rp as u,YD as un,cf as ur,Ym as ut,sh as v,Oa as vn,uf as vr,kp as vt,la as w,Hn as wn,b as wr,Ze as wt,bi as x,_u as xn,bm as xr,Kc as xt,Zi as y,bp as yn,ii as yr,Cm as yt,Au as z,we as zn,g as zt};