(()=>{var T1=Object.defineProperty;var bM=(o,e)=>{for(var t in e)T1(o,t,{get:e[t],enumerable:!0})};var US={};bM(US,{ACESFilmicToneMapping:()=>nm,AONode:()=>Yg,AddEquation:()=>Rn,AddOperation:()=>Jp,AdditiveAnimationBlendMode:()=>xd,AdditiveBlending:()=>va,AgXToneMapping:()=>im,AlphaFormat:()=>yd,AlwaysCompare:()=>wd,AlwaysDepth:()=>Ma,AlwaysStencilFunc:()=>il,AmbientLight:()=>ua,AmbientLightNode:()=>j_,AnalyticLightNode:()=>vs,AnimationAction:()=>$l,AnimationClip:()=>Ui,AnimationLoader:()=>Ah,AnimationMixer:()=>Fh,AnimationObjectGroup:()=>Dh,AnimationUtils:()=>Mh,ArcCurve:()=>_l,ArrayCamera:()=>Hl,ArrayElementNode:()=>_s,ArrayNode:()=>mf,ArrowHelper:()=>nd,AssignNode:()=>_g,AttachedBindMode:()=>ah,AttributeNode:()=>xf,Audio:()=>Xl,AudioAnalyser:()=>Lh,AudioContext:()=>ma,AudioListener:()=>Ph,AudioLoader:()=>Ch,AxesHelper:()=>id,BackSide:()=>Nt,BasicDepthPacking:()=>fm,BasicEnvironmentNode:()=>Cu,BasicShadowMap:()=>$p,BatchNode:()=>Hg,BatchedMesh:()=>hl,BitcastNode:()=>oo,Bone:()=>qs,BooleanKeyframeTrack:()=>Di,Box2:()=>Hh,Box3:()=>_t,Box3Helper:()=>ed,BoxGeometry:()=>Hs,BoxHelper:()=>Qh,BufferAttribute:()=>Ee,BufferAttributeNode:()=>Ag,BufferGeometry:()=>_e,BufferGeometryLoader:()=>kl,BufferNode:()=>Au,BumpMapNode:()=>Gg,BundleGroup:()=>sb,BypassNode:()=>Cg,ByteType:()=>Js,Cache:()=>si,CacheNode:()=>Rg,Camera:()=>Ws,CameraHelper:()=>Jh,CanvasTexture:()=>xh,CapsuleGeometry:()=>fl,CatmullRomCurve3:()=>yl,CineonToneMapping:()=>tm,CircleGeometry:()=>pl,ClampToEdgeWrapping:()=>Dt,ClippingGroup:()=>hb,Clock:()=>Wl,CodeNode:()=>Gt,Color:()=>q,ColorKeyframeTrack:()=>ra,ColorManagement:()=>xe,ColorSpaceNode:()=>Mu,CompressedArrayTexture:()=>_h,CompressedCubeTexture:()=>yh,CompressedTexture:()=>Dr,CompressedTextureLoader:()=>Eh,ComputeNode:()=>wg,ConeGeometry:()=>Ho,ConstNode:()=>Mn,ConstantAlphaFactor:()=>jx,ConstantColorFactor:()=>Yx,ContextNode:()=>_f,Controls:()=>_a,ConvertNode:()=>rf,CubeCamera:()=>Go,CubeReflectionMapping:()=>rs,CubeRefractionMapping:()=>zr,CubeTexture:()=>Pi,CubeTextureLoader:()=>wh,CubeTextureNode:()=>Bg,CubeUVReflectionMapping:()=>Da,CubicBezierCurve:()=>Wo,CubicBezierCurve3:()=>xl,CubicInterpolant:()=>Ul,CullFaceBack:()=>Xp,CullFaceFront:()=>qp,CullFaceFrontBack:()=>qx,CullFaceNone:()=>Wp,Curve:()=>vn,CurvePath:()=>Tl,CustomBlending:()=>kr,CustomToneMapping:()=>Jx,CylinderGeometry:()=>Fr,Cylindrical:()=>zh,Data3DTexture:()=>Fo,DataArrayTexture:()=>Do,DataTexture:()=>gn,DataTextureLoader:()=>aa,DataUtils:()=>Qi,DebugNode:()=>Pg,DecrementStencilOp:()=>ym,DecrementWrapStencilOp:()=>vm,DefaultLoadingManager:()=>Im,DepthFormat:()=>Hn,DepthStencilFormat:()=>pi,DepthTexture:()=>cn,DetachedBindMode:()=>rm,DirectionalLight:()=>js,DirectionalLightHelper:()=>Zh,DirectionalLightNode:()=>q_,DiscreteInterpolant:()=>Bl,DodecahedronGeometry:()=>ml,DoubleSide:()=>fi,DstAlphaFactor:()=>hd,DstColorFactor:()=>fd,DynamicCopyUsage:()=>uv,DynamicDrawUsage:()=>er,DynamicReadUsage:()=>av,EdgesGeometry:()=>gl,EllipseCurve:()=>Ur,EnvironmentNode:()=>u_,EqualCompare:()=>bd,EqualDepth:()=>Ea,EqualStencilFunc:()=>Mm,EquirectangularReflectionMapping:()=>Ia,EquirectangularRefractionMapping:()=>La,Euler:()=>xn,EventDispatcher:()=>on,EventNode:()=>co,ExpressionNode:()=>Ec,ExternalTexture:()=>vh,ExtrudeGeometry:()=>Sl,FileLoader:()=>jt,Float16BufferAttribute:()=>Vo,Float32BufferAttribute:()=>J,FloatType:()=>nt,Fog:()=>cl,FogExp2:()=>al,FramebufferTexture:()=>zo,FrontFacingNode:()=>Ug,FrontSide:()=>zn,Frustum:()=>$s,FrustumArray:()=>ko,FunctionCallNode:()=>yg,FunctionNode:()=>Nf,FunctionOverloadingNode:()=>T_,GLBufferAttribute:()=>Vh,GLSL1:()=>dv,GLSL3:()=>fv,GLSLNodeParser:()=>ey,GreaterCompare:()=>Md,GreaterDepth:()=>Ra,GreaterEqualCompare:()=>Ed,GreaterEqualDepth:()=>wa,GreaterEqualStencilFunc:()=>Rm,GreaterStencilFunc:()=>Em,GridHelper:()=>Kh,Group:()=>rn,HalfFloatType:()=>ft,HemisphereLight:()=>la,HemisphereLightHelper:()=>Yh,HemisphereLightNode:()=>Z_,IESSpotLight:()=>py,IESSpotLightNode:()=>Y_,IcosahedronGeometry:()=>Ml,ImageBitmapLoader:()=>pa,ImageLoader:()=>Ys,ImageUtils:()=>sl,IncrementStencilOp:()=>_m,IncrementWrapStencilOp:()=>xm,IndexNode:()=>wt,IndirectStorageBufferAttribute:()=>lb,InstanceNode:()=>vf,InstancedBufferAttribute:()=>Bt,InstancedBufferGeometry:()=>Gl,InstancedInterleavedBuffer:()=>Yl,InstancedMesh:()=>Pr,InstancedMeshNode:()=>zg,Int16BufferAttribute:()=>ph,Int32BufferAttribute:()=>mh,Int8BufferAttribute:()=>hh,IntType:()=>Vt,InterleavedBuffer:()=>ci,InterleavedBufferAttribute:()=>Wn,Interpolant:()=>Li,InterpolateDiscrete:()=>ks,InterpolateLinear:()=>zs,InterpolateSmooth:()=>tl,InterpolationSamplingMode:()=>mv,InterpolationSamplingType:()=>pv,InvertStencilOp:()=>Tm,IrradianceNode:()=>jg,JoinNode:()=>ug,KeepStencilOp:()=>Ji,KeyframeTrack:()=>ln,LOD:()=>ul,LatheGeometry:()=>Al,Layers:()=>Uo,LessCompare:()=>nu,LessDepth:()=>Aa,LessEqualCompare:()=>Sd,LessEqualDepth:()=>Gs,LessEqualStencilFunc:()=>Am,LessStencilFunc:()=>Sm,Light:()=>di,LightProbe:()=>da,LightProbeNode:()=>J_,Lighting:()=>iy,LightingContextNode:()=>Kg,LightingModel:()=>ro,LightingNode:()=>pr,LightsNode:()=>Iu,Line:()=>Pn,Line2NodeMaterial:()=>g0,Line3:()=>Wh,LineBasicMaterial:()=>yt,LineBasicNodeMaterial:()=>Qg,LineCurve:()=>Xo,LineCurve3:()=>vl,LineDashedMaterial:()=>Vr,LineDashedNodeMaterial:()=>e_,LineLoop:()=>Ir,LineSegments:()=>an,LinearFilter:()=>Ae,LinearInterpolant:()=>sa,LinearMipMapLinearFilter:()=>om,LinearMipMapNearestFilter:()=>tv,LinearMipmapLinearFilter:()=>Zt,LinearMipmapNearestFilter:()=>Zs,LinearSRGBColorSpace:()=>Ut,LinearToneMapping:()=>Qp,LinearTransfer:()=>Lo,Loader:()=>Mt,LoaderUtils:()=>Xn,LoadingManager:()=>oa,LoopNode:()=>qg,LoopOnce:()=>um,LoopPingPong:()=>dm,LoopRepeat:()=>hm,MOUSE:()=>ns,MRTNode:()=>v_,Material:()=>je,MaterialLoader:()=>fa,MaterialNode:()=>G,MaterialReferenceNode:()=>Og,MathUtils:()=>nr,Matrix2:()=>ga,Matrix3:()=>pe,Matrix4:()=>ee,MaxEquation:()=>jp,MaxMipLevelNode:()=>Lg,MemberNode:()=>dg,Mesh:()=>Ze,MeshBasicMaterial:()=>at,MeshBasicNodeMaterial:()=>r_,MeshDepthMaterial:()=>Dl,MeshDistanceMaterial:()=>Fl,MeshLambertMaterial:()=>na,MeshLambertNodeMaterial:()=>o_,MeshMatcapMaterial:()=>ia,MeshMatcapNodeMaterial:()=>d_,MeshNormalMaterial:()=>ta,MeshNormalNodeMaterial:()=>n_,MeshPhongMaterial:()=>Qo,MeshPhongNodeMaterial:()=>a_,MeshPhysicalMaterial:()=>Wt,MeshPhysicalNodeMaterial:()=>Mf,MeshSSSNodeMaterial:()=>A0,MeshStandardMaterial:()=>Ii,MeshStandardNodeMaterial:()=>Sf,MeshToonMaterial:()=>ea,MeshToonNodeMaterial:()=>h_,MinEquation:()=>Kp,MirroredRepeatWrapping:()=>oi,MixOperation:()=>Zp,ModelNode:()=>An,MorphNode:()=>$g,MultiplyBlending:()=>ba,MultiplyOperation:()=>Na,NearestFilter:()=>We,NearestMipMapLinearFilter:()=>ev,NearestMipMapNearestFilter:()=>Qx,NearestMipmapLinearFilter:()=>ki,NearestMipmapNearestFilter:()=>Hr,NeutralToneMapping:()=>sm,NeverCompare:()=>Td,NeverDepth:()=>Sa,NeverStencilFunc:()=>bm,NoBlending:()=>ss,NoColorSpace:()=>Xi,NoToneMapping:()=>Gi,Node:()=>j,NodeAccess:()=>qt,NodeAttribute:()=>Df,NodeBuilder:()=>Uf,NodeCache:()=>bu,NodeCode:()=>X_,NodeFrame:()=>Bf,NodeFunctionInput:()=>Lu,NodeLoader:()=>gy,NodeMaterial:()=>qe,NodeMaterialLoader:()=>_y,NodeMaterialObserver:()=>ag,NodeObjectLoader:()=>ub,NodeShaderStage:()=>pu,NodeType:()=>iw,NodeUniform:()=>H_,NodeUpdateType:()=>me,NodeUtils:()=>gI,NodeVar:()=>Ff,NodeVarying:()=>W_,NormalAnimationBlendMode:()=>tu,NormalBlending:()=>ri,NormalMapNode:()=>Vg,NotEqualCompare:()=>Ad,NotEqualDepth:()=>Ca,NotEqualStencilFunc:()=>wm,NumberKeyframeTrack:()=>li,Object3D:()=>we,Object3DNode:()=>bt,ObjectLoader:()=>zl,ObjectSpaceNormalMap:()=>pm,OctahedronGeometry:()=>jo,OneFactor:()=>cd,OneMinusConstantAlphaFactor:()=>Zx,OneMinusConstantColorFactor:()=>Kx,OneMinusDstAlphaFactor:()=>dd,OneMinusDstColorFactor:()=>pd,OneMinusSrcAlphaFactor:()=>Po,OneMinusSrcColorFactor:()=>ud,OrthographicCamera:()=>Oi,OutputStructNode:()=>Rf,PCFShadowMap:()=>Yp,PCFSoftShadowMap:()=>$x,PMREMGenerator:()=>c_,PMREMNode:()=>l_,ParameterNode:()=>wf,PassNode:()=>Ki,Path:()=>Br,PerspectiveCamera:()=>ht,PhongLightingModel:()=>bf,PhysicalLightingModel:()=>Pu,Plane:()=>pn,PlaneGeometry:()=>Zo,PlaneHelper:()=>td,PointLight:()=>Ks,PointLightHelper:()=>$h,PointLightNode:()=>G_,PointUVNode:()=>w_,Points:()=>Lr,PointsMaterial:()=>es,PointsNodeMaterial:()=>p_,PolarGridHelper:()=>jh,PolyhedronGeometry:()=>ts,PositionalAudio:()=>Ih,PostProcessing:()=>rb,PosterizeNode:()=>P_,ProjectorLight:()=>my,ProjectorLightNode:()=>K_,PropertyBinding:()=>De,PropertyMixer:()=>ql,PropertyNode:()=>Ie,QuadMesh:()=>ao,QuadraticBezierCurve:()=>qo,QuadraticBezierCurve3:()=>$o,Quaternion:()=>tt,QuaternionKeyframeTrack:()=>ui,QuaternionLinearInterpolant:()=>Ol,RED_GREEN_RGTC2_Format:()=>sc,RED_RGTC1_Format:()=>nc,REVISION:()=>ya,RGBADepthPacking:()=>nv,RGBAFormat:()=>Ft,RGBAIntegerFormat:()=>Ba,RGBA_ASTC_10x10_Format:()=>Ja,RGBA_ASTC_10x5_Format:()=>Ka,RGBA_ASTC_10x6_Format:()=>ja,RGBA_ASTC_10x8_Format:()=>Za,RGBA_ASTC_12x10_Format:()=>Qa,RGBA_ASTC_12x12_Format:()=>ec,RGBA_ASTC_4x4_Format:()=>ka,RGBA_ASTC_5x4_Format:()=>za,RGBA_ASTC_5x5_Format:()=>Ha,RGBA_ASTC_6x5_Format:()=>Wa,RGBA_ASTC_6x6_Format:()=>Xa,RGBA_ASTC_8x5_Format:()=>qa,RGBA_ASTC_8x6_Format:()=>$a,RGBA_ASTC_8x8_Format:()=>Ya,RGBA_BPTC_Format:()=>tc,RGBA_ETC2_EAC_Format:()=>Ga,RGBA_PVRTC_2BPPV1_Format:()=>eu,RGBA_PVRTC_4BPPV1_Format:()=>Ql,RGBA_S3TC_DXT1_Format:()=>$r,RGBA_S3TC_DXT3_Format:()=>Yr,RGBA_S3TC_DXT5_Format:()=>Kr,RGBDepthPacking:()=>iv,RGBFormat:()=>Fa,RGBIntegerFormat:()=>am,RGB_BPTC_SIGNED_Format:()=>cm,RGB_BPTC_UNSIGNED_Format:()=>lm,RGB_ETC1_Format:()=>Oa,RGB_ETC2_Format:()=>Va,RGB_PVRTC_2BPPV1_Format:()=>Jl,RGB_PVRTC_4BPPV1_Format:()=>Zl,RGB_S3TC_DXT1_Format:()=>qr,RGDepthPacking:()=>sv,RGFormat:()=>Hi,RGIntegerFormat:()=>Ua,RTTNode:()=>A_,RangeNode:()=>O_,RawShaderMaterial:()=>Ll,Ray:()=>ai,Raycaster:()=>Gh,RectAreaLight:()=>ha,RectAreaLightNode:()=>$_,RedFormat:()=>Wr,RedIntegerFormat:()=>Xr,ReferenceNode:()=>Cc,ReflectorNode:()=>M_,ReinhardToneMapping:()=>em,RemapNode:()=>yf,RenderOutputNode:()=>Ng,RenderTarget:()=>yn,RenderTarget3D:()=>Uh,RendererReferenceNode:()=>Sg,RendererUtils:()=>_B,RepeatWrapping:()=>Cn,ReplaceStencilOp:()=>gm,ReverseSubtractEquation:()=>ad,RingGeometry:()=>El,RotateNode:()=>f_,SIGNED_RED_GREEN_RGTC2_Format:()=>rc,SIGNED_RED_RGTC1_Format:()=>ic,SRGBColorSpace:()=>ut,SRGBTransfer:()=>he,Scene:()=>Xs,SceneNode:()=>Ai,ScreenNode:()=>Yt,ScriptableNode:()=>B_,ScriptableValueNode:()=>F_,SetNode:()=>hg,ShaderMaterial:()=>wr,ShadowBaseNode:()=>V_,ShadowMaterial:()=>Jo,ShadowNode:()=>If,ShadowNodeMaterial:()=>m_,Shape:()=>Ni,ShapeGeometry:()=>wl,ShapePath:()=>sd,ShapeUtils:()=>Gn,ShortType:()=>Qs,Skeleton:()=>Nr,SkeletonHelper:()=>qh,SkinnedMesh:()=>Cr,SkinningNode:()=>Tf,Source:()=>ii,Sphere:()=>ot,SphereGeometry:()=>Or,Spherical:()=>Gr,SphericalHarmonics3:()=>Vl,SplineCurve:()=>Yo,SplitNode:()=>of,SpotLight:()=>Bi,SpotLightHelper:()=>Xh,SpotLightNode:()=>Du,Sprite:()=>ll,SpriteMaterial:()=>Rr,SpriteNodeMaterial:()=>Af,SpriteSheetUVNode:()=>b_,SrcAlphaFactor:()=>No,SrcAlphaSaturateFactor:()=>md,SrcColorFactor:()=>ld,StackNode:()=>__,StaticCopyUsage:()=>lv,StaticDrawUsage:()=>Mr,StaticReadUsage:()=>ov,StereoCamera:()=>Nh,Storage3DTexture:()=>ab,StorageArrayElementNode:()=>Wg,StorageArrayTexture:()=>cb,StorageBufferAttribute:()=>Cf,StorageBufferNode:()=>Xg,StorageInstancedBufferAttribute:()=>E_,StorageTexture:()=>ob,StorageTextureNode:()=>R_,StreamCopyUsage:()=>hv,StreamDrawUsage:()=>rv,StreamReadUsage:()=>cv,StringKeyframeTrack:()=>Fi,StructNode:()=>x_,StructTypeNode:()=>y_,SubBuildNode:()=>vg,SubtractEquation:()=>od,SubtractiveBlending:()=>Ta,TOUCH:()=>is,TSL:()=>g,TangentSpaceNormalMap:()=>Wi,TempNode:()=>st,TetrahedronGeometry:()=>Rl,Texture:()=>Ge,Texture3DNode:()=>C_,TextureLoader:()=>ca,TextureNode:()=>Jn,TextureSizeNode:()=>Ig,TextureUtils:()=>rd,Timer:()=>kh,TimestampQuery:()=>tr,ToneMappingNode:()=>Mg,ToonOutlinePassNode:()=>D_,TorusGeometry:()=>Cl,TorusKnotGeometry:()=>Nl,Triangle:()=>ni,TriangleFanDrawMode:()=>jr,TriangleStripDrawMode:()=>oc,TrianglesDrawMode:()=>vd,TubeGeometry:()=>Pl,UVMapping:()=>Pa,Uint16BufferAttribute:()=>Bo,Uint32BufferAttribute:()=>Oo,Uint8BufferAttribute:()=>dh,Uint8ClampedBufferAttribute:()=>fh,Uniform:()=>Bh,UniformArrayNode:()=>Dg,UniformGroupNode:()=>pf,UniformNode:()=>so,UniformsGroup:()=>Oh,UnsignedByteType:()=>Ot,UnsignedInt101111Type:()=>jl,UnsignedInt248Type:()=>zi,UnsignedInt5999Type:()=>Kl,UnsignedIntType:()=>Je,UnsignedShort4444Type:()=>gd,UnsignedShort5551Type:()=>_d,UnsignedShortType:()=>os,UserDataNode:()=>N_,VSMShadowMap:()=>xa,VarNode:()=>Ac,VaryingNode:()=>Tg,Vector2:()=>B,Vector3:()=>S,Vector4:()=>ge,VectorKeyframeTrack:()=>hi,VertexColorNode:()=>Jg,VideoFrameTexture:()=>gh,VideoTexture:()=>dl,ViewportDepthNode:()=>Mi,ViewportDepthTextureNode:()=>Zg,ViewportSharedTextureNode:()=>t_,ViewportTextureNode:()=>Nc,VolumeNodeMaterial:()=>C0,WebGL3DRenderTarget:()=>uh,WebGLArrayRenderTarget:()=>lh,WebGLCoordinateSystem:()=>Kt,WebGLCubeRenderTarget:()=>rl,WebGLRenderTarget:()=>Er,WebGPUCoordinateSystem:()=>Nn,WebGPURenderer:()=>ib,WebXRController:()=>ol,WireframeGeometry:()=>Il,WrapAroundEnding:()=>Io,ZeroCurvatureEnding:()=>Bs,ZeroFactor:()=>Vi,ZeroSlopeEnding:()=>Os,ZeroStencilOp:()=>mm,createCanvasElement:()=>Nm,defaultBuildStages:()=>cg,defaultShaderStages:()=>xb,shaderStages:()=>lg,vectorComponents:()=>lo});var ya="180",ns={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},is={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Wp=0,Xp=1,qp=2,qx=3,$p=0,Yp=1,$x=2,xa=3,zn=0,Nt=1,fi=2,ss=0,ri=1,va=2,Ta=3,ba=4,kr=5,Rn=100,od=101,ad=102,Kp=103,jp=104,Vi=200,cd=201,ld=202,ud=203,No=204,Po=205,hd=206,dd=207,fd=208,pd=209,md=210,Yx=211,Kx=212,jx=213,Zx=214,Sa=0,Ma=1,Aa=2,Gs=3,Ea=4,wa=5,Ra=6,Ca=7,Na=0,Zp=1,Jp=2,Gi=0,Qp=1,em=2,tm=3,nm=4,Jx=5,im=6,sm=7,ah="attached",rm="detached",Pa=300,rs=301,zr=302,Ia=303,La=304,Da=306,Cn=1e3,Dt=1001,oi=1002,We=1003,Hr=1004,Qx=1004,ki=1005,ev=1005,Ae=1006,Zs=1007,tv=1007,Zt=1008,om=1008,Ot=1009,Js=1010,Qs=1011,os=1012,Vt=1013,Je=1014,nt=1015,ft=1016,gd=1017,_d=1018,zi=1020,Kl=35902,jl=35899,yd=1021,Fa=1022,Ft=1023,Hn=1026,pi=1027,Wr=1028,Xr=1029,Hi=1030,Ua=1031,am=1032,Ba=1033,qr=33776,$r=33777,Yr=33778,Kr=33779,Zl=35840,Jl=35841,Ql=35842,eu=35843,Oa=36196,Va=37492,Ga=37496,ka=37808,za=37809,Ha=37810,Wa=37811,Xa=37812,qa=37813,$a=37814,Ya=37815,Ka=37816,ja=37817,Za=37818,Ja=37819,Qa=37820,ec=37821,tc=36492,cm=36494,lm=36495,nc=36283,ic=36284,sc=36285,rc=36286,um=2200,hm=2201,dm=2202,ks=2300,zs=2301,tl=2302,Bs=2400,Os=2401,Io=2402,tu=2500,xd=2501,vd=0,oc=1,jr=2,fm=3200,nv=3201,iv=3202,sv=3203,Wi=0,pm=1,Xi="",ut="srgb",Ut="srgb-linear",Lo="linear",he="srgb",mm=0,Ji=7680,gm=7681,_m=7682,ym=7683,xm=34055,vm=34056,Tm=5386,bm=512,Sm=513,Mm=514,Am=515,Em=516,wm=517,Rm=518,il=519,Td=512,nu=513,bd=514,Sd=515,Md=516,Ad=517,Ed=518,wd=519,Mr=35044,er=35048,rv=35040,ov=35045,av=35049,cv=35041,lv=35046,uv=35050,hv=35042,dv="100",fv="300 es",Kt=2e3,Nn=2001,tr={COMPUTE:"compute",RENDER:"render"},pv={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},mv={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},on=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){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,r=i.length;s>8&255]+tn[o>>16&255]+tn[o>>24&255]+"-"+tn[e&255]+tn[e>>8&255]+"-"+tn[e>>16&15|64]+tn[e>>24&255]+"-"+tn[t&63|128]+tn[t>>8&255]+"-"+tn[t>>16&255]+tn[t>>24&255]+tn[n&255]+tn[n>>8&255]+tn[n>>16&255]+tn[n>>24&255]).toLowerCase()}function fe(o,e,t){return Math.max(e,Math.min(t,o))}function gv(o,e){return(o%e+e)%e}function b1(o,e,t,n,i){return n+(o-e)*(i-n)/(t-e)}function S1(o,e,t){return o!==e?(t-o)/(e-o):0}function sh(o,e,t){return(1-t)*o+t*e}function M1(o,e,t,n){return sh(o,e,1-Math.exp(-t*n))}function A1(o,e=1){return e-Math.abs(gv(o,e*2)-e)}function E1(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*(3-2*o))}function w1(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*o*(o*(o*6-15)+10))}function R1(o,e){return o+Math.floor(Math.random()*(e-o+1))}function C1(o,e){return o+Math.random()*(e-o)}function N1(o){return o*(.5-Math.random())}function P1(o){o!==void 0&&(SM=o);let e=SM+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function I1(o){return o*Co}function L1(o){return o*Ar}function D1(o){return(o&o-1)===0&&o!==0}function F1(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function U1(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function B1(o,e,t,n,i){let s=Math.cos,r=Math.sin,a=s(t/2),c=r(t/2),l=s((e+n)/2),u=r((e+n)/2),h=s((e-n)/2),d=r((e-n)/2),f=s((n-e)/2),p=r((n-e)/2);switch(i){case"XYX":o.set(a*u,c*h,c*d,a*l);break;case"YZY":o.set(c*d,a*u,c*h,a*l);break;case"ZXZ":o.set(c*h,c*d,a*u,a*l);break;case"XZX":o.set(a*u,c*p,c*f,a*l);break;case"YXY":o.set(c*f,a*u,c*p,a*l);break;case"ZYZ":o.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function mn(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return o/4294967295;case Uint16Array:return o/65535;case Uint8Array:return o/255;case Int32Array:return Math.max(o/2147483647,-1);case Int16Array:return Math.max(o/32767,-1);case Int8Array:return Math.max(o/127,-1);default:throw new Error("Invalid component type.")}}function ye(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return Math.round(o*4294967295);case Uint16Array:return Math.round(o*65535);case Uint8Array:return Math.round(o*255);case Int32Array:return Math.round(o*2147483647);case Int16Array:return Math.round(o*32767);case Int8Array:return Math.round(o*127);default:throw new Error("Invalid component type.")}}var nr={DEG2RAD:Co,RAD2DEG:Ar,generateUUID:kn,clamp:fe,euclideanModulo:gv,mapLinear:b1,inverseLerp:S1,lerp:sh,damp:M1,pingpong:A1,smoothstep:E1,smootherstep:w1,randInt:R1,randFloat:C1,randFloatSpread:N1,seededRandom:P1,degToRad:I1,radToDeg:L1,isPowerOfTwo:D1,ceilPowerOfTwo:F1,floorPowerOfTwo:U1,setQuaternionFromProperEuler:B1,normalize:ye,denormalize:mn},B=class o{constructor(e=0,t=0){o.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=fe(this.x,e.x,t.x),this.y=fe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=fe(this.x,e,t),this.y=fe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(fe(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),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},tt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,r,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3],d=s[r+0],f=s[r+1],p=s[r+2],m=s[r+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(h!==m||c!==d||l!==f||u!==p){let _=1-a,y=c*d+l*f+u*p+h*m,x=y>=0?1:-1,v=1-y*y;if(v>Number.EPSILON){let M=Math.sqrt(v),w=Math.atan2(M,y*x);_=Math.sin(_*w)/M,a=Math.sin(a*w)/M}let T=a*x;if(c=c*_+d*T,l=l*_+f*T,u=u*_+p*T,h=h*_+m*T,_===1-a){let M=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=M,l*=M,u*=M,h*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,r){let a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[r],d=s[r+1],f=s[r+2],p=s[r+3];return e[t]=a*p+u*h+c*f-l*d,e[t+1]=c*p+u*d+l*h-a*f,e[t+2]=l*p+u*f+a*d-c*h,e[t+3]=u*p-a*h-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,i=e._y,s=e._z,r=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(s/2),d=c(n/2),f=c(i/2),p=c(s/2);switch(r){case"XYZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"YZX":this._x=d*u*h+l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h-d*f*p;break;case"XZY":this._x=d*u*h-l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(r-i)*f}else if(n>a&&n>h){let f=2*Math.sqrt(1+n-a-h);this._w=(u-c)/f,this._x=.25*f,this._y=(i+r)/f,this._z=(s+l)/f}else if(a>h){let f=2*Math.sqrt(1+a-n-h);this._w=(s-l)/f,this._x=(i+r)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+h-n-a);this._w=(r-i)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fe(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,r=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+r*a+i*l-s*c,this._y=i*u+r*c+s*a-n*l,this._z=s*u+r*l+n*c-i*a,this._w=r*u-n*a-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,r=this._w,a=r*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-t;return this._w=f*r+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=r*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+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(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*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}},S=class o{constructor(e=0,t=0,n=0){o.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(MM.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(MM.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,a=e.z,c=e.w,l=2*(r*i-a*n),u=2*(a*t-s*i),h=2*(s*n-r*t);return this.x=t+c*l+r*h-a*u,this.y=n+c*u+a*l-s*h,this.z=i+c*h+s*u-r*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=fe(this.x,e.x,t.x),this.y=fe(this.y,e.y,t.y),this.z=fe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=fe(this.x,e,t),this.y=fe(this.y,e,t),this.z=fe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,r=t.x,a=t.y,c=t.z;return this.x=i*c-s*a,this.y=s*r-n*c,this.z=n*a-i*r,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 jy.copy(this).projectOnVector(e),this.sub(jy)}reflect(e){return this.sub(jy.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(fe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){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}},jy=new S,MM=new tt,pe=class o{constructor(e,t,n,i,s,r,a,c,l){o.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,r,a,c,l)}set(e,t,n,i,s,r,a,c,l){let u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=r,u[8]=l,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,i=t.elements,s=this.elements,r=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],d=n[2],f=n[5],p=n[8],m=i[0],_=i[3],y=i[6],x=i[1],v=i[4],T=i[7],M=i[2],w=i[5],E=i[8];return s[0]=r*m+a*x+c*M,s[3]=r*_+a*v+c*w,s[6]=r*y+a*T+c*E,s[1]=l*m+u*x+h*M,s[4]=l*_+u*v+h*w,s[7]=l*y+u*T+h*E,s[2]=d*m+f*x+p*M,s[5]=d*_+f*v+p*w,s[8]=d*y+f*T+p*E,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],i=e[2],s=e[3],r=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*r*u-t*a*l-n*s*u+n*a*c+i*s*l-i*r*c}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*r-a*l,d=a*c-u*s,f=l*s-r*c,p=t*h+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=h*m,e[1]=(i*l-u*n)*m,e[2]=(a*n-i*r)*m,e[3]=d*m,e[4]=(u*t-i*c)*m,e[5]=(i*s-a*t)*m,e[6]=f*m,e[7]=(n*c-l*t)*m,e[8]=(r*t-n*s)*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,i,s,r,a){let c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*r+l*a)+r+e,-i*l,i*c,-i*(-l*r+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Zy.makeScale(e,t)),this}rotate(e){return this.premultiply(Zy.makeRotation(-e)),this}translate(e,t){return this.premultiply(Zy.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 i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){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)}},Zy=new pe;function Cm(o){for(let e=o.length-1;e>=0;--e)if(o[e]>=65535)return!0;return!1}var O1={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function el(o,e){return new O1[o](e)}function ch(o){return document.createElementNS("http://www.w3.org/1999/xhtml",o)}function Nm(){let o=ch("canvas");return o.style.display="block",o}var AM={};function _n(o){o in AM||(AM[o]=!0,console.warn(o))}var EM=new pe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wM=new pe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function V1(){let o={enabled:!0,workingColorSpace:Ut,spaces:{},convert:function(i,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===he&&(i.r=Vs(i.r),i.g=Vs(i.g),i.b=Vs(i.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===he&&(i.r=nl(i.r),i.g=nl(i.g),i.b=nl(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Xi?Lo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,r){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return _n("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),o.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return _n("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),o.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return o.define({[Ut]:{primaries:e,whitePoint:n,transfer:Lo,toXYZ:EM,fromXYZ:wM,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ut},outputColorSpaceConfig:{drawingBufferColorSpace:ut}},[ut]:{primaries:e,whitePoint:n,transfer:he,toXYZ:EM,fromXYZ:wM,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ut}}}),o}var xe=V1();function Vs(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function nl(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}var Dc,sl=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Dc===void 0&&(Dc=ch("canvas")),Dc.width=e.width,Dc.height=e.height;let i=Dc.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Dc}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){let t=ch("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r1),this.pmremVersion=0}get width(){return this.source.getSize(Qy).x}get height(){return this.source.getSize(Qy).y}get depth(){return this.source.getSize(Qy).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}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.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Pa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Cn:e.x=e.x-Math.floor(e.x);break;case Dt:e.x=e.x<0?0:1;break;case oi:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Cn:e.y=e.y-Math.floor(e.y);break;case Dt:e.y=e.y<0?0:1;break;case oi:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ge.DEFAULT_IMAGE=null;Ge.DEFAULT_MAPPING=Pa;Ge.DEFAULT_ANISOTROPY=1;var ge=class o{constructor(e=0,t=0,n=0,i=1){o.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,i,s,c=e.elements,l=c[0],u=c[4],h=c[8],d=c[1],f=c[5],p=c[9],m=c[2],_=c[6],y=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-m)<.01&&Math.abs(p-_)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+m)<.1&&Math.abs(p+_)<.1&&Math.abs(l+f+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(l+1)/2,T=(f+1)/2,M=(y+1)/2,w=(u+d)/4,E=(h+m)/4,A=(p+_)/4;return v>T&&v>M?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=w/n,s=E/n):T>M?T<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),n=w/i,s=A/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=E/s,i=A/s),this.set(n,i,s,t),this}let x=Math.sqrt((_-p)*(_-p)+(h-m)*(h-m)+(d-u)*(d-u));return Math.abs(x)<.001&&(x=1),this.x=(_-p)/x,this.y=(h-m)/x,this.z=(d-u)/x,this.w=Math.acos((l+f+y-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=fe(this.x,e.x,t.x),this.y=fe(this.y,e.y,t.y),this.z=fe(this.z,e.z,t.z),this.w=fe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=fe(this.x,e,t),this.y=fe(this.y,e,t),this.z=fe(this.z,e,t),this.w=fe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},yn=class extends on{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ae,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ge(0,0,e,t),this.scissorTest=!1,this.viewport=new ge(0,0,e,t);let i={width:e,height:t,depth:n.depth},s=new Ge(i);this.textures=[];let r=n.count;for(let a=0;a1;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=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,wi),wi.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(Wu),ep.subVectors(this.max,Wu),Fc.subVectors(e.a,Wu),Uc.subVectors(e.b,Wu),Bc.subVectors(e.c,Wu),_r.subVectors(Uc,Fc),yr.subVectors(Bc,Uc),go.subVectors(Fc,Bc);let t=[0,-_r.z,_r.y,0,-yr.z,yr.y,0,-go.z,go.y,_r.z,0,-_r.x,yr.z,0,-yr.x,go.z,0,-go.x,-_r.y,_r.x,0,-yr.y,yr.x,0,-go.y,go.x,0];return!ex(t,Fc,Uc,Bc,ep)||(t=[1,0,0,0,1,0,0,0,1],!ex(t,Fc,Uc,Bc,ep))?!1:(tp.crossVectors(_r,yr),t=[tp.x,tp.y,tp.z],ex(t,Fc,Uc,Bc,ep))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(wi).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:(Ns[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ns[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ns[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ns[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ns[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ns[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ns[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ns[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ns),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ns=[new S,new S,new S,new S,new S,new S,new S,new S],wi=new S,Qf=new _t,Fc=new S,Uc=new S,Bc=new S,_r=new S,yr=new S,go=new S,Wu=new S,ep=new S,tp=new S,_o=new S;function ex(o,e,t,n,i){for(let s=0,r=o.length-3;s<=r;s+=3){_o.fromArray(o,s);let a=i.x*Math.abs(_o.x)+i.y*Math.abs(_o.y)+i.z*Math.abs(_o.z),c=e.dot(_o),l=t.dot(_o),u=n.dot(_o);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var z1=new _t,Xu=new S,tx=new S,ot=class{constructor(e=new S,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?n.copy(t):z1.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Xu.subVectors(e,this.center);let t=Xu.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Xu,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(tx.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xu.copy(e.center).add(tx)),this.expandByPoint(Xu.copy(e.center).sub(tx))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Ps=new S,nx=new S,np=new S,xr=new S,ix=new S,ip=new S,sx=new S,ai=class{constructor(e=new S,t=new S(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,Ps)),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=Ps.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ps.copy(this.origin).addScaledVector(this.direction,t),Ps.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){nx.copy(e).add(t).multiplyScalar(.5),np.copy(t).sub(e).normalize(),xr.copy(this.origin).sub(nx);let s=e.distanceTo(t)*.5,r=-this.direction.dot(np),a=xr.dot(this.direction),c=-xr.dot(np),l=xr.lengthSq(),u=Math.abs(1-r*r),h,d,f,p;if(u>0)if(h=r*c-a,d=r*a-c,p=s*u,h>=0)if(d>=-p)if(d<=p){let m=1/u;h*=m,d*=m,f=h*(h+r*d+2*a)+d*(r*h+d+2*c)+l}else d=s,h=Math.max(0,-(r*d+a)),f=-h*h+d*(d+2*c)+l;else d=-s,h=Math.max(0,-(r*d+a)),f=-h*h+d*(d+2*c)+l;else d<=-p?(h=Math.max(0,-(-r*s+a)),d=h>0?-s:Math.min(Math.max(-s,-c),s),f=-h*h+d*(d+2*c)+l):d<=p?(h=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(h=Math.max(0,-(r*s+a)),d=h>0?s:Math.min(Math.max(-s,-c),s),f=-h*h+d*(d+2*c)+l);else d=r>0?-s:s,h=Math.max(0,-(r*d+a)),f=-h*h+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(nx).addScaledVector(np,d),f}intersectSphere(e,t){Ps.subVectors(e.center,this.origin);let n=Ps.dot(this.direction),i=Ps.dot(Ps)-n*n,s=e.radius*e.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,c=n+r;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1: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,i,s,r,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(s=(e.min.y-d.y)*u,r=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,r=(e.min.y-d.y)*u),n>r||s>i||((s>n||isNaN(n))&&(n=s),(r=0?(a=(e.min.z-d.z)*h,c=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,c=(e.min.z-d.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ps)!==null}intersectTriangle(e,t,n,i,s){ix.subVectors(t,e),ip.subVectors(n,e),sx.crossVectors(ix,ip);let r=this.direction.dot(sx),a;if(r>0){if(i)return null;a=1}else if(r<0)a=-1,r=-r;else return null;xr.subVectors(this.origin,e);let c=a*this.direction.dot(ip.crossVectors(xr,ip));if(c<0)return null;let l=a*this.direction.dot(ix.cross(xr));if(l<0||c+l>r)return null;let u=-a*xr.dot(sx);return u<0?null:this.at(u/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ee=class o{constructor(e,t,n,i,s,r,a,c,l,u,h,d,f,p,m,_){o.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,r,a,c,l,u,h,d,f,p,m,_)}set(e,t,n,i,s,r,a,c,l,u,h,d,f,p,m,_){let y=this.elements;return y[0]=e,y[4]=t,y[8]=n,y[12]=i,y[1]=s,y[5]=r,y[9]=a,y[13]=c,y[2]=l,y[6]=u,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=_,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 o().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,i=1/Oc.setFromMatrixColumn(e,0).length(),s=1/Oc.setFromMatrixColumn(e,1).length(),r=1/Oc.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,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,i=e.y,s=e.z,r=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=r*u,f=r*h,p=a*u,m=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=f+p*l,t[5]=d-m*l,t[9]=-a*c,t[2]=m-d*l,t[6]=p+f*l,t[10]=r*c}else if(e.order==="YXZ"){let d=c*u,f=c*h,p=l*u,m=l*h;t[0]=d+m*a,t[4]=p*a-f,t[8]=r*l,t[1]=r*h,t[5]=r*u,t[9]=-a,t[2]=f*a-p,t[6]=m+d*a,t[10]=r*c}else if(e.order==="ZXY"){let d=c*u,f=c*h,p=l*u,m=l*h;t[0]=d-m*a,t[4]=-r*h,t[8]=p+f*a,t[1]=f+p*a,t[5]=r*u,t[9]=m-d*a,t[2]=-r*l,t[6]=a,t[10]=r*c}else if(e.order==="ZYX"){let d=r*u,f=r*h,p=a*u,m=a*h;t[0]=c*u,t[4]=p*l-f,t[8]=d*l+m,t[1]=c*h,t[5]=m*l+d,t[9]=f*l-p,t[2]=-l,t[6]=a*c,t[10]=r*c}else if(e.order==="YZX"){let d=r*c,f=r*l,p=a*c,m=a*l;t[0]=c*u,t[4]=m-d*h,t[8]=p*h+f,t[1]=h,t[5]=r*u,t[9]=-a*u,t[2]=-l*u,t[6]=f*h+p,t[10]=d-m*h}else if(e.order==="XZY"){let d=r*c,f=r*l,p=a*c,m=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=d*h+m,t[5]=r*u,t[9]=f*h-p,t[2]=p*h-f,t[6]=a*u,t[10]=m*h+d}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(H1,e,W1)}lookAt(e,t,n){let i=this.elements;return On.subVectors(e,t),On.lengthSq()===0&&(On.z=1),On.normalize(),vr.crossVectors(n,On),vr.lengthSq()===0&&(Math.abs(n.z)===1?On.x+=1e-4:On.z+=1e-4,On.normalize(),vr.crossVectors(n,On)),vr.normalize(),sp.crossVectors(On,vr),i[0]=vr.x,i[4]=sp.x,i[8]=On.x,i[1]=vr.y,i[5]=sp.y,i[9]=On.y,i[2]=vr.z,i[6]=sp.z,i[10]=On.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],d=n[9],f=n[13],p=n[2],m=n[6],_=n[10],y=n[14],x=n[3],v=n[7],T=n[11],M=n[15],w=i[0],E=i[4],A=i[8],N=i[12],L=i[1],V=i[5],H=i[9],W=i[13],X=i[2],ae=i[6],oe=i[10],Le=i[14],He=i[3],ve=i[7],Me=i[11],Ke=i[15];return s[0]=r*w+a*L+c*X+l*He,s[4]=r*E+a*V+c*ae+l*ve,s[8]=r*A+a*H+c*oe+l*Me,s[12]=r*N+a*W+c*Le+l*Ke,s[1]=u*w+h*L+d*X+f*He,s[5]=u*E+h*V+d*ae+f*ve,s[9]=u*A+h*H+d*oe+f*Me,s[13]=u*N+h*W+d*Le+f*Ke,s[2]=p*w+m*L+_*X+y*He,s[6]=p*E+m*V+_*ae+y*ve,s[10]=p*A+m*H+_*oe+y*Me,s[14]=p*N+m*W+_*Le+y*Ke,s[3]=x*w+v*L+T*X+M*He,s[7]=x*E+v*V+T*ae+M*ve,s[11]=x*A+v*H+T*oe+M*Me,s[15]=x*N+v*W+T*Le+M*Ke,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],i=e[8],s=e[12],r=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],d=e[10],f=e[14],p=e[3],m=e[7],_=e[11],y=e[15];return p*(+s*c*h-i*l*h-s*a*d+n*l*d+i*a*f-n*c*f)+m*(+t*c*f-t*l*d+s*r*d-i*r*f+i*l*u-s*c*u)+_*(+t*l*h-t*a*f-s*r*h+n*r*f+s*a*u-n*l*u)+y*(-i*a*u-t*c*h+t*a*d+i*r*h-n*r*d+n*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],d=e[10],f=e[11],p=e[12],m=e[13],_=e[14],y=e[15],x=h*_*l-m*d*l+m*c*f-a*_*f-h*c*y+a*d*y,v=p*d*l-u*_*l-p*c*f+r*_*f+u*c*y-r*d*y,T=u*m*l-p*h*l+p*a*f-r*m*f-u*a*y+r*h*y,M=p*h*c-u*m*c-p*a*d+r*m*d+u*a*_-r*h*_,w=t*x+n*v+i*T+s*M;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/w;return e[0]=x*E,e[1]=(m*d*s-h*_*s-m*i*f+n*_*f+h*i*y-n*d*y)*E,e[2]=(a*_*s-m*c*s+m*i*l-n*_*l-a*i*y+n*c*y)*E,e[3]=(h*c*s-a*d*s-h*i*l+n*d*l+a*i*f-n*c*f)*E,e[4]=v*E,e[5]=(u*_*s-p*d*s+p*i*f-t*_*f-u*i*y+t*d*y)*E,e[6]=(p*c*s-r*_*s-p*i*l+t*_*l+r*i*y-t*c*y)*E,e[7]=(r*d*s-u*c*s+u*i*l-t*d*l-r*i*f+t*c*f)*E,e[8]=T*E,e[9]=(p*h*s-u*m*s-p*n*f+t*m*f+u*n*y-t*h*y)*E,e[10]=(r*m*s-p*a*s+p*n*l-t*m*l-r*n*y+t*a*y)*E,e[11]=(u*a*s-r*h*s-u*n*l+t*h*l+r*n*f-t*a*f)*E,e[12]=M*E,e[13]=(u*m*i-p*h*i+p*n*d-t*m*d-u*n*_+t*h*_)*E,e[14]=(p*a*i-r*m*i-p*n*c+t*m*c+r*n*_-t*a*_)*E,e[15]=(r*h*i-u*a*i+u*n*c-t*h*c-r*n*d+t*a*d)*E,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){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),i=Math.sin(t),s=1-n,r=e.x,a=e.y,c=e.z,l=s*r,u=s*a;return this.set(l*r+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*r,0,l*c-i*a,u*c+i*r,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,r=t._y,a=t._z,c=t._w,l=s+s,u=r+r,h=a+a,d=s*l,f=s*u,p=s*h,m=r*u,_=r*h,y=a*h,x=c*l,v=c*u,T=c*h,M=n.x,w=n.y,E=n.z;return i[0]=(1-(m+y))*M,i[1]=(f+T)*M,i[2]=(p-v)*M,i[3]=0,i[4]=(f-T)*w,i[5]=(1-(d+y))*w,i[6]=(_+x)*w,i[7]=0,i[8]=(p+v)*E,i[9]=(_-x)*E,i[10]=(1-(d+m))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=Oc.set(i[0],i[1],i[2]).length(),r=Oc.set(i[4],i[5],i[6]).length(),a=Oc.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ri.copy(this);let l=1/s,u=1/r,h=1/a;return Ri.elements[0]*=l,Ri.elements[1]*=l,Ri.elements[2]*=l,Ri.elements[4]*=u,Ri.elements[5]*=u,Ri.elements[6]*=u,Ri.elements[8]*=h,Ri.elements[9]*=h,Ri.elements[10]*=h,t.setFromRotationMatrix(Ri),n.x=s,n.y=r,n.z=a,this}makePerspective(e,t,n,i,s,r,a=Kt,c=!1){let l=this.elements,u=2*s/(t-e),h=2*s/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i),p,m;if(c)p=s/(r-s),m=r*s/(r-s);else if(a===Kt)p=-(r+s)/(r-s),m=-2*r*s/(r-s);else if(a===Nn)p=-r/(r-s),m=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,r,a=Kt,c=!1){let l=this.elements,u=2/(t-e),h=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i),p,m;if(c)p=1/(r-s),m=r/(r-s);else if(a===Kt)p=-2/(r-s),m=-(r+s)/(r-s);else if(a===Nn)p=-1/(r-s),m=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=h,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){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}},Oc=new S,Ri=new ee,H1=new S(0,0,0),W1=new S(1,1,1),vr=new S,sp=new S,On=new S,RM=new ee,CM=new tt,xn=class o{constructor(e=0,t=0,n=0,i=o.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],r=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-fe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-fe(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(fe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-fe(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return RM.makeRotationFromQuaternion(e),this.setFromRotationMatrix(RM,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return CM.setFromEuler(this),this.setFromQuaternion(CM,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}};xn.DEFAULT_ORDER="XYZ";var Uo=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Ci.subVectors(i,t),Ls.subVectors(n,t),ox.subVectors(e,t);let r=Ci.dot(Ci),a=Ci.dot(Ls),c=Ci.dot(ox),l=Ls.dot(Ls),u=Ls.dot(ox),h=r*l-a*a;if(h===0)return s.set(0,0,0),null;let d=1/h,f=(l*c-a*u)*d,p=(r*u-a*c)*d;return s.set(1-f-p,p,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ds)===null?!1:Ds.x>=0&&Ds.y>=0&&Ds.x+Ds.y<=1}static getInterpolation(e,t,n,i,s,r,a,c){return this.getBarycoord(e,t,n,i,Ds)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Ds.x),c.addScaledVector(r,Ds.y),c.addScaledVector(a,Ds.z),c)}static getInterpolatedAttribute(e,t,n,i,s,r){return ux.setScalar(0),hx.setScalar(0),dx.setScalar(0),ux.fromBufferAttribute(e,t),hx.fromBufferAttribute(e,n),dx.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(ux,s.x),r.addScaledVector(hx,s.y),r.addScaledVector(dx,s.z),r}static isFrontFacing(e,t,n,i){return Ci.subVectors(n,t),Ls.subVectors(e,t),Ci.cross(Ls).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ci.subVectors(this.c,this.b),Ls.subVectors(this.a,this.b),Ci.cross(Ls).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return o.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return o.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return o.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return o.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return o.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,r,a;kc.subVectors(i,n),zc.subVectors(s,n),ax.subVectors(e,n);let c=kc.dot(ax),l=zc.dot(ax);if(c<=0&&l<=0)return t.copy(n);cx.subVectors(e,i);let u=kc.dot(cx),h=zc.dot(cx);if(u>=0&&h<=u)return t.copy(i);let d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return r=c/(c-u),t.copy(n).addScaledVector(kc,r);lx.subVectors(e,s);let f=kc.dot(lx),p=zc.dot(lx);if(p>=0&&f<=p)return t.copy(s);let m=f*l-c*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(zc,a);let _=u*p-f*h;if(_<=0&&h-u>=0&&f-p>=0)return FM.subVectors(s,i),a=(h-u)/(h-u+(f-p)),t.copy(i).addScaledVector(FM,a);let y=1/(_+m+d);return r=m*y,a=d*y,t.copy(n).addScaledVector(kc,r).addScaledVector(zc,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},NA={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Tr={h:0,s:0,l:0},op={h:0,s:0,l:0};function fx(o,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?o+(e-o)*6*t:t<1/2?e:t<2/3?o+(e-o)*6*(2/3-t):o}var q=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 i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ut){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=xe.workingColorSpace){return this.r=e,this.g=t,this.b=n,xe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=xe.workingColorSpace){if(e=gv(e,1),t=fe(t,0,1),n=fe(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=fx(r,s,e+1/3),this.g=fx(r,s,e),this.b=fx(r,s,e-1/3)}return xe.colorSpaceToWorking(this,i),this}setStyle(e,t=ut){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ut){let n=NA[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vs(e.r),this.g=Vs(e.g),this.b=Vs(e.b),this}copyLinearToSRGB(e){return this.r=nl(e.r),this.g=nl(e.g),this.b=nl(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ut){return xe.workingToColorSpace(nn.copy(this),e),Math.round(fe(nn.r*255,0,255))*65536+Math.round(fe(nn.g*255,0,255))*256+Math.round(fe(nn.b*255,0,255))}getHexString(e=ut){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xe.workingColorSpace){xe.workingToColorSpace(nn.copy(this),t);let n=nn.r,i=nn.g,s=nn.b,r=Math.max(n,i,s),a=Math.min(n,i,s),c,l,u=(a+r)/2;if(a===r)c=0,l=0;else{let h=r-a;switch(l=u<=.5?h/(r+a):h/(2-r-a),r){case n:c=(i-s)/h+(i0!=e>0&&this.version++,this._alphaTest=e}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 i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ri&&(n.blending=this.blending),this.side!==zn&&(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!==No&&(n.blendSrc=this.blendSrc),this.blendDst!==Po&&(n.blendDst=this.blendDst),this.blendEquation!==Rn&&(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!==Gs&&(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!==il&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ji&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ji&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ji&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){let r=[];for(let a in s){let c=s[a];delete c.metadata,r.push(c)}return r}if(t){let s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}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 i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},at=class extends je{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new q(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 xn,this.combine=Na,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}},Us=j1();function j1(){let o=new ArrayBuffer(4),e=new Float32Array(o),t=new Uint32Array(o),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}let s=new Uint32Array(2048),r=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;!(l&8388608);)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:r,offsetTable:a}}function wn(o){Math.abs(o)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),o=fe(o,-65504,65504),Us.floatView[0]=o;let e=Us.uint32View[0],t=e>>23&511;return Us.baseTable[t]+((e&8388607)>>Us.shiftTable[t])}function nh(o){let e=o>>10;return Us.uint32View[0]=Us.mantissaTable[Us.offsetTable[e]+(o&1023)]+Us.exponentTable[e],Us.floatView[0]}var Qi=class{static toHalfFloat(e){return wn(e)}static fromHalfFloat(e){return nh(e)}},Ct=new S,ap=new B,Z1=0,Ee=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Z1++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Mr,this.updateRanges=[],this.gpuType=nt,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 i=0,s=this.itemSize;it.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t);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 S(-1/0,-1/0,-1/0),new S(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let i={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,d=l.length;h0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let i=e.attributes;for(let l in i){let u=i[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],h=s[l];for(let d=0,f=h.length;d0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s(e.far-e.near)**2))&&(UM.copy(s).invert(),yo.copy(e.ray).applyMatrix4(UM),!(n.boundingBox!==null&&yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,yo)))}_computeIntersections(e,t,n){let i,s=this.geometry,r=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(r))for(let p=0,m=d.length;pt.far?null:{distance:l,point:fp.clone(),object:o}}function pp(o,e,t,n,i,s,r,a,c,l){o.getVertexPosition(a,lp),o.getVertexPosition(c,up),o.getVertexPosition(l,hp);let u=Q1(o,e,t,n,lp,up,hp,OM);if(u){let h=new S;ni.getBarycoord(OM,lp,up,hp,h),i&&(u.uv=ni.getInterpolatedAttribute(i,a,c,l,h,new B)),s&&(u.uv1=ni.getInterpolatedAttribute(s,a,c,l,h,new B)),r&&(u.normal=ni.getInterpolatedAttribute(r,a,c,l,h,new S),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new S,materialIndex:0};ni.getNormal(lp,up,hp,d.normal),u.face=d,u.barycoord=h}return u}var Hs=class o extends _e{constructor(e=1,t=1,n=1,i=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};let a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);let c=[],l=[],u=[],h=[],d=0,f=0;p("z","y","x",-1,-1,n,t,e,r,s,0),p("z","y","x",1,-1,n,t,-e,r,s,1),p("x","z","y",1,1,e,n,t,i,r,2),p("x","z","y",1,-1,e,n,-t,i,r,3),p("x","y","z",1,-1,e,t,n,i,s,4),p("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(c),this.setAttribute("position",new J(l,3)),this.setAttribute("normal",new J(u,3)),this.setAttribute("uv",new J(h,2));function p(m,_,y,x,v,T,M,w,E,A,N){let L=T/E,V=M/A,H=T/2,W=M/2,X=w/2,ae=E+1,oe=A+1,Le=0,He=0,ve=new S;for(let Me=0;Me0?1:-1,u.push(ve.x,ve.y,ve.z),h.push(ct/E),h.push(1-Me/A),Le+=1}}for(let Me=0;Me0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Ws=class extends we{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ee,this.projectionMatrix=new ee,this.projectionMatrixInverse=new ee,this.coordinateSystem=Kt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},br=new S,VM=new B,GM=new B,ht=class extends Ws{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Ar*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Co*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ar*2*Math.atan(Math.tan(Co*.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){br.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(br.x,br.y).multiplyScalar(-e/br.z),br.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(br.x,br.y).multiplyScalar(-e/br.z)}getViewSize(e,t){return this.getViewBounds(e,VM,GM),t.subVectors(GM,VM)}setViewOffset(e,t,n,i,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Co*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i,r=this.view;if(this.view!==null&&this.view.enabled){let c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*i/c,t-=r.offsetY*n/l,i*=r.width/c,n*=r.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),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}},Wc=-90,Xc=1,Go=class extends we{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new ht(Wc,Xc,e,t);i.layers=this.layers,this.add(i);let s=new ht(Wc,Xc,e,t);s.layers=this.layers,this.add(s);let r=new ht(Wc,Xc,e,t);r.layers=this.layers,this.add(r);let a=new ht(Wc,Xc,e,t);a.layers=this.layers,this.add(a);let c=new ht(Wc,Xc,e,t);c.layers=this.layers,this.add(c);let l=new ht(Wc,Xc,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,s,r,a,c]=t;for(let l of t)this.remove(l);if(e===Kt)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Nn)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,r,a,c,l,u]=this.children,h=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,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,r),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},Pi=class extends Ge{constructor(e=[],t=rs,n,i,s,r,a,c,l,u){super(e,t,n,i,s,r,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},rl=class extends Er{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Pi(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},i=new Hs(5,5,5),s=new wr({name:"CubemapFromEquirect",uniforms:Pm(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Nt,blending:ss});s.uniforms.tEquirect.value=t;let r=new Ze(i,s),a=t.minFilter;return t.minFilter===Zt&&(t.minFilter=Ae),new Go(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(s)}},rn=class extends we{constructor(){super(),this.isGroup=!0,this.type="Group"}},iP={type:"move"},ol=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new rn,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 rn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new S,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new S),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new rn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new S,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new S),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 i=null,s=null,r=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),y=this._getHandJoint(l,m);_!==null&&(y.matrix.fromArray(_.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=_.radius),y.visible=_!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(iP)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new rn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},al=class o{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new q(e),this.density=t}clone(){return new o(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},cl=class o{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new q(e),this.near=t,this.far=n}clone(){return new o(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Xs=class extends we{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 xn,this.environmentIntensity=1,this.environmentRotation=new xn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__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}},ci=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Mr,this.updateRanges=[],this.version=0,this.uuid=kn()}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 i=0,s=this.stride;ie.far||t.push({distance:c,point:Yu.clone(),uv:ni.getInterpolation(Yu,mp,ju,gp,kM,gx,zM,new B),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 _p(o,e,t,n,i,s){Kc.subVectors(o,t).addScalar(.5).multiply(n),i!==void 0?(Ku.x=s*Kc.x-i*Kc.y,Ku.y=i*Kc.x+s*Kc.y):Ku.copy(Kc),o.copy(e),o.x+=Ku.x,o.y+=Ku.y,o.applyMatrix4(PA)}var yp=new S,HM=new S,ul=class extends we{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){yp.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(yp);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){yp.setFromMatrixPosition(e.matrixWorld),HM.setFromMatrixPosition(this.matrixWorld);let n=yp.distanceTo(HM)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=r)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i1?null:t.copy(e.start).addScaledVector(n,s)}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||cP.getNormalMatrix(e),i=this.coplanarPoint(xx).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},xo=new ot,lP=new B(.5,.5),Tp=new S,$s=class{constructor(e=new pn,t=new pn,n=new pn,i=new pn,s=new pn,r=new pn){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),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=Kt,n=!1){let i=this.planes,s=e.elements,r=s[0],a=s[1],c=s[2],l=s[3],u=s[4],h=s[5],d=s[6],f=s[7],p=s[8],m=s[9],_=s[10],y=s[11],x=s[12],v=s[13],T=s[14],M=s[15];if(i[0].setComponents(l-r,f-u,y-p,M-x).normalize(),i[1].setComponents(l+r,f+u,y+p,M+x).normalize(),i[2].setComponents(l+a,f+h,y+m,M+v).normalize(),i[3].setComponents(l-a,f-h,y-m,M-v).normalize(),n)i[4].setComponents(c,d,_,T).normalize(),i[5].setComponents(l-c,f-d,y-_,M-T).normalize();else if(i[4].setComponents(l-c,f-d,y-_,M-T).normalize(),t===Kt)i[5].setComponents(l+c,f+d,y+_,M+T).normalize();else if(t===Nn)i[5].setComponents(c,d,_,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),xo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xo)}intersectsSprite(e){xo.center.set(0,0,0);let t=lP.distanceTo(e.center);return xo.radius=.7071067811865476+t,xo.applyMatrix4(e.matrixWorld),this.intersectsSphere(xo)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,Tp.y=i.normal.y>0?e.max.y:e.min.y,Tp.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Tp)<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)}},ji=new ee,Zi=new $s,ko=class o{constructor(){this.coordinateSystem=Kt}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});let a=s[this.index];r.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}},En=new ee,dP=new q(1,1,1),JM=new $s,fP=new ko,bp=new _t,vo=new ot,Qu=new S,QM=new S,pP=new S,Tx=new Dx,sn=new Ze,Sp=[];function mP(o,e,t=0){let n=e.itemSize;if(o.isInterleavedBufferAttribute||o.array.constructor!==e.array.constructor){let i=o.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Ee(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=e.getAttribute(n),s=t.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:e},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(vx),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let s=this._matricesTexture;En.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;let r=this._colorsTexture;return r&&(dP.toArray(r.image.data,i*4),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let r=e.getIndex();if(r!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?r.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(vx),c=this._availableGeometryIds.shift(),s[c]=i):(c=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(c,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),r=t.getIndex(),a=this._geometryInfo[e];if(i&&r.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(let u in n.attributes){let h=t.getAttribute(u),d=n.getAttribute(u);mP(h,d,c);let f=h.itemSize;for(let p=h.count,m=l;p=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let i=0,s=n.length;ia).sort((r,a)=>n[r].vertexStart-n[a].vertexStart),s=this.geometry;for(let r=0,a=n.length;r=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){let s=new _t,r=n.index,a=n.attributes.position;for(let c=i.start,l=i.start+i.count;c=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){let s=new ot;this.getBoundingBoxAt(e,bp),bp.getCenter(s.center);let r=n.index,a=n.attributes.position,c=0;for(let l=i.start,u=i.start+i.count;la.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new _e,this._initializeGeometry(s));let r=this.geometry;s.index&&To(s.index.array,r.index.array);for(let a in s.attributes)To(s.attributes[a].array,r.attributes[a].array)}raycast(e,t){let n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,r=this.geometry;sn.material=this.material,sn.geometry.index=r.index,sn.geometry.attributes=r.attributes,sn.geometry.boundingBox===null&&(sn.geometry.boundingBox=new _t),sn.geometry.boundingSphere===null&&(sn.geometry.boundingSphere=new ot);for(let a=0,c=n.length;a({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.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(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let r=i.getIndex(),a=r===null?1:r.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,p=f.image.data,m=n.isArrayCamera?fP:JM;d&&!n.isArrayCamera&&(En.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),JM.setFromProjectionMatrix(En,n.coordinateSystem,n.reversedDepth));let _=0;if(this.sortObjects){En.copy(this.matrixWorld).invert(),Qu.setFromMatrixPosition(n.matrixWorld).applyMatrix4(En),QM.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(En);for(let v=0,T=c.length;v0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;sn)return;bx.applyMatrix4(o.matrixWorld);let l=e.ray.origin.distanceTo(bx);if(!(le.far))return{distance:l,point:tA.clone().applyMatrix4(o.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:o}}var nA=new S,iA=new S,an=class extends Pn{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 i=0,s=t.count;i0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;si.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}var dl=class extends Ge{constructor(e,t,n,i,s=Ae,r=Ae,a,c,l){super(e,t,n,i,s,r,a,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let u=this;function h(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(h))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}},gh=class extends dl{constructor(e,t,n,i,s,r,a,c){super({},e,t,n,i,s,r,a,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},zo=class extends Ge{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=We,this.minFilter=We,this.generateMipmaps=!1,this.needsUpdate=!0}},Dr=class extends Ge{constructor(e,t,n,i,s,r,a,c,l,u,h,d){super(null,r,a,c,l,u,i,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},_h=class extends Dr{constructor(e,t,n,i,s,r){super(e,t,n,s,r),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Dt,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},yh=class extends Dr{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,rs),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},xh=class extends Ge{constructor(e,t,n,i,s,r,a,c,l){super(e,t,n,i,s,r,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},cn=class extends Ge{constructor(e,t,n=Je,i,s,r,a=We,c=We,l,u=Hn,h=1){if(u!==Hn&&u!==pi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:h};super(d,i,s,r,a,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ii(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},vh=class extends Ge{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},fl=class o extends _e{constructor(e=1,t=1,n=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:s},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));let r=[],a=[],c=[],l=[],u=t/2,h=Math.PI/2*e,d=t,f=2*h+d,p=n*2+s,m=i+1,_=new S,y=new S;for(let x=0;x<=p;x++){let v=0,T=0,M=0,w=0;if(x<=n){let N=x/n,L=N*Math.PI/2;T=-u-e*Math.cos(L),M=e*Math.sin(L),w=-e*Math.cos(L),v=N*h}else if(x<=n+s){let N=(x-n)/s;T=-u+N*t,M=e,w=0,v=h+N*d}else{let N=(x-n-s)/n,L=N*Math.PI/2;T=u+e*Math.sin(L),M=e*Math.cos(L),w=e*Math.sin(L),v=h+d+N*h}let E=Math.max(0,Math.min(1,v/f)),A=0;x===0?A=.5/i:x===p&&(A=-.5/i);for(let N=0;N<=i;N++){let L=N/i,V=L*Math.PI*2,H=Math.sin(V),W=Math.cos(V);y.x=-M*W,y.y=T,y.z=M*H,a.push(y.x,y.y,y.z),_.set(-M*W,w,M*H),_.normalize(),c.push(_.x,_.y,_.z),l.push(L+A,E)}if(x>0){let N=(x-1)*m;for(let L=0;L0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new J(h,3)),this.setAttribute("normal",new J(d,3)),this.setAttribute("uv",new J(f,2));function x(){let T=new S,M=new S,w=0,E=(t-e)/n;for(let A=0;A<=s;A++){let N=[],L=A/s,V=L*(t-e)+e;for(let H=0;H<=i;H++){let W=H/i,X=W*c+a,ae=Math.sin(X),oe=Math.cos(X);M.x=V*ae,M.y=-L*n+_,M.z=V*oe,h.push(M.x,M.y,M.z),T.set(ae,E,oe).normalize(),d.push(T.x,T.y,T.z),f.push(W,1-L),N.push(p++)}m.push(N)}for(let A=0;A0||N!==0)&&(u.push(L,V,W),w+=3),(t>0||N!==s-1)&&(u.push(V,H,W),w+=3)}l.addGroup(y,w,0),y+=w}function v(T){let M=p,w=new B,E=new S,A=0,N=T===!0?e:t,L=T===!0?1:-1;for(let H=1;H<=i;H++)h.push(0,_*L,0),d.push(0,L,0),f.push(.5,.5),p++;let V=p;for(let H=0;H<=i;H++){let X=H/i*c+a,ae=Math.cos(X),oe=Math.sin(X);E.x=N*oe,E.y=_*L,E.z=N*ae,h.push(E.x,E.y,E.z),d.push(0,L,0),w.x=ae*.5+.5,w.y=oe*.5*L+.5,f.push(w.x,w.y),p++}for(let H=0;H.9&&E<.1&&(v<.2&&(r[x+0]+=1),T<.2&&(r[x+2]+=1),M<.2&&(r[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function f(x,v){let T=x*3;v.x=e[T+0],v.y=e[T+1],v.z=e[T+2]}function p(){let x=new S,v=new S,T=new S,M=new S,w=new B,E=new B,A=new B;for(let N=0,L=0;N0)c=i-1;else{c=i;break}if(i=c,n[i]===r)return i/(s-1);let u=n[i],d=n[i+1]-u,f=(r-u)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let r=this.getPoint(i),a=this.getPoint(s),c=t||(r.isVector2?new B:new S);return c.copy(a).sub(r).normalize(),c}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new S,i=[],s=[],r=[],a=new S,c=new ee;for(let f=0;f<=e;f++){let p=f/e;i[f]=this.getTangentAt(p,new S)}s[0]=new S,r[0]=new S;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),r[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),r[f]=r[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(fe(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(a,p))}r[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(fe(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(i[p],f*p)),r[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ur=class extends vn{constructor(e=0,t=0,n=1,i=1,s=0,r=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new B){let n=t,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%s]:(Pp.subVectors(i[0],i[1]).add(i[0]),l=Pp);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2i.length-2?i.length-1:r+1],h=i[r>i.length-3?i.length-1:r+2];return n.set(oA(a,c.x,l.x,u.x,h.x),oA(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let r=i[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-r/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Ni=class extends Br{constructor(e){super(e),this.uuid=kn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n80*t){a=1/0,c=1/0;let u=-1/0,h=-1/0;for(let d=t;du&&(u=f),p>h&&(h=p)}l=Math.max(u-a,h-c),l=l!==0?32767/l:0}return Th(s,r,t,a,c,l,0),r}function IA(o,e,t,n,i){let s;if(i===VP(o,e,t,n)>0)for(let r=e;r=e;r-=n)s=aA(r/n|0,o[r],o[r+1],s);return s&&bl(s,s.next)&&(Sh(s),s=s.next),s}function Ko(o,e){if(!o)return o;e||(e=o);let t=o,n;do if(n=!1,!t.steiner&&(bl(t,t.next)||dt(t.prev,t,t.next)===0)){if(Sh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Th(o,e,t,n,i,s,r){if(!o)return;!r&&s&&LP(o,n,i,s);let a=o;for(;o.prev!==o.next;){let c=o.prev,l=o.next;if(s?AP(o,n,i,s):MP(o)){e.push(c.i,o.i,l.i),Sh(o),o=l.next,a=l.next;continue}if(o=l,o===a){r?r===1?(o=EP(Ko(o),e),Th(o,e,t,n,i,s,2)):r===2&&wP(o,e,t,n,i,s):Th(Ko(o),e,t,n,i,s,1);break}}}function MP(o){let e=o.prev,t=o,n=o.next;if(dt(e,t,n)>=0)return!1;let i=e.x,s=t.x,r=n.x,a=e.y,c=t.y,l=n.y,u=Math.min(i,s,r),h=Math.min(a,c,l),d=Math.max(i,s,r),f=Math.max(a,c,l),p=n.next;for(;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&ih(i,a,s,c,r,l,p.x,p.y)&&dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function AP(o,e,t,n){let i=o.prev,s=o,r=o.next;if(dt(i,s,r)>=0)return!1;let a=i.x,c=s.x,l=r.x,u=i.y,h=s.y,d=r.y,f=Math.min(a,c,l),p=Math.min(u,h,d),m=Math.max(a,c,l),_=Math.max(u,h,d),y=Ux(f,p,e,t,n),x=Ux(m,_,e,t,n),v=o.prevZ,T=o.nextZ;for(;v&&v.z>=y&&T&&T.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==r&&ih(a,u,c,h,l,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0||(v=v.prevZ,T.x>=f&&T.x<=m&&T.y>=p&&T.y<=_&&T!==i&&T!==r&&ih(a,u,c,h,l,d,T.x,T.y)&&dt(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;v&&v.z>=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==r&&ih(a,u,c,h,l,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;T&&T.z<=x;){if(T.x>=f&&T.x<=m&&T.y>=p&&T.y<=_&&T!==i&&T!==r&&ih(a,u,c,h,l,d,T.x,T.y)&&dt(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function EP(o,e){let t=o;do{let n=t.prev,i=t.next.next;!bl(n,i)&&DA(n,t,t.next,i)&&bh(n,i)&&bh(i,n)&&(e.push(n.i,t.i,i.i),Sh(t),Sh(t.next),t=o=i),t=t.next}while(t!==o);return Ko(t)}function wP(o,e,t,n,i,s){let r=o;do{let a=r.next.next;for(;a!==r.prev;){if(r.i!==a.i&&UP(r,a)){let c=FA(r,a);r=Ko(r,r.next),c=Ko(c,c.next),Th(r,e,t,n,i,s,0),Th(c,e,t,n,i,s,0);return}a=a.next}r=r.next}while(r!==o)}function RP(o,e,t,n){let i=[];for(let s=0,r=e.length;s=t.next.y&&t.next.y!==t.y){let h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s&&(s=h,r=t.x=t.x&&t.x>=c&&n!==t.x&&LA(ir.x||t.x===r.x&&IP(r,t)))&&(r=t,u=h)}t=t.next}while(t!==a);return r}function IP(o,e){return dt(o.prev,o,e.prev)<0&&dt(e.next,o,o.next)<0}function LP(o,e,t,n){let i=o;do i.z===0&&(i.z=Ux(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==o);i.prevZ.nextZ=null,i.prevZ=null,DP(i)}function DP(o){let e,t=1;do{let n=o,i;o=null;let s=null;for(e=0;n;){e++;let r=n,a=0;for(let l=0;l0||c>0&&r;)a!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,c--),s?s.nextZ=i:o=i,i.prevZ=s,s=i;n=r}s.nextZ=null,t*=2}while(e>1);return o}function Ux(o,e,t,n,i){return o=(o-t)*i|0,e=(e-n)*i|0,o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,o|e<<1}function FP(o){let e=o,t=o;do(e.x=(o-r)*(s-a)&&(o-r)*(n-a)>=(t-r)*(e-a)&&(t-r)*(s-a)>=(i-r)*(n-a)}function ih(o,e,t,n,i,s,r,a){return!(o===r&&e===a)&&LA(o,e,t,n,i,s,r,a)}function UP(o,e){return o.next.i!==e.i&&o.prev.i!==e.i&&!BP(o,e)&&(bh(o,e)&&bh(e,o)&&OP(o,e)&&(dt(o.prev,o,e.prev)||dt(o,e.prev,e))||bl(o,e)&&dt(o.prev,o,o.next)>0&&dt(e.prev,e,e.next)>0)}function dt(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function bl(o,e){return o.x===e.x&&o.y===e.y}function DA(o,e,t,n){let i=Lp(dt(o,e,t)),s=Lp(dt(o,e,n)),r=Lp(dt(t,n,o)),a=Lp(dt(t,n,e));return!!(i!==s&&r!==a||i===0&&Ip(o,t,e)||s===0&&Ip(o,n,e)||r===0&&Ip(t,o,n)||a===0&&Ip(t,e,n))}function Ip(o,e,t){return e.x<=Math.max(o.x,t.x)&&e.x>=Math.min(o.x,t.x)&&e.y<=Math.max(o.y,t.y)&&e.y>=Math.min(o.y,t.y)}function Lp(o){return o>0?1:o<0?-1:0}function BP(o,e){let t=o;do{if(t.i!==o.i&&t.next.i!==o.i&&t.i!==e.i&&t.next.i!==e.i&&DA(t,t.next,o,e))return!0;t=t.next}while(t!==o);return!1}function bh(o,e){return dt(o.prev,o,o.next)<0?dt(o,e,o.next)>=0&&dt(o,o.prev,e)>=0:dt(o,e,o.prev)<0||dt(o,o.next,e)<0}function OP(o,e){let t=o,n=!1,i=(o.x+e.x)/2,s=(o.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==o);return n}function FA(o,e){let t=Bx(o.i,o.x,o.y),n=Bx(e.i,e.x,e.y),i=o.next,s=e.prev;return o.next=e,e.prev=o,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function aA(o,e,t,n){let i=Bx(o,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Sh(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function Bx(o,e,t){return{i:o,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function VP(o,e,t,n){let i=0;for(let s=e,r=t-n;s2&&o[e-1].equals(o[0])&&o.pop()}function lA(o,e){for(let t=0;tNumber.EPSILON){let Bn=Math.sqrt(Un),_M=Math.sqrt(lt*lt+Lt*Lt),yM=ie.x-rt/Bn,xM=ie.y+be/Bn,x1=re.x-Lt/_M,v1=re.y+lt/_M,vM=((x1-yM)*Lt-(v1-xM)*lt)/(be*Lt-rt*lt);le=yM+be*vM-Z.x,ce=xM+rt*vM-Z.y;let TM=le*le+ce*ce;if(TM<=2)return new B(le,ce);Ue=Math.sqrt(TM/2)}else{let Bn=!1;be>Number.EPSILON?lt>Number.EPSILON&&(Bn=!0):be<-Number.EPSILON?lt<-Number.EPSILON&&(Bn=!0):Math.sign(rt)===Math.sign(Lt)&&(Bn=!0),Bn?(le=-rt,ce=be,Ue=Math.sqrt(Un)):(le=be,ce=rt,Ue=Math.sqrt(Un/2))}return new B(le/Ue,ce/Ue)}let ve=[];for(let Z=0,ie=ae.length,re=ie-1,le=Z+1;Z=0;Z--){let ie=Z/_,re=f*Math.cos(ie*Math.PI/2),le=p*Math.sin(ie*Math.PI/2)+m;for(let ce=0,Ue=ae.length;ce=0;){let le=re,ce=re-1;ce<0&&(ce=Z.length-1);for(let Ue=0,be=u+_*2;Ue0)&&f.push(v,T,w),(y!==n-1||c0!=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}},Qo=class extends je{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new q(16777215),this.specular=new q(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xn,this.combine=Na,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}},ea=class extends je{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new q(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new B(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}},ta=class extends je{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new B(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}},na=class extends je{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new q(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xn,this.combine=Na,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}},Dl=class extends je{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fm,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}},Fl=class extends je{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}},ia=class extends je{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new q(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new B(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}},Vr=class extends yt{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 Ro(o,e){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function UA(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function BA(o){function e(i,s){return o[i]-o[s]}let t=o.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Vx(o,e,t){let n=o.length,i=new o.constructor(n);for(let s=0,r=0;r!==n;++s){let a=t[s]*e;for(let c=0;c!==e;++c)i[r++]=o[a+c]}return i}function yv(o,e,t,n){let i=1,s=o[0];for(;s!==void 0&&s[n]===void 0;)s=o[i++];if(s===void 0)return;let r=s[n];if(r!==void 0)if(Array.isArray(r))do r=s[n],r!==void 0&&(e.push(s.time),t.push(...r)),s=o[i++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[n],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=o[i++];while(s!==void 0);else do r=s[n],r!==void 0&&(e.push(s.time),t.push(r)),s=o[i++];while(s!==void 0)}function HP(o,e,t,n,i=30){let s=o.clone();s.name=e;let r=[];for(let c=0;c=n)){h.push(l.times[f]);for(let m=0;ms.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c=a.times[p]){let y=p*h+u,x=y+h-u;m=a.values.slice(y,x)}else{let y=a.createInterpolant(),x=u,v=h-u;y.evaluate(s),m=y.resultBuffer.slice(x,v)}c==="quaternion"&&new tt().fromArray(m).normalize().conjugate().toArray(m);let _=l.times.length;for(let y=0;y<_;++y){let x=y*f+d;if(c==="quaternion")tt.multiplyQuaternionsFlat(l.values,x,m,0,l.values,x);else{let v=f-d*2;for(let T=0;T=s)){let a=t[1];e=s)break t}r=n,n=0;break n}break e}for(;n>>1;et;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let a=0;a!==s;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,r),e=!1;break}r=c}if(i!==void 0&&UA(i))for(let a=0,c=i.length;a!==c;++a){let l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===tl,s=e.length-1,r=1;for(let a=1;a0){e[r]=e[s];for(let a=s*n,c=r*n,l=0;l!==n;++l)t[c+l]=t[a+l];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};ln.prototype.ValueTypeName="";ln.prototype.TimeBufferType=Float32Array;ln.prototype.ValueBufferType=Float32Array;ln.prototype.DefaultInterpolation=zs;var Di=class extends ln{constructor(e,t,n){super(e,t,n)}};Di.prototype.ValueTypeName="bool";Di.prototype.ValueBufferType=Array;Di.prototype.DefaultInterpolation=ks;Di.prototype.InterpolantFactoryMethodLinear=void 0;Di.prototype.InterpolantFactoryMethodSmooth=void 0;var ra=class extends ln{constructor(e,t,n,i){super(e,t,n,i)}};ra.prototype.ValueTypeName="color";var li=class extends ln{constructor(e,t,n,i){super(e,t,n,i)}};li.prototype.ValueTypeName="number";var Ol=class extends Li{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t),l=e*a;for(let u=l+a;l!==u;l+=4)tt.slerpFlat(s,0,r,l-a,r,l,c);return s}},ui=class extends ln{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Ol(this.times,this.values,this.getValueSize(),e)}};ui.prototype.ValueTypeName="quaternion";ui.prototype.InterpolantFactoryMethodSmooth=void 0;var Fi=class extends ln{constructor(e,t,n){super(e,t,n)}};Fi.prototype.ValueTypeName="string";Fi.prototype.ValueBufferType=Array;Fi.prototype.DefaultInterpolation=ks;Fi.prototype.InterpolantFactoryMethodLinear=void 0;Fi.prototype.InterpolantFactoryMethodSmooth=void 0;var hi=class extends ln{constructor(e,t,n,i){super(e,t,n,i)}};hi.prototype.ValueTypeName="vector";var Ui=class{constructor(e="",t=-1,n=[],i=tu){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=kn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,a=n.length;r!==a;++r)t.push(qP(n[r]).scale(i));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,r=n.length;s!==r;++s)t.push(ln.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let s=t.length,r=[];for(let a=0;a1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(l)}}let r=[];for(let a in i)r.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return r}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,f,p,m){if(f.length!==0){let _=[],y=[];yv(f,_,y,p),_.length!==0&&m.push(new h(d,_,y))}},i=[],s=e.name||"default",r=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(Fs[e]!==void 0){Fs[e].push({onLoad:t,onProgress:n,onError:i});return}Fs[e]=[],Fs[e].push({onLoad:t,onProgress:n,onError:i});let r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body===void 0||l.body.getReader===void 0)return l;let u=Fs[e],h=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0,m=0,_=new ReadableStream({start(y){x();function x(){h.read().then(({done:v,value:T})=>{if(v)y.close();else{m+=T.byteLength;let M=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let w=0,E=u.length;w{y.error(v)})}}});return new Response(_)}else throw new Gx(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a==="")return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{si.add(`file:${e}`,l);let u=Fs[e];delete Fs[e];for(let h=0,d=u.length;h{let u=Fs[e];if(u===void 0)throw this.manager.itemError(e),l;delete Fs[e];for(let h=0,d=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Ah=class extends Mt{constructor(e){super(e)}load(e,t,n,i){let s=this,r=new jt(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){let t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let r=e.uniforms[s];switch(i.uniforms[s]={},r.type){case"t":i.uniforms[s].value=n(r.value);break;case"c":i.uniforms[s].value=new q().setHex(r.value);break;case"v2":i.uniforms[s].value=new B().fromArray(r.value);break;case"v3":i.uniforms[s].value=new S().fromArray(r.value);break;case"v4":i.uniforms[s].value=new ge().fromArray(r.value);break;case"m3":i.uniforms[s].value=new pe().fromArray(r.value);break;case"m4":i.uniforms[s].value=new ee().fromArray(r.value);break;default:i.uniforms[s].value=r.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new B().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new B().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return o.createMaterialFromType(e)}static createMaterialFromType(e){let t={ShadowMaterial:Jo,SpriteMaterial:Rr,RawShaderMaterial:Ll,ShaderMaterial:wr,PointsMaterial:es,MeshPhysicalMaterial:Wt,MeshStandardMaterial:Ii,MeshPhongMaterial:Qo,MeshToonMaterial:ea,MeshNormalMaterial:ta,MeshLambertMaterial:na,MeshDepthMaterial:Dl,MeshDistanceMaterial:Fl,MeshBasicMaterial:at,MeshMatcapMaterial:ia,LineDashedMaterial:Vr,LineBasicMaterial:yt,Material:je};return new t[e]}},Xn=class{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)}},Gl=class extends _e{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}},kl=class extends Mt{constructor(e){super(e)}load(e,t,n,i){let s=this,r=new jt(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,p){if(t[p]!==void 0)return t[p];let _=f.interleavedBuffers[p],y=s(f,_.buffer),x=el(_.type,y),v=new ci(x,_.stride);return v.uuid=_.uuid,t[p]=v,v}function s(f,p){if(n[p]!==void 0)return n[p];let _=f.arrayBuffers[p],y=new Uint32Array(_).buffer;return n[p]=y,y}let r=e.isInstancedBufferGeometry?new Gl:new _e,a=e.data.index;if(a!==void 0){let f=el(a.type,a.array);r.setIndex(new Ee(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],m;if(p.isInterleavedBufferAttribute){let _=i(e.data,p.data);m=new Wn(_,p.itemSize,p.offset,p.normalized)}else{let _=el(p.type,p.array),y=p.isInstancedBufferAttribute?Bt:Ee;m=new y(_,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),r.setAttribute(f,m)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],m=[];for(let _=0,y=p.length;_0){let c=new oa(t);s=new Ys(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l0){i=new Ys(this.manager),i.setCrossOrigin(this.crossOrigin);for(let r=0,a=e.length;r{let _=null,y=null;return m.boundingBox!==void 0&&(_=new _t().fromJSON(m.boundingBox)),m.boundingSphere!==void 0&&(y=new ot().fromJSON(m.boundingSphere)),{...m,boundingBox:_,boundingSphere:y}}),r._instanceInfo=e.instanceInfo,r._availableInstanceIds=e._availableInstanceIds,r._availableGeometryIds=e._availableGeometryIds,r._nextIndexStart=e.nextIndexStart,r._nextVertexStart=e.nextVertexStart,r._geometryCount=e.geometryCount,r._maxInstanceCount=e.maxInstanceCount,r._maxVertexCount=e.maxVertexCount,r._maxIndexCount=e.maxIndexCount,r._geometryInitialized=e.geometryInitialized,r._matricesTexture=l(e.matricesTexture.uuid),r._indirectTexture=l(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(r._colorsTexture=l(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(r.boundingSphere=new ot().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(r.boundingBox=new _t().fromJSON(e.boundingBox));break;case"LOD":r=new ul;break;case"Line":r=new Pn(a(e.geometry),c(e.material));break;case"LineLoop":r=new Ir(a(e.geometry),c(e.material));break;case"LineSegments":r=new an(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":r=new Lr(a(e.geometry),c(e.material));break;case"Sprite":r=new ll(c(e.material));break;case"Group":r=new rn;break;case"Bone":r=new qs;break;default:r=new we}if(r.uuid=e.uuid,e.name!==void 0&&(r.name=e.name),e.matrix!==void 0?(r.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(r.matrixAutoUpdate=e.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(e.position!==void 0&&r.position.fromArray(e.position),e.rotation!==void 0&&r.rotation.fromArray(e.rotation),e.quaternion!==void 0&&r.quaternion.fromArray(e.quaternion),e.scale!==void 0&&r.scale.fromArray(e.scale)),e.up!==void 0&&r.up.fromArray(e.up),e.castShadow!==void 0&&(r.castShadow=e.castShadow),e.receiveShadow!==void 0&&(r.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(r.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(r.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(r.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(r.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&r.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(r.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(r.visible=e.visible),e.frustumCulled!==void 0&&(r.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(r.renderOrder=e.renderOrder),e.userData!==void 0&&(r.userData=e.userData),e.layers!==void 0&&(r.layers.mask=e.layers),e.children!==void 0){let d=e.children;for(let f=0;f{if(Cx.has(r)===!0)i&&i(Cx.get(r)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(l),s.manager.itemEnd(e),l});return}return setTimeout(function(){t&&t(r),s.manager.itemEnd(e)},0),r}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return si.add(`image-bitmap:${e}`,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){i&&i(l),Cx.set(c,l),si.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});si.add(`image-bitmap:${e}`,c),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Dp,ma=class{static getContext(){return Dp===void 0&&(Dp=new(window.AudioContext||window.webkitAudioContext)),Dp}static setContext(e){Dp=e}},Ch=class extends Mt{constructor(e){super(e)}load(e,t,n,i){let s=this,r=new jt(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(c){try{let l=c.slice(0);ma.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),s.manager.itemError(e)}}},_A=new ee,yA=new ee,bo=new ee,Nh=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ht,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ht,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,bo.copy(e.projectionMatrix);let i=t.eyeSep/2,s=i*t.near/t.focus,r=t.near*Math.tan(Co*t.fov*.5)/t.zoom,a,c;yA.elements[12]=-i,_A.elements[12]=i,a=-r*t.aspect+s,c=r*t.aspect+s,bo.elements[0]=2*t.near/(c-a),bo.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(bo),a=-r*t.aspect-s,c=r*t.aspect-s,bo.elements[0]=2*t.near/(c-a),bo.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(bo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(yA),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_A)}},Hl=class extends ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Wl=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},So=new S,Nx=new tt,YP=new S,Mo=new S,Ao=new S,Ph=class extends we{constructor(){super(),this.type="AudioListener",this.context=ma.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Wl}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(So,Nx,YP),Mo.set(0,0,-1).applyQuaternion(Nx),Ao.set(0,1,0).applyQuaternion(Nx),t.positionX){let n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(So.x,n),t.positionY.linearRampToValueAtTime(So.y,n),t.positionZ.linearRampToValueAtTime(So.z,n),t.forwardX.linearRampToValueAtTime(Mo.x,n),t.forwardY.linearRampToValueAtTime(Mo.y,n),t.forwardZ.linearRampToValueAtTime(Mo.z,n),t.upX.linearRampToValueAtTime(Ao.x,n),t.upY.linearRampToValueAtTime(Ao.y,n),t.upZ.linearRampToValueAtTime(Ao.z,n)}else t.setPosition(So.x,So.y,So.z),t.setOrientation(Mo.x,Mo.y,Mo.z,Ao.x,Ao.y,Ao.z)}},Xl=class extends we{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(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;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,r=i;s!==r;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==s;++r)e[t+r]=e[n+r]}_slerp(e,t,n,i){tt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){let r=this._workIndex*s;tt.multiplyQuaternionsFlat(e,r,e,t,e,n),tt.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,s){let r=1-i;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*r+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let r=0;r!==s;++r){let a=t+r;e[a]=e[a]+e[n+r]*i}}},xv="\\[\\]\\.:\\/",jP=new RegExp("["+xv+"]","g"),vv="[^"+xv+"]",ZP="[^"+xv.replace("\\.","")+"]",JP=/((?:WC+[\/:])*)/.source.replace("WC",vv),QP=/(WCOD+)?/.source.replace("WCOD",ZP),eI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vv),tI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vv),nI=new RegExp("^"+JP+QP+eI+tI+"$"),iI=["material","materials","bones","map"],Wx=class{constructor(e,t,n){let i=n||De.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].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()}},De=class o{constructor(e,t,n){this.path=t,this.parsedPath=n||o.parseTrackName(t),this.node=o.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new o.Composite(e,t,n):new o(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(jP,"")}static parseTrackName(e){let t=nI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);iI.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let r=0;r=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[l]=h,e[h]=c;for(let f=0,p=i;f!==p;++f){let m=n[f],_=m[h],y=m[u];m[u]=_,m[h]=y}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,s=this.nCachedObjects_,r=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[f.uuid]=h),e[h]=f,e.pop();for(let p=0,m=i;p!==m;++p){let _=n[p];_[h]=_[d],_.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],s=this._bindings;if(i!==void 0)return s[i];let r=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,r.push(e),a.push(t),s.push(h);for(let d=u,f=c.length;d!==f;++d){let p=c[d];h[d]=new De(p,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let i=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,c=r[a],l=e[a];t[l]=n,r[n]=c,r.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}},$l=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let s=t.tracks,r=s.length,a=new Array(r),c={endingStart:Bs,endingEnd:Bs};for(let l=0;l!==r;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=hm,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=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,s=e._clip.duration,r=s/i,a=i/s;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){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 i=this._mixer,s=i.time,r=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/r,l[1]=t/r,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,i){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);let r=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case xd:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulateAdditive(a);break;case tu:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===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 i=n.evaluate(e)[0];t*=i,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,i=this.time+e,s=this._loopCount,r=n===dm;if(e===0)return s===-1?i:r&&(s&1)===1?t-i:i;if(n===um){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),i>=t||i<0){let a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(r&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=Os,i.endingEnd=Os):(e?i.endingStart=this.zeroSlopeAtStart?Os:Bs:i.endingStart=Io,t?i.endingEnd=this.zeroSlopeAtEnd?Os:Bs:i.endingEnd=Io)}_scheduleFading(e,t,n){let i=this._mixer,s=i.time,r=this._weightInterpolant;r===null&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);let a=r.parameterPositions,c=r.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=n,this}},sI=new Float32Array(1),Fh=class extends on{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,i=e._clip.tracks,s=i.length,r=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,p=u[f];if(p!==void 0)++p.referenceCount,r[h]=p;else{if(p=r[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let m=t&&t._propertyBindings[h].binding.parsedPath;p=new ql(De.create(n,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),r[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),r=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,r);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(r);return this}setTime(e){this.time=0;for(let t=0;t=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,bA).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)}},SA=new S,Fp=new S,Jc=new S,Qc=new S,Px=new S,aI=new S,cI=new S,Wh=class{constructor(e=new S,t=new S){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){SA.subVectors(e,this.start),Fp.subVectors(this.end,this.start);let n=Fp.dot(Fp),s=Fp.dot(SA)/n;return t&&(s=fe(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=aI,n=cI){let i=10000000000000001e-32,s,r,a=this.start,c=e.start,l=this.end,u=e.end;Jc.subVectors(l,a),Qc.subVectors(u,c),Px.subVectors(a,c);let h=Jc.dot(Jc),d=Qc.dot(Qc),f=Qc.dot(Px);if(h<=i&&d<=i)return t.copy(a),n.copy(c),t.sub(n),t.dot(t);if(h<=i)s=0,r=f/d,r=fe(r,0,1);else{let p=Jc.dot(Px);if(d<=i)r=0,s=fe(-p/h,0,1);else{let m=Jc.dot(Qc),_=h*d-m*m;_!==0?s=fe((m*f-p*d)/_,0,1):s=0,r=(m*s+f)/d,r<0?(r=0,s=fe(-p/h,0,1)):r>1&&(r=1,s=fe((m-p)/h,0,1))}}return t.copy(a).add(Jc.multiplyScalar(s)),n.copy(c).add(Qc.multiplyScalar(r)),t.sub(n),t.dot(t)}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)}},MA=new S,Xh=class extends we{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new _e,i=[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 r=0,a=1,c=32;r1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{CA.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(CA,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()}},id=class extends an{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],i=new _e;i.setAttribute("position",new J(t,3)),i.setAttribute("color",new J(n,3));let s=new yt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new q,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},sd=class{constructor(){this.type="ShapePath",this.color=new q,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Br,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,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,r){return this.currentPath.bezierCurveTo(e,t,n,i,s,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(y){let x=[];for(let v=0,T=y.length;vNumber.EPSILON){if(L<0&&(E=x[w],N=-N,A=x[M],L=-L),y.yA.y)continue;if(y.y===E.y){if(y.x===E.x)return!0}else{let V=L*(y.x-E.x)-N*(y.y-E.y);if(V===0)return!0;if(V<0)continue;T=!T}}else{if(y.y!==E.y)continue;if(A.x<=y.x&&y.x<=E.x||E.x<=y.x&&y.x<=A.x)return!0}}return T}let i=Gn.isClockWise,s=this.subPaths;if(s.length===0)return[];let r,a,c,l=[];if(s.length===1)return a=s[0],c=new Ni,c.curves=a.curves,l.push(c),l;let u=!i(s[0].getPoints());u=e?!u:u;let h=[],d=[],f=[],p=0,m;d[p]=void 0,f[p]=[];for(let y=0,x=s.length;y1){let y=!1,x=0;for(let v=0,T=d.length;v0&&y===!1&&(f=h)}let _;for(let y=0,x=d.length;ye?(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2):(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0),o}function hI(o,e){let t=o.image&&o.image.width?o.image.width/o.image.height:1;return t>e?(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0):(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2),o}function dI(o){return o.repeat.x=1,o.repeat.y=1,o.offset.x=0,o.offset.y=0,o}function Lm(o,e,t,n){let i=fI(n);switch(t){case yd:return o*e;case Wr:return o*e/i.components*i.byteLength;case Xr:return o*e/i.components*i.byteLength;case Hi:return o*e*2/i.components*i.byteLength;case Ua:return o*e*2/i.components*i.byteLength;case Fa:return o*e*3/i.components*i.byteLength;case Ft:return o*e*4/i.components*i.byteLength;case Ba:return o*e*4/i.components*i.byteLength;case qr:case $r:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Yr:case Kr:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case Jl:case eu:return Math.max(o,16)*Math.max(e,8)/4;case Zl:case Ql:return Math.max(o,8)*Math.max(e,8)/2;case Oa:case Va:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Ga:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case ka:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case za:return Math.floor((o+4)/5)*Math.floor((e+3)/4)*16;case Ha:return Math.floor((o+4)/5)*Math.floor((e+4)/5)*16;case Wa:return Math.floor((o+5)/6)*Math.floor((e+4)/5)*16;case Xa:return Math.floor((o+5)/6)*Math.floor((e+5)/6)*16;case qa:return Math.floor((o+7)/8)*Math.floor((e+4)/5)*16;case $a:return Math.floor((o+7)/8)*Math.floor((e+5)/6)*16;case Ya:return Math.floor((o+7)/8)*Math.floor((e+7)/8)*16;case Ka:return Math.floor((o+9)/10)*Math.floor((e+4)/5)*16;case ja:return Math.floor((o+9)/10)*Math.floor((e+5)/6)*16;case Za:return Math.floor((o+9)/10)*Math.floor((e+7)/8)*16;case Ja:return Math.floor((o+9)/10)*Math.floor((e+9)/10)*16;case Qa:return Math.floor((o+11)/12)*Math.floor((e+9)/10)*16;case ec:return Math.floor((o+11)/12)*Math.floor((e+11)/12)*16;case tc:case cm:case lm:return Math.ceil(o/4)*Math.ceil(e/4)*16;case nc:case ic:return Math.ceil(o/4)*Math.ceil(e/4)*8;case sc:case rc:return Math.ceil(o/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function fI(o){switch(o){case Ot:case Js:return{byteLength:1,components:1};case os:case Qs:case ft:return{byteLength:2,components:1};case gd:case _d:return{byteLength:2,components:4};case Je:case Vt:case nt:return{byteLength:4,components:1};case Kl:case jl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${o}.`)}var rd=class{static contain(e,t){return uI(e,t)}static cover(e,t){return hI(e,t)}static fill(e){return dI(e)}static getByteLength(e,t,n,i){return Lm(e,t,n,i)}};typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ya}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ya);var pI=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],Tv=new WeakMap,ag=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=pI,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:i,object:s}=e;if(t={material:this.getMaterialData(i),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:r,height:a}=e.context;t.bufferWidth=r,t.bufferHeight=a}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let i=e[n];t[n]={version:i.version}}return t}containsNode(e){let t=e.material;for(let n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let i=e[n];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?t[n]={id:i.id,version:i.version}:t[n]=i.clone():t[n]=i)}return t}equals(e,t){let{object:n,material:i,geometry:s}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(n.matrixWorld)!==!0)return r.worldMatrix.copy(n.matrixWorld),!1;let a=r.material;for(let _ in a){let y=a[_],x=i[_];if(y.equals!==void 0){if(y.equals(x)===!1)return y.copy(x),!1}else if(x.isTexture===!0){if(y.id!==x.id||y.version!==x.version)return y.id=x.id,y.version=x.version,!1}else if(y!==x)return a[_]=x,!1}if(a.transmission>0){let{width:_,height:y}=e.context;if(r.bufferWidth!==_||r.bufferHeight!==y)return r.bufferWidth=_,r.bufferHeight=y,!1}let c=r.geometry,l=s.attributes,u=c.attributes,h=Object.keys(u),d=Object.keys(l);if(c.id!==s.id)return c.id=s.id,!1;if(h.length!==d.length)return r.geometry.attributes=this.getAttributesData(l),!1;for(let _ of h){let y=u[_],x=l[_];if(x===void 0)return delete u[_],!1;if(y.version!==x.version)return y.version=x.version,!1}let f=s.index,p=c.indexVersion,m=f?f.version:null;if(p!==m)return c.indexVersion=m,!1;if(c.drawRange.start!==s.drawRange.start||c.drawRange.count!==s.drawRange.count)return c.drawRange.start=s.drawRange.start,c.drawRange.count=s.drawRange.count,!1;if(r.morphTargetInfluences){let _=!1;for(let y=0;y>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}var db=o=>ef(o),Gf=o=>ef(o),tf=(...o)=>ef(o);function fb(o,e=!1){let t=[];o.isNode===!0&&t.push(o.id);for(let{property:n,childNode:i}of nf(o))t.push(ef(n.slice(0,-4)),i.getCacheKey(e));return ef(t)}function*nf(o,e=!1){for(let t of Object.getOwnPropertyNames(o)){if(t.startsWith("_")===!0)continue;let n=o[t];if(Array.isArray(n)===!0)for(let i=0;ie.charCodeAt(0)).buffer}var gI=Object.freeze({__proto__:null,arrayBufferToBase64:_b,base64ToArrayBuffer:yb,getByteBoundaryFromType:nw,getCacheKey:fb,getDataFromObject:gb,getLengthFromType:mb,getMemoryLengthFromType:tw,getNodeChildren:nf,getTypeFromLength:pb,getTypedArrayFromType:sf,getValueFromType:yy,getValueType:lr,hash:tf,hashArray:Gf,hashString:db}),pu={VERTEX:"vertex",FRAGMENT:"fragment"},me={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},iw={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},qt={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},xb=["fragment","vertex"],cg=["setup","analyze","generate"],lg=[...xb,"compute"],lo=["x","y","z","w"],_I={analyze:"setup",generate:"analyze"},yI=0,j=class extends on{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=me.NONE,this.updateBeforeType=me.NONE,this.updateAfterType=me.NONE,this.uuid=nr.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:yI++})}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),this}onFrameUpdate(e){return this.onUpdate(e,me.FRAME)}onRenderUpdate(e){return this.onUpdate(e,me.RENDER)}onObjectUpdate(e){return this.onUpdate(e,me.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of nf(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=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=tf(fb(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}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)}getMemberType(){return"void"}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}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let i of this.getChildren())t["node"+n++]=i;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let i=e.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[e.shaderStage]=i.stages[e.shaderStage]||[],i.stages[e.shaderStage].push(t)}if(n===1){let i=e.getNodeProperties(this);for(let s of Object.values(i))s&&s.isNode===!0&&s.build(e,this)}}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);let i=e.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[e.buildStage]=!0;let s=_I[e.buildStage];if(s&&i.buildStages[s]!==!0){let c=e.getBuildStage();e.setBuildStage(s),this.build(e),e.setBuildStage(c)}e.addNode(this),e.addChain(this);let r=null,a=e.getBuildStage();if(a==="setup"){this.updateReference(e);let c=e.getNodeProperties(this);if(c.initialized!==!0){c.initialized=!0,c.outputNode=this.setup(e)||c.outputNode||null;for(let l of Object.values(c))if(l&&l.isNode===!0){if(l.parents===!0){let u=e.getNodeProperties(l);u.parents=u.parents||[],u.parents.push(this)}l.build(e)}}r=c.outputNode}else if(a==="analyze")this.analyze(e,t);else if(a==="generate"){if(this.generate.length===1){let l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?u.generated===void 0?(u.generated=!0,r=this.generate(e)||"",u.snippet=r):(console.warn("THREE.Node: Recursion detected.",this),r="/* Recursion detected. */"):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";r===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(console.error(`THREE.TSL: Invalid generated code, expected a "${t}".`),r=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return nf(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:i,index:s,childNode:r}of t)s!==void 0?(n[i]===void 0&&(n[i]=Number.isInteger(s)?[]:{}),n[i][s]=r.toJSON(e.meta).uuid):n[i]=r.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 i=[];for(let s of e.inputNodes[n])i.push(t[s]);this[n]=i}else if(typeof e.inputNodes[n]=="object"){let i={};for(let s in e.inputNodes[n]){let r=e.inputNodes[n][s];i[s]=t[r]}this[n]=i}else{let i=e.inputNodes[n];this[n]=t[i]}}}toJSON(e){let{uuid:t,type:n}=this,i=e===void 0||typeof e=="string";i&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function r(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}if(i){let a=r(e.textures),c=r(e.images),l=r(e.nodes);a.length>0&&(s.textures=a),c.length>0&&(s.images=c),l.length>0&&(s.nodes=l)}return s}},_s=class extends j{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){let t=this.indexNode.getNodeType(e),n=this.node.build(e),i=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${i} ]`}},rf=class extends j{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 i of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(i))&&(n=i);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,i=this.getNodeType(e),s=n.build(e,i);return e.format(s,i,t)}},st=class extends j{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){let i=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){let r=super.build(e,i),a=e.getVarFromNode(this,null,i),c=e.getPropertyName(a);return e.addLineFlowCode(`${c} = ${r}`,this),s.snippet=r,s.propertyName=c,e.format(s.propertyName,i,t)}}return super.build(e,t)}},ug=class extends st{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){let n=this.getNodeType(e),i=e.getTypeLength(n),s=this.nodes,r=e.getComponentType(n),a=[],c=0;for(let u of s){if(c>=i){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let h=u.getNodeType(e),d=e.getTypeLength(h),f;if(c+d>i&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),d=i-c,h=e.getTypeFromLength(d)),c+=d,f=u.build(e,h),e.getComponentType(h)!==r){let m=e.getTypeFromLength(d,r);f=e.format(f,h,m)}a.push(f)}let l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}},xI=lo.join(""),of=class extends j{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(lo.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))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,i=e.getTypeLength(n.getNodeType(e)),s=null;if(i>1){let r=null;this.getVectorLength()>=i&&(r=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let c=n.build(e,r);this.components.length===i&&this.components===xI.slice(0,this.components.length)?s=e.format(c,r,t):s=e.format(`${c}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},hg=class extends st{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:i}=this,s=this.getNodeType(e),r=e.getComponentType(i.getNodeType(e)),a=e.getTypeFromLength(n.length,r),c=i.build(e,a),l=t.build(e,s),u=e.getTypeLength(s),h=[];for(let d=0;do.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),kA=o=>vI(o).split("").sort().join("");j.prototype.assign=function(...o){if(this.isStackNode!==!0)return io!==null?io.assign(this,...o):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{let e=Jv.get("assign");return this.add(e(...o))}};j.prototype.toVarIntent=function(){return this};j.prototype.get=function(o){return new dg(this,o)};var Xd={};function Dm(o,e,t){Xd[o]=Xd[e]=Xd[t]={get(){this._cache=this._cache||{};let r=this._cache[o];return r===void 0&&(r=new of(this,o),this._cache[o]=r),r},set(r){this[o].assign(U(r))}};let n=o.toUpperCase(),i=e.toUpperCase(),s=t.toUpperCase();j.prototype["set"+n]=j.prototype["set"+i]=j.prototype["set"+s]=function(r){let a=kA(o);return new hg(this,a,U(r))},j.prototype["flip"+n]=j.prototype["flip"+i]=j.prototype["flip"+s]=function(){let r=kA(o);return new Zv(this,r)}}var as=["x","y","z","w"],cs=["r","g","b","a"],ls=["s","t","p","q"];for(let o=0;o<4;o++){let e=as[o],t=cs[o],n=ls[o];Dm(e,t,n);for(let i=0;i<4;i++){e=as[o]+as[i],t=cs[o]+cs[i],n=ls[o]+ls[i],Dm(e,t,n);for(let s=0;s<4;s++){e=as[o]+as[i]+as[s],t=cs[o]+cs[i]+cs[s],n=ls[o]+ls[i]+ls[s],Dm(e,t,n);for(let r=0;r<4;r++)e=as[o]+as[i]+as[s]+as[r],t=cs[o]+cs[i]+cs[s]+cs[r],n=ls[o]+ls[i]+ls[s]+ls[r],Dm(e,t,n)}}}for(let o=0;o<32;o++)Xd[o]={get(){this._cache=this._cache||{};let e=this._cache[o];return e===void 0&&(e=new _s(this,new Mn(o,"uint")),this._cache[o]=e),e},set(e){this[o].assign(U(e))}};Object.defineProperties(j.prototype,Xd);var zA=new WeakMap,TI=function(o,e=null){let t=lr(o);return t==="node"?o:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?U(t0(o,e)):t==="shader"?o.isFn?o:I(o):o},bI=function(o,e=null){for(let t in o)o[t]=U(o[t],e);return o},SI=function(o,e=null){let t=o.length;for(let n=0;nc?(console.error(`THREE.TSL: "${h}" parameter length exceeds limit.`),u.slice(0,c)):u}return e===null?s=(...u)=>i(new o(...Tc(l(u)))):t!==null?(t=U(t),s=(...u)=>i(new o(e,...Tc(l(u)),t))):s=(...u)=>i(new o(e,...Tc(l(u)))),s.setParameterLength=(...u)=>(u.length===1?a=c=u[0]:u.length===2&&([a,c]=u),s),s.setName=u=>(r=u,s),s},MI=function(o,...e){return U(new o(...Tc(e)))},Qv=class extends j{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,i=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",r=s||"default";if(i[r])return i[r];let a=e.subBuildFn;e.subBuildFn=s;let c=null;if(t.layout){let l=zA.get(e.constructor);l===void 0&&(l=new WeakMap,zA.set(e.constructor,l));let u=l.get(t);u===void 0&&(u=U(e.buildFunctionNode(t)),l.set(t,u)),e.addInclude(u);let h=n?AI(n):null;c=U(u.call(h))}else{let l=new Proxy(e,{get:(p,m,_)=>{let y;return Symbol.iterator===m?y=function*(){yield void 0}:y=Reflect.get(p,m,_),y}}),u=n?EI(n):null,h=Array.isArray(n)?n.length>0:n!==null,d=t.jsFunc,f=h||d.length>1?d(u,l):d(l);c=U(f)}return e.subBuildFn=a,t.once&&(i[r]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,i=e.getBuildStage(),s=e.getNodeProperties(this),r=e.getSubBuildOutput(this),a=this.getOutputNode(e);if(i==="setup"){let c=e.getSubBuildProperty("initialized",this);if(s[c]!==!0&&(s[c]=!0,s[r]=this.getOutputNode(e),s[r].build(e),this.shaderNode.subBuilds))for(let l of e.chaining){let u=e.getDataFromNode(l,"any");u.subBuilds=u.subBuilds||new Set;for(let h of this.shaderNode.subBuilds)u.subBuilds.add(h)}n=s[r]}else i==="analyze"?a.build(e,t):i==="generate"&&(n=a.build(e,t)||"");return n}};function AI(o){let e;return Ty(o),o[0]&&(o[0].isNode||Object.getPrototypeOf(o[0])!==Object.prototype)?e=[...o]:e=o[0],e}function EI(o){let e=0;return Ty(o),new Proxy(o,{get:(t,n,i)=>{let s;if(n==="length")return s=o.length,s;if(Symbol.iterator===n)s=function*(){for(let r of o)yield U(r)};else{if(o.length>0)if(Object.getPrototypeOf(o[0])===Object.prototype){let r=o[0];r[n]===void 0?s=r[e++]:s=Reflect.get(r,n,i)}else o[0]instanceof j&&(o[n]===void 0?s=o[e++]:s=Reflect.get(o,n,i));else s=Reflect.get(t,n,i);s=U(s)}return s}})}var e0=class extends j{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 U(new Qv(this,e))}setup(){return this.call()}},wI=[!1,!0],RI=[0,1,2,3],CI=[-1,-2],rw=[.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],vb=new Map;for(let o of wI)vb.set(o,new Mn(o));var Tb=new Map;for(let o of RI)Tb.set(o,new Mn(o,"uint"));var bb=new Map([...Tb].map(o=>new Mn(o.value,"int")));for(let o of CI)bb.set(o,new Mn(o,"int"));var xy=new Map([...bb].map(o=>new Mn(o.value)));for(let o of rw)xy.set(o,new Mn(o));for(let o of rw)xy.set(-o,new Mn(-o));var vy={bool:vb,uint:Tb,ints:bb,float:xy},HA=new Map([...vb,...xy]),t0=(o,e)=>HA.has(o)?HA.get(o):o.isNode===!0?o:new Mn(o,e),It=function(o,e=null){return(...t)=>{for(let i of t)if(i===void 0)return console.error(`THREE.TSL: Invalid parameter for the type "${o}".`),U(new Mn(0,o));if((t.length===0||!["bool","float","int","uint"].includes(o)&&t.every(i=>{let s=typeof i;return s!=="object"&&s!=="function"}))&&(t=[yy(o,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Wd(e.get(t[0]));if(t.length===1){let i=t0(t[0],o);return i.nodeType===o?Wd(i):Wd(new rf(i,o))}let n=t.map(i=>t0(i));return Wd(new ug(n,o))}},cf=o=>typeof o=="object"&&o!==null?o.value:o,ow=o=>o!=null?o.nodeType||o.convertTo||(typeof o=="string"?o:null):null;function mu(o,e){return new e0(o,e)}var U=(o,e=null)=>TI(o,e),Wd=(o,e=null)=>U(o,e).toVarIntent(),Ty=(o,e=null)=>new bI(o,e),Tc=(o,e=null)=>new SI(o,e),ue=(o,e=null,t=null,n=null)=>new sw(o,e,t,n),z=(o,...e)=>new MI(o,...e),k=(o,e=null,t=null,n={})=>new sw(o,e,t,{intent:!0,...n}),NI=0,n0=class extends j{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:console.error("THREE.TSL: Invalid layout type."),t=null)),this.shaderNode=new mu(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){let n={name:"fn"+NI++,type:t,inputs:[]};for(let i in e)i!=="return"&&n.inputs.push({name:i,type:e[i]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return console.error('THREE.TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}};function I(o,e=null){let t=new n0(o,e);return new Proxy(()=>{},{apply(n,i,s){return t.call(...s)},get(n,i,s){return Reflect.get(t,i,s)},set(n,i,s,r){return Reflect.set(t,i,s,r)}})}var lf=o=>{io=o},by=()=>io,ne=(...o)=>io.If(...o),PI=(...o)=>io.Switch(...o);function Sy(o){return io&&io.add(o),o}F("toStack",Sy);var aw=new It("color"),b=new It("float",vy.float),R=new It("int",vy.ints),$=new It("uint",vy.uint),Ti=new It("bool",vy.bool),O=new It("vec2"),kt=new It("ivec2"),cw=new It("uvec2"),lw=new It("bvec2"),P=new It("vec3"),uw=new It("ivec3"),Bu=new It("uvec3"),Sb=new It("bvec3"),Y=new It("vec4"),hw=new It("ivec4"),dw=new It("uvec4"),fw=new It("bvec4"),My=new It("mat2"),dn=new It("mat3"),bc=new It("mat4"),II=(o="")=>U(new Mn(o,"string")),LI=o=>U(new Mn(o,"ArrayBuffer"));F("toColor",aw);F("toFloat",b);F("toInt",R);F("toUint",$);F("toBool",Ti);F("toVec2",O);F("toIVec2",kt);F("toUVec2",cw);F("toBVec2",lw);F("toVec3",P);F("toIVec3",uw);F("toUVec3",Bu);F("toBVec3",Sb);F("toVec4",Y);F("toIVec4",hw);F("toUVec4",dw);F("toBVec4",fw);F("toMat2",My);F("toMat3",dn);F("toMat4",bc);var pw=ue(_s).setParameterLength(2),mw=(o,e)=>U(new rf(U(o),e)),DI=(o,e)=>U(new of(U(o),e));F("element",pw);F("convert",mw);var FI=o=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),Sy(o));F("append",o=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),Sy(o)));var Ie=class extends j{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}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)}},Yi=(o,e)=>U(new Ie(o,e)),$n=(o,e)=>U(new Ie(o,e,!0)),Fe=z(Ie,"vec4","DiffuseColor"),i0=z(Ie,"vec3","EmissiveColor"),ds=z(Ie,"float","Roughness"),uf=z(Ie,"float","Metalness"),fg=z(Ie,"float","Clearcoat"),hf=z(Ie,"float","ClearcoatRoughness"),_c=z(Ie,"vec3","Sheen"),Ay=z(Ie,"float","SheenRoughness"),Ey=z(Ie,"float","Iridescence"),Mb=z(Ie,"float","IridescenceIOR"),Ab=z(Ie,"float","IridescenceThickness"),pg=z(Ie,"float","AlphaT"),Jr=z(Ie,"float","Anisotropy"),qd=z(Ie,"vec3","AnisotropyT"),Sc=z(Ie,"vec3","AnisotropyB"),In=z(Ie,"color","SpecularColor"),df=z(Ie,"float","SpecularF90"),mg=z(Ie,"float","Shininess"),yu=z(Ie,"vec4","Output"),Mc=z(Ie,"float","dashSize"),ff=z(Ie,"float","gapSize"),UI=z(Ie,"float","pointWidth"),$d=z(Ie,"float","IOR"),gg=z(Ie,"float","Transmission"),Eb=z(Ie,"float","Thickness"),wb=z(Ie,"float","AttenuationDistance"),Rb=z(Ie,"color","AttenuationColor"),Cb=z(Ie,"float","Dispersion"),pf=class extends j{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}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}},gw=o=>new pf(o),wy=(o,e=0)=>new pf(o,!0,e),_w=wy("frame"),te=wy("render"),Nb=gw("object"),so=class extends af{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Nb}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(n=>{let i=e(n,this);i!==void 0&&(this.value=i)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){let n=this.getNodeType(e),i=this.getUniformHash(e),s=e.getNodeFromHash(i);s===void 0&&(e.setHashNode(this,i),s=this);let r=s.getInputType(e),a=e.getUniformFromNode(s,r,e.shaderStage,this.name||e.context.nodeName),c=e.getPropertyName(a);e.context.nodeName!==void 0&&delete e.context.nodeName;let l=c;if(n==="bool"){let u=e.getDataFromNode(this),h=u.propertyName;if(h===void 0){let d=e.getVarFromNode(this,null,"bool");h=e.getPropertyName(d),u.propertyName=h,l=e.format(c,r,n),e.addLineFlowCode(`${h} = ${l}`,this)}l=h}return e.format(l,n,t)}},se=(o,e)=>{let t=ow(e||o);return t===o&&(o=yy(t)),o=o&&o.isNode===!0?o.node&&o.node.value||o.value:o,U(new so(o,t))},mf=class extends st{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},yw=(...o)=>{let e;if(o.length===1){let t=o[0];e=new mf(null,t.length,t)}else{let t=o[0],n=o[1];e=new mf(t,n)}return U(e)};F("toArray",(o,e)=>yw(Array(e).fill(o)));var _g=class extends st{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}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 lo.join("").slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,i=t.getScope(),s=e.getNodeProperties(i);s.assign=!0;let r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:i}=e.getNodeProperties(this),s=this.needsSplitAssign(e),r=n.build(e),a=n.getNodeType(e),c=i.build(e,a),l=i.getNodeType(e),u=e.getDataFromNode(this),h;if(u.initialized===!0)t!=="void"&&(h=r);else if(s){let d=e.getVarFromNode(this,null,a),f=e.getPropertyName(d);e.addLineFlowCode(`${f} = ${c}`,this);let p=n.node,_=p.node.context({assign:!0}).build(e);for(let y=0;y{let u=l.type,h=u==="pointer",d;return h?d="&"+c.build(e):d=c.build(e,u),d};if(Array.isArray(s)){if(s.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length(e=e.length>1||e[0]&&e[0].isNode===!0?Tc(e):Ty(e[0]),U(new yg(U(o),e)));F("call",vw);var BI={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},pt=class o extends st{static get type(){return"OperatorNode"}constructor(e,t,n,...i){if(super(),i.length>0){let s=new o(e,t,n);for(let r=0;r>"||n==="<<")return e.getIntegerType(r);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){let c=Math.max(e.getTypeLength(r),e.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else{if(e.isMatrix(r)){if(a==="float")return r;if(e.isVector(a))return e.getVectorFromMatrix(r);if(e.isMatrix(a))return r}else if(e.isMatrix(a)){if(r==="float")return a;if(e.isVector(r))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(r)?a:r}}generate(e,t){let n=this.op,{aNode:i,bNode:s}=this,r=this.getNodeType(e,t),a=null,c=null;r!=="void"?(a=i.getNodeType(e),c=s?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(a)?c=a:e.isVector(c)?a=c:a!==c&&(a=c="float"):n===">>"||n==="<<"?(a=r,c=e.changeComponentType(c,"uint")):n==="%"?(a=r,c=e.isInteger(a)&&e.isInteger(c)?c:a):e.isMatrix(a)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(a):e.isMatrix(c)||(a=c=r):e.isMatrix(c)?a==="float"?a="float":e.isVector(a)?a=e.getVectorFromMatrix(c):a=c=r:a=c=r):a=c=r;let l=i.build(e,a),u=s?s.build(e,c):null,h=e.getFunctionOperator(n);if(t!=="void"){let d=e.renderer.coordinateSystem===Kt;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return d?e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${u} )`,r,t):e.format(`( ${l} ${n} ${u} )`,r,t):e.format(`( ${l} ${n} ${u} )`,r,t);if(n==="%")return e.isInteger(c)?e.format(`( ${l} % ${u} )`,r,t):e.format(`${this.getOperatorMethod(e,r)}( ${l}, ${u} )`,r,t);if(n==="!"||n==="~")return e.format(`(${n}${l})`,a,t);if(h)return e.format(`${h}( ${l}, ${u} )`,r,t);if(e.isMatrix(a)&&c==="float")return e.format(`( ${u} ${n} ${l} )`,r,t);if(a==="float"&&e.isMatrix(c))return e.format(`${l} ${n} ${u}`,r,t);{let f=`( ${l} ${n} ${u} )`;return!d&&r==="bool"&&e.isVector(a)&&e.isVector(c)&&(f=`all${f}`),e.format(f,r,t)}}else if(a!=="void")return h?e.format(`${h}( ${l}, ${u} )`,r,t):e.isMatrix(a)&&c==="float"?e.format(`${u} ${n} ${l}`,r,t):e.format(`${l} ${n} ${u}`,r,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},Et=k(pt,"+").setParameterLength(2,1/0).setName("add"),Se=k(pt,"-").setParameterLength(2,1/0).setName("sub"),de=k(pt,"*").setParameterLength(2,1/0).setName("mul"),Zn=k(pt,"/").setParameterLength(2,1/0).setName("div"),kf=k(pt,"%").setParameterLength(2).setName("mod"),Pb=k(pt,"==").setParameterLength(2).setName("equal"),Tw=k(pt,"!=").setParameterLength(2).setName("notEqual"),bw=k(pt,"<").setParameterLength(2).setName("lessThan"),Ib=k(pt,">").setParameterLength(2).setName("greaterThan"),Sw=k(pt,"<=").setParameterLength(2).setName("lessThanEqual"),Mw=k(pt,">=").setParameterLength(2).setName("greaterThanEqual"),Aw=k(pt,"&&").setParameterLength(2,1/0).setName("and"),Ew=k(pt,"||").setParameterLength(2,1/0).setName("or"),ww=k(pt,"!").setParameterLength(1).setName("not"),Rw=k(pt,"^^").setParameterLength(2).setName("xor"),Cw=k(pt,"&").setParameterLength(2).setName("bitAnd"),Nw=k(pt,"~").setParameterLength(2).setName("bitNot"),Pw=k(pt,"|").setParameterLength(2).setName("bitOr"),Iw=k(pt,"^").setParameterLength(2).setName("bitXor"),Lw=k(pt,"<<").setParameterLength(2).setName("shiftLeft"),Dw=k(pt,">>").setParameterLength(2).setName("shiftRight"),Fw=I(([o])=>(o.addAssign(1),o)),Uw=I(([o])=>(o.subAssign(1),o)),Bw=I(([o])=>{let e=R(o).toConst();return o.addAssign(1),e}),Ow=I(([o])=>{let e=R(o).toConst();return o.subAssign(1),e});F("add",Et);F("sub",Se);F("mul",de);F("div",Zn);F("mod",kf);F("equal",Pb);F("notEqual",Tw);F("lessThan",bw);F("greaterThan",Ib);F("lessThanEqual",Sw);F("greaterThanEqual",Mw);F("and",Aw);F("or",Ew);F("not",ww);F("xor",Rw);F("bitAnd",Cw);F("bitNot",Nw);F("bitOr",Pw);F("bitXor",Iw);F("shiftLeft",Lw);F("shiftRight",Dw);F("incrementBefore",Fw);F("decrementBefore",Uw);F("increment",Bw);F("decrement",Ow);var Vw=(o,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),kf(R(o),R(e)));F("modInt",Vw);var D=class o extends st{static get type(){return"MathNode"}constructor(e,t,n=null,i=null){if(super(),(e===o.MAX||e===o.MIN)&&arguments.length>3){let s=new o(e,t,n);for(let r=2;rr&&s>a?t:r>a?n:a>s?i:t}getNodeType(e){let t=this.method;return t===o.LENGTH||t===o.DISTANCE||t===o.DOT?"float":t===o.CROSS?"vec3":t===o.ALL||t===o.ANY?"bool":t===o.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:t,bNode:n,method:i}=this,s=null;if(i===o.ONE_MINUS)s=Se(1,t);else if(i===o.RECIPROCAL)s=Zn(1,t);else if(i===o.DIFFERENCE)s=Ye(Se(t,n));else if(i===o.TRANSFORM_DIRECTION){let r=t,a=n;e.isMatrix(r.getNodeType(e))?a=Y(P(a),0):r=Y(P(r),0);let c=de(r,a).xyz;s=hr(c)}return s!==null?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method,s=this.getNodeType(e),r=this.getInputType(e),a=this.aNode,c=this.bNode,l=this.cNode,u=e.renderer.coordinateSystem;if(i===o.NEGATE)return e.format("( - "+a.build(e,r)+" )",s,t);{let h=[];return i===o.CROSS?h.push(a.build(e,s),c.build(e,s)):u===Kt&&i===o.STEP?h.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":r),c.build(e,r)):u===Kt&&(i===o.MIN||i===o.MAX)?h.push(a.build(e,r),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":r)):i===o.REFRACT?h.push(a.build(e,r),c.build(e,r),l.build(e,"float")):i===o.MIX?h.push(a.build(e,r),c.build(e,r),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":r)):(u===Nn&&i===o.ATAN&&c!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===o.DFDX||i===o.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${e.shaderStage} stage.`),i="/*"+i+"*/"),h.push(a.build(e,r)),c!==null&&h.push(c.build(e,r)),l!==null&&h.push(l.build(e,r))),e.format(`${e.getMethod(i,s)}( ${h.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};D.ALL="all";D.ANY="any";D.RADIANS="radians";D.DEGREES="degrees";D.EXP="exp";D.EXP2="exp2";D.LOG="log";D.LOG2="log2";D.SQRT="sqrt";D.INVERSE_SQRT="inversesqrt";D.FLOOR="floor";D.CEIL="ceil";D.NORMALIZE="normalize";D.FRACT="fract";D.SIN="sin";D.COS="cos";D.TAN="tan";D.ASIN="asin";D.ACOS="acos";D.ATAN="atan";D.ABS="abs";D.SIGN="sign";D.LENGTH="length";D.NEGATE="negate";D.ONE_MINUS="oneMinus";D.DFDX="dFdx";D.DFDY="dFdy";D.ROUND="round";D.RECIPROCAL="reciprocal";D.TRUNC="trunc";D.FWIDTH="fwidth";D.TRANSPOSE="transpose";D.DETERMINANT="determinant";D.INVERSE="inverse";D.EQUALS="equals";D.MIN="min";D.MAX="max";D.STEP="step";D.REFLECT="reflect";D.DISTANCE="distance";D.DIFFERENCE="difference";D.DOT="dot";D.CROSS="cross";D.POW="pow";D.TRANSFORM_DIRECTION="transformDirection";D.MIX="mix";D.CLAMP="clamp";D.REFRACT="refract";D.SMOOTHSTEP="smoothstep";D.FACEFORWARD="faceforward";var Gw=b(1e-6),OI=b(1e6),xg=b(Math.PI),VI=b(Math.PI*2),kw=k(D,D.ALL).setParameterLength(1),zw=k(D,D.ANY).setParameterLength(1),Hw=k(D,D.RADIANS).setParameterLength(1),Ww=k(D,D.DEGREES).setParameterLength(1),Lb=k(D,D.EXP).setParameterLength(1),Su=k(D,D.EXP2).setParameterLength(1),Ry=k(D,D.LOG).setParameterLength(1),fs=k(D,D.LOG2).setParameterLength(1),bs=k(D,D.SQRT).setParameterLength(1),Db=k(D,D.INVERSE_SQRT).setParameterLength(1),ps=k(D,D.FLOOR).setParameterLength(1),Cy=k(D,D.CEIL).setParameterLength(1),hr=k(D,D.NORMALIZE).setParameterLength(1),mr=k(D,D.FRACT).setParameterLength(1),Kn=k(D,D.SIN).setParameterLength(1),sr=k(D,D.COS).setParameterLength(1),Xw=k(D,D.TAN).setParameterLength(1),qw=k(D,D.ASIN).setParameterLength(1),Fb=k(D,D.ACOS).setParameterLength(1),Ny=k(D,D.ATAN).setParameterLength(1,2),Ye=k(D,D.ABS).setParameterLength(1),gf=k(D,D.SIGN).setParameterLength(1),ms=k(D,D.LENGTH).setParameterLength(1),$w=k(D,D.NEGATE).setParameterLength(1),Yw=k(D,D.ONE_MINUS).setParameterLength(1),Ub=k(D,D.DFDX).setParameterLength(1),Bb=k(D,D.DFDY).setParameterLength(1),Kw=k(D,D.ROUND).setParameterLength(1),jw=k(D,D.RECIPROCAL).setParameterLength(1),Ob=k(D,D.TRUNC).setParameterLength(1),Zw=k(D,D.FWIDTH).setParameterLength(1),Jw=k(D,D.TRANSPOSE).setParameterLength(1),Qw=k(D,D.DETERMINANT).setParameterLength(1),eR=k(D,D.INVERSE).setParameterLength(1),tR=(o,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),Pb(o,e)),Ln=k(D,D.MIN).setParameterLength(2,1/0),mt=k(D,D.MAX).setParameterLength(2,1/0),Py=k(D,D.STEP).setParameterLength(2),nR=k(D,D.REFLECT).setParameterLength(2),iR=k(D,D.DISTANCE).setParameterLength(2),sR=k(D,D.DIFFERENCE).setParameterLength(2),uo=k(D,D.DOT).setParameterLength(2),Iy=k(D,D.CROSS).setParameterLength(2),yi=k(D,D.POW).setParameterLength(2),Vb=o=>de(o,o),rR=o=>de(o,o,o),oR=o=>de(o,o,o,o),aR=k(D,D.TRANSFORM_DIRECTION).setParameterLength(2),cR=o=>de(gf(o),yi(Ye(o),1/3)),Gb=o=>uo(o,o),Ne=k(D,D.MIX).setParameterLength(3),bi=(o,e=0,t=1)=>U(new D(D.CLAMP,U(o),U(e),U(t))),kb=o=>bi(o),zb=k(D,D.REFRACT).setParameterLength(3),Si=k(D,D.SMOOTHSTEP).setParameterLength(3),Hb=k(D,D.FACEFORWARD).setParameterLength(3),lR=I(([o])=>{let n=43758.5453,i=uo(o.xy,O(12.9898,78.233)),s=kf(i,xg);return mr(Kn(s).mul(n))}),uR=(o,e,t)=>Ne(e,t,o),hR=(o,e,t)=>Si(e,t,o),dR=(o,e)=>Py(e,o),fR=(o,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Ny(o,e)),GI=Hb,kI=Db;F("all",kw);F("any",zw);F("equals",tR);F("radians",Hw);F("degrees",Ww);F("exp",Lb);F("exp2",Su);F("log",Ry);F("log2",fs);F("sqrt",bs);F("inverseSqrt",Db);F("floor",ps);F("ceil",Cy);F("normalize",hr);F("fract",mr);F("sin",Kn);F("cos",sr);F("tan",Xw);F("asin",qw);F("acos",Fb);F("atan",Ny);F("abs",Ye);F("sign",gf);F("length",ms);F("lengthSq",Gb);F("negate",$w);F("oneMinus",Yw);F("dFdx",Ub);F("dFdy",Bb);F("round",Kw);F("reciprocal",jw);F("trunc",Ob);F("fwidth",Zw);F("atan2",fR);F("min",Ln);F("max",mt);F("step",dR);F("reflect",nR);F("distance",iR);F("dot",uo);F("cross",Iy);F("pow",yi);F("pow2",Vb);F("pow3",rR);F("pow4",oR);F("transformDirection",aR);F("mix",uR);F("clamp",bi);F("refract",zb);F("smoothstep",hR);F("faceForward",Hb);F("difference",sR);F("saturate",kb);F("cbrt",cR);F("transpose",Jw);F("determinant",Qw);F("inverse",eR);F("rand",lR);var s0=class extends j{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);let i=t.getNodeType(e);if(n!==null){let s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(i))return s}return i}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,i!==null&&(e.getDataFromNode(i).parentNodeBlock=s);let r=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=r?n:n.context({nodeBlock:n}),a.elseNode=i?r?i:i.context({nodeBlock:i}):null}generate(e,t){let n=this.getNodeType(e),i=e.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;let{condNode:s,ifNode:r,elseNode:a}=e.getNodeProperties(this),c=e.currentFunctionNode,l=t!=="void",u=l?Yi(n).build(e):"";i.nodeProperty=u;let h=s.build(e,"bool");if(e.context.uniformFlow&&a!==null){let p=r.build(e,n),m=a.build(e,n),_=e.getTernary(h,p,m);return e.format(_,n,t)}e.addFlowCode(` ${e.tab}if ( ${h} ) { `).addFlowTab();let f=r.build(e,n);if(f&&(l?f=u+" = "+f+";":(f="return "+f+";",c===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),f="// "+f))),e.removeFlowTab().addFlowCode(e.tab+" "+f+` `+e.tab+"}"),a!==null){e.addFlowCode(` else { `).addFlowTab();let p=a.build(e,n);p&&(l?p=u+" = "+p+";":(p="return "+p+";",c===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+` `+e.tab+`} `)}else e.addFlowCode(` `);return e.format(u,n,t)}},$t=ue(s0).setParameterLength(2,3);F("select",$t);var _f=class extends j{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let i=this.node.build(e,t);return e.setContext(n),i}},zf=ue(_f).setParameterLength(1,2),pR=o=>zf(o,{uniformFlow:!0}),Wb=(o,e)=>zf(o,{nodeName:e});function mR(o,e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),Wb(o,e)}F("context",zf);F("label",mR);F("uniformFlow",pR);F("setName",Wb);var Ac=class extends j{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}build(...e){return this.intent===!0&&e[0].getNodeProperties(this).assign!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:i}=this,{renderer:s}=e,r=s.backend.isWebGPUBackend===!0,a=!1,c=!1;i&&(a=e.isDeterministic(t),c=r?i:a);let l=e.getVectorType(this.getNodeType(e)),u=t.build(e,l),h=e.getVarFromNode(this,n,l,void 0,c),d=e.getPropertyName(h),f=d;if(c)if(r)f=a?`const ${d}`:`let ${d}`;else{let p=t.getArrayCount(e);f=`const ${e.getVar(h.type,d,p)}`}return e.addLineFlowCode(`${f} = ${u}`,this),d}},Xb=ue(Ac),gR=(o,e=null)=>Xb(o,e).toStack(),_R=(o,e=null)=>Xb(o,e,!0).toStack(),yR=o=>by()===null?o:Xb(o).setIntent(!0).toStack();F("toVar",gR);F("toConst",_R);F("toVarIntent",yR);var vg=class extends j{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},xu=(o,e,t=null)=>U(new vg(U(o),e,t)),Tg=class extends j{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}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 i=this.name,s=this.getNodeType(e),r=this.interpolationType,a=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,i,s,r,a),t.node=xu(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(pu.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(pu.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),i=this.setupVarying(e);if(n[t]===void 0){let s=this.getNodeType(e),r=e.getPropertyName(i,pu.VERTEX);e.flowNodeFromShaderStage(pu.VERTEX,n.node,s,r),n[t]=r}return e.getPropertyName(i)}},Ss=ue(Tg).setParameterLength(1,2),xR=o=>Ss(o);F("toVarying",Ss);F("toVertexStage",xR);F("varying",(...o)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Ss(...o)));F("vertexStage",(...o)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Ss(...o)));var vR=I(([o])=>{let e=o.mul(.9478672986).add(.0521327014).pow(2.4),t=o.mul(.0773993808),n=o.lessThanEqual(.04045);return Ne(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),TR=I(([o])=>{let e=o.pow(.41666).mul(1.055).sub(.055),t=o.mul(12.92),n=o.lessThanEqual(.0031308);return Ne(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qb="WorkingColorSpace",zI="OutputColorSpace",Mu=class extends st{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===qb?xe.workingColorSpace:t===zI?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),i=this.resolveColorSpace(e,this.target),s=t;return xe.enabled===!1||n===i||!n||!i||(xe.getTransfer(n)===he&&(s=Y(vR(s.rgb),s.a)),xe.getPrimaries(n)!==xe.getPrimaries(i)&&(s=Y(dn(xe._getMatrix(new pe,n,i)).mul(s.rgb),s.a)),xe.getTransfer(i)===he&&(s=Y(TR(s.rgb),s.a))),s}},bR=(o,e)=>U(new Mu(U(o),qb,e)),Ly=(o,e)=>U(new Mu(U(o),e,qb)),HI=(o,e,t)=>U(new Mu(U(o),e,t));F("workingToColorSpace",bR);F("colorSpaceToWorking",Ly);var WI=class extends _s{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(),i=this.getNodeType();return e.format(t,n,i)}},bg=class extends j{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=me.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new WI(this,U(e)))}setNodeType(e){let t=se(null,e);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 i=1;iU(new bg(o,e,t)),Sg=class extends bg{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(te)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}},SR=(o,e,t=null)=>U(new Sg(o,e,t)),Mg=class extends st{static get type(){return"ToneMappingNode"}constructor(e,t=AR,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return tf(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Gi)return t;let i=null,s=e.renderer.library.getToneMappingFunction(n);return s!==null?i=Y(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=t),i}},MR=(o,e,t)=>U(new Mg(o,U(e),U(t))),AR=SR("toneMappingExposure","float");F("toneMapping",(o,e,t)=>MR(e,t,o));var Ag=class extends af{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=i,this.usage=Mr,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,i=e.getTypeLength(t),s=this.bufferStride||i,r=this.bufferOffset,a=n.isInterleavedBuffer===!0?n:new ci(n,s),c=new Wn(a,i,r);a.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(n),s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=i,s=i):s=Ss(this).build(e,t),s}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}},Hf=(o,e=null,t=0,n=0)=>U(new Ag(o,e,t,n)),ER=(o,e=null,t=0,n=0)=>Hf(o,e,t,n).setUsage(er),Eg=(o,e=null,t=0,n=0)=>Hf(o,e,t,n).setInstanced(!0),r0=(o,e=null,t=0,n=0)=>ER(o,e,t,n).setInstanced(!0);F("toAttribute",o=>Hf(o.value));var wg=class extends j{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=me.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n==="compute"){let i=this.computeNode.build(e,"void");i!==""&&e.addLineFlowCode(i,this)}else{let s=e.getNodeProperties(this).outputComputeNode;if(s)return s.build(e,t)}}},$b=(o,e=[64])=>{(e.length===0||e.length>3)&&console.error("THREE.TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;t$b(o,t).setCount(e);F("compute",wR);F("computeKernel",$b);var Rg=class extends j{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let i=this.node.getNodeType(e);return e.setCache(t),i}build(e,...t){let n=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);let s=this.node.build(e,...t);return e.setCache(n),s}},Yd=(o,e)=>U(new Rg(U(o),e));F("cache",Yd);var Cg=class extends j{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)}},RR=ue(Cg).setParameterLength(2);F("bypass",RR);var yf=class extends j{static get type(){return"RemapNode"}constructor(e,t,n,i=b(0),s=b(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:i,outHighNode:s,doClamp:r}=this,a=e.sub(t).div(n.sub(t));return r===!0&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}},CR=ue(yf,null,null,{doClamp:!1}).setParameterLength(3,5),NR=ue(yf).setParameterLength(3,5);F("remap",CR);F("remapClamp",NR);var Ec=class extends j{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),i=this.snippet;if(n==="void")e.addLineFlowCode(i,this);else return e.format(i,n,t)}},dr=ue(Ec).setParameterLength(1,2),PR=o=>(o?$t(o,dr("discard")):dr("discard")).toStack(),qI=()=>dr("return").toStack();F("discard",PR);var Ng=class extends st{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Gi,i=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Xi;return n!==Gi&&(t=t.toneMapping(n)),i!==Xi&&i!==xe.workingColorSpace&&(t=t.workingToColorSpace(i)),t}},Yb=(o,e=null,t=null)=>U(new Ng(U(o),e,t));F("renderOutput",Yb);var Pg=class extends st{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),i="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(i.length),r="";return r+="// #"+i+`# `,r+=e.flow.code.replace(/^\t/mg,"")+` `,r+="/* ... */ "+n+` /* ... */ `,r+="// #"+s+`# `,t!==null?t(e,r):console.log(r),n}},IR=(o,e=null)=>U(new Pg(U(o),e)).toStack();F("debug",IR);function $I(o){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",o)}var xf=class extends j{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 i=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(i)}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 s=e.geometry.getAttribute(t),r=e.getTypeFromAttribute(s),a=e.getAttribute(t,r);return e.shaderStage==="vertex"?e.format(a.name,r,n):Ss(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}},Sn=(o,e=null)=>U(new xf(o,e)),ze=(o=0)=>Sn("uv"+(o>0?o:""),"vec2"),Ig=class extends j{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"),i=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(e),t)}},to=ue(Ig).setParameterLength(1,2),Lg=class extends so{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=me.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:i,height:s}=n;this.value=Math.log2(Math.max(i,s))}}},Kb=ue(Lg).setParameterLength(1),jb=new Ge,Jn=class extends so{static get type(){return"TextureNode"}constructor(e=jb,t=null,n=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=me.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===Je?"uvec4":this.value.type===Vt?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return ze(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=se(this.value.matrix)),this._matrixUniform.mul(P(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?me.OBJECT:me.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(R(to(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let i=this.uvNode;(i===null||e.context.forceUVContext===!0)&&e.context.getUV&&(i=e.context.getUV(this,e)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,n,i,s,r,a,c,l){let u=this.value,h;return i?h=e.generateTextureLevel(u,t,n,i,r,l):s?h=e.generateTextureBias(u,t,n,s,r,l):c?h=e.generateTextureGrad(u,t,n,c,r,l):a?h=e.generateTextureCompare(u,t,n,a,r,l):this.sampler===!1?h=e.generateTextureLoad(u,t,n,r,l):h=e.generateTexture(u,t,n,r,l),h}generate(e,t){let n=this.value,i=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{let r=e.getDataFromNode(this),a=r.propertyName;if(a===void 0){let{uvNode:u,levelNode:h,biasNode:d,compareNode:f,depthNode:p,gradNode:m,offsetNode:_}=i,y=this.generateUV(e,u),x=h?h.build(e,"float"):null,v=d?d.build(e,"float"):null,T=p?p.build(e,"int"):null,M=f?f.build(e,"float"):null,w=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,E=_?this.generateOffset(e,_):null,A=e.getVarFromNode(this);a=e.getPropertyName(A);let N=this.generateSnippet(e,s,y,x,v,T,M,w,E);e.addLineFlowCode(`${a} = ${N}`,this),r.snippet=N,r.propertyName=a}let c=a,l=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(c=Ly(dr(c,l),n.colorSpace).setup(e).build(e,l)),e.format(c,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getBase(),U(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=U(e).mul(Kb(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===We||n.magFilter===We)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getBase(),U(t)}size(e){return to(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getBase(),U(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getBase(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getBase(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getBase(),U(t)}offset(e){let t=this.clone();return t.offsetNode=U(e),t.referenceNode=this.getBase(),U(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.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},YI=ue(Jn).setParameterLength(1,4).setName("texture"),Te=(o=jb,e=null,t=null,n=null)=>{let i;return o&&o.isTextureNode===!0?(i=U(o.clone()),i.referenceNode=o.getBase(),e!==null&&(i.uvNode=U(e)),t!==null&&(i.levelNode=U(t)),n!==null&&(i.biasNode=U(n))):i=YI(o,e,t,n),i},KI=(o=jb)=>Te(o),xt=(...o)=>Te(...o).setSampler(!1),jI=o=>(o.isNode===!0?o:Te(o)).convert("sampler"),ZI=o=>(o.isNode===!0?o:Te(o)).convert("samplerComparison"),Au=class extends so{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"}},Wf=(o,e,t)=>U(new Au(o,e,t)),o0=class extends _s{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),i=this.node.getPaddedType();return e.format(t,i,n)}},Dg=class extends Au{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?lr(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=me.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let i=0;iU(new Dg(o,e)),a0=class extends j{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}},gr=ue(a0).setParameterLength(1),Rd,Cd,Yt=class o extends j{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===o.DPR?"float":this.scope===o.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=me.NONE;return(this.scope===o.SIZE||this.scope===o.VIEWPORT||this.scope===o.DPR)&&(e=me.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===o.VIEWPORT?t!==null?Cd.copy(t.viewport):(e.getViewport(Cd),Cd.multiplyScalar(e.getPixelRatio())):this.scope===o.DPR?this._output.value=e.getPixelRatio():t!==null?(Rd.width=t.width,Rd.height=t.height):e.getDrawingBufferSize(Rd)}setup(){let e=this.scope,t=null;return e===o.SIZE?t=se(Rd||(Rd=new B)):e===o.VIEWPORT?t=se(Cd||(Cd=new ge)):e===o.DPR?t=se(1):t=O(Xf.div(Rc)),this._output=t,t}generate(e){if(this.scope===o.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let n=e.getNodeProperties(Rc).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}};Yt.COORDINATE="coordinate";Yt.VIEWPORT="viewport";Yt.SIZE="size";Yt.UV="uv";Yt.DPR="dpr";var LR=z(Yt,Yt.DPR),ur=z(Yt,Yt.UV),Rc=z(Yt,Yt.SIZE),Xf=z(Yt,Yt.COORDINATE),vu=z(Yt,Yt.VIEWPORT),Zb=vu.zw,DR=Xf.sub(vu.xy),JI=DR.div(Zb),QI=I(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Rc),"vec2").once()(),ho=se(0,"uint").setName("u_cameraIndex").setGroup(wy("cameraIndex")).toVarying("v_cameraIndex"),or=se("float").setName("cameraNear").setGroup(te).onRenderUpdate(({camera:o})=>o.near),ar=se("float").setName("cameraFar").setGroup(te).onRenderUpdate(({camera:o})=>o.far),_i=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.projectionMatrix);e=un(t).setGroup(te).setName("cameraProjectionMatrices").element(o.isMultiViewCamera?gr("gl_ViewID_OVR"):ho).toConst("cameraProjectionMatrix")}else e=se("mat4").setName("cameraProjectionMatrix").setGroup(te).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),eL=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.projectionMatrixInverse);e=un(t).setGroup(te).setName("cameraProjectionMatricesInverse").element(o.isMultiViewCamera?gr("gl_ViewID_OVR"):ho).toConst("cameraProjectionMatrixInverse")}else e=se("mat4").setName("cameraProjectionMatrixInverse").setGroup(te).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),ei=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.matrixWorldInverse);e=un(t).setGroup(te).setName("cameraViewMatrices").element(o.isMultiViewCamera?gr("gl_ViewID_OVR"):ho).toConst("cameraViewMatrix")}else e=se("mat4").setName("cameraViewMatrix").setGroup(te).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),tL=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.matrixWorld);e=un(t).setGroup(te).setName("cameraWorldMatrices").element(o.isMultiViewCamera?gr("gl_ViewID_OVR"):ho).toConst("cameraWorldMatrix")}else e=se("mat4").setName("cameraWorldMatrix").setGroup(te).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),nL=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.normalMatrix);e=un(t).setGroup(te).setName("cameraNormalMatrices").element(o.isMultiViewCamera?gr("gl_ViewID_OVR"):ho).toConst("cameraNormalMatrix")}else e=se("mat3").setName("cameraNormalMatrix").setGroup(te).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),Kd=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i=0,s=o.cameras.length;i{let r=i.cameras,a=s.array;for(let c=0,l=r.length;cn.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),iL=I(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){let t=[];for(let i of o.cameras)t.push(i.viewport);e=un(t,"vec4").setGroup(te).setName("cameraViewports").element(ho).toConst("cameraViewport")}else e=Y(0,0,Rc.x,Rc.y).toConst("cameraViewport");return e}).once()(),WA=new ot,bt=class o extends j{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=me.OBJECT,this.uniformNode=new so(null)}getNodeType(){let e=this.scope;if(e===o.WORLD_MATRIX)return"mat4";if(e===o.POSITION||e===o.VIEW_POSITION||e===o.DIRECTION||e===o.SCALE)return"vec3";if(e===o.RADIUS)return"float"}update(e){let t=this.object3d,n=this.uniformNode,i=this.scope;if(i===o.WORLD_MATRIX)n.value=t.matrixWorld;else if(i===o.POSITION)n.value=n.value||new S,n.value.setFromMatrixPosition(t.matrixWorld);else if(i===o.SCALE)n.value=n.value||new S,n.value.setFromMatrixScale(t.matrixWorld);else if(i===o.DIRECTION)n.value=n.value||new S,t.getWorldDirection(n.value);else if(i===o.VIEW_POSITION){let s=e.camera;n.value=n.value||new S,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}else if(i===o.RADIUS){let s=e.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),WA.copy(s.boundingSphere).applyMatrix4(t.matrixWorld),n.value=WA.radius}}generate(e){let t=this.scope;return t===o.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===o.POSITION||t===o.VIEW_POSITION||t===o.DIRECTION||t===o.SCALE?this.uniformNode.nodeType="vec3":t===o.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};bt.WORLD_MATRIX="worldMatrix";bt.POSITION="position";bt.SCALE="scale";bt.VIEW_POSITION="viewPosition";bt.DIRECTION="direction";bt.RADIUS="radius";var sL=ue(bt,bt.DIRECTION).setParameterLength(1),rL=ue(bt,bt.WORLD_MATRIX).setParameterLength(1),FR=ue(bt,bt.POSITION).setParameterLength(1),oL=ue(bt,bt.SCALE).setParameterLength(1),aL=ue(bt,bt.VIEW_POSITION).setParameterLength(1),cL=ue(bt,bt.RADIUS).setParameterLength(1),An=class extends bt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},lL=z(An,An.DIRECTION),xi=z(An,An.WORLD_MATRIX),uL=z(An,An.POSITION),hL=z(An,An.SCALE),dL=z(An,An.VIEW_POSITION),UR=z(An,An.RADIUS),BR=se(new pe).onObjectUpdate(({object:o},e)=>e.value.getNormalMatrix(o.matrixWorld)),fL=se(new ee).onObjectUpdate(({object:o},e)=>e.value.copy(o.matrixWorld).invert()),fr=I(o=>o.renderer.overrideNodes.modelViewMatrix||OR).once()().toVar("modelViewMatrix"),OR=ei.mul(xi),c0=I(o=>(o.context.isHighPrecisionModelViewMatrix=!0,se("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),l0=I(o=>{let e=o.context.isHighPrecisionModelViewMatrix;return se("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Qt=Sn("position","vec3"),vt=Qt.toVarying("positionLocal"),Fg=Qt.toVarying("positionPrevious"),jn=I(o=>xi.mul(vt).xyz.toVarying(o.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),Jb=I(()=>vt.transformDirection(xi).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Tt=I(o=>o.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Qe=Tt.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection"),Ug=class extends j{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";let{material:t}=e;return t.side===Nt?"false":e.getFrontFacing()}},VR=z(Ug),Qb=b(VR).mul(2).sub(1),Ou=I(([o],{material:e})=>{let t=e.side;return t===Nt?o=o.mul(-1):t===fi&&(o=o.mul(Qb)),o}),Dy=Sn("normal","vec3"),Dn=I(o=>o.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),P(0,1,0)):Dy,"vec3").once()().toVar("normalLocal"),GR=Tt.dFdx().cross(Tt.dFdy()).normalize().toVar("normalFlat"),Eu=I(o=>{let e;return o.material.flatShading===!0?e=GR:e=eS(Dn).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),kR=I(o=>{let e=Eu.transformDirection(ei);return o.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Oe=I(({subBuildFn:o,material:e,context:t})=>{let n;return o==="NORMAL"||o==="VERTEX"?(n=Eu,e.flatShading!==!0&&(n=Ou(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),fo=Oe.transformDirection(ei).toVar("normalWorld"),yc=I(({subBuildFn:o,context:e})=>{let t;return o==="NORMAL"||o==="VERTEX"?t=Oe:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),zR=I(([o,e=xi])=>{let t=dn(e),n=o.div(P(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),eS=I(([o],e)=>{let t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(o);let n=BR.mul(o);return ei.transformDirection(n)}),pL=I(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Oe)).once(["NORMAL","VERTEX"])(),mL=I(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),fo)).once(["NORMAL","VERTEX"])(),gL=I(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),yc)).once(["NORMAL","VERTEX"])(),XA=new xn,bv=new ee,HR=se(0).onReference(({material:o})=>o).onObjectUpdate(({material:o})=>o.refractionRatio),tg=se(1).onReference(({material:o})=>o).onObjectUpdate(function({material:o,scene:e}){return o.envMap?o.envMapIntensity:e.environmentIntensity}),tS=se(new ee).onReference(function(o){return o.material}).onObjectUpdate(function({material:o,scene:e}){let t=e.environment!==null&&o.envMap===null?e.environmentRotation:o.envMapRotation;return t?(XA.copy(t),bv.makeRotationFromEuler(XA)):bv.identity(),bv}),WR=Qe.negate().reflect(Oe),XR=Qe.negate().refract(Oe,HR),qR=WR.transformDirection(ei).toVar("reflectVector"),$R=XR.transformDirection(ei).toVar("reflectVector"),YR=new Pi,Bg=class extends Jn{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,i=null){super(e,t,n,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===rs?qR:e.mapping===zr?$R:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),P(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===Nn||!n.isRenderTargetTexture)&&(t=P(t.x.negate(),t.yz)),tS.mul(t)}generateUV(e,t){return t.build(e,"vec3")}},nS=ue(Bg).setParameterLength(1,4).setName("cubeTexture"),wu=(o=YR,e=null,t=null,n=null)=>{let i;return o&&o.isCubeTextureNode===!0?(i=U(o.clone()),i.referenceNode=o,e!==null&&(i.uvNode=U(e)),t!==null&&(i.levelNode=U(t)),n!==null&&(i.biasNode=U(n))):i=nS(o,e,t,n),i},_L=(o=YR)=>nS(o),u0=class extends _s{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(),i=this.getNodeType();return e.format(t,n,i)}},Cc=class extends j{static get type(){return"ReferenceNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=me.OBJECT}element(e){return U(new u0(this,U(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=Wf(null,e,this.count):Array.isArray(this.getValueFromReference())?t=un(null,e):e==="texture"?t=Te(null):e==="cubeTexture"?t=wu(null):t=se(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),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 i=1;iU(new Cc(o,e,t)),h0=(o,e,t,n)=>U(new Cc(o,e,n,t)),Og=class extends Cc{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?this.material:e.material,this.reference}},cr=(o,e,t=null)=>U(new Og(o,e,t)),KR=ze(),yL=Tt.dFdx(),xL=Tt.dFdy(),jR=KR.dFdx(),ZR=KR.dFdy(),JR=Oe,QR=xL.cross(JR),eC=JR.cross(yL),d0=QR.mul(jR.x).add(eC.mul(ZR.x)),f0=QR.mul(jR.y).add(eC.mul(ZR.y)),qA=d0.dot(d0).max(f0.dot(f0)),tC=qA.equal(0).select(0,qA.inverseSqrt()),vL=d0.mul(tC).toVar("tangentViewFrame"),TL=f0.mul(tC).toVar("bitangentViewFrame"),Fy=I(o=>(o.geometry.hasAttribute("tangent")===!1&&o.geometry.computeTangents(),Sn("tangent","vec4")))(),qf=Fy.xyz.toVar("tangentLocal"),Uy=I(({subBuildFn:o,geometry:e,material:t})=>{let n;return o==="VERTEX"||e.hasAttribute("tangent")?n=fr.mul(Y(qf,0)).xyz.toVarying("v_tangentView").normalize():n=vL,t.flatShading!==!0&&(n=Ou(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),nC=Uy.transformDirection(ei).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),By=I(([o,e],{subBuildFn:t,material:n})=>{let i=o.mul(Fy.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(i=i.toVarying(e)),i}).once(["NORMAL"]),bL=By(Dy.cross(Fy),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),SL=By(Dn.cross(qf),"v_bitangentLocal").normalize().toVar("bitangentLocal"),iC=I(({subBuildFn:o,geometry:e,material:t})=>{let n;return o==="VERTEX"||e.hasAttribute("tangent")?n=By(Oe.cross(Uy),"v_bitangentView").normalize():n=TL,t.flatShading!==!0&&(n=Ou(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),ML=By(fo.cross(nC),"v_bitangentWorld").normalize().toVar("bitangentWorld"),xc=dn(Uy,iC,Oe).toVar("TBNViewMatrix"),sC=Qe.mul(xc),AL=(o,e)=>o.sub(sC.mul(e)),rC=I(()=>{let o=Sc.cross(Qe);return o=o.cross(Sc).normalize(),o=Ne(o,Oe,Jr.mul(ds.oneMinus()).oneMinus().pow2().pow2()).normalize(),o}).once()(),Vg=class extends st{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Wi}setup({material:e}){let{normalMapType:t,scaleNode:n}=this,i=this.node.mul(2).sub(1);if(n!==null){let r=n;e.flatShading===!0&&(r=Ou(r)),i=P(i.xy.mul(r),i.z)}let s=null;return t===pm?s=eS(i):t===Wi?s=xc.mul(i).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),s=Oe),s}},p0=ue(Vg).setParameterLength(1,2),EL=I(({textureNode:o,bumpScale:e})=>{let t=i=>o.cache().context({getUV:s=>i(s.uvNode||ze()),forceUVContext:!0}),n=b(t(i=>i));return O(b(t(i=>i.add(i.dFdx()))).sub(n),b(t(i=>i.add(i.dFdy()))).sub(n)).mul(e)}),wL=I(o=>{let{surf_pos:e,surf_norm:t,dHdxy:n}=o,i=e.dFdx().normalize(),s=e.dFdy().normalize(),r=t,a=s.cross(r),c=r.cross(i),l=i.dot(a).mul(Qb),u=l.sign().mul(n.x.mul(a).add(n.y.mul(c)));return l.abs().mul(t).sub(u).normalize()}),Gg=class extends st{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode!==null?this.scaleNode:1,t=EL({textureNode:this.textureNode,bumpScale:e});return wL({surf_pos:Tt,surf_norm:Oe,dHdxy:t})}},iS=ue(Gg).setParameterLength(1,2),$A=new Map,G=class o extends j{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=$A.get(e);return n===void 0&&(n=cr(e,t),$A.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(e){let t=e.context.material,n=this.scope,i=null;if(n===o.COLOR){let s=t.color!==void 0?this.getColor(n):P();t.map&&t.map.isTexture===!0?i=s.mul(this.getTexture("map")):i=s}else if(n===o.OPACITY){let s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?i=s.mul(this.getTexture("alpha")):i=s}else if(n===o.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=b(1);else if(n===o.SPECULAR_INTENSITY){let s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s}else if(n===o.SPECULAR_COLOR){let s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?i=s.mul(this.getTexture(n).rgb):i=s}else if(n===o.ROUGHNESS){let s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).g):i=s}else if(n===o.METALNESS){let s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?i=s.mul(this.getTexture(n).b):i=s}else if(n===o.EMISSIVE){let s=this.getFloat("emissiveIntensity"),r=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?i=r.mul(this.getTexture(n)):i=r}else if(n===o.NORMAL)t.normalMap?(i=p0(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType):t.bumpMap?i=iS(this.getTexture("bump").r,this.getFloat("bumpScale")):i=Oe;else if(n===o.CLEARCOAT){let s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===o.CLEARCOAT_ROUGHNESS){let s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===o.CLEARCOAT_NORMAL)t.clearcoatNormalMap?i=p0(this.getTexture(n),this.getCache(n+"Scale","vec2")):i=Oe;else if(n===o.SHEEN){let s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?i=s.mul(this.getTexture("sheenColor").rgb):i=s}else if(n===o.SHEEN_ROUGHNESS){let s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s,i=i.clamp(.07,1)}else if(n===o.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){let s=this.getTexture(n);i=My(du.x,du.y,du.y.negate(),du.x).mul(s.rg.mul(2).sub(O(1)).normalize().mul(s.b))}else i=du;else if(n===o.IRIDESCENCE_THICKNESS){let s=Xe("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let r=Xe("0","float",t.iridescenceThicknessRange);i=s.sub(r).mul(this.getTexture(n).g).add(r)}else i=s}else if(n===o.TRANSMISSION){let s=this.getFloat(n);t.transmissionMap?i=s.mul(this.getTexture(n).r):i=s}else if(n===o.THICKNESS){let s=this.getFloat(n);t.thicknessMap?i=s.mul(this.getTexture(n).g):i=s}else if(n===o.IOR)i=this.getFloat(n);else if(n===o.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===o.AO)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===o.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(n):b(0);else{let s=this.getNodeType(e);i=this.getCache(n,s)}return i}};G.ALPHA_TEST="alphaTest";G.COLOR="color";G.OPACITY="opacity";G.SHININESS="shininess";G.SPECULAR="specular";G.SPECULAR_STRENGTH="specularStrength";G.SPECULAR_INTENSITY="specularIntensity";G.SPECULAR_COLOR="specularColor";G.REFLECTIVITY="reflectivity";G.ROUGHNESS="roughness";G.METALNESS="metalness";G.NORMAL="normal";G.CLEARCOAT="clearcoat";G.CLEARCOAT_ROUGHNESS="clearcoatRoughness";G.CLEARCOAT_NORMAL="clearcoatNormal";G.EMISSIVE="emissive";G.ROTATION="rotation";G.SHEEN="sheen";G.SHEEN_ROUGHNESS="sheenRoughness";G.ANISOTROPY="anisotropy";G.IRIDESCENCE="iridescence";G.IRIDESCENCE_IOR="iridescenceIOR";G.IRIDESCENCE_THICKNESS="iridescenceThickness";G.IOR="ior";G.TRANSMISSION="transmission";G.THICKNESS="thickness";G.ATTENUATION_DISTANCE="attenuationDistance";G.ATTENUATION_COLOR="attenuationColor";G.LINE_SCALE="scale";G.LINE_DASH_SIZE="dashSize";G.LINE_GAP_SIZE="gapSize";G.LINE_WIDTH="linewidth";G.LINE_DASH_OFFSET="dashOffset";G.POINT_SIZE="size";G.DISPERSION="dispersion";G.LIGHT_MAP="light";G.AO="ao";var oC=z(G,G.ALPHA_TEST),kg=z(G,G.COLOR),aC=z(G,G.SHININESS),cC=z(G,G.EMISSIVE),Oy=z(G,G.OPACITY),lC=z(G,G.SPECULAR),m0=z(G,G.SPECULAR_INTENSITY),uC=z(G,G.SPECULAR_COLOR),jd=z(G,G.SPECULAR_STRENGTH),ng=z(G,G.REFLECTIVITY),hC=z(G,G.ROUGHNESS),dC=z(G,G.METALNESS),fC=z(G,G.NORMAL),pC=z(G,G.CLEARCOAT),mC=z(G,G.CLEARCOAT_ROUGHNESS),gC=z(G,G.CLEARCOAT_NORMAL),_C=z(G,G.ROTATION),yC=z(G,G.SHEEN),xC=z(G,G.SHEEN_ROUGHNESS),vC=z(G,G.ANISOTROPY),TC=z(G,G.IRIDESCENCE),bC=z(G,G.IRIDESCENCE_IOR),SC=z(G,G.IRIDESCENCE_THICKNESS),MC=z(G,G.TRANSMISSION),AC=z(G,G.THICKNESS),EC=z(G,G.IOR),wC=z(G,G.ATTENUATION_DISTANCE),RC=z(G,G.ATTENUATION_COLOR),sS=z(G,G.LINE_SCALE),rS=z(G,G.LINE_DASH_SIZE),oS=z(G,G.LINE_GAP_SIZE),ig=z(G,G.LINE_WIDTH),aS=z(G,G.LINE_DASH_OFFSET),CC=z(G,G.POINT_SIZE),NC=z(G,G.DISPERSION),cS=z(G,G.LIGHT_MAP),PC=z(G,G.AO),du=se(new B).onReference(function(o){return o.material}).onRenderUpdate(function({material:o}){this.value.set(o.anisotropy*Math.cos(o.anisotropyRotation),o.anisotropy*Math.sin(o.anisotropyRotation))}),lS=I(o=>o.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection"),wt=class o extends j{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){let t=this.getNodeType(e),n=this.scope,i;if(n===o.VERTEX)i=e.getVertexIndex();else if(n===o.INSTANCE)i=e.getInstanceIndex();else if(n===o.DRAW)i=e.getDrawIndex();else if(n===o.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(n===o.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else if(n===o.SUBGROUP)i=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=i:s=Ss(this).build(e,t),s}};wt.VERTEX="vertex";wt.INSTANCE="instance";wt.SUBGROUP="subgroup";wt.INVOCATION_LOCAL="invocationLocal";wt.INVOCATION_SUBGROUP="invocationSubgroup";wt.DRAW="draw";var IC=z(wt,wt.VERTEX),no=z(wt,wt.INSTANCE),RL=z(wt,wt.SUBGROUP),CL=z(wt,wt.INVOCATION_SUBGROUP),NL=z(wt,wt.INVOCATION_LOCAL),LC=z(wt,wt.DRAW),vf=class extends j{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=me.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{instanceMatrix:t,instanceColor:n}=this,{count:i}=t,{instanceMatrixNode:s,instanceColorNode:r}=this;if(s===null){if(i<=1e3)s=Wf(t.array,"mat4",Math.max(i,1)).element(no);else{let c=new Yl(t.array,16,1);this.buffer=c;let l=t.usage===er?r0:Eg,u=[l(c,"vec4",16,0),l(c,"vec4",16,4),l(c,"vec4",16,8),l(c,"vec4",16,12)];s=bc(...u)}this.instanceMatrixNode=s}if(n&&r===null){let c=new Bt(n.array,3),l=n.usage===er?r0:Eg;this.bufferColor=c,r=P(l(c,"vec3",3,0)),this.instanceColorNode=r}let a=s.mul(vt).xyz;if(vt.assign(a),e.hasGeometryAttribute("normal")){let c=zR(Dn,s);Dn.assign(c)}this.instanceColorNode!==null&&$n("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==er&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==er&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}},PL=ue(vf).setParameterLength(2,3),zg=class extends vf{static get type(){return"InstancedMeshNode"}constructor(e){let{count:t,instanceMatrix:n,instanceColor:i}=e;super(t,n,i),this.instancedMesh=e}},DC=ue(zg).setParameterLength(1),Hg=class extends j{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=no:this.batchingIdNode=LC);let n=I(([p])=>{let m=R(to(xt(this.batchMesh._indirectTexture),0).x),_=R(p).mod(m),y=R(p).div(m);return xt(this.batchMesh._indirectTexture,kt(_,y)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(R(this.batchingIdNode)),i=this.batchMesh._matricesTexture,s=R(to(xt(i),0).x),r=b(n).mul(4).toInt().toVar(),a=r.mod(s),c=r.div(s),l=bc(xt(i,kt(a,c)),xt(i,kt(a.add(1),c)),xt(i,kt(a.add(2),c)),xt(i,kt(a.add(3),c))),u=this.batchMesh._colorsTexture;if(u!==null){let m=I(([_])=>{let y=R(to(xt(u),0).x),x=_,v=x.mod(y),T=x.div(y);return xt(u,kt(v,T)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);$n("vec3","vBatchColor").assign(m)}let h=dn(l);vt.assign(l.mul(vt));let d=Dn.div(P(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),f=h.mul(d).xyz;Dn.assign(f),e.hasGeometryAttribute("tangent")&&qf.mulAssign(h)}},FC=ue(Hg).setParameterLength(1),Wg=class extends _s{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}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,i=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&i!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),i!==!0){let s=this.getNodeType(e);n=e.format(n,s,t)}return n}},IL=ue(Wg).setParameterLength(2),Xg=class extends Au{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let i,s=null;t&&t.isStruct?(i="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(i=pb(e.itemSize),n=e.count):i=t,super(e,i,n),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=qt.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,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 this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return IL(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(qt.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Hf(this.value),this._varying=Ss(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),i=n.build(e);return e.registerTransform(i,t),i}},wc=(o,e=null,t=0)=>U(new Xg(o,e,t)),LL=(o,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),wc(o,e,t).setPBO(!0)),YA=new WeakMap,Tf=class extends j{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=me.OBJECT,this.skinIndexNode=Sn("skinIndex","uvec4"),this.skinWeightNode=Sn("skinWeight","vec4"),this.bindMatrixNode=Xe("bindMatrix","mat4"),this.bindMatrixInverseNode=Xe("bindMatrixInverse","mat4"),this.boneMatricesNode=h0("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=vt,this.toPositionNode=vt,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:r}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w),h=s.mul(t),d=Et(a.mul(i.x).mul(h),c.mul(i.y).mul(h),l.mul(i.z).mul(h),u.mul(i.w).mul(h));return r.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Dn){let{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:r}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w),h=Et(i.x.mul(a),i.y.mul(c),i.z.mul(l),i.w.mul(u));return h=r.mul(h).mul(s),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=h0("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Fg)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has("velocity")||gb(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Fg.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){let n=this.getSkinnedNormal();Dn.assign(n),e.hasGeometryAttribute("tangent")&&qf.assign(n)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;YA.get(t)!==e.frameId&&(YA.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}},UC=o=>U(new Tf(o)),DL=(o,e=null)=>{let t=new Tf(o);return t.positionNode=wc(new Bt(o.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(no).toVar(),t.skinIndexNode=wc(new Bt(new Uint32Array(o.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(no).toVar(),t.skinWeightNode=wc(new Bt(o.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(no).toVar(),t.bindMatrixNode=se(o.bindMatrix,"mat4"),t.bindMatrixInverseNode=se(o.bindMatrixInverse,"mat4"),t.boneMatricesNode=Wf(o.skeleton.boneMatrices,"mat4",o.skeleton.bones.length),t.toPositionNode=e,U(t)},qg=class extends j{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 r=0,a=this.params.length-1;rNumber(d)?m=">=":m="<"));let y;if(u)y=`while ( ${d} )`;else{let x={start:h,end:d},v=x.start,T=x.end,M,w=()=>m.includes("<")?"+=":"-=";if(_!=null)switch(typeof _){case"function":M=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":M=f+" "+w()+" "+e.generateConst(p,_);break;case"string":M=f+" "+_;break;default:_.isNode?M=f+" "+w()+" "+_.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),M="break /* invalid update */")}else p==="int"||p==="uint"?_=m.includes("<")?"++":"--":_=w()+" 1.",M=f+" "+_;let E=e.getVar(p,f)+" = "+v,A=f+" "+m+" "+T;y=`for ( ${E}; ${A}; ${M} )`}e.addFlowCode((a===0?` `:"")+e.tab+y+` { `).addFlowTab()}let s=i.build(e,"void"),r=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` `+e.tab+s);for(let a=0,c=this.params.length-1;aU(new qg(Tc(o,"int"))).toStack(),FL=()=>dr("continue").toStack(),BC=()=>dr("break").toStack(),Sv=new WeakMap,qn=new ge,KA=I(({bufferMap:o,influence:e,stride:t,width:n,depth:i,offset:s})=>{let r=R(IC).mul(t).add(s),a=r.div(n),c=r.sub(a.mul(n));return xt(o,kt(c,a)).depth(i).xyz.mul(e)});function UL(o){let e=o.morphAttributes.position!==void 0,t=o.morphAttributes.normal!==void 0,n=o.morphAttributes.color!==void 0,i=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,s=i!==void 0?i.length:0,r=Sv.get(o);if(r===void 0||r.count!==s){let y=function(){m.dispose(),Sv.delete(o),o.removeEventListener("dispose",y)};r!==void 0&&r.texture.dispose();let a=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],l=o.morphAttributes.color||[],u=0;e===!0&&(u=1),t===!0&&(u=2),n===!0&&(u=3);let h=o.attributes.position.count*u,d=1,f=4096;h>f&&(d=Math.ceil(h/f),h=f);let p=new Float32Array(h*d*4*s),m=new Do(p,h,d,s);m.type=nt,m.needsUpdate=!0;let _=u*4;for(let x=0;x{let d=b(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(xt(this.mesh.morphTexture,kt(R(h).add(1),R(no))).r):d.assign(Xe("morphTargetInfluences","float").element(h).toVar()),ne(d.notEqual(0),()=>{n===!0&&vt.addAssign(KA({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:R(0)})),i===!0&&Dn.addAssign(KA({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:R(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}},OC=ue($g).setParameterLength(1),pr=class extends j{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},Yg=class extends pr{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Kg=class extends _f{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,i=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=P().toVar("directDiffuse"),i=P().toVar("directSpecular"),s=P().toVar("indirectDiffuse"),r=P().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:i,indirectDiffuse:s,indirectSpecular:r};return{radiance:P().toVar("radiance"),irradiance:P().toVar("irradiance"),iblIrradiance:P().toVar("iblIrradiance"),ambientOcclusion:b(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}},VC=ue(Kg),jg=class extends pr{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},iu=new B,Nc=class extends Jn{static get type(){return"ViewportTextureNode"}constructor(e=ur,t=null,n=null){let i=null;n===null?(i=new zo,i.minFilter=Zt,n=i):i=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=me.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let i=t.clone();n.set(e,i)}return n.get(e)}updateReference(e){let t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(iu):iu.set(n.width,n.height);let i=this.getTextureForReference(n);(i.image.width!==iu.width||i.image.height!==iu.height)&&(i.image.width=iu.width,i.image.height=iu.height,i.needsUpdate=!0);let s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},BL=ue(Nc).setParameterLength(0,3),uS=ue(Nc,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Fm=null,Zg=class extends Nc{static get type(){return"ViewportDepthTextureNode"}constructor(e=ur,t=null){Fm===null&&(Fm=new cn),super(e,t,Fm)}getTextureForReference(){return Fm}},hS=ue(Zg).setParameterLength(0,2),Mi=class o extends j{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){let{scope:t}=this;return t===o.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,n=this.valueNode,i=null;if(t===o.DEPTH_BASE)n!==null&&(i=GC().assign(n));else if(t===o.DEPTH)e.isPerspectiveCamera?i=dS(Tt.z,or,ar):i=Tu(Tt.z,or,ar);else if(t===o.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){let s=fS(n,or,ar);i=Tu(s,or,ar)}else i=n;else i=Tu(Tt.z,or,ar);return i}};Mi.DEPTH_BASE="depthBase";Mi.DEPTH="depth";Mi.LINEAR_DEPTH="linearDepth";var Tu=(o,e,t)=>o.add(e).div(e.sub(t)),OL=(o,e,t)=>e.sub(t).mul(o).sub(e),dS=(o,e,t)=>e.add(o).mul(t).div(t.sub(e).mul(o)),fS=(o,e,t)=>e.mul(t).div(t.sub(e).mul(o).sub(t)),pS=(o,e,t)=>{e=e.max(1e-6).toVar();let n=fs(o.negate().div(e)),i=fs(t.div(e));return n.div(i)},VL=(o,e,t)=>{let n=o.mul(Ry(t.div(e)));return b(Math.E).pow(n).mul(e).negate()},GC=ue(Mi,Mi.DEPTH_BASE),mS=z(Mi,Mi.DEPTH),Ru=ue(Mi,Mi.LINEAR_DEPTH).setParameterLength(0,1),GL=Ru(hS());mS.assign=o=>GC(o);var ys=class o extends j{static get type(){return"ClippingNode"}constructor(e=o.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let t=e.clippingContext,{intersectionPlanes:n,unionPlanes:i}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===o.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,i):this.scope===o.HARDWARE?this.setupHardwareClipping(i,e):this.setupDefault(n,i)}setupAlphaToCoverage(e,t){return I(()=>{let n=b().toVar("distanceToPlane"),i=b().toVar("distanceToGradient"),s=b(1).toVar("clipOpacity"),r=t.length;if(this.hardwareClipping===!1&&r>0){let c=un(t).setGroup(te);Ve(r,({i:l})=>{let u=c.element(l);n.assign(Tt.dot(u.xyz).negate().add(u.w)),i.assign(n.fwidth().div(2)),s.mulAssign(Si(i.negate(),i,n))})}let a=e.length;if(a>0){let c=un(e).setGroup(te),l=b(1).toVar("intersectionClipOpacity");Ve(a,({i:u})=>{let h=c.element(u);n.assign(Tt.dot(h.xyz).negate().add(h.w)),i.assign(n.fwidth().div(2)),l.mulAssign(Si(i.negate(),i,n).oneMinus())}),s.mulAssign(l.oneMinus())}Fe.a.mulAssign(s),Fe.a.equal(0).discard()})()}setupDefault(e,t){return I(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let s=un(t).setGroup(te);Ve(n,({i:r})=>{let a=s.element(r);Tt.dot(a.xyz).greaterThan(a.w).discard()})}let i=e.length;if(i>0){let s=un(e).setGroup(te),r=Ti(!0).toVar("clipped");Ve(i,({i:a})=>{let c=s.element(a);r.assign(Tt.dot(c.xyz).greaterThan(c.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),I(()=>{let i=un(e).setGroup(te),s=gr(t.getClipDistance());Ve(n,({i:r})=>{let a=i.element(r),c=Tt.dot(a.xyz).sub(a.w).negate();s.element(r).assign(c)})})()}};ys.ALPHA_TO_COVERAGE="alphaToCoverage";ys.DEFAULT="default";ys.HARDWARE="hardware";var kL=()=>U(new ys),zL=()=>U(new ys(ys.ALPHA_TO_COVERAGE)),HL=()=>U(new ys(ys.HARDWARE)),WL=.05,jA=I(([o])=>mr(de(1e4,Kn(de(17,o.x).add(de(.1,o.y)))).mul(Et(.1,Ye(Kn(de(13,o.y).add(o.x))))))),ZA=I(([o])=>jA(O(jA(o.xy),o.z))),XL=I(([o])=>{let e=mt(ms(Ub(o.xyz)),ms(Bb(o.xyz))),t=b(1).div(b(WL).mul(e)).toVar("pixScale"),n=O(Su(ps(fs(t))),Su(Cy(fs(t)))),i=O(ZA(ps(n.x.mul(o.xyz))),ZA(ps(n.y.mul(o.xyz)))),s=mr(fs(t)),r=Et(de(s.oneMinus(),i.x),de(s,i.y)),a=Ln(s,s.oneMinus()),c=P(r.mul(r).div(de(2,a).mul(Se(1,a))),r.sub(de(.5,a)).div(Se(1,a)),Se(1,Se(1,r).mul(Se(1,r)).div(de(2,a).mul(Se(1,a))))),l=r.lessThan(a.oneMinus()).select(r.lessThan(a).select(c.x,c.y),c.z);return bi(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]}),Jg=class extends xf{static get type(){return"VertexColorNode"}constructor(e){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),i;return n===!0?i=super.generate(e):i=e.generateConst(this.nodeType,new ge(1,1,1,1)),i}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},kC=(o=0)=>U(new Jg(o)),zC=I(([o,e])=>Ln(1,o.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),HC=I(([o,e])=>Ln(o.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),WC=I(([o,e])=>o.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),XC=I(([o,e])=>Ne(o.mul(2).mul(e),o.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Py(.5,o))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qL=I(([o,e])=>{let t=e.a.add(o.a.mul(e.a.oneMinus()));return Y(e.rgb.mul(e.a).add(o.rgb.mul(o.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),qC=I(([o])=>Y(o.rgb.mul(o.a),o.a),{color:"vec4",return:"vec4"}),$L=I(([o])=>(ne(o.a.equal(0),()=>Y(0)),Y(o.rgb.div(o.a),o.a)),{color:"vec4",return:"vec4"}),YL=(...o)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),zC(o)),KL=(...o)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),HC(o)),jL=(...o)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),WC(o)),ZL=(...o)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),XC(o)),qe=class extends je{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!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.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+fb(this)}build(e){this.setup(e)}setupObserver(e){return new ag(e)}setup(e){e.context.setupNormal=()=>xu(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let i=xu(this.setupVertex(e),"VERTEX"),s=this.vertexNode||i;e.stack.outputNode=s,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let r,a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let c=this.setupLighting(e);a!==null&&e.stack.add(a);let l=Y(c,Fe.a).max(0);r=this.setupOutput(e,l),yu.assign(r);let u=this.outputNode!==null;if(u&&(r=this.outputNode),n!==null){let h=t.getMRT(),d=this.mrtNode;h!==null?(u&&yu.assign(r),r=h,d!==null&&(r=h.merge(d))):d!==null&&(r=d)}}else{let c=this.fragmentNode;c.isOutputStructNode!==!0&&(c=Y(c)),r=this.setupOutput(e,c)}e.stack.outputNode=r,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,i=null;if(t.length>0||n.length>0){let s=e.renderer.samples;this.alphaToCoverage&&s>1?i=zL():e.stack.add(kL())}return i}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(HL()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,i=this.depthNode;if(i===null){let s=t.getMRT();s&&s.has("depth")?i=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?i=pS(Tt.z,or,ar):i=Tu(Tt.z,or,ar))}i!==null&&mS.assign(i).toStack()}setupPositionView(){return fr.mul(vt).xyz}setupModelViewProjection(){return _i.mul(Tt)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),lS}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&OC(t).toStack(),t.isSkinnedMesh===!0&&UC(t).toStack(),this.displacementMap){let i=cr("displacementMap","texture"),s=cr("displacementScale","float"),r=cr("displacementBias","float");vt.addAssign(Dn.normalize().mul(i.x.mul(s).add(r)))}return t.isBatchedMesh&&FC(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&DC(t).toStack(),this.positionNode!==null&&vt.assign(xu(this.positionNode,"POSITION","vec3")),vt}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Ti(this.maskNode).not().discard();let n=this.colorNode?Y(this.colorNode):kg;this.vertexColors===!0&&t.hasAttribute("color")&&(n=n.mul(kC())),e.instanceColor&&(n=$n("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=$n("vec3","vBatchColor").mul(n)),Fe.assign(n);let i=this.opacityNode?b(this.opacityNode):Oy;Fe.a.assign(Fe.a.mul(i));let s=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(s=this.alphaTestNode!==null?b(this.alphaTestNode):oC,Fe.a.lessThanEqual(s).discard()),this.alphaHash===!0&&Fe.a.lessThan(XL(vt)).discard(),this.transparent===!1&&this.blending===ri&&this.alphaToCoverage===!1?Fe.a.assign(1):s===null&&Fe.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?P(0):Fe.rgb}setupNormal(){return this.normalNode?P(this.normalNode):fC}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?cr("envMap","cubeTexture"):cr("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new jg(cS)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),this.aoNode!==null||e.material.aoMap){let r=this.aoNode!==null?this.aoNode:PC;t.push(new Yg(r))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:i,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,c=this.setupOutgoingLight(e);if(a&&a.getScope().hasLights){let l=this.setupLightingModel(e)||null;c=VC(a,l,n,i)}else n!==null&&(c=P(i!==null?Ne(c,n,i):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(i0.assign(P(s||cC)),c=c.add(i0)),c}setupFog(e,t){let n=e.fogNode;return n&&(yu.assign(t),t=Y(n.toVar())),t}setupPremultipliedAlpha(e,t){return qC(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let n in e){let i=e[n];this[n]===void 0&&(this[n]=i,i&&i.clone&&(this[n]=i.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});let n=je.prototype.toJSON.call(this,e),i=nf(this);n.inputNodes={};for(let{property:r,childNode:a}of i)n.inputNodes[r]=a.toJSON(e).uuid;function s(r){let a=[];for(let c in r){let l=r[c];delete l.metadata,a.push(l)}return a}if(t){let r=s(e.textures),a=s(e.images),c=s(e.nodes);r.length>0&&(n.textures=r),a.length>0&&(n.images=a),c.length>0&&(n.nodes=c)}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.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}},JL=new yt,Qg=class extends qe{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(JL),this.setValues(e)}},QL=new Vr,e_=class extends qe{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(QL),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?b(this.offsetNode):aS,t=this.dashScaleNode?b(this.dashScaleNode):sS,n=this.dashSizeNode?b(this.dashSizeNode):rS,i=this.gapSizeNode?b(this.gapSizeNode):oS;Mc.assign(n),ff.assign(i);let s=Ss(Sn("lineDistance").mul(t));(e?s.add(e):s).mod(Mc.add(ff)).greaterThan(Mc).discard()}},Um=null,t_=class extends Nc{static get type(){return"ViewportSharedTextureNode"}constructor(e=ur,t=null){Um===null&&(Um=new zo),super(e,t,Um)}getTextureForReference(){return Um}updateReference(){return this}},$C=ue(t_).setParameterLength(0,2),eD=new Vr,g0=class extends qe{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(eD),this.useColor=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=ss,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){let{renderer:t}=e,n=this._useAlphaToCoverage,i=this.useColor,s=this._useDash,r=this._useWorldUnits,a=I(({start:l,end:u})=>{let h=_i.element(2).element(2),p=_i.element(3).element(2).mul(-.5).div(h).sub(l.z).div(u.z.sub(l.z));return Y(Ne(l.xyz,u.xyz,p),u.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=I(()=>{let l=Sn("instanceStart"),u=Sn("instanceEnd"),h=Y(fr.mul(Y(l,1))).toVar("start"),d=Y(fr.mul(Y(u,1))).toVar("end");if(s){let M=this.dashScaleNode?b(this.dashScaleNode):sS,w=this.offsetNode?b(this.offsetNode):aS,E=Sn("instanceDistanceStart"),A=Sn("instanceDistanceEnd"),N=Qt.y.lessThan(.5).select(M.mul(E),M.mul(A));N=N.add(w),$n("float","lineDistance").assign(N)}r&&($n("vec3","worldStart").assign(h.xyz),$n("vec3","worldEnd").assign(d.xyz));let f=vu.z.div(vu.w),p=_i.element(2).element(3).equal(-1);ne(p,()=>{ne(h.z.lessThan(0).and(d.z.greaterThan(0)),()=>{d.assign(a({start:h,end:d}))}).ElseIf(d.z.lessThan(0).and(h.z.greaterThanEqual(0)),()=>{h.assign(a({start:d,end:h}))})});let m=_i.mul(h),_=_i.mul(d),y=m.xyz.div(m.w),x=_.xyz.div(_.w),v=x.xy.sub(y.xy).toVar();v.x.assign(v.x.mul(f)),v.assign(v.normalize());let T=Y().toVar();if(r){let M=d.xyz.sub(h.xyz).normalize(),w=Ne(h.xyz,d.xyz,.5).normalize(),E=M.cross(w).normalize(),A=M.cross(E),N=$n("vec4","worldPos");N.assign(Qt.y.lessThan(.5).select(h,d));let L=ig.mul(.5);N.addAssign(Y(Qt.x.lessThan(0).select(E.mul(L),E.mul(L).negate()),0)),s||(N.addAssign(Y(Qt.y.lessThan(.5).select(M.mul(L).negate(),M.mul(L)),0)),N.addAssign(Y(A.mul(L),0)),ne(Qt.y.greaterThan(1).or(Qt.y.lessThan(0)),()=>{N.subAssign(Y(A.mul(2).mul(L),0))})),T.assign(_i.mul(N));let V=P().toVar();V.assign(Qt.y.lessThan(.5).select(y,x)),T.z.assign(V.z.mul(T.w))}else{let M=O(v.y,v.x.negate()).toVar("offset");v.x.assign(v.x.div(f)),M.x.assign(M.x.div(f)),M.assign(Qt.x.lessThan(0).select(M.negate(),M)),ne(Qt.y.lessThan(0),()=>{M.assign(M.sub(v))}).ElseIf(Qt.y.greaterThan(1),()=>{M.assign(M.add(v))}),M.assign(M.mul(ig)),M.assign(M.div(vu.w)),T.assign(Qt.y.lessThan(.5).select(m,_)),M.assign(M.mul(T.w)),T.assign(T.add(Y(M,0,0)))}return T})();let c=I(({p1:l,p2:u,p3:h,p4:d})=>{let f=l.sub(h),p=d.sub(h),m=u.sub(l),_=f.dot(p),y=p.dot(m),x=f.dot(m),v=p.dot(p),M=m.dot(m).mul(v).sub(y.mul(y)),E=_.mul(y).sub(x.mul(v)).div(M).clamp(),A=_.add(y.mul(E)).div(v).clamp();return O(E,A)});if(this.colorNode=I(()=>{let l=ze();if(s){let d=this.dashSizeNode?b(this.dashSizeNode):rS,f=this.gapSizeNode?b(this.gapSizeNode):oS;Mc.assign(d),ff.assign(f);let p=$n("float","lineDistance");l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),p.mod(Mc.add(ff)).greaterThan(Mc).discard()}let u=b(1).toVar("alpha");if(r){let d=$n("vec3","worldStart"),f=$n("vec3","worldEnd"),p=$n("vec4","worldPos").xyz.normalize().mul(1e5),m=f.sub(d),_=c({p1:d,p2:f,p3:P(0,0,0),p4:p}),y=d.add(m.mul(_.x)),x=p.mul(_.y),M=y.sub(x).length().div(ig);if(!s)if(n&&t.samples>1){let w=M.fwidth();u.assign(Si(w.negate().add(.5),w.add(.5),M).oneMinus())}else M.greaterThan(.5).discard()}else if(n&&t.samples>1){let d=l.x,f=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1)),p=d.mul(d).add(f.mul(f)),m=b(p.fwidth()).toVar("dlen");ne(l.y.abs().greaterThan(1),()=>{u.assign(Si(m.oneMinus(),m.add(1),p).oneMinus())})}else ne(l.y.abs().greaterThan(1),()=>{let d=l.x,f=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1));d.mul(d).add(f.mul(f)).greaterThan(1).discard()});let h;if(this.lineColorNode)h=this.lineColorNode;else if(i){let d=Sn("instanceColorStart"),f=Sn("instanceColorEnd");h=Qt.y.lessThan(.5).select(d,f).mul(kg)}else h=kg;return Y(h,u)})(),this.transparent){let l=this.opacityNode?b(this.opacityNode):Oy;this.outputNode=Y(this.colorNode.rgb.mul(l).add($C().rgb.mul(l.oneMinus())),this.colorNode.a)}super.setup(e)}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)}},YC=o=>U(o).mul(.5).add(.5),tD=o=>U(o).mul(2).sub(1),nD=new ta,n_=class extends qe{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nD),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?b(this.opacityNode):Oy;Fe.assign(Ly(Y(YC(Oe),e),ut))}},gS=I(([o=Jb])=>{let e=o.z.atan(o.x).mul(1/(Math.PI*2)).add(.5),t=o.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return O(e,t)}),i_=class extends rl{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,i=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 s=new Hs(5,5,5),r=gS(Jb),a=new qe;a.colorNode=Te(t,r,0),a.side=Nt,a.blending=ss;let c=new Ze(s,a),l=new Xs;l.add(c),t.minFilter===Zt&&(t.minFilter=Ae);let u=new Go(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,l),e.setMRT(h),t.minFilter=n,t.currentGenerateMipmaps=i,c.geometry.dispose(),c.material.dispose(),this}},Zd=new WeakMap,_0=class extends st{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=wu(null);let t=new Pi;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=me.RENDER}updateBefore(e){let{renderer:t,material:n}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){let s=i.isTextureNode?i.value:n[i.property];if(s&&s.isTexture){let r=s.mapping;if(r===Ia||r===La){if(Zd.has(s)){let a=Zd.get(s);JA(a,s.mapping),this._cubeTexture=a}else{let a=s.image;if(iD(a)){let c=new i_(a.height);c.fromEquirectangularTexture(t,s),JA(c.texture,s.mapping),this._cubeTexture=c.texture,Zd.set(s,c.texture),s.addEventListener("dispose",KC)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function iD(o){return o==null?!1:o.height>0}function KC(o){let e=o.target;e.removeEventListener("dispose",KC);let t=Zd.get(e);t!==void 0&&(Zd.delete(e),t.dispose())}function JA(o,e){e===Ia?o.mapping=rs:e===La&&(o.mapping=zr)}var jC=ue(_0).setParameterLength(1),Cu=class extends pr{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=jC(this.envNode)}},y0=class extends pr{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=b(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},ro=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},s_=class extends ro{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,i=e.irradianceLightMap;n.indirectDiffuse.assign(Y(0)),i?n.indirectDiffuse.addAssign(i):n.indirectDiffuse.addAssign(Y(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(Fe.rgb)}finish(e){let{material:t,context:n}=e,i=n.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case Na:i.rgb.assign(Ne(i.rgb,i.rgb.mul(s.rgb),jd.mul(ng)));break;case Zp:i.rgb.assign(Ne(i.rgb,s.rgb,jd.mul(ng)));break;case Jp:i.rgb.addAssign(s.rgb.mul(jd.mul(ng)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}},sD=new at,r_=class extends qe{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(sD),this.setValues(e)}setupNormal(){return Ou(Eu)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cu(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new y0(cS)),t}setupOutgoingLight(){return Fe.rgb}setupLightingModel(){return new s_}},Nu=I(({f0:o,f90:e,dotVH:t})=>{let n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return o.mul(n.oneMinus()).add(e.mul(n))}),Pc=I(o=>o.diffuseColor.mul(1/Math.PI)),rD=()=>b(.25),oD=I(({dotNH:o})=>mg.mul(b(.5)).add(1).mul(b(1/Math.PI)).mul(o.pow(mg))),aD=I(({lightDirection:o})=>{let e=o.add(Qe).normalize(),t=Oe.dot(e).clamp(),n=Qe.dot(e).clamp(),i=Nu({f0:In,f90:1,dotVH:n}),s=rD(),r=oD({dotNH:t});return i.mul(s).mul(r)}),bf=class extends s_{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let s=Oe.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(Pc({diffuseColor:Fe.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(aD({lightDirection:e})).mul(jd))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(n.mul(Pc({diffuseColor:Fe}))),i.indirectDiffuse.mulAssign(t)}},cD=new na,o_=class extends qe{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(cD),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cu(t):null}setupLightingModel(){return new bf(!1)}},lD=new Qo,a_=class extends qe{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(lD),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Cu(t):null}setupLightingModel(){return new bf}setupVariants(){let e=(this.shininessNode?b(this.shininessNode):aC).max(1e-4);mg.assign(e);let t=this.specularNode||lC;In.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}},ZC=I(o=>{if(o.geometry.hasAttribute("normal")===!1)return b(0);let e=Eu.dFdx().abs().max(Eu.dFdy().abs());return e.x.max(e.y).max(e.z)}),_S=I(o=>{let{roughness:e}=o,t=ZC(),n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),JC=I(({alpha:o,dotNL:e,dotNV:t})=>{let n=o.pow2(),i=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Zn(.5,i.add(s).max(Gw))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),uD=I(({alphaT:o,alphaB:e,dotTV:t,dotBV:n,dotTL:i,dotBL:s,dotNV:r,dotNL:a})=>{let c=a.mul(P(o.mul(t),e.mul(n),r).length()),l=r.mul(P(o.mul(i),e.mul(s),a).length());return Zn(.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"}]}),QC=I(({alpha:o,dotNH:e})=>{let t=o.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),hD=b(1/Math.PI),dD=I(({alphaT:o,alphaB:e,dotNH:t,dotTH:n,dotBH:i})=>{let s=o.mul(e),r=P(e.mul(n),o.mul(i),s.mul(t)),a=r.dot(r),c=s.div(a);return hD.mul(s.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"}]}),x0=I(({lightDirection:o,f0:e,f90:t,roughness:n,f:i,normalView:s=Oe,USE_IRIDESCENCE:r,USE_ANISOTROPY:a})=>{let c=n.pow2(),l=o.add(Qe).normalize(),u=s.dot(o).clamp(),h=s.dot(Qe).clamp(),d=s.dot(l).clamp(),f=Qe.dot(l).clamp(),p=Nu({f0:e,f90:t,dotVH:f}),m,_;if(cf(r)&&(p=Ey.mix(p,i)),cf(a)){let y=qd.dot(o),x=qd.dot(Qe),v=qd.dot(l),T=Sc.dot(o),M=Sc.dot(Qe),w=Sc.dot(l);m=uD({alphaT:pg,alphaB:c,dotTV:x,dotBV:M,dotTL:y,dotBL:T,dotNV:h,dotNL:u}),_=dD({alphaT:pg,alphaB:c,dotNH:d,dotTH:v,dotBH:w})}else m=JC({alpha:c,dotNL:u,dotNV:h}),_=QC({alpha:c,dotNH:d});return p.mul(m).mul(_)}),yS=I(({roughness:o,dotNV:e})=>{let t=Y(-1,-.0275,-.572,.022),n=Y(1,.0425,1.04,-.04),i=o.mul(t).add(n),s=i.x.mul(i.x).min(e.mul(-9.28).exp2()).mul(i.x).add(i.y);return O(-1.04,1.04).mul(s).add(i.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),eN=I(o=>{let{dotNV:e,specularColor:t,specularF90:n,roughness:i}=o,s=yS({dotNV:e,roughness:i});return t.mul(s.x).add(n.mul(s.y))}),tN=I(({f:o,f90:e,dotVH:t})=>{let n=t.oneMinus().saturate(),i=n.mul(n),s=n.mul(i,i).clamp(0,.9999);return o.sub(P(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),fD=I(({roughness:o,dotNH:e})=>{let t=o.pow2(),n=b(1).div(t),s=e.pow2().oneMinus().max(.0078125);return b(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),pD=I(({dotNV:o,dotNL:e})=>b(1).div(b(4).mul(e.add(o).sub(e.mul(o))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),mD=I(({lightDirection:o})=>{let e=o.add(Qe).normalize(),t=Oe.dot(o).clamp(),n=Oe.dot(Qe).clamp(),i=Oe.dot(e).clamp(),s=fD({roughness:Ay,dotNH:i}),r=pD({dotNV:n,dotNL:t});return _c.mul(s).mul(r)}),gD=I(({N:o,V:e,roughness:t})=>{let s=.0078125,r=o.dot(e).saturate(),a=O(t,r.oneMinus().sqrt());return a.assign(a.mul(.984375).add(s)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),nN=I(({f:o})=>{let e=o.length();return mt(e.mul(e).add(o.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),eo=I(({v1:o,v2:e})=>{let t=o.dot(e),n=t.abs().toVar(),i=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),r=i.div(s),a=t.greaterThan(0).select(r,mt(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(r));return o.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),QA=I(({N:o,V:e,P:t,mInv:n,p0:i,p1:s,p2:r,p3:a})=>{let c=s.sub(i).toVar(),l=a.sub(i).toVar(),u=c.cross(l),h=P().toVar();return ne(u.dot(t.sub(i)).greaterThanEqual(0),()=>{let d=e.sub(o.mul(e.dot(o))).normalize(),f=o.cross(d).negate(),p=n.mul(dn(d,f,o).transpose()).toVar(),m=p.mul(i.sub(t)).normalize().toVar(),_=p.mul(s.sub(t)).normalize().toVar(),y=p.mul(r.sub(t)).normalize().toVar(),x=p.mul(a.sub(t)).normalize().toVar(),v=P(0).toVar();v.addAssign(eo({v1:m,v2:_})),v.addAssign(eo({v1:_,v2:y})),v.addAssign(eo({v1:y,v2:x})),v.addAssign(eo({v1:x,v2:m})),h.assign(P(nN({f:v})))}),h}).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"}]}),_D=I(({P:o,p0:e,p1:t,p2:n,p3:i})=>{let s=t.sub(e).toVar(),r=i.sub(e).toVar(),a=s.cross(r),c=P().toVar();return ne(a.dot(o.sub(e)).greaterThanEqual(0),()=>{let l=e.sub(o).normalize().toVar(),u=t.sub(o).normalize().toVar(),h=n.sub(o).normalize().toVar(),d=i.sub(o).normalize().toVar(),f=P(0).toVar();f.addAssign(eo({v1:l,v2:u})),f.addAssign(eo({v1:u,v2:h})),f.addAssign(eo({v1:h,v2:d})),f.addAssign(eo({v1:d,v2:l})),c.assign(P(nN({f:f.abs()})))}),c}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Vy=1/6,iN=o=>de(Vy,de(o,de(o,o.negate().add(3)).sub(3)).add(1)),v0=o=>de(Vy,de(o,de(o,de(3,o).sub(6))).add(4)),sN=o=>de(Vy,de(o,de(o,de(-3,o).add(3)).add(3)).add(1)),T0=o=>de(Vy,yi(o,3)),eE=o=>iN(o).add(v0(o)),tE=o=>sN(o).add(T0(o)),nE=o=>Et(-1,v0(o).div(iN(o).add(v0(o)))),iE=o=>Et(1,T0(o).div(sN(o).add(T0(o)))),sE=(o,e,t)=>{let n=o.uvNode,i=de(n,e.zw).add(.5),s=ps(i),r=mr(i),a=eE(r.x),c=tE(r.x),l=nE(r.x),u=iE(r.x),h=nE(r.y),d=iE(r.y),f=O(s.x.add(l),s.y.add(h)).sub(.5).mul(e.xy),p=O(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),m=O(s.x.add(l),s.y.add(d)).sub(.5).mul(e.xy),_=O(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),y=eE(r.y).mul(Et(a.mul(o.sample(f).level(t)),c.mul(o.sample(p).level(t)))),x=tE(r.y).mul(Et(a.mul(o.sample(m).level(t)),c.mul(o.sample(_).level(t))));return y.add(x)},xS=I(([o,e])=>{let t=O(o.size(R(e))),n=O(o.size(R(e.add(1)))),i=Zn(1,t),s=Zn(1,n),r=sE(o,Y(i,t),ps(e)),a=sE(o,Y(s,n),Cy(e));return mr(e).mix(r,a)}),yD=I(([o,e])=>{let t=e.mul(Kb(o));return xS(o,t)}),rE=I(([o,e,t,n,i])=>{let s=P(zb(e.negate(),hr(o),Zn(1,n))),r=P(ms(i[0].xyz),ms(i[1].xyz),ms(i[2].xyz));return hr(s).mul(t.mul(r))}).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"}]}),xD=I(([o,e])=>o.mul(bi(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),vD=uS(),TD=uS(),oE=I(([o,e,t],{material:n})=>{let s=(n.side===Nt?vD:TD).sample(o),r=fs(Rc.x).mul(xD(e,t));return xS(s,r)}),aE=I(([o,e,t])=>(ne(t.notEqual(0),()=>{let n=Ry(e).negate().div(t);return Lb(n.negate().mul(o))}),P(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),bD=I(([o,e,t,n,i,s,r,a,c,l,u,h,d,f,p])=>{let m,_;if(p){m=Y().toVar(),_=P().toVar();let M=u.sub(1).mul(p.mul(.025)),w=P(u.sub(M),u,u.add(M));Ve({start:0,end:3},({i:E})=>{let A=w.element(E),N=rE(o,e,h,A,a),L=r.add(N),V=l.mul(c.mul(Y(L,1))),H=O(V.xy.div(V.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(O(H.x,H.y.oneMinus()));let W=oE(H,t,A);m.element(E).assign(W.element(E)),m.a.addAssign(W.a),_.element(E).assign(n.element(E).mul(aE(ms(N),d,f).element(E)))}),m.a.divAssign(3)}else{let M=rE(o,e,h,u,a),w=r.add(M),E=l.mul(c.mul(Y(w,1))),A=O(E.xy.div(E.w)).toVar();A.addAssign(1),A.divAssign(2),A.assign(O(A.x,A.y.oneMinus())),m=oE(A,t,u),_=n.mul(aE(ms(M),d,f))}let y=_.rgb.mul(m.rgb),x=o.dot(e).clamp(),v=P(eN({dotNV:x,specularColor:i,specularF90:s,roughness:t})),T=_.r.add(_.g,_.b).div(3);return Y(v.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())}),SD=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),MD=o=>{let e=o.sqrt();return P(1).add(e).div(P(1).sub(e))},cE=(o,e)=>o.sub(e).div(o.add(e)).pow2(),AD=(o,e)=>{let t=o.mul(2*Math.PI*1e-9),n=P(54856e-17,44201e-17,52481e-17),i=P(1681e3,1795300,2208400),s=P(43278e5,93046e5,66121e5),r=b(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp()),a=n.mul(s.mul(2*Math.PI).sqrt()).mul(i.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return a=P(a.x.add(r),a.y,a.z).div(10685e-11),SD.mul(a)},ED=I(({outsideIOR:o,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:i})=>{let s=Ne(o,e,Si(0,.03,n)),a=o.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();ne(a.lessThan(0),()=>P(1));let c=a.sqrt(),l=cE(s,o),u=Nu({f0:l,f90:1,dotVH:t}),h=u.oneMinus(),d=s.lessThan(o).select(Math.PI,0),f=b(Math.PI).sub(d),p=MD(i.clamp(0,.9999)),m=cE(p,s.toVec3()),_=Nu({f0:m,f90:1,dotVH:c}),y=P(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),x=s.mul(n,c,2),v=P(f).add(y),T=u.mul(_).clamp(1e-5,.9999),M=T.sqrt(),w=h.pow2().mul(_).div(P(1).sub(T)),A=u.add(w).toVar(),N=w.sub(h).toVar();return Ve({start:1,end:2,condition:"<=",name:"m"},({m:L})=>{N.mulAssign(M);let V=AD(b(L).mul(x),b(L).mul(v)).mul(2);A.addAssign(N.mul(V))}),A.max(P(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"}]}),wD=I(({normal:o,viewDir:e,roughness:t})=>{let n=o.dot(e).saturate(),i=t.pow2(),s=$t(t.lessThan(.25),b(-339.2).mul(i).add(b(161.4).mul(t)).sub(25.9),b(-8.48).mul(i).add(b(14.3).mul(t)).sub(9.95)),r=$t(t.lessThan(.25),b(44).mul(i).sub(b(23.7).mul(t)).add(3.26),b(1.97).mul(i).sub(b(3.27).mul(t)).add(.72));return $t(t.lessThan(.25),0,b(.1).mul(t).sub(.025)).add(s.mul(n).add(r).exp()).mul(1/Math.PI).saturate()}),Mv=P(.04),Av=b(1),Pu=class extends ro{constructor(e=!1,t=!1,n=!1,i=!1,s=!1,r=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=i,this.transmission=s,this.dispersion=r,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=P().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=P().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=P().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=P().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=P().toVar("sheenSpecularIndirect")),this.iridescence===!0){let t=Oe.dot(Qe).clamp();this.iridescenceFresnel=ED({outsideIOR:b(1),eta2:Mb,cosTheta1:t,thinFilmThickness:Ab,baseF0:In}),this.iridescenceF0=tN({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){let t=jn,n=Kd.sub(jn).normalize(),i=fo,s=e.context;s.backdrop=bD(i,n,ds,Fe,In,df,t,xi,ei,_i,$d,Eb,Rb,wb,this.dispersion?Cb:null),s.backdropAlpha=gg,Fe.a.mulAssign(Ne(1,s.backdrop.a,gg))}super.start(e)}computeMultiscattering(e,t,n){let i=Oe.dot(Qe).clamp(),s=yS({roughness:ds,dotNV:i}),a=(this.iridescenceF0?Ey.mix(In,this.iridescenceF0):In).mul(s.x).add(n.mul(s.y)),l=s.x.add(s.y).oneMinus(),u=In.add(In.oneMinus().mul(.047619)),h=a.mul(u).div(l.mul(u).oneMinus());e.addAssign(a),t.addAssign(h.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let s=Oe.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(mD({lightDirection:e}))),this.clearcoat===!0){let a=yc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(x0({lightDirection:e,f0:Mv,f90:Av,roughness:hf,normalView:yc})))}n.directDiffuse.addAssign(s.mul(Pc({diffuseColor:Fe.rgb}))),n.directSpecular.addAssign(s.mul(x0({lightDirection:e,f0:In,f90:1,roughness:ds,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:i,reflectedLight:s,ltc_1:r,ltc_2:a}){let c=t.add(n).sub(i),l=t.sub(n).sub(i),u=t.sub(n).add(i),h=t.add(n).add(i),d=Oe,f=Qe,p=Tt.toVar(),m=gD({N:d,V:f,roughness:ds}),_=r.sample(m).toVar(),y=a.sample(m).toVar(),x=dn(P(_.x,0,_.y),P(0,1,0),P(_.z,0,_.w)).toVar(),v=In.mul(y.x).add(In.oneMinus().mul(y.y)).toVar();s.directSpecular.addAssign(e.mul(v).mul(QA({N:d,V:f,P:p,mInv:x,p0:c,p1:l,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Fe).mul(QA({N:d,V:f,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:c,p1:l,p2:u,p3:h})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(t.mul(Pc({diffuseColor:Fe})))}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:i}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(_c,wD({normal:Oe,viewDir:Qe,roughness:Ay}))),this.clearcoat===!0){let u=yc.dot(Qe).clamp(),h=eN({dotNV:u,specularColor:Mv,specularF90:Av,roughness:hf});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(h))}let s=P().toVar("singleScattering"),r=P().toVar("multiScattering"),a=n.mul(1/Math.PI);this.computeMultiscattering(s,r,df);let c=s.add(r),l=Fe.mul(c.r.max(c.g).max(c.b).oneMinus());i.indirectSpecular.addAssign(t.mul(s)),i.indirectSpecular.addAssign(r.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,s=Oe.dot(Qe).clamp().add(t),r=ds.mul(-16).oneMinus().negate().exp2(),a=t.sub(s.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let n=yc.dot(Qe).clamp(),i=Nu({dotVH:n,f0:Mv,f90:Av}),s=t.mul(fg.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(fg));t.assign(s)}if(this.sheen===!0){let n=_c.r.max(_c.g).max(_c.b).mul(.157).oneMinus(),i=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(i)}}},lE=b(1),b0=b(-2),Bm=b(.8),Ev=b(-1),Om=b(.4),wv=b(2),Vm=b(.305),Rv=b(3),uE=b(.21),RD=b(4),hE=b(4),CD=b(16),ND=I(([o])=>{let e=P(Ye(o)).toVar(),t=b(-1).toVar();return ne(e.x.greaterThan(e.z),()=>{ne(e.x.greaterThan(e.y),()=>{t.assign($t(o.x.greaterThan(0),0,3))}).Else(()=>{t.assign($t(o.y.greaterThan(0),1,4))})}).Else(()=>{ne(e.z.greaterThan(e.y),()=>{t.assign($t(o.z.greaterThan(0),2,5))}).Else(()=>{t.assign($t(o.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),PD=I(([o,e])=>{let t=O().toVar();return ne(e.equal(0),()=>{t.assign(O(o.z,o.y).div(Ye(o.x)))}).ElseIf(e.equal(1),()=>{t.assign(O(o.x.negate(),o.z.negate()).div(Ye(o.y)))}).ElseIf(e.equal(2),()=>{t.assign(O(o.x.negate(),o.y).div(Ye(o.z)))}).ElseIf(e.equal(3),()=>{t.assign(O(o.z.negate(),o.y).div(Ye(o.x)))}).ElseIf(e.equal(4),()=>{t.assign(O(o.x.negate(),o.z).div(Ye(o.y)))}).Else(()=>{t.assign(O(o.x,o.y).div(Ye(o.z)))}),de(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),ID=I(([o])=>{let e=b(0).toVar();return ne(o.greaterThanEqual(Bm),()=>{e.assign(lE.sub(o).mul(Ev.sub(b0)).div(lE.sub(Bm)).add(b0))}).ElseIf(o.greaterThanEqual(Om),()=>{e.assign(Bm.sub(o).mul(wv.sub(Ev)).div(Bm.sub(Om)).add(Ev))}).ElseIf(o.greaterThanEqual(Vm),()=>{e.assign(Om.sub(o).mul(Rv.sub(wv)).div(Om.sub(Vm)).add(wv))}).ElseIf(o.greaterThanEqual(uE),()=>{e.assign(Vm.sub(o).mul(RD.sub(Rv)).div(Vm.sub(uE)).add(Rv))}).Else(()=>{e.assign(b(-2).mul(fs(de(1.16,o))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),rN=I(([o,e])=>{let t=o.toVar();t.assign(de(2,t).sub(1));let n=P(t,1).toVar();return ne(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),oN=I(([o,e,t,n,i,s])=>{let r=b(t),a=P(e),c=bi(ID(r),b0,s),l=mr(c),u=ps(c),h=P(S0(o,a,u,n,i,s)).toVar();return ne(l.notEqual(0),()=>{let d=P(S0(o,a,u.add(1),n,i,s)).toVar();h.assign(Ne(h,d,l))}),h}),S0=I(([o,e,t,n,i,s])=>{let r=b(t).toVar(),a=P(e),c=b(ND(a)).toVar(),l=b(mt(hE.sub(r),0)).toVar();r.assign(mt(r,hE));let u=b(Su(r)).toVar(),h=O(PD(a,c).mul(u.sub(2)).add(1)).toVar();return ne(c.greaterThan(2),()=>{h.y.addAssign(u),c.subAssign(3)}),h.x.addAssign(c.mul(u)),h.x.addAssign(l.mul(de(3,CD))),h.y.addAssign(de(4,Su(s).sub(u))),h.x.mulAssign(n),h.y.mulAssign(i),o.sample(h).grad(O(),O())}),Cv=I(({envMap:o,mipInt:e,outputDirection:t,theta:n,axis:i,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:r,CUBEUV_MAX_MIP:a})=>{let c=sr(n),l=t.mul(c).add(i.cross(t).mul(Kn(n))).add(i.mul(i.dot(t).mul(c.oneMinus())));return S0(o,l,e,s,r,a)}),aN=I(({n:o,latitudinal:e,poleAxis:t,outputDirection:n,weights:i,samples:s,dTheta:r,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{let d=P($t(e,t,Iy(t,n))).toVar();ne(d.equal(P(0)),()=>{d.assign(P(n.z,0,n.x.negate()))}),d.assign(hr(d));let f=P().toVar();return f.addAssign(i.element(0).mul(Cv({theta:0,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),Ve({start:R(1),end:o},({i:p})=>{ne(p.greaterThanEqual(s),()=>{BC()});let m=b(r.mul(b(p))).toVar();f.addAssign(i.element(p).mul(Cv({theta:m.mul(-1),axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),f.addAssign(i.element(p).mul(Cv({theta:m,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),Y(f,1)}),gu=4,dE=[.125,.215,.35,.446,.526,.582],mc=20,Nv=new Oi(-1,1,1,-1,0,1),LD=new ht(90,1),fE=new q,Pv=null,Iv=0,Lv=0,pc=(1+Math.sqrt(5))/2,su=1/pc,pE=[new S(-pc,su,0),new S(pc,su,0),new S(-su,0,pc),new S(su,0,pc),new S(0,pc,-su),new S(0,pc,su),new S(-1,1,-1),new S(1,1,-1),new S(-1,1,1),new S(1,1,1)],DD=new S,cN=new WeakMap,FD=[3,1,5,0,4,2],Dv=rN(ze(),Sn("faceIndex")).normalize(),vS=P(Dv.x,Dv.y,Dv.z),c_=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}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,i=100,s={}){let{size:r=256,position:a=DD,renderTarget:c=null}=s;if(this._setSize(r),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");let u=c||this._allocateTarget();return s.renderTarget=u,this.fromSceneAsync(e,t,n,i,s),u}Pv=this._renderer.getRenderTarget(),Iv=this._renderer.getActiveCubeFace(),Lv=this._renderer.getActiveMipmapLevel();let l=c||this._allocateTarget();return l.depthBuffer=!0,this._init(l),this._sceneToCubeUV(e,n,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,n=.1,i=100,s={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,i,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=gE(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_E(),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())}_setSizeFromTexture(e){e.mapping===rs||e.mapping===zr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?_:0,_,_),l.render(e,r)}l.autoClear=u,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===rs||e.mapping===zr;i?this._cubemapMaterial===null&&(this._cubemapMaterial=gE(e)):this._equirectMaterial===null&&(this._equirectMaterial=_E(e));let s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let r=this._lodMeshes[0];r.material=s;let a=this._cubeSize;Gm(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(r,Nv)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodPlanes.length;for(let s=1;smc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${mc}`);let y=[],x=0;for(let E=0;Ev-gu?i-v+gu:0),w=4*(this._cubeSize-T);Gm(t,M,w,3*T,2*T),c.setRenderTarget(t),c.render(h,Nv)}};function UD(o){let e=[],t=[],n=[],i=[],s=o,r=o-gu+1+dE.length;for(let a=0;ao-gu?l=dE[a-o+gu-1]:a===0&&(l=0),n.push(l);let u=1/(c-2),h=-u,d=1+u,f=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,m=6,_=3,y=2,x=1,v=new Float32Array(_*m*p),T=new Float32Array(y*m*p),M=new Float32Array(x*m*p);for(let E=0;E2?0:-1,L=[A,N,0,A+2/3,N,0,A+2/3,N+1,0,A,N,0,A+2/3,N+1,0,A,N+1,0],V=FD[E];v.set(L,_*m*V),T.set(f,y*m*V);let H=[V,V,V,V,V,V];M.set(H,x*m*V)}let w=new _e;w.setAttribute("position",new Ee(v,_)),w.setAttribute("uv",new Ee(T,y)),w.setAttribute("faceIndex",new Ee(M,x)),e.push(w),i.push(new Ze(w,null)),s>gu&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:i}}function mE(o,e){let t={magFilter:Ae,minFilter:Ae,generateMipmaps:!1,type:ft,format:Ft,colorSpace:Ut},n=new yn(o,e,t);return n.texture.mapping=Da,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function Gm(o,e,t,n,i){o.viewport.set(e,t,n,i),o.scissor.set(e,t,n,i)}function TS(o){let e=new qe;return e.depthTest=!1,e.depthWrite=!1,e.blending=ss,e.name=`PMREM_${o}`,e}function BD(o,e,t){let n=un(new Array(mc).fill(0)),i=se(new S(0,1,0)),s=se(0),r=b(mc),a=se(0),c=se(1),l=Te(null),u=se(0),h=b(1/e),d=b(1/t),f=b(o),p={n:r,latitudinal:a,weights:n,poleAxis:i,outputDirection:vS,dTheta:s,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:f},m=TS("blur");return m.fragmentNode=aN({...p,latitudinal:a.equal(1)}),cN.set(m,p),m}function gE(o){let e=TS("cubemap");return e.fragmentNode=wu(o,vS),e}function _E(o){let e=TS("equirect");return e.fragmentNode=Te(o,gS(vS),0),e}var yE=new WeakMap;function OD(o){let e=Math.log2(o)-2,t=1/o;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function VD(o,e,t){let n=GD(e),i=n.get(o);if((i!==void 0?i.pmremVersion:-1)!==o.pmremVersion){let r=o.image;if(o.isCubeTexture)if(kD(r))i=t.fromCubemap(o,i);else return null;else if(zD(r))i=t.fromEquirectangular(o,i);else return null;i.pmremVersion=o.pmremVersion,n.set(o,i)}return i.texture}function GD(o){let e=yE.get(o);return e===void 0&&(e=new WeakMap,yE.set(o,e)),e}var l_=class extends st{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 i=new Ge;i.isRenderTargetTexture=!0,this._texture=Te(i),this._width=se(0),this._height=se(0),this._maxMip=se(0),this.updateBeforeType=me.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=OD(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,i=this._value;n!==i.pmremVersion&&(i.isPMREMTexture===!0?t=i:t=VD(i,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new c_(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=tS.mul(P(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),oN(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function kD(o){if(o==null)return!1;let e=0,t=6;for(let n=0;n0}var bS=ue(l_).setParameterLength(1,3),xE=new WeakMap,u_=class extends pr{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 h=n.isTextureNode?n.value:t[n.property],d=xE.get(h);d===void 0&&(d=bS(h),xE.set(h,d)),n=d}let s=t.useAnisotropy===!0||t.anisotropy>0?rC:Oe,r=n.context(vE(ds,s)).mul(tg),a=n.context(HD(fo)).mul(Math.PI).mul(tg),c=Yd(r),l=Yd(a);e.context.radiance.addAssign(c),e.context.iblIrradiance.addAssign(l);let u=e.context.lightingModel.clearcoatRadiance;if(u){let h=n.context(vE(hf,yc)).mul(tg),d=Yd(h);u.addAssign(d)}}},vE=(o,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Qe.negate().reflect(e),t=o.mul(o).mix(t,e).normalize(),t=t.transformDirection(ei)),t),getTextureLevel:()=>o}},HD=o=>({getUV:()=>o,getTextureLevel:()=>b(1)}),WD=new Ii,Sf=class extends qe{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(WD),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new u_(t):null}setupLightingModel(){return new Pu}setupSpecular(){let e=Ne(P(.04),Fe.rgb,uf);In.assign(e),df.assign(1)}setupVariants(){let e=this.metalnessNode?b(this.metalnessNode):dC;uf.assign(e);let t=this.roughnessNode?b(this.roughnessNode):hC;t=_S({roughness:t}),ds.assign(t),this.setupSpecular(),Fe.assign(Y(Fe.rgb.mul(e.oneMinus()),Fe.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}},XD=new Wt,Mf=class extends Sf{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(XD),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?b(this.iorNode):EC;$d.assign(e),In.assign(Ne(Ln(Vb($d.sub(1).div($d.add(1))).mul(uC),P(1)).mul(m0),Fe.rgb,uf)),df.assign(Ne(m0,1,uf))}setupLightingModel(){return new Pu(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let t=this.clearcoatNode?b(this.clearcoatNode):pC,n=this.clearcoatRoughnessNode?b(this.clearcoatRoughnessNode):mC;fg.assign(t),hf.assign(_S({roughness:n}))}if(this.useSheen){let t=this.sheenNode?P(this.sheenNode):yC,n=this.sheenRoughnessNode?b(this.sheenRoughnessNode):xC;_c.assign(t),Ay.assign(n)}if(this.useIridescence){let t=this.iridescenceNode?b(this.iridescenceNode):TC,n=this.iridescenceIORNode?b(this.iridescenceIORNode):bC,i=this.iridescenceThicknessNode?b(this.iridescenceThicknessNode):SC;Ey.assign(t),Mb.assign(n),Ab.assign(i)}if(this.useAnisotropy){let t=(this.anisotropyNode?O(this.anisotropyNode):vC).toVar();Jr.assign(t.length()),ne(Jr.equal(0),()=>{t.assign(O(1,0))}).Else(()=>{t.divAssign(O(Jr)),Jr.assign(Jr.saturate())}),pg.assign(Jr.pow2().mix(ds.pow2(),1)),qd.assign(xc[0].mul(t.x).add(xc[1].mul(t.y))),Sc.assign(xc[1].mul(t.x).sub(xc[0].mul(t.y)))}if(this.useTransmission){let t=this.transmissionNode?b(this.transmissionNode):MC,n=this.thicknessNode?b(this.thicknessNode):AC,i=this.attenuationDistanceNode?b(this.attenuationDistanceNode):wC,s=this.attenuationColorNode?P(this.attenuationColorNode):RC;if(gg.assign(t),Eb.assign(n),wb.assign(i),Rb.assign(s),this.useDispersion){let r=this.dispersionNode?b(this.dispersionNode):NC;Cb.assign(r)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?P(this.clearcoatNormalNode):gC}setup(e){e.context.setupClearcoatNormal=()=>xu(this.setupClearcoatNormal(e),"NORMAL","vec3"),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)}},M0=class extends Pu{constructor(e=!1,t=!1,n=!1,i=!1,s=!1,r=!1,a=!1){super(e,t,n,i,s,r),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:n},i){if(this.useSSS===!0){let s=i.material,{thicknessColorNode:r,thicknessDistortionNode:a,thicknessAmbientNode:c,thicknessAttenuationNode:l,thicknessPowerNode:u,thicknessScaleNode:h}=s,d=e.add(Oe.mul(a)).normalize(),f=b(Qe.dot(d.negate()).saturate().pow(u).mul(h)),p=P(f.add(c).mul(r));n.directDiffuse.addAssign(p.mul(l.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},i)}},A0=class extends Mf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=b(.1),this.thicknessAmbientNode=b(0),this.thicknessAttenuationNode=b(.1),this.thicknessPowerNode=b(2),this.thicknessScaleNode=b(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new M0(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,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)}},qD=I(({normal:o,lightDirection:e,builder:t})=>{let n=o.dot(e),i=O(n.mul(.5).add(.5),0);if(t.material.gradientMap){let s=cr("gradientMap","texture").context({getUV:()=>i});return P(s.r)}else{let s=i.fwidth().mul(.5);return Ne(P(.7),P(1),Si(b(.7).sub(s.x),b(.7).add(s.x),i.x))}}),E0=class extends ro{direct({lightDirection:e,lightColor:t,reflectedLight:n},i){let s=qD({normal:Dy,lightDirection:e,builder:i}).mul(t);n.directDiffuse.addAssign(s.mul(Pc({diffuseColor:Fe.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(n.mul(Pc({diffuseColor:Fe}))),i.indirectDiffuse.mulAssign(t)}},$D=new ea,h_=class extends qe{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues($D),this.setValues(e)}setupLightingModel(){return new E0}},lN=I(()=>{let o=P(Qe.z,0,Qe.x.negate()).normalize(),e=Qe.cross(o);return O(o.dot(Oe),e.dot(Oe)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),YD=new ia,d_=class extends qe{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(YD),this.setValues(e)}setupVariants(e){let t=lN,n;e.material.matcap?n=cr("matcap","texture").context({getUV:()=>t}):n=P(Ne(.2,.8,t.y)),Fe.rgb.mulAssign(n.rgb)}},f_=class extends st{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 s=t.cos(),r=t.sin();return My(s,r,r.negate(),s).mul(n)}else{let s=t,r=bc(Y(1,0,0,0),Y(0,sr(s.x),Kn(s.x).negate(),0),Y(0,Kn(s.x),sr(s.x),0),Y(0,0,0,1)),a=bc(Y(sr(s.y),0,Kn(s.y),0),Y(0,1,0,0),Y(Kn(s.y).negate(),0,sr(s.y),0),Y(0,0,0,1)),c=bc(Y(sr(s.z),Kn(s.z).negate(),0,0),Y(Kn(s.z),sr(s.z),0,0),Y(0,0,1,0),Y(0,0,0,1));return r.mul(a).mul(c).mul(Y(n,1)).xyz}}},$f=ue(f_).setParameterLength(2),KD=new Rr,Af=class extends qe{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(KD),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:i,rotationNode:s,scaleNode:r,sizeAttenuation:a}=this,c=fr.mul(P(i||0)),l=O(xi[0].xyz.length(),xi[1].xyz.length());r!==null&&(l=l.mul(O(r))),n.isPerspectiveCamera&&a===!1&&(l=l.mul(c.z.negate()));let u=Qt.xy;if(t.center&&t.center.isVector2===!0){let f=XI("center","vec2",t);u=u.sub(f.sub(.5))}u=u.mul(l);let h=b(s||_C),d=$f(u,h);return Y(c.xy.add(d),c.zw)}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)}},jD=new es,ZD=new B,p_=class extends Af{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(jD),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return fr.mul(P(e||vt)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:i,scaleNode:s,sizeNode:r,sizeAttenuation:a}=this,c=super.setupVertex(e);if(t.isNodeMaterial!==!0)return c;let l=r!==null?O(r):CC;l=l.mul(LR),n.isPerspectiveCamera&&a===!0&&(l=l.mul(JD.div(Tt.z.negate()))),s&&s.isNode&&(l=l.mul(O(s)));let u=Qt.xy;if(i&&i.isNode){let h=b(i);u=$f(u,h)}return u=u.mul(l),u=u.div(Zb.div(2)),u=u.mul(c.w),c=c.add(Y(u,0,0)),c}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},JD=se(1).onFrameUpdate(function({renderer:o}){let e=o.getSize(ZD);this.value=.5*e.y}),w0=class extends ro{constructor(){super(),this.shadowNode=b(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Fe.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Fe.rgb)}},QD=new Jo,m_=class extends qe{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(QD),this.setValues(e)}setupLightingModel(){return new w0}},Nd=Yi("vec3"),TE=Yi("vec3"),bE=Yi("vec3"),R0=class extends ro{constructor(){super()}start(e){let{material:t,context:n}=e,i=Yi("vec3"),s=Yi("vec3");ne(Kd.sub(jn).length().greaterThan(UR.mul(2)),()=>{i.assign(Kd),s.assign(jn)}).Else(()=>{i.assign(jn),s.assign(Kd)});let r=s.sub(i),a=se("int").onRenderUpdate(({material:d})=>d.steps),c=r.length().div(a).toVar(),l=r.normalize().toVar(),u=b(0).toVar(),h=P(1).toVar();t.offsetNode&&u.addAssign(t.offsetNode.mul(c)),Ve(a,()=>{let d=i.add(l.mul(u)),f=ei.mul(Y(d,1)).xyz;t.depthNode!==null&&(TE.assign(Ru(dS(f.z,or,ar))),n.sceneDepthNode=Ru(t.depthNode).toVar()),n.positionWorld=d,n.shadowPositionWorld=d,n.positionView=f,Nd.assign(0);let p;t.scatteringNode&&(p=t.scatteringNode({positionRay:d})),super.start(e),p&&Nd.mulAssign(p);let m=Nd.mul(.01).negate().mul(c).exp();h.mulAssign(m),u.addAssign(c)}),bE.addAssign(h.saturate().oneMinus())}scatteringLight(e,t){let n=t.context.sceneDepthNode;n?ne(n.greaterThanEqual(TE),()=>{Nd.addAssign(e)}):Nd.addAssign(e)}direct({lightNode:e,lightColor:t},n){if(e.light.distance===void 0)return;let i=t.xyz.toVar();i.mulAssign(e.shadowNode),this.scatteringLight(i,n)}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:i},s){let r=t.add(n).sub(i),a=t.sub(n).sub(i),c=t.sub(n).add(i),l=t.add(n).add(i),u=s.context.positionView,h=e.xyz.mul(_D({P:u,p0:r,p1:a,p2:c,p3:l})).pow(1.5);this.scatteringLight(h,s)}finish(e){e.context.outgoingLight.assign(bE)}},C0=class extends qe{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=Nt,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new R0}},N0=class{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},Qn=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],i=new Set,s={};for(let r of e){let a;if(r.node&&r.node.attribute?a=r.node.attribute:(a=t.getAttribute(r.name),s[r.name]=a.version),a===void 0)continue;n.push(a);let c=a.isInterleavedBufferAttribute?a.data:a;i.add(c)}return this.attributes=n,this.attributesId=s,this.vertexBuffers=Array.from(i.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:i,drawRange:s}=this,r=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),c=a!==null,l=1;if(n.isInstancedBufferGeometry===!0?l=n.instanceCount:e.count!==void 0&&(l=Math.max(0,e.count)),l===0)return null;if(r.instanceCount=l,e.isBatchedMesh===!0)return r;let u=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(u=2);let h=s.start*u,d=(s.start+s.count)*u;i!==null&&(h=Math.max(h,i.start*u),d=Math.min(d,(i.start+i.count)*u));let f=n.attributes.position,p=1/0;c?p=a.count:f!=null&&(p=f.count),h=Math.max(h,0),d=Math.min(d,p);let m=d-h;return m<0||m===1/0?null:(r.vertexCount=m,r.firstVertex=h,r)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let n of Object.keys(e.attributes).sort()){let i=e.attributes[n];t+=n+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(let n of Object.keys(e.morphAttributes).sort()){let i=e.morphAttributes[n];t+="morph-"+n+",";for(let s=0,r=i.length;s1)&&(i+=e.uuid+","),i+=e.receiveShadow+",",db(i)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=tf(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=tf(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}},ac=[],I0=class{constructor(e,t,n,i,s,r){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=i,this.bindings=s,this.info=r,this.chainMaps={}}get(e,t,n,i,s,r,a,c){let l=this.getChainMap(c);ac[0]=e,ac[1]=t,ac[2]=r,ac[3]=s;let u=l.get(ac);return u===void 0?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,i,s,r,a,c),l.set(ac,u)):(u.updateClipping(a),u.needsGeometryUpdate&&u.setGeometry(e.geometry),(u.version!==t.version||u.needsUpdate)&&(u.initialCacheKey!==u.getCacheKey()?(u.dispose(),u=this.get(e,t,n,i,s,r,a,c)):u.version=t.version)),ac.length=0,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Qn)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,i,s,r,a,c,l,u,h){let d=this.getChainMap(h),f=new P0(e,t,n,i,s,r,a,c,l,u);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.delete(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},xs=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},vi={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Qr=16,nF=211,iF=212,L0=class extends xs{constructor(e){super(),this.backend=e}delete(e){let t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===vi.VERTEX?this.backend.createAttribute(e):t===vi.INDEX?this.backend.createIndexAttribute(e):t===vi.STORAGE?this.backend.createStorageAttribute(e):t===vi.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{let i=this._getBufferAttribute(e);(n.version{this.info.memory.geometries--;let s=t.index,r=e.getAttributes();s!==null&&this.attributes.delete(s);for(let c of r)this.attributes.delete(c);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",i)};t.addEventListener("dispose",i)}updateAttributes(e){let t=e.getAttributes();for(let s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,vi.STORAGE):this.updateAttribute(s,vi.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,vi.INDEX);let i=e.geometry.indirect;i!==null&&this.updateAttribute(i,vi.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){let{geometry:t,material:n}=e,i=t.index;if(n.wireframe===!0){let s=this.wireframes,r=s.get(t);r===void 0?(r=SE(t),s.set(t,r)):r.version!==uN(t)&&(this.attributes.delete(r),r=SE(t),s.set(t,r)),i=r}return i}},F0=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}},g_=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},U0=class extends g_{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},B0=class extends g_{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},sF=0,Jd=class{constructor(e,t,n,i=null,s=null){this.id=sF++,this.code=e,this.stage=t,this.name=n,this.transforms=i,this.attributes=s,this.usedTimes=0}},O0=class extends xs{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,i=this.get(e);if(this._needsComputeUpdate(e)){let s=i.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);let r=this.nodes.getForCompute(e),a=this.programs.compute.get(r.computeShader);a===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),a=new Jd(r.computeShader,"compute",e.name,r.transforms,r.nodeAttributes),this.programs.compute.set(r.computeShader,a),n.createProgram(a));let c=this._getComputeCacheKey(e,a),l=this.caches.get(c);l===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),l=this._getComputePipeline(e,a,c,t)),l.usedTimes++,a.usedTimes++,i.version=e.version,i.pipeline=l}return i.pipeline}getForRender(e,t=null){let{backend:n}=this,i=this.get(e);if(this._needsRenderUpdate(e)){let s=i.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);let r=e.getNodeBuilderState(),a=e.material?e.material.name:"",c=this.programs.vertex.get(r.vertexShader);c===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),c=new Jd(r.vertexShader,"vertex",a),this.programs.vertex.set(r.vertexShader,c),n.createProgram(c));let l=this.programs.fragment.get(r.fragmentShader);l===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),l=new Jd(r.fragmentShader,"fragment",a),this.programs.fragment.set(r.fragmentShader,l),n.createProgram(l));let u=this._getRenderCacheKey(e,c,l),h=this.caches.get(u);h===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getRenderPipeline(e,c,l,u,t)):e.pipeline=h,h.usedTimes++,c.usedTimes++,l.usedTimes++,i.pipeline=h}return i.pipeline}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,i){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new B0(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,i)),s}_getRenderPipeline(e,t,n,i,s){i=i||this._getRenderCacheKey(e,t,n);let r=this.caches.get(i);return r===void 0&&(r=new U0(i,t,n),this.caches.set(i,r),e.pipeline=r,this.backend.createRenderPipeline(e,s)),r}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},V0=class extends xs{constructor(e,t,n,i,s,r){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=i,this.nodes=t,this.info=r,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings();for(let n of t){let i=this.get(n);i.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),i.bindGroup=n)}return t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let n of t){let i=this.get(n);i.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),i.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(let t of e)this._update(t,e)}_init(e){for(let t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){let n=t.attribute,i=n.isIndirectStorageBufferAttribute?vi.INDIRECT:vi.STORAGE;this.attributes.update(n,i)}}_update(e,t){let{backend:n}=this,i=!1,s=!0,r=0,a=0;for(let c of e.bindings)if(!(c.isNodeUniformsGroup&&this.nodes.updateGroup(c)===!1)){if(c.isStorageBuffer){let l=c.attribute,u=l.isIndirectStorageBufferAttribute?vi.INDIRECT:vi.STORAGE;this.attributes.update(l,u)}if(c.isUniformBuffer)c.update()&&n.updateBinding(c);else if(c.isSampledTexture){let l=c.update(),u=c.texture,h=this.textures.get(u);if(l&&(this.textures.updateTexture(u),c.generation!==h.generation&&(c.generation=h.generation,i=!0,s=!1)),n.get(u).externalTexture!==void 0||h.isDefaultTexture?s=!1:(r=r*10+u.id,a+=u.version),u.isStorageTexture===!0){let f=this.get(u);c.store===!0?f.needsMipmap=!0:this.textures.needsMipmaps(u)&&f.needsMipmap===!0&&(this.backend.generateMipmaps(u),f.needsMipmap=!1)}}else c.isSampler&&c.update()}i===!0&&this.backend.updateBindings(e,t,s?r:0,a)}};function rF(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?o.z-e.z:o.id-e.id}function ME(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?e.z-o.z:o.id-e.id}function AE(o){return(o.transmission>0||o.transmissionNode)&&o.side===fi&&o.forceSinglePass===!1}var G0=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,i,s,r,a){let c=this.renderItems[this.renderItemsIndex];return c===void 0?(c={id:e.id,object:e,geometry:t,material:n,groupOrder:i,renderOrder:e.renderOrder,z:s,group:r,clippingContext:a},this.renderItems[this.renderItemsIndex]=c):(c.id=e.id,c.object=e,c.geometry=t,c.material=n,c.groupOrder=i,c.renderOrder=e.renderOrder,c.z=s,c.group=r,c.clippingContext=a),this.renderItemsIndex++,c}push(e,t,n,i,s,r,a){let c=this.getNextRenderItem(e,t,n,i,s,r,a);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(AE(n)&&this.transparentDoublePass.push(c),this.transparent.push(c)):this.opaque.push(c)}unshift(e,t,n,i,s,r,a){let c=this.getNextRenderItem(e,t,n,i,s,r,a);n.transparent===!0||n.transmission>0?(AE(n)&&this.transparentDoublePass.unshift(c),this.transparent.unshift(c)):this.opaque.unshift(c)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||rF),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||ME),this.transparent.length>1&&this.transparent.sort(t||ME)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,l=a.height>>t,u=e.depthTexture||s[t],h=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1;u===void 0&&h&&(u=new cn,u.format=e.stencilBuffer?pi:Hn,u.type=e.stencilBuffer?zi:Je,u.image.width=c,u.image.height=l,u.image.depth=a.depth,u.isArrayTexture=e.multiview===!0&&a.depth>1,s[t]=u),(n.width!==a.width||a.height!==n.height)&&(d=!0,u&&(u.needsUpdate=!0,u.image.width=c,u.image.height=l,u.image.depth=u.isArrayTexture?u.image.depth:1)),n.width=a.width,n.height=a.height,n.textures=r,n.depthTexture=u||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==i&&(d=!0,u&&(u.needsUpdate=!0),n.sampleCount=i);let f={sampleCount:i};if(e.isXRRenderTarget!==!0){for(let p=0;p{e.removeEventListener("dispose",p);for(let m=0;m0&&t.levels++,i||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createSampler(e),s.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&s.createSampler(e),e.version>0){let u=e.image;if(u===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(u.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){let h=[];for(let d of e.images)h.push(d);t.images=h}else t.image=u;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&xe.getTransfer(e.colorSpace)!==he&&console.warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.");let l=()=>{e.removeEventListener("dispose",l),this._destroyTexture(e)};e.addEventListener("dispose",l)}n.version=e.version}getSize(e,t=lF){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let i;return e.mipmaps.length>0?i=e.mipmaps.length:e.isCompressedTexture===!0?i=1:i=Math.floor(Math.log2(Math.max(t,n)))+1,i}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}},Ef=class extends q{constructor(e,t,n,i=1){super(e,t,n),this.a=i}set(e,t,n,i=1){return this.a=i,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},wf=class extends Ie{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}},uF=(o,e)=>U(new wf(o,e)),__=class extends j{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}add(e){return e.isNode!==!0?(console.error("THREE.TSL: Invalid node added to stack."),this):(this.nodes.push(e),this)}If(e,t){let n=new mu(t);return this._currentCond=$t(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new mu(t),i=$t(e,n);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new mu(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let a=0;atypeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var y_=class extends j{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=hF(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let i of this.membersLayout){let s=i.type,r=tw(s)*t,a=nw(s),c=n%8,l=c%a,u=c+l;n+=l,u!==0&&8-ui.name===t);return n?n.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},x_=class extends j{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},dF=(o,e=null)=>{let t=new y_(o,e),n=(...i)=>{let s=null;if(i.length>0)if(i[0].isNode){s={};let r=Object.keys(o);for(let a=0;anew oo(o,"int","float"),gF=o=>new oo(o,"uint","float"),_F=o=>new oo(o,"float","int"),yF=o=>new oo(o,"float","uint"),xF=I(([o])=>{let e=o.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),X0=(o,e)=>yi(de(4,o.mul(Se(1,o))),e),vF=(o,e)=>o.lessThan(.5)?X0(o.mul(2),e).div(2):Se(1,X0(de(Se(1,o),2),e).div(2)),TF=(o,e,t)=>yi(Zn(yi(o,e),Et(yi(o,e),yi(Se(1,o),t))),1/e),bF=(o,e)=>Kn(xg.mul(e.mul(o).sub(1))).div(xg.mul(e.mul(o).sub(1))),rr=I(([o])=>o.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),SF=I(([o])=>P(rr(o.z.add(rr(o.y.mul(1)))),rr(o.z.add(rr(o.x.mul(1)))),rr(o.y.add(rr(o.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),MF=I(([o,e,t])=>{let n=P(o).toVar(),i=b(1.4).toVar(),s=b(0).toVar(),r=P(n).toVar();return Ve({start:b(0),end:b(3),type:"float",condition:"<="},()=>{let a=P(SF(r.mul(2))).toVar();n.addAssign(a.add(t.mul(b(.1).mul(e)))),r.mulAssign(1.8),i.mulAssign(1.5),n.mulAssign(1.2);let c=b(rr(n.z.add(rr(n.x.add(rr(n.y)))))).toVar();s.addAssign(c.div(i)),r.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),T_=class extends j{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 i=null,s=-1;for(let r of this.functionNodes){let c=r.shaderNode.layout;if(c===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");let l=c.inputs;if(t.length===l.length){let u=0;for(let h=0;hs&&(i=r,s=u)}}this._candidateFnCall=n=i(...t)}return n}},AF=ue(T_),en=o=>(...e)=>AF(o,...e),Vu=se(0).setGroup(te).onRenderUpdate(o=>o.time),EF=se(0).setGroup(te).onRenderUpdate(o=>o.deltaTime),pN=se(0,"uint").setGroup(te).onRenderUpdate(o=>o.frameId),wF=(o=Vu)=>o.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),RF=(o=Vu)=>o.fract().round(),CF=(o=Vu)=>o.add(.5).fract().mul(2).sub(1).abs(),NF=(o=Vu)=>o.fract(),PF=I(([o,e,t=O(.5)])=>$f(o.sub(t),e).add(t)),IF=I(([o,e,t=O(.5)])=>{let n=o.sub(t),i=n.dot(n),r=i.mul(i).mul(e);return o.add(n.mul(r))}),LF=I(({position:o=null,horizontal:e=!0,vertical:t=!1})=>{let n;o!==null?(n=xi.toVar(),n[3][0]=o.x,n[3][1]=o.y,n[3][2]=o.z):n=xi;let i=ei.mul(n);return cf(e)&&(i[0][0]=xi[0].length(),i[0][1]=0,i[0][2]=0),cf(t)&&(i[1][0]=0,i[1][1]=xi[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,_i.mul(i).mul(vt)}),DF=I(([o=null])=>{let e=Ru();return Ru(hS(o)).sub(e).lessThan(0).select(ur,o)}),b_=class extends j{static get type(){return"SpriteSheetUVNode"}constructor(e,t=ze(),n=b(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:i,height:s}=n,r=e.mod(i.mul(s)).floor(),a=r.mod(i),c=s.sub(r.add(1).div(i).ceil()),l=n.reciprocal(),u=O(a,c);return t.add(u).mul(l)}},FF=ue(b_).setParameterLength(3),mN=I(([o,e=null,t=null,n=b(1),i=vt,s=Dn])=>{let r=s.abs().normalize();r=r.div(r.dot(P(1)));let a=i.yz.mul(n),c=i.zx.mul(n),l=i.xy.mul(n),u=o.value,h=e!==null?e.value:u,d=t!==null?t.value:u,f=Te(u,a).mul(r.x),p=Te(h,c).mul(r.y),m=Te(d,l).mul(r.z);return Et(f,p,m)}),UF=(...o)=>mN(...o),ru=new pn,cc=new S,ou=new S,Fv=new S,Ld=new ee,km=new S(0,0,-1),us=new ge,Dd=new S,zm=new S,Fd=new ge,Hm=new B,S_=new yn,BF=ur.flipX();S_.depthTexture=new cn(1,1);var Wm=!1,M_=class o extends Jn{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||S_.texture,BF),this._reflectorBaseNode=e.reflector||new q0(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=U(new o({defaultTexture:S_.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},q0=class extends j{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:n=new we,resolutionScale:i=1,generateMipmaps:s=!1,bounces:r=!0,depth:a=!1,samples:c=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=i,t.resolution!==void 0&&(_n('THREE.ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=r,this.depth=a,this.samples=c,this.updateBeforeType=r?me.RENDER:me.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolutionScale;t.getDrawingBufferSize(Hm),e.setSize(Math.round(Hm.width*n),Math.round(Hm.height*n))}setup(e){return this._updateResolution(S_,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}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 yn(0,0,{type:ft,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=om,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new cn),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Wm)return!1;Wm=!0;let{scene:t,camera:n,renderer:i,material:s}=e,{target:r}=this,a=this.getVirtualCamera(n),c=this.getRenderTarget(a);i.getDrawingBufferSize(Hm),this._updateResolution(c,i),ou.setFromMatrixPosition(r.matrixWorld),Fv.setFromMatrixPosition(n.matrixWorld),Ld.extractRotation(r.matrixWorld),cc.set(0,0,1),cc.applyMatrix4(Ld),Dd.subVectors(ou,Fv);let l=Dd.dot(cc)>0,u=!1;if(l===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Wm=!1;return}u=!0}Dd.reflect(cc).negate(),Dd.add(ou),Ld.extractRotation(n.matrixWorld),km.set(0,0,-1),km.applyMatrix4(Ld),km.add(Fv),zm.subVectors(ou,km),zm.reflect(cc).negate(),zm.add(ou),a.coordinateSystem=n.coordinateSystem,a.position.copy(Dd),a.up.set(0,1,0),a.up.applyMatrix4(Ld),a.up.reflect(cc),a.lookAt(zm),a.near=n.near,a.far=n.far,a.updateMatrixWorld(),a.projectionMatrix.copy(n.projectionMatrix),ru.setFromNormalAndCoplanarPoint(cc,ou),ru.applyMatrix4(a.matrixWorldInverse),us.set(ru.normal.x,ru.normal.y,ru.normal.z,ru.constant);let h=a.projectionMatrix;Fd.x=(Math.sign(us.x)+h.elements[8])/h.elements[0],Fd.y=(Math.sign(us.y)+h.elements[9])/h.elements[5],Fd.z=-1,Fd.w=(1+h.elements[10])/h.elements[14],us.multiplyScalar(1/us.dot(Fd));let d=0;h.elements[2]=us.x,h.elements[6]=us.y,h.elements[10]=i.coordinateSystem===Nn?us.z-d:us.z+1-d,h.elements[14]=us.w,this.textureNode.value=c.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=c.depthTexture),s.visible=!1;let f=i.getRenderTarget(),p=i.getMRT(),m=i.autoClear;i.setMRT(null),i.setRenderTarget(c),i.autoClear=!0,u?(i.clear(),this.hasOutput=!1):(i.render(t,a),this.hasOutput=!0),i.setMRT(p),i.setRenderTarget(f),i.autoClear=m,s.visible=!0,Wm=!1,this.forceUpdate=!1}get resolution(){return _n('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){_n('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}},OF=o=>U(new M_(o)),Uv=new Oi(-1,1,1,-1,0,1),$0=class extends _e{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new J([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new J(t,2))}},VF=new $0,ao=class extends Ze{constructor(e=null){super(VF,e),this.camera=Uv,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Uv)}render(e){e.render(this,Uv)}},GF=new B,A_=class extends Jn{static get type(){return"RTTNode"}constructor(e,t=null,n=null,i={type:ft}){let s=new yn(t,n,i);super(s.texture,ze()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new ao(new qe),this.updateBeforeType=me.RENDER}get autoResize(){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,i=t*this.pixelRatio;this.renderTarget.setSize(n,i),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.autoResize===!0){let n=e.getPixelRatio(),i=e.getSize(GF),s=i.width*n,r=i.height*n;(s!==this.renderTarget.width||r!==this.renderTarget.height)&&(this.renderTarget.setSize(s,r),this.textureNeedsUpdate=!0)}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 Jn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},gN=(o,...e)=>U(new A_(U(o),...e)),kF=(o,...e)=>o.isSampleNode||o.isTextureNode?o:o.isPassNode?o.getTextureNode():gN(o,...e),fu=I(([o,e,t],n)=>{let i;n.renderer.coordinateSystem===Nn?(o=O(o.x,o.y.oneMinus()).mul(2).sub(1),i=Y(P(o,e),1)):i=Y(P(o.x,o.y.oneMinus(),e).mul(2).sub(1),1);let s=Y(t.mul(i));return s.xyz.div(s.w)}),zF=I(([o,e])=>{let t=e.mul(Y(o,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return O(n.x,n.y.oneMinus())}),HF=I(([o,e,t])=>{let n=to(xt(e)),i=kt(o.mul(n)).toVar(),s=xt(e,i).toVar(),r=xt(e,i.sub(kt(2,0))).toVar(),a=xt(e,i.sub(kt(1,0))).toVar(),c=xt(e,i.add(kt(1,0))).toVar(),l=xt(e,i.add(kt(2,0))).toVar(),u=xt(e,i.add(kt(0,2))).toVar(),h=xt(e,i.add(kt(0,1))).toVar(),d=xt(e,i.sub(kt(0,1))).toVar(),f=xt(e,i.sub(kt(0,2))).toVar(),p=Ye(Se(b(2).mul(a).sub(r),s)).toVar(),m=Ye(Se(b(2).mul(c).sub(l),s)).toVar(),_=Ye(Se(b(2).mul(h).sub(u),s)).toVar(),y=Ye(Se(b(2).mul(d).sub(f),s)).toVar(),x=fu(o,s,t).toVar(),v=p.lessThan(m).select(x.sub(fu(o.sub(O(b(1).div(n.x),0)),a,t)),x.negate().add(fu(o.add(O(b(1).div(n.x),0)),c,t))),T=_.lessThan(y).select(x.sub(fu(o.add(O(0,b(1).div(n.y))),h,t)),x.negate().add(fu(o.sub(O(0,b(1).div(n.y))),d,t)));return hr(Iy(v,T))}),Y0=class extends j{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(ze())}sample(e){return this.callback(e)}},WF=(o,e=null)=>U(new Y0(o,U(e))),co=class o extends j{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===o.OBJECT?this.updateType=me.OBJECT:e===o.MATERIAL&&(this.updateType=me.RENDER)}update(e){this.callback(e)}};co.OBJECT="object";co.MATERIAL="material";var _N=(o,e)=>U(new co(o,e)).toStack(),XF=o=>_N(co.OBJECT,o),qF=o=>_N(co.MATERIAL,o),E_=class extends Bt{constructor(e,t,n=Float32Array){let i=ArrayBuffer.isView(e)?e:new n(e*t);super(i,t),this.isStorageInstancedBufferAttribute=!0}},Cf=class extends Ee{constructor(e,t,n=Float32Array){let i=ArrayBuffer.isView(e)?e:new n(e*t);super(i,t),this.isStorageBufferAttribute=!0}},$F=(o,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=sf("float")):(t=mb(e),n=sf(e));let i=new Cf(o,t,n);return wc(i,e,o)},YF=(o,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=sf("float")):(t=mb(e),n=sf(e));let i=new E_(o,t,n);return wc(i,e,o)},w_=class extends j{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}},KF=z(w_),Ud=new xn,Bv=new ee,Ai=class o extends j{static get type(){return"SceneNode"}constructor(e=o.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){let t=this.scope,n=this.scene!==null?this.scene:e.scene,i;return t===o.BACKGROUND_BLURRINESS?i=Xe("backgroundBlurriness","float",n):t===o.BACKGROUND_INTENSITY?i=Xe("backgroundIntensity","float",n):t===o.BACKGROUND_ROTATION?i=se("mat4").setName("backgroundRotation").setGroup(te).onRenderUpdate(()=>{let s=n.background;return s!==null&&s.isTexture&&s.mapping!==Pa?(Ud.copy(n.backgroundRotation),Ud.x*=-1,Ud.y*=-1,Ud.z*=-1,Bv.makeRotationFromEuler(Ud)):Bv.identity(),Bv}):console.error("THREE.SceneNode: Unknown scope:",t),i}};Ai.BACKGROUND_BLURRINESS="backgroundBlurriness";Ai.BACKGROUND_INTENSITY="backgroundIntensity";Ai.BACKGROUND_ROTATION="backgroundRotation";var yN=z(Ai,Ai.BACKGROUND_BLURRINESS),K0=z(Ai,Ai.BACKGROUND_INTENSITY),xN=z(Ai,Ai.BACKGROUND_ROTATION),R_=class extends Jn{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=qt.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(qt.READ_WRITE)}toReadOnly(){return this.setAccess(qt.READ_ONLY)}toWriteOnly(){return this.setAccess(qt.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:i,depthNode:s}=t,r=super.generate(e,"property"),a=n.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),c=i.build(e,"vec4"),l=s?s.build(e,"int"):null,u=e.generateTextureStore(e,r,a,l,c);e.addLineFlowCode(u,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}},vN=ue(R_).setParameterLength(1,3),jF=(o,e,t)=>{let n=vN(o,e,t);return t!==null&&n.toStack(),n},ZF=I(({texture:o,uv:e})=>{let n=P().toVar();return ne(e.x.lessThan(1e-4),()=>{n.assign(P(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(P(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(P(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(P(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(P(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(P(0,0,-1))}).Else(()=>{let s=o.sample(e.add(P(-.01,0,0))).r.sub(o.sample(e.add(P(.01,0,0))).r),r=o.sample(e.add(P(0,-.01,0))).r.sub(o.sample(e.add(P(0,.01,0))).r),a=o.sample(e.add(P(0,0,-.01))).r.sub(o.sample(e.add(P(0,0,.01))).r);n.assign(P(s,r,a))}),n.normalize()}),C_=class extends Jn{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return P(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(R(to(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return ZF({texture:this,uv:e})}},TN=ue(C_).setParameterLength(1,3),N_=class extends Cc{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?this.userData:e.object.userData,this.reference}},JF=(o,e,t)=>U(new N_(o,e,t)),EE=new WeakMap,j0=class extends st{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=me.OBJECT,this.updateAfterType=me.OBJECT,this.previousModelWorldMatrix=se(new ee),this.previousProjectionMatrix=se(new ee).setGroup(te),this.previousCameraViewMatrix=se(new ee)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let i=wE(n);this.previousModelWorldMatrix.value.copy(i);let s=bN(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new ee,s.previousCameraViewMatrix=new ee,s.currentProjectionMatrix=new ee,s.currentCameraViewMatrix=new ee,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){wE(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?_i:se(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(fr).mul(vt),i=this.previousProjectionMatrix.mul(t).mul(Fg),s=n.xy.div(n.w),r=i.xy.div(i.w);return Se(s,r)}};function bN(o){let e=EE.get(o);return e===void 0&&(e={},EE.set(o,e)),e}function wE(o,e=0){let t=bN(o),n=t[e];return n===void 0&&(t[e]=n=new ee,t[e].copy(o.matrixWorld)),n}var QF=z(j0),eU=I(([o])=>SS(o.rgb)),tU=I(([o,e=b(1)])=>e.mix(SS(o.rgb),o.rgb)),nU=I(([o,e=b(1)])=>{let t=Et(o.r,o.g,o.b).div(3),n=o.r.max(o.g.max(o.b)),i=n.sub(t).mul(e).mul(-3);return Ne(o.rgb,n,i)}),iU=I(([o,e=b(1)])=>{let t=P(.57735,.57735,.57735),n=e.cos();return P(o.rgb.mul(n).add(t.cross(o.rgb).mul(e.sin()).add(t.mul(uo(t,o.rgb).mul(n.oneMinus())))))}),SS=(o,e=P(xe.getLuminanceCoefficients(new S)))=>uo(o,e),sU=I(([o,e=P(1),t=P(0),n=P(1),i=b(1),s=P(xe.getLuminanceCoefficients(new S,Ut))])=>{let r=o.rgb.dot(P(s)),a=mt(o.rgb.mul(e).add(t),0).toVar(),c=a.pow(n).toVar();return ne(a.r.greaterThan(0),()=>{a.r.assign(c.r)}),ne(a.g.greaterThan(0),()=>{a.g.assign(c.g)}),ne(a.b.greaterThan(0),()=>{a.b.assign(c.b)}),a.assign(r.add(a.sub(r).mul(i))),Y(a.rgb,o.a)}),P_=class extends st{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)}},rU=ue(P_).setParameterLength(2),Xm=new B,I_=class extends Jn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},L_=class extends I_{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(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}},Ki=class o extends st{static get type(){return"PassNode"}constructor(e,t,n,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;let s=new cn;s.isRenderTargetTexture=!0,s.name="depth";let r=new yn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ft,...i});r.texture.name="output",r.depthTexture=s,this.renderTarget=r,this._textures={output:r.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=se(0),this._cameraFar=se(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=me.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),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(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=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&&(t=U(new L_(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new L_(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=fS(this.getTextureNode(e),n,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=Tu(s,n,i)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===o.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,i,s,r=t.getOutputRenderTarget();r&&r.isXRRenderTarget===!0?(s=1,i=t.xr.getCamera(),t.xr.updateCamera(i),Xm.set(r.width,r.height)):(i=this.camera,s=t.getPixelRatio(),t.getSize(Xm)),this._pixelRatio=s,this.setSize(Xm.width,Xm.height);let a=t.getRenderTarget(),c=t.getMRT(),l=i.layers.mask;this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask);for(let u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,i),t.setRenderTarget(a),t.setMRT(c),i.layers.mask=l}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,i=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,i),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,i){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new ge),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,i),this._scissor.multiplyScalar(this._pixelRatio*this._resolution).floor())}setViewport(e,t,n,i){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new ge),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,i),this._viewport.multiplyScalar(this._pixelRatio*this._resolution).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};Ki.COLOR="color";Ki.DEPTH="depth";var oU=(o,e,t)=>U(new Ki(Ki.COLOR,o,e,t)),aU=(o,e)=>U(new I_(o,e)),cU=(o,e,t)=>U(new Ki(Ki.DEPTH,o,e,t)),D_=class extends Ki{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,i,s){super(Ki.COLOR,e,t),this.colorNode=n,this.thicknessNode=i,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((i,s,r,a,c,l,u,h)=>{if((c.isMeshToonMaterial||c.isMeshToonNodeMaterial)&&c.wireframe===!1){let d=this._getOutlineMaterial(c);t.renderObject(i,s,r,a,d,l,u,h)}t.renderObject(i,s,r,a,c,l,u,h)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new qe;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Nt;let t=Dn.negate(),n=_i.mul(fr),i=b(1),s=n.mul(Y(vt,1)),r=n.mul(Y(vt.add(t),1)),a=hr(s.sub(r));return e.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(i)),e.colorNode=Y(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}},lU=(o,e,t=new q(0,0,0),n=.003,i=1)=>U(new D_(o,e,U(t),U(n),U(i))),SN=I(([o,e])=>o.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MN=I(([o,e])=>(o=o.mul(e),o.div(o.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),AN=I(([o,e])=>{o=o.mul(e),o=o.sub(.004).max(0);let t=o.mul(o.mul(6.2).add(.5)),n=o.mul(o.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),uU=I(([o])=>{let e=o.mul(o.add(.0245786)).sub(90537e-9),t=o.mul(o.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),EN=I(([o,e])=>{let t=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return o=o.mul(e).div(.6),o=t.mul(o),o=uU(o),o=n.mul(o),o.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hU=dn(P(1.6605,-.1246,-.0182),P(-.5876,1.1329,-.1006),P(-.0728,-.0083,1.1187)),dU=dn(P(.6274,.0691,.0164),P(.3293,.9195,.088),P(.0433,.0113,.8956)),fU=I(([o])=>{let e=P(o).toVar(),t=P(e.mul(e)).toVar(),n=P(t.mul(t)).toVar();return b(15.5).mul(n.mul(t)).sub(de(40.14,n.mul(e))).add(de(31.96,n).sub(de(6.868,t.mul(e))).add(de(.4298,t).add(de(.1191,e).sub(.00232))))}),wN=I(([o,e])=>{let t=P(o).toVar(),n=dn(P(.856627153315983,.137318972929847,.11189821299995),P(.0951212405381588,.761241990602591,.0767994186031903),P(.0482516061458583,.101439036467562,.811302368396859)),i=dn(P(1.1271005818144368,-.1413297634984383,-.14132976349843826),P(-.11060664309660323,1.157823702216272,-.11060664309660294),P(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=b(-12.47393),r=b(4.026069);return t.mulAssign(e),t.assign(dU.mul(t)),t.assign(n.mul(t)),t.assign(mt(t,1e-10)),t.assign(fs(t)),t.assign(t.sub(s).div(r.sub(s))),t.assign(bi(t,0,1)),t.assign(fU(t)),t.assign(i.mul(t)),t.assign(yi(mt(P(0),t),P(2.2))),t.assign(hU.mul(t)),t.assign(bi(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),RN=I(([o,e])=>{let t=b(.76),n=b(.15);o=o.mul(e);let i=Ln(o.r,Ln(o.g,o.b)),s=$t(i.lessThan(.08),i.sub(de(6.25,i.mul(i))),.04);o.subAssign(s);let r=mt(o.r,mt(o.g,o.b));ne(r.lessThan(t),()=>o);let a=Se(1,t),c=Se(1,a.mul(a).div(r.add(a.sub(t))));o.mulAssign(c.div(r));let l=Se(1,Zn(1,n.mul(r.sub(c)).add(1)));return Ne(o,P(c),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Gt=class extends j{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let i of t)i.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}},Gy=ue(Gt).setParameterLength(1,3),pU=(o,e)=>Gy(o,e,"js"),mU=(o,e)=>Gy(o,e,"wgsl"),gU=(o,e)=>Gy(o,e,"glsl"),Nf=class extends Gt{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}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),i=n.name,s=n.type,r=e.getCodeFromNode(this,s);i!==""&&(r.name=i);let a=e.getPropertyName(r),c=this.getNodeFunction(e).getCode(a);return r.code=c+` `,t==="property"?a:e.format(`${a}()`,s,t)}},CN=(o,e=[],t="")=>{for(let s=0;sn.call(...s);return i.functionNode=n,i},_U=(o,e)=>CN(o,e,"glsl"),yU=(o,e)=>CN(o,e,"wgsl"),F_=class extends j{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new on,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:b()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=_b(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=yb(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}},rg=ue(F_).setParameterLength(1),U_=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let i=t(...n);return this.set(e,i),i}}},Z0=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}},og=new U_,B_=class extends j{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new U_,this._output=rg(null),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]=rg(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]=rg(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 i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){let i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(l,u)=>this.setOutput(l,u),n=new Z0(this),i=og.get("THREE"),s=og.get("TSL"),r=this.getMethod(),a=[n,this._local,og,e,t,i,s];this._object=r(...a);let c=this._object.layout;if(c&&(c.cache===!1&&this._local.clear(),this._output.outputType=c.outputType||null,Array.isArray(c.elements)))for(let l of c.elements){let u=l.id||l.name;l.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=l.inputType),l.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=l.outputType)}return this._object}deserialize(e){super.deserialize(e);for(let t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:b()}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"],n=["layout","init","main","dispose"].join(", "),i="var "+n+`; var output = {}; `,s=` return { ...output, `+n+" };",r=i+this.codeNode.code+s;return this._method=new Function(...e,r),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=[db(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Gf(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()}},xU=ue(B_).setParameterLength(1,2);function NN(o){let e,t=o.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Tt.z).negate()}var MS=I(([o,e],t)=>{let n=NN(t);return Si(o,e,n)}),AS=I(([o],e)=>{let t=NN(e);return o.mul(o,t,t).negate().exp().oneMinus()}),Pf=I(([o,e])=>Y(e.toFloat().mix(yu.rgb,o.toVec3()),yu.a));function vU(o,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Pf(o,MS(e,t))}function TU(o,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Pf(o,AS(e))}var lc=null,uc=null,O_=class extends j{static get type(){return"RangeNode"}constructor(e=b(),t=b()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(lr(this.minNode.value)),n=e.getTypeLength(lr(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 i=this.minNode.value,s=this.maxNode.value,r=e.getTypeLength(lr(i)),a=e.getTypeLength(lr(s));lc=lc||new ge,uc=uc||new ge,lc.setScalar(0),uc.setScalar(0),r===1?lc.setScalar(i):i.isColor?lc.set(i.r,i.g,i.b,1):lc.set(i.x,i.y,i.z||0,i.w||0),a===1?uc.setScalar(s):s.isColor?uc.set(s.r,s.g,s.b,1):uc.set(s.x,s.y,s.z||0,s.w||0);let c=4,l=c*t.count,u=new Float32Array(l);for(let d=0;dU(new J0(o,e)),SU=Yf("numWorkgroups","uvec3"),MU=Yf("workgroupId","uvec3"),AU=Yf("globalId","uvec3"),EU=Yf("localId","uvec3"),wU=Yf("subgroupSize","uint"),Q0=class extends j{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier `):e.addLineFlowCode(`${t}Barrier()`,this)}},ES=ue(Q0),RU=()=>ES("workgroup").toStack(),CU=()=>ES("storage").toStack(),NU=()=>ES("texture").toStack(),eT=class extends _s{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,i=e.context.assign;if(n=super.generate(e),i!==!0){let s=this.getNodeType(e);n=e.format(n,s,t)}return n}},tT=class extends j{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new eT(this,e))}generate(e){let t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},PU=(o,e)=>U(new tT("Workgroup",o,e)),Rt=class extends j{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,i=this.method,s=this.getNodeType(e),r=this.getInputType(e),a=this.pointerNode,c=this.valueNode,l=[];l.push(`&${a.build(e,r)}`),c!==null&&l.push(c.build(e,r));let u=`${e.getMethod(i,s)}( ${l.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(u,this);else return t.constNode===void 0&&(t.constNode=dr(u,s).toConst()),t.constNode.build(e)}};Rt.ATOMIC_LOAD="atomicLoad";Rt.ATOMIC_STORE="atomicStore";Rt.ATOMIC_ADD="atomicAdd";Rt.ATOMIC_SUB="atomicSub";Rt.ATOMIC_MAX="atomicMax";Rt.ATOMIC_MIN="atomicMin";Rt.ATOMIC_AND="atomicAnd";Rt.ATOMIC_OR="atomicOr";Rt.ATOMIC_XOR="atomicXor";var IU=ue(Rt),Ms=(o,e,t)=>IU(o,e,t).toStack(),LU=o=>Ms(Rt.ATOMIC_LOAD,o,null),DU=(o,e)=>Ms(Rt.ATOMIC_STORE,o,e),FU=(o,e)=>Ms(Rt.ATOMIC_ADD,o,e),UU=(o,e)=>Ms(Rt.ATOMIC_SUB,o,e),BU=(o,e)=>Ms(Rt.ATOMIC_MAX,o,e),OU=(o,e)=>Ms(Rt.ATOMIC_MIN,o,e),VU=(o,e)=>Ms(Rt.ATOMIC_AND,o,e),GU=(o,e)=>Ms(Rt.ATOMIC_OR,o,e),kU=(o,e)=>Ms(Rt.ATOMIC_XOR,o,e),K=class o extends st{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(n)?0:e.getTypeLength(n);return i>s?t:n}getNodeType(e){let t=this.method;return t===o.SUBGROUP_ELECT?"bool":t===o.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let n=this.method,i=this.getNodeType(e),s=this.getInputType(e),r=this.aNode,a=this.bNode,c=[];if(n===o.SUBGROUP_BROADCAST||n===o.SUBGROUP_SHUFFLE||n===o.QUAD_BROADCAST){let u=a.getNodeType(e);c.push(r.build(e,i),a.build(e,u==="float"?"int":i))}else n===o.SUBGROUP_SHUFFLE_XOR||n===o.SUBGROUP_SHUFFLE_DOWN||n===o.SUBGROUP_SHUFFLE_UP?c.push(r.build(e,i),a.build(e,"uint")):(r!==null&&c.push(r.build(e,s)),a!==null&&c.push(a.build(e,s)));let l=c.length===0?"()":`( ${c.join(", ")} )`;return e.format(`${e.getMethod(n,i)}${l}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};K.SUBGROUP_ELECT="subgroupElect";K.SUBGROUP_BALLOT="subgroupBallot";K.SUBGROUP_ADD="subgroupAdd";K.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";K.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";K.SUBGROUP_MUL="subgroupMul";K.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";K.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";K.SUBGROUP_AND="subgroupAnd";K.SUBGROUP_OR="subgroupOr";K.SUBGROUP_XOR="subgroupXor";K.SUBGROUP_MIN="subgroupMin";K.SUBGROUP_MAX="subgroupMax";K.SUBGROUP_ALL="subgroupAll";K.SUBGROUP_ANY="subgroupAny";K.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";K.QUAD_SWAP_X="quadSwapX";K.QUAD_SWAP_Y="quadSwapY";K.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";K.SUBGROUP_BROADCAST="subgroupBroadcast";K.SUBGROUP_SHUFFLE="subgroupShuffle";K.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";K.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";K.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";K.QUAD_BROADCAST="quadBroadcast";var zU=k(K,K.SUBGROUP_ELECT).setParameterLength(0),HU=k(K,K.SUBGROUP_BALLOT).setParameterLength(1),WU=k(K,K.SUBGROUP_ADD).setParameterLength(1),XU=k(K,K.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),qU=k(K,K.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),$U=k(K,K.SUBGROUP_MUL).setParameterLength(1),YU=k(K,K.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),KU=k(K,K.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),jU=k(K,K.SUBGROUP_AND).setParameterLength(1),ZU=k(K,K.SUBGROUP_OR).setParameterLength(1),JU=k(K,K.SUBGROUP_XOR).setParameterLength(1),QU=k(K,K.SUBGROUP_MIN).setParameterLength(1),eB=k(K,K.SUBGROUP_MAX).setParameterLength(1),tB=k(K,K.SUBGROUP_ALL).setParameterLength(0),nB=k(K,K.SUBGROUP_ANY).setParameterLength(0),iB=k(K,K.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),sB=k(K,K.QUAD_SWAP_X).setParameterLength(1),rB=k(K,K.QUAD_SWAP_Y).setParameterLength(1),oB=k(K,K.QUAD_SWAP_DIAGONAL).setParameterLength(1),aB=k(K,K.SUBGROUP_BROADCAST).setParameterLength(2),cB=k(K,K.SUBGROUP_SHUFFLE).setParameterLength(2),lB=k(K,K.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),uB=k(K,K.SUBGROUP_SHUFFLE_UP).setParameterLength(2),hB=k(K,K.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),dB=k(K,K.QUAD_BROADCAST).setParameterLength(1),qm;function ky(o){qm=qm||new WeakMap;let e=qm.get(o);return e===void 0&&qm.set(o,e={}),e}function zy(o){let e=ky(o);return e.shadowMatrix||(e.shadowMatrix=se("mat4").setGroup(te).onRenderUpdate(t=>((o.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&o.shadow.updateMatrices(o),o.shadow.matrix)))}function PN(o,e=jn){let t=zy(o).mul(e);return t.xyz.div(t.w)}function wS(o){let e=ky(o);return e.position||(e.position=se(new S).setGroup(te).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(o.matrixWorld)))}function IN(o){let e=ky(o);return e.targetPosition||(e.targetPosition=se(new S).setGroup(te).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(o.target.matrixWorld)))}function RS(o){let e=ky(o);return e.viewPosition||(e.viewPosition=se(new S).setGroup(te).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new S,n.value.setFromMatrixPosition(o.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}var CS=o=>ei.transformDirection(wS(o).sub(IN(o))),fB=o=>o.sort((e,t)=>e.id-t.id),pB=(o,e)=>{for(let t of e)if(t.isAnalyticLightNode&&t.light.id===o)return t;return null},Ov=new WeakMap,Bd=[],Iu=class extends j{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Yi("vec3","totalDiffuse"),this.totalSpecularNode=Yi("vec3","totalSpecular"),this.outgoingLightNode=Yi("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let n=0;n0}},mB=(o=[])=>U(new Iu).setLights(o),V_=class extends j{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=me.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){NS.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||jn)}},NS=Yi("vec3","shadowPositionWorld");function PS(o,e={}){return e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure,e.outputColorSpace=o.outputColorSpace,e.renderTarget=o.getRenderTarget(),e.activeCubeFace=o.getActiveCubeFace(),e.activeMipmapLevel=o.getActiveMipmapLevel(),e.renderObjectFunction=o.getRenderObjectFunction(),e.pixelRatio=o.getPixelRatio(),e.mrt=o.getMRT(),e.clearColor=o.getClearColor(e.clearColor||new q),e.clearAlpha=o.getClearAlpha(),e.autoClear=o.autoClear,e.scissorTest=o.getScissorTest(),e}function LN(o,e){return e=PS(o,e),o.setMRT(null),o.setRenderObjectFunction(null),o.setClearColor(0,1),o.autoClear=!0,e}function DN(o,e){o.toneMapping=e.toneMapping,o.toneMappingExposure=e.toneMappingExposure,o.outputColorSpace=e.outputColorSpace,o.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),o.setRenderObjectFunction(e.renderObjectFunction),o.setPixelRatio(e.pixelRatio),o.setMRT(e.mrt),o.setClearColor(e.clearColor,e.clearAlpha),o.autoClear=e.autoClear,o.setScissorTest(e.scissorTest)}function IS(o,e={}){return e.background=o.background,e.backgroundNode=o.backgroundNode,e.overrideMaterial=o.overrideMaterial,e}function FN(o,e){return e=IS(o,e),o.background=null,o.backgroundNode=null,o.overrideMaterial=null,e}function UN(o,e){o.background=e.background,o.backgroundNode=e.backgroundNode,o.overrideMaterial=e.overrideMaterial}function gB(o,e,t={}){return t=PS(o,t),t=IS(e,t),t}function BN(o,e,t){return t=LN(o,t),t=FN(e,t),t}function ON(o,e,t){DN(o,t),UN(e,t)}var _B=Object.freeze({__proto__:null,resetRendererAndSceneState:BN,resetRendererState:LN,resetSceneState:FN,restoreRendererAndSceneState:ON,restoreRendererState:DN,restoreSceneState:UN,saveRendererAndSceneState:gB,saveRendererState:PS,saveSceneState:IS}),RE=new WeakMap,VN=I(({depthTexture:o,shadowCoord:e,depthLayer:t})=>{let n=Te(o,e.xy).setName("t_basic");return o.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),GN=I(({depthTexture:o,shadowCoord:e,shadow:t,depthLayer:n})=>{let i=(_,y)=>{let x=Te(o,_);return o.isArrayTexture&&(x=x.depth(n)),x.compare(y)},s=Xe("mapSize","vec2",t).setGroup(te),r=Xe("radius","float",t).setGroup(te),a=O(1).div(s),c=a.x.negate().mul(r),l=a.y.negate().mul(r),u=a.x.mul(r),h=a.y.mul(r),d=c.div(2),f=l.div(2),p=u.div(2),m=h.div(2);return Et(i(e.xy.add(O(c,l)),e.z),i(e.xy.add(O(0,l)),e.z),i(e.xy.add(O(u,l)),e.z),i(e.xy.add(O(d,f)),e.z),i(e.xy.add(O(0,f)),e.z),i(e.xy.add(O(p,f)),e.z),i(e.xy.add(O(c,0)),e.z),i(e.xy.add(O(d,0)),e.z),i(e.xy,e.z),i(e.xy.add(O(p,0)),e.z),i(e.xy.add(O(u,0)),e.z),i(e.xy.add(O(d,m)),e.z),i(e.xy.add(O(0,m)),e.z),i(e.xy.add(O(p,m)),e.z),i(e.xy.add(O(c,h)),e.z),i(e.xy.add(O(0,h)),e.z),i(e.xy.add(O(u,h)),e.z)).mul(1/17)}),kN=I(({depthTexture:o,shadowCoord:e,shadow:t,depthLayer:n})=>{let i=(h,d)=>{let f=Te(o,h);return o.isArrayTexture&&(f=f.depth(n)),f.compare(d)},s=Xe("mapSize","vec2",t).setGroup(te),r=O(1).div(s),a=r.x,c=r.y,l=e.xy,u=mr(l.mul(s).add(.5));return l.subAssign(u.mul(r)),Et(i(l,e.z),i(l.add(O(a,0)),e.z),i(l.add(O(0,c)),e.z),i(l.add(r),e.z),Ne(i(l.add(O(a.negate(),0)),e.z),i(l.add(O(a.mul(2),0)),e.z),u.x),Ne(i(l.add(O(a.negate(),c)),e.z),i(l.add(O(a.mul(2),c)),e.z),u.x),Ne(i(l.add(O(0,c.negate())),e.z),i(l.add(O(0,c.mul(2))),e.z),u.y),Ne(i(l.add(O(a,c.negate())),e.z),i(l.add(O(a,c.mul(2))),e.z),u.y),Ne(Ne(i(l.add(O(a.negate(),c.negate())),e.z),i(l.add(O(a.mul(2),c.negate())),e.z),u.x),Ne(i(l.add(O(a.negate(),c.mul(2))),e.z),i(l.add(O(a.mul(2),c.mul(2))),e.z),u.x),u.y)).mul(1/9)}),zN=I(({depthTexture:o,shadowCoord:e,depthLayer:t})=>{let n=b(1).toVar(),i=Te(o).sample(e.xy);o.isArrayTexture&&(i=i.depth(t)),i=i.rg;let s=Py(e.z,i.x);return ne(s.notEqual(b(1)),()=>{let r=e.z.sub(i.x),a=mt(0,i.y.mul(i.y)),c=a.div(a.add(r.mul(r)));c=bi(Se(c,.3).div(.95-.3)),n.assign(bi(mt(s,c)))}),n}),yB=I(([o,e,t])=>{let n=jn.sub(o).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),xB=o=>{let e=o.shadow.camera,t=Xe("near","float",e).setGroup(te),n=Xe("far","float",e).setGroup(te),i=FR(o);return yB(i,t,n)},HN=o=>{let e=RE.get(o);if(e===void 0){let t=o.isPointLight?xB(o):null;e=new qe,e.colorNode=Y(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,RE.set(o,e)}return e},CE=new Qn,au=[],WN=(o,e,t,n)=>{au[0]=o,au[1]=e;let i=CE.get(au);return(i===void 0||i.shadowType!==t||i.useVelocity!==n)&&(i=(s,r,a,c,l,u,...h)=>{(s.castShadow===!0||s.receiveShadow&&t===xa)&&(n&&(gb(s).useVelocity=!0),s.onBeforeShadow(o,s,a,e.camera,c,r.overrideMaterial,u),o.renderObject(s,r,a,c,l,u,...h),s.onAfterShadow(o,s,a,e.camera,c,r.overrideMaterial,u))},i.shadowType=t,i.useVelocity=n,CE.set(au,i)),au[0]=null,au[1]=null,i},vB=I(({samples:o,radius:e,size:t,shadowPass:n,depthLayer:i})=>{let s=b(0).toVar("meanVertical"),r=b(0).toVar("squareMeanVertical"),a=o.lessThanEqual(b(1)).select(b(0),b(2).div(o.sub(1))),c=o.lessThanEqual(b(1)).select(b(0),b(-1));Ve({start:R(0),end:R(o),type:"int",condition:"<"},({i:u})=>{let h=c.add(b(u).mul(a)),d=n.sample(Et(Xf.xy,O(0,h).mul(e)).div(t));n.value.isArrayTexture&&(d=d.depth(i)),d=d.x,s.addAssign(d),r.addAssign(d.mul(d))}),s.divAssign(o),r.divAssign(o);let l=bs(r.sub(s.mul(s)));return O(s,l)}),TB=I(({samples:o,radius:e,size:t,shadowPass:n,depthLayer:i})=>{let s=b(0).toVar("meanHorizontal"),r=b(0).toVar("squareMeanHorizontal"),a=o.lessThanEqual(b(1)).select(b(0),b(2).div(o.sub(1))),c=o.lessThanEqual(b(1)).select(b(0),b(-1));Ve({start:R(0),end:R(o),type:"int",condition:"<"},({i:u})=>{let h=c.add(b(u).mul(a)),d=n.sample(Et(Xf.xy,O(h,0).mul(e)).div(t));n.value.isArrayTexture&&(d=d.depth(i)),s.addAssign(d.x),r.addAssign(Et(d.y.mul(d.y),d.x.mul(d.x)))}),s.divAssign(o),r.divAssign(o);let l=bs(r.sub(s.mul(s)));return O(s,l)}),bB=[VN,GN,kN,zN],Vv,$m=new ao,If=class extends V_{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:i,shadow:s,depthLayer:r}){let a=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),c=t({depthTexture:n,shadowCoord:i,shadow:s,depthLayer:r});return a.select(c,b(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:i}=e,s=Xe("bias","float",n).setGroup(te),r=t,a;if(n.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)r=r.xyz.div(r.w),a=r.z,i.coordinateSystem===Nn&&(a=a.mul(2).sub(1));else{let c=r.w;r=r.xy.div(c);let l=Xe("near","float",n.camera).setGroup(te),u=Xe("far","float",n.camera).setGroup(te);a=pS(c.negate(),l,u)}return r=P(r.x,r.y.oneMinus(),a.add(s)),r}getShadowFilterFn(e){return bB[e]}setupRenderTarget(e,t){let n=new cn(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=nu;let i=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=e.mapType,i.depthTexture=n,{shadowMap:i,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:i}=this,s=t.shadowMap.type,{depthTexture:r,shadowMap:a}=this.setupRenderTarget(i,e);if(i.camera.updateProjectionMatrix(),s===xa&&i.isPointLightShadow!==!0){r.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Hi,type:ft,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Hi,type:ft,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Hi,type:ft,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Hi,type:ft,depthBuffer:!1}));let y=Te(r);r.isArrayTexture&&(y=y.depth(this.depthLayer));let x=Te(this.vsmShadowMapVertical.texture);r.isArrayTexture&&(x=x.depth(this.depthLayer));let v=Xe("blurSamples","float",i).setGroup(te),T=Xe("radius","float",i).setGroup(te),M=Xe("mapSize","vec2",i).setGroup(te),w=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qe);w.fragmentNode=vB({samples:v,radius:T,size:M,shadowPass:y,depthLayer:this.depthLayer}).context(e.getSharedContext()),w.name="VSMVertical",w=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qe),w.fragmentNode=TB({samples:v,radius:T,size:M,shadowPass:x,depthLayer:this.depthLayer}).context(e.getSharedContext()),w.name="VSMHorizontal"}let c=Xe("intensity","float",i).setGroup(te),l=Xe("normalBias","float",i).setGroup(te),u=zy(n).mul(NS.add(fo.mul(l))),h=this.setupShadowCoord(e,u),d=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let f=s===xa&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:r,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:a.texture,depthTexture:f,shadowCoord:h,shadow:i,depthLayer:this.depthLayer}),m=Te(a.texture,h);r.isArrayTexture&&(m=m.depth(this.depthLayer));let _=Ne(1,p.rgb.mix(m,1),c.mul(m.a)).toVar();return this.shadowMap=a,this.shadow.map=a,_}setup(e){if(e.renderer.shadowMap.enabled!==!1)return I(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:i}=this,{renderer:s,scene:r}=e;t.updateMatrices(i),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),s.render(r,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:i}=this,{renderer:s,scene:r,camera:a}=e,c=s.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;let u=i.camera.layers.mask;i.camera.layers.mask&4294967294||(i.camera.layers.mask=a.layers.mask);let h=s.getRenderObjectFunction(),d=s.getMRT(),f=d?d.has("velocity"):!1;Vv=BN(s,r,Vv),r.overrideMaterial=HN(n),s.setRenderObjectFunction(WN(s,i,c,f)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(h),c===xa&&i.isPointLightShadow!==!0&&this.vsmPass(s),i.camera.layers.mask=u,ON(s,r,Vv)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),$m.material=this.vsmMaterialVertical,$m.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),$m.material=this.vsmMaterialHorizontal,$m.render(e)}dispose(){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),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},XN=(o,e)=>U(new If(o,e)),SB=new q,$i=I(([o,e])=>{let t=o.toVar(),n=Ye(t),i=Zn(1,mt(n.x,mt(n.y,n.z)));n.mulAssign(i),t.mulAssign(i.mul(e.mul(2).oneMinus()));let s=O(t.xy).toVar(),a=e.mul(1.5).oneMinus();return ne(n.z.greaterThanEqual(a),()=>{ne(t.z.greaterThan(0),()=>{s.x.assign(Se(4,t.x))})}).ElseIf(n.x.greaterThanEqual(a),()=>{let c=gf(t.x);s.x.assign(t.z.mul(c).add(c.mul(2)))}).ElseIf(n.y.greaterThanEqual(a),()=>{let c=gf(t.y);s.x.assign(t.x.add(c.mul(2)).add(2)),s.y.assign(t.z.mul(c).sub(2))}),O(.125,.25).mul(s).add(O(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),qN=I(({depthTexture:o,bd3D:e,dp:t,texelSize:n})=>Te(o,$i(e,n.y)).compare(t)),$N=I(({depthTexture:o,bd3D:e,dp:t,texelSize:n,shadow:i})=>{let s=Xe("radius","float",i).setGroup(te),r=O(-1,1).mul(s).mul(n.y);return Te(o,$i(e.add(r.xyy),n.y)).compare(t).add(Te(o,$i(e.add(r.yyy),n.y)).compare(t)).add(Te(o,$i(e.add(r.xyx),n.y)).compare(t)).add(Te(o,$i(e.add(r.yyx),n.y)).compare(t)).add(Te(o,$i(e,n.y)).compare(t)).add(Te(o,$i(e.add(r.xxy),n.y)).compare(t)).add(Te(o,$i(e.add(r.yxy),n.y)).compare(t)).add(Te(o,$i(e.add(r.xxx),n.y)).compare(t)).add(Te(o,$i(e.add(r.yxx),n.y)).compare(t)).mul(1/9)}),MB=I(({filterFn:o,depthTexture:e,shadowCoord:t,shadow:n})=>{let i=t.xyz.toVar(),s=i.length(),r=se("float").setGroup(te).onRenderUpdate(()=>n.camera.near),a=se("float").setGroup(te).onRenderUpdate(()=>n.camera.far),c=Xe("bias","float",n).setGroup(te),l=se(n.mapSize).setGroup(te),u=b(1).toVar();return ne(s.sub(a).lessThanEqual(0).and(s.sub(r).greaterThanEqual(0)),()=>{let h=s.sub(r).div(a.sub(r)).toVar();h.addAssign(c);let d=i.normalize(),f=O(1).div(l.mul(O(4,2)));u.assign(o({depthTexture:e,bd3D:d,dp:h,texelSize:f,shadow:n}))}),u}),NE=new ge,cu=new B,Od=new B,nT=class extends If{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===$p?qN:$N}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:i,shadowCoord:s,shadow:r}){return MB({filterFn:t,shadowTexture:n,depthTexture:i,shadowCoord:s,shadow:r})}renderShadow(e){let{shadow:t,shadowMap:n,light:i}=this,{renderer:s,scene:r}=e,a=t.getFrameExtents();Od.copy(t.mapSize),Od.multiply(a),n.setSize(Od.width,Od.height),cu.copy(t.mapSize);let c=s.autoClear,l=s.getClearColor(SB),u=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();let h=t.getViewportCount();for(let d=0;dU(new nT(o,e)),vs=class extends pr{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new q,this.colorNode=e&&e.colorNode||se(this.color).setGroup(te),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=me.FRAME}getHash(){return this.light.uuid}getLightVector(e){return RS(this.light).sub(e.context.positionView||Tt)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return XN(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let i=this.light.shadow.shadowNode,s;i!==void 0?s=U(i):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},LS=I(({lightDistance:o,cutoffDistance:e,decayExponent:t})=>{let n=o.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(o.div(e).pow4().oneMinus().clamp().pow2()),n)}),KN=({color:o,lightVector:e,cutoffDistance:t,decayExponent:n})=>{let i=e.normalize(),s=e.length(),r=LS({lightDistance:s,cutoffDistance:t,decayExponent:n}),a=o.mul(r);return{lightDirection:i,lightColor:a}},G_=class extends vs{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=se(0).setGroup(te),this.decayExponentNode=se(2).setGroup(te)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return YN(this.light)}setupDirect(e){return KN({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},AB=I(([o=ze()])=>{let e=o.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),EB=I(([o=ze()],{renderer:e,material:t})=>{let n=Gb(o.mul(2).sub(1)),i;if(t.alphaToCoverage&&e.samples>1){let s=b(n.fwidth()).toVar();i=Si(s.oneMinus(),s.add(1),n).oneMinus()}else i=$t(n.greaterThan(1),0,1);return i}),Qd=I(([o,e,t])=>{let n=b(t).toVar(),i=b(e).toVar(),s=Ti(o).toVar();return $t(s,i,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),k_=I(([o,e])=>{let t=Ti(e).toVar(),n=b(o).toVar();return $t(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),At=I(([o])=>{let e=b(o).toVar();return R(ps(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),it=I(([o,e])=>{let t=b(o).toVar();return e.assign(At(t)),t.sub(b(e))}),wB=I(([o,e,t,n,i,s])=>{let r=b(s).toVar(),a=b(i).toVar(),c=b(n).toVar(),l=b(t).toVar(),u=b(e).toVar(),h=b(o).toVar(),d=b(Se(1,a)).toVar();return Se(1,r).mul(h.mul(d).add(u.mul(a))).add(r.mul(l.mul(d).add(c.mul(a))))}).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"}]}),RB=I(([o,e,t,n,i,s])=>{let r=b(s).toVar(),a=b(i).toVar(),c=P(n).toVar(),l=P(t).toVar(),u=P(e).toVar(),h=P(o).toVar(),d=b(Se(1,a)).toVar();return Se(1,r).mul(h.mul(d).add(u.mul(a))).add(r.mul(l.mul(d).add(c.mul(a))))}).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"}]}),jN=en([wB,RB]),CB=I(([o,e,t,n,i,s,r,a,c,l,u])=>{let h=b(u).toVar(),d=b(l).toVar(),f=b(c).toVar(),p=b(a).toVar(),m=b(r).toVar(),_=b(s).toVar(),y=b(i).toVar(),x=b(n).toVar(),v=b(t).toVar(),T=b(e).toVar(),M=b(o).toVar(),w=b(Se(1,f)).toVar(),E=b(Se(1,d)).toVar();return b(Se(1,h)).toVar().mul(E.mul(M.mul(w).add(T.mul(f))).add(d.mul(v.mul(w).add(x.mul(f))))).add(h.mul(E.mul(y.mul(w).add(_.mul(f))).add(d.mul(m.mul(w).add(p.mul(f))))))}).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"}]}),NB=I(([o,e,t,n,i,s,r,a,c,l,u])=>{let h=b(u).toVar(),d=b(l).toVar(),f=b(c).toVar(),p=P(a).toVar(),m=P(r).toVar(),_=P(s).toVar(),y=P(i).toVar(),x=P(n).toVar(),v=P(t).toVar(),T=P(e).toVar(),M=P(o).toVar(),w=b(Se(1,f)).toVar(),E=b(Se(1,d)).toVar();return b(Se(1,h)).toVar().mul(E.mul(M.mul(w).add(T.mul(f))).add(d.mul(v.mul(w).add(x.mul(f))))).add(h.mul(E.mul(y.mul(w).add(_.mul(f))).add(d.mul(m.mul(w).add(p.mul(f))))))}).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"}]}),ZN=en([CB,NB]),PB=I(([o,e,t])=>{let n=b(t).toVar(),i=b(e).toVar(),s=$(o).toVar(),r=$(s.bitAnd($(7))).toVar(),a=b(Qd(r.lessThan($(4)),i,n)).toVar(),c=b(de(2,Qd(r.lessThan($(4)),n,i))).toVar();return k_(a,Ti(r.bitAnd($(1)))).add(k_(c,Ti(r.bitAnd($(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),IB=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=b(e).toVar(),a=$(o).toVar(),c=$(a.bitAnd($(15))).toVar(),l=b(Qd(c.lessThan($(8)),r,s)).toVar(),u=b(Qd(c.lessThan($(4)),s,Qd(c.equal($(12)).or(c.equal($(14))),r,i))).toVar();return k_(l,Ti(c.bitAnd($(1)))).add(k_(u,Ti(c.bitAnd($(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"}]}),Xt=en([PB,IB]),LB=I(([o,e,t])=>{let n=b(t).toVar(),i=b(e).toVar(),s=Bu(o).toVar();return P(Xt(s.x,i,n),Xt(s.y,i,n),Xt(s.z,i,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),DB=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=b(e).toVar(),a=Bu(o).toVar();return P(Xt(a.x,r,s,i),Xt(a.y,r,s,i),Xt(a.z,r,s,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"}]}),mi=en([LB,DB]),FB=I(([o])=>{let e=b(o).toVar();return de(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),UB=I(([o])=>{let e=b(o).toVar();return de(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),BB=I(([o])=>{let e=P(o).toVar();return de(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),JN=en([FB,BB]),OB=I(([o])=>{let e=P(o).toVar();return de(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),QN=en([UB,OB]),Yn=I(([o,e])=>{let t=R(e).toVar(),n=$(o).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(R(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),e1=I(([o,e,t])=>{o.subAssign(t),o.bitXorAssign(Yn(t,R(4))),t.addAssign(e),e.subAssign(o),e.bitXorAssign(Yn(o,R(6))),o.addAssign(t),t.subAssign(e),t.bitXorAssign(Yn(e,R(8))),e.addAssign(o),o.subAssign(t),o.bitXorAssign(Yn(t,R(16))),t.addAssign(e),e.subAssign(o),e.bitXorAssign(Yn(o,R(19))),o.addAssign(t),t.subAssign(e),t.bitXorAssign(Yn(e,R(4))),e.addAssign(o)}),Kf=I(([o,e,t])=>{let n=$(t).toVar(),i=$(e).toVar(),s=$(o).toVar();return n.bitXorAssign(i),n.subAssign(Yn(i,R(14))),s.bitXorAssign(n),s.subAssign(Yn(n,R(11))),i.bitXorAssign(s),i.subAssign(Yn(s,R(25))),n.bitXorAssign(i),n.subAssign(Yn(i,R(16))),s.bitXorAssign(n),s.subAssign(Yn(n,R(4))),i.bitXorAssign(s),i.subAssign(Yn(s,R(14))),n.bitXorAssign(i),n.subAssign(Yn(i,R(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),hn=I(([o])=>{let e=$(o).toVar();return b(e).div(b($(R(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),gs=I(([o])=>{let e=b(o).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),VB=I(([o])=>{let e=R(o).toVar(),t=$($(1)).toVar(),n=$($(R(3735928559)).add(t.shiftLeft($(2))).add($(13))).toVar();return Kf(n.add($(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),GB=I(([o,e])=>{let t=R(e).toVar(),n=R(o).toVar(),i=$($(2)).toVar(),s=$().toVar(),r=$().toVar(),a=$().toVar();return s.assign(r.assign(a.assign($(R(3735928559)).add(i.shiftLeft($(2))).add($(13))))),s.addAssign($(n)),r.addAssign($(t)),Kf(s,r,a)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),kB=I(([o,e,t])=>{let n=R(t).toVar(),i=R(e).toVar(),s=R(o).toVar(),r=$($(3)).toVar(),a=$().toVar(),c=$().toVar(),l=$().toVar();return a.assign(c.assign(l.assign($(R(3735928559)).add(r.shiftLeft($(2))).add($(13))))),a.addAssign($(s)),c.addAssign($(i)),l.addAssign($(n)),Kf(a,c,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),zB=I(([o,e,t,n])=>{let i=R(n).toVar(),s=R(t).toVar(),r=R(e).toVar(),a=R(o).toVar(),c=$($(4)).toVar(),l=$().toVar(),u=$().toVar(),h=$().toVar();return l.assign(u.assign(h.assign($(R(3735928559)).add(c.shiftLeft($(2))).add($(13))))),l.addAssign($(a)),u.addAssign($(r)),h.addAssign($(s)),e1(l,u,h),l.addAssign($(i)),Kf(l,u,h)}).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"}]}),HB=I(([o,e,t,n,i])=>{let s=R(i).toVar(),r=R(n).toVar(),a=R(t).toVar(),c=R(e).toVar(),l=R(o).toVar(),u=$($(5)).toVar(),h=$().toVar(),d=$().toVar(),f=$().toVar();return h.assign(d.assign(f.assign($(R(3735928559)).add(u.shiftLeft($(2))).add($(13))))),h.addAssign($(l)),d.addAssign($(c)),f.addAssign($(a)),e1(h,d,f),h.addAssign($(r)),d.addAssign($(s)),Kf(h,d,f)}).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"}]}),ke=en([VB,GB,kB,zB,HB]),WB=I(([o,e])=>{let t=R(e).toVar(),n=R(o).toVar(),i=$(ke(n,t)).toVar(),s=Bu().toVar();return s.x.assign(i.bitAnd(R(255))),s.y.assign(i.shiftRight(R(8)).bitAnd(R(255))),s.z.assign(i.shiftRight(R(16)).bitAnd(R(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),XB=I(([o,e,t])=>{let n=R(t).toVar(),i=R(e).toVar(),s=R(o).toVar(),r=$(ke(s,i,n)).toVar(),a=Bu().toVar();return a.x.assign(r.bitAnd(R(255))),a.y.assign(r.shiftRight(R(8)).bitAnd(R(255))),a.z.assign(r.shiftRight(R(16)).bitAnd(R(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gi=en([WB,XB]),qB=I(([o])=>{let e=O(o).toVar(),t=R().toVar(),n=R().toVar(),i=b(it(e.x,t)).toVar(),s=b(it(e.y,n)).toVar(),r=b(gs(i)).toVar(),a=b(gs(s)).toVar(),c=b(jN(Xt(ke(t,n),i,s),Xt(ke(t.add(R(1)),n),i.sub(1),s),Xt(ke(t,n.add(R(1))),i,s.sub(1)),Xt(ke(t.add(R(1)),n.add(R(1))),i.sub(1),s.sub(1)),r,a)).toVar();return JN(c)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),$B=I(([o])=>{let e=P(o).toVar(),t=R().toVar(),n=R().toVar(),i=R().toVar(),s=b(it(e.x,t)).toVar(),r=b(it(e.y,n)).toVar(),a=b(it(e.z,i)).toVar(),c=b(gs(s)).toVar(),l=b(gs(r)).toVar(),u=b(gs(a)).toVar(),h=b(ZN(Xt(ke(t,n,i),s,r,a),Xt(ke(t.add(R(1)),n,i),s.sub(1),r,a),Xt(ke(t,n.add(R(1)),i),s,r.sub(1),a),Xt(ke(t.add(R(1)),n.add(R(1)),i),s.sub(1),r.sub(1),a),Xt(ke(t,n,i.add(R(1))),s,r,a.sub(1)),Xt(ke(t.add(R(1)),n,i.add(R(1))),s.sub(1),r,a.sub(1)),Xt(ke(t,n.add(R(1)),i.add(R(1))),s,r.sub(1),a.sub(1)),Xt(ke(t.add(R(1)),n.add(R(1)),i.add(R(1))),s.sub(1),r.sub(1),a.sub(1)),c,l,u)).toVar();return QN(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),DS=en([qB,$B]),YB=I(([o])=>{let e=O(o).toVar(),t=R().toVar(),n=R().toVar(),i=b(it(e.x,t)).toVar(),s=b(it(e.y,n)).toVar(),r=b(gs(i)).toVar(),a=b(gs(s)).toVar(),c=P(jN(mi(gi(t,n),i,s),mi(gi(t.add(R(1)),n),i.sub(1),s),mi(gi(t,n.add(R(1))),i,s.sub(1)),mi(gi(t.add(R(1)),n.add(R(1))),i.sub(1),s.sub(1)),r,a)).toVar();return JN(c)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),KB=I(([o])=>{let e=P(o).toVar(),t=R().toVar(),n=R().toVar(),i=R().toVar(),s=b(it(e.x,t)).toVar(),r=b(it(e.y,n)).toVar(),a=b(it(e.z,i)).toVar(),c=b(gs(s)).toVar(),l=b(gs(r)).toVar(),u=b(gs(a)).toVar(),h=P(ZN(mi(gi(t,n,i),s,r,a),mi(gi(t.add(R(1)),n,i),s.sub(1),r,a),mi(gi(t,n.add(R(1)),i),s,r.sub(1),a),mi(gi(t.add(R(1)),n.add(R(1)),i),s.sub(1),r.sub(1),a),mi(gi(t,n,i.add(R(1))),s,r,a.sub(1)),mi(gi(t.add(R(1)),n,i.add(R(1))),s.sub(1),r,a.sub(1)),mi(gi(t,n.add(R(1)),i.add(R(1))),s,r.sub(1),a.sub(1)),mi(gi(t.add(R(1)),n.add(R(1)),i.add(R(1))),s.sub(1),r.sub(1),a.sub(1)),c,l,u)).toVar();return QN(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),jf=en([YB,KB]),jB=I(([o])=>{let e=b(o).toVar(),t=R(At(e)).toVar();return hn(ke(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ZB=I(([o])=>{let e=O(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar();return hn(ke(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),JB=I(([o])=>{let e=P(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar(),i=R(At(e.z)).toVar();return hn(ke(t,n,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),QB=I(([o])=>{let e=Y(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar(),i=R(At(e.z)).toVar(),s=R(At(e.w)).toVar();return hn(ke(t,n,i,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),e2=en([jB,ZB,JB,QB]),t2=I(([o])=>{let e=b(o).toVar(),t=R(At(e)).toVar();return P(hn(ke(t,R(0))),hn(ke(t,R(1))),hn(ke(t,R(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),n2=I(([o])=>{let e=O(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar();return P(hn(ke(t,n,R(0))),hn(ke(t,n,R(1))),hn(ke(t,n,R(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),i2=I(([o])=>{let e=P(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar(),i=R(At(e.z)).toVar();return P(hn(ke(t,n,i,R(0))),hn(ke(t,n,i,R(1))),hn(ke(t,n,i,R(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),s2=I(([o])=>{let e=Y(o).toVar(),t=R(At(e.x)).toVar(),n=R(At(e.y)).toVar(),i=R(At(e.z)).toVar(),s=R(At(e.w)).toVar();return P(hn(ke(t,n,i,s,R(0))),hn(ke(t,n,i,s,R(1))),hn(ke(t,n,i,s,R(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),Hy=en([t2,n2,i2,s2]),z_=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=R(e).toVar(),a=P(o).toVar(),c=b(0).toVar(),l=b(1).toVar();return Ve(r,()=>{c.addAssign(l.mul(DS(a))),l.mulAssign(i),a.mulAssign(s)}),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"}]}),Wy=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=R(e).toVar(),a=P(o).toVar(),c=P(0).toVar(),l=b(1).toVar();return Ve(r,()=>{c.addAssign(l.mul(jf(a))),l.mulAssign(i),a.mulAssign(s)}),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"}]}),r2=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=R(e).toVar(),a=P(o).toVar();return O(z_(a,r,s,i),z_(a.add(P(R(19),R(193),R(17))),r,s,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"}]}),o2=I(([o,e,t,n])=>{let i=b(n).toVar(),s=b(t).toVar(),r=R(e).toVar(),a=P(o).toVar(),c=P(Wy(a,r,s,i)).toVar(),l=b(z_(a.add(P(R(19),R(193),R(17))),r,s,i)).toVar();return Y(c,l)}).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"}]}),a2=I(([o,e,t,n,i,s,r])=>{let a=R(r).toVar(),c=b(s).toVar(),l=R(i).toVar(),u=R(n).toVar(),h=R(t).toVar(),d=R(e).toVar(),f=O(o).toVar(),p=P(Hy(O(d.add(u),h.add(l)))).toVar(),m=O(p.x,p.y).toVar();m.subAssign(.5),m.mulAssign(c),m.addAssign(.5);let _=O(O(b(d),b(h)).add(m)).toVar(),y=O(_.sub(f)).toVar();return ne(a.equal(R(2)),()=>Ye(y.x).add(Ye(y.y))),ne(a.equal(R(3)),()=>mt(Ye(y.x),Ye(y.y))),uo(y,y)}).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"}]}),c2=I(([o,e,t,n,i,s,r,a,c])=>{let l=R(c).toVar(),u=b(a).toVar(),h=R(r).toVar(),d=R(s).toVar(),f=R(i).toVar(),p=R(n).toVar(),m=R(t).toVar(),_=R(e).toVar(),y=P(o).toVar(),x=P(Hy(P(_.add(f),m.add(d),p.add(h)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);let v=P(P(b(_),b(m),b(p)).add(x)).toVar(),T=P(v.sub(y)).toVar();return ne(l.equal(R(2)),()=>Ye(T.x).add(Ye(T.y)).add(Ye(T.z))),ne(l.equal(R(3)),()=>mt(Ye(T.x),Ye(T.y),Ye(T.z))),uo(T,T)}).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"}]}),Gu=en([a2,c2]),l2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=O(o).toVar(),r=R().toVar(),a=R().toVar(),c=O(it(s.x,r),it(s.y,a)).toVar(),l=b(1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:u})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:h})=>{let d=b(Gu(c,u,h,r,a,i,n)).toVar();l.assign(Ln(l,d))})}),ne(n.equal(R(0)),()=>{l.assign(bs(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),u2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=O(o).toVar(),r=R().toVar(),a=R().toVar(),c=O(it(s.x,r),it(s.y,a)).toVar(),l=O(1e6,1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:u})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:h})=>{let d=b(Gu(c,u,h,r,a,i,n)).toVar();ne(d.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.y.assign(d)})})}),ne(n.equal(R(0)),()=>{l.assign(bs(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),h2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=O(o).toVar(),r=R().toVar(),a=R().toVar(),c=O(it(s.x,r),it(s.y,a)).toVar(),l=P(1e6,1e6,1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:u})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:h})=>{let d=b(Gu(c,u,h,r,a,i,n)).toVar();ne(d.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(d)}).ElseIf(d.lessThan(l.z),()=>{l.z.assign(d)})})}),ne(n.equal(R(0)),()=>{l.assign(bs(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),d2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=P(o).toVar(),r=R().toVar(),a=R().toVar(),c=R().toVar(),l=P(it(s.x,r),it(s.y,a),it(s.z,c)).toVar(),u=b(1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:h})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:d})=>{Ve({start:-1,end:R(1),name:"z",condition:"<="},({z:f})=>{let p=b(Gu(l,h,d,f,r,a,c,i,n)).toVar();u.assign(Ln(u,p))})})}),ne(n.equal(R(0)),()=>{u.assign(bs(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),f2=en([l2,d2]),p2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=P(o).toVar(),r=R().toVar(),a=R().toVar(),c=R().toVar(),l=P(it(s.x,r),it(s.y,a),it(s.z,c)).toVar(),u=O(1e6,1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:h})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:d})=>{Ve({start:-1,end:R(1),name:"z",condition:"<="},({z:f})=>{let p=b(Gu(l,h,d,f,r,a,c,i,n)).toVar();ne(p.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.y.assign(p)})})})}),ne(n.equal(R(0)),()=>{u.assign(bs(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),m2=en([u2,p2]),g2=I(([o,e,t])=>{let n=R(t).toVar(),i=b(e).toVar(),s=P(o).toVar(),r=R().toVar(),a=R().toVar(),c=R().toVar(),l=P(it(s.x,r),it(s.y,a),it(s.z,c)).toVar(),u=P(1e6,1e6,1e6).toVar();return Ve({start:-1,end:R(1),name:"x",condition:"<="},({x:h})=>{Ve({start:-1,end:R(1),name:"y",condition:"<="},({y:d})=>{Ve({start:-1,end:R(1),name:"z",condition:"<="},({z:f})=>{let p=b(Gu(l,h,d,f,r,a,c,i,n)).toVar();ne(p.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(p)}).ElseIf(p.lessThan(u.z),()=>{u.z.assign(p)})})})}),ne(n.equal(R(0)),()=>{u.assign(bs(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FS=en([h2,g2]),_2=I(([o,e,t,n,i,s,r,a,c,l,u])=>{let h=R(o).toVar(),d=O(e).toVar(),f=O(t).toVar(),p=O(n).toVar(),m=b(i).toVar(),_=b(s).toVar(),y=b(r).toVar(),x=Ti(a).toVar(),v=R(c).toVar(),T=b(l).toVar(),M=b(u).toVar(),w=d.mul(f).add(p),E=b(0).toVar();return ne(h.equal(R(0)),()=>{E.assign(jf(w))}),ne(h.equal(R(1)),()=>{E.assign(Hy(w))}),ne(h.equal(R(2)),()=>{E.assign(FS(w,m,R(0)))}),ne(h.equal(R(3)),()=>{E.assign(Wy(P(w,0),v,T,M))}),E.assign(E.mul(y.sub(_)).add(_)),ne(x,()=>{E.assign(bi(E,_,y))}),E}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),y2=I(([o,e,t,n,i,s,r,a,c,l,u])=>{let h=R(o).toVar(),d=P(e).toVar(),f=P(t).toVar(),p=P(n).toVar(),m=b(i).toVar(),_=b(s).toVar(),y=b(r).toVar(),x=Ti(a).toVar(),v=R(c).toVar(),T=b(l).toVar(),M=b(u).toVar(),w=d.mul(f).add(p),E=b(0).toVar();return ne(h.equal(R(0)),()=>{E.assign(jf(w))}),ne(h.equal(R(1)),()=>{E.assign(Hy(w))}),ne(h.equal(R(2)),()=>{E.assign(FS(w,m,R(0)))}),ne(h.equal(R(3)),()=>{E.assign(Wy(w,v,T,M))}),E.assign(E.mul(y.sub(_)).add(_)),ne(x,()=>{E.assign(bi(E,_,y))}),E}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),x2=I(([o])=>{let e=o.y,t=o.z,n=P().toVar();return ne(e.lessThan(1e-4),()=>{n.assign(P(t,t,t))}).Else(()=>{let i=o.x;i=i.sub(ps(i)).mul(6).toVar();let s=R(Ob(i)),r=i.sub(b(s)),a=t.mul(e.oneMinus()),c=t.mul(e.mul(r).oneMinus()),l=t.mul(e.mul(r.oneMinus()).oneMinus());ne(s.equal(R(0)),()=>{n.assign(P(t,l,a))}).ElseIf(s.equal(R(1)),()=>{n.assign(P(c,t,a))}).ElseIf(s.equal(R(2)),()=>{n.assign(P(a,t,l))}).ElseIf(s.equal(R(3)),()=>{n.assign(P(a,c,t))}).ElseIf(s.equal(R(4)),()=>{n.assign(P(l,a,t))}).Else(()=>{n.assign(P(t,a,c))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),v2=I(([o])=>{let e=P(o).toVar(),t=b(e.x).toVar(),n=b(e.y).toVar(),i=b(e.z).toVar(),s=b(Ln(t,Ln(n,i))).toVar(),r=b(mt(t,mt(n,i))).toVar(),a=b(r.sub(s)).toVar(),c=b().toVar(),l=b().toVar(),u=b().toVar();return u.assign(r),ne(r.greaterThan(0),()=>{l.assign(a.div(r))}).Else(()=>{l.assign(0)}),ne(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{ne(t.greaterThanEqual(r),()=>{c.assign(n.sub(i).div(a))}).ElseIf(n.greaterThanEqual(r),()=>{c.assign(Et(2,i.sub(t).div(a)))}).Else(()=>{c.assign(Et(4,t.sub(n).div(a)))}),c.mulAssign(1/6),ne(c.lessThan(0),()=>{c.addAssign(1)})}),P(c,l,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),T2=I(([o])=>{let e=P(o).toVar(),t=Sb(Ib(e,P(.04045))).toVar(),n=P(e.div(12.92)).toVar(),i=P(yi(mt(e.add(P(.055)),P(0)).div(1.055),P(2.4))).toVar();return Ne(n,i,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),t1=(o,e)=>{o=b(o),e=b(e);let t=O(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Si(o.sub(t),o.add(t),e)},n1=(o,e,t,n)=>Ne(o,e,t[n].clamp()),b2=(o,e,t=ze())=>n1(o,e,t,"x"),S2=(o,e,t=ze())=>n1(o,e,t,"y"),M2=(o,e,t,n,i=ze())=>{let s=i.x.clamp(),r=i.y.clamp(),a=Ne(o,e,s),c=Ne(t,n,s);return Ne(a,c,r)},i1=(o,e,t,n,i)=>Ne(o,e,t1(t,n[i])),A2=(o,e,t,n=ze())=>i1(o,e,t,n,"x"),E2=(o,e,t,n=ze())=>i1(o,e,t,n,"y"),w2=(o=1,e=0,t=ze())=>t.mul(o).add(e),R2=(o,e=1)=>(o=b(o),o.abs().pow(e).mul(o.sign())),C2=(o,e=1,t=.5)=>b(o).sub(t).mul(e).add(t),N2=(o=ze(),e=1,t=0)=>DS(o.convert("vec2|vec3")).mul(e).add(t),P2=(o=ze(),e=1,t=0)=>jf(o.convert("vec2|vec3")).mul(e).add(t),I2=(o=ze(),e=1,t=0)=>(o=o.convert("vec2|vec3"),Y(jf(o),DS(o.add(O(19,73)))).mul(e).add(t)),L2=(o,e=ze(),t=O(1,1),n=O(0,0),i=1,s=0,r=1,a=!1,c=1,l=2,u=.5)=>_2(o,e.convert("vec2|vec3"),t,n,i,s,r,a,c,l,u),D2=(o,e=ze(),t=O(1,1),n=O(0,0),i=1,s=0,r=1,a=!1,c=1,l=2,u=.5)=>y2(o,e.convert("vec2|vec3"),t,n,i,s,r,a,c,l,u),F2=(o=ze(),e=1)=>f2(o.convert("vec2|vec3"),e,R(1)),U2=(o=ze(),e=1)=>m2(o.convert("vec2|vec3"),e,R(1)),B2=(o=ze(),e=1)=>FS(o.convert("vec2|vec3"),e,R(1)),O2=(o=ze())=>e2(o.convert("vec2|vec3")),V2=(o=ze(),e=3,t=2,n=.5,i=1)=>z_(o,R(e),t,n).mul(i),G2=(o=ze(),e=3,t=2,n=.5,i=1)=>r2(o,R(e),t,n).mul(i),k2=(o=ze(),e=3,t=2,n=.5,i=1)=>Wy(o,R(e),t,n).mul(i),z2=(o=ze(),e=3,t=2,n=.5,i=1)=>o2(o,R(e),t,n).mul(i),H2=(o,e=b(0))=>Et(o,e),W2=(o,e=b(0))=>Se(o,e),X2=(o,e=b(1))=>de(o,e),q2=(o,e=b(1))=>Zn(o,e),$2=(o,e=b(1))=>kf(o,e),Y2=(o,e=b(1))=>yi(o,e),K2=(o=b(0),e=b(1))=>Ny(o,e),j2=()=>Vu,Z2=()=>pN,J2=(o,e=b(1))=>Se(e,o),Q2=(o,e,t,n)=>o.greaterThan(e).mix(t,n),eO=(o,e,t,n)=>o.greaterThanEqual(e).mix(t,n),tO=(o,e,t,n)=>o.equal(e).mix(t,n),nO=(o,e=null)=>{if(typeof e=="string"){let t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},n=e.replace(/^out/,"").toLowerCase();if(t[n]!==void 0)return o.element(t[n])}if(typeof e=="number")return o.element(e);if(typeof e=="string"&&e.length===1){let t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return o.element(t[e])}return o},iO=(o,e=O(.5,.5),t=O(1,1),n=b(0),i=O(0,0))=>{let s=o;if(e&&(s=s.sub(e)),t&&(s=s.mul(t)),n){let r=n.mul(Math.PI/180),a=r.cos(),c=r.sin();s=O(s.x.mul(a).sub(s.y.mul(c)),s.x.mul(c).add(s.y.mul(a)))}return e&&(s=s.add(e)),i&&(s=s.add(i)),s},sO=(o,e)=>{o=O(o),e=b(e);let t=e.mul(Math.PI/180);return $f(o,t)},rO=(o,e,t)=>{o=P(o),e=b(e),t=P(t);let n=e.mul(Math.PI/180),i=t.normalize(),s=n.cos(),r=n.sin(),a=b(1).sub(s);return o.mul(s).add(i.cross(o).mul(r)).add(i.mul(i.dot(o)).mul(a))},oO=(o,e)=>(o=P(o),e=b(e),iS(o,e)),aO=I(([o,e,t])=>{let n=hr(o).toVar(),i=Se(b(.5).mul(e.sub(t)),jn).div(n).toVar(),s=Se(b(-.5).mul(e.sub(t)),jn).div(n).toVar(),r=P().toVar();r.x=n.x.greaterThan(b(0)).select(i.x,s.x),r.y=n.y.greaterThan(b(0)).select(i.y,s.y),r.z=n.z.greaterThan(b(0)).select(i.z,s.z);let a=Ln(r.x,r.y,r.z).toVar();return jn.add(n.mul(a)).toVar().sub(t)}),s1=I(([o,e])=>{let t=o.x,n=o.y,i=o.z,s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(i)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(i)),s=s.add(e.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(8).mul(.429043).mul(de(t,t).sub(de(n,n)))),s}),g=Object.freeze({__proto__:null,BRDF_GGX:x0,BRDF_Lambert:Pc,BasicPointShadowFilter:qN,BasicShadowFilter:VN,Break:BC,Const:_R,Continue:FL,DFGApprox:yS,D_GGX:QC,Discard:PR,EPSILON:Gw,F_Schlick:Nu,Fn:I,INFINITY:OI,If:ne,Loop:Ve,NodeAccess:qt,NodeShaderStage:pu,NodeType:iw,NodeUpdateType:me,OnMaterialUpdate:qF,OnObjectUpdate:XF,PCFShadowFilter:GN,PCFSoftShadowFilter:kN,PI:xg,PI2:VI,PointShadowFilter:$N,Return:qI,Schlick_to_F0:tN,ScriptableNodeResources:og,ShaderNode:mu,Stack:Sy,Switch:PI,TBNViewMatrix:xc,VSMShadowFilter:zN,V_GGX_SmithCorrelated:JC,Var:gR,VarIntent:yR,abs:Ye,acesFilmicToneMapping:EN,acos:Fb,add:Et,addMethodChaining:F,addNodeElement:$I,agxToneMapping:wN,all:kw,alphaT:pg,and:Aw,anisotropy:Jr,anisotropyB:Sc,anisotropyT:qd,any:zw,append:FI,array:yw,arrayBuffer:LI,asin:qw,assign:xw,atan:Ny,atan2:fR,atomicAdd:FU,atomicAnd:VU,atomicFunc:Ms,atomicLoad:LU,atomicMax:BU,atomicMin:OU,atomicOr:GU,atomicStore:DU,atomicSub:UU,atomicXor:kU,attenuationColor:Rb,attenuationDistance:wb,attribute:Sn,attributeArray:$F,backgroundBlurriness:yN,backgroundIntensity:K0,backgroundRotation:xN,batch:FC,bentNormalView:rC,billboarding:LF,bitAnd:Cw,bitNot:Nw,bitOr:Pw,bitXor:Iw,bitangentGeometry:bL,bitangentLocal:SL,bitangentView:iC,bitangentWorld:ML,bitcast:pF,blendBurn:zC,blendColor:qL,blendDodge:HC,blendOverlay:XC,blendScreen:WC,blur:aN,bool:Ti,buffer:Wf,bufferAttribute:Hf,builtin:gr,bumpMap:iS,burn:YL,bvec2:lw,bvec3:Sb,bvec4:fw,bypass:RR,cache:Yd,call:vw,cameraFar:ar,cameraIndex:ho,cameraNear:or,cameraNormalMatrix:nL,cameraPosition:Kd,cameraProjectionMatrix:_i,cameraProjectionMatrixInverse:eL,cameraViewMatrix:ei,cameraViewport:iL,cameraWorldMatrix:tL,cbrt:cR,cdl:sU,ceil:Cy,checker:AB,cineonToneMapping:AN,clamp:bi,clearcoat:fg,clearcoatNormalView:yc,clearcoatRoughness:hf,code:Gy,color:aw,colorSpaceToWorking:Ly,colorToDirection:tD,compute:wR,computeKernel:$b,computeSkinning:DL,context:zf,convert:mw,convertColorSpace:HI,convertToTexture:kF,cos:sr,cross:Iy,cubeTexture:wu,cubeTextureBase:nS,cubeToUV:$i,dFdx:Ub,dFdy:Bb,dashSize:Mc,debug:IR,decrement:Ow,decrementBefore:Uw,defaultBuildStages:cg,defaultShaderStages:xb,defined:cf,degrees:Ww,deltaTime:EF,densityFog:TU,densityFogFactor:AS,depth:mS,depthPass:cU,determinant:Qw,difference:sR,diffuseColor:Fe,directPointLight:KN,directionToColor:YC,directionToFaceDirection:Ou,dispersion:Cb,distance:iR,div:Zn,dodge:KL,dot:uo,drawIndex:LC,dynamicBufferAttribute:ER,element:pw,emissive:i0,equal:Pb,equals:tR,equirectUV:gS,exp:Lb,exp2:Su,expression:dr,faceDirection:Qb,faceForward:Hb,faceforward:GI,float:b,floatBitsToInt:mF,floatBitsToUint:gF,floor:ps,fog:Pf,fract:mr,frameGroup:_w,frameId:pN,frontFacing:VR,fwidth:Zw,gain:vF,gapSize:ff,getConstNodeType:ow,getCurrentStack:by,getDirection:rN,getDistanceAttenuation:LS,getGeometryRoughness:ZC,getNormalFromDepth:HF,getParallaxCorrectNormal:aO,getRoughness:_S,getScreenPosition:zF,getShIrradianceAt:s1,getShadowMaterial:HN,getShadowRenderObjectFunction:WN,getTextureIndex:dN,getViewPosition:fu,globalId:AU,glsl:gU,glslFn:_U,grayscale:eU,greaterThan:Ib,greaterThanEqual:Mw,hash:xF,highpModelNormalViewMatrix:l0,highpModelViewMatrix:c0,hue:iU,increment:Bw,incrementBefore:Fw,instance:PL,instanceIndex:no,instancedArray:YF,instancedBufferAttribute:Eg,instancedDynamicBufferAttribute:r0,instancedMesh:DC,int:R,intBitsToFloat:_F,inverse:eR,inverseSqrt:Db,inversesqrt:kI,invocationLocalIndex:NL,invocationSubgroupIndex:CL,ior:$d,iridescence:Ey,iridescenceIOR:Mb,iridescenceThickness:Ab,ivec2:kt,ivec3:uw,ivec4:hw,js:pU,label:mR,length:ms,lengthSq:Gb,lessThan:bw,lessThanEqual:Sw,lightPosition:wS,lightProjectionUV:PN,lightShadowMatrix:zy,lightTargetDirection:CS,lightTargetPosition:IN,lightViewPosition:RS,lightingContext:VC,lights:mB,linearDepth:Ru,linearToneMapping:SN,localId:EU,log:Ry,log2:fs,logarithmicDepthToViewZ:VL,luminance:SS,mat2:My,mat3:dn,mat4:bc,matcapUV:lN,materialAO:PC,materialAlphaTest:oC,materialAnisotropy:vC,materialAnisotropyVector:du,materialAttenuationColor:RC,materialAttenuationDistance:wC,materialClearcoat:pC,materialClearcoatNormal:gC,materialClearcoatRoughness:mC,materialColor:kg,materialDispersion:NC,materialEmissive:cC,materialEnvIntensity:tg,materialEnvRotation:tS,materialIOR:EC,materialIridescence:TC,materialIridescenceIOR:bC,materialIridescenceThickness:SC,materialLightMap:cS,materialLineDashOffset:aS,materialLineDashSize:rS,materialLineGapSize:oS,materialLineScale:sS,materialLineWidth:ig,materialMetalness:dC,materialNormal:fC,materialOpacity:Oy,materialPointSize:CC,materialReference:cr,materialReflectivity:ng,materialRefractionRatio:HR,materialRotation:_C,materialRoughness:hC,materialSheen:yC,materialSheenRoughness:xC,materialShininess:aC,materialSpecular:lC,materialSpecularColor:uC,materialSpecularIntensity:m0,materialSpecularStrength:jd,materialThickness:AC,materialTransmission:MC,max:mt,maxMipLevel:Kb,mediumpModelViewMatrix:OR,metalness:uf,min:Ln,mix:Ne,mixElement:uR,mod:kf,modInt:Vw,modelDirection:lL,modelNormalMatrix:BR,modelPosition:uL,modelRadius:UR,modelScale:hL,modelViewMatrix:fr,modelViewPosition:dL,modelViewProjection:lS,modelWorldMatrix:xi,modelWorldMatrixInverse:fL,morphReference:OC,mrt:fN,mul:de,mx_aastep:t1,mx_add:H2,mx_atan2:K2,mx_cell_noise_float:O2,mx_contrast:C2,mx_divide:q2,mx_fractal_noise_float:V2,mx_fractal_noise_vec2:G2,mx_fractal_noise_vec3:k2,mx_fractal_noise_vec4:z2,mx_frame:Z2,mx_heighttonormal:oO,mx_hsvtorgb:x2,mx_ifequal:tO,mx_ifgreater:Q2,mx_ifgreatereq:eO,mx_invert:J2,mx_modulo:$2,mx_multiply:X2,mx_noise_float:N2,mx_noise_vec3:P2,mx_noise_vec4:I2,mx_place2d:iO,mx_power:Y2,mx_ramp4:M2,mx_ramplr:b2,mx_ramptb:S2,mx_rgbtohsv:v2,mx_rotate2d:sO,mx_rotate3d:rO,mx_safepower:R2,mx_separate:nO,mx_splitlr:A2,mx_splittb:E2,mx_srgb_texture_to_lin_rec709:T2,mx_subtract:W2,mx_timer:j2,mx_transform_uv:w2,mx_unifiednoise2d:L2,mx_unifiednoise3d:D2,mx_worley_noise_float:F2,mx_worley_noise_vec2:U2,mx_worley_noise_vec3:B2,negate:$w,neutralToneMapping:RN,nodeArray:Tc,nodeImmutable:z,nodeObject:U,nodeObjectIntent:Wd,nodeObjects:Ty,nodeProxy:ue,nodeProxyIntent:k,normalFlat:GR,normalGeometry:Dy,normalLocal:Dn,normalMap:p0,normalView:Oe,normalViewGeometry:Eu,normalWorld:fo,normalWorldGeometry:kR,normalize:hr,not:ww,notEqual:Tw,numWorkgroups:SU,objectDirection:sL,objectGroup:Nb,objectPosition:FR,objectRadius:cL,objectScale:oL,objectViewPosition:aL,objectWorldMatrix:rL,oneMinus:Yw,or:Ew,orthographicDepthToViewZ:OL,oscSawtooth:NF,oscSine:wF,oscSquare:RF,oscTriangle:CF,output:yu,outputStruct:fF,overlay:ZL,overloadingFn:en,parabola:X0,parallaxDirection:sC,parallaxUV:AL,parameter:uF,pass:oU,passTexture:aU,pcurve:TF,perspectiveDepthToViewZ:fS,pmremTexture:bS,pointShadow:YN,pointUV:KF,pointWidth:UI,positionGeometry:Qt,positionLocal:vt,positionPrevious:Fg,positionView:Tt,positionViewDirection:Qe,positionWorld:jn,positionWorldDirection:Jb,posterize:rU,pow:yi,pow2:Vb,pow3:rR,pow4:oR,premultiplyAlpha:qC,property:Yi,quadBroadcast:dB,quadSwapDiagonal:oB,quadSwapX:sB,quadSwapY:rB,radians:Hw,rand:lR,range:bU,rangeFog:vU,rangeFogFactor:MS,reciprocal:jw,reference:Xe,referenceBuffer:h0,reflect:nR,reflectVector:qR,reflectView:WR,reflector:OF,refract:zb,refractVector:$R,refractView:XR,reinhardToneMapping:MN,remap:CR,remapClamp:NR,renderGroup:te,renderOutput:Yb,rendererReference:SR,rotate:$f,rotateUV:PF,roughness:ds,round:Kw,rtt:gN,sRGBTransferEOTF:vR,sRGBTransferOETF:TR,sample:WF,sampler:jI,samplerComparison:ZI,saturate:kb,saturation:tU,screen:jL,screenCoordinate:Xf,screenDPR:LR,screenSize:Rc,screenUV:ur,scriptable:xU,scriptableValue:rg,select:$t,setCurrentStack:lf,setName:Wb,shaderStages:lg,shadow:XN,shadowPositionWorld:NS,shapeCircle:EB,sharedUniformGroup:wy,sheen:_c,sheenRoughness:Ay,shiftLeft:Lw,shiftRight:Dw,shininess:mg,sign:gf,sin:Kn,sinc:bF,skinning:UC,smoothstep:Si,smoothstepElement:hR,specularColor:In,specularF90:df,spherizeUV:IF,split:DI,spritesheetUV:FF,sqrt:bs,stack:sg,step:Py,stepElement:dR,storage:wc,storageBarrier:CU,storageObject:LL,storageTexture:vN,string:II,struct:dF,sub:Se,subBuild:xu,subgroupAdd:WU,subgroupAll:tB,subgroupAnd:jU,subgroupAny:nB,subgroupBallot:HU,subgroupBroadcast:aB,subgroupBroadcastFirst:iB,subgroupElect:zU,subgroupExclusiveAdd:qU,subgroupExclusiveMul:KU,subgroupInclusiveAdd:XU,subgroupInclusiveMul:YU,subgroupIndex:RL,subgroupMax:eB,subgroupMin:QU,subgroupMul:$U,subgroupOr:ZU,subgroupShuffle:cB,subgroupShuffleDown:hB,subgroupShuffleUp:uB,subgroupShuffleXor:lB,subgroupSize:wU,subgroupXor:JU,tan:Xw,tangentGeometry:Fy,tangentLocal:qf,tangentView:Uy,tangentWorld:nC,texture:Te,texture3D:TN,textureBarrier:NU,textureBicubic:yD,textureBicubicLevel:xS,textureCubeUV:oN,textureLoad:xt,textureSize:to,textureStore:jF,thickness:Eb,time:Vu,toneMapping:MR,toneMappingExposure:AR,toonOutlinePass:lU,transformDirection:aR,transformNormal:zR,transformNormalToView:eS,transformedClearcoatNormalView:gL,transformedNormalView:pL,transformedNormalWorld:mL,transmission:gg,transpose:Jw,triNoise3D:MF,triplanarTexture:UF,triplanarTextures:mN,trunc:Ob,uint:$,uintBitsToFloat:yF,uniform:se,uniformArray:un,uniformCubeTexture:_L,uniformFlow:pR,uniformGroup:gw,uniformTexture:KI,unpremultiplyAlpha:$L,userData:JF,uv:ze,uvec2:cw,uvec3:Bu,uvec4:dw,varying:Ss,varyingProperty:$n,vec2:O,vec3:P,vec4:Y,vectorComponents:lo,velocity:QF,vertexColor:kC,vertexIndex:IC,vertexStage:xR,vibrance:nU,viewZToLogarithmicDepth:pS,viewZToOrthographicDepth:Tu,viewZToPerspectiveDepth:dS,viewport:vu,viewportCoordinate:DR,viewportDepthTexture:hS,viewportLinearDepth:GL,viewportMipTexture:uS,viewportResolution:QI,viewportSafeUV:DF,viewportSharedTexture:$C,viewportSize:Zb,viewportTexture:BL,viewportUV:JI,wgsl:mU,wgslFn:yU,workgroupArray:PU,workgroupBarrier:RU,workgroupId:MU,workingToColorSpace:bR,xor:Rw}),qi=new Ef,iT=class extends xs{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,r=!1;if(s===null)i._clearColor.getRGB(qi),qi.a=i._clearColor.a;else if(s.isColor===!0)s.getRGB(qi),qi.a=1,r=!0;else if(s.isNode===!0){let c=this.get(e),l=s;qi.copy(i._clearColor);let u=c.backgroundMesh;if(u===void 0){let m=function(){s.removeEventListener("dispose",m),u.material.dispose(),u.geometry.dispose()},d=zf(Y(l).mul(K0),{getUV:()=>xN.mul(kR),getTextureLevel:()=>yN}),f=lS;f=f.setZ(f.w);let p=new qe;p.name="Background.material",p.side=Nt,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=f,p.colorNode=d,c.backgroundMeshNode=d,c.backgroundMesh=u=new Ze(new Or(1,32,32),p),u.frustumCulled=!1,u.name="Background.mesh",u.onBeforeRender=function(_,y,x){this.matrixWorld.copyPosition(x.matrixWorld)},s.addEventListener("dispose",m)}let h=l.getCacheKey();c.backgroundCacheKey!==h&&(c.backgroundMeshNode.node=Y(l).mul(K0),c.backgroundMeshNode.needsUpdate=!0,u.material.needsUpdate=!0,c.backgroundCacheKey=h),t.unshift(u,u.geometry,u.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);let a=i.xr.getEnvironmentBlendMode();if(a==="additive"?qi.set(0,0,0,1):a==="alpha-blend"&&qi.set(0,0,0,0),i.autoClear===!0||r===!0){let c=n.clearColorValue;c.r=qi.r,c.g=qi.g,c.b=qi.b,c.a=qi.a,(i.backend.isWebGLBackend===!0||i.alpha===!0)&&(c.r*=c.a,c.g*=c.a,c.b*=c.a),n.depthClearValue=i._clearDepth,n.stencilClearValue=i._clearStencil,n.clearColor=i.autoClearColor===!0,n.clearDepth=i.autoClearDepth===!0,n.clearStencil=i.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},cO=0,Lf=class{constructor(e="",t=[],n=0,i=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=i,this.id=cO++}},sT=class{constructor(e,t,n,i,s,r,a,c,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=i,this.bindings=s,this.updateNodes=r,this.updateBeforeNodes=a,this.updateAfterNodes=c,this.observer=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let i=new Lf(t.name,[],t.index,t.bindingsReference);e.push(i);for(let s of t.bindings)i.bindings.push(s.clone())}else e.push(t);return e}},Df=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},H_=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}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}},Ff=class{constructor(e,t,n=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=i}},W_=class extends Ff{constructor(e,t,n=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=i}},X_=class{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}},lO=0,bu=class{constructor(e=null){this.id=lO++,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)}},rT=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},Ts=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}},oT=class extends Ts{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},aT=class extends Ts{constructor(e,t=new B){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},cT=class extends Ts{constructor(e,t=new S){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},lT=class extends Ts{constructor(e,t=new ge){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},uT=class extends Ts{constructor(e,t=new q){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},hT=class extends Ts{constructor(e,t=new ga){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},dT=class extends Ts{constructor(e,t=new pe){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},fT=class extends Ts{constructor(e,t=new ee){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},pT=class extends oT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},mT=class extends aT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},gT=class extends cT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},_T=class extends lT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},yT=class extends uT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},xT=class extends hT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},vT=class extends dT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},TT=class extends fT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},PE=new WeakMap,uO=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Ym=o=>/e/g.test(o)?String(o).replace(/\+/g,""):(o=Number(o),o+(o%1?"":".0")),Uf=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.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=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.types={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.declarations={},this.flow={code:""},this.chaining=[],this.stack=sg(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new bu,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=PE.get(this.renderer);return e===void 0&&(e=new Qn,PE.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new yn(e,t,n)}createCubeRenderTarget(e,t){return new i_(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){let n=this.getBindGroupsCache(),i=[],s=!0;for(let a of t)i.push(a),s=s&&a.groupNode.shared!==!0;let r;return s?(r=n.get(i),r===void 0&&(r=new Lf(e,i,this.bindingsIndexes[e].group,i),n.set(i,r))):r=new Lf(e,i,this.bindingsIndexes[e].group,i),r}getBindGroupArray(e,t){let n=this.bindings[t],i=n[e];return i===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let i of lg)for(let s in n[i]){let r=n[i][s];(t[s]||(t[s]=[])).push(...r)}e=[];for(let i in t){let s=t[i],r=this._getBindGroup(i,s);e.push(r)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Ym(t.r)}, ${Ym(t.g)}, ${Ym(t.b)} )`;let n=this.getTypeLength(e),i=this.getComponentType(e),s=r=>this.generateConst(i,r);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new 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 s of n)if(s.name===e)return s;let i=new Df(e,t);return this.registerDeclaration(i),n.push(i),i}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==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===Vt)return"int";if(t===Je)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=pb(e),i=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),i+n}getTypeFromArray(e){return uO.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,i=e.itemSize,s=e.normalized,r;return!(e instanceof Vo)&&s!==!0&&(r=this.getTypeFromArray(n)),this.getTypeFromLength(i,r)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):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}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(){this.stack=sg(this.stack);let e=by();return this.stacks.push(e),lf(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,lf(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let i=n.getData(e);i===void 0&&(i={},n.setData(e,i)),i[t]===void 0&&(i[t]={});let s=i[t],r=i.any?i.any.subBuilds:null,a=this.getClosestSubBuild(r);return a&&(s.subBuildsCache===void 0&&(s.subBuildsCache={}),s=s.subBuildsCache[a]||(s.subBuildsCache[a]={}),s.subBuilds=r),s}getNodeProperties(e,t="any"){let n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){let n=this.getDataFromNode(e),i=n.bufferAttribute;if(i===void 0){let s=this.uniforms.index++;i=new Df("nodeAttribute"+s,t,e),this.bufferAttributes.push(i),n.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,i=this.shaderStage){let s=this.getDataFromNode(e,i,this.globalCache),r=s.structType;if(r===void 0){let a=this.structs.index++;n===null&&(n="StructType"+a),r=new rT(n,t),this.structs[i].push(r),this.types[i][n]=e,s.structType=r}return r}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,i=null){let s=this.getDataFromNode(e,n,this.globalCache),r=s.uniform;if(r===void 0){let a=this.uniforms.index++;r=new H_(i||"nodeUniform"+a,t,e),this.uniforms[n].push(r),this.registerDeclaration(r),s.uniform=r}return r}getVarFromNode(e,t=null,n=e.getNodeType(this),i=this.shaderStage,s=!1){let r=this.getDataFromNode(e,i),a=this.getSubBuildProperty("variable",r.subBuilds),c=r[a];if(c===void 0){let l=s?"_const":"_var",u=this.vars[i]||(this.vars[i]=[]),h=this.vars[l]||(this.vars[l]=0);t===null&&(t=(s?"nodeConst":"nodeVar")+h,this.vars[l]++),a!=="variable"&&(t=this.getSubBuildProperty(t,r.subBuilds));let d=e.getArrayCount(this);c=new Ff(t,n,s,d),s||u.push(c),this.registerDeclaration(c),r[a]=c}return c}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),i=null,s=null){let r=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",r.subBuilds),c=r[a];if(c===void 0){let l=this.varyings,u=l.length;t===null&&(t="nodeVarying"+u),a!=="varying"&&(t=this.getSubBuildProperty(t,r.subBuilds)),c=new W_(t,n,i,s),l.push(c),this.registerDeclaration(c),r[a]=c}return c}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),i=this.getPropertyName(e),s=1,r=i;for(;n[r]!==void 0;)r=i+"_"+s++;s>1&&(e.name=r,console.warn(`THREE.TSL: Declaration name '${i}' of '${e.type}' already in use. Renamed to '${r}'.`)),n[r]=e}getCodeFromNode(e,t,n=this.shaderStage){let i=this.getDataFromNode(e),s=i.code;if(s===void 0){let r=this.codes[n]||(this.codes[n]=[]),a=r.length;s=new X_("nodeCode"+a,t),r.push(s),i.code=s}return s}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:i}=this.getDataFromNode(e),s=!0,r=t;for(;r;){if(i.get(r)===!0){s=!1;break}r=this.getDataFromNode(r).parentNodeBlock}if(s)for(let a of n)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,n){let i=this.getDataFromNode(e),s=i.flowCodes||(i.flowCodes=[]),r=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);s.push(t),r.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=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}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=new Nf,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 r=0,a=Object.values(this);return{next:()=>({value:a[r],done:r++>=a.length})}}};for(let r of t.inputs)n[r.name]=new wf(r.type,r.name);e.layout=null;let i=e.call(n),s=this.flowStagesNode(i,t.type);return e.layout=t,s}flowBuildStage(e,t,n=null){let i=this.getBuildStage();this.setBuildStage(t);let s=e.build(this,n);return this.setBuildStage(i),s}flowStagesNode(e,t=null){let n=this.flow,i=this.vars,s=this.declarations,r=this.cache,a=this.buildStage,c=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new bu,this.stack=sg();for(let u of cg)this.setBuildStage(u),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=i,this.declarations=s,this.cache=r,this.stack=c,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){let n=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=n,i}flowNodeFromShaderStage(e,t,n=null,i=null){let s=this.tab,r=this.cache,a=this.shaderStage,c=this.context;this.setShaderStage(e);let l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=l;let u=null;if(this.buildStage==="generate"){let h=this.flowChildNode(t,n);i!==null&&(h.code+=`${this.tab+i} = ${h.result}; `),this.flowCode[e]=this.flowCode[e]+h.code,u=h}else u=t.build(this);return this.setShaderStage(a),this.cache=r,this.tab=s,this.context=c,u}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="",n=this.vars[e];if(n!==void 0)for(let i of n)t+=`${this.getVar(i.type,i.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){let t=this.codes[e],n="";if(t!==void 0)for(let i of t)n+=i.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.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;let n=this.subBuildLayers;for(let i=t.length-1;i>=0;i--){let s=t[i];if(n.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let i;return n?i=e?n+"_"+e:n:i=e,i}build(){let{object:e,material:t,renderer:n}=this;if(t!==null){let i=n.library.fromMaterial(t);i===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),i=new qe),i.build(this)}else this.addFlow("compute",e);for(let i of cg){this.setBuildStage(i),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(let s of lg){this.setShaderStage(s);let r=this.flowNodes[s];for(let a of r)i==="generate"?this.flowNode(a):a.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 pT(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new mT(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new gT(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new _T(e);if(t==="color")return new yT(e);if(t==="mat2")return new xT(e);if(t==="mat3")return new vT(e);if(t==="mat4")return new TT(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let i=this.getTypeLength(t),s=this.getTypeLength(n);return i===16&&s===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:i===9&&s===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:i>4||s>4||s===0?e:i===s?`${this.getType(n)}( ${e} )`:i>s?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),n)):s===4&&i>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:i===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(i===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${ya} - Node System `}},Bf=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,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===me.FRAME){let{frameMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&i.set(n,this.frameId)}else if(t===me.RENDER){let{renderMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&i.set(n,this.renderId)}else t===me.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===me.FRAME){let{frameMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&i.set(n,this.frameId)}else if(t===me.RENDER){let{renderMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&i.set(n,this.renderId)}else t===me.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===me.FRAME){let{frameMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.frameId&&e.update(this)!==!1&&i.set(n,this.frameId)}else if(t===me.RENDER){let{renderMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.renderId&&e.update(this)!==!1&&i.set(n,this.renderId)}else t===me.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}},Lu=class{constructor(e,t,n=null,i="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=i,this.isConst=s}};Lu.isNodeFunctionInput=!0;var q_=class extends vs{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:CS(this.light),lightColor:e}}},Gv=new ee,Km=new ee,Vd=null,$_=class extends vs{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=se(new S).setGroup(te),this.halfWidth=se(new S).setGroup(te),this.updateType=me.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;Km.identity(),Gv.copy(t.matrixWorld),Gv.premultiply(n),Km.extractRotation(Gv),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Km),this.halfHeight.value.applyMatrix4(Km)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Te(Vd.LTC_FLOAT_1),n=Te(Vd.LTC_FLOAT_2)):(t=Te(Vd.LTC_HALF_1),n=Te(Vd.LTC_HALF_2));let{colorNode:i,light:s}=this,r=RS(s);return{lightColor:i,lightPosition:r,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){Vd=e}},Du=class extends vs{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=se(0).setGroup(te),this.penumbraCosNode=se(0).setGroup(te),this.cutoffDistanceNode=se(0).setGroup(te),this.decayExponentNode=se(0).setGroup(te),this.colorNode=se(this.color).setGroup(te)}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,t){let{coneCosNode:n,penumbraCosNode:i}=this;return Si(n,i,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=PN(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:i,light:s}=this,r=this.getLightVector(e),a=r.normalize(),c=a.dot(CS(s)),l=this.getSpotAttenuation(e,c),u=r.length(),h=LS({lightDistance:u,cutoffDistance:n,decayExponent:i}),d=t.mul(l).mul(h),f,p;return s.colorNode?(p=this.getLightCoord(e),f=s.colorNode(p)):s.map&&(p=this.getLightCoord(e),f=Te(s.map,p.xy).onRenderUpdate(()=>s.map)),f&&(d=p.mul(2).sub(1).abs().lessThan(1).all().select(d.mul(f),d)),{lightColor:d,lightDirection:a}}},Y_=class extends Du{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){let n=this.light.iesMap,i=null;if(n&&n.isTexture===!0){let s=t.acos().mul(1/Math.PI);i=Te(n,O(s,0),0).r}else i=super.getSpotAttenuation(t);return i}},hO=I(([o,e])=>{let t=o.abs().sub(e);return ms(mt(t,0)).add(Ln(mt(t.x,t.y),0))}),K_=class extends Du{static get type(){return"ProjectorLightNode"}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=b(0),n=this.penumbraCosNode,i=zy(this.light).mul(e.context.positionWorld||jn);return ne(i.w.greaterThan(0),()=>{let s=i.xyz.div(i.w),r=hO(s.xy.sub(O(.5)),O(.5)),a=Zn(-1,Se(1,Fb(n)).sub(1));t.assign(kb(r.mul(-2).mul(a)))}),t}},j_=class extends vs{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},Z_=class extends vs{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=wS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=se(new q).setGroup(te)}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:i}=this,r=fo.dot(i).mul(.5).add(.5),a=Ne(n,t,r);e.context.irradiance.addAssign(a)}},J_=class extends vs{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let n=0;n<9;n++)t.push(new S);this.lightProbe=un(t)}update(e){let{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){let t=s1(fo,this.lightProbe);e.context.irradiance.addAssign(t)}},Q_=class{parseFunction(){console.warn("Abstract function.")}},Of=class{constructor(e,t,n="",i=""){this.type=e,this.inputs=t,this.name=n,this.precision=i}getCode(){console.warn("Abstract function.")}};Of.isNodeFunction=!0;var dO=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,fO=/[a-z_0-9]+/ig,IE="#pragma main",pO=o=>{o=o.trim();let e=o.indexOf(IE),t=e!==-1?o.slice(e+IE.length):o,n=t.match(dO);if(n!==null&&n.length===5){let i=n[4],s=[],r=null;for(;(r=fO.exec(i))!==null;)s.push(r);let a=[],c=0;for(;c0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||i){let s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Ia||n.mapping===La||n.mapping===Da){if(e.backgroundBlurriness>0||n.mapping===Da)return bS(n);{let r;return n.isCubeTexture===!0?r=wu(n):r=Te(n),jC(r)}}else{if(n.isTexture===!0)return Te(n,ur.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},i);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,i=!1){let s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),r=s.get(t);return(r===void 0||i)&&(r=n(),s.set(t,r)),r}updateFog(e){let t=this.get(e),n=e.fog;if(n){if(t.fog!==n){let i=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){let s=Xe("color","color",n).setGroup(te),r=Xe("density","float",n).setGroup(te);return Pf(s,AS(r))}else if(n.isFog){let s=Xe("color","color",n).setGroup(te),r=Xe("near","float",n).setGroup(te),a=Xe("far","float",n).setGroup(te);return Pf(s,MS(r,a))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=i,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){let t=this.get(e),n=e.environment;if(n){if(t.environment!==n){let i=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return wu(n);if(n.isTexture===!0)return Te(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=i,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,i=null,s=null){let r=this.nodeFrame;return r.renderer=e,r.scene=t,r.object=n,r.camera=i,r.material=s,r}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return LE.get(e)!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,n=this.getOutputCacheKey(),i=e.isArrayTexture?TN(e,P(ur,gr("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Te(e,ur).renderOutput(t.toneMapping,t.currentColorSpace);return LE.set(e,n),i}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let i of n.updateNodes)t.updateNode(i)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let i of n.updateNodes)t.updateNode(i)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Bf,this.nodeBuilderCache=new Map,this.cacheLib={}}},kv=new pn,ty=class o{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new pe,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){let i=e.length;for(let s=0;s0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},a=new XRWebGLLayer(e,i,r);this._glBaseLayer=a,e.updateRenderState({baseLayer:a}),t.setPixelRatio(1),t._setXRLayerSize(a.framebufferWidth,a.framebufferHeight),this._xrRenderTarget=new vc(a.framebufferWidth,a.framebufferHeight,{format:Ft,type:Ot,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:a.ignoreDepthValues===!1,resolveStencilBuffer:a.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,i=e.far,s=this._cameraXR,r=this._cameraL,a=this._cameraR;s.near=a.near=r.near=n,s.far=a.far=r.far=i,s.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==s.near||this._currentDepthFar!==s.far)&&(t.updateRenderState({depthNear:s.near,depthFar:s.far}),this._currentDepthNear=s.near,this._currentDepthFar=s.far),s.layers.mask=e.layers.mask|6,r.layers.mask=s.layers.mask&3,a.layers.mask=s.layers.mask&5;let c=e.parent,l=s.cameras;UE(s,c);for(let u=0;u=0&&(t[s]=null,e[s].disconnect(i))}for(let n=0;n=t.length){t.push(i),s=a;break}else if(t[a]===null){t[a]=i,s=a;break}if(s===-1)break}let r=e[s];r&&r.connect(i)}}function TO(o){return o.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(o.translation,o.quaternion),width:o.width/2,height:o.height/2,space:this._referenceSpace,viewPixelWidth:o.pixelwidth,viewPixelHeight:o.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(o.translation,o.quaternion),radius:o.radius,centralAngle:o.centralAngle,aspectRatio:o.aspectRatio,space:this._referenceSpace,viewPixelWidth:o.pixelwidth,viewPixelHeight:o.pixelheight,clearOnAccess:!1})}function bO(o,e){if(e===void 0)return;let t=this._cameraXR,n=this._renderer,i=n.backend,s=this._glBaseLayer,r=this.getReferenceSpace(),a=e.getViewerPose(r);if(this._xrFrame=e,a!==null){let c=a.views;this._glBaseLayer!==null&&i.setXRTarget(s.framebuffer);let l=!1;c.length!==t.cameras.length&&(t.cameras.length=0,l=!0);for(let u=0;u{await this.compileAsync(f,p);let _=this._renderLists.get(f,p),y=this._renderContexts.get(f,p,this._renderTarget),x=f.overrideMaterial||m.material,v=this._objects.get(m,x,f,p,_.lightsNode,y,y.clippingContext),{fragmentShader:T,vertexShader:M}=v.getNodeBuilderState();return{fragmentShader:T,vertexShader:M}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(i){if(this._getFallback!==null)try{this.backend=n=this._getFallback(i),await n.init(this)}catch(s){t(s);return}else{t(i);return}}this._nodes=new ST(this,n),this._animation=new N0(this._nodes,this.info),this._attributes=new L0(n),this._background=new iT(this,this._nodes),this._geometries=new D0(this._attributes,this.info),this._textures=new W0(this,n,this.info),this._pipelines=new O0(n,this._nodes),this._bindings=new V0(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new I0(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new k0(this.lighting),this._bundles=new AT,this._renderContexts=new H0,this._animation.start(),this._initialized=!0,e(this)}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let i=this._nodes.nodeFrame,s=i.renderId,r=this._currentRenderContext,a=this._currentRenderObjectFunction,c=this._compilationPromises,l=e.isScene===!0?e:BE;n===null&&(n=e);let u=this._renderTarget,h=this._renderContexts.get(n,t,u),d=this._activeMipmapLevel,f=[];this._currentRenderContext=h,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=f,i.renderId++,i.update(),h.depth=this.depth,h.stencil=this.stencil,h.clippingContext||(h.clippingContext=new ty),h.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,u);let p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,h.clippingContext),n!==e&&n.traverseVisible(function(v){v.isLight&&v.layers.test(t.layers)&&p.pushLight(v)}),p.finish(),u!==null){this._textures.updateRenderTarget(u,d);let v=this._textures.get(u);h.textures=v.textures,h.depthTexture=v.depthTexture}else h.textures=null,h.depthTexture=null;this._background.update(l,p,h);let m=p.opaque,_=p.transparent,y=p.transparentDoublePass,x=p.lightsNode;this.opaque===!0&&m.length>0&&this._renderObjects(m,t,l,x),this.transparent===!0&&_.length>0&&this._renderTransparents(_,y,t,l,x),i.renderId=s,this._currentRenderContext=r,this._currentRenderObjectFunction=a,this._compilationPromises=c,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(f)}async renderAsync(e,t){this._initialized===!1&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=c0,this.overrideNodes.modelNormalViewMatrix=l0):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===c0&&this.overrideNodes.modelNormalViewMatrix===l0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: Message: ${e.message}`;e.reason&&(t+=` Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){let{bundleGroup:i,camera:s,renderList:r}=e,a=this._currentRenderContext,c=this._bundles.get(i,s),l=this.backend.get(c);l.renderContexts===void 0&&(l.renderContexts=new Set);let u=i.version!==l.version,h=l.renderContexts.has(a)===!1||u;if(l.renderContexts.add(a),h){this.backend.beginBundle(a),(l.renderObjects===void 0||u)&&(l.renderObjects=[]),this._currentRenderBundle=c;let{transparentDoublePass:d,transparent:f,opaque:p}=r;this.opaque===!0&&p.length>0&&this._renderObjects(p,s,t,n),this.transparent===!0&&f.length>0&&this._renderTransparents(f,d,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(a,c),l.version=i.version}else{let{renderObjects:d}=l;for(let f=0,p=d.length;f>=d,p.viewportValue.height>>=d,p.viewportValue.minDepth=T,p.viewportValue.maxDepth=M,p.viewport=p.viewportValue.equals(zv)===!1,p.scissorValue.copy(x).multiplyScalar(v).floor(),p.scissor=this._scissorTest&&p.scissorValue.equals(zv)===!1,p.scissorValue.width>>=d,p.scissorValue.height>>=d,p.clippingContext||(p.clippingContext=new ty),p.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,f);let w=t.isArrayCamera?Wv:Hv;t.isArrayCamera||(jm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),w.setFromProjectionMatrix(jm,t.coordinateSystem,t.reversedDepth));let E=this._renderLists.get(e,t);if(E.begin(),this._projectObject(e,t,0,E,p.clippingContext),E.finish(),this.sortObjects===!0&&E.sort(this._opaqueSort,this._transparentSort),f!==null){this._textures.updateRenderTarget(f,d);let W=this._textures.get(f);p.textures=W.textures,p.depthTexture=W.depthTexture,p.width=W.width,p.height=W.height,p.renderTarget=f,p.depth=f.depthBuffer,p.stencil=f.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=lu.width,p.height=lu.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=d,p.height>>=d,p.activeCubeFace=h,p.activeMipmapLevel=d,p.occlusionQueryCount=E.occlusionQueryCount,p.scissorValue.max(ir.set(0,0,0,0)),p.scissorValue.x+p.scissorValue.width>p.width&&(p.scissorValue.width=Math.max(p.width-p.scissorValue.x,0)),p.scissorValue.y+p.scissorValue.height>p.height&&(p.scissorValue.height=Math.max(p.height-p.scissorValue.y,0)),this._background.update(l,E,p),p.camera=t,this.backend.beginRender(p);let{bundles:A,lightsNode:N,transparentDoublePass:L,transparent:V,opaque:H}=E;return A.length>0&&this._renderBundles(A,l,N),this.opaque===!0&&H.length>0&&this._renderObjects(H,t,l,N),this.transparent===!0&&V.length>0&&this._renderTransparents(V,L,t,l,N),this.backend.finishRender(p),s.renderId=r,this._currentRenderContext=a,this._currentRenderObjectFunction=c,i!==null&&(this.setRenderTarget(u,h,d),this._renderOutput(f)),l.onAfterRender(this,e,t,f),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);let n=this.autoClear,i=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=i}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,i){let s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,i)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,i,s=0,r=1){let a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,n,i),a.minDepth=s,a.maxDepth=r}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);let i=this._renderTarget||this._getFrameBufferTarget(),s=null;if(i!==null){this._textures.updateRenderTarget(i);let r=this._textures.get(i);s=this._renderContexts.getForClear(i),s.textures=r.textures,s.depthTexture=r.depthTexture,s.width=r.width,s.height=r.height,s.renderTarget=i,s.depth=i.depthBuffer,s.stencil=i.stencilBuffer,s.clearColorValue=this.backend.getClearColor(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,s),i!==null&&this._renderTarget===null&&this._renderOutput(i)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Gi}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:xe.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);let n=this._nodes.nodeFrame,i=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls;let s=this.backend,r=this._pipelines,a=this._bindings,c=this._nodes,l=Array.isArray(e)?e:[e];if(l[0]===void 0||l[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(let u of l){if(r.has(u)===!1){let f=()=>{u.removeEventListener("dispose",f),r.delete(u),a.delete(u),c.delete(u)};u.addEventListener("dispose",f);let p=u.onInitFunction;p!==null&&p.call(u,{renderer:this})}c.updateForCompute(u),a.updateForCompute(u);let h=a.getForCompute(u),d=r.getForCompute(u,h);s.compute(e,u,h,d,t)}s.finishCompute(e),n.renderId=i}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=ir.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=ir.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=ir.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,i;n!==null?i=n.renderTarget:(i=this._renderTarget||this._getFrameBufferTarget(),i!==null&&(this._textures.updateRenderTarget(i),n=this._textures.get(i))),this._textures.updateTexture(e,{renderTarget:i}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,i=null,s=0,r=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,i,s,r)}async readRenderTargetPixelsAsync(e,t,n,i,s,r=0,a=0){return this.backend.copyTextureToBuffer(e.textures[r],t,n,i,s,a)}_projectObject(e,t,n,i,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){let c=t.isArrayCamera?Wv:Hv;if(!e.frustumCulled||c.intersectsSprite(e,t)){this.sortObjects===!0&&ir.setFromMatrixPosition(e.matrixWorld).applyMatrix4(jm);let{geometry:l,material:u}=e;u.visible&&i.push(e,l,u,n,ir.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){let c=t.isArrayCamera?Wv:Hv;if(!e.frustumCulled||c.intersectsObject(e,t)){let{geometry:l,material:u}=e;if(this.sortObjects===!0&&(l.boundingSphere===null&&l.computeBoundingSphere(),ir.copy(l.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(jm)),Array.isArray(u)){let h=l.groups;for(let d=0,f=h.length;d0){for(let{material:r}of t)r.side=Nt;this._renderObjects(t,n,i,s,"backSide");for(let{material:r}of t)r.side=zn;this._renderObjects(e,n,i,s);for(let{material:r}of t)r.side=fi}else this._renderObjects(e,n,i,s)}_renderObjects(e,t,n,i,s=null){for(let r=0,a=e.length;r0,f.isShadowPassMaterial&&(f.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(d=f.depthNode,f.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(h=f.colorNode,f.colorNode=s.castShadowNode),s.castShadowPositionNode&&s.castShadowPositionNode.isNode&&(u=f.positionNode,f.positionNode=s.castShadowPositionNode)),s=f}s.transparent===!0&&s.side===fi&&s.forceSinglePass===!1?(s.side=Nt,this._handleObjectFunction(e,s,t,n,a,r,c,"backSide"),s.side=zn,this._handleObjectFunction(e,s,t,n,a,r,c,l),s.side=fi):this._handleObjectFunction(e,s,t,n,a,r,c,l),u!==void 0&&(t.overrideMaterial.positionNode=u),d!==void 0&&(t.overrideMaterial.depthNode=d),h!==void 0&&(t.overrideMaterial.colorNode=h),e.onAfterRender(this,t,n,i,s,r)}_renderObjectDirect(e,t,n,i,s,r,a,c){let l=this._objects.get(e,t,n,i,s,this._currentRenderContext,a,c);l.drawRange=e.geometry.drawRange,l.group=r;let u=this._nodes.needsRefresh(l);u&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(l,this.info),u&&this._nodes.updateAfter(l)}_createObjectPipeline(e,t,n,i,s,r,a,c){let l=this._objects.get(e,t,n,i,s,this._currentRenderContext,a,c);l.drawRange=e.geometry.drawRange,l.group=r,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}get compile(){return this.compileAsync}},sy=class{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}};function SO(o){return o+(Qr-o%Qr)%Qr}var ry=class extends sy{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return SO(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},oy=class extends ry{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},MO=0,ay=class extends oy{constructor(e,t){super("UniformBuffer_"+MO++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}},RT=class extends oy{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,i=this.uniforms.length;n{this._texture=null,this.generation=null,this.version=0};this._texture&&this._texture.removeEventListener("dispose",t),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",t)}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){let e=super.clone();return e._texture=null,e.texture=this.texture,e}},RO=0,CT=class extends ly{constructor(e,t){super(e,t),this.id=RO++,this.store=!1,this.isSampledTexture=!0}},Fu=class extends CT{constructor(e,t,n,i=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=i}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}},uy=class extends Fu{constructor(e,t,n,i=null){super(e,t,n,i),this.isSampledCubeTexture=!0}},Vf=class extends Fu{constructor(e,t,n,i=null){super(e,t,n,i),this.isSampledTexture3D=!0}},OE={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},CO={low:"lowp",medium:"mediump",high:"highp"},VE={swizzleAssign:!0,storageBuffer:!1},GE={perspective:"smooth",linear:"noperspective"},kE={centroid:"centroid"},zE=` precision highp float; precision highp int; precision highp sampler2D; precision highp sampler3D; precision highp samplerCube; precision highp sampler2DArray; precision highp usampler2D; precision highp usampler3D; precision highp usamplerCube; precision highp usampler2DArray; precision highp isampler2D; precision highp isampler3D; precision highp isamplerCube; precision highp isampler2DArray; precision lowp sampler2DShadow; precision lowp sampler2DArrayShadow; precision lowp samplerCubeShadow; `,NT=class extends Uf{constructor(e,t){super(e,t,new ey),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Xi}getMethod(e){return OE[e]||e}getBitcastMethod(e,t){return OE[`bitcast_${t}_${e}`]}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),i=[];for(let r of t.inputs)i.push(this.getType(r.type)+" "+r.name);return`${this.getType(t.type)} ${t.name}( ${i.join(", ")} ) { ${n.vars} ${n.code} return ${n.result}; }`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let n=t.array,i=t.count*t.itemSize,{itemSize:s}=t,r=t.array.constructor.name.toLowerCase().includes("int"),a=r?Xr:Wr;s===2?a=r?Ua:Hi:s===3?a=r?am:Fa:s===4&&(a=r?Ba:Ft);let c={Float32Array:nt,Uint8Array:Ot,Uint16Array:os,Uint32Array:Je,Int8Array:Js,Int16Array:Qs,Int32Array:Vt,Uint8ClampedArray:Ot},l=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(i/s)))),u=Math.ceil(i/s/l);l*u*s0?d:"";a=`${u.name} { ${h} ${r.name}[${f}]; }; `}else a=`${this.getVectorType(r.type)} ${this.getPropertyName(r,e)};`,c=!0;let l=r.node.precision;if(l!==null&&(a=CO[l]+" "+a),c){a=" "+a;let u=r.groupNode.name;(i[u]||(i[u]=[])).push(a)}else a="uniform "+a,n.push(a)}let s="";for(let r in i){let a=i[r];s+=this._getGLSLUniformStruct(e+"_"+r,a.join(` `))+` `}return s+=n.join(` `),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Vt){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let i=n.array;i instanceof Uint32Array||i instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){let n=this.getAttributesArray(),i=0;for(let s of n)t+=`layout( location = ${i++} ) in ${s.type} ${s.name}; `}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(` `)}getStructs(e){let t=[],n=this.structs[e],i=[];for(let s of n)if(s.output)for(let r of s.members)i.push(`layout( location = ${r.index} ) out ${r.type} ${r.name};`);else{let r="struct "+s.name+` { `;r+=this.getStructMembers(s),r+=` }; `,t.push(r)}return i.length===0&&i.push("layout( location = 0 ) out vec4 fragColor;"),` `+i.join(` `)+` `+t.join(` `)}getVaryings(e){let t="",n=this.varyings;if(e==="vertex"||e==="compute")for(let i of n){e==="compute"&&(i.needsInterpolation=!0);let s=this.getType(i.type);if(i.needsInterpolation)if(i.interpolationType){let r=GE[i.interpolationType]||i.interpolationType,a=kE[i.interpolationSampling]||"";t+=`${r} ${a} out ${s} ${i.name}; `}else{let r=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${r}out ${s} ${i.name}; `}else t+=`${s} ${i.name}; `}else if(e==="fragment"){for(let i of n)if(i.needsInterpolation){let s=this.getType(i.type);if(i.interpolationType){let r=GE[i.interpolationType]||i.interpolationType,a=kE[i.interpolationSampling]||"";t+=`${r} ${a} in ${s} ${i.name}; `}else{let r=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${r}in ${s} ${i.name}; `}}}for(let i of this.builtins[e])t+=`${i}; `;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,i)=>n*i,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){let i=this.extensions[n]||(this.extensions[n]=new Map);i.has(e)===!1&&i.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e==="vertex"){let i=this.renderer.backend.extensions;this.object.isBatchedMesh&&i.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}let n=this.extensions[e];if(n!==void 0)for(let{name:i,behavior:s}of n.values())t.push(`#extension ${i} : ${s}`);return t.join(` `)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=VE[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){let i=this.renderer.backend.extensions;i.has(n)&&(i.get(n),t=!0)}VE[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t="";for(let n=0;n0&&(n+=` `),n+=` // flow -> ${l} `),n+=`${c.code} `,a===s&&t!=="compute"&&(n+=`// result `,t==="vertex"?(n+="gl_Position = ",n+=`${c.result};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${c.result};`)))}let r=e[t];r.extensions=this.getExtensions(t),r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.vars=this.getVars(t),r.structs=this.getStructs(t),r.codes=this.getCodes(t),r.transforms=this.getTransforms(t),r.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,i=null){let s=super.getUniformFromNode(e,t,n,i),r=this.getDataFromNode(e,n,this.globalCache),a=r.uniformGPU;if(a===void 0){let c=e.groupNode,l=c.name,u=this.getBindGroupArray(l,n);if(t==="texture")a=new Fu(s.name,s.node,c),u.push(a);else if(t==="cubeTexture")a=new uy(s.name,s.node,c),u.push(a);else if(t==="texture3D")a=new Vf(s.name,s.node,c),u.push(a);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;let h=new ay(e,c);h.name=e.name,u.push(h),a=h}else{let h=this.uniformGroups[n]||(this.uniformGroups[n]={}),d=h[l];d===void 0&&(d=new cy(n+"_"+l,c),h[l]=d,u.push(d)),a=this.getNodeUniform(s,t),d.addUniform(a)}r.uniformGPU=a}return s}},Xv=null,uu=null,hy=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}getTimestampUID(e){let t=this.get(e),n=e.isComputeNode===!0?"c":"r";return n+=":"+t.frameCalls+":"+e.id,n}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){_n("WebGPURenderer: Timestamp tracking is disabled.");return}let t=this.timestampQueryPool[e];if(!t){_n(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Xv=Xv||new B,this.renderer.getDrawingBufferSize(Xv)}setScissorTest(){}getClearColor(){let e=this.renderer;return uu=uu||new Ef,e.getClearColor(uu),uu.getRGB(uu),uu}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:Nm(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${ya} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}},NO=0,PT=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},IT=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:i}=n,s=e.array,r=e.usage||i.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,c=n.get(a),l=c.bufferGPU;l===void 0&&(l=this._createBuffer(i,t,s,r),c.bufferGPU=l,c.bufferType=t,c.version=a.version);let u;if(s instanceof Float32Array)u=i.FLOAT;else if(typeof Float16Array!="undefined"&&s instanceof Float16Array)u=i.HALF_FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?u=i.HALF_FLOAT:u=i.UNSIGNED_SHORT;else if(s instanceof Int16Array)u=i.SHORT;else if(s instanceof Uint32Array)u=i.UNSIGNED_INT;else if(s instanceof Int32Array)u=i.INT;else if(s instanceof Int8Array)u=i.BYTE;else if(s instanceof Uint8Array)u=i.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)u=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let h={bufferGPU:l,bufferType:t,type:u,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===i.INT||u===i.UNSIGNED_INT||e.gpuType===Vt,id:NO++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let d=this._createBuffer(i,t,s,r);h=new PT(h,d)}n.set(e,h)}updateAttribute(e){let t=this.backend,{gl:n}=t,i=e.array,s=e.isInterleavedBufferAttribute?e.data:e,r=t.get(s),a=r.bufferType,c=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(a,r.bufferGPU),c.length===0)n.bufferSubData(a,0,i);else{for(let l=0,u=c.length;l1?this.enable(i.SAMPLE_ALPHA_TO_COVERAGE):this.disable(i.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let c=0;c<8;c++)c{function s(){let r=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(r===e.WAIT_FAILED){e.deleteSync(t),i();return}if(r===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}},HE=!1,Zm,$v,WE,FT=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},HE===!1&&(this._init(),HE=!0)}_init(){let e=this.gl;Zm={[Cn]:e.REPEAT,[Dt]:e.CLAMP_TO_EDGE,[oi]:e.MIRRORED_REPEAT},$v={[We]:e.NEAREST,[Hr]:e.NEAREST_MIPMAP_NEAREST,[ki]:e.NEAREST_MIPMAP_LINEAR,[Ae]:e.LINEAR,[Zs]:e.LINEAR_MIPMAP_NEAREST,[Zt]:e.LINEAR_MIPMAP_LINEAR},WE={[Td]:e.NEVER,[wd]:e.ALWAYS,[nu]:e.LESS,[Sd]:e.LEQUAL,[bd]:e.EQUAL,[Ed]:e.GEQUAL,[Md]:e.GREATER,[Ad]:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,i,s=!1){let{gl:r,extensions:a}=this;if(e!==null){if(r[e]!==void 0)return r[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let c=t;if(t===r.RED&&(n===r.FLOAT&&(c=r.R32F),n===r.HALF_FLOAT&&(c=r.R16F),n===r.UNSIGNED_BYTE&&(c=r.R8),n===r.UNSIGNED_SHORT&&(c=r.R16),n===r.UNSIGNED_INT&&(c=r.R32UI),n===r.BYTE&&(c=r.R8I),n===r.SHORT&&(c=r.R16I),n===r.INT&&(c=r.R32I)),t===r.RED_INTEGER&&(n===r.UNSIGNED_BYTE&&(c=r.R8UI),n===r.UNSIGNED_SHORT&&(c=r.R16UI),n===r.UNSIGNED_INT&&(c=r.R32UI),n===r.BYTE&&(c=r.R8I),n===r.SHORT&&(c=r.R16I),n===r.INT&&(c=r.R32I)),t===r.RG&&(n===r.FLOAT&&(c=r.RG32F),n===r.HALF_FLOAT&&(c=r.RG16F),n===r.UNSIGNED_BYTE&&(c=r.RG8),n===r.UNSIGNED_SHORT&&(c=r.RG16),n===r.UNSIGNED_INT&&(c=r.RG32UI),n===r.BYTE&&(c=r.RG8I),n===r.SHORT&&(c=r.RG16I),n===r.INT&&(c=r.RG32I)),t===r.RG_INTEGER&&(n===r.UNSIGNED_BYTE&&(c=r.RG8UI),n===r.UNSIGNED_SHORT&&(c=r.RG16UI),n===r.UNSIGNED_INT&&(c=r.RG32UI),n===r.BYTE&&(c=r.RG8I),n===r.SHORT&&(c=r.RG16I),n===r.INT&&(c=r.RG32I)),t===r.RGB){let l=s?Lo:xe.getTransfer(i);n===r.FLOAT&&(c=r.RGB32F),n===r.HALF_FLOAT&&(c=r.RGB16F),n===r.UNSIGNED_BYTE&&(c=r.RGB8),n===r.UNSIGNED_SHORT&&(c=r.RGB16),n===r.UNSIGNED_INT&&(c=r.RGB32UI),n===r.BYTE&&(c=r.RGB8I),n===r.SHORT&&(c=r.RGB16I),n===r.INT&&(c=r.RGB32I),n===r.UNSIGNED_BYTE&&(c=l===he?r.SRGB8:r.RGB8),n===r.UNSIGNED_SHORT_5_6_5&&(c=r.RGB565),n===r.UNSIGNED_SHORT_5_5_5_1&&(c=r.RGB5_A1),n===r.UNSIGNED_SHORT_4_4_4_4&&(c=r.RGB4),n===r.UNSIGNED_INT_5_9_9_9_REV&&(c=r.RGB9_E5),n===r.UNSIGNED_INT_10F_11F_11F_REV&&(c=r.R11F_G11F_B10F)}if(t===r.RGB_INTEGER&&(n===r.UNSIGNED_BYTE&&(c=r.RGB8UI),n===r.UNSIGNED_SHORT&&(c=r.RGB16UI),n===r.UNSIGNED_INT&&(c=r.RGB32UI),n===r.BYTE&&(c=r.RGB8I),n===r.SHORT&&(c=r.RGB16I),n===r.INT&&(c=r.RGB32I)),t===r.RGBA){let l=s?Lo:xe.getTransfer(i);n===r.FLOAT&&(c=r.RGBA32F),n===r.HALF_FLOAT&&(c=r.RGBA16F),n===r.UNSIGNED_BYTE&&(c=r.RGBA8),n===r.UNSIGNED_SHORT&&(c=r.RGBA16),n===r.UNSIGNED_INT&&(c=r.RGBA32UI),n===r.BYTE&&(c=r.RGBA8I),n===r.SHORT&&(c=r.RGBA16I),n===r.INT&&(c=r.RGBA32I),n===r.UNSIGNED_BYTE&&(c=l===he?r.SRGB8_ALPHA8:r.RGBA8),n===r.UNSIGNED_SHORT_4_4_4_4&&(c=r.RGBA4),n===r.UNSIGNED_SHORT_5_5_5_1&&(c=r.RGB5_A1)}return t===r.RGBA_INTEGER&&(n===r.UNSIGNED_BYTE&&(c=r.RGBA8UI),n===r.UNSIGNED_SHORT&&(c=r.RGBA16UI),n===r.UNSIGNED_INT&&(c=r.RGBA32UI),n===r.BYTE&&(c=r.RGBA8I),n===r.SHORT&&(c=r.RGBA16I),n===r.INT&&(c=r.RGBA32I)),t===r.DEPTH_COMPONENT&&(n===r.UNSIGNED_SHORT&&(c=r.DEPTH_COMPONENT16),n===r.UNSIGNED_INT&&(c=r.DEPTH_COMPONENT24),n===r.FLOAT&&(c=r.DEPTH_COMPONENT32F)),t===r.DEPTH_STENCIL&&n===r.UNSIGNED_INT_24_8&&(c=r.DEPTH24_STENCIL8),(c===r.R16F||c===r.R32F||c===r.RG16F||c===r.RG32F||c===r.RGBA16F||c===r.RGBA32F)&&a.get("EXT_color_buffer_float"),c}setTextureParameters(e,t){let{gl:n,extensions:i,backend:s}=this,r=xe.getPrimaries(xe.workingColorSpace),a=t.colorSpace===Xi?null:xe.getPrimaries(t.colorSpace),c=t.colorSpace===Xi||r===a?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,Zm[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Zm[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Zm[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,$v[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===Ae&&l?Zt:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,$v[u]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,WE[t.compareFunction])),i.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===We||t.minFilter!==ki&&t.minFilter!==Zt||t.type===nt&&i.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){let h=i.get("EXT_texture_filter_anisotropic");n.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:i}=this,s=this.getGLTextureType(e),r=i[s];r===void 0&&(r=t.createTexture(),n.state.bindTexture(s,r),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),i[s]=r),n.set(e,{textureGPU:r,glTextureType:s,isDefault:!0})}createTexture(e,t){let{gl:n,backend:i}=this,{levels:s,width:r,height:a,depth:c}=t,l=i.utils.convert(e.format,e.colorSpace),u=i.utils.convert(e.type),h=this.getInternalFormat(e.internalFormat,l,u,e.colorSpace,e.isVideoTexture),d=n.createTexture(),f=this.getGLTextureType(e);i.state.bindTexture(f,d),this.setTextureParameters(f,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,h,r,a,c):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,h,r,a,c):e.isVideoTexture||n.texStorage2D(f,s,h,r,a),i.set(e,{textureGPU:d,glTextureType:f,glFormat:l,glType:u,glInternalFormat:h})}copyBufferToTexture(e,t){let{gl:n,backend:i}=this,{textureGPU:s,glTextureType:r,glFormat:a,glType:c}=i.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(r,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(r,0,0,0,l,u,a,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:i,height:s}=t,{textureGPU:r,glTextureType:a,glFormat:c,glType:l,glInternalFormat:u}=this.backend.get(e);if(!(e.isRenderTargetTexture||r===void 0))if(this.backend.state.bindTexture(a,r),this.setTextureParameters(a,e),e.isCompressedTexture){let h=e.mipmaps,d=t.image;for(let f=0;f0){let d=Lm(h.width,h.height,e.format,e.type);for(let f of e.layerUpdates){let p=h.data.subarray(f*d/h.data.BYTES_PER_ELEMENT,(f+1)*d/h.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,f,h.width,h.height,1,c,l,p)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,h.width,h.height,h.depth,c,l,h.data)}else if(e.isData3DTexture){let h=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,h.width,h.height,h.depth,c,l,h.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(a,0,u,c,l,t.image);else{let h=e.mipmaps;if(h.length>0)for(let d=0,f=h.length;d0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(h){let f=a!==0||c!==0,p,m;if(e.isDepthTexture===!0?(p=i.DEPTH_BUFFER_BIT,m=i.DEPTH_ATTACHMENT,t.stencil&&(p|=i.STENCIL_BUFFER_BIT)):(p=i.COLOR_BUFFER_BIT,m=i.COLOR_ATTACHMENT0),f){let _=this.backend.get(t.renderTarget),y=_.framebuffers[t.getCacheKey()],x=_.msaaFrameBuffer;s.bindFramebuffer(i.DRAW_FRAMEBUFFER,y),s.bindFramebuffer(i.READ_FRAMEBUFFER,x);let v=d-c-u;i.blitFramebuffer(a,v,a+l,v+u,a,v,a+l,v+u,p,i.NEAREST),s.bindFramebuffer(i.READ_FRAMEBUFFER,y),s.bindTexture(i.TEXTURE_2D,r),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,v,l,u),s.unbindTexture()}else{let _=i.createFramebuffer();s.bindFramebuffer(i.DRAW_FRAMEBUFFER,_),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,m,i.TEXTURE_2D,r,0),i.blitFramebuffer(0,0,l,u,0,0,l,u,p,i.NEAREST),i.deleteFramebuffer(_)}}else s.bindTexture(i.TEXTURE_2D,r),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,d-u-c,l,u),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,i=!1){let{gl:s}=this,r=t.renderTarget,{depthTexture:a,depthBuffer:c,stencilBuffer:l,width:u,height:h}=r;if(s.bindRenderbuffer(s.RENDERBUFFER,e),c&&!l){let d=s.DEPTH_COMPONENT24;i===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,r.samples,d,u,h):n>0?(a&&a.isDepthTexture&&a.type===s.FLOAT&&(d=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,n,d,u,h)):s.renderbufferStorage(s.RENDERBUFFER,d,u,h),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else c&&l&&(n>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,u,h):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,u,h),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,i,s,r){let{backend:a,gl:c}=this,{textureGPU:l,glFormat:u,glType:h}=this.backend.get(e),d=c.createFramebuffer();c.bindFramebuffer(c.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?c.TEXTURE_CUBE_MAP_POSITIVE_X+r:c.TEXTURE_2D;c.framebufferTexture2D(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,f,l,0);let p=this._getTypedArrayType(h),m=this._getBytesPerTexel(h,u),y=i*s*m,x=c.createBuffer();c.bindBuffer(c.PIXEL_PACK_BUFFER,x),c.bufferData(c.PIXEL_PACK_BUFFER,y,c.STREAM_READ),c.readPixels(t,n,i,s,u,h,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();let v=new p(y/p.BYTES_PER_ELEMENT);return c.bindBuffer(c.PIXEL_PACK_BUFFER,x),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,v),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),c.deleteFramebuffer(d),v}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,i=0;if(e===n.UNSIGNED_BYTE&&(i=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(i=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(i=4),t===n.RGBA)return i*4;if(t===n.RGB)return i*3;if(t===n.ALPHA)return i}};function Jm(o){return o.isDataTexture?o.image.data:typeof HTMLImageElement!="undefined"&&o instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&o instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&o instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&o instanceof OffscreenCanvas?o:o.data}var UT=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},BT=class{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){let n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}},XE={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"},OT=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:i,object:s,type:r,info:a,index:c}=this;c!==0?n.drawElements(i,t,r,e):n.drawArrays(i,e,t),a.update(s,t,1)}renderInstances(e,t,n){let{gl:i,mode:s,type:r,index:a,object:c,info:l}=this;n!==0&&(a!==0?i.drawElementsInstanced(s,t,r,e,n):i.drawArraysInstanced(s,e,t,n),l.update(c,t,n))}renderMultiDraw(e,t,n){let{extensions:i,mode:s,object:r,info:a}=this;if(n===0)return;let c=i.get("WEBGL_multi_draw");if(c===null)for(let l=0;lthis.maxQueries)return _n(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(i){console.error("Error in beginQuery:",i),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(n){console.error("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=[];for(let[i,s]of this.queryStates)if(s==="ended"){let r=this.queries[i];e.push(this.resolveQuery(r))}if(e.length===0)return this.lastValue;let n=(await Promise.all(e)).reduce((i,s)=>i+s,0);return this.lastValue=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,i=!1,s=()=>{n&&(clearTimeout(n),n=null)},r=c=>{i||(i=!0,s(),t(c))},a=()=>{if(this.isDisposed){r(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){r(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(a,1);return}let u=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(u)/1e6)}catch(c){console.error("Error checking query:",c),t(this.lastValue)}};a()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},fy=class extends hy{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},i=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function s(r){r.preventDefault();let a={api:"WebGL",message:r.statusMessage||"Unknown reason",reason:null,originalEvent:r};e.onDeviceLost(a)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=i,this.extensions=new UT(this),this.capabilities=new BT(this),this.attributeUtils=new IT(this),this.textureUtils=new FT(this),this.bufferRenderer=new OT(this),this.state=new LT(this),this.utils=new DT(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return Kt}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let i=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:i.RGBA8}),n!==null){let s=e.stencilBuffer?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:s}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new VT(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(n.frameCalls=this.renderer.info.render.frameCalls,e.viewport)this.updateViewport(e);else{let{width:s,height:r}=this.getDrawingBufferSize();t.viewport(0,0,s,r)}if(e.scissor){let{x:s,y:r,width:a,height:c}=e.scissorValue;t.scissor(s,e.height-c-r,a,c)}this.initTimestampQuery(tr.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let i=e.occlusionQueryCount;i>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(i),n.occlusionQueryObjects=new Array(i),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,i=this.get(e),s=i.previousContext;n.resetVertexState();let r=e.occlusionQueryCount;r>0&&(r>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let a=e.textures;if(a!==null)for(let c=0;c{let c=0;for(let l=0;l{t.isBatchedMesh?t._multiDrawInstances!==null?(_n("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),v.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?v.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):_n("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):M>1?v.renderInstances(w,T,M):v.render(w,T)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let A=this.get(e.camera),N=e.camera.cameras,L=e.getBindingGroup("cameraIndex").bindings[0];if(A.indexesGPU===void 0||A.indexesGPU.length!==N.length){let oe=new Uint32Array([0,0,0,0]),Le=[];for(let He=0,ve=N.length;He{let d=this.parallel,f=()=>{n.getProgramParameter(a,d.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),h()):requestAnimationFrame(f)};f()});t.push(u);return}this._completeCompile(e,i)}_handleSource(e,t){let n=e.split(` `),i=[],s=Math.max(t-6,0),r=Math.min(t+6,n.length);for(let a=s;a":" "} ${c}: ${n[a]}`)}return i.join(` `)}_getShaderErrors(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let c=parseInt(a[1]);return n.toUpperCase()+` `+r+` `+this._handleSource(e.getShaderSource(t),c)}else return r}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){let i=this.gl,r=(i.getProgramInfoLog(e)||"").trim();if(i.getProgramParameter(e,i.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(i,e,n,t);else{let a=this._getShaderErrors(i,n,"vertex"),c=this._getShaderErrors(i,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+` Program Info Log: `+r+` `+a+` `+c)}else r!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",r)}}_completeCompile(e,t){let{state:n,gl:i}=this,s=this.get(t),{programGPU:r,fragmentShader:a,vertexShader:c}=s;i.getProgramParameter(r,i.LINK_STATUS)===!1&&this._logProgramError(r,a,c),n.useProgram(r);let l=e.getBindings();this._setupBindings(l,r),this.set(t,{programGPU:r})}createComputePipeline(e,t){let{state:n,gl:i}=this,s={stage:"fragment",code:`#version 300 es precision highp float; void main() {}`};this.createProgram(s);let{computeProgram:r}=e,a=i.createProgram(),c=this.get(s).shaderGPU,l=this.get(r).shaderGPU,u=r.transforms,h=[],d=[];for(let _=0;_XE[i]===e),n=this.extensions;for(let i=0;i1,f=s.isXRRenderTarget===!0,p=f===!0&&s._hasExternalTextures===!0,m=r.msaaFrameBuffer,_=r.depthRenderbuffer,y=this.extensions.get("WEBGL_multisampled_render_to_texture"),x=this.extensions.get("OVR_multiview2"),v=this._useMultisampledExtension(s),T=hN(e),M;if(u?(r.cubeFramebuffers||(r.cubeFramebuffers={}),M=r.cubeFramebuffers[T]):f&&p===!1?M=this._xrFramebuffer:(r.framebuffers||(r.framebuffers={}),M=r.framebuffers[T]),M===void 0){M=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,M);let w=e.textures,E=[];if(u){r.cubeFramebuffers[T]=M;let{textureGPU:N}=this.get(w[0]),L=this.renderer._activeCubeFace,V=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+L,N,V)}else{r.framebuffers[T]=M;for(let N=0;N0&&v===!1&&!s.multiview){if(m===void 0){let w=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let E=[],A=e.textures;for(let N=0;N0&&this._useMultisampledExtension(i)===!1){let r=s.framebuffers[e.getCacheKey()],a=t.COLOR_BUFFER_BIT;i.resolveDepthBuffer&&(i.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),i.stencilBuffer&&i.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));let c=s.msaaFrameBuffer,l=s.msaaRenderbuffers,u=e.textures,h=u.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,c),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,r),h)for(let d=0;d0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){let e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}},_u={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Jt={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},bn={Store:"store"},Be={Load:"load",Clear:"clear"},qE={CCW:"ccw",CW:"cw"},$E={None:"none",Back:"back"},Uu={Uint16:"uint16",Uint32:"uint32"},C={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},Yv={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},gc={Linear:"linear",Nearest:"nearest"},Re={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},dc={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},YE={None:0,All:15},Zr={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},Kv={Storage:"storage",ReadOnlyStorage:"read-only-storage"},jv={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},KE={NonFiltering:"non-filtering",Comparison:"comparison"},fc={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},jE={TwoD:"2d",ThreeD:"3d"},Pt={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},PO={All:"all"},Qm={Vertex:"vertex",Instance:"instance"},GT={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},kT=class extends ly{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}},zT=class extends ry{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}},IO=0,HT=class extends zT{constructor(e,t){super("StorageBuffer_"+IO++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:qt.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}},WT=class extends xs{constructor(e){super(),this.device=e;let t=` struct VarysStruct { @builtin( position ) Position: vec4, @location( 0 ) vTex : vec2 }; @vertex fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { var Varys : VarysStruct; var pos = array< vec2, 4 >( vec2( -1.0, 1.0 ), vec2( 1.0, 1.0 ), vec2( -1.0, -1.0 ), vec2( 1.0, -1.0 ) ); var tex = array< vec2, 4 >( vec2( 0.0, 0.0 ), vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ), vec2( 1.0, 1.0 ) ); Varys.vTex = tex[ vertexIndex ]; Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); return Varys; } `,n=` @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img : texture_2d; @fragment fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { return textureSample( img, imgSampler, vTex ); } `,i=` @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img : texture_2d; @fragment fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); } `;this.mipmapSampler=e.createSampler({minFilter:gc.Linear}),this.flipYSampler=e.createSampler({minFilter:gc.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:i})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:_u.TriangleStrip,stripIndexFormat:Uu.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:_u.TriangleStrip,stripIndexFormat:Uu.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){let i=t.format,{width:s,height:r}=t.size,a=this.getTransferPipeline(i),c=this.getFlipYPipeline(i),l=this.device.createTexture({size:{width:s,height:r,depthOrArrayLayers:1},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),u=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Pt.TwoD,baseArrayLayer:n}),h=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:Pt.TwoD,baseArrayLayer:0}),d=this.device.createCommandEncoder({}),f=(p,m,_)=>{let y=p.getBindGroupLayout(0),x=this.device.createBindGroup({layout:y,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:m}]}),v=d.beginRenderPass({colorAttachments:[{view:_,loadOp:Be.Clear,storeOp:bn.Store,clearValue:[0,0,0,0]}]});v.setPipeline(p),v.setBindGroup(0,x),v.draw(4,1,0,0),v.end()};f(a,u,h),f(c,h,u),this.device.queue.submit([d.finish()]),l.destroy()}generateMipmaps(e,t,n=0){let i=this.get(e);i.useCount===void 0&&(i.useCount=0,i.layers=[]);let s=i.layers[n]||this._mipmapCreateBundles(e,t,n),r=this.device.createCommandEncoder({});this._mipmapRunBundles(r,s),this.device.queue.submit([r.finish()]),i.useCount!==0&&(i.layers[n]=s),i.useCount++}_mipmapCreateBundles(e,t,n){let i=this.getTransferPipeline(t.format),s=i.getBindGroupLayout(0),r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Pt.TwoD,baseArrayLayer:n}),a=[];for(let c=1;c0)for(let r=0,a=i.length;r0)for(let r=0,a=i.length;r0?e.width:n.size.width,u=a>0?e.height:n.size.height;c.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:a,origin:{x:0,y:0,z:i},premultipliedAlpha:r},{width:l,height:u,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new WT(this.backend.device)),e}_generateMipmaps(e,t,n=0){this._getPassUtils().generateMipmaps(e,t,n)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,i,s,r=0,a=0){let c=this.backend.device,l=e.data,u=this._getBytesPerTexel(n.format),h=e.width*u;c.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:i}},l,{offset:e.width*e.height*u*r,bytesPerRow:h},{width:e.width,height:e.height,depthOrArrayLayers:1}),s===!0&&this._flipY(t,n,i)}_copyCompressedBufferToTexture(e,t,n){let i=this.backend.device,s=this._getBlockData(n.format),r=n.size.depthOrArrayLayers>1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,UO=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,ZE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},BO=o=>{o=o.trim();let e=o.match(FO);if(e!==null&&e.length===4){let t=e[2],n=[],i=null;for(;(i=UO.exec(t))!==null;)n.push({name:i[1],type:i[2]});let s=[];for(let u=0;u "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},YT=class extends Q_{parseFunction(e){return new $T(e)}},hu=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},OO={[qt.READ_ONLY]:"read",[qt.WRITE_ONLY]:"write",[qt.READ_WRITE]:"read_write"},JE={[Cn]:"repeat",[Dt]:"clamp",[oi]:"mirror"},eg={vertex:hu?hu.VERTEX:1,fragment:hu?hu.FRAGMENT:2,compute:hu?hu.COMPUTE:4},QE={instance:!0,swizzleAssign:!1,storageBuffer:!0},VO={"^^":"tsl_xor"},GO={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},ew={},Hd={tsl_xor:new Gt("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Gt("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Gt("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Gt("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Gt("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Gt("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Gt("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Gt("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Gt("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Gt("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Gt("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Gt("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Gt(` fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `)},kO={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"},r1="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(r1+=`diagnostic( off, derivative_uniformity ); `);var KT=class extends Uf{constructor(e,t){super(e,t,new YT),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,i,s,r=this.shaderStage){return r==="fragment"?i?s?`textureSample( ${t}, ${t}_sampler, ${n}, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${i} )`:s?`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",i)}generateTextureSampleLevel(e,t,n,i,s,r){return this.isUnfilterable(e)===!1?r?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r,i):this.generateTextureLod(e,t,n,s,r,i)}generateWrapFunction(e){let t=`tsl_coord_${JE[e.wrapS]}S_${JE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`,n=ew[t];if(n===void 0){let i=[],s=e.isData3DTexture?"vec3f":"vec2f",r=`fn ${t}( coord : ${s} ) -> ${s} { return ${s}( `,a=(c,l)=>{c===Cn?(i.push(Hd.repeatWrapping_float),r+=` tsl_repeatWrapping_float( coord.${l} )`):c===Dt?(i.push(Hd.clampWrapping_float),r+=` tsl_clampWrapping_float( coord.${l} )`):c===oi?(i.push(Hd.mirrorWrapping_float),r+=` tsl_mirrorWrapping_float( coord.${l} )`):(r+=` coord.${l}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${c}" for vertex shader.`))};a(e.wrapS,"x"),r+=`, `,a(e.wrapT,"y"),e.isData3DTexture&&(r+=`, `,a(e.wrapR,"z")),r+=` ); } `,ew[t]=n=new Gt(r,i)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let i=this.getDataFromNode(e,this.shaderStage,this.globalCache);i.dimensionsSnippet===void 0&&(i.dimensionsSnippet={});let s=i.dimensionsSnippet[n];if(i.dimensionsSnippet[n]===void 0){let r,a,{primarySamples:c}=this.renderer.backend.utils.getTextureSampleData(e),l=c>1;e.isData3DTexture?a="vec3":a="vec2",l||e.isStorageTexture?r=t:r=`${t}${n?`, u32( ${n} )`:""}`,s=new Ac(new Ec(`textureDimensions( ${r} )`,a)),i.dimensionsSnippet[n]=s,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(i.arrayLayerCount=new Ac(new Ec(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new Ac(new Ec("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,i,s="0u"){this._include("biquadraticTexture");let r=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,s);return i&&(n=`${n} + vec2(${i}) / ${a}`),`tsl_biquadraticTexture( ${t}, ${r}( ${n} ), ${a}, u32( ${s} ) )`}generateTextureLod(e,t,n,i,s,r="0u"){let a=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,r),l=e.isData3DTexture?"vec3":"vec2";s&&(n=`${n} + ${l}(${s}) / ${l}( ${c} )`);let u=`${l}( ${a}( ${n} ) * ${l}( ${c} ) )`;return this.generateTextureLoad(e,t,u,i,null,r)}generateTextureLoad(e,t,n,i,s,r="0u"){let a;return s&&(n=`${n} + ${s}`),i?a=`textureLoad( ${t}, ${n}, ${i}, u32( ${r} ) )`:(a=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,n,i,s){let r;return i?r=`textureStore( ${t}, ${n}, ${i}, ${s} )`:r=`textureStore( ${t}, ${n}, ${s} )`,r}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===nt||this.isSampleCompare(e)===!1&&e.minFilter===We&&e.magFilter===We||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,i,s,r=this.shaderStage){let a=null;return this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,i,s,"0",r):a=this._generateTextureSample(e,t,n,i,s,r),a}generateTextureGrad(e,t,n,i,s,r,a=this.shaderStage){if(a==="fragment")return r?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i[0]}, ${i[1]}, ${r} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,i,s,r,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?r?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${i}, ${r} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${i} )`:r?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,i,s,r){return this.isUnfilterable(e)===!1?r?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r,i):this.generateTextureLod(e,t,n,s,r,i)}generateTextureBias(e,t,n,i,s,r,a=this.shaderStage){if(a==="fragment")return r?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let n=e.name,i=e.type;return i==="texture"||i==="cubeTexture"||i==="storageTexture"||i==="texture3D"?n:i==="buffer"||i==="storageBuffer"||i==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=VO[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(console.warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),qt.READ_WRITE):qt.READ_ONLY:e.access}getStorageAccess(e,t){return OO[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,i=null){let s=super.getUniformFromNode(e,t,n,i),r=this.getDataFromNode(e,n,this.globalCache);if(r.uniformGPU===void 0){let a,c=e.groupNode,l=c.name,u=this.getBindGroupArray(l,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let h=null,d=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?h=new Vf(s.name,s.node,c,d):h=new Fu(s.name,s.node,c,d):t==="cubeTexture"?h=new uy(s.name,s.node,c,d):t==="texture3D"&&(h=new Vf(s.name,s.node,c,d)),h.store=e.isStorageTextureNode===!0,h.setVisibility(eg[n]),this.isUnfilterable(e.value)===!1&&h.store===!1){let f=new kT(`${s.name}_sampler`,s.node,c);f.setVisibility(eg[n]),u.push(f,h),a=[f,h]}else u.push(h),a=[h]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){let h=t==="buffer"?ay:HT,d=new h(e,c);d.setVisibility(eg[n]),u.push(d),a=d,s.name=i||"NodeBuffer_"+s.id}else{let h=this.uniformGroups[n]||(this.uniformGroups[n]={}),d=h[l];d===void 0&&(d=new cy(l,c),d.setVisibility(eg[n]),h[l]=d,u.push(d)),a=this.getNodeUniform(s,t),d.addUniform(a)}r.uniformGPU=a}return s}getBuiltin(e,t,n,i=this.shaderStage){let s=this.builtins[i]||(this.builtins[i]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),i=[];for(let r of t.inputs)i.push(r.name+" : "+this.getType(r.type));let s=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} { ${n.vars} ${n.code} `;return n.result&&(s+=` return ${n.result}; `),s+=` } `,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],n=this.directives[e];if(n!==void 0)for(let i of n)t.push(`enable ${i};`);return t.join(` `)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){let t=[],n=this.builtins[e];if(n!==void 0)for(let{name:i,property:s,type:r}of n.values())t.push(`@builtin( ${i} ) ${s} : ${r}`);return t.join(`, `)}getScopedArray(e,t,n,i){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:i}),e}getScopedArrays(e){if(e!=="compute")return;let t=[];for(let{name:n,scope:i,bufferType:s,bufferCount:r}of this.scopedArrays.values()){let a=this.getType(s);t.push(`var<${i}> ${n}: array< ${a}, ${r} >;`)}return t.join(` `)}getAttributes(e){let t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){let n=this.getBuiltins("attribute");n&&t.push(n);let i=this.getAttributesArray();for(let s=0,r=i.length;s"),t.push(` ${i+n.name} : ${s}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, `)}getStructs(e){let t="",n=this.structs[e];if(n.length>0){let i=[];for(let s of n){let r=`struct ${s.name} { `;r+=this.getStructMembers(s),r+=` };`,i.push(r)}t=` `+i.join(` `)+` `}return t}getVar(e,t,n=null){let i=`var ${t} : `;return n!==null?i+=this.generateArrayDeclaration(e,n):i+=this.getType(e),i}getVars(e){let t=[],n=this.vars[e];if(n!==void 0)for(let i of n)t.push(` ${this.getVar(i.type,i.name,i.count)};`);return` ${t.join(` `)} `}getVaryings(e){let t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){let s=this.varyings,r=this.vars[e];for(let a=0;an.value.itemSize;return i&&!s}getUniforms(e){let t=this.uniforms[e],n=[],i=[],s=[],r={};for(let c of t){let l=c.groupNode.name,u=this.bindingsIndexes[l];if(c.type==="texture"||c.type==="cubeTexture"||c.type==="storageTexture"||c.type==="texture3D"){let h=c.node.value;this.isUnfilterable(h)===!1&&c.node.isStorageTextureNode!==!0&&(this.isSampleCompare(h)?n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${c.name}_sampler : sampler_comparison;`):n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${c.name}_sampler : sampler;`));let d,f="",{primarySamples:p}=this.renderer.backend.utils.getTextureSampleData(h);if(p>1&&(f="_multisampled"),h.isCubeTexture===!0)d="texture_cube";else if(h.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&h.compareFunction===null?d=`texture${f}_2d`:d=`texture_depth${f}_2d${h.isArrayTexture===!0?"_array":""}`;else if(c.node.isStorageTextureNode===!0){let m=qT(h),_=this.getStorageAccess(c.node,e),y=c.node.value.is3DTexture,x=c.node.value.isArrayTexture;d=`texture_storage_${y?"3d":`2d${x?"_array":""}`}<${m}, ${_}>`}else if(h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0)d="texture_2d_array";else if(h.is3DTexture===!0||h.isData3DTexture===!0)d="texture_3d";else{let m=this.getComponentTypeFromTexture(h).charAt(0);d=`texture${f}_2d<${m}32>`}n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${c.name} : ${d};`)}else if(c.type==="buffer"||c.type==="storageBuffer"||c.type==="indirectStorageBuffer"){let h=c.node,d=this.getType(h.getNodeType(this)),f=h.bufferCount,p=f>0&&c.type==="buffer"?", "+f:"",m=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(c))i.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var<${m}> ${c.name} : ${d};`);else{let y=` value : array< ${h.isAtomic?`atomic<${d}>`:`${d}`}${p} >`;i.push(this._getWGSLStructBinding(c.name,y,m,u.binding++,u.group))}}else{let h=this.getType(this.getVectorType(c.type)),d=c.groupNode.name;(r[d]||(r[d]={index:u.binding++,id:u.group,snippets:[]})).snippets.push(` ${c.name} : ${h}`)}}for(let c in r){let l=r[c];s.push(this._getWGSLStructBinding(c,l.snippets.join(`, `),"uniform",l.index,l.id))}let a=n.join(` `);return a+=i.join(` `),a+=s.join(` `),a}buildCode(){let e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let i=`// code `;i+=this.flowCode[t];let s=this.flowNodes[t],r=s[s.length-1],a=r.outputNode,c=a!==void 0&&a.isOutputStructNode===!0;for(let l of s){let u=this.getFlowData(l),h=l.name;if(h&&(i.length>0&&(i+=` `),i+=` // flow -> ${h} `),i+=`${u.code} `,l===r&&t!=="compute"){if(i+=`// result `,t==="vertex")i+=`varyings.Vertex = ${u.result};`;else if(t==="fragment")if(c)n.returnType=a.getNodeType(this),n.structs+="var output : "+n.returnType+";",i+=`return ${u.result};`;else{let d=" @location(0) color: vec4",f=this.getBuiltins("output");f&&(d+=`, `+f),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",d),n.structs+=` var output : OutputStruct;`,i+=`output.color = ${u.result}; return output;`}}}n.flow=i}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return GO[e]||e}isAvailable(e){let t=QE[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),QE[e]=t),t}_getWGSLMethod(e){return Hd[e]!==void 0&&this._include(e),kO[e]}_include(e){let t=Hd[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} // directives ${e.directives} // structs ${e.structs} // uniforms ${e.uniforms} // varyings ${e.varyings} var varyings : VaryingsStruct; // codes ${e.codes} @vertex fn main( ${e.attributes} ) -> VaryingsStruct { // vars ${e.vars} // flow ${e.flow} return varyings; } `}_getWGSLFragmentCode(e){return`${this.getSignature()} // global ${r1} // structs ${e.structs} // uniforms ${e.uniforms} // codes ${e.codes} @fragment fn main( ${e.varyings} ) -> ${e.returnType} { // vars ${e.vars} // flow ${e.flow} } `}_getWGSLComputeCode(e,t){let[n,i,s]=t;return`${this.getSignature()} // directives ${e.directives} // system var instanceIndex : u32; // locals ${e.scopedArrays} // structs ${e.structs} // uniforms ${e.uniforms} // codes ${e.codes} @compute @workgroup_size( ${n}, ${i}, ${s} ) fn main( ${e.attributes} ) { // system instanceIndex = globalId.x + globalId.y * ( ${n} * numWorkgroups.x ) + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y ); // vars ${e.vars} // flow ${e.flow} } `}_getWGSLStruct(e,t){return` struct ${e} { ${t} };`}_getWGSLStructBinding(e,t,n,i=0,s=0){let r=e+"Struct";return`${this._getWGSLStruct(r,t)} @binding( ${i} ) @group( ${s} ) var<${n}> ${e} : ${r};`}},jT=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=C.Depth24PlusStencil8:e.depth&&(t=C.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let s=this.backend.renderer,r=s.getRenderTarget();t=r?r.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return _u.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return _u.LineList;if(e.isLine)return _u.LineStrip;if(e.isMesh)return _u.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===Ot)return C.BGRA8Unorm;if(e===ft)return C.RGBA16Float;throw new Error("Unsupported outputType")}},o1=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array!="undefined"&&o1.set(Float16Array,["float16"]);var zO=new Map([[Vo,["float16"]]]),HO=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]),ZT=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),i=this.backend,s=i.get(n),r=s.buffer;if(r===void 0){let a=i.device,c=n.array;if(e.normalized===!1){if(c.constructor===Int16Array||c.constructor===Int8Array)c=new Int32Array(c);else if((c.constructor===Uint16Array||c.constructor===Uint8Array)&&(c=new Uint32Array(c),t&GPUBufferUsage.INDEX))for(let h=0;h1&&(c.multisampled=!0,r.texture.isDepthTexture||(c.sampleType=fc.UnfilterableFloat)),r.texture.isDepthTexture)t.compatibilityMode&&r.texture.compareFunction===null?c.sampleType=fc.UnfilterableFloat:c.sampleType=fc.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){let u=r.texture.type;u===Vt?c.sampleType=fc.SInt:u===Je?c.sampleType=fc.UInt:u===nt&&(this.backend.hasFeature("float32-filterable")?c.sampleType=fc.Float:c.sampleType=fc.UnfilterableFloat)}r.isSampledCubeTexture?c.viewDimension=Pt.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?c.viewDimension=Pt.TwoDArray:r.isSampledTexture3D&&(c.viewDimension=Pt.ThreeD),a.texture=c}else if(r.isSampler){let c={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null?c.type=KE.Comparison:t.compatibilityMode&&(c.type=KE.NonFiltering)),a.sampler=c}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);i.push(a)}return n.createBindGroupLayout({entries:i})}createBindings(e,t,n,i=0){let{backend:s,bindGroupLayoutCache:r}=this,a=s.get(e),c=r.get(e.bindingsReference);c===void 0&&(c=this.createBindingsLayout(e),r.set(e.bindingsReference,c));let l;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===i&&(l=a.groups[n])),l===void 0&&(l=this.createBindGroup(e,c),n>0&&(a.groups[n]=l,a.versions[n]=i)),a.group=l,a.layout=c}updateBinding(e){let t=this.backend,n=t.device,i=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,i,0)}createBindGroupIndex(e,t){let i=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,r=e[0],a=i.createBuffer({label:"bindingCameraIndex_"+r,size:16,usage:s});i.queue.writeBuffer(a,0,e,0);let c=[{binding:0,resource:{buffer:a}}];return i.createBindGroup({label:"bindGroupCameraIndex_"+r,layout:t,entries:c})}createBindGroup(e,t){let n=this.backend,i=n.device,s=0,r=[];for(let a of e.bindings){if(a.isUniformBuffer){let c=n.get(a);if(c.buffer===void 0){let l=a.byteLength,u=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,h=i.createBuffer({label:"bindingBuffer_"+a.name,size:l,usage:u});c.buffer=h}r.push({binding:s,resource:{buffer:c.buffer}})}else if(a.isStorageBuffer){let c=n.get(a);if(c.buffer===void 0){let l=a.attribute;c.buffer=n.get(l).buffer}r.push({binding:s,resource:{buffer:c.buffer}})}else if(a.isSampledTexture){let c=n.get(a.texture),l;if(c.externalTexture!==void 0)l=i.importExternalTexture({source:c.externalTexture});else{let u=a.store?1:c.texture.mipLevelCount,h=`view-${c.texture.width}-${c.texture.height}`;if(c.texture.depthOrArrayLayers>1&&(h+=`-${c.texture.depthOrArrayLayers}`),h+=`-${u}`,l=c[h],l===void 0){let d=PO.All,f;a.isSampledCubeTexture?f=Pt.Cube:a.isSampledTexture3D?f=Pt.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?f=Pt.TwoDArray:f=Pt.TwoD,l=c[h]=c.texture.createView({aspect:d,dimension:f,mipLevelCount:u})}}r.push({binding:s,resource:l})}else if(a.isSampler){let c=n.get(a.texture);r.push({binding:s,resource:c.sampler})}s++}return i.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:r})}},QT=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:i,geometry:s,pipeline:r}=e,{vertexProgram:a,fragmentProgram:c}=r,l=this.backend,u=l.device,h=l.utils,d=l.get(r),f=[];for(let W of e.getBindings()){let X=l.get(W);f.push(X.layout)}let p=l.attributeUtils.createShaderVertexBuffers(e),m;i.blending!==ss&&(i.blending!==ri||i.transparent!==!1)&&(m=this._getBlending(i));let _={};i.stencilWrite===!0&&(_={compare:this._getStencilCompare(i),failOp:this._getStencilOperation(i.stencilFail),depthFailOp:this._getStencilOperation(i.stencilZFail),passOp:this._getStencilOperation(i.stencilZPass)});let y=this._getColorWriteMask(i),x=[];if(e.context.textures!==null){let W=e.context.textures;for(let X=0;X1},layout:u.createPipelineLayout({bindGroupLayouts:f})},L={},V=e.context.depth,H=e.context.stencil;if((V===!0||H===!0)&&(V===!0&&(L.format=E,L.depthWriteEnabled=i.depthWrite,L.depthCompare=w),H===!0&&(L.stencilFront=_,L.stencilBack={},L.stencilReadMask=i.stencilFuncMask,L.stencilWriteMask=i.stencilWriteMask),i.polygonOffset===!0&&(L.depthBias=i.polygonOffsetUnits,L.depthBiasSlopeScale=i.polygonOffsetFactor,L.depthBiasClamp=0),N.depthStencil=L),t===null)d.pipeline=u.createRenderPipeline(N);else{let W=new Promise(X=>{u.createRenderPipelineAsync(N).then(ae=>{d.pipeline=ae,X()})});t.push(W)}}createBundleEncoder(e,t="renderBundleEncoder"){let n=this.backend,{utils:i,device:s}=n,r=i.getCurrentDepthStencilFormat(e),a=i.getCurrentColorFormat(e),c=this._getSampleCount(e),l={label:t,colorFormats:[a],depthStencilFormat:r,sampleCount:c};return s.createRenderBundleEncoder(l)}createComputePipeline(e,t){let n=this.backend,i=n.device,s=n.get(e.computeProgram).module,r=n.get(e),a=[];for(let c of t){let l=n.get(c);a.push(l.layout)}r.pipeline=i.createComputePipeline({compute:s,layout:i.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,n,i=e.blending,s=e.blendSrc,r=e.blendDst,a=e.blendEquation;if(i===kr){let c=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,l=e.blendDstAlpha!==null?e.blendDstAlpha:r,u=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(r),operation:this._getBlendOperation(a)},n={srcFactor:this._getBlendFactor(c),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(u)}}else{let c=e.premultipliedAlpha,l=(u,h,d,f)=>{t={srcFactor:u,dstFactor:h,operation:dc.Add},n={srcFactor:d,dstFactor:f,operation:dc.Add}};if(c)switch(i){case ri:l(Re.One,Re.OneMinusSrcAlpha,Re.One,Re.OneMinusSrcAlpha);break;case va:l(Re.One,Re.One,Re.One,Re.One);break;case Ta:l(Re.Zero,Re.OneMinusSrc,Re.Zero,Re.One);break;case ba:l(Re.Dst,Re.OneMinusSrcAlpha,Re.Zero,Re.One);break}else switch(i){case ri:l(Re.SrcAlpha,Re.OneMinusSrcAlpha,Re.One,Re.OneMinusSrcAlpha);break;case va:l(Re.SrcAlpha,Re.One,Re.One,Re.One);break;case Ta:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ba:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case Vi:t=Re.Zero;break;case cd:t=Re.One;break;case ld:t=Re.Src;break;case ud:t=Re.OneMinusSrc;break;case No:t=Re.SrcAlpha;break;case Po:t=Re.OneMinusSrcAlpha;break;case fd:t=Re.Dst;break;case pd:t=Re.OneMinusDst;break;case hd:t=Re.DstAlpha;break;case dd:t=Re.OneMinusDstAlpha;break;case md:t=Re.SrcAlphaSaturated;break;case nF:t=Re.Constant;break;case iF:t=Re.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case bm:t=Jt.Never;break;case il:t=Jt.Always;break;case Sm:t=Jt.Less;break;case Am:t=Jt.LessEqual;break;case Mm:t=Jt.Equal;break;case Rm:t=Jt.GreaterEqual;break;case Em:t=Jt.Greater;break;case wm:t=Jt.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Ji:t=Zr.Keep;break;case mm:t=Zr.Zero;break;case gm:t=Zr.Replace;break;case Tm:t=Zr.Invert;break;case _m:t=Zr.IncrementClamp;break;case ym:t=Zr.DecrementClamp;break;case xm:t=Zr.IncrementWrap;break;case vm:t=Zr.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Rn:t=dc.Add;break;case od:t=dc.Subtract;break;case ad:t=dc.ReverseSubtract;break;case Kp:t=dc.Min;break;case jp:t=dc.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){let i={},s=this.backend.utils;i.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?Uu.Uint16:Uu.Uint32);let r=n.side===Nt;return e.isMesh&&e.matrixWorld.determinant()<0&&(r=!r),i.frontFace=r===!0?qE.CW:qE.CCW,i.cullMode=n.side===fi?$E.None:$E.Back,i}_getColorWriteMask(e){return e.colorWrite===!0?YE.All:YE.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Jt.Always;else{let n=e.depthFunc;switch(n){case Sa:t=Jt.Never;break;case Ma:t=Jt.Always;break;case Aa:t=Jt.Less;break;case Gs:t=Jt.LessEqual;break;case Ea:t=Jt.Equal;break;case wa:t=Jt.GreaterEqual;break;case Ra:t=Jt.Greater;break;case Ca:t=Jt.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}},eb=class extends dy{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let i=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return _n(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let i=this.device.createCommandEncoder();i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let s=i.finish();if(this.device.queue.submit([s]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let r=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),a=0;for(let[,c]of e){let l=r[c],u=r[c+1],h=Number(u-l)/1e6;a+=h}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},tb=class extends hy{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new jT(this),this.attributeUtils=new ZT(this),this.bindingUtils=new JT(this),this.pipelineUtils=new QT(this),this.textureUtils=new XT(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let a={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},c=typeof navigator!="undefined"?await navigator.gpu.requestAdapter(a):null;if(c===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");let l=Object.values(GT),u=[];for(let d of l)c.features.has(d)&&u.push(d);let h={requiredFeatures:u,requiredLimits:t.requiredLimits};n=await c.requestDevice(h)}else n=t.device;n.lost.then(a=>{let c={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(c)});let i=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=i;let s=t.alpha?"premultiplied":"opaque",r=xe.getToneMappingMode(this.renderer.outputColorSpace);this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:r}}),this.trackTimestamp=this.trackTimestamp&&this.hasFeature(GT.TimestampQuery),this.updateSize()}get coordinateSystem(){return Nn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});let i=e.colorAttachments[0];this.renderer.samples>0?i.view=this.colorBuffer.createView():i.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,i=this.get(n),s=i.descriptors;(s===void 0||i.width!==n.width||i.height!==n.height||i.samples!==n.samples)&&(s={},i.descriptors=s);let r=e.getCacheKey(),a=s[r];if(a===void 0){let l=e.textures,u=[],h,d=this._isRenderCameraDepthArray(e);for(let f=0;f1)if(d===!0){let _=e.camera.cameras;for(let y=0;y<_.length;y++){let x={...m,baseArrayLayer:y,arrayLayerCount:1,dimension:Pt.TwoD},v=p.texture.createView(x);u.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Pt.TwoDArray,m.depthOrArrayLayers=l[f].image.depth;if(d!==!0){let _=p.texture.createView(m),y,x;p.msaaTexture!==void 0?(y=p.msaaTexture.createView(),x=_):(y=_,x=void 0),u.push({view:y,resolveTarget:x,depthSlice:h})}}if(a={textureViews:u},e.depth){let f=this.get(e.depthTexture),p={};e.depthTexture.isArrayTexture&&(p.dimension=Pt.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=e.activeCubeFace),a.depthStencilView=f.texture.createView(p)}s[r]=a,i.width=n.width,i.height=n.height,i.samples=n.samples,i.activeMipmapLevel=e.activeMipmapLevel,i.activeCubeFace=e.activeCubeFace}let c={colorAttachments:[]};for(let l=0;l0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:i,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(i),t.lastOcclusionObject=null);let r;e.textures===null?r=this._getDefaultRenderPassDescriptor():r=this._getRenderPassDescriptor(e,{loadOp:Be.Load}),this.initTimestampQuery(tr.RENDER,this.getTimestampUID(e),r),r.occlusionQuerySet=s;let a=r.depthStencilAttachment;if(e.textures!==null){let l=r.colorAttachments;for(let u=0;u0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let i=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let s=[];for(let r=0;r0){let s=n*8,r=this.occludedResolveCache.get(s);r===void 0&&(r=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,r));let a=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,r,0),t.encoder.copyBufferToBuffer(r,0,a,0,s),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let s=e.textures;for(let r=0;rp&&(l[0]=Math.min(f,p),l[1]=Math.ceil(f/p)),r.dispatchSize=l}l=r.dispatchSize}else l=s;a.dispatchWorkgroups(l[0],l[1]||1,l[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:i,context:s,pipeline:r}=e,a=e.getBindings(),c=this.get(s),l=this.get(r).pipeline,u=e.getIndex(),h=u!==null,d=e.getDrawParameters();if(d===null)return;let f=(m,_)=>{this.pipelineUtils.setPipeline(m,l),_.pipeline=l;let y=_.bindingGroups;for(let v=0,T=a.length;v{if(f(m,_),n.isBatchedMesh===!0){let y=n._multiDrawStarts,x=n._multiDrawCounts,v=n._multiDrawCount,T=n._multiDrawInstances;T!==null&&_n("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let M=0;M1?0:M;h===!0?m.drawIndexed(x[M],w,y[M]/u.array.BYTES_PER_ELEMENT,0,E):m.draw(x[M],w,y[M],E),t.update(n,x[M],w)}}else if(h===!0){let{vertexCount:y,instanceCount:x,firstVertex:v}=d,T=e.getIndirect();if(T!==null){let M=this.get(T).buffer;m.drawIndexedIndirect(M,0)}else m.drawIndexed(y,x,v,0,0);t.update(n,y,x)}else{let{vertexCount:y,instanceCount:x,firstVertex:v}=d,T=e.getIndirect();if(T!==null){let M=this.get(T).buffer;m.drawIndirect(M,0)}else m.draw(y,x,v,0);t.update(n,y,x)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let m=this.get(e.camera),_=e.camera.cameras,y=e.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==_.length){let v=this.get(y),T=[],M=new Uint32Array([0,0,0,0]);for(let w=0,E=_.length;w(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new fy(e)));let n=new t(e);super(n,e),this.library=new nb,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},sb=class extends rn{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}},rb=class{constructor(e,t=Y(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;let n=new qe;n.name="PostProcessing",this._quadMesh=new ao(n),this._context=null}render(){let e=this.renderer;this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();let t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=Gi,e.outputColorSpace=xe.workingColorSpace;let i=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=i,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this.needsUpdate===!0){let e=this.renderer,t=e.toneMapping,n=e.outputColorSpace,i={postProcessing:this,onBeforePostProcessing:null,onAfterPostProcessing:null},s=this.outputNode;this.outputColorTransform===!0?(s=s.context(i),s=Yb(s,t,n)):(i.toneMapping=t,i.outputColorSpace=n,s=s.context(i)),this._context=i,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();let e=this.renderer,t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=Gi,e.outputColorSpace=xe.workingColorSpace;let i=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=i,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()}},ob=class extends Ge{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=Ae,this.minFilter=Ae,this.isStorageTexture=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}},ab=class extends Ge{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:n},this.magFilter=Ae,this.minFilter=Ae,this.wrapR=Dt,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}},cb=class extends Ge{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:n},this.magFilter=Ae,this.minFilter=Ae,this.isStorageTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}},lb=class extends Cf{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}},gy=class extends Mt{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,i){let s=new jt(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{try{t(this.parse(JSON.parse(r)))}catch(a){i?i(a):console.error(a),this.manager.itemError(e)}},n,i)}parseNodes(e){let t={};if(e!==void 0){for(let i of e){let{uuid:s,type:r}=i;t[s]=this.createNodeFromType(r),t[s].uuid=s}let n={nodes:t,textures:this.textures};for(let i of e)i.meta=n,t[i.uuid].deserialize(i),delete i.meta}return t}parse(e){let t=this.createNodeFromType(e.type);t.uuid=e.uuid;let i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,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),b()):U(new this.nodes[e])}},_y=class extends fa{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){let t=super.parse(e),n=this.nodes,i=e.inputNodes;for(let s in i){let r=i[s];t[s]=n[r]}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?new t:super.createMaterialFromType(e)}},ub=class extends zl{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 gy;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){let n={};if(e!==void 0){let i=this.parseNodes(this._nodesJSON,t),s=new _y;s.setTextures(t),s.setNodes(i),s.setNodeMaterials(this.nodeMaterials);for(let r=0,a=e.length;rWO,BRDF_Lambert:()=>XO,BasicPointShadowFilter:()=>qO,BasicShadowFilter:()=>$O,Break:()=>YO,Const:()=>KO,Continue:()=>jO,DFGApprox:()=>ZO,D_GGX:()=>JO,Discard:()=>QO,EPSILON:()=>e3,F_Schlick:()=>t3,Fn:()=>n3,INFINITY:()=>i3,If:()=>s3,Loop:()=>r3,NodeAccess:()=>o3,NodeShaderStage:()=>a3,NodeType:()=>c3,NodeUpdateType:()=>l3,OnMaterialUpdate:()=>lW,OnObjectUpdate:()=>cW,PCFShadowFilter:()=>u3,PCFSoftShadowFilter:()=>h3,PI:()=>d3,PI2:()=>f3,PointShadowFilter:()=>p3,Return:()=>m3,Schlick_to_F0:()=>g3,ScriptableNodeResources:()=>_3,ShaderNode:()=>y3,Stack:()=>x3,Switch:()=>v3,TBNViewMatrix:()=>T3,VSMShadowFilter:()=>b3,V_GGX_SmithCorrelated:()=>S3,Var:()=>M3,VarIntent:()=>A3,abs:()=>E3,acesFilmicToneMapping:()=>w3,acos:()=>R3,add:()=>C3,addMethodChaining:()=>N3,addNodeElement:()=>P3,agxToneMapping:()=>I3,all:()=>L3,alphaT:()=>D3,and:()=>F3,anisotropy:()=>U3,anisotropyB:()=>B3,anisotropyT:()=>O3,any:()=>V3,append:()=>G3,array:()=>k3,arrayBuffer:()=>z3,asin:()=>H3,assign:()=>W3,atan:()=>X3,atan2:()=>q3,atomicAdd:()=>$3,atomicAnd:()=>Y3,atomicFunc:()=>K3,atomicLoad:()=>j3,atomicMax:()=>Z3,atomicMin:()=>J3,atomicOr:()=>Q3,atomicStore:()=>eV,atomicSub:()=>tV,atomicXor:()=>nV,attenuationColor:()=>iV,attenuationDistance:()=>sV,attribute:()=>rV,attributeArray:()=>oV,backgroundBlurriness:()=>aV,backgroundIntensity:()=>cV,backgroundRotation:()=>lV,batch:()=>uV,bentNormalView:()=>hV,billboarding:()=>dV,bitAnd:()=>fV,bitNot:()=>pV,bitOr:()=>mV,bitXor:()=>gV,bitangentGeometry:()=>_V,bitangentLocal:()=>yV,bitangentView:()=>xV,bitangentWorld:()=>vV,bitcast:()=>TV,blendBurn:()=>bV,blendColor:()=>SV,blendDodge:()=>MV,blendOverlay:()=>AV,blendScreen:()=>EV,blur:()=>wV,bool:()=>RV,buffer:()=>CV,bufferAttribute:()=>NV,builtin:()=>LV,bumpMap:()=>PV,burn:()=>IV,bvec2:()=>DV,bvec3:()=>FV,bvec4:()=>UV,bypass:()=>BV,cache:()=>OV,call:()=>VV,cameraFar:()=>GV,cameraIndex:()=>kV,cameraNear:()=>zV,cameraNormalMatrix:()=>HV,cameraPosition:()=>WV,cameraProjectionMatrix:()=>XV,cameraProjectionMatrixInverse:()=>qV,cameraViewMatrix:()=>$V,cameraViewport:()=>YV,cameraWorldMatrix:()=>KV,cbrt:()=>jV,cdl:()=>ZV,ceil:()=>JV,checker:()=>QV,cineonToneMapping:()=>eG,clamp:()=>tG,clearcoat:()=>nG,clearcoatNormalView:()=>iG,clearcoatRoughness:()=>sG,code:()=>rG,color:()=>oG,colorSpaceToWorking:()=>aG,colorToDirection:()=>cG,compute:()=>lG,computeKernel:()=>uG,computeSkinning:()=>hG,context:()=>dG,convert:()=>fG,convertColorSpace:()=>pG,convertToTexture:()=>mG,cos:()=>gG,cross:()=>_G,cubeTexture:()=>yG,cubeTextureBase:()=>xG,cubeToUV:()=>vG,dFdx:()=>TG,dFdy:()=>bG,dashSize:()=>SG,debug:()=>MG,decrement:()=>AG,decrementBefore:()=>EG,defaultBuildStages:()=>wG,defaultShaderStages:()=>RG,defined:()=>CG,degrees:()=>NG,deltaTime:()=>PG,densityFog:()=>IG,densityFogFactor:()=>LG,depth:()=>DG,depthPass:()=>FG,determinant:()=>UG,difference:()=>BG,diffuseColor:()=>OG,directPointLight:()=>VG,directionToColor:()=>GG,directionToFaceDirection:()=>kG,dispersion:()=>zG,distance:()=>HG,div:()=>WG,dodge:()=>XG,dot:()=>qG,drawIndex:()=>$G,dynamicBufferAttribute:()=>YG,element:()=>KG,emissive:()=>jG,equal:()=>ZG,equals:()=>JG,equirectUV:()=>QG,exp:()=>ek,exp2:()=>tk,expression:()=>nk,faceDirection:()=>ik,faceForward:()=>sk,faceforward:()=>rk,float:()=>ok,floatBitsToInt:()=>ak,floatBitsToUint:()=>ck,floor:()=>lk,fog:()=>uk,fract:()=>hk,frameGroup:()=>dk,frameId:()=>fk,frontFacing:()=>pk,fwidth:()=>mk,gain:()=>gk,gapSize:()=>_k,getConstNodeType:()=>yk,getCurrentStack:()=>xk,getDirection:()=>vk,getDistanceAttenuation:()=>Tk,getGeometryRoughness:()=>bk,getNormalFromDepth:()=>Sk,getParallaxCorrectNormal:()=>Mk,getRoughness:()=>Ak,getScreenPosition:()=>Ek,getShIrradianceAt:()=>wk,getShadowMaterial:()=>Rk,getShadowRenderObjectFunction:()=>Ck,getTextureIndex:()=>Nk,getViewPosition:()=>Pk,globalId:()=>Ik,glsl:()=>Lk,glslFn:()=>Dk,grayscale:()=>Fk,greaterThan:()=>Uk,greaterThanEqual:()=>Bk,hash:()=>Ok,highpModelNormalViewMatrix:()=>Vk,highpModelViewMatrix:()=>Gk,hue:()=>kk,increment:()=>zk,incrementBefore:()=>Hk,instance:()=>Wk,instanceIndex:()=>Xk,instancedArray:()=>qk,instancedBufferAttribute:()=>$k,instancedDynamicBufferAttribute:()=>Yk,instancedMesh:()=>Kk,int:()=>jk,intBitsToFloat:()=>Zk,inverse:()=>Jk,inverseSqrt:()=>Qk,inversesqrt:()=>ez,invocationLocalIndex:()=>tz,invocationSubgroupIndex:()=>nz,ior:()=>iz,iridescence:()=>sz,iridescenceIOR:()=>rz,iridescenceThickness:()=>oz,ivec2:()=>az,ivec3:()=>cz,ivec4:()=>lz,js:()=>uz,label:()=>hz,length:()=>dz,lengthSq:()=>fz,lessThan:()=>pz,lessThanEqual:()=>mz,lightPosition:()=>gz,lightProjectionUV:()=>_z,lightShadowMatrix:()=>yz,lightTargetDirection:()=>xz,lightTargetPosition:()=>vz,lightViewPosition:()=>Tz,lightingContext:()=>bz,lights:()=>Sz,linearDepth:()=>Mz,linearToneMapping:()=>Az,localId:()=>Ez,log:()=>wz,log2:()=>Rz,logarithmicDepthToViewZ:()=>Cz,luminance:()=>Nz,mat2:()=>Pz,mat3:()=>Iz,mat4:()=>Lz,matcapUV:()=>Dz,materialAO:()=>Fz,materialAlphaTest:()=>Uz,materialAnisotropy:()=>Bz,materialAnisotropyVector:()=>Oz,materialAttenuationColor:()=>Vz,materialAttenuationDistance:()=>Gz,materialClearcoat:()=>kz,materialClearcoatNormal:()=>zz,materialClearcoatRoughness:()=>Hz,materialColor:()=>Wz,materialDispersion:()=>Xz,materialEmissive:()=>qz,materialEnvIntensity:()=>$z,materialEnvRotation:()=>Yz,materialIOR:()=>Kz,materialIridescence:()=>jz,materialIridescenceIOR:()=>Zz,materialIridescenceThickness:()=>Jz,materialLightMap:()=>Qz,materialLineDashOffset:()=>eH,materialLineDashSize:()=>tH,materialLineGapSize:()=>nH,materialLineScale:()=>iH,materialLineWidth:()=>sH,materialMetalness:()=>rH,materialNormal:()=>oH,materialOpacity:()=>aH,materialPointSize:()=>cH,materialReference:()=>lH,materialReflectivity:()=>uH,materialRefractionRatio:()=>hH,materialRotation:()=>dH,materialRoughness:()=>fH,materialSheen:()=>pH,materialSheenRoughness:()=>mH,materialShininess:()=>gH,materialSpecular:()=>_H,materialSpecularColor:()=>yH,materialSpecularIntensity:()=>xH,materialSpecularStrength:()=>vH,materialThickness:()=>TH,materialTransmission:()=>bH,max:()=>SH,maxMipLevel:()=>MH,mediumpModelViewMatrix:()=>AH,metalness:()=>EH,min:()=>wH,mix:()=>RH,mixElement:()=>CH,mod:()=>NH,modInt:()=>PH,modelDirection:()=>IH,modelNormalMatrix:()=>LH,modelPosition:()=>DH,modelRadius:()=>FH,modelScale:()=>UH,modelViewMatrix:()=>BH,modelViewPosition:()=>OH,modelViewProjection:()=>VH,modelWorldMatrix:()=>GH,modelWorldMatrixInverse:()=>kH,morphReference:()=>zH,mrt:()=>HH,mul:()=>WH,mx_aastep:()=>XH,mx_add:()=>qH,mx_atan2:()=>$H,mx_cell_noise_float:()=>YH,mx_contrast:()=>KH,mx_divide:()=>jH,mx_fractal_noise_float:()=>ZH,mx_fractal_noise_vec2:()=>JH,mx_fractal_noise_vec3:()=>QH,mx_fractal_noise_vec4:()=>e4,mx_frame:()=>t4,mx_heighttonormal:()=>n4,mx_hsvtorgb:()=>i4,mx_ifequal:()=>s4,mx_ifgreater:()=>r4,mx_ifgreatereq:()=>o4,mx_invert:()=>a4,mx_modulo:()=>c4,mx_multiply:()=>l4,mx_noise_float:()=>u4,mx_noise_vec3:()=>h4,mx_noise_vec4:()=>d4,mx_place2d:()=>f4,mx_power:()=>p4,mx_ramp4:()=>m4,mx_ramplr:()=>g4,mx_ramptb:()=>_4,mx_rgbtohsv:()=>y4,mx_rotate2d:()=>x4,mx_rotate3d:()=>v4,mx_safepower:()=>T4,mx_separate:()=>b4,mx_splitlr:()=>S4,mx_splittb:()=>M4,mx_srgb_texture_to_lin_rec709:()=>A4,mx_subtract:()=>E4,mx_timer:()=>w4,mx_transform_uv:()=>R4,mx_unifiednoise2d:()=>C4,mx_unifiednoise3d:()=>N4,mx_worley_noise_float:()=>P4,mx_worley_noise_vec2:()=>I4,mx_worley_noise_vec3:()=>L4,negate:()=>D4,neutralToneMapping:()=>F4,nodeArray:()=>U4,nodeImmutable:()=>B4,nodeObject:()=>O4,nodeObjectIntent:()=>V4,nodeObjects:()=>G4,nodeProxy:()=>k4,nodeProxyIntent:()=>z4,normalFlat:()=>H4,normalGeometry:()=>W4,normalLocal:()=>X4,normalMap:()=>q4,normalView:()=>$4,normalViewGeometry:()=>Y4,normalWorld:()=>K4,normalWorldGeometry:()=>j4,normalize:()=>Z4,not:()=>J4,notEqual:()=>Q4,numWorkgroups:()=>eW,objectDirection:()=>tW,objectGroup:()=>nW,objectPosition:()=>iW,objectRadius:()=>sW,objectScale:()=>rW,objectViewPosition:()=>oW,objectWorldMatrix:()=>aW,oneMinus:()=>uW,or:()=>hW,orthographicDepthToViewZ:()=>dW,oscSawtooth:()=>fW,oscSine:()=>pW,oscSquare:()=>mW,oscTriangle:()=>gW,output:()=>_W,outputStruct:()=>yW,overlay:()=>xW,overloadingFn:()=>vW,parabola:()=>TW,parallaxDirection:()=>bW,parallaxUV:()=>SW,parameter:()=>MW,pass:()=>AW,passTexture:()=>EW,pcurve:()=>wW,perspectiveDepthToViewZ:()=>RW,pmremTexture:()=>CW,pointShadow:()=>NW,pointUV:()=>PW,pointWidth:()=>IW,positionGeometry:()=>LW,positionLocal:()=>DW,positionPrevious:()=>FW,positionView:()=>UW,positionViewDirection:()=>BW,positionWorld:()=>OW,positionWorldDirection:()=>VW,posterize:()=>GW,pow:()=>kW,pow2:()=>zW,pow3:()=>HW,pow4:()=>WW,premultiplyAlpha:()=>XW,property:()=>qW,radians:()=>$W,rand:()=>YW,range:()=>KW,rangeFog:()=>jW,rangeFogFactor:()=>ZW,reciprocal:()=>JW,reference:()=>QW,referenceBuffer:()=>e5,reflect:()=>t5,reflectVector:()=>n5,reflectView:()=>i5,reflector:()=>s5,refract:()=>r5,refractVector:()=>o5,refractView:()=>a5,reinhardToneMapping:()=>c5,remap:()=>l5,remapClamp:()=>u5,renderGroup:()=>h5,renderOutput:()=>d5,rendererReference:()=>f5,rotate:()=>p5,rotateUV:()=>m5,roughness:()=>g5,round:()=>_5,rtt:()=>y5,sRGBTransferEOTF:()=>x5,sRGBTransferOETF:()=>v5,sample:()=>T5,sampler:()=>b5,samplerComparison:()=>S5,saturate:()=>M5,saturation:()=>A5,screen:()=>E5,screenCoordinate:()=>w5,screenDPR:()=>R5,screenSize:()=>C5,screenUV:()=>N5,scriptable:()=>P5,scriptableValue:()=>I5,select:()=>L5,setCurrentStack:()=>D5,setName:()=>F5,shaderStages:()=>U5,shadow:()=>B5,shadowPositionWorld:()=>O5,shapeCircle:()=>V5,sharedUniformGroup:()=>G5,sheen:()=>k5,sheenRoughness:()=>z5,shiftLeft:()=>H5,shiftRight:()=>W5,shininess:()=>X5,sign:()=>q5,sin:()=>$5,sinc:()=>Y5,skinning:()=>K5,smoothstep:()=>j5,smoothstepElement:()=>Z5,specularColor:()=>J5,specularF90:()=>Q5,spherizeUV:()=>e6,split:()=>t6,spritesheetUV:()=>n6,sqrt:()=>i6,stack:()=>s6,step:()=>r6,stepElement:()=>o6,storage:()=>a6,storageBarrier:()=>c6,storageObject:()=>l6,storageTexture:()=>u6,string:()=>h6,struct:()=>d6,sub:()=>f6,subBuild:()=>T6,subgroupAdd:()=>p6,subgroupAll:()=>m6,subgroupAnd:()=>g6,subgroupAny:()=>_6,subgroupBallot:()=>y6,subgroupBroadcast:()=>x6,subgroupBroadcastFirst:()=>v6,subgroupElect:()=>b6,subgroupExclusiveAdd:()=>S6,subgroupExclusiveMul:()=>M6,subgroupInclusiveAdd:()=>A6,subgroupInclusiveMul:()=>E6,subgroupIndex:()=>w6,subgroupMax:()=>R6,subgroupMin:()=>C6,subgroupMul:()=>N6,subgroupOr:()=>P6,subgroupShuffle:()=>I6,subgroupShuffleDown:()=>L6,subgroupShuffleUp:()=>D6,subgroupShuffleXor:()=>F6,subgroupSize:()=>U6,subgroupXor:()=>B6,tan:()=>O6,tangentGeometry:()=>V6,tangentLocal:()=>G6,tangentView:()=>k6,tangentWorld:()=>z6,texture:()=>H6,texture3D:()=>W6,textureBarrier:()=>X6,textureBicubic:()=>q6,textureBicubicLevel:()=>$6,textureCubeUV:()=>Y6,textureLoad:()=>K6,textureSize:()=>j6,textureStore:()=>Z6,thickness:()=>J6,time:()=>Q6,toneMapping:()=>e8,toneMappingExposure:()=>t8,toonOutlinePass:()=>n8,transformDirection:()=>i8,transformNormal:()=>s8,transformNormalToView:()=>r8,transformedClearcoatNormalView:()=>o8,transformedNormalView:()=>a8,transformedNormalWorld:()=>c8,transmission:()=>l8,transpose:()=>u8,triNoise3D:()=>h8,triplanarTexture:()=>d8,triplanarTextures:()=>f8,trunc:()=>p8,uint:()=>m8,uintBitsToFloat:()=>g8,uniform:()=>_8,uniformArray:()=>y8,uniformCubeTexture:()=>x8,uniformFlow:()=>T8,uniformGroup:()=>v8,uniformTexture:()=>b8,unpremultiplyAlpha:()=>S8,userData:()=>M8,uv:()=>A8,uvec2:()=>E8,uvec3:()=>w8,uvec4:()=>R8,varying:()=>C8,varyingProperty:()=>N8,vec2:()=>P8,vec3:()=>I8,vec4:()=>L8,vectorComponents:()=>D8,velocity:()=>F8,vertexColor:()=>U8,vertexIndex:()=>B8,vertexStage:()=>O8,vibrance:()=>V8,viewZToLogarithmicDepth:()=>G8,viewZToOrthographicDepth:()=>k8,viewZToPerspectiveDepth:()=>z8,viewport:()=>H8,viewportCoordinate:()=>W8,viewportDepthTexture:()=>X8,viewportLinearDepth:()=>q8,viewportMipTexture:()=>$8,viewportResolution:()=>Y8,viewportSafeUV:()=>K8,viewportSharedTexture:()=>j8,viewportSize:()=>Z8,viewportTexture:()=>J8,viewportUV:()=>Q8,wgsl:()=>eX,wgslFn:()=>tX,workgroupArray:()=>nX,workgroupBarrier:()=>iX,workgroupId:()=>sX,workingToColorSpace:()=>rX,xor:()=>oX});var WO=g.BRDF_GGX,XO=g.BRDF_Lambert,qO=g.BasicPointShadowFilter,$O=g.BasicShadowFilter,YO=g.Break,KO=g.Const,jO=g.Continue,ZO=g.DFGApprox,JO=g.D_GGX,QO=g.Discard,e3=g.EPSILON,t3=g.F_Schlick,n3=g.Fn,i3=g.INFINITY,s3=g.If,r3=g.Loop,o3=g.NodeAccess,a3=g.NodeShaderStage,c3=g.NodeType,l3=g.NodeUpdateType,u3=g.PCFShadowFilter,h3=g.PCFSoftShadowFilter,d3=g.PI,f3=g.PI2,p3=g.PointShadowFilter,m3=g.Return,g3=g.Schlick_to_F0,_3=g.ScriptableNodeResources,y3=g.ShaderNode,x3=g.Stack,v3=g.Switch,T3=g.TBNViewMatrix,b3=g.VSMShadowFilter,S3=g.V_GGX_SmithCorrelated,M3=g.Var,A3=g.VarIntent,E3=g.abs,w3=g.acesFilmicToneMapping,R3=g.acos,C3=g.add,N3=g.addMethodChaining,P3=g.addNodeElement,I3=g.agxToneMapping,L3=g.all,D3=g.alphaT,F3=g.and,U3=g.anisotropy,B3=g.anisotropyB,O3=g.anisotropyT,V3=g.any,G3=g.append,k3=g.array,z3=g.arrayBuffer,H3=g.asin,W3=g.assign,X3=g.atan,q3=g.atan2,$3=g.atomicAdd,Y3=g.atomicAnd,K3=g.atomicFunc,j3=g.atomicLoad,Z3=g.atomicMax,J3=g.atomicMin,Q3=g.atomicOr,eV=g.atomicStore,tV=g.atomicSub,nV=g.atomicXor,iV=g.attenuationColor,sV=g.attenuationDistance,rV=g.attribute,oV=g.attributeArray,aV=g.backgroundBlurriness,cV=g.backgroundIntensity,lV=g.backgroundRotation,uV=g.batch,hV=g.bentNormalView,dV=g.billboarding,fV=g.bitAnd,pV=g.bitNot,mV=g.bitOr,gV=g.bitXor,_V=g.bitangentGeometry,yV=g.bitangentLocal,xV=g.bitangentView,vV=g.bitangentWorld,TV=g.bitcast,bV=g.blendBurn,SV=g.blendColor,MV=g.blendDodge,AV=g.blendOverlay,EV=g.blendScreen,wV=g.blur,RV=g.bool,CV=g.buffer,NV=g.bufferAttribute,PV=g.bumpMap,IV=g.burn,LV=g.builtin,DV=g.bvec2,FV=g.bvec3,UV=g.bvec4,BV=g.bypass,OV=g.cache,VV=g.call,GV=g.cameraFar,kV=g.cameraIndex,zV=g.cameraNear,HV=g.cameraNormalMatrix,WV=g.cameraPosition,XV=g.cameraProjectionMatrix,qV=g.cameraProjectionMatrixInverse,$V=g.cameraViewMatrix,YV=g.cameraViewport,KV=g.cameraWorldMatrix,jV=g.cbrt,ZV=g.cdl,JV=g.ceil,QV=g.checker,eG=g.cineonToneMapping,tG=g.clamp,nG=g.clearcoat,iG=g.clearcoatNormalView,sG=g.clearcoatRoughness,rG=g.code,oG=g.color,aG=g.colorSpaceToWorking,cG=g.colorToDirection,lG=g.compute,uG=g.computeKernel,hG=g.computeSkinning,dG=g.context,fG=g.convert,pG=g.convertColorSpace,mG=g.convertToTexture,gG=g.cos,_G=g.cross,yG=g.cubeTexture,xG=g.cubeTextureBase,vG=g.cubeToUV,TG=g.dFdx,bG=g.dFdy,SG=g.dashSize,MG=g.debug,AG=g.decrement,EG=g.decrementBefore,wG=g.defaultBuildStages,RG=g.defaultShaderStages,CG=g.defined,NG=g.degrees,PG=g.deltaTime,IG=g.densityFog,LG=g.densityFogFactor,DG=g.depth,FG=g.depthPass,UG=g.determinant,BG=g.difference,OG=g.diffuseColor,VG=g.directPointLight,GG=g.directionToColor,kG=g.directionToFaceDirection,zG=g.dispersion,HG=g.distance,WG=g.div,XG=g.dodge,qG=g.dot,$G=g.drawIndex,YG=g.dynamicBufferAttribute,KG=g.element,jG=g.emissive,ZG=g.equal,JG=g.equals,QG=g.equirectUV,ek=g.exp,tk=g.exp2,nk=g.expression,ik=g.faceDirection,sk=g.faceForward,rk=g.faceforward,ok=g.float,ak=g.floatBitsToInt,ck=g.floatBitsToUint,lk=g.floor,uk=g.fog,hk=g.fract,dk=g.frameGroup,fk=g.frameId,pk=g.frontFacing,mk=g.fwidth,gk=g.gain,_k=g.gapSize,yk=g.getConstNodeType,xk=g.getCurrentStack,vk=g.getDirection,Tk=g.getDistanceAttenuation,bk=g.getGeometryRoughness,Sk=g.getNormalFromDepth,Mk=g.getParallaxCorrectNormal,Ak=g.getRoughness,Ek=g.getScreenPosition,wk=g.getShIrradianceAt,Rk=g.getShadowMaterial,Ck=g.getShadowRenderObjectFunction,Nk=g.getTextureIndex,Pk=g.getViewPosition,Ik=g.globalId,Lk=g.glsl,Dk=g.glslFn,Fk=g.grayscale,Uk=g.greaterThan,Bk=g.greaterThanEqual,Ok=g.hash,Vk=g.highpModelNormalViewMatrix,Gk=g.highpModelViewMatrix,kk=g.hue,zk=g.increment,Hk=g.incrementBefore,Wk=g.instance,Xk=g.instanceIndex,qk=g.instancedArray,$k=g.instancedBufferAttribute,Yk=g.instancedDynamicBufferAttribute,Kk=g.instancedMesh,jk=g.int,Zk=g.intBitsToFloat,Jk=g.inverse,Qk=g.inverseSqrt,ez=g.inversesqrt,tz=g.invocationLocalIndex,nz=g.invocationSubgroupIndex,iz=g.ior,sz=g.iridescence,rz=g.iridescenceIOR,oz=g.iridescenceThickness,az=g.ivec2,cz=g.ivec3,lz=g.ivec4,uz=g.js,hz=g.label,dz=g.length,fz=g.lengthSq,pz=g.lessThan,mz=g.lessThanEqual,gz=g.lightPosition,_z=g.lightProjectionUV,yz=g.lightShadowMatrix,xz=g.lightTargetDirection,vz=g.lightTargetPosition,Tz=g.lightViewPosition,bz=g.lightingContext,Sz=g.lights,Mz=g.linearDepth,Az=g.linearToneMapping,Ez=g.localId,wz=g.log,Rz=g.log2,Cz=g.logarithmicDepthToViewZ,Nz=g.luminance,Pz=g.mat2,Iz=g.mat3,Lz=g.mat4,Dz=g.matcapUV,Fz=g.materialAO,Uz=g.materialAlphaTest,Bz=g.materialAnisotropy,Oz=g.materialAnisotropyVector,Vz=g.materialAttenuationColor,Gz=g.materialAttenuationDistance,kz=g.materialClearcoat,zz=g.materialClearcoatNormal,Hz=g.materialClearcoatRoughness,Wz=g.materialColor,Xz=g.materialDispersion,qz=g.materialEmissive,$z=g.materialEnvIntensity,Yz=g.materialEnvRotation,Kz=g.materialIOR,jz=g.materialIridescence,Zz=g.materialIridescenceIOR,Jz=g.materialIridescenceThickness,Qz=g.materialLightMap,eH=g.materialLineDashOffset,tH=g.materialLineDashSize,nH=g.materialLineGapSize,iH=g.materialLineScale,sH=g.materialLineWidth,rH=g.materialMetalness,oH=g.materialNormal,aH=g.materialOpacity,cH=g.materialPointSize,lH=g.materialReference,uH=g.materialReflectivity,hH=g.materialRefractionRatio,dH=g.materialRotation,fH=g.materialRoughness,pH=g.materialSheen,mH=g.materialSheenRoughness,gH=g.materialShininess,_H=g.materialSpecular,yH=g.materialSpecularColor,xH=g.materialSpecularIntensity,vH=g.materialSpecularStrength,TH=g.materialThickness,bH=g.materialTransmission,SH=g.max,MH=g.maxMipLevel,AH=g.mediumpModelViewMatrix,EH=g.metalness,wH=g.min,RH=g.mix,CH=g.mixElement,NH=g.mod,PH=g.modInt,IH=g.modelDirection,LH=g.modelNormalMatrix,DH=g.modelPosition,FH=g.modelRadius,UH=g.modelScale,BH=g.modelViewMatrix,OH=g.modelViewPosition,VH=g.modelViewProjection,GH=g.modelWorldMatrix,kH=g.modelWorldMatrixInverse,zH=g.morphReference,HH=g.mrt,WH=g.mul,XH=g.mx_aastep,qH=g.mx_add,$H=g.mx_atan2,YH=g.mx_cell_noise_float,KH=g.mx_contrast,jH=g.mx_divide,ZH=g.mx_fractal_noise_float,JH=g.mx_fractal_noise_vec2,QH=g.mx_fractal_noise_vec3,e4=g.mx_fractal_noise_vec4,t4=g.mx_frame,n4=g.mx_heighttonormal,i4=g.mx_hsvtorgb,s4=g.mx_ifequal,r4=g.mx_ifgreater,o4=g.mx_ifgreatereq,a4=g.mx_invert,c4=g.mx_modulo,l4=g.mx_multiply,u4=g.mx_noise_float,h4=g.mx_noise_vec3,d4=g.mx_noise_vec4,f4=g.mx_place2d,p4=g.mx_power,m4=g.mx_ramp4,g4=g.mx_ramplr,_4=g.mx_ramptb,y4=g.mx_rgbtohsv,x4=g.mx_rotate2d,v4=g.mx_rotate3d,T4=g.mx_safepower,b4=g.mx_separate,S4=g.mx_splitlr,M4=g.mx_splittb,A4=g.mx_srgb_texture_to_lin_rec709,E4=g.mx_subtract,w4=g.mx_timer,R4=g.mx_transform_uv,C4=g.mx_unifiednoise2d,N4=g.mx_unifiednoise3d,P4=g.mx_worley_noise_float,I4=g.mx_worley_noise_vec2,L4=g.mx_worley_noise_vec3,D4=g.negate,F4=g.neutralToneMapping,U4=g.nodeArray,B4=g.nodeImmutable,O4=g.nodeObject,V4=g.nodeObjectIntent,G4=g.nodeObjects,k4=g.nodeProxy,z4=g.nodeProxyIntent,H4=g.normalFlat,W4=g.normalGeometry,X4=g.normalLocal,q4=g.normalMap,$4=g.normalView,Y4=g.normalViewGeometry,K4=g.normalWorld,j4=g.normalWorldGeometry,Z4=g.normalize,J4=g.not,Q4=g.notEqual,eW=g.numWorkgroups,tW=g.objectDirection,nW=g.objectGroup,iW=g.objectPosition,sW=g.objectRadius,rW=g.objectScale,oW=g.objectViewPosition,aW=g.objectWorldMatrix,cW=g.OnObjectUpdate,lW=g.OnMaterialUpdate,uW=g.oneMinus,hW=g.or,dW=g.orthographicDepthToViewZ,fW=g.oscSawtooth,pW=g.oscSine,mW=g.oscSquare,gW=g.oscTriangle,_W=g.output,yW=g.outputStruct,xW=g.overlay,vW=g.overloadingFn,TW=g.parabola,bW=g.parallaxDirection,SW=g.parallaxUV,MW=g.parameter,AW=g.pass,EW=g.passTexture,wW=g.pcurve,RW=g.perspectiveDepthToViewZ,CW=g.pmremTexture,NW=g.pointShadow,PW=g.pointUV,IW=g.pointWidth,LW=g.positionGeometry,DW=g.positionLocal,FW=g.positionPrevious,UW=g.positionView,BW=g.positionViewDirection,OW=g.positionWorld,VW=g.positionWorldDirection,GW=g.posterize,kW=g.pow,zW=g.pow2,HW=g.pow3,WW=g.pow4,XW=g.premultiplyAlpha,qW=g.property,$W=g.radians,YW=g.rand,KW=g.range,jW=g.rangeFog,ZW=g.rangeFogFactor,JW=g.reciprocal,QW=g.reference,e5=g.referenceBuffer,t5=g.reflect,n5=g.reflectVector,i5=g.reflectView,s5=g.reflector,r5=g.refract,o5=g.refractVector,a5=g.refractView,c5=g.reinhardToneMapping,l5=g.remap,u5=g.remapClamp,h5=g.renderGroup,d5=g.renderOutput,f5=g.rendererReference,p5=g.rotate,m5=g.rotateUV,g5=g.roughness,_5=g.round,y5=g.rtt,x5=g.sRGBTransferEOTF,v5=g.sRGBTransferOETF,T5=g.sample,b5=g.sampler,S5=g.samplerComparison,M5=g.saturate,A5=g.saturation,E5=g.screen,w5=g.screenCoordinate,R5=g.screenDPR,C5=g.screenSize,N5=g.screenUV,P5=g.scriptable,I5=g.scriptableValue,L5=g.select,D5=g.setCurrentStack,F5=g.setName,U5=g.shaderStages,B5=g.shadow,O5=g.shadowPositionWorld,V5=g.shapeCircle,G5=g.sharedUniformGroup,k5=g.sheen,z5=g.sheenRoughness,H5=g.shiftLeft,W5=g.shiftRight,X5=g.shininess,q5=g.sign,$5=g.sin,Y5=g.sinc,K5=g.skinning,j5=g.smoothstep,Z5=g.smoothstepElement,J5=g.specularColor,Q5=g.specularF90,e6=g.spherizeUV,t6=g.split,n6=g.spritesheetUV,i6=g.sqrt,s6=g.stack,r6=g.step,o6=g.stepElement,a6=g.storage,c6=g.storageBarrier,l6=g.storageObject,u6=g.storageTexture,h6=g.string,d6=g.struct,f6=g.sub,p6=g.subgroupAdd,m6=g.subgroupAll,g6=g.subgroupAnd,_6=g.subgroupAny,y6=g.subgroupBallot,x6=g.subgroupBroadcast,v6=g.subgroupBroadcastFirst,T6=g.subBuild,b6=g.subgroupElect,S6=g.subgroupExclusiveAdd,M6=g.subgroupExclusiveMul,A6=g.subgroupInclusiveAdd,E6=g.subgroupInclusiveMul,w6=g.subgroupIndex,R6=g.subgroupMax,C6=g.subgroupMin,N6=g.subgroupMul,P6=g.subgroupOr,I6=g.subgroupShuffle,L6=g.subgroupShuffleDown,D6=g.subgroupShuffleUp,F6=g.subgroupShuffleXor,U6=g.subgroupSize,B6=g.subgroupXor,O6=g.tan,V6=g.tangentGeometry,G6=g.tangentLocal,k6=g.tangentView,z6=g.tangentWorld,H6=g.texture,W6=g.texture3D,X6=g.textureBarrier,q6=g.textureBicubic,$6=g.textureBicubicLevel,Y6=g.textureCubeUV,K6=g.textureLoad,j6=g.textureSize,Z6=g.textureStore,J6=g.thickness,Q6=g.time,e8=g.toneMapping,t8=g.toneMappingExposure,n8=g.toonOutlinePass,i8=g.transformDirection,s8=g.transformNormal,r8=g.transformNormalToView,o8=g.transformedClearcoatNormalView,a8=g.transformedNormalView,c8=g.transformedNormalWorld,l8=g.transmission,u8=g.transpose,h8=g.triNoise3D,d8=g.triplanarTexture,f8=g.triplanarTextures,p8=g.trunc,m8=g.uint,g8=g.uintBitsToFloat,_8=g.uniform,y8=g.uniformArray,x8=g.uniformCubeTexture,v8=g.uniformGroup,T8=g.uniformFlow,b8=g.uniformTexture,S8=g.unpremultiplyAlpha,M8=g.userData,A8=g.uv,E8=g.uvec2,w8=g.uvec3,R8=g.uvec4,C8=g.varying,N8=g.varyingProperty,P8=g.vec2,I8=g.vec3,L8=g.vec4,D8=g.vectorComponents,F8=g.velocity,U8=g.vertexColor,B8=g.vertexIndex,O8=g.vertexStage,V8=g.vibrance,G8=g.viewZToLogarithmicDepth,k8=g.viewZToOrthographicDepth,z8=g.viewZToPerspectiveDepth,H8=g.viewport,W8=g.viewportCoordinate,X8=g.viewportDepthTexture,q8=g.viewportLinearDepth,$8=g.viewportMipTexture,Y8=g.viewportResolution,K8=g.viewportSafeUV,j8=g.viewportSharedTexture,Z8=g.viewportSize,J8=g.viewportTexture,Q8=g.viewportUV,eX=g.wgsl,tX=g.wgslFn,nX=g.workgroupArray,iX=g.workgroupBarrier,sX=g.workgroupId,rX=g.workingToColorSpace,oX=g.xor;var aX=`#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`,cX=`#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`,lX=`#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`,uX=`#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,hX=`#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`,dX=`#ifdef USE_ALPHATEST uniform float alphaTest; #endif`,fX=`#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`,pX=`#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`,mX=`#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`,gX=`#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); #endif`,_X=`vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`,yX=`vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`,xX=`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`,vX=`#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`,TX=`#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`,bX=`#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`,SX=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,MX=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,AX=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,EX=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,wX=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,RX=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,CX=`#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`,NX=`#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`,PX=`#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`,IX=`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`,LX=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,DX=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,FX=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,UX=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,BX="gl_FragColor = linearToOutputTexel( gl_FragColor );",OX=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } 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 ); }`,VX=`#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`,GX=`#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`,kX=`#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`,zX=`#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`,HX=`#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`,WX=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,XX=`#ifdef USE_FOG varying float vFogDepth; #endif`,qX=`#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`,$X=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,YX=`#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 }`,KX=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,jX=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,ZX=`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`,JX=`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`,QX=`#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`,eq=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,tq=`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`,nq=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,iq=`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`,sq=`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`,rq=`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 ); }`,oq=` 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`,aq=`#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`,cq=`#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`,lq=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,uq=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,hq=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,dq=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,fq=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,pq=`#ifdef USE_MAP uniform sampler2D map; #endif`,mq=`#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`,gq=`#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`,_q=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,yq=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,xq=`#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`,vq=`#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`,Tq=`#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`,bq=`#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`,Sq=`#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`,Mq=`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;`,Aq=`#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`,Eq=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,wq=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,Rq=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,Cq=`#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`,Nq=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,Pq=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,Iq=`#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`,Lq=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,Dq=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Fq=`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 ); }`,Uq=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,Bq=`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;`,Oq=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,Vq=`#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`,Gq=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,kq=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,zq=`#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 ) { float depth = unpackRGBAToDepth( texture2D( depths, uv ) ); #ifdef USE_REVERSED_DEPTH_BUFFER return step( depth, compare ); #else return step( compare, depth ); #endif } 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 ); #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( distribution.x, compare ); #else float hard_shadow = step( compare, distribution.x ); #endif 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`,Hq=`#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`,Wq=`#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`,Xq=`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; }`,qq=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,$q=`#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`,Yq=`#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`,Kq=`#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`,jq=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,Zq=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,Jq=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,Qq=`#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; }`,e$=`#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`,t$=`#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`,n$=`#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`,i$=`#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`,s$=`#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`,r$=`#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`,o$=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,a$=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,c$=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,l$=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,u$=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,h$=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,d$=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,f$=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #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 }`,p$=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,m$=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,g$=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,_$=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,y$=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,x$=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,v$=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,T$=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,b$=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,S$=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,M$=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,A$=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,E$=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,w$=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,R$=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,C$=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,N$=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,P$=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,I$=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,L$=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,D$=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,F$=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,U$=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,B$=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,O$=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,V$=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,Pe={alphahash_fragment:aX,alphahash_pars_fragment:cX,alphamap_fragment:lX,alphamap_pars_fragment:uX,alphatest_fragment:hX,alphatest_pars_fragment:dX,aomap_fragment:fX,aomap_pars_fragment:pX,batching_pars_vertex:mX,batching_vertex:gX,begin_vertex:_X,beginnormal_vertex:yX,bsdfs:xX,iridescence_fragment:vX,bumpmap_pars_fragment:TX,clipping_planes_fragment:bX,clipping_planes_pars_fragment:SX,clipping_planes_pars_vertex:MX,clipping_planes_vertex:AX,color_fragment:EX,color_pars_fragment:wX,color_pars_vertex:RX,color_vertex:CX,common:NX,cube_uv_reflection_fragment:PX,defaultnormal_vertex:IX,displacementmap_pars_vertex:LX,displacementmap_vertex:DX,emissivemap_fragment:FX,emissivemap_pars_fragment:UX,colorspace_fragment:BX,colorspace_pars_fragment:OX,envmap_fragment:VX,envmap_common_pars_fragment:GX,envmap_pars_fragment:kX,envmap_pars_vertex:zX,envmap_physical_pars_fragment:QX,envmap_vertex:HX,fog_vertex:WX,fog_pars_vertex:XX,fog_fragment:qX,fog_pars_fragment:$X,gradientmap_pars_fragment:YX,lightmap_pars_fragment:KX,lights_lambert_fragment:jX,lights_lambert_pars_fragment:ZX,lights_pars_begin:JX,lights_toon_fragment:eq,lights_toon_pars_fragment:tq,lights_phong_fragment:nq,lights_phong_pars_fragment:iq,lights_physical_fragment:sq,lights_physical_pars_fragment:rq,lights_fragment_begin:oq,lights_fragment_maps:aq,lights_fragment_end:cq,logdepthbuf_fragment:lq,logdepthbuf_pars_fragment:uq,logdepthbuf_pars_vertex:hq,logdepthbuf_vertex:dq,map_fragment:fq,map_pars_fragment:pq,map_particle_fragment:mq,map_particle_pars_fragment:gq,metalnessmap_fragment:_q,metalnessmap_pars_fragment:yq,morphinstance_vertex:xq,morphcolor_vertex:vq,morphnormal_vertex:Tq,morphtarget_pars_vertex:bq,morphtarget_vertex:Sq,normal_fragment_begin:Mq,normal_fragment_maps:Aq,normal_pars_fragment:Eq,normal_pars_vertex:wq,normal_vertex:Rq,normalmap_pars_fragment:Cq,clearcoat_normal_fragment_begin:Nq,clearcoat_normal_fragment_maps:Pq,clearcoat_pars_fragment:Iq,iridescence_pars_fragment:Lq,opaque_fragment:Dq,packing:Fq,premultiplied_alpha_fragment:Uq,project_vertex:Bq,dithering_fragment:Oq,dithering_pars_fragment:Vq,roughnessmap_fragment:Gq,roughnessmap_pars_fragment:kq,shadowmap_pars_fragment:zq,shadowmap_pars_vertex:Hq,shadowmap_vertex:Wq,shadowmask_pars_fragment:Xq,skinbase_vertex:qq,skinning_pars_vertex:$q,skinning_vertex:Yq,skinnormal_vertex:Kq,specularmap_fragment:jq,specularmap_pars_fragment:Zq,tonemapping_fragment:Jq,tonemapping_pars_fragment:Qq,transmission_fragment:e$,transmission_pars_fragment:t$,uv_pars_fragment:n$,uv_pars_vertex:i$,uv_vertex:s$,worldpos_vertex:r$,background_vert:o$,background_frag:a$,backgroundCube_vert:c$,backgroundCube_frag:l$,cube_vert:u$,cube_frag:h$,depth_vert:d$,depth_frag:f$,distanceRGBA_vert:p$,distanceRGBA_frag:m$,equirect_vert:g$,equirect_frag:_$,linedashed_vert:y$,linedashed_frag:x$,meshbasic_vert:v$,meshbasic_frag:T$,meshlambert_vert:b$,meshlambert_frag:S$,meshmatcap_vert:M$,meshmatcap_frag:A$,meshnormal_vert:E$,meshnormal_frag:w$,meshphong_vert:R$,meshphong_frag:C$,meshphysical_vert:N$,meshphysical_frag:P$,meshtoon_vert:I$,meshtoon_frag:L$,points_vert:D$,points_frag:F$,shadow_vert:U$,shadow_frag:B$,sprite_vert:O$,sprite_frag:V$},Q={common:{diffuse:{value:new q(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new pe},alphaMap:{value:null},alphaMapTransform:{value:new pe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new pe}},envmap:{envMap:{value:null},envMapRotation:{value:new pe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new pe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new pe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new pe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new pe},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new pe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new pe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new pe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new pe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new q(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 q(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new pe},alphaTest:{value:0},uvTransform:{value:new pe}},sprite:{diffuse:{value:new q(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new pe},alphaMap:{value:null},alphaMapTransform:{value:new pe},alphaTest:{value:0}}},a1={basic:{uniforms:Tn([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.fog]),vertexShader:Pe.meshbasic_vert,fragmentShader:Pe.meshbasic_frag},lambert:{uniforms:Tn([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new q(0)}}]),vertexShader:Pe.meshlambert_vert,fragmentShader:Pe.meshlambert_frag},phong:{uniforms:Tn([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new q(0)},specular:{value:new q(1118481)},shininess:{value:30}}]),vertexShader:Pe.meshphong_vert,fragmentShader:Pe.meshphong_frag},standard:{uniforms:Tn([Q.common,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.roughnessmap,Q.metalnessmap,Q.fog,Q.lights,{emissive:{value:new q(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pe.meshphysical_vert,fragmentShader:Pe.meshphysical_frag},toon:{uniforms:Tn([Q.common,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.gradientmap,Q.fog,Q.lights,{emissive:{value:new q(0)}}]),vertexShader:Pe.meshtoon_vert,fragmentShader:Pe.meshtoon_frag},matcap:{uniforms:Tn([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,{matcap:{value:null}}]),vertexShader:Pe.meshmatcap_vert,fragmentShader:Pe.meshmatcap_frag},points:{uniforms:Tn([Q.points,Q.fog]),vertexShader:Pe.points_vert,fragmentShader:Pe.points_frag},dashed:{uniforms:Tn([Q.common,Q.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pe.linedashed_vert,fragmentShader:Pe.linedashed_frag},depth:{uniforms:Tn([Q.common,Q.displacementmap]),vertexShader:Pe.depth_vert,fragmentShader:Pe.depth_frag},normal:{uniforms:Tn([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,{opacity:{value:1}}]),vertexShader:Pe.meshnormal_vert,fragmentShader:Pe.meshnormal_frag},sprite:{uniforms:Tn([Q.sprite,Q.fog]),vertexShader:Pe.sprite_vert,fragmentShader:Pe.sprite_frag},background:{uniforms:{uvTransform:{value:new pe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Pe.background_vert,fragmentShader:Pe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new pe}},vertexShader:Pe.backgroundCube_vert,fragmentShader:Pe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Pe.cube_vert,fragmentShader:Pe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pe.equirect_vert,fragmentShader:Pe.equirect_frag},distanceRGBA:{uniforms:Tn([Q.common,Q.displacementmap,{referencePosition:{value:new S},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pe.distanceRGBA_vert,fragmentShader:Pe.distanceRGBA_frag},shadow:{uniforms:Tn([Q.lights,Q.fog,{color:{value:new q(0)},opacity:{value:1}}]),vertexShader:Pe.shadow_vert,fragmentShader:Pe.shadow_frag}};a1.physical={uniforms:Tn([a1.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new pe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new pe},clearcoatNormalScale:{value:new B(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new pe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new pe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new pe},sheen:{value:0},sheenColor:{value:new q(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new pe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new pe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new pe},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new pe},attenuationDistance:{value:0},attenuationColor:{value:new q(0)},specularColor:{value:new q(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new pe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new pe},anisotropyVector:{value:new B},anisotropyMap:{value:null},anisotropyMapTransform:{value:new pe}}]),vertexShader:Pe.meshphysical_vert,fragmentShader:Pe.meshphysical_frag};var Ic=(1+Math.sqrt(5))/2,ku=1/Ic,v9=[new S(-Ic,ku,0),new S(Ic,ku,0),new S(-ku,0,Ic),new S(ku,0,Ic),new S(0,Ic,-ku),new S(0,Ic,ku),new S(-1,1,-1),new S(1,1,-1),new S(-1,1,1),new S(1,1,1)];var T9=new Float32Array(16),b9=new Float32Array(9),S9=new Float32Array(4);var M9={[Sa]:Ma,[Aa]:Ra,[Ea]:Ca,[Gs]:wa,[Ma]:Sa,[Ra]:Aa,[Ca]:Ea,[wa]:Gs};var c1={type:"change"},VS={type:"start"},u1={type:"end"},Xy=new ai,l1=new pn,G$=Math.cos(70*nr.DEG2RAD),zt=new S,Fn=2*Math.PI,$e={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},OS=1e-6,qy=class extends _a{constructor(e,t=null){super(e,t),this.state=$e.NONE,this.target=new S,this.cursor=new S,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:ns.ROTATE,MIDDLE:ns.DOLLY,RIGHT:ns.PAN},this.touches={ONE:is.ROTATE,TWO:is.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new S,this._lastQuaternion=new tt,this._lastTargetPosition=new S,this._quat=new tt().setFromUnitVectors(e.up,new S(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Gr,this._sphericalDelta=new Gr,this._scale=1,this._panOffset=new S,this._rotateStart=new B,this._rotateEnd=new B,this._rotateDelta=new B,this._panStart=new B,this._panEnd=new B,this._panDelta=new B,this._dollyStart=new B,this._dollyEnd=new B,this._dollyDelta=new B,this._dollyDirection=new S,this._mouse=new B,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=z$.bind(this),this._onPointerDown=k$.bind(this),this._onPointerUp=H$.bind(this),this._onContextMenu=j$.bind(this),this._onMouseWheel=q$.bind(this),this._onKeyDown=$$.bind(this),this._onTouchStart=Y$.bind(this),this._onTouchMove=K$.bind(this),this._onMouseDown=W$.bind(this),this._onMouseMove=X$.bind(this),this._interceptControlDown=Z$.bind(this),this._interceptControlUp=J$.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(c1),this.update(),this.state=$e.NONE}update(e=null){let t=this.object.position;zt.copy(t).sub(this.target),zt.applyQuaternion(this._quat),this._spherical.setFromVector3(zt),this.autoRotate&&this.state===$e.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Fn:n>Math.PI&&(n-=Fn),i<-Math.PI?i+=Fn:i>Math.PI&&(i-=Fn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(zt.setFromSpherical(this._spherical),zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(zt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){let a=zt.length();r=this._clampDistance(a*this._scale);let c=a-r;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){let a=new S(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;let l=new S(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),r=zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(Xy.origin.copy(this.object.position),Xy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Xy.direction))OS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>OS||this._lastTargetPosition.distanceToSquared(this.target)>OS?(this.dispatchEvent(c1),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Fn/60*this.autoRotateSpeed*e:Fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){zt.setFromMatrixColumn(t,0),zt.multiplyScalar(-e),this._panOffset.add(zt)}_panUp(e,t){this.screenSpacePanning===!0?zt.setFromMatrixColumn(t,1):(zt.setFromMatrixColumn(t,0),zt.crossVectors(this.object.up,zt)),zt.multiplyScalar(e),this._panOffset.add(zt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;zt.copy(i).sub(this.target);let s=zt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,r=n.width,a=n.height;this._mouse.x=i/r*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Fn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let r=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(r,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=2.0 are supported."));return}let l=new mM(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}};function Q$(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}var Ce={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},WS=class{constructor(e){this.parser=e,this.name=Ce.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}},sM=class{constructor(e){this.parser=e,this.name=Ce.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;let r=s.extensions[t],a=i.images[r.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}},rM=class{constructor(e){this.parser=e,this.name=Ce.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;let r=s.extensions[t],a=i.images[r.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}},oM=class{constructor(e){this.name=Ce.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,d=new Uint8Array(a,c,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,h,d,i.mode,i.filter).then(function(f){return f.buffer}):r.ready.then(function(){let f=new ArrayBuffer(u*h);return r.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})})}else return null}},aM=class{constructor(e){this.name=Ce.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let l of i.primitives)if(l.mode!==Ei.TRIANGLES&&l.mode!==Ei.TRIANGLE_STRIP&&l.mode!==Ei.TRIANGLE_FAN&&l.mode!==void 0)return null;let r=n.extensions[this.name].attributes,a=[],c={};for(let l in r)a.push(this.parser.getDependency("accessor",r[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],d=l[0].count,f=[];for(let p of h){let m=new ee,_=new S,y=new tt,x=new S(1,1,1),v=new Pr(p.geometry,p.material,d);for(let T=0;T0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var a9=new ee,mM=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Q$,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,r=-1;if(typeof navigator!="undefined"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,s=a.indexOf("Firefox")>-1,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap=="undefined"||n&&i<17||s&&r<98?this.textureLoader=new ca(this.options.manager):this.textureLoader=new pa(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new jt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){let a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Lc(s,a,i),As(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{let c=this.associations.get(r);c!=null&&this.associations.set(a,c);for(let[l,u]of r.children.entries())s(u,a.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&_.setY(N,w[E*c+1]),c>=3&&_.setZ(N,w[E*c+2]),c>=4&&_.setW(N,w[E*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=p}return _})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s],a=this.textureLoader;if(r.uri){let c=n.manager.getHandler(r.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){let i=this,s=this.json,r=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let d=(s.samplers||{})[r.sampler]||{};return u.magFilter=d1[d.magFilter]||Ae,u.minFilter=d1[d.minFilter]||Zt,u.wrapS=f1[d.wrapS]||Cn,u.wrapT=f1[d.wrapT]||Cn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==We&&u.minFilter!==Ae,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());let r=i.images[e],a=self.URL||self.webkitURL,c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;let d=new Blob([h],{type:r.mimeType});return c=a.createObjectURL(d),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(d,f){let p=d;t.isImageBitmapLoader===!0&&(p=function(m){let _=new Ge(m);_.needsUpdate=!0,d(_)}),t.load(Xn.resolveURL(h,s.path),p,void 0,f)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),As(h,r),h.userData.mimeType=r.mimeType||o9(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){let s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),s.extensions[Ce.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Ce.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=s.associations.get(r);r=s.extensions[Ce.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,c)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new es,je.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new yt,je.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||s||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),r&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Ii}loadMaterial(e){let t=this,n=this.json,i=this.extensions,s=n.materials[e],r,a={},c=s.extensions||{},l=[];if(c[Ce.KHR_MATERIALS_UNLIT]){let h=i[Ce.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new q(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],Ut),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,ut)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=fi);let u=s.alphaMode||zS.OPAQUE;if(u===zS.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===zS.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==at&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new B(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&r!==at&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==at){let h=s.emissiveFactor;a.emissive=new q().setRGB(h[0],h[1],h[2],Ut)}return s.emissiveTexture!==void 0&&r!==at&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,ut)),Promise.all(l).then(function(){let h=new r(a);return s.name&&(h.name=s.name),As(h,s),t.associations.set(h,{materials:e}),s.extensions&&Lc(i,h,s),h})}createUniqueName(e){let t=De.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[Ce.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return p1(c,a,t)})}let r=[];for(let a=0,c=e.length;a0&&s9(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),As(y,s),_.extensions&&Lc(i,y,_),t.assignFinalMaterial(y),h.push(y)}for(let f=0,p=h.length;f1?u=new rn:l.length===1?u=l[0]:u=new we,u!==l[0])for(let h=0,d=l.length;h1){let h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,s=new rn;n.name&&(s.name=i.createUniqueName(n.name)),As(s,n),n.extensions&&Lc(t,s,n);let r=n.nodes||[],a=[];for(let c=0,l=r.length;c{let h=new Map;for(let[d,f]of i.associations)(d instanceof je||d instanceof Ge)&&h.set(d,f);return u.traverse(d=>{let f=i.associations.get(d);f!=null&&h.set(d,f)}),h};return i.associations=l(s),s})}_createAnimationTracks(e,t,n,i,s){let r=[],a=e.name?e.name:e.uuid,c=[];po[s.path]===po.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch(po[s.path]){case po.weights:l=li;break;case po.rotation:l=ui;break;case po.translation:case po.scale:l=hi;break;default:switch(n.itemSize){case 1:l=li;break;case 2:case 3:default:l=hi;break}break}let u=i.interpolation!==void 0?t9[i.interpolation]:zs,h=this._getArrayFromAccessor(n);for(let d=0,f=c.length;d(W=oe.indexOf(u))&&X=A.byteLength||!(ae=h(A)))&&r(1,"no header found"),(oe=ae.match(N))||r(3,"bad initial token"),X.valid|=1,X.programtype=oe[1],X.string+=ae+` `;ae=h(A),ae!==!1;){if(X.string+=ae+` `,ae.charAt(0)==="#"){X.comments+=ae+` `;continue}if((oe=ae.match(L))&&(X.gamma=parseFloat(oe[1])),(oe=ae.match(V))&&(X.exposure=parseFloat(oe[1])),(oe=ae.match(H))&&(X.valid|=2,X.format=oe[1]),(oe=ae.match(W))&&(X.valid|=4,X.height=parseInt(oe[1],10),X.width=parseInt(oe[2],10)),X.valid&2&&X.valid&4)break}return X.valid&2||r(3,"missing format specifier"),X.valid&4||r(3,"missing image size specifier"),X},f=function(A,N,L){let V=N;if(V<8||V>32767||A[0]!==2||A[1]!==2||A[2]&128)return new Uint8Array(A);V!==(A[2]<<8|A[3])&&r(3,"wrong scanline width");let H=new Uint8Array(4*N*L);H.length||r(4,"unable to allocate buffer space");let W=0,X=0,ae=4*V,oe=new Uint8Array(4),Le=new Uint8Array(ae),He=L;for(;He>0&&XA.byteLength&&r(1),oe[0]=A[X++],oe[1]=A[X++],oe[2]=A[X++],oe[3]=A[X++],(oe[0]!=2||oe[1]!=2||(oe[2]<<8|oe[3])!=V)&&r(3,"bad rgbe scanline format");let ve=0,Me;for(;ve128;if(ct&&(Me-=128),(Me===0||ve+Me>ae)&&r(3,"bad scanline data"),ct){let et=A[X++];for(let Es=0;Es