1var _cache,_setConsoleFunction,_lut,_seed,DEG2RAD,RAD2DEG,MathUtils,_vector$c,_quaternion$4,_m3,LINEAR_REC709_TO_XYZ,XYZ_TO_LINEAR_REC709,ColorManagement,_canvas,_sourceId,_textureId,_tempVec3,_points,_vector$b,_box$4,_v0$2,_v1$7,_v2$4,_f0,_f1,_f2,_center,_extents,_triangleNormal,_testAxis,_box$3,_v1$6,_v2$3,_vector$a,_segCenter,_segDir,_diff,_edge1,_edge2,_normal$1,_v1$5,_m1$2,_zero,_one,_x,_y,_z,_matrix$2,_quaternion$3,_object3DId,_v1$4,_q1,_m1$1,_target,_position$3,_scale$2,_quaternion$2,_xAxis,_yAxis,_zAxis,_addedEvent,_removedEvent,_childaddedEvent,_childremovedEvent,_v0$1,_v1$3,_v2$2,_v3$2,_vab,_vac,_vbc,_vap,_vbp,_vcp,_v40,_v41,_v42,_colorKeywords,_hslA,_hslB,_color,_materialId,_tables,_vector$9,_vector2$1,_id$2,_id$1,_m1,_obj,_offset,_box$2,_boxMorphTargets,_vector$8,_inverseMatrix$3,_ray$3,_sphere$6,_sphereHitAt,_vA$1,_vB$1,_vC$1,_tempA,_morphA,_intersectionPoint,_intersectionPointWorld,default_vertex,default_fragment,_v3$1,_minTarget,_maxTarget,fov,aspect,_moveEvent,_vector$7,_basePosition,_skinIndex,_skinWeight,_vector3,_matrix4,_vertex,_sphere$5,_inverseMatrix$2,_ray$2,_offsetMatrix,_identityMatrix,_instanceLocalMatrix,_instanceWorldMatrix,_instanceIntersects,_box3,_identity,_mesh$1,_sphere$4,_vector1,_vector2,_normalMatrix,_sphere$3,_defaultSpriteCenter,_vector$6,_projScreenMatrix$1,_frustum$1,_vStart,_vEnd,_inverseMatrix$1,_ray$1,_sphere$1,_intersectPointOnRay,_intersectPointOnSegment,_start,_end,_inverseMatrix,_ray,_sphere,_position$2,Cache,DefaultLoadingManager,loading,_loading,_projScreenMatrix,_lightPositionWorld,_lookTarget,_errorMap,_RESERVED_CHARS_RE,_reservedRe,_wordChar,_wordCharOrDot,_directoryRe,_nodeRe,_objectRe,_propertyRe,_trackRe,_supportedObjectNames,_controlInterpolantsResultBuffer,refreshUniforms,_lightsCache,hashString,hashArray,hash$1,typeFromLength,dataFromObject,NodeShaderStage,NodeUpdateType,NodeAccess,defaultShaderStages,defaultBuildStages,shaderStages,vectorComponents,_parentBuildStage,_nodeId,_str
1ingVectorComponents,_regNum,currentStack,NodeElements,parseSwizzle,parseSwizzleAndSort,proto,swizzleA,swizzleB,swizzleC,nodeBuilderFunctionsCacheMap,ShaderNodeObject,ShaderNodeObjects,ShaderNodeArray,ShaderNodeProxy,ShaderNodeImmutable,bools,uints,ints,floats,boolsCacheMap,uintsCacheMap,intsCacheMap,floatsCacheMap,cacheMaps,constNodesCacheMap,getConstNode,ConvertType,defined,getConstNodeType,nodeObject,nodeObjectIntent,nodeObjects,nodeArray,nodeProxy,nodeImmutable,nodeProxyIntent,fnId,setCurrentStack,getCurrentStack,If,color,float,int,uint,bool,vec2,ivec2,uvec2,bvec2,vec3,ivec3,uvec3,bvec3,vec4,ivec4,uvec4,bvec4,mat2,mat3,mat4,element,convert,property,varyingProperty,diffuseColor,diffuseContribution,emissive,roughness,metalness,clearcoat,clearcoatRoughness,sheen,sheenRoughness,iridescence,iridescenceIOR,iridescenceThickness,alphaT,anisotropy,anisotropyT,anisotropyB,specularColor,specularColorBlended,specularF90,shininess,output,dashSize,gapSize,ior,transmission,thickness,attenuationDistance,attenuationColor,dispersion,uniformGroup,sharedUniformGroup,frameGroup,renderGroup,objectGroup,uniform,array,assign,call,_vectorOperators,add,sub,mul,div,mod,equal,notEqual,lessThan,greaterThan,lessThanEqual,greaterThanEqual,and,or,not,xor,bitAnd,bitNot,bitOr,bitXor,shiftLeft,shiftRight,incrementBefore,decrementBefore,increment,decrement,modInt,EPSILON,PI,PI2,TWO_PI,HALF_PI,all,any,radians,degrees,exp,exp2,log2,log22,sqrt,inverseSqrt,floor,ceil,normalize2,fract,sin,cos,tan,asin,acos,atan,abs,sign,length,negate,oneMinus,dFdx,dFdy,round,reciprocal,trunc,fwidth,transpose,determinant,inverse,equals,min$1,max$1,step,reflect,distance,difference,dot,cross,pow,pow2,pow3,pow4,transformDirection,cbrt,lengthSq,mix,clamp2,saturate,refract,smoothstep2,faceForward,rand,mi
1xElement,smoothstepElement,stepElement,atan2,select,context,uniformFlow,setName,createVar,Var,Const,VarIntent,subBuild,varying,vertexStage,sRGBTransferEOTF,sRGBTransferOETF,WORKING_COLOR_SPACE,OUTPUT_COLOR_SPACE,workingToColorSpace,colorSpaceToWorking,ReferenceElementNode$1,reference$1,rendererReference,toneMapping,toneMappingExposure,_bufferLib,bufferAttribute,instancedBufferAttribute,instancedDynamicBufferAttribute,computeKernel,compute,isolate,bypass,remap,remapClamp,expression,Discard,renderOutput,debug,attribute,uv$1,textureSize,maxMipLevel,EmptyTexture$1,textureBase,texture,textureLoad,buffer,uniformArray,builtin,_screenSizeVec,_viewportVec,screenDPR,screenUV,screenSize,screenCoordinate,viewport,viewportSize,viewportCoordinate,cameraIndex,cameraNear,cameraFar,cameraProjectionMatrix,cameraViewMatrix,cameraPosition,_sphere2,objectPosition,modelDirection,modelWorldMatrix,modelPosition,modelScale,modelViewPosition,modelRadius,modelNormalMatrix,modelViewMatrix,mediumpModelViewMatrix,highpModelViewMatrix,highpModelNormalViewMatrix,positionGeometry,positionLocal,positionPrevious,positionWorld,positionWorldDirection,positionView,positionViewDirection,frontFacing,faceDirection,directionToFaceDirection,normalGeometry,normalLocal,normalFlat,normalViewGeometry,normalWorldGeometry,normalView,normalWorld,clearcoatNormalView,transformNormal,transformNormalToView,transformedNormalView,transformedNormalWorld,transformedClearcoatNormalView,_e1$1,_m1$12,materialRefractionRatio,materialEnvIntensity,materialEnvRotation,reflectView,refractView,reflectVector,refractVector,EmptyTexture,cubeTextureBase,cubeTexture,reference,referenceBuffer,materialReference,uv,q0,q1,st0,st1,N,q1perp,q0perp,T,B,det,scale$1,tangentViewFrame,bitangentViewFrame,tangentGeometry,tangentLocal,tangentView,getBitangent,bitangentView,TBNViewMatrix,bentNormalView,directionToColor,unpackNormal,normalMap,dHdxy_fwd,perturbNormalArb,bumpMap,_propertyCache,materialAlphaTest,materialColor,materialShininess,materialEmissive,materialOpacity,materialSpecular,materialSpecularIntensity,materialSpecularColor,materialSpecularStrength,materialReflectivity,materialRoughness,materialMetalness,materialNormal,materialClearcoat,materialClearcoatRoughness,materialClearcoatNormal,materialRotation,materialSheen,materialSheenRoughness,materialAnisotropy,materialIridescence,materialIridescenceIOR,materialIridescenceThickness,materialTransmission,materialThickness,materialIOR,materialAttenuationDistance,materialAttenuationColor,materialLineScale,materialLineDashSize,materialLineGapSize,materialLineWidth,materialLineDashOffset,materialPointSize,materialDispersion,materialLightMap,materialAO,materialAnisotropyVector,modelViewProjection,storageElement,storage,vertexIndex,instanceIndex,subgroupIndex,invocationSubgroupIndex,invocationLocalIndex,drawIndex,instancedMesh,batch,_frameId,skinning,Loop,Break,_morphTextures,_morphVec4,getMorph,morphReference,lightingContext,_size$5,viewportMipTexture,_sharedDepthbuffer,viewportDepthTexture,viewZToOrthographicDepth,viewZToPerspectiveDepth,perspectiveDepthToViewZ,viewZToLogarithmicDepth,depthBase,depth,linearDepth,viewportLinearDepth,clipping,clippingAlpha,hardwareClipping,ALPHA_HASH_SCALE,hash2D,hash3D,getAlphaHashThreshold,vertexColor,premultiplyAlpha,_defaultValues$d,_defaultValues$c,_defaultValues$a,equirectUV,_cache$1,cubeMapNode,_defaultValues$9,F_Schlick,BRDF_Lambert,G_BlinnPhong_Implicit,D_BlinnPhong,BRDF_BlinnPhong,_defaultValues$8,_defaultValues$7,getGeometryRoughness,getRoughness,V_GGX_SmithCorrelated,V_GGX_SmithCorrelated_Anisotropic,D_GGX,RECIPROCAL_PI,D_GGX_Anisotropic,BRDF_GGX,DATA,lut,DFGLUT,BRDF_GGX_Multiscatter,EnvironmentBRDF,Schlick_to_F0,D_Charlie,V_Neubelt,BRDF_Sheen,LTC_Uv,LTC_ClippedSphereFormFactor,LTC_EdgeVectorFormFactor,LTC_Evaluate,bC,w0,w1,w2,w3,g0,g1,h0,h1,bicubic,textureBicubicLevel,getVolumeTransmissionRay,applyIorToRoughness,viewportBackSideTexture,viewportFrontSideTexture,getTransmissionSample,volumeAttenuation,getIBLVolumeRefraction,XYZ_TO_REC709,Fresnel0ToIor,IorToFresnel0,evalSensitivity,evalIridescence,IBLSheenBRDF,clearcoatF0,clearcoatF90,cubeUV_r0,cubeUV_m0,cubeUV_r1,cubeUV_m1,cubeUV_r4,cubeUV_m4,cubeUV_r5,cubeUV_m5,cubeUV_r6,cubeUV_m6,cubeUV_minMipLevel,cubeUV_minTileSize,getFace,getUV,roughnessToMip,getDirection,textureCubeUV,bilinearCubeUV,getSample,blur,radicalInverse_VdC,hammersley,importanceSampleGGX_VNDF,ggxConvolution,LOD_MIN,EXTRA_LOD_SIGMA,MAX_SAMPLES,GGX_SAMPLES,_flatCamera,_cubeCamera,_clearColor$2,_oldTarget,_oldActiveCubeFace,_oldActiveMipmapLevel,_origin,_uniformsMap,_faceLib,_direction,_outputDirection,_cache2,pmremTexture,_envNodeCache,createRadianceContext,createIrradianceContext,_defaultValues$6,_defaultValues$5,getGradientIrradiance,_defaultValues$4,matcapUV,_defaultValues$3,rotate,_defaultValues$2,_defaultValues$1,_size$4,scale,_defaultValues,scatteringDensity,linearDepthRay,outgoingRayLight,_id$a,_chainKeys$5,AttributeType,GPU_CHUNK_BYTES,BlendColorFactor,OneMinusBlendColorFactor,_id$9,_chainKeys$4,_id$8,_chainKeys$3,_defaultScene,_defaultCamera,_size$3,stack,bitcast,floatBitsToUint,registeredBitcountFunctions,_reflectorPlane,_normal,_reflectorWorldPosition,_cameraWorldPosition,_rotationMatrix,_lookAtPosition,clipPlane,_view,_target2,_q,_size$2,_defaultRT,_defaultUV,_camera,_geometry,interleavedGradientNoise,vogelDiskSample,_e1,_m12,backgroundBlurriness,backgroundIntensity,backgroundRotation,normal,texture3D,_objectData,_size,linearToneMapping,reinhardToneMapping,cineonToneMapping,RRTAndODTFit,acesFilmicToneMapping,LINEAR_REC2020_TO_LINEAR_SRGB,LINEAR_SRGB_TO_LINEAR_REC2020,agxDefaultContrastApprox,agxToneMapping,neutralToneMapping,ScriptableNodeResources,rangeFogFactor,densityFogFactor,fog,barrier,atomicNode,uniformsLib,lightTargetDirection,sortLights,getLightNodeById,_lightsNodeRef,_hashData,shadowPositionWorld,shadowMaterialLib,BasicShadowFilter,PCFShadowFilter,PCFSoftShadowFilter,VSMShadowFilter,linearDistance,linearShadowDistance,getShadowMaterial,disposeShadowMaterial,_shadowRenderObjectLibrary,_shadowRenderObjectKeys,get
1ShadowRenderObjectFunction,VSMPassVertical,VSMPassHorizontal,_shadowFilterLib,_rendererState,_quadMesh,shadow,_clearColor$1,_projScreenMatrix$12,_lightPositionWorld2,_lookTarget2,_cubeDirectionsWebGPU,_cubeUpsWebGPU,_cubeDirectionsWebGL,_cubeUpsWebGL,BasicPointShadowFilter,PointShadowFilter,pointShadowFilter,pointShadow,getDistanceAttenuation,directPointLight,shapeCircle,getShIrradianceAt,_clearColor,_id$7,_id$6,_id$5,sharedNodeData,rendererCache,typeFromArray,toFloat,_matrix41,_matrix42,_ltcLib,sdBox,declarationRegexp$1,propertiesRegexp$1,pragmaMain,parse$1,_outputNodeMap,_chainKeys$2,_cacheKeyValues,_plane,_chainKeys$1,_defaultLights,_chainKeys,_cameraLPos,_cameraRPos,_scene,_drawingBufferSize,_screen,_frustum,_frustumArray,_projScreenMatrix2,_vector4,_id$4,_id$3,_id$22,glslPolyfills,glslMethods,precisionLib,supports$1,interpolationTypeMap,interpolationModeMap,defaultPrecisions,_vector22,_color4,_id$12,equationToGL,factorToGL,initialized,wrappingToGL,filterToGL,compareToGL,GLFeatureName,GPUPrimitiveTopology,GPUShaderStage,GPUCompareFunction,GPUStoreOp,GPULoadOp,GPUFrontFace,GPUCullMode,GPUIndexFormat,GPUTextureFormat,GPUAddressMode,GPUFilterMode,GPUBlendFactor,GPUBlendOperation,GPUColorWriteFlags,GPUStencilOperation,GPUBufferBindingType,GPUStorageTextureAccess,GPUSamplerBindingType,GPUTextureSampleType,GPUTextureDimension,GPUTextureViewDimension,GPUTextureAspect,GPUInputStepMode,GPUFeatureName,GPUFeatureMap,_id,_compareToWebGPU,_flipMap,declarationRegexp,propertiesRegexp,wgslTypeLib$1,parse,accessNames,wrapNames,gpuShaderStageLib,supports,wgslFnOpLib,wgslTypeLib,wgslCodeCache,wgslPolyfill,wgslMethods,diagnostics,typedArraysToVertexFormatPrefix,typedAttributeToVertexFormatPrefix,typeArraysToVertexFormatPrefixForItemSize1,alphahash_fragment,alphahash_pars_fragment,alphamap_fragment,alphamap_pars_fragment,alphatest_fragment,alphatest_pars_fragment,aomap_fragment,aomap_pars_fragment,batching_pars_vertex,batching_vertex,begin_vertex,beginnormal_vertex,bsdfs,iridescence_fragment,bumpmap_pars_fragment,clipping_planes_fragment,clipping_planes_pars_fragment,clipping_planes_pars_vertex,clipping_planes_vertex,color_fragment,color_pars_fragment,color_pars_vertex,color_vertex,common,cube_uv_reflection_fragment,defaultnormal_vertex,displacementmap_pars_vertex,displacementmap_vertex,emissivemap_fragment,emissivemap_pars_fragment,colorspace_fragment,colorspace_pars_fragment,envmap_fragment,envmap_common_pars_fragment,envmap_pars_fragment,envmap_pars_vertex,envmap_vertex,fog_vertex,fog_pars_vertex,fog_fragment,fog_pars_fragment,gradientmap_pars_fragment,lightmap_pars_fragment,lights_lambert_fragment,lights_lambert_pars_fragment,lights_pars_begin,envmap_physical_pars_fragment,lights_toon_fragment,lights_toon_pars_fragment,lights_phong_fragment,lights_phong_pars_fragment,lights_physical_fragment,lights_physical_pars_fragment,lights_fragment_begin,lights_fragment_maps,lights_fragment_end,logdepthbuf_fragment,logdepthbuf_pars_fragment,logdepthbuf_pars_vertex,logdepthbuf_vertex,map_fragment,map_pars_fragment,map_particle_fragment,map_particle_pars_fragment,metalnessmap_fragment,metalnessmap_pars_fragment,morphinstance_vertex,morphcolor_vertex,morphnormal_vertex,morphtarget_pars_vertex,morphtarget_vertex,normal_fragment_begin,normal_fragment_maps,normal_pars_fragment,normal_pars_vertex,normal_vertex,normalmap_pars_fragment,clearcoat_normal_fragment_begin,clearcoat_normal_fragment_maps,clearcoat_pars_fragment,iridescence_pars_fragment,opaque_fragment,packing,premultiplied_alpha_fragment,project_vertex,dithering_fragment,dithering_pars_fragment,roughnessmap_fragment,roughnessmap_pars_fragment,shadowmap_pars_fragment,shadowmap_pars_vertex,shadowmap_vertex,shadowmask_pars_fragment,skinbase_vertex,skinning_pars_vertex,skinning_vertex,skinnormal_vertex,specularmap_fragment,specularmap_pars_fragment,tonemapping_fragment,tonemapping_pars_fragment,transmission_fragment,transmission_pars_fragment,uv_pars_fragment,uv_pars_vertex,uv_vertex,worldpos_vertex,vertex$h,fragment$h,vertex$g,fragment$g,vertex$f,fragment$f,vertex$e,fragment$e,vertex$d,fragment$d,vertex$c,fragment$c,vertex$b,fragment$b,vertex$a,fragment$a,vertex$9,fragment$9,vertex$8,fragment$8,vertex$7,fragment$7,vertex$6,fragment$6,vertex$5,fragment$5,vertex$4,fragment$4,vertex$3,fragment$3,vertex$2,fragment$2,vertex$1,fragment$1,ShaderChunk,UniformsLib,ShaderLib,toneMappingMap,mat4array,mat3array,mat2array,toneMappingFunctions,shaderChunkMap,shadowMapTypeDefines,envMapTypeDefines,envMapModeDefines,envMapBlendingDefines,reversedFuncs,DATA2,_changeEvent,_startEvent,_endEvent,_ray2,_plane2,_TILT_LIMIT,_v,_twoPI,_STATE,_EPS,MeshoptDecoder,EXTENSIONS,BINARY_EXTENSION_HEADER_MAGIC,BINARY_EXTENSION_HEADER_LENGTH,BINARY_EXTENSION_CHUNK_TYPES,_quaternion,WEBGL_CONSTANTS,WEBGL_COMPONENT_TYPES,WEBGL_FILTERS,WEBGL_WRAPPINGS,WEBGL_TYPE_SIZES,ATTRIBUTES,PATH_PROPERTIES,INT
1ERPOLATION,ALPHA_MODES,_identityMatrix2,t,n,u,y,E,S,X,it,ht,gt,xt,dt,Ft,Et,te,ae,ue,ye,de,Ae,We,He,qe,Je,Qe,Ze,en,nn,sn,an,rn,on,cn,Un,pn,xn,yn,bn,mn,dn,Dn,wn,Vn,Cn,ri,oi,ci,Ui,_i,yi,Fi,Oi,A,I,B2,g,C,DisplayP3ColorSpace,LinearDisplayP3ColorSpace,ExtendedSRGBColorSpaceImpl,_taskCache,_activeLoaders,_zstd,UNCOMPRESSED_FORMATS,FORMAT_MAP,TYPE_MAP,loadScene,REVISION="182",MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},CullFaceNone=0,CullFaceBack=1,CullFaceFront=2,BasicShadowMap=0,PCFShadowMap=1,VSMShadowMap=3,FrontSide=0,BackSide=1,DoubleSide=2,NoBlending=0,NormalBlending=1,AdditiveBlending=2,SubtractiveBlending=3,MultiplyBlending=4,CustomBlending=5,AddEquation=100,SubtractEquation=101,ReverseSubtractEquation=102,MinEquation=103,MaxEquation=104,ZeroFactor=200,OneFactor=201,SrcColorFactor=202,OneMinusSrcColorFactor=203,SrcAlphaFactor=204,OneMinusSrcAlphaFactor=205,DstAlphaFactor=206,OneMinusDstAlphaFactor=207,DstColorFactor=208,OneMinusDstColorFactor=209,SrcAlphaSaturateFactor=210,NeverDepth=0,AlwaysDepth=1,LessDepth=2,LessEqualDepth=3,EqualDepth=4,GreaterEqualDepth=5,GreaterDepth=6,NotEqualDepth=7,MultiplyOperation=0,MixOperation=1,AddOperation=2,NoToneMapping=0,LinearToneMapping=1,ReinhardToneMapping=2,CineonToneMapping=3,ACESFilmicToneMapping=4,CustomToneMapping=5,AgXToneMapping=6,NeutralToneMapping=7,AttachedBindMode="attached",DetachedBindMode="detached",UVMapping=300,CubeReflectionMapping=301,CubeRefractionMapping=302,EquirectangularReflectionMapping=303,EquirectangularRefractionMapping=304,CubeUVReflectionMapping=306,RepeatWrapping=1e3,ClampToEdgeWrapping=1001,MirroredRepeatWrapping=1002,NearestFilter=1003,NearestMipmapNearestFilter=1004,NearestMipmapLinearFilter=1005,LinearFilter=1006,LinearMipmapNearestFilter=1007,LinearMipmapLinearFilter=1008,UnsignedByteType=1009,ByteType=1010,ShortType=1011,UnsignedShortType=1012,IntType=1013,UnsignedIntType=1014,FloatType=1015,HalfFloatType=1016,UnsignedShort4444Type=1017,UnsignedShort5551Type=1018,UnsignedInt248Type=1020,UnsignedInt5999Type=35902,UnsignedInt101111Type=35899,AlphaFormat=1021,RGBFormat=1022,RGBAFormat=1023,DepthFormat=1026,DepthStencilFormat=1027,RedFormat=1028,RedIntegerFormat=1029,RGFormat=1030,RGIntegerFormat=1031,RGBIntegerFormat=1032,RGBAIntegerFormat=1033,RGB_S3TC_DXT1_Format=33776,RGBA_S3TC_DXT1_Format=33777,RGBA_S3TC_DXT3_Format=33778,RGBA_S3TC_DXT5_Format=33779,RGB_PVRTC_4BPPV1_Format=35840,RGB_PVRTC_2BPPV1_Format=35841,RGBA_PVRTC_4BPPV1_Format=35842,RGBA_PVRTC_2BPPV1_Format=35843,RGB_ETC1_Format=36196,RGB_ETC2_Format=37492,RGBA_ETC2_EAC_Format=37496,R11_EAC_Format=37488,SIGNED_R11_EAC_Format=37489,RG11_EAC_Format=37490,SIGNED_RG11_EAC_Format=37491,RGBA_ASTC_4x4_Format=37808,RGBA_ASTC_5x4_Format=37809,RGBA_ASTC_5x5_Format=37810,RGBA_ASTC_6x5_Format=37811,RGBA_ASTC_6x6_Format=37812,RGBA_ASTC_8x5_Format=37813,RGBA_ASTC_8x6_Format=37814,RGBA_ASTC_8x8_Format=37815,RGBA_ASTC_10x5_Format=37816,RGBA_ASTC_10x6_Format=37817,RGBA_ASTC_10x8_Format=37818,RGBA_ASTC_10x10_Format=37819,RGBA_ASTC_12x10_Format=37820,RGBA_ASTC_12x12_Format=37821,RGBA_BPTC_Format=36492,RGB_BPTC_SIGNED_Format=36494,RGB_BPTC_UNSIGNED_Format=36495,RED_RGTC1_Format=36283,SIGNED_RED_RGTC1_Format=36284,RED_GREEN_RGTC2_Format=36285,SIGNED_RED_GREEN_RGTC2_Format=36286,InterpolateDiscrete=2300,InterpolateLinear=2301,InterpolateSmooth=2302,ZeroCurvatureEnding=2400,ZeroSlopeEnding=2401,WrapAroundEnding=2402,NormalAnimationBlendMode=2500,TrianglesDrawMode=0,TriangleStripDrawMode=1,TriangleFanDrawMode=2,TangentSpaceNormalMap=0,ObjectSpaceNormalMap=1,NoColorSpace="",SRGBColorSpace="srgb",LinearSRGBColorSpace="srgb-linear",LinearTransfer="linear",SRGBTransfer="srgb",NoNormalPacking="",NormalRGPacking="rg",NormalGAPacking="ga",ZeroStencilOp=0,KeepStencilOp=7680,ReplaceStencilOp=7681,IncrementStencilOp=7682,DecrementStencilOp=7683,IncrementWrapStencilOp=34055,DecrementWrapStencilOp=34056,InvertStencilOp=5386,NeverStencilFunc=512,LessStencilFunc=513,EqualStencilFunc=514,LessEqualStencilFunc=515,GreaterStencilFunc=516,NotEqualStencilFunc=517,GreaterEqualStencilFunc=518,AlwaysStencilFunc=519,NeverCompare=512,LessCompare=513,EqualCompare=514,LessEqualCompare=515,GreaterCompare=516,NotEqualCompare=517,GreaterEqualCompare=518,AlwaysCompare=519,StaticDrawUsage=35044,DynamicDrawUsage=35048,WebGLCoordinateSystem=2e3,WebGPUCoordinateSystem=2001,TimestampQuery={COMPUTE:"compute",RENDER:"render"};function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}_cache={},_setConsoleFunction=null;function log(...e){const t="THREE."+e.shift();_setConsoleFunction?_setConsoleFunction("log",t,...e):console.log(t,...e)}function warn(...e){const t="THREE."+e.shift();_setConsoleFunction?_setConsoleFunction("warn",t,...e):console.warn(t,...e)}function error(...e){const t="THREE."+e.shift();_setConsoleFunction?_setConsoleFunction("error",t,...e):console.error(t,...e)}function warnOnce(...e){const t=e.join(" ");if(t in _cache)return;_cache[t]=!0,warn(...e)}class EventDispatcher{addEventListener(e,t){this._listeners===0[0]&&(this._listeners={});const n=this._listeners;n[e]===0[0]&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n!==0[0]&&n[e]!==0[0]&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===0[0])return;const n=s[e];if(n!==0[0]){const e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){const t=this._listeners;if(t===0[0])return;const n=t[e.type];if(n!==0[0]){e.target=this;const t=n.slice(0);for(let n=0,s=t.length;n<s;n++)t[n].call(this,e);e.target=null}}}_lut=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","5
15","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],_seed=1234567,DEG2RAD=Math.PI/180,RAD2DEG=180/Math.PI;function generateUUID(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,s=Math.random()*4294967295|0,o=_lut[e&255]+_lut[e>>8&255]+_lut[e>>16&255]+_lut[e>>24&255]+"-"+_lut[t&255]+_lut[t>>8&255]+"-"+_lut[t>>16&15|64]+_lut[t>>24&255]+"-"+_lut[n&63|128]+_lut[n>>8&255]+"-"+_lut[n>>16&255]+_lut[n>>24&255]+_lut[s&255]+_lut[s>>8&255]+_lut[s>>16&255]+_lut[s>>24&255];return o.toLowerCase()}function clamp(e,t,n){return Math.max(t,Math.min(n,e))}function euclideanModulo(e,t){return(e%t+t)%t}function mapLinear(e,t,n,s,o){return s+(e-t)*(o-s)/(n-t)}function inverseLerp(e,t,n){return e!==t?(n-e)/(t-e):0}function lerp(e,t,n){return(1-n)*e+n*t}function damp(e,t,n,s){return lerp(e,t,1-Math.exp(-n*s))}function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,t*2)-t)}function smoothstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function smootherstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function randFloat(e,t){return e+Math.random()*(t-e)}function randFloatSpread(e){return e*(.5-Math.random())}function seededRandom(e){e!==0[0]&&(_seed=e);let t=_seed+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function degToRad(e){return e*DEG2RAD}function radToDeg(e){return e*RAD2DEG}function isPowerOfTwo(e){return(e&e-1)===0&&e!==0}function ceilPowerOfTwo(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function floorPowerOfTwo(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function setQuaternionFromProperEuler(e,t,n,s,o){const l=Math.cos,d=Math.sin,i=l(n/2),a=d(n/2),r=l((t+s)/2),c=d((t+s)/2),u=l((t-s)/2),h=d((t-s)/2),m=l((s-t)/2),f=d((s-t)/2);switch(o){case"XYX":e.set(i*c,a*u,a*h,i*r);break;case"YZY":e.set(a*h,i*c,a*u,i*r);break;case"ZXZ":e.set(a*u,a*h,i*c,i*r);break;case"XZX":e.set(i*c,a*f,a*m,i*r);break;case"YXY":e.set(a*m,i*c,a*f,i*r);break;case"ZYZ":e.set(a*f,a*m,i*c,i*r);break;default:warn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+o)}}function denormalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function normalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}MathUtils={DEG2RAD,RAD2DEG,generateUUID,clamp,euclideanModulo,mapLinear,inverseLerp,lerp,damp,pingpong,smoothstep,smootherstep,randInt,randFloat,randFloatSpread,seededRandom,degToRad,radToDeg,isPowerOfTwo,ceilPowerOfTwo,floorPowerOfTwo,setQuaternionFromProperEuler,normalize,denormalize};class Vector2{constructor(e=0,t=0){Vector2.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}
vendor: 17,883 bytes, line 1
1sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,s=this.y,t=e.elements;return this.x=t[0]*n+t[3]*s+t[6],this.y=t[1]*n+t[4]*s+t[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=clamp(this.x,e.x,t.x),this.y=clamp(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=clamp(this.x,e,t),this.y=clamp(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(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=this.x|0,this.y=this.y|0,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(this.x*this.x+this.y*this.y)**.5}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){const e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){const t=(this.lengthSq()*e.lengthSq())**.5;if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(clamp(n,-1,1))}distanceTo(e){return this.distanceToSquared(e)**.5}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),o=this.x-e.x,i=this.y-e.y;return this.x=o*n-i*s+e.x,this.y=o*s+i*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Quaternion{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,o,i,a){let r=n[s+0],c=n[s+1],l=n[s+2],d=n[s+3],u=o[i+0],h=o[i+1],m=o[i+2],f=o[i+3];if(a<=0){e[t+0]=r,e[t+1]=c,e[t+2]=l,e[t+3]=d;return}if(a>=1){e[t+0]=u,e[t+1]=h,e[t+2]=m,e[t+3]=f;return}if(d!==f||r!==u||c!==h||l!==m){let t=r*u+c*h+l*m+d*f;t<0&&(u=-u,h=-h,m=-m,f=-f,t=-t);let e=1-a;if(t<.9995){const n=Math.acos(t),s=Math.sin(n);e=Math.sin(e*n)/s,a=Math.sin(a*n)/s,r=r*e+u*a,c=c*e+h*a,l=l*e+m*a,d=d*e+f*a}else{r=r*e+u*a,c=c*e+h*a,l=l*e+m*a,d=d*e+f*a;const t=1/(r*r+c*c+l*l+d*d)**.5;r*=t,c*=t,l*=t,d*=t}}e[t]=r,e[t+1]=c,e[t+2]=l,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,o,i){const a=n[s],r=n[s+1],c=n[s+2],l=n[s+3],d=o[i],u=o[i+1],h=o[i+2],m=o[i+3];return e[t]=a*m+l*d+r*h-c*u,e[t+1]=r*m+l*u+c*d-a*h,e[t+2]=c*m+l*h+a*u-r*d,e[t+3]=l*m-a*d-r*u-c*h,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const{_x:d,_y:u,_z:h,_order:m}=e,c=Math.cos,l=Math.sin,n=c(d/2),s=c(u/2),o=c(h/2),i=l(d/2),a=l(u/2),r=l(h/2);switch(m){case"XYZ":this._x=i*s*o+n*a*r,this._y=n*a*o-i*s*r,this._z=n*s*r+i*a*o,this._w=n*s*o-i*a*r;break;case"YXZ":this._x=i*s*o+n*a*r,this._y=n*a*o-i*s*r,this._z=n*s*r-i*a*o,this._w=n*s*o+i*a*r;break;case"ZXY":this._x=i*s*o-n*a*r,this._y=n*a*o+i*s*r,this._z=n*s*r+i*a*o,this._w=n*s*o-i*a*r;break;case"ZYX":this._x=i*s*o-n*a*r,this._y=n*a*o+i*s*r,this._z=n*s*r-i*a*o,this._w=n*s*o+i*a*r;break;case"YZX":this._x=i*s*o+n*a*r,this._y=n*a*o+i*s*r,this._z=n*s*r-i*a*o,this._w=n*s*o-i*a*r;break;case"XZY":this._x=i*s*o-n*a*r,this._y=n*a*o-i*s*r,this._z=n*s*r+i*a*o,this._w=n*s*o+i*a*r;break;default:warn("Quaternion: .setFromEuler() encountered an unknown order: "+m)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,n=Math.sin(s);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],a=t[8],r=t[1],s=t[5],c=t[9],l=t[2],d=t[6],o=t[10],u=n+s+o;if(u>0){const e=.5/(u+1)**.5;this._w=.25/e,this._x=(d-c)*e,this._y=(a-l)*e,this._z=(r-i)*e}else if(n>s&&n>o){const e=2*(1+n-s-o)**.5;this._w=(d-c)/e,this._x=.25*e,this._y=(i+r)/e,this._z=(a+l)/e}else if(s>o){const e=2*(1+s-n-o)**.5;this._w=(a-l)/e,this._x=(i+r)/e,this._y=.25*e,this._z=(c+d)/e}else{const e=2*(1+o-n-s)**.5;this._w=(r-i)/e,this._x=(a+l)/e,this._y=(c+d)/e,this._z=.25*e}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(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),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(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)**.5}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const{_x:n,_y:s,_z:o,_w:i}=e,{_x:a,_y:r,_z:c,_w:l}=t;return this._x=n*l+i*a+s*c-o*r,this._y=s*l+i*r+o*a-n*c,this._z=o*l+i*c+n*r-s*a,this._w=i*l-n*a-s*r-o*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let{_x:o,_y:i,_z:a,_w:r}=e,s=this.dot(e);s<0&&(o=-o,i=-i,a=-a,r=-r,s=-s);let n=1-t;if(s<.9995){const e=Math.acos(s),c=Math.sin(e);n=Math.sin(n*e)/c,t=Math.sin(t*e)/c,this._x=this._x*n+o*t,this._y=this._y*n+i*t,this._z=this._z*n+a*t,this._w=this._w*n+r*t,this._onChangeCallback()}else this._x=this._x*n+o*t,this._y=this._y*n+i*t,this._z=this._z*n+a*t,this._w=this._w*n+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=(1-n)**.5,o=n**.5;return this.set(s*Math.sin(e),s*Math.cos(e),o*Math.sin(t),o*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}}class Vector3{constructor(e=0,t=0,n=0){Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===0[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(_quaternion$4.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_quaternion$4.setFromAxisAngle(e,t))}applyMatrix3(e){const n=this.x,s=this.y,o=this.z,t=e.elements;return this.x=t[0]*n+t[3]*s+t[6]*o,this.y=t[1]*n+t[4]*s+t[7]*o,this.z=t[2]*n+t[5]*s+t[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,s=this.y,o=this.z,t=e.elements,i=1/(t[3]*n+t[7]*s+t[11]*o+t[15]);return this.x=(t[0]*n+t[4]*s+t[8]*o+t[12])*i,this.y=(t[1]*n+t[5]*s+t[9]*o+t[13])*i,this.z=(t[2]*n+t[6]*s+t[10]*o+t[14])*i,this}applyQuaternion(e){const o=this.x,i=this.y,a=this.z,{x:t,y:n,z:s,w:r}=e,c=2*(n*a-s*i),l=2*(s*o-t*a),d=2*(t*i-n*o);return this.x=o+r*c+n*d-s*l,this.y=i+r*l+s*c-t*d,this.z=a+r*d+t*l-n*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,s=this.y,o=this.z,t=e.elements;return this.x=t[0]*n+t[4]*s+t[8]*o,this.y=t[1]*n+t[5]*s+t[9]*o,this.z=t[2]*n+t[6]*s+t[10]*o,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=clamp(this.x,e.x,t.x),this.y=clamp(this.y,e.y,t.y),this.z=clamp(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=clamp(this.x,e,t),this.y=clamp(this.y,e,t),this.z=clamp(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(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=this.x|0,this.y=this.y|0,this.z=this.z|0,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(this.x*this.x+this.y*this.y+this.z*this.z)**.5}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const{x:n,y:s,z:o}=e,{x:i,y:a,z:r}=t;return this.x=s*r-o*a,this.y=o*i-n*r,this.z=n*a-s*i,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return _vector$c.copy(this).projectOnVector(e),this.sub(_vector$c)}reflect(e){return this.sub(_vector$c.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=(this.lengthSq()*e.lengthSq())**.5;if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(clamp(n,-1,1))}distanceTo(e){return this.distanceToSquared(e)**.5}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=(1-e*e)**.5;return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}_vector$c=new Vector3,_quaternion$4=new Quaternion;class Matrix3{constructor(e,t,n,s,o,i,a,r,c){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==0[0]&&this.set(e,t,n,s,o,i,a,r,c)}set(e,t,n,s,o,i,a,r,c){const l=this.elements;return l[0]=e,l[1]=s,l[2]=a,l[3]=t,l[4]=o,l[5]=r,l[6]=n,l[7]=i,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,i=n[0],a=n[3],r=n[6],c=n[1],l=n[4],d=n[7],u=n[2],h=n[5],m=n[8],f=s[0],p=s[3],g=s[6],v=s[1],b=s[4],j=s[7],y=s[2],_=s[5],w=s[8];return o[0]=i*f+a*v+r*y,o[3]=i*p+a*b+r*_,o[6]=i*g+a*j+r*w,o[1]=c*f+l*v+d*y,o[4]=c*p+l*b+d*_,o[7]=c*g+l*j+d*w,o[2]=u*f+h*v+m*y,o[5]=u*p+h*b+m*_,o[8]=u*g+h*j+m*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],i=e[4],a=e[5],r=e[6],c=e[7],l=e[8];return t*i*l-t*a*c-n*o*l+n*a*r+s*o*c-s*i*r}invert(){const e=this.elements,n=e[0],s=e[1],o=e[2],d=e[3],a=e[4],i=e[5],r=e[6],c=e[7],l=e[8],u=l*a-i*c,h=i*r-l*d,m=c*d-a*r,f=n*u+s*h+o*m;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const t=1/f;return e[0]=u*t,e[1]=(o*c-l*s)*t,e[2]=(i*s-o*a)*t,e[3]=h*t,e[4]=(l*n-o*r)*t,e[5]=(o*d-i*n)*t,e[6]=m*t,e[7]=(s*r-c*n)*t,e[8]=(a*n-s*d)*t,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,o,i,a){const r=Math.cos(o),c=Math.sin(o);return this.set(n*r,n*c,-n*(r*i+c*a)+i+e,-s*c,s*r,-s*(-c*i+r*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(_m3.makeScale(e,t)),this}rotate(e){return this.premultiply(_m3.makeRotation(-e)),this}translate(e,t){return this.premultiply(_m3.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}_m3=new Matrix3,LINEAR_REC709_TO_XYZ=(new Matrix3).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),XYZ_TO_LINEAR_REC709=(new Matrix3).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.20397
17,1.0569715);function createColorManagement(){const e={enabled:!0,workingColorSpace:LinearSRGBColorSpace,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===SRGBTransfer&&(e.r=SRGBToLinear(e.r),e.g=SRGBToLinear(e.g),e.b=SRGBToLinear(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===SRGBTransfer&&(e.r=LinearToSRGB(e.r),e.g=LinearToSRGB(e.g),e.b=LinearToSRGB(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===NoColorSpace?LinearTransfer:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return warnOnce("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return warnOnce("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],s=[.3127,.329];return e.define({[LinearSRGBColorSpace]:{primaries:t,whitePoint:s,transfer:LinearTransfer,toXYZ:LINEAR_REC709_TO_XYZ,fromXYZ:XYZ_TO_LINEAR_REC709,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:SRGBColorSpace},outputColorSpaceConfig:{drawingBufferColorSpace:SRGBColorSpace}},[SRGBColorSpace]:{primaries:t,whitePoint:s,transfer:SRGBTransfer,toXYZ:LINEAR_REC709_TO_XYZ,fromXYZ:XYZ_TO_LINEAR_REC709,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:SRGBColorSpace}}}),e}ColorManagement=createColorManagement();function SRGBToLinear(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function LinearToSRGB(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}class ImageUtils{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement=="undefined")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{_canvas===0[0]&&(_canvas=createElementNS("canvas")),_canvas.width=e.width,_canvas.height=e.height;const t=_canvas.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=_canvas}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){const t=createElementNS("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const o=n.getImageData(0,0,e.width,e.height),s=o.data;for(let e=0;e<s.length;e++)s[e]=SRGBToLinear(s[e]/255)*255;return n.putImageData(o,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(SRGBToLinear(t[e]/255)*255):t[e]=SRGBToLinear(t[e]);return{data:t,width:e.width,height:e.height}}return warn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}_sourceId=0;class Source{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_sourceId++}),this.uuid=generateUUID(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement!="undefined"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame!="undefined"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const s=e===0[0]||typeof e=="string";if(!s&&e.images[this.uuid]!==0[0])return e.images[this.uuid];const n={uuid:this.uuid,url:""},t=this.data;if(t!==null){let e;if(Array.isArray(t)){e=[];for(let n=0,s=t.length;n<s;n++)t[n].isDataTexture?e.push(serializeImage(t[n].image)):e.push(serializeImage(t[n]))}else e=serializeImage(t);n.url=e}return s||(e.images[this.uuid]=n),n}}function serializeImage(e){return typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(warn("Texture: Unable to serialize Texture."),{})}_textureId=0,_tempVec3=new Vector3;
vendor: 5,755 bytes, line 1
1class Texture extends EventDispatcher{constructor(e=Texture.DEFAULT_IMAGE,t=Texture.DEFAULT_MAPPING,n=ClampToEdgeWrapping,s=ClampToEdgeWrapping,o=LinearFilter,i=LinearMipmapLinearFilter,a=RGBAFormat,r=UnsignedByteType,c=Texture.DEFAULT_ANISOTROPY,l=NoColorSpace){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_textureId++}),this.uuid=generateUUID(),this.name="",this.source=new Source(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=o,this.minFilter=i,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=r,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(_tempVec3).x}get height(){return this.source.getSize(_tempVec3).y}get depth(){return this.source.getSize(_tempVec3).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(const s in e){const t=e[s];if(t===0[0]){warn(`Texture.setValues(): parameter '${s}' has value of undefined.`);continue}const n=this[s];if(n===0[0]){warn(`Texture.setValues(): property '${s}' does not exist.`);continue}n&&t&&n.isVector2&&t.isVector2?n.copy(t):n&&t&&n.isVector3&&t.isVector3?n.copy(t):n&&t&&n.isMatrix3&&t.isMatrix3?n.copy(t):this[s]=t}}toJSON(e){const n=e===0[0]||typeof e=="string";if(!n&&e.textures[this.uuid]!==0[0])return e.textures[this.uuid];const t={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&&(t.userData=this.userData),n||(e.textures[this.uuid]=t),t}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==UVMapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case MirroredRepeatWrapping: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 RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case MirroredRepeatWrapping: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++}}Texture.DEFAULT_IMAGE=null,Texture.DEFAULT_MAPPING=UVMapping,Texture.DEFAULT_ANISOTROPY=1;class Vector4{constructor(e=0,t=0,n=0,s=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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!==0[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}
vendor: 5,521 bytes, line 1
1sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,s=this.y,o=this.z,i=this.w,t=e.elements;return this.x=t[0]*n+t[4]*s+t[8]*o+t[12]*i,this.y=t[1]*n+t[5]*s+t[9]*o+t[13]*i,this.z=t[2]*n+t[6]*s+t[10]*o+t[14]*i,this.w=t[3]*n+t[7]*s+t[11]*o+t[15]*i,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);const t=(1-e.w*e.w)**.5;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 v,n,s,o;const a=.01,m=.1,t=e.elements,f=t[0],i=t[4],r=t[8],c=t[1],p=t[5],l=t[9],d=t[2],u=t[6],g=t[10];if(Math.abs(i-c)<a&&Math.abs(r-d)<a&&Math.abs(l-u)<a){if(Math.abs(i+c)<m&&Math.abs(r+d)<m&&Math.abs(l+u)<m&&Math.abs(f+p+g-3)<m)return this.set(1,0,0,0),this;v=Math.PI;const e=(f+1)/2,t=(p+1)/2,h=(g+1)/2,b=(i+c)/4,j=(r+d)/4,y=(l+u)/4;return e>t&&e>h?e<a?(n=0,s=.707106781,o=.707106781):(n=e**.5,s=b/n,o=j/n):t>h?t<a?(n=.707106781,s=0,o=.707106781):(s=t**.5,n=b/s,o=y/s):h<a?(n=.707106781,s=.707106781,o=0):(o=h**.5,n=j/o,s=y/o),this.set(n,s,o,v),this}let h=((u-l)*(u-l)+(r-d)*(r-d)+(c-i)*(c-i))**.5;return(h<0?-h:h)<.001&&(h=1),this.x=(u-l)/h,this.y=(r-d)/h,this.z=(c-i)/h,this.w=Math.acos((f+p+g-1)/2),this}setFromMatrixPosition(e){const 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=clamp(this.x,e.x,t.x),this.y=clamp(this.y,e.y,t.y),this.z=clamp(this.z,e.z,t.z),this.w=clamp(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=clamp(this.x,e,t),this.y=clamp(this.y,e,t),this.z=clamp(this.z,e,t),this.w=clamp(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(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=this.x|0,this.y=this.y|0,this.z=this.z|0,this.w=this.w|0,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(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)**.5}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class RenderTarget extends EventDispatcher{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:LinearFilter,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 Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t);const s={width:e,height:t,depth:n.depth},o=new Texture(s);this.textures=[];const i=n.count;for(let e=0;e<i;e++)this.textures[e]=o.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:LinearFilter,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==0[0]&&(t.mapping=e.mapping),e.wrapS!==0[0]&&(t.wrapS=e.wrapS),e.wrapT!==0[0]&&(t.wrapT=e.wrapT),e.wrapR!==0[0]&&(t.wrapR=e.wrapR),e.magFilter!==0[0]&&(t.magFilter=e.magFilter),e.minFilter!==0[0]&&(t.minFilter=e.minFilter),e.format!==0[0]&&(t.format=e.format),e.type!==0[0]&&(t.type=e.type),e.anisotropy!==0[0]&&(t.anisotropy=e.anisotropy),e.colorSpace!==0[0]&&(t.colorSpace
vendor: 48,275 bytes, line 1
1=e.colorSpace),e.flipY!==0[0]&&(t.flipY=e.flipY),e.generateMipmaps!==0[0]&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==0[0]&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){const n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,o=this.textures.length;s<o;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Source(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class WebGLRenderTarget extends RenderTarget{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class DataArrayTexture extends Texture{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Data3DTexture extends Texture{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Box3{constructor(e=new Vector3(1/0,1/0,1/0),t=new Vector3(-(1/0),-(1/0),-(1/0))){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(_vector$b.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(_vector$b.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_vector$b.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-(1/0),this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==0[0]){const s=n.getAttribute("position");if(t===!0&&s!==0[0]&&e.isInstancedMesh!==!0)for(let t=0,n=s.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,_vector$b):_vector$b.fromBufferAttribute(s,t),_vector$b.applyMatrix4(e.matrixWorld),this.expandByPoint(_vector$b);else e.boundingBox!==0[0]?(e.boundingBox===null&&e.computeBoundingBox(),_box$4.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),_box$4.copy(n.boundingBox)),_box$4.applyMatrix4(e.matrixWorld),this.union(_box$4)}const s=e.children;for(let e=0,n=s.length;e<n;e++)this.expandByObject(s[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,_vector$b),_vector$b.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(_center),_extents.subVectors(this.max,_center),_v0$2.subVectors(e.a,_center),_v1$7.subVectors(e.b,_center),_v2$4.subVectors(e.c,_center),_f0.subVectors(_v1$7,_v0$2),_f1.subVectors(_v2$4,_v1$7),_f2.subVectors(_v0$2,_v2$4);let t=[0,-_f0.z,_f0.y,0,-_f1.z,_f1.y,0,-_f2.z,_f2.y,_f0.z,0,-_f0.x,_f1.z,0,-_f1.x,_f2.z,0,-_f2.x,-_f0.y,_f0.x,0,-_f1.y,_f1.x,0,-_f2.y,_f2.x,0];return!!satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),t=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(t,_v0$2,_v1$7,_v2$4,_extents)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_vector$b).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(_vector$b).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:(_points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_points),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}}_points=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],_vector$b=new Vector3,_box$4=new Box3,_v0$2=new Vector3,_v1$7=new Vector3,_v2$4=new Vector3,_f0=new Vector3,_f1=new Vector3,_f2=new Vector3,_center=new Vector3,_extents=new Vector3,_triangleNormal=new Vector3,_testAxis=new Vector3;function satForAxes(e,t,n,s,o){for(let i=0,l=e.length-3;i<=l;i+=3){_testAxis.fromArray(e,i);const d=o.x*Math.abs(_testAxis.x)+o.y*Math.abs(_testAxis.y)+o.z*Math.abs(_testAxis.z),a=t.dot(_testAxis),r=n.dot(_testAxis),c=s.dot(_testAxis);if(Math.max(-Math.max(a,r,c),Math.min(a,r,c))>d)return!1}return!0}_box$3=new Box3,_v1$6=new Vector3,_v2$3=new Vector3;class Sphere{constructor(e=new Vector3,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==0[0]?n.copy(t):_box$3.setFromPoints(e).getCenter(n);let s=0;for(let t=0,o=e.length;t<o;t++)s=Math.max(s,n.distanceToSquared(e[t]));return this.radius=s**.5,this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_v1$6.subVectors(e,this.center);const t=_v1$6.lengthSq();if(t>this.radius*this.radius){const e=t**.5,n=(e-this.radius)*.5;this.center.addScaledVector(_v1$6,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(_v2$3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_v1$6.copy(e.center).add(_v2$3)),this.expandByPoint(_v1$6.copy(e.center).sub(_v2$3))),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}}_vector$a=new Vector3,_segCenter=new Vector3,_segDir=new Vector3,_diff=new Vector3,_edge1=new Vector3,_edge2=new Vector3,_normal$1=new Vector3;class Ray{constructor(e=new Vector3,t=new Vector3(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,_vector$a)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return this.distanceSqToPoint(e)**.5}distanceSqToPoint(e){const t=_vector$a.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_vector$a.copy(this.origin).addScaledVector(this.direction,t),_vector$a.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){_segCenter.copy(e).add(t).multiplyScalar(.5),_segDir.copy(t).sub(e).normalize(),_diff.copy(this.origin).sub(_segCenter);const a=e.distanceTo(t)*.5,r=-this.direction.dot(_segDir),l=_diff.dot(this.direction),c=-_diff.dot(_segDir),u=_diff.lengthSq(),m=Math.abs(1-r*r);let i,o,d,h;if(m>0)if(i=r*c-l,o=r*l-c,h=a*m,i>=0)if(o>=-h)if(o<=h){const e=1/m;i*=e,o*=e,d=i*(i+r*o+2*l)+o*(r*i+o+2*c)+u}else o=a,i=Math.max(0,-(r*o+l)),d=-i*i+o*(o+2*c)+u;else o=-a,i=Math.max(0,-(r*o+l)),d=-i*i+o*(o+2*c)+u;else o<=-h?(i=Math.max(0,-(-r*a+l)),o=i>0?-a:Math.min(Math.max(-a,-c),a),d=-i*i+o*(o+2*c)+u):o<=h?(i=0,o=Math.min(Math.max(-a,-c),a),d=o*(o+2*c)+u):(i=Math.max(0,-(r*a+l)),o=i>0?a:Math.min(Math.max(-a,-c),a),d=-i*i+o*(o+2*c)+u);else o=r>0?-a:a,i=Math.max(0,-(r*o+l)),d=-i*i+o*(o+2*c)+u;return n&&n.copy(this.origin).addScaledVector(this.direction,i),s&&s.copy(_segCenter).addScaledVector(_segDir,o),d}intersectSphere(e,t){_vector$a.subVectors(e.center,this.origin);const n=_vector$a.dot(this.direction),s=_vector$a.dot(_vector$a)-n*n,o=e.radius*e.radius;if(s>o)return null;const i=(o-s)**.5,a=n-i,r=n+i;return r<0?null:a<0?this.at(r,t):this.at(a,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(t===0)return!0;const n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,s,i,a,r,c;const l=1/this.direction.x,d=1/this.direction.y,u=1/this.direction.z,o=this.origin;return l>=0?(n=(e.min.x-o.x)*l,s=(e.max.x-o.x)*l):(n=(e.max.x-o.x)*l,s=(e.min.x-o.x)*l),d>=0?(i=(e.min.y-o.y)*d,a=(e.max.y-o.y)*d):(i=(e.max.y-o.y)*d,a=(e.min.y-o.y)*d),n>a||i>s?null:((i>n||isNaN(n))&&(n=i),(a<s||isNaN(s))&&(s=a),u>=0?(r=(e.min.z-o.z)*u,c=(e.max.z-o.z)*u):(r=(e.max.z-o.z)*u,c=(e.min.z-o.z)*u),n>c||r>s?null:((r>n||n!==n)&&(n=r),(c<s||s!==s)&&(s=c),s<0?null:this.at(n>=0?n:s,t)))}intersectsBox(e){return this.intersectBox(e,_vector$a)!==null}intersectTriangle(e,t,n,s,o){_edge1.subVectors(t,e),_edge2.subVectors(n,e),_normal$1.crossVectors(_edge1,_edge2);let i=this.direction.dot(_normal$1),a;if(i>0){if(s)return null;a=1}else if(i<0)a=-1,i=-i;else return null;_diff.subVectors(this.origin,e);const r=a*this.direction.dot(_edge2.crossVectors(_diff,_edge2));if(r<0)return null;const c=a*this.direction.dot(_edge1.cross(_diff));if(c<0)return null;if(r+c>i)return null;const l=-a*_diff.dot(_normal$1);return l<0?null:this.at(l/i,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Matrix4{constructor(e,t,n,s,o,i,a,r,c,l,d,u,h,m,f,p){Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==0[0]&&this.set(e,t,n,s,o,i,a,r,c,l,d,u,h,m,f,p)}set(e,t,n,s,o,i,a,r,c,l,d,u,h,m,f,p){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=s,g[1]=o,g[5]=i,g[9]=a,g[13]=r,g[2]=c,g[6]=l,g[10]=d,g[14]=u,g[3]=h,g[7]=m,g[11]=f,g[15]=p,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 Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,s=1/_v1$5.setFromMatrixColumn(e,0).length(),o=1/_v1$5.setFromMatrixColumn(e,1).length(),i=1/_v1$5.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*i,t[9]=n[9]*i,t[10]=n[10]*i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,{x:c,y:l,z:d}=e,i=Math.cos(c),n=Math.sin(c),a=Math.cos(l),s=Math.sin(l),r=Math.cos(d),o=Math.sin(d);if(e.order==="XYZ"){const e=i*r,c=i*o,l=n*r,d=n*o;t[0]=a*r,t[4]=-a*o,t[8]=s,t[1]=c+l*s,t[5]=e-d*s,t[9]=-n*a,t[2]=d-e*s,t[6]=l+c*s,t[10]=i*a}else if(e.order==="YXZ"){const e=a*r,c=a*o,l=s*r,d=s*o;t[0]=e+d*n,t[4]=l*n-c,t[8]=i*s,t[1]=i*o,t[5]=i*r,t[9]=-n,t[2]=c*n-l,t[6]=d+e*n,t[10]=i*a}else if(e.order==="ZXY"){const e=a*r,c=a*o,l=s*r,d=s*o;t[0]=e-d*n,t[4]=-i*o,t[8]=l+c*n,t[1]=c+l*n,t[5]=i*r,t[9]=d-e*n,t[2]=-i*s,t[6]=n,t[10]=i*a}else if(e.order==="ZYX"){const e=i*r,c=i*o,l=n*r,d=n*o;t[0]=a*r,t[4]=l*s-c,t[8]=e*s+d,t[1]=a*o,t[5]=d*s+e,t[9]=c*s-l,t[2]=-s,t[6]=n*a,t[10]=i*a}else if(e.order==="YZX"){const e=i*a,c=i*s,l=n*a,d=n*s;t[0]=a*r,t[4]=d-e*o,t[8]=l*o+c,t[1]=o,t[5]=i*r,t[9]=-n*r,t[2]=-s*r,t[6]=c*o+l,t[10]=e-d*o}else if(e.order==="XZY"){const e=i*a,c=i*s,l=n*a,d=n*s;t[0]=a*r,t[4]=-o,t[8]=s*r,t[1]=e*o+d,t[5]=i*r,t[9]=c*o-l,t[2]=l*o-c,t[6]=n*r,t[10]=d*o+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(_zero,e,_one)}lookAt(e,t,n){const s=this.elements;return _z.subVectors(e,t),_z.lengthSq()===0&&(_z.z=1),_z.normalize(),_x.crossVectors(n,_z),_x.lengthSq()===0&&(Math.abs(n.z)===1?_z.x+=1e-4:_z.z+=1e-4,_z.normalize(),_x.crossVectors(n,_z)),_x.normalize(),_y.crossVectors(_z,_x),s[0]=_x.x,s[4]=_y.x,s[8]=_z.x,s[1]=_x.y,s[5]=_y.y,s[9]=_z.y,s[2]=_x.z,s[6]=_y.z,s[10]=_z.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,i=n[0],a=n[4],r=n[8],c=n[12],l=n[1],d=n[5],u=n[9],h=n[13],m=n[2],f=n[6],p=n[10],g=n[14],v=n[3],b=n[7],j=n[11],y=n[15],_=s[0],w=s[4],O=s[8],x=s[12],C=s[1],E=s[5],k=s[9],A=s[13],S=s[2],M=s[6],F=s[10],T=s[14],z=s[3],D=s[7],N=s[11],L=s[15];return o[0]=i*_+a*C+r*S+c*z,o[4]=i*w+a*E+r*M+c*D,o[8]=i*O+a*k+r*F+c*N,o[12]=i*x+a*A+r*T+c*L,o[1]=l*_+d*C+u*S+h*z,o[5]=l*w+d*E+u*M+h*D,o[9]=l*O+d*k+u*F+h*N,o[13]=l*x+d*A+u*T+h*L,o[2]=m*_+f*C+p*S+g*z,o[6]=m*w+f*E+p*M+g*D,o[10]=m*O+f*k+p*F+g*N,o[14]=m*x+f*A+p*T+g*L,o[3]=v*_+b*C+j*S+y*z,o[7]=v*w+b*E+j*M+y*D,o[11]=v*O+b*k+j*F+y*N,o[15]=v*x+b*A+j*T+y*L,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,j=e[0],y=e[4],w=e[8],_=e[12],i=e[1],a=e[5],r=e[9],c=e[13],l=e[2],t=e[6],h=e[10],n=e[14],d=e[3],u=e[7],o=e[11],s=e[15],m=r*n-c*h,f=a*n-c*t,p=a*h-r*t,g=i*n-c*l,v=i*h-r*l,b=i*t-a*l;return j*(u*m-o*f+s*p)-y*(d*m-o*g+s*v)+w*(d*f-u*g+s*b)-_*(d*p-u*v+o*b)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],d=e[4],f=e[5],r=e[6],c=e[7],l=e[8],i=e[9],u=e[10],h=e[11],m=e[12],a=e[13],p=e[14],g=e[15],b=i*p*c-a*u*c+a*r*h-f*p*h-i*r*g+f*u*g,j=m*u*c-l*p*c-m*r*h+d*p*h+l*r*g-d*u*g,y=l*a*c-m*i*c+m*f*h-d*a*h-l*f*g+d*i*g,_=m*i*r-l*a*r-m*f*u+d*a*u+l*f*p-d*i*p,w=t*b+n*j+s*y+o*_;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const v=1/w;return e[0]=b*v,e[1]=(a*u*o-i*p*o-a*s*h+n*p*h+i*s*g-n*u*g)*v,e[2]=(f*p*o-a*r*o+a*s*c-n*p*c-f*s*g+n*r*g)*v,e[3]=(i*r*o-f*u*o-i*s*c+n*u*c+f*s*h-n*r*h)*v,e[4]=j*v,e[5]=(l*p*o-m*u*o+m*s*h-t*p*h-l*s*g+t*u*g)*v,e[6]=(m*r*o-d*p*o-m*s*c+t*p*c+d*s*g-t*r*g)*v,e[7]=(d*u*o-l*r*o+l*s*c-t*u*c-d*s*h+t*r*h)*v,e[8]=y*v,e[9]=(m*i*o-l*a*o-m*n*h+t*a*h+l*n*g-t*i*g)*v,e[10]=(d*a*o-m*f*o+m*n*c-t*a*c-d*n*g+t*f*g)*v,e[11]=(l*f*o-d*i*o-l*n*c+t*i*c+d*n*h-t*f*h)*v,e[12]=_*v,e[13]=(l*a*s-m*i*s+m*n*u-t*a*u-l*n*p+t*i*p)*v,e[14]=(m*f*s-d*a*s-m*n*r+t*a*r+d*n*p-t*f*p)*v,e[15]=(d*i*s-l*f*s+l*n*r-t*i*r-d*n*u+t*f*u)*v,this}scale(e){const t=this.elements,{x:n,y:s,z:o}=e;return t[0]*=n,t[4]*=s,t[8]*=o,t[1]*=n,t[5]*=s,t[9]*=o,t[2]*=n,t[6]*=s,t[10]*=o,t[3]*=n,t[7]*=s,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.max(t,n,s)**.5}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const a=Math.cos(t),s=Math.sin(t),c=1-a,{x:r,y:o,z:n}=e,i=c*r,l=c*o;return this.set(i*r+a,i*o-s*n,i*n+s*o,0,i*o+s*n,l*o+a,l*n-s*r,0,i*n-s*o,l*n+s*r,c*n*n+a,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,s,o,i){return this.set(1,n,o,0,e,1,i,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,{_x:o,_y:i,_z:r,_w:c}=t,w=o+o,d=i+i,a=r+r,_=o*w,y=o*d,m=o*a,f=i*d,p=i*a,g=r*a,v=c*w,b=c*d,j=c*a,{x:h,y:u,z:l}=n;return s[0]=(1-(f+g))*h,s[1]=(y+j)*h,s[2]=(m-b)*h,s[3]=0,s[4]=(y-j)*u,s[5]=(1-(_+g))*u,s[6]=(p+v)*u,s[7]=0,s[8]=(m+b)*l,s[9]=(p-v)*l,s[10]=(1-(_+f))*l,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;if(e.x=s[12],e.y=s[13],e.z=s[14],this.determinant()===0)return n.set(1,1,1),t.identity(),this;let o=_v1$5.set(s[0],s[1],s[2]).length();const c=_v1$5.set(s[4],s[5],s[6]).length(),l=_v1$5.set(s[8],s[9],s[10]).length(),d=this.determinant();d<0&&(o=-o),_m1$2.copy(this);const i=1/o,a=1/c,r=1/l;return _m1$2.elements[0]*=i,_m1$2.elements[1]*=i,_m1$2.elements[2]*=i,_m1$2.elements[4]*=a,_m1$2.elements[5]*=a,_m1$2.elements[6]*=a,_m1$2.elements[8]*=r,_m1$2.elements[9]*=r,_m1$2.elements[10]*=r,t.setFromRotationMatrix(_m1$2),n.x=o,n.y=c,n.z=l,this}makePerspective(e,t,n,s,o,i,a=WebGLCoordinateSystem,r=!1){const c=this.elements,u=2*o/(t-e),h=2*o/(n-s),m=(t+e)/(t-e),f=(n+s)/(n-s);let l,d;if(r)l=o/(i-o),d=i*o/(i-o);else if(a===WebGLCoordinateSystem)l=-(i+o)/(i-o),d=-2*i*o/(i-o);else if(a===WebGPUCoordinateSystem)l=-i/(i-o),d=-i*o/(i-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=m,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=d,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,o,i,a=WebGLCoordinateSystem,r=!1){const c=this.elements,u=2/(t-e),h=2/(n-s),m=-(t+e)/(t-e),f=-(n+s)/(n-s);let l,d;if(r)l=1/(i-o),d=i/(i-o);else if(a===WebGLCoordinateSystem)l=-2/(i-o),d=-(i+o)/(i-o);else if(a===WebGPUCoordinateSystem)l=-1/(i-o),d=-o/(i-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=0,c[12]=m,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=l,c[14]=d,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}_v1$5=new Vector3,_m1$2=new Matrix4,_zero=new Vector3(0,0,0),_one=new Vector3(1,1,1),_x=new Vector3,_y=new Vector3,_z=new Vector3,_matrix$2=new Matrix4,_quaternion$3=new Quaternion;class Euler{constructor(e=0,t=0,n=0,s=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,o=s[0],r=s[4],c=s[8],l=s[1],i=s[5],d=s[9],u=s[2],h=s[6],a=s[10];switch(t){case"XYZ":this._y=Math.asin(clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,a),this._z=Math.atan2(-r,o)):(this._x=Math.atan2(h,i),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(c,a),this._z=Math.atan2(l,i)):(this._y=Math.atan2(-u,o),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,a),this._z=Math.atan2(-r,i)):(this._y=0,this._z=Math.atan2(l,o));break;case"ZYX":this._y=Math.asin(-clamp(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,a),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-r,i));break;case"YZX":this._z=Math.asin(clamp(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,i),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(c,a));break;case"XZY":this._z=Math.asin(-clamp(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(h,i),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-d,a),this._y=0);break;default:warn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _matrix$2.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_matrix$2,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _quaternion$3.setFromEuler(this),this.setFromQuaternion(_quaternion$3,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]!==0[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}}Euler.DEFAULT_ORDER="XYZ";class Layers{constructor(){this.mask=1|0}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=4294967295|0}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}_object3DId=0,_v1$4=new Vector3,_q1=new Quaternion,_m1$1=new Matrix4,_target=new Vector3,_position$3=new Vector3,_scale$2=new Vector3,_quaternion$2=new Quaternion,_xAxis=new Vector3(1,0,0),_yAxis=new Vector3(0,1,0),_zAxis=new Vector3(0,0,1),_addedEvent={type:"added"},_removedEvent={type:"removed"},_childaddedEvent={type:"childadded",child:null},_childremovedEvent={type:"childremoved",child:null};class Object3D extends EventDispatcher{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_object3DId++}),this.uuid=generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DEFAULT_UP.clone();const n=new Vector3,e=new Euler,t=new Quaternion,s=new Vector3(1,1,1);function o(){t.setFromEuler(e,!1)}function i(){e.setFromQuaternion(t,0[0],!1)}e._onChange(o),t._onChange(i),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:n},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:t},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new Matrix4,this.matrixWorld=new Matrix4,this.matrixAutoUpdate=Object3D.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=0[0],this.customDistanceMaterial=0[0],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.multiply(_q1),this}rotateOnWorldAxis(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.premultiply(_q1),this}rotateX(e){return this.rotateOnAxis(_xAxis,e)}rotateY(e){return this.rotateOnAxis(_yAxis,e)}rotateZ(e){return this.rotateOnAxis(_zAxis,e)}translateOnAxis(e,t){return _v1$4.copy(e).applyQuaternion(this.quaternion),this.position.add(_v1$4.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_xAxis,e)}translateY(e){return this.translateOnAxis(_yAxis,e)}translateZ(e){return this.translateOnAxis(_zAxis,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_m1$1.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_target.copy(e):_target.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),_position$3.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_m1$1.lookAt(_position$3,_target,this.up):_m1$1.lookAt(_target,_position$3,this.up),this.quaternion.setFromRotationMatrix(_m1$1),s&&(_m1$1.extractRotation(s.matrixWorld),_q1.setFromRotationMatrix(_m1$1),this.quaternion.premultiply(_q1.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(error("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(_addedEvent),_childaddedEvent.child=e,this.dispatchEvent(_childaddedEvent),_childaddedEvent.child=null):error("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(_removedEvent),_childremovedEvent.child=e,this.dispatchEvent(_childremovedEvent),_childremovedEvent.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),_m1$1.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),_m1$1.multiply(e.parent.matrixWorld)),e.applyMatrix4(_m1$1),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(_addedEvent),_childaddedEvent.child=e,this.dispatchEvent(_childaddedEvent),_childaddedEvent.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,o=this.children.length;n<o;n++){const i=this.children[n],s=i.getObjectByProperty(e,t);if(s!==0[0])return s}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let o=0,i=s.length;o<i;o++)s[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,e,_scale$2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,_quaternion$2,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++){const o=t[n];o.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const e=this.children;for(let t=0,n=e.length;t<n;t++){const s=e[t];s.updateWorldMatrix(!1,!0)}}}toJSON(e){const i=e===0[0]||typeof e=="string",n={};i&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const t={};t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.castShadow===!0&&(t.castShadow=!0),this.receiveShadow===!0&&(t.receiveShadow=!0),this.visible===!1&&(t.visible=!1),this.frustumCulled===!1&&(t.frustumCulled=!1),this.renderOrder!==0&&(t.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(t.userData=this.userData),t.layers=this.layers.mask,t.matrix=this.matrix.toArray(),t.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(t.matrixAutoUpdate=!1),this.isInstancedMesh&&(t.type="InstancedMesh",t.count=this.count,t.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(t.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(t.type="BatchedMesh",t.perObjectFrustumCulled=this.perObjectFrustumCulled,t.sortObjects=this.sortObjects,t.drawRanges=this._drawRanges,t.reservedRanges=this._reservedRanges,t.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():0[0],boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():0[0]})),t.instanceInfo=this._instanceInfo.map(e=>({...e})),t.availableInstanceIds=this._availableInstanceIds.slice(),t.availableGeometryIds=this._availableGeometryIds.slice(),t.nextIndexStart=this._nextIndexStart,t.nextVertexStart=this._nextVertexStart,t.geometryCount=this._geometryCount,t.maxInstanceCount=this._maxInstanceCount,t.maxVertexCount=this._maxVertexCount,t.maxIndexCount=this._maxIndexCount,t.geometryInitialized=this._geometryInitialized,t.matricesTexture=this._matricesTexture.toJSON(e),t.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(t.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(t.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(t.boundingBox=this.boundingBox.toJSON()));function o(t,n){return t[n.uuid]===0[0]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?t.background=this.background.toJSON():this.background.isTexture&&(t.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(t.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){t.geometry=o(e.geometries,this.geometry);const n=this.geometry.parameters;if(n!==0[0]&&n.shapes!==0[0]){const t=n.shapes;if(Array.isArray(t))for(let n=0,s=t.length;n<s;n++){const i=t[n];o(e.shapes,i)}else o(e.shapes,t)}}if(this.isSkinnedMesh&&(t.bindMode=this.bindMode,t.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==0[0]&&(o(e.skeletons,this.skeleton),t.skeleton=this.skeleton.uuid)),this.material!==0[0])if(Array.isArray(this.material)){const n=[];for(let t=0,s=this.material.length;t<s;t++)n.push(o(e.materials,this.material[t]));t.material=n}else t.material=o(e.materials,this.material);if(this.children.length>0){t.children=[];for(let n=0;n<this.children.length;n++)t.children.push(this.children[n].toJSON(e).object)}if(this.animations.length>0){t.animations=[];for(let n=0;n<this.animations.length;n++){const s=this.animations[n];t.animations.push(o(e.animations,s))}}if(i){const t=s(e.geometries),o=s(e.materials),i=s(e.textures),a=s(e.images),r=s(e.shapes),c=s(e.skeletons),l=s(e.animations),d=s(e.nodes);t.length>0&&(n.geometries=t),o.length>0&&(n.materials=o),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),r.length>0&&(n.shapes=r),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),d.length>0&&(n.nodes=d)}return n.object=t,n;function s(e){const t=[];for(const s in e){const n=e[s];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}Object3D.DEFAULT_UP=new Vector3(0,1,0),Object3D.DEFAULT_MATRIX_AUTO_UPDATE=!0,Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0,_v0$1=new Vector3,_v1$3=new Vector3,_v2$2=new Vector3,_v3$2=new Vector3,_vab=new Vector3,_vac=new Vector3,_vbc=new Vector3,_vap=new Vector3,_vbp=new Vector3,_vcp=new Vector3,_v40=new Vector4,_v41=new Vector4,_v42=new Vector4;class Triangle{constructor(e=new Vector3,t=new Vector3,n=new Vector3){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),_v0$1.subVectors(e,t),s.cross(_v0$1);const o=s.lengthSq();return o>0?s.multiplyScalar(1/o**.5):s.set(0,0,0)}static getBarycoord(e,t,n,s,o){_v0$1.subVectors(s,t),_v1$3.subVectors(n,t),_v2$2.subVectors(e,t);const a=_v0$1.dot(_v0$1),i=_v0$1.dot(_v1$3),r=_v0$1.dot(_v2$2),c=_v1$3.dot(_v1$3),l=_v1$3.dot(_v2$2),d=a*c-i*i;if(d===0)return o.set(0,0,0),null;const u=1/d,h=(c*r-i*l)*u,m=(a*l-i*r)*u;return o.set(1-h-m,m,h)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,_v3$2)!==null&&_v3$2.x>=0&&_v3$2.y>=0&&_v3$2.x+_v3$2.y<=1}static getInterpolation(e,t,n,s,o,i,a,r){return this.getBarycoord(e,t,n,s,_v3$2)===null?(r.x=0,r.y=0,"z"in r&&(r.z=0),"w"in r&&(r.w=0),null):(r.setScalar(0),r.addScaledVector(o,_v3$2.x),r.addScaledVector(i,_v3$2.y),r.addScaledVector(a,_v3$2.z),r)}static getInterpolatedAttribute(e,t,n,s,o,i){return _v40.setScalar(0),_v41.setScalar(0),_v42.setScalar(0),_v40.fromBufferAttribute(e,t),_v41.fromBufferAttribute(e,n),_v42.fromBufferAttribute(e,s),i.setScalar(0),i.addScaledVector(_v40,o.x),i.addScaledVector(_v41,o.y),i.addScaledVector(_v42,o.z),i}static isFrontFacing(e,t,n,s){return _v0$1.subVectors(n,t),_v1$3.subVectors(e,t),_v0$1.cross(_v1$3).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 _v0$1.subVectors(this.c,this.b),_v1$3.subVectors(this.a,this.b),_v0$1.cross(_v1$3).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,o){return Triangle.getInterpolation(e,this.a,this.b,this.c,t,n,s,o)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const o=this.a,d=this.b,h=this.c;let u,i;_vab.subVectors(d,o),_vac.subVectors(h,o),_vap.subVectors(e,o);const a=_vab.dot(_vap),r=_vac.dot(_vap);if(a<=0&&r<=0)return t.copy(o);_vbp.subVectors(e,d);const n=_vab.dot(_vbp),c=_vac.dot(_vbp);if(n>=0&&c<=n)return t.copy(d);const m=a*c-n*r;if(m<=0&&a>=0&&n<=0)return u=a/(a-n),t.copy(o).addScaledVector(_vab,u);_vcp.subVectors(e,h);const l=_vab.dot(_vcp),s=_vac.dot(_vcp);if(s>=0&&l<=s)return t.copy(h);const f=l*r-a*s;if(f<=0&&r>=0&&s<=0)return i=r/(r-s),t.copy(o).addScaledVector(_vac,i);const p=n*s-l*c;if(p<=0&&c-n>=0&&l-s>=0)return _vbc.subVectors(h,d),i=(c-n)/(c-n+(l-s)),t.copy(d).addScaledVector(_vbc,i);const g=1/(p+f+m);return u=f*g,i=m*g,t.copy(o).addScaledVector(_vab,u).addScaledVector(_vac,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}_colorKeywords={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},_hslA={h:0,s:0,l:0},_hslB={h:0,s:0,l:0};function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}class Color{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===0[0]&&n===0[0]){const t=e;t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=SRGBColorSpace){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ColorManagement.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=ColorManagement.workingColorSpace){return this.r=e,this.g=t,this.b=n,ColorManagement.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=ColorManagement.workingColorSpace){if(e=euclideanModulo(e,1),t=clamp(t,0,1),n=clamp(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=hue2rgb(o,s,e+1/3),this.g=hue2rgb(o,s,e),this.b=hue2rgb(o,s,e-1/3)}return ColorManagement.colorSpaceToWorking(this,s),this}setStyle(e,t=SRGBColorSpace){function s(t){if(t===0[0])return;parseFloat(t)<1&&warn("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^)]*)\)/.exec(e)){let o;const a=n[1],i=n[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return s(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return s(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return s(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:warn("Color: Unknown color model "+e)}}else if(n=/^#([A-Fa-f\d]+)$/.exec(e)){const s=n[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);warn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=SRGBColorSpace){const n=_colorKeywords[e.toLowerCase()];return n!==0[0]?this.setHex(n,t):warn("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=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=SRGBColorSpace){return ColorManagement.workingToColorSpace(_color.copy(this),e),Math.round(clamp(_color.r*255,0,255))*65536+Math.round(clamp(_color.g*255,0,255))*256+Math.round(clamp(_color.b*255,0,255))}getHexString(e=SRGBColorSpace){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ColorManagement.workingColorSpace){ColorManagement.workingToColorSpace(_color.copy(this),t);const{r:a,g:n,b:s}=_color,o=Math.max(a,n,s),r=Math.min(a,n,s);let i,c;const l=(r+o)/2;if(r===o)i=0,c=0;else{const e=o-r;switch(c=l<=.5?e/(o+r):e/(2-o-r),o){case a:i=(n-s)/e+(n<s?6:0);break;case n:i=(s-a)/e+2;break;case s:i=(a-n)/e+4;break}i/=6}return e.h=i,e.s=c,e.l=l,e}getRGB(e,t=ColorManagement.workingColorSpace){return ColorManagement.workingToColorSpace(_color.copy(this),t),e.r=_color.r,e.g=_color.g,e.b
vendor: 6,964 bytes, line 1
1=_color.b,e}getStyle(e=SRGBColorSpace){ColorManagement.workingToColorSpace(_color.copy(this),e);const{r:t,g:n,b:s}=_color;return e!==SRGBColorSpace?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(_hslA),this.setHSL(_hslA.h+e,_hslA.s+t,_hslA.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_hslA),e.getHSL(_hslB);const n=lerp(_hslA.h,_hslB.h,t),s=lerp(_hslA.s,_hslB.s,t),o=lerp(_hslA.l,_hslB.l,t);return this.setHSL(n,s,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,s=this.g,o=this.b,t=e.elements;return this.r=t[0]*n+t[3]*s+t[6]*o,this.g=t[1]*n+t[4]*s+t[7]*o,this.b=t[2]*n+t[5]*s+t[8]*o,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}_color=new Color,Color.NAMES=_colorKeywords,_materialId=0;class Material extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_materialId++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.blending=NormalBlending,this.side=FrontSide,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=SrcAlphaFactor,this.blendDst=OneMinusSrcAlphaFactor,this.blendEquation=AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Color(0,0,0),this.blendAlpha=0,this.depthFunc=LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AlwaysStencilFunc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=KeepStencilOp,this.stencilZFail=KeepStencilOp,this.stencilZPass=KeepStencilOp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!==e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===0[0])return;for(const s in e){const n=e[s];if(n===0[0]){warn(`Material: parameter '${s}' has value of undefined.`);continue}const t=this[s];if(t===0[0]){warn(`Material: '${s}' is not a property of THREE.${this.type}.`);continue}t&&t.isColor?t.set(n):t&&t.isVector3&&n&&n.isVector3?t.copy(n):this[s]=n}}toJSON(e){const n=e===0[0]||typeof e=="string";n&&(e={textures:{},images:{}});const t={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.color&&this.color.isColor&&(t.color=this.color.getHex()),this.roughness!==0[0]&&(t.roughness=this.roughness),this.metalness!==0[0]&&(t.metalness=this.metalness),this.sheen!==0[0]&&(t.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(t.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==0[0]&&(t.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(t.emissive=this.emissive.getHex()),this.emissiveIntensity!==0[0]&&this.emissiveIntensity!==1&&(t.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(t.specular=this.specular.getHex()),this.specularIntensity!==0[0]&&(t.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(t.specularColor=this.specularColor.getHex()),this.shininess!==0[0]&&(t.shininess=this.shininess),this.clearcoat!==0[0]&&(t.clearcoat=this.clearcoat),this.clearcoatRoughness!==0[0]&&(t.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(t.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(t.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(t.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,t.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(t.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(t.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==0[0]&&(t.dispersion=this.dispersion),this.iridescence!==0[0]&&(t.iridescence=this.iridescence),this.iridescenceIOR!==0[0]&&(t.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==0[0]&&(t.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(t.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(t.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==0[0]&&(t.anisotropy=this.anisotropy),this.anisotropyRotation!==0[0]&&(t.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(t.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(t.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(t.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(t.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(t.lightMap=this.lightMap.toJSON(e).uuid,t.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(t.aoMap=this.aoMap.toJSON(e).uuid,t.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(t.bumpMap=this.bumpMap.toJSON(e).uuid,t.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(t.normalMap=this.normalMap.toJSON(e).uuid,t.normalMapType=this.normalMapType,t.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(t.displacementMap=this.displacementMap.toJSON(e).uuid,t.dis
1placementScale=this.displacementScale,t.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(t.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(t.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(t.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(t.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(t.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(t.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(t.envMap=this.envMap.toJSON(e).uuid,this.combine!==0[0]&&(t.combine=this.combine)),this.envMapRotation!==0[0]&&(t.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==0[0]&&(t.envMapIntensity=this.envMapIntensity),this.reflectivity!==0[0]&&(t.reflectivity=this.reflectivity),this.refractionRatio!==0[0]&&(t.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(t.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==0[0]&&(t.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(t.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==0[0]&&(t.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(t.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==0[0]&&this.attenuationDistance!==1/0&&(t.attenuationDistance=this.attenuationDistance),this.attenuationColor!==0[0]&&(t.attenuationColor=this.attenuationColor.getHex()),this.size!==0[0]&&(t.size=this.size),this.shadowSide!==null&&(t.shadowSide=this.shadowSide),this.sizeAttenuation!==0[0]&&(t.sizeAttenuation=this.sizeAttenuation),this.blending!==NormalBlending&&(t.blending=this.blending),this.side!==FrontSide&&(t.side=this.side),this.vertexColors===!0&&(t.vertexColors=!0),this.opacity<1&&(t.opacity=this.opacity),this.transparent===!0&&(t.transparent=!0),this.blendSrc!==SrcAlphaFactor&&(t.blendSrc=this.blendSrc),this.blendDst!==OneMinusSrcAlphaFactor&&(t.blendDst=this.blendDst),this.blendEquation!==AddEquation&&(t.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(t.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(t.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(t.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(t.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(t.blendAlpha=this.blendAlpha),this.depthFunc!==LessEqualDepth&&(t.depthFunc=this.depthFunc),this.depthTest===!1&&(t.depthTest=this.depthTest),this.depthWrite===!1&&(t.depthWrite=this.depthWrite),this.colorWrite===!1&&(t.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(t.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==AlwaysStencilFunc&&(t.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(t.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(t.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==KeepStencilOp&&(t.stencilFail=this.stencilFail),this.stencilZFail!==KeepStencilOp&&(t.stencilZFail=this.stencilZFail),this.stencilZPass!==KeepStencilOp&&(t.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(t.stencilWrite=this.stencilWrite),this.rotation!==0[0]&&this.rotation!==0&&(t.rotation=this.rotation),this.polygonOffset===!0&&(t.polygonOffset=!0),this.polygonOffsetFactor!==0&&(t.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(t.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==0[0]&&this.linewidth!==1&&(t.linewidth=this.linewidth),this.dashSize!==0[0]&&(t.dashSize=this.dashSize),this.gapSize!==0[0]&&(t.gapSize=this.gapSize),this.scale!==0[0]&&(t.scale=this.scale),this.dithering===!0&&(t.dithering=!0),this.alphaTest>0&&(t.alphaTest=this.alphaTest),this.alphaHash===!0&&(t.alphaHash=!0),this.alphaToCoverage===!0&&(t.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(t.premultipliedAlpha=!0),this.forceSinglePass===!0&&(t.forceSinglePass=!0),this.allowOverride===!1&&(t.allowOverride=!1),this.wireframe===!0&&(t.wireframe=!0),this.wireframeLinewidth>1&&(t.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(t.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(t.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(t.flatShading=!0),this.visible===!1&&(t.visible=!1),this.toneMapped===!1&&(t.toneMapped=!1),this.fog===!1&&(t.fog=!1),Object.keys(this.userData).length>0&&(t.userData=this.userData);function s(e){const t=[];for(const s in e){const n=e[s];delete n.metadata,t.push(n)}return t}if(n){const n=s(e.textures),o=s(e.images);n.length>0&&(t.textures=n),o.length>0&&(t.images=o)}return t}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const e=t.length;n=new Array(e);for(let s=0;s!==e;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipSh
vendor: 4,233 bytes, line 1
1adows,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.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class MeshBasicMaterial extends Material{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(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 Euler,this.combine=MultiplyOperation,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}}_tables=_generateTables();function _generateTables(){const o=new ArrayBuffer(4),a=new Float32Array(o),r=new Uint32Array(o),e=new Uint32Array(512),t=new Uint32Array(512);for(let n=0;n<256;++n){const s=n-127;s<-27?(e[n]=0,e[n|256]=32768,t[n]=24,t[n|256]=24):s<-14?(e[n]=1024>>-s-14,e[n|256]=1024>>-s-14|32768,t[n]=-s-1,t[n|256]=-s-1):s<=15?(e[n]=s+15<<10,e[n|256]=s+15<<10|32768,t[n]=13,t[n|256]=13):s<128?(e[n]=31744,e[n|256]=64512,t[n]=24,t[n|256]=24):(e[n]=31744,e[n|256]=64512,t[n]=13,t[n|256]=13)}const s=new Uint32Array(2048),n=new Uint32Array(64),i=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;(t&8388608)===0;)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)n[e]=e<<23;n[31]=1199570944,n[32]=2147483648;for(let e=33;e<63;++e)n[e]=2147483648+(e-32<<23);n[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(i[e]=1024);return{floatView:a,uint32View:r,baseTable:e,shiftTable:t,mantissaTable:s,exponentTable:n,offsetTable:i}}function toHalfFloat(e){(e<0?-e:e)>65504&&warn("DataUtils.toHalfFloat(): Value out of range."),e=clamp(e,-65504,65504),_tables.floatView[0]=e;const t=_tables.uint32View[0],n=t>>23&511;return _tables.baseTable[n]+((t&8388607)>>_tables.shiftTable[n])}function fromHalfFloat(e){const t=e>>10;return _tables.uint32View[0]=_tables.mantissaTable[_tables.offsetTable[t]+(e&1023)]+_tables.exponentTable[t],_tables.floatView[0]}class DataUtils{static toHalfFloat(e){return toHalfFloat(e)}static fromHalfFloat(e){return fromHalfFloat(e)}}_vector$9=new Vector3,_vector2$1=new Vector2,_id$2=0;class BufferAttribute{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:_id$2++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==0[0]?e.length/t:0,this.normalized=n,this.usage=StaticDrawUsage,this.updateRanges=[],this.gpuType=FloatType,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;
vendor: 4,248 bytes, line 1
1for(let s=0,o=this.itemSize;s<o;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)_vector2$1.fromBufferAttribute(this,t),_vector2$1.applyMatrix3(e),this.setXY(t,_vector2$1.x,_vector2$1.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)_vector$9.fromBufferAttribute(this,t),_vector$9.applyMatrix3(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_vector$9.fromBufferAttribute(this,t),_vector$9.applyMatrix4(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_vector$9.fromBufferAttribute(this,t),_vector$9.applyNormalMatrix(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_vector$9.fromBufferAttribute(this,t),_vector$9.transformDirection(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=denormalize(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=normalize(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=denormalize(t,this.array)),t}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=denormalize(t,this.array)),t}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=denormalize(t,this.array)),t}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=denormalize(t,this.array)),t}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,o){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=o,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==StaticDrawUsage&&(e.usage=this.usage),e}}class Uint16BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Uint32BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Float16BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=fromHalfFloat(this.array[e*this.itemSize]);return this.normalized&&(t=denormalize(t,this.array)),t}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize]=toHalfFloat(t),this}getY(e){let t=fromHalfFloat(this.array[e*this.itemSize+1]);return this.normalized&&(t=denormalize(t,this.array)),t}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+1]=toHalfFloat(t),this}getZ(e){let t=fromHalfFloat(this.array[e*this.itemSize+2]);return this.normalized&&(t=denormalize(t,this.array)),t}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+2]=toHalfFloat(t),this}getW(e){let t=fromHalfFloat(this.array[e*this.itemSize+3]);return this.normalized&&(t=denormalize(t,this.array)),t}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+3]=toH
vendor: 92,893 bytes, lines 1-40
1alfFloat(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array)),this.array[e+0]=toHalfFloat(t),this.array[e+1]=toHalfFloat(n),this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array)),this.array[e+0]=toHalfFloat(t),this.array[e+1]=toHalfFloat(n),this.array[e+2]=toHalfFloat(s),this}setXYZW(e,t,n,s,o){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.array[e+0]=toHalfFloat(t),this.array[e+1]=toHalfFloat(n),this.array[e+2]=toHalfFloat(s),this.array[e+3]=toHalfFloat(o),this}}class Float32BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Float32Array(e),t,n)}}_id$1=0,_m1=new Matrix4,_obj=new Object3D,_offset=new Vector3,_box$2=new Box3,_boxMorphTargets=new Box3,_vector$8=new Vector3;class BufferGeometry extends EventDispatcher{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_id$1++}),this.uuid=generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(arrayNeedsUint32(e)?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==0[0]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==0[0]&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==0[0]){const t=(new Matrix3).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==0[0]&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _m1.makeRotationFromQuaternion(e),this.applyMatrix4(_m1),this}rotateX(e){return _m1.makeRotationX(e),this.applyMatrix4(_m1),this}rotateY(e){return _m1.makeRotationY(e),this.applyMatrix4(_m1),this}rotateZ(e){return _m1.makeRotationZ(e),this.applyMatrix4(_m1),this}translate(e,t,n){return _m1.makeTranslation(e,t,n),this.applyMatrix4(_m1),this}scale(e,t,n){return _m1.makeScale(e,t,n),this.applyMatrix4(_m1),this}lookAt(e){return _obj.lookAt(e),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===0[0]){const t=[];for(let n=0,o=e.length;n<o;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Float32BufferAttribute(t,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const o=e[s];t.setXYZ(s,o.x,o.y,o.z||0)}e.length>t.count&&warn("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 Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){error("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Vector3(-(1/0),-(1/0),-(1/0)),new Vector3(1/0,1/0,1/0));return}if(e!==0[0]){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const s=t[e];_box$2.setFromBufferAttribute(s),this.morphTargetsRelative?(_vector$8.addVectors(this.boundingBox.min,_box$2.min),this.boundingBox.expandByPoint(_vector$8),_vector$8.addVectors(this.boundingBox.max,_box$2.max),this.boundingBox.expandByPoint(_vector$8)):(this.boundingBox.expandByPoint(_box$2.min),this.boundingBox.expandByPoint(_box$2.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&error('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){error("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Vector3,1/0);return}if(e){const s=this.boundingSphere.center;if(_box$2.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const s=t[e];_boxMorphTargets.setFromBufferAttribute(s),this.morphTargetsRelative?(_vector$8.addVectors(_box$2.min,_boxMorphTargets.min),_box$2.expandByPoint(_vector$8),_vector$8.addVectors(_box$2.max,_boxMorphTargets.max),_box$2.expandByPoint(_vector$8)):(_box$2.expandByPoint(_boxMorphTargets.min),_box$2.expandByPoint(_boxMorphTargets.max))}_box$2.getCenter(s);let n=0;for(let t=0,o=e.count;t<o;t++)_vector$8.fromBufferAttribute(e,t),n=Math.max(n,s.distanceToSquared(_vector$8));if(t)for(let o=0,a=t.length;o<a;o++){const i=t[o],r=this.morphTargetsRelative;for(let t=0,o=i.count;t<o;t++)_vector$8.fromBufferAttribute(i,t),r&&(_offset.fromBufferAttribute(e,t),_vector$8.add(_offset)),n=Math.max(n,s.distanceToSquared(_vector$8))}this.boundingSphere.radius=n**.5,isNaN(this.boundingSphere.radius)&&error('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===0[0]||n.normal===0[0]||n.uv===0[0]){error("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=n.position,y=n.normal,v=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new BufferAttribute(new Float32Array(4*i.count),4));const w=this.getAttribute("tangent"),r=[],c=[];for(let e=0;e<i.count;e++)r[e]=new Vector3,c[e]=new Vector3;const p=new Vector3,u=new Vector3,d=new Vector3,f=new Vector2,t=new Vector2,o=new Vector2,h=new Vector3,l=new Vector3;function _(e,n,s){p.fromBufferAttribute(i,e),u.fromBufferAttribute(i,n),d.fromBufferAttribute(i,s),f.fromBufferAttribute(v,e),t.fromBufferAttribute(v,n),o.fromBufferAttribute(v,s),u.sub(p),d.sub(p),t.sub(f),o.sub(f);const a=1/(t.x*o.y-o.x*t.y);if(!isFinite(a))return;h.copy(u).multiplyScalar(o.y).addScaledVector(d,-t.y).multiplyScalar(a),l.copy(d).multiplyScalar(t.x).addScaledVector(u,-o.x).multiplyScalar(a),r[e].add(h),r[n].add(h),r[s].add(h),c[e].add(l),c[n].add(l),c[s].add(l)}let s=this.groups;s.length===0&&(s=[{start:0,count:e.count}]);for(let t=0,i=s.length;t<i;++t){const n=s[t],o=n.start,a=n.count;for(let t=o,n=o+a;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}const a=new Vector3,b=new Vector3,m=new Vector3,j=new Vector3;function g(e){m.fromBufferAttribute(y,e),j.copy(m);const t=r[e];a.copy(t),a.sub(m.multiplyScalar(m.dot(t))).normalize(),b.crossVectors(j,t);const n=b.dot(c[e]),s=n<0?-1:1;w.setXYZW(e,a.x,a.y,a.z,s)}for(let t=0,i=s.length;t<i;++t){const n=s[t],o=n.start,a=n.count;for(let t=o,n=o+a;t<n;t+=3)g(e.getX(t+0)),g(e.getX(t+1)),g(e.getX(t+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==0[0]){let s=this.getAttribute("normal");if(s===0[0])s=new BufferAttribute(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let e=0,t=s.count;e<t;e++)s.setXYZ(e,0,0,0);const c=new Vector3,o=new Vector3,l=new Vector3,i=new Vector3,a=new Vector3,r=new Vector3,n=new Vector3,d=new Vector3;if(t)for(let u=0,p=t.count;u<p;u+=3){const h=t.getX(u+0),m=t.getX(u+1),f=t.getX(u+2);c.fromBufferAttribute(e,h),o.fromBufferAttribute(e,m),l.fromBufferAttribute(e,f),n.subVectors(l,o),d.subVectors(c,o),n.cross(d),i.fromBufferAttribute(s,h),a.fromBufferAttribute(s,m),r.fromBufferAttribute(s,f),i.add(n),a.add(n),r.add(n),s.setXYZ(h,i.x,i.y,i.z),s.setXYZ(m,a.x,a.y,a.z),s.setXYZ(f,r.x,r.y,r.z)}else for(let t=0,i=e.count;t<i;t+=3)c.fromBufferAttribute(e,t+0),o.fromBufferAttribute(e,t+1),l.fromBufferAttribute(e,t+2),n.subVectors(l,o),d.subVectors(c,o),n.cross(d),s.setXYZ(t+0,n.x,n.y,n.z),s.setXYZ(t+1,n.x,n.y,n.z),s.setXYZ(t+2,n.x,n.y,n.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_vector$8.fromBufferAttribute(e,t),_vector$8.normalize(),e.setXYZ(t,_vector$8.x,_vector$8.y,_vector$8.z)}toNonIndexed(){function t(e,t){const o=e.array,n=e.itemSize,a=e.normalized,i=new o.constructor(t.length*n);let s=0,r=0;for(let a=0,c=t.length;a<c;a++){e.isInterleavedBufferAttribute?s=t[a]*e.data.stride+e.offset:s=t[a]*n;for(let e=0;e<n;e++)i[r++]=o[s++]}return new BufferAttribute(i,n,a)}if(this.index===null)return warn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new BufferGeometry,n=this.index.array,s=this.attributes;for(const o in s){const i=s[o],a=t(i,n);e.setAttribute(o,a)}const o=this.morphAttributes;for(const s in o){const i=[],a=o[s];for(let e=0,s=a.length;e<s;e++){const o=a[e],r=t(o,n);i.push(r)}e.morphAttributes[s]=i}e.morphTargetsRelative=this.morphTargetsRelative;const i=this.groups;for(let t=0,s=i.length;t<s;t++){const n=i[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==0[0]){const t=this.parameters;for(const n in t)t[n]!==0[0]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const s=n[t];e.data.attributes[t]=s.toJSON(e.data)}const s={};let o=!1;for(const n in this.morphAttributes){const i=this.morphAttributes[n],t=[];for(let n=0,s=i.length;n<s;n++){const o=i[n];t.push(o.toJSON(e.data))}t.length>0&&(s[n]=t,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const i=this.groups;i.length>0&&(e.data.groups=JSON.parse(JSON.stringify(i)));const 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;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const e in s){const n=s[e];this.setAttribute(e,n.clone(t))}const o=e.morphAttributes;for(const e in o){const n=[],s=o[e];for(let e=0,o=s.length;e<o;e++)n.push(s[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const i=e.groups;for(let e=0,n=i.length;e<n;e++){const t=i[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const r=e.boundingSphere;return r!==null&&(this.boundingSphere=r.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}_inverseMatrix$3=new Matrix4,_ray$3=new Ray,_sphere$6=new Sphere,_sphereHitAt=new Vector3,_vA$1=new Vector3,_vB$1=new Vector3,_vC$1=new Vector3,_tempA=new Vector3,_morphA=new Vector3,_intersectionPoint=new Vector3,_intersectionPointWorld=new Vector3;class Mesh extends Object3D{constructor(e=new BufferGeometry,t=new MeshBasicMaterial){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=0[0],this.morphTargetInfluences=0[0],this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==0[0]&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==0[0]&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry,e=n.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==0[0]){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const s=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=e}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){_morphA.set(0,0,0);for(let n=0,r=s.length;n<r;n++){const i=o[n],c=s[n];if(i===0)continue;_tempA.fromBufferAttribute(c,e),a?_morphA.addScaledVector(_tempA,i):_morphA.addScaledVector(_tempA.sub(t),i)}t.add(_morphA)}return t}raycast(e,t){const n=this.geometry,o=this.material,s=this.matrixWorld;if(o===0[0])return;if(n.boundingSphere===null&&n.computeBoundingSphere(),_sphere$6.copy(n.boundingSphere),_sphere$6.applyMatrix4(s),_ray$3.copy(e.ray).recast(e.near),_sphere$6.containsPoint(_ray$3.origin)===!1){if(_ray$3.intersectSphere(_sphere$6,_sphereHitAt)===null)return;if(_ray$3.origin.distanceToSquared(_sphereHitAt)>(e.far-e.near)**2)return}if(_inverseMatrix$3.copy(s).invert(),_ray$3.copy(e.ray).applyMatrix4(_inverseMatrix$3),n.boundingBox!==null&&_ray$3.intersectsBox(n.boundingBox)===!1)return;this._computeIntersections(e,t,_ray$3)}_computeIntersections(e,t,n){let s;const a=this.geometry,r=this.material,i=a.index,h=a.attributes.position,c=a.attributes.uv,l=a.attributes.uv1,d=a.attributes.normal,u=a.groups,o=a.drawRange;if(i!==null)if(Array.isArray(r))for(let h=0,m=u.length;h<m;h++){const a=u[h],f=r[a.materialIndex],p=Math.max(a.start,o.start),g=Math.min(i.count,Math.min(a.start+a.count,o.start+o.count));for(let o=p,r=g;o<r;o+=3){const u=i.getX(o),h=i.getX(o+1),m=i.getX(o+2);s=checkGeometryIntersection(this,f,e,n,c,l,d,u,h,m),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=a.materialIndex,t.push(s))}}else{const a=Math.max(0,o.start),u=Math.min(i.count,o.start+o.count);for(let o=a,h=u;o<h;o+=3){const m=i.getX(o),f=i.getX(o+1),p=i.getX(o+2);s=checkGeometryIntersection(this,r,e,n,c,l,d,m,f,p),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}else if(h!==0[0])if(Array.isArray(r))for(let a=0,m=u.length;a<m;a++){const i=u[a],f=r[i.materialIndex],p=Math.max(i.start,o.start),g=Math.min(h.count,Math.min(i.start+i.count,o.start+o.count));for(let o=p,a=g;o<a;o+=3){const r=o,u=o+1,h=o+2;s=checkGeometryIntersection(this,f,e,n,c,l,d,r,u,h),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=i.materialIndex,t.push(s))}}else{const i=Math.max(0,o.start),a=Math.min(h.count,o.start+o.count);for(let o=i,u=a;o<u;o+=3){const h=o,m=o+1,f=o+2;s=checkGeometryIntersection(this,r,e,n,c,l,d,h,m,f),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}}}function checkIntersection$1(e,t,n,s,o,i,a,r){let c;if(t.side===BackSide?c=s.intersectTriangle(a,i,o,!0,r):c=s.intersectTriangle(o,i,a,t.side===FrontSide,r),c===null)return null;_intersectionPointWorld.copy(r),_intersectionPointWorld.applyMatrix4(e.matrixWorld);const l=n.ray.origin.distanceTo(_intersectionPointWorld);return l<n.near||l>n.far?null:{distance:l,point:_intersectionPointWorld.clone(),object:e}}function checkGeometryIntersection(e,t,n,s,o,i,a,r,c,l){e.getVertexPosition(r,_vA$1),e.getVertexPosition(c,_vB$1),e.getVertexPosition(l,_vC$1);const d=checkIntersection$1(e,t,n,s,_vA$1,_vB$1,_vC$1,_intersectionPoint);if(d){const e=new Vector3;Triangle.getBarycoord(_intersectionPoint,_vA$1,_vB$1,_vC$1,e),o&&(d.uv=Triangle.getInterpolatedAttribute(o,r,c,l,e,new Vector2)),i&&(d.uv1=Triangle.getInterpolatedAttribute(i,r,c,l,e,new Vector2)),a&&(d.normal=Triangle.getInterpolatedAttribute(a,r,c,l,e,new Vector3),d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1));const t={a:r,b:c,c:l,normal:new Vector3,materialIndex:0};Triangle.getNormal(_vA$1,_vB$1,_vC$1,t.normal),d.face=t,d.barycoord=e}return d}class BoxGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,s=1,o=1,i=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:o,depthSegments:i};const m=this;s=Math.floor(s),o=Math.floor(o),i=Math.floor(i);const c=[],d=[],u=[],l=[];let r=0,h=0;a("z","y","x",-1,-1,n,t,e,i,o,0),a("z","y","x",1,-1,n,t,-e,i,o,1),a("x","z","y",1,1,e,n,t,s,i,2),a("x","z","y",1,-1,e,n,-t,s,i,3),a("x","y","z",1,-1,e,t,n,s,o,4),a("x","y","z",-1,-1,e,t,-n,s,o,5),this.setIndex(c),this.setAttribute("position",new Float32BufferAttribute(d,3)),this.setAttribute("normal",new Float32BufferAttribute(u,3)),this.setAttribute("uv",new Float32BufferAttribute(l,2));function a(e,t,n,s,o,i,a,f,p,g,v){const w=i/p,O=a/g,x=i/2,C=a/2,E=f/2,j=p+1,k=g+1;let _=0,y=0;const b=new Vector3;for(let i=0;i<k;i++){const a=i*O-C;for(let r=0;r<j;r++){const c=r*w-x;b[e]=c*s,b[t]=a*o,b[n]=E,d.push(b.x,b.y,b.z),b[e]=0,b[t]=0,b[n]=f>0?1:-1,u.push(b.x,b.y,b.z),l.push(r/p),l.push(1-i/g),_+=1}}for(let e=0;e<g;e++)for(let t=0;t<p;t++){const o=r+t+j*e,n=r+t+j*(e+1),i=r+(t+1)+j*(e+1),s=r+(t+1)+j*e;c.push(o,n,s),c.push(n,i,s),y+=6}m.addGroup(h,y,v),h+=y,r+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new BoxGeometry(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cloneUniforms(e){const t={};for(const n in e){t[n]={};for(const o in e[n]){const s=e[n][o];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][o]=null):t[n][o]=s.clone():Array.isArray(s)?t[n][o]=s.slice():t[n][o]=s}}return t}function mergeUniforms(e){const t={};for(let n=0;n<e.length;n++){const s=cloneUniforms(e[n]);for(const e in s)t[e]=s[e]}return t}function cloneUniformsGroups(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}default_vertex=`void main() { 2 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 3}`,default_fragment=`void main() { 4 gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); 5}`;class ShaderMaterial extends Material{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=default_vertex,this.fragmentShader=default_fragment,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=0[0],this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==0[0]&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.uniformsGroups=cloneUniformsGroups(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const o=this.uniforms[s],n=o.value;n&&n.isTexture?t.uniforms[s]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[s]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[s]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[s]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[s]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[s]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[s]={type:"m4",value:n.toArray()}:t.uniforms[s]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4,this.coordinateSystem=WebGLCoordinateSystem,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)}}_v3$1=new Vector3,_minTarget=new Vector2,_maxTarget=new Vector2;class PerspectiveCamera extends Camera{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(DEG2RAD*.5*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return RAD2DEG*2*Math.atan(Math.tan(DEG2RAD*.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){_v3$1.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(_v3$1.x,_v3$1.y).multiplyScalar(-e/_v3$1.z),_v3$1.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(_v3$1.x,_v3$1.y).multiplyScalar(-e/_v3$1.z)}getViewSize(e,t){return this.getViewBounds(e,_minTarget,_maxTarget),t.subVectors(_maxTarget,_minTarget)}setViewOffset(e,t,n,s,o,i){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=s,this.view.width=o,this.view.height=i,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const i=this.near;let t=i*Math.tan(DEG2RAD*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,o=-.5*s;const e=this.view;if(this.view!==null&&this.view.enabled){const{fullWidth:i,fullHeight:a}=e;o+=e.offsetX*s/i,t-=e.offsetY*n/a,s*=e.width/i,n*=e.height/a}const a=this.filmOffset;a!==0&&(o+=i*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-n,i,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}fov=-90,aspect=1;class CubeCamera extends Object3D{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new PerspectiveCamera(fov,aspect,e,t);s.layers=this.layers,this.add(s);const o=new PerspectiveCamera(fov,aspect,e,t);o.layers=this.layers,this.add(o);const i=new PerspectiveCamera(fov,aspect,e,t);i.layers=this.layers,this.add(i);const a=new PerspectiveCamera(fov,aspect,e,t);a.layers=this.layers,this.add(a);const r=new PerspectiveCamera(fov,aspect,e,t);r.layers=this.layers,this.add(r);const c=new PerspectiveCamera(fov,aspect,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const a=this.coordinateSystem,r=this.children.concat(),[e,t,n,s,o,i]=r;for(const e of r)this.remove(e);if(a===WebGLCoordinateSystem)e.up.set(0,1,0),e.lookAt(1,0,0),t.up.set(0,1,0),t.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),i.up.set(0,1,0),i.lookAt(0,0,-1);else if(a===WebGPUCoordinateSystem)e.up.set(0,-1,0),e.lookAt(-1,0,0),t.up.set(0,-1,0),t.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),i.up.set(0,-1,0),i.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+a);for(const e of r)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,i,a,r,c,l]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,o),e.setRenderTarget(n,1,s),e.render(t,i),e.setRenderTarget(n,2,s),e.render(t,a),e.setRenderTarget(n,3,s),e.render(t,r),e.setRenderTarget(n,4,s),e.render(t,c),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,s),e.render(t,l),e.setRenderTarget(d,u,h),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(e=[],t=CubeReflectionMapping,n,s,o,i,a,r,c,l){super(e,t,n,s,o,i,a,r,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new CubeTexture(s),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;const n={uniforms:{tEquirect:{value:null}},vertexShader:` 6 7 varying vec3 vWorldDirection; 8 9 vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 10 11 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 12 13 } 14 15 void main() { 16 17 vWorldDirection = transformDirection( position, modelMatrix ); 18 19 #include <begin_vertex> 20 #include <project_vertex> 21 22 } 23 `,fragmentShader:` 24 25 uniform sampler2D tEquirect; 26 27 varying vec3 vWorldDirection; 28 29 #include <common> 30 31 void main() { 32 33 vec3 direction = normalize( vWorldDirection ); 34 35 vec2 sampleUV = equirectUv( direction ); 36 37 gl_FragColor = texture2D( tEquirect, sampleUV ); 38 39 } 40 `},i=new BoxGeometry(5,5,5),o=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:BackSide,blending:NoBlending});o.uniforms.tEquirect.value=t;const s=new Mesh(i,o),a=t.minFilter;t.minFilter===LinearMipmapLinearFilter&&(t.minFilter=LinearFilter);const r=new CubeCamera(1,10,this);return r.update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const o=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(o)}}class Group extends Object3D{constructor(){super(),this.isGroup=!0,this.type="Group"}}_moveEvent={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Group,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 Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Vector3),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Vector3),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,a=null,c=null;const s=this._targetRay,o=this._grip,r=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(r&&e.hand){c=!0;for(const i of e.hand.values()){const o=t.getJointPose(i,n),s=this._getHandJoint(r,i);o!==null&&(s.matrix.fromArray(o.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,s.jointRadius=o.radius),s.visible=o!==null}const a=r.joints["index-finger-tip"],l=r.joints["thumb-tip"],s=a.position.distanceTo(l.position),o=.02,i=.005;r.inputState.pinching&&s>o+i?(r.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!r.inputState.pinching&&s<=o-i&&(r.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,n),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1));s!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&a!==null&&(i=a),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent)))}return s!==null&&(s.visible=i!==null),o!==null&&(o.visible=a!==null),r!==null&&(r.visible=c!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===0[0]){const n=new Group;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Scene extends Object3D{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 Euler,this.environmentIntensity=1,this.environmentRotation=new Euler,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){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class InterleavedBuffer{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==0[0]?e.length/t:0,this.usage=StaticDrawUsage,this.updateRanges=[],this.version=0,this.uuid=generateUUID()}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 s=0,o=this.stride;s<o;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===0[0]&&(e.arrayBuffers={}),this.array.buffer._uuid===0[0]&&(this.array.buffer._uuid=generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===0[0]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),t=new this.constructor(n,this.stride);return t.setUsage(this.usage),t}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===0[0]&&(e.arrayBuffers={}),this.array.buffer._uuid===0[0]&&(this.array.buffer._uuid=generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===0[0]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}_vector$7=new Vector3;class InterleavedBufferAttribute{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)_vector$7.fromBufferAttribute(this,t),_vector$7.applyMatrix4(e),this.setXYZ(t,_vector$7.x,_vector$7.y,_vector$7.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_vector$7.fromBufferAttribute(this,t),_vector$7.applyNormalMatrix(e),this.setXYZ(t,_vector$7.x,_vector$7.y,_vector$7.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_vector$7.fromBufferAttribute(this,t),_vector$7.transformDirection(e),this.setXYZ(t,_vector$7.x,_vector$7.y,_vector$7.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=denormalize(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=normalize(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=denormalize(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=denormalize(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=denormalize(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=denormalize(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),n=normalize(n,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=o,this}clone(e){if(e===0[0]){log("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return e.interleavedBuffers===0[0]&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===0[0]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===0[0]){log("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===0[0]&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===0[0]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class SpriteMaterial extends Material{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}_basePosition=new Vector3,_skinIndex=new Vector4,_skinWeight=new Vector4,_vector3=new Vector3,_matrix4=new Matrix4,_vertex=new Vector3,_sphere$5=new Sphere,_inverseMatrix$2=new Matrix4,_ray$2=new Ray;class SkinnedMesh extends Mesh{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=AttachedBindMode,this.bindMatrix=new Matrix4,this.bindMatrixInverse=new Matrix4,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Box3),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,_vertex),this.boundingBox.expandByPoint(_vertex)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Sphere),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,_vertex),this.boundingSphere.expandByPoint(_vertex)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const s=this.material,n=this.matrixWorld;if(s===0[0])return;if(this.boundingSphere===null&&this.computeBoundingSphere(),_sphere$5.copy(this.boundingSphere),_sphere$5.applyMatrix4(n),e.ray.intersectsSphere(_sphere$5)===!1)return;if(_inverseMatrix$2.copy(n).invert(),_ray$2.copy(e.ray).applyMatrix4(_inverseMatrix$2),this.boundingBox!==null&&_ray$2.intersectsBox(this.boundingBox)===!1)return;this._computeIntersections(e,t,_ray$2)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===0[0]&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let n=0,o=t.count;n<o;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===AttachedBindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===DetachedBindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():warn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;_skinIndex.fromBufferAttribute(s.attributes.skinIndex,e),_skinWeight.fromBufferAttribute(s.attributes.skinWeight,e),_basePosition.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const s=_skinWeight.getComponent(e);if(s!==0){const o=_skinIndex.getComponent(e);_matrix4.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(_vector3.copy(_basePosition).applyMatrix4(_matrix4),s)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Bone extends Object3D{constructor(){super(),this.isBone=!0,this.type="Bone"}}class DataTexture extends Texture{constructor(e=null,t=1,n=1,s,o,i,a,r,c=NearestFilter,l=NearestFilter,d,u){super(null,i,a,r,c,l,s,o,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}_offsetMatrix=new Matrix4,_identityMatrix=new Matrix4;class Skeleton{constructor(e=[],t=[]){this.uuid=generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){warn("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Matrix4)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,n=this.bones.length;e<n;e++){const t=new Matrix4;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,n=this.bones.length;e<n;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let t=0,n=this.bones.length;t<n;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const e=this.bones,n=this.boneInverses,s=this.boneMatrices,t=this.boneTexture;for(let t=0,o=e.length;t<o;t++){const i=e[t]?e[t].matrixWorld:_identityMatrix;_offsetMatrix.multiplyMatrices(i,n[t]),_offsetMatrix.toArray(s,t*16)}t!==null&&(t.needsUpdate=!0)}clone(){return new Skeleton(this.bones,this.boneInverses)}computeBoneTexture(){let e=(this.bones.length*4)**.5;e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new DataTexture(t,e,e,RGBAFormat,FloatType);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,s=this.bones.length;t<s;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const o=e.bones[n];let s=t[o];s===0[0]&&(warn("Skeleton: No bone found with UUID:",o),s=new Bone),this.bones.push(s),this.boneInverses.push((new Matrix4).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let s=0,o=t.length;s<o;s++){const i=t[s];e.bones.push(i.uuid);const a=n[s];e.boneInverses.push(a.toArray())}return e}}class InstancedBufferAttribute extends BufferAttribute{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}_instanceLocalMatrix=new Matrix4,_instanceWorldMatrix=new Matrix4,_instanceIntersects=[],_box3=new Box3,_identity=new Matrix4,_mesh$1=new Mesh,_sphere$4=new Sphere;class InstancedMesh extends Mesh{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new InstancedBufferAttribute(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,_identity)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Box3),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_instanceLocalMatrix),_box3.copy(e.boundingBox).applyMatrix4(_instanceLocalMatrix),this.boundingBox.union(_box3)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Sphere),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_instanceLocalMatrix),_sphere$4.copy(e.boundingSphere).applyMatrix4(_instanceLocalMatrix),this.boundingSphere.union(_sphere$4)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,o=n.length+1,i=e*o+1;for(let e=0;e<n.length;e++)n[e]=s[i+e]}raycast(e,t){const n=this.matrixWorld,s=this.count;if(_mesh$1.geometry=this.geometry,_mesh$1.material=this.material,_mesh$1.material===0[0])return;if(this.boundingSphere===null&&this.computeBoundingSphere(),_sphere$4.copy(this.boundingSphere),_sphere$4.applyMatrix4(n),e.ray.intersectsSphere(_sphere$4)===!1)return;for(let o=0;o<s;o++){this.getMatrixAt(o,_instanceLocalMatrix),_instanceWorldMatrix.multiplyMatrices(n,_instanceLocalMatrix),_mesh$1.matrixWorld=_instanceWorldMatrix,_mesh$1.raycast(e,_instanceIntersects);for(let e=0,s=_instanceIntersects.length;e<s;e++){const n=_instanceIntersects[e];n.instanceId=o,n.object=this,t.push(n)}_instanceIntersects.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new InstancedBufferAttribute(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new DataTexture(new Float32Array(s*this.count),s,this.count,RedFormat,FloatType));const o=this.morphTexture.source.data.data;let i=0;for(let e=0;e<n.length;e++)i+=n[e];const r=this.geometry.morphTargetsRelative?1:1-i,a=s*e;o[a]=r,o.set(n,a+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}_vector1=new Vector3,_vector2=new Vector3,_normalMatrix=new Matrix3;class Plane{constructor(e=new Vector3(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=_vector1.subVectors(n,t).cross(_vector2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const s=e.delta(_vector1),o=this.normal.dot(s);if(o===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/o;return n<0||n>1?null:t.copy(e.start).addScaledVector(s,n)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||_normalMatrix.getNormalMatrix(e),s=this.coplanarPoint(_vector1).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(o),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)}}_sphere$3=new Sphere,_defaultSpriteCenter=new Vector2(.5,.5),_vector$6=new Vector3;class Frustum{constructor(e=new Plane,t=new Plane,n=new Plane,s=new Plane,o=new Plane,i=new Plane){this.planes=[e,t,n,s,o,i]}set(e,t,n,s,o,i){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(o),a[5].copy(i),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=WebGLCoordinateSystem,n=!1){const o=this.planes,s=e.elements,y=s[0],v=s[1],d=s[2],c=s[3],f=s[4],m=s[5],l=s[6],r=s[7],p=s[8],g=s[9],u=s[10],a=s[11],b=s[12],j=s[13],h=s[14],i=s[15];if(o[0].setComponents(c-y,r-f,a-p,i-b).normalize(),o[1].setComponents(c+y,r+f,a+p,i+b).normalize(),o[2].setComponents(c+v,r+m,a+g,i+j).normalize(),o[3].setComponents(c-v,r-m,a-g,i-j).normalize(),n)o[4].setComponents(d,l,u,h).normalize(),o[5].setComponents(c-d,r-l,a-u,i-h).normalize();else if(o[4].setComponents(c-d,r-l,a-u,i-h).normalize(),t===WebGLCoordinateSystem)o[5].setComponents(c+d,r+l,a+u,i+h).normalize();else if(t===WebGPUCoordinateSystem)o[5].setComponents(d,l,u,h).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==0[0])e.boundingSphere===null&&e.computeBoundingSphere(),_sphere$3.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),_sphere$3.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_sphere$3)}intersectsSprite(e){_sphere$3.center.set(0,0,0);const t=_defaultSpriteCenter.distanceTo(e.center);return _sphere$3.radius=.7071067811865476+t,_sphere$3.applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$3)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let e=0;e<6;e++){const o=t[e].distanceToPoint(n);if(o<s)return!1}return!0}intersectsBox(e){const t=this.planes;for(let s=0;s<6;s++){const n=t[s];if(_vector$6.x=n.normal.x>0?e.max.x:e.min.x,_vector$6.y=n.normal.y>0?e.max.y:e.min.y,_vector$6.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(_vector$6)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}_projScreenMatrix$1=new Matrix4,_frustum$1=new Frustum;class FrustumArray{constructor(){this.coordinateSystem=WebGLCoordinateSystem}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let s=0;s<t.cameras.length;s++){const n=t.cameras[s];if(_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),_frustum$1.setFromProjectionMatrix(_projScreenMatrix$1,n.coordinateSystem,n.reversedDepth),_frustum$1.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let s=0;s<t.cameras.length;s++){const n=t.cameras[s];if(_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),_frustum$1.setFromProjectionMatrix(_projScreenMatrix$1,n.coordinateSystem,n.reversedDepth),_frustum$1.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let s=0;s<t.cameras.length;s++){const n=t.cameras[s];if(_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),_frustum$1.setFromProjectionMatrix(_projScreenMatrix$1,n.coordinateSystem,n.reversedDepth),_frustum$1.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let s=0;s<t.cameras.length;s++){const n=t.cameras[s];if(_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),_frustum$1.setFromProjectionMatrix(_projScreenMatrix$1,n.coordinateSystem,n.reversedDepth),_frustum$1.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let s=0;s<t.cameras.length;s++){const n=t.cameras[s];if(_projScreenMatrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),_frustum$1.setFromProjectionMatrix(_projScreenMatrix$1,n.coordinateSystem,n.reversedDepth),_frustum$1.containsPoint(e))return!0}return!1}clone(){return new FrustumArray}}class LineBasicMaterial extends Material{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Color(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}_vStart=new Vector3,_vEnd=new Vector3,_inverseMatrix$1=new Matrix4,_ray$1=new Ray,_sphere$1=new Sphere,_intersectPointOnRay=new Vector3,_intersectPointOnSegment=new Vector3;class Line extends Object3D{constructor(e=new BufferGeometry,t=new LineBasicMaterial){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=0[0],this.morphTargetInfluences=0[0],this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,t=[0];for(let e=1,s=n.count;e<s;e++)_vStart.fromBufferAttribute(n,e-1),_vEnd.fromBufferAttribute(n,e),t[e]=t[e-1],t[e]+=_vStart.distanceTo(_vEnd);e.setAttribute("lineDistance",new Float32BufferAttribute(t,1))}else warn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,a=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_sphere$1.copy(n.boundingSphere),_sphere$1.applyMatrix4(a),_sphere$1.radius+=r,e.ray.intersectsSphere(_sphere$1)===!1)return;_inverseMatrix$1.copy(a).invert(),_ray$1.copy(e.ray).applyMatrix4(_inverseMatrix$1);const c=r/((this.scale.x+this.scale.y+this.scale.z)/3),i=c*c,l=this.isLineSegments?2:1,o=n.index,d=n.attributes,u=d.position;if(o!==null){{const a=Math.max(0,s.start),n=Math.min(o.count,s.start+s.count);for(let s=a,c=n-1;s<c;s+=l){const d=o.getX(s),u=o.getX(s+1),r=checkIntersection(this,e,_ray$1,i,d,u,s);r&&t.push(r)}if(this.isLineLoop){const r=o.getX(n-1),c=o.getX(a),s=checkIntersection(this,e,_ray$1,i,r,c,n-1);s&&t.push(s)}}}else{const o=Math.max(0,s.start),n=Math.min(u.count,s.start+s.count);for(let s=o,r=n-1;s<r;s+=l){const a=checkIntersection(this,e,_ray$1,i,s,s+1,s);a&&t.push(a)}if(this.isLineLoop){const s=checkIntersection(this,e,_ray$1,i,n-1,o,n-1);s&&t.push(s)}}}updateMorphTargets(){const n=this.geometry,e=n.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==0[0]){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const s=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=e}}}}}function checkIntersection(e,t,n,s,o,i,a){const c=e.geometry.attributes.position;_vStart.fromBufferAttribute(c,o),_vEnd.fromBufferAttribute(c,i);const l=n.distanceSqToSegment(_vStart,_vEnd,_intersectPointOnRay,_intersectPointOnSegment);if(l>s)return;_intersectPointOnRay.applyMatrix4(e.matrixWorld);const r=t.ray.origin.distanceTo(_intersectPointOnRay);if(r<t.near||r>t.far)return;return{distance:r,point:_intersectPointOnSegment.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}_start=new Vector3,_end=new Vector3;class LineSegments extends Line{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,t=[];for(let e=0,s=n.count;e<s;e+=2)_start.fromBufferAttribute(n,e),_end.fromBufferAttribute(n,e+1),t[e]=e===0?0:t[e-1],t[e+1]=t[e]+_start.distanceTo(_end);e.setAttribute("lineDistance",new Float32BufferAttribute(t,1))}else warn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class LineLoop extends Line{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class PointsMaterial extends Material{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}_inverseMatrix=new Matrix4,_ray=new Ray,_sphere=new Sphere,_position$2=new Vector3;class Points extends Object3D{constructor(e=new BufferGeometry,t=new PointsMaterial){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=0[0],this.morphTargetInfluences=0[0],this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,o=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_sphere.copy(n.boundingSphere),_sphere.applyMatrix4(o),_sphere.radius+=r,e.ray.intersectsSphere(_sphere)===!1)return;_inverseMatrix.copy(o).invert(),_ray.copy(e.ray).applyMatrix4(_inverseMatrix);const c=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,i=n.index,d=n.attributes,a=d.position;if(i!==null){const n=Math.max(0,s.start),r=Math.min(i.count,s.start+s.count);for(let s=n,d=r;s<d;s++){const c=i.getX(s);_position$2.fromBufferAttribute(a,c),testPoint(_position$2,c,l,o,e,t,this)}}else{const n=Math.max(0,s.start),i=Math.min(a.count,s.start+s.count);for(let s=n,r=i;s<r;s++)_position$2.fromBufferAttribute(a,s),testPoint(_position$2,s,l,o,e,t,this)}}updateMorphTargets(){const n=this.geometry,e=n.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==0[0]){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const s=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=e}}}}}function testPoint(e,t,n,s,o,i,a){const r=_ray.distanceSqToPoint(e);if(r<n){const n=new Vector3;_ray.closestPointToPoint(e,n),n.applyMatrix4(s);const c=o.ray.origin.distanceTo(n);if(c<o.near||c>o.far)return;i.push({distance:c,distanceToRay:r**.5,point:n,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class FramebufferTexture extends Texture{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.generateMipmaps=!1,this.needsUpdate=!0}}class CompressedTexture extends Texture{constructor(e,t,n,s,o,i,a,r,c,l,d,u){super(null,i,a,r,c,l,s,o,d,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(e,t,n,s,o,i){super(e,t,n,o,i),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=ClampToEdgeWrapping,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class CompressedCubeTexture extends CompressedTexture{constructor(e,t,n){super(0[0],e[0].width,e[0].height,t,n,CubeReflectionMapping),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class DepthTexture extends Texture{constructor(e,t,n=UnsignedIntType,s,o,i,a=NearestFilter,r=NearestFilter,c,l=DepthFormat,d=1){if(l!==DepthFormat&&l!==DepthStencilFormat)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,s,o,i,a,r,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Source(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class CubeDepthTexture extends DepthTexture{constructor(e,t=UnsignedIntType,n=CubeReflectionMapping,s,o,i=NearestFilter,a=NearestFilter,r,c=DepthFormat){const l={width:e,height:e,depth:1},d=[l,l,l,l,l,l];super(e,e,t,n,s,o,i,a,r,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class CylinderGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,s=32,o=1,i=!1,a=0,r=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:o,openEnded:i,thetaStart:a,thetaLength:r};const g=this;s=Math.floor(s),o=Math.floor(o);const c=[],u=[],h=[],m=[];let l=0;const d=[],p=n/2;let f=0;b(),i===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Float32BufferAttribute(u,3)),this.setAttribute("normal",new Float32BufferAttribute(h,3)),this.setAttribute("uv",new Float32BufferAttribute(m,2));function b(){const v=new Vector3,i=new Vector3;let b=0;const j=(t-e)/n;for(let c=0;c<=o;c++){const g=[],f=c/o,b=f*(t-e)+e;for(let e=0;e<=s;e++){const t=e/s,o=t*r+a,c=Math.sin(o),d=Math.cos(o);i.x=b*c,i.y=-f*n+p,i.z=b*d,u.push(i.x,i.y,i.z),v.set(c,j,d).normalize(),h.push(v.x,v.y,v.z),m.push(t,1-f),g.push(l++)}d.push(g)}for(let n=0;n<s;n++)for(let s=0;s<o;s++){const r=d[s][n],i=d[s+1][n],l=d[s+1][n+1],a=d[s][n+1];(e>0||s!==0)&&(c.push(r,i,a),b+=3),(t>0||s!==o-1)&&(c.push(i,l,a),b+=3)}g.addGroup(f,b,0),f+=b}function v(n){const j=l,d=new Vector2,o=new Vector3;let v=0;const b=n===!0?e:t,i=n===!0?1:-1;for(let e=1;e<=s;e++)u.push(0,p*i,0),h.push(0,i,0),m.push(.5,.5),l++;const y=l;for(let e=0;e<=s;e++){const f=e/s,t=f*r+a,n=Math.cos(t),c=Math.sin(t);o.x=b*c,o.y=p*i,o.z=b*n,u.push(o.x,o.y,o.z),h.push(0,i,0),d.x=n*.5+.5,d.y=c*.5*i+.5,m.push(d.x,d.y),l++}for(let e=0;e<s;e++){const o=j+e,t=y+e;n===!0?c.push(t,t+1,o):c.push(t+1,t,o),v+=3}g.addGroup(f,v,n===!0?1:2),f+=v}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new CylinderGeometry(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class PlaneGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const u=e/2,h=t/2,i=Math.floor(n),a=Math.floor(s),o=i+1,m=a+1,f=e/i,p=t/a,r=[],l=[],d=[],c=[];for(let e=0;e<m;e++){const t=e*p-h;for(let n=0;n<o;n++){const s=n*f-u;l.push(s,-t,0),d.push(0,0,1),c.push(n/i),c.push(1-e/a)}}for(let e=0;e<a;e++)for(let t=0;t<i;t++){const a=t+o*e,n=t+o*(e+1),c=t+1+o*(e+1),s=t+1+o*e;r.push(a,n,s),r.push(n,c,s)}this.setIndex(r),this.setAttribute("position",new Float32BufferAttribute(l,3)),this.setAttribute("normal",new Float32BufferAttribute(d,3)),this.setAttribute("uv",new Float32BufferAttribute(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new PlaneGeometry(e.width,e.height,e.widthSegments,e.heightSegments)}}class SphereGeometry extends BufferGeometry{constructor(e=1,t=32,n=16,s=0,o=Math.PI*2,i=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:o,thetaStart:i,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const u=Math.min(i+a,Math.PI);let p=0;const c=[],r=new Vector3,l=new Vector3,d=[],h=[],m=[],f=[];for(let d=0;d<=n;d++){const b=[],g=d/n;let v=0;d===0&&i===0?v=.5/t:d===n&&u===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){const c=n/t;r.x=-e*Math.cos(s+c*o)*Math.sin(i+g*a),r.y=e*Math.cos(i+g*a),r.z=e*Math.sin(s+c*o)*Math.sin(i+g*a),h.push(r.x,r.y,r.z),l.copy(r).normalize(),m.push(l.x,l.y,l.z),f.push(c+v,1-g),b.push(p++)}c.push(b)}for(let e=0;e<n;e++)for(let s=0;s<t;s++){const r=c[e][s+1],o=c[e][s],l=c[e+1][s],a=c[e+1][s+1];(e!==0||i>0)&&d.push(r,o,a),(e!==n-1||u<Math.PI)&&d.push(o,l,a)}this.setIndex(d),this.setAttribute("position",new Float32BufferAttribute(h,3)),this.setAttribute("normal",new Float32BufferAttribute(m,3)),this.setAttribute("uv",new Float32BufferAttribute(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new SphereGeometry(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ShadowMaterial extends Material{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Color(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class MeshStandardMaterial extends Material{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Color(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Euler,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Color(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Color(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!==e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!==e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!==e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!==e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!==e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!==e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class MeshPhongMaterial extends Material{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Color(16777215),this.specular=new Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Euler,this.combine=MultiplyOperation,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}}class MeshToonMaterial extends Material{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Color(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(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}}class MeshNormalMaterial extends Material{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(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}}class MeshLambertMaterial extends Material{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Euler,this.combine=MultiplyOperation,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}}class MeshMatcapMaterial extends Material{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Color(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class LineDashedMaterial extends LineBasicMaterial{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 convertArray(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function getKeyframeOrder(e){function s(t,n){return e[t]-e[n]}const n=e.length,t=new Array(n);for(let e=0;e!==n;++e)t[e]=e;return t.sort(s),t}function sortedArray(e,t,n){const s=e.length,o=new e.constructor(s);for(let i=0,a=0;a!==s;++i){const r=n[i]*t;for(let n=0;n!==t;++n)o[a++]=e[r+n]}return o}function flattenJSON(e,t,n,s){let a=1,o=e[0];for(;o!==0[0]&&o[s]===0[0];)o=e[a++];if(o===0[0])return;let i=o[s];if(i===0[0])return;if(Array.isArray(i))do i=o[s],i!==0[0]&&(t.push(o.time),n.push(...i)),o=e[a++];while(o!==0[0])else if(i.toArray!==0[0])do i=o[s],i!==0[0]&&(t.push(o.time),i.toArray(n,n.length)),o=e[a++];while(o!==0[0])else do i=o[s],i!==0[0]&&(t.push(o.time),n.push(i)),o=e[a++];while(o!==0[0])}class Interpolant{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==0[0]?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const s=this.parameterPositions;let t=this._cachedIndex,o=s[t],n=s[t-1];validate_interval:{seek:{let i;linear_scan:{forward_scan:if(!(e<o)){for(let i=t+2;;){if(o===0[0]){if(e<n)break forward_scan;return t=s.length,this._cachedIndex=t,this.copySampleValue_(t-1)}if(t===i)break;if(n=o,o=s[++t],e<o)break seek}i=s.length;break linear_scan}if(!(e>=n)){const a=s[1];e<a&&(t=2,n=a);for(let i=t-2;;){if(n===0[0])return this._cachedIndex=0,this.copySampleValue_(0);if(t===i)break;if(o=n,n=s[--t-1],e>=n)break seek}i=t,t=0;break linear_scan}break validate_interval}for(;t<i;){const n=t+i>>>1;e<s[n]?i=n:t=n+1}if(o=s[t],n=s[t-1],n===0[0])return this._cachedIndex=0,this.copySampleValue_(0);if(o===0[0])return t=s.length,this._cachedIndex=t,this.copySampleValue_(t-1)}this._cachedIndex=t,this.intervalChanged_(t,n,o)}return this.interpolate_(t,n,e,o)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n;for(let e=0;e!==n;++e)t[e]=s[o+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class CubicInterpolant extends Interpolant{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding}}intervalChanged_(e,t,n){const s=this.parameterPositions;let o=e-2,i=e+1,a=s[o],r=s[i];if(a===0[0])switch(this.getSettings_().endingStart){case ZeroSlopeEnding:o=e,a=2*t-n;break;case WrapAroundEnding:o=s.length-2,a=t+s[o]-s[o+1];break;default:o=e,a=n}if(r===0[0])switch(this.getSettings_().endingEnd){case ZeroSlopeEnding:i=e,r=2*n-t;break;case WrapAroundEnding:i=1,r=n+s[1]-s[0];break;default:i=e-1,r=t}const c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(r-n),this._offsetPrev=o*l,this._offsetNext=i*l}interpolate_(e,t,n,s){const h=this.resultBuffer,r=this.sampleValues,d=this.valueSize,u=e*d,m=u-d,p=this._offsetPrev,f=this._offsetNext,i=this._weightPrev,l=this._weightNext,o=(n-t)/(s-t),a=o*o,c=a*o,g=-i*c+2*i*a-i*o,v=(1+i)*c+(-1.5-2*i)*a+(-.5+i)*o+1,b=(-1-l)*c+(1.5+l)*a+.5*o,j=l*c-l*a;for(let e=0;e!==d;++e)h[e]=g*r[p+e]+v*r[m+e]+b*r[u+e]+j*r[f+e];return h}}class LinearInterpolant extends Interpolant{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,r=e*o,l=r-o,c=(n-t)/(s-t),d=1-c;for(let e=0;e!==o;++e)i[e]=a[l+e]*d+a[r+e]*c;return i}}class DiscreteInterpolant extends Interpolant{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class KeyframeTrack{constructor(e,t,n,s){if(e===0[0])throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===0[0]||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=convertArray(t,this.TimeBufferType),this.values=convertArray(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){const n=e.constructor;let t;if(n.toJSON!==this.toJSON)t=n.toJSON(e);else{t={name:e.name,times:convertArray(e.times,Array),values:convertArray(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case InterpolateDiscrete:t=this.InterpolantFactoryMethodDiscrete;break;case InterpolateLinear:t=this.InterpolantFactoryMethodLinear;break;case InterpolateSmooth:t=this.InterpolantFactoryMethodSmooth;break}if(t===0[0]){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===0[0])if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(t);return warn("KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return InterpolateSmooth}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){const o=this.times,i=o.length;let s=0,n=i-1;for(;s!==i&&o[s]<e;)++s;for(;n!==-1&&o[n]>t;)--n;if(++n,s!==0||n!==i){s>=n&&(n=Math.max(n,1),s=n-1);const e=this.getValueSize();this.times=o.slice(s,n),this.values=this.values.slice(s*e,n*e)}return this}validate(){let e=!0;const s=this.getValueSize();s-Math.floor(s)!==0&&(error("KeyframeTrack: Invalid value size in track.",this),e=!1);const o=this.times,t=this.values,i=o.length;i===0&&(error("KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let s=0;s!==i;s++){const t=o[s];if(typeof t=="number"&&isNaN(t)){error("KeyframeTrack: Time is not a valid number.",this,s,t),e=!1;break}if(n!==null&&n>t){error("KeyframeTrack: Out of order keys.",this,s,t,n),e=!1;break}n=t}if(t!==0[0]&&isTypedArray(t))for(let n=0,o=t.length;n!==o;++n){const s=t[n];if(isNaN(s)){error("KeyframeTrack: Value is not a valid number.",this,n,s),e=!1;break}}return e}optimize(){const e=this.times.slice(),s=this.values.slice(),t=this.getValueSize(),i=this.getInterpolation()===InterpolateSmooth,o=e.length-1;let n=1;for(let a=1;a<o;++a){let r=!1;const c=e[a],l=e[a+1];if(c!==l&&(a!==1||c!==e[0]))if(i)r=!0;else{const e=a*t,n=e-t,o=e+t;for(let i=0;i!==t;++i){const a=s[e+i];if(a!==s[n+i]||a!==s[o+i]){r=!0;break}}}if(r){if(a!==n){e[n]=e[a];const o=a*t,i=n*t;for(let e=0;e!==t;++e)s[i+e]=s[o+e]}++n}}if(o>0){e[n]=e[o];for(let i=o*t,a=n*t,e=0;e!==t;++e)s[a+e]=s[i+e];++n}return n!==e.length?(this.times=e.slice(0,n),this.values=s.slice(0,n*t)):(this.times=e,this.values=s),this}clone(){const t=this.times.slice(),n=this.values.slice(),s=this.constructor,e=new s(this.name,t,n);return e.createInterpolant=this.createInterpolant,e}}KeyframeTrack.prototype.ValueTypeName="",KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=InterpolateLinear;class BooleanKeyframeTrack extends KeyframeTrack{constructor(e,t,n){super(e,t,n)}}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=0[0],BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=0[0];class ColorKeyframeTrack extends KeyframeTrack{constructor(e,t,n,s){super(e,t,n,s)}}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{constructor(e,t,n,s){super(e,t,n,s)}}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const a=this.resultBuffer,r=this.sampleValues,i=this.valueSize,c=(n-t)/(s-t);let o=e*i;for(let e=o+i;o!==e;o+=4)Quaternion.slerpFlat(a,0,r,o-i,r,o,c);return a}}class QuaternionKeyframeTrack extends KeyframeTrack{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=0[0];class StringKeyframeTrack extends KeyframeTrack{constructor(e,t,n){super(e,t,n)}}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=0[0],StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=0[0];class VectorKeyframeTrack extends KeyframeTrack{constructor(e,t,n,s){super(e,t,n,s)}}VectorKeyframeTrack.prototype.ValueTypeName="vector";class AnimationClip{constructor(e="",t=-1,n=[],s=NormalAnimationBlendMode){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=generateUUID(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const n=[],s=e.tracks,o=1/(e.fps||1);for(let e=0,t=s.length;e!==t;++e)n.push(parseKeyframeTrack(s[e]).scale(o));const t=new this(e.name,e.duration,n,e.blendMode);return t.uuid=e.uuid,t.userData=JSON.parse(e.userData||"{}"),t}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,s=n.length;e!==s;++e)t.push(KeyframeTrack.toJSON(n[e]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const o=t.length,i=[];for(let a=0;a<o;a++){let e=[],r=[];e.push((a+o-1)%o,a,(a+1)%o),r.push(0,1,0);const c=getKeyframeOrder(e);e=sortedArray(e,1,c),r=sortedArray(r,1,c),!s&&e[0]===0&&(e.push(o),r.push(r[0])),i.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[a].name+"]",e,r).scale(1/n))}return new this(e,-1,i)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const s={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,a=e.length;t<a;t++){const o=e[t],n=o.name.match(i);if(n&&n.length>1){const t=n[1];let e=s[t];e||(s[t]=e=[]),e.push(o)}}const o=[];for(const e in s)o.push(this.CreateFromMorphTargetSequence(e,s[e],t,n));return o}static parseAnimation(e,t){if(warn("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return error("AnimationClip: No animation in JSONLoader data."),null;const s=function(e,t,n,s,o){if(n.length!==0){const i=[],a=[];flattenJSON(n,i,a,s),i.length!==0&&o.push(new e(t,i,a))}},n=[],a=e.name||"default",r=e.fps||30,c=e.blendMode;let o=e.length||-1;const i=e.hierarchy||[];for(let a=0;a<i.length;a++){const e=i[a].keys;if(!e||e.length===0)continue;if(e[0].morphTargets){const s={};let t;for(t=0;t<e.length;t++)if(e[t].morphTargets)for(let n=0;n<e[t].morphTargets.length;n++)s[e[t].morphTargets[n]]=-1;for(const o in s){const i=[],a=[];for(let n=0;n!==e[t].morphTargets.length;++n){const s=e[t];i.push(s.time),a.push(s.morphTarget===o?1:0)}n.push(new NumberKeyframeTrack(".morphTargetInfluence["+o+"]",i,a))}o=s.length*r}else{const o=".bones["+t[a].name+"]";s(VectorKeyframeTrack,o+".position",e,"pos",n),s(QuaternionKeyframeTrack,o+".quaternion",e,"rot",n),s(VectorKeyframeTrack,o+".scale",e,"scl",n)}}if(n.length===0)return null;const l=new this(a,o,n,c);return l}resetDuration(){const t=this.tracks;let e=0;for(let n=0,o=t.length;n!==o;++n){const s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;
40case"vector":case"vector2":case"vector3":case"vector4":return VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function parseKeyframeTrack(e){if(e.type===0[0])throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=getTrackTypeForValueTypeName(e.type);if(e.times===0[0]){const t=[],n=[];flattenJSON(e.keys,t,n,"value"),e.times=t,e.values=n}return t.parse!==0[0]?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Cache={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class LoadingManager{constructor(e,t,n){const s=this;let r=!1,i=0,a=0,c=0[0];const o=[];this.onStart=0[0],this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){a++,r===!1&&s.onStart!==0[0]&&s.onStart(e,i,a),r=!0},this.itemEnd=function(e){i++,s.onProgress!==0[0]&&s.onProgress(e,i,a),i===a&&(r=!1,s.onLoad!==0[0]&&s.onLoad())},this.itemError=function(e){s.onError!==0[0]&&s.onError(e)},this.resolveURL=function(e){return c?c(e):e},this.setURLModifier=function(e){return c=e,this},this.addHandler=function(e,t){return o.push(e,t),this},this.removeHandler=function(e){const t=o.indexOf(e);return t!==-1&&o.splice(t,2),this},this.getHandler=function(e){for(let t=0,s=o.length;t<s;t+=2){const n=o[t],i=o[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}DefaultLoadingManager=new LoadingManager;class Loader{constructor(e){this.manager=e!==0[0]?e:DefaultLoadingManager,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(s,o){n.load(e,s,t,o)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Loader.DEFAULT_MATERIAL_NAME="__DEFAULT",loading={};class HttpError extends Error{constructor(e,t){super(e),this.response=t}}class FileLoader extends Loader{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,s){e===0[0]&&(e=""),this.path!==0[0]&&(e=this.path+e),e=this.manager.resolveURL(e);const o=Cache.get(`file:${e}`);if(o!==0[0])return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(loading[e]!==0[0]){loading[e].push({onLoad:t,onProgress:n,onError:s});return}loading[e]=[],loading[e].push({onLoad:t,onProgress:n,onError:s});const a=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}),i=this.mimeType,r=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&warn("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||t.body===0[0]||t.body.getReader===0[0])return t;const n=loading[e],a=t.body.getReader(),s=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),o=s?parseInt(s):0,r=o!==0;let i=0;const c=new ReadableStream({start(e){t();function t(){a.read().then(({done:s,value:a})=>{if(s)e.close();else{i+=a.byteLength;const s=new ProgressEvent("progress",{lengthComputable:r,loaded:i,total:o});for(let e=0,o=n.length;e<o;e++){const t=n[e];t.onProgress&&t.onProgress(s)}e.enqueue(a),t()}},t=>{e.error(t)})}}});return new Response(c)}throw new HttpError(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(r){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>{const t=new DOMParser;return t.parseFromString(e,i)});case"json":return e.json();default:if(i==="")return e.text();const n=/charset="?([^;"\s]*)"?/i,t=n.exec(i),s=t&&t[1]?t[1].toLowerCase():0[0],o=new TextDecoder(s);return e.arrayBuffer().then(e=>o.decode(e))}}).then(t=>{Cache.add(`file:${e}`,t);const n=loading[e];delete loading[e];for(let e=0,o=n.length;e<o;e++){const s=n[e];s.onLoad&&s.onLoad(t)}}).catch(t=>{const n=loading[e];if(n===0[0])throw this.manager.itemError(e),t;delete loading[e];for(let e=0,o=n.length;e<o;e++){const s=n[e];s.onError&&s.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}_loading=new WeakMap;class ImageLoader extends Loader{constructor(e){super(e)}load(e,t,n,s){this.path!==0[0]&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,a=Cache.get(`image:${e}`);if(a!==0[0]){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=_loading.get(a);e===0[0]&&(e=[],_loading.set(a,e)),e.push({onLoad:t,onError:s})}return a}const o=createElementNS("img");function r(){l(),t&&t(this);const n=_loading.get(this)||[];for(let e=0;e<n.length;e++){const t=n[e];t.onLoad&&t.onLoad(this)}_loading.delete(this),i.manager.itemEnd(e)}function c(t){l(),s&&s(t),Cache.remove(`image:${e}`);const n=_loading.get(this)||[];for(let e=0;e<n.length;e++){const s=n[e];s.onError&&s.onError(t)}_loading.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener("load",r,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",r,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==0[0]&&(o.crossOrigin=this.crossOrigin),Cache.add(`image:${e}`,o),i.manager.itemStart(e),o.src=e,o}}class DataTextureLoader extends Loader{constructor(e){super(e)}load(e,t,n,s){const a=this,o=new DataTexture,i=new FileLoader(this.manager);return i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setPath(this.path),i.setWithCredentials(a.withCredentials),i.load(e,function(e){let n;try{n=a.parse(e)}catch(e){if(s!==0[0])s(e);else{e(e);return}}n.image!==0[0]?o.image=n.image:n.data!==0[0]&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=n.wrapS!==0[0]?n.wrapS:ClampToEdgeWrapping,o.wrapT=n.wrapT!==0[0]?n.wrapT:ClampToEdgeWrapping,o.magFilter=n.magFilter!==0[0]?n.magFilter:LinearFilter,o.minFilter=n.minFilter!==0[0]?n.minFilter:LinearFilter,o.anisotropy=n.anisotropy!==0[0]?n.anisotropy:1,n.colorSpace!==0[0]&&(o.colorSpace
vendor: 16,165 bytes, line 40
40=n.colorSpace),n.flipY!==0[0]&&(o.flipY=n.flipY),n.format!==0[0]&&(o.format=n.format),n.type!==0[0]&&(o.type=n.type),n.mipmaps!==0[0]&&(o.mipmaps=n.mipmaps,o.minFilter=LinearMipmapLinearFilter),n.mipmapCount===1&&(o.minFilter=LinearFilter),n.generateMipmaps!==0[0]&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n)},n,s),o}}class TextureLoader extends Loader{constructor(e){super(e)}load(e,t,n,s){const o=new Texture,i=new ImageLoader(this.manager);return i.setCrossOrigin(this.crossOrigin),i.setPath(this.path),i.load(e,function(e){o.image=e,o.needsUpdate=!0,t!==0[0]&&t(o)},n,s),o}}class Light extends Object3D{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Color(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class HemisphereLight extends Light{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Color(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}_projScreenMatrix=new Matrix4,_lightPositionWorld=new Vector3,_lookTarget=new Vector3;class LightShadow{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.mapType=UnsignedByteType,this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;_lightPositionWorld.setFromMatrixPosition(e.matrixWorld),t.position.copy(_lightPositionWorld),_lookTarget.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(_lookTarget),t.updateMatrixWorld(),_projScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(_projScreenMatrix)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=RAD2DEG*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height*this.aspect,o=e.distance||t.far;(n!==t.fov||s!==t.aspect||o!==t.far)&&(t.fov=n,t.aspect=s,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class SpotLight extends Light{constructor(e,t,n=0,s=Math.PI/3,o=0,i=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.distance=n,this.angle=s,this.penumbra=o,this.decay=i,this.map=null,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this.isPointLightShadow=!0}}class PointLight extends Light{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new PointLightShadow}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,n=1,s=-1,o=.1,i=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=o,this.far=i,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,o,i){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=s,this.view.width=o,this.view.height=i,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const n=(this.right-this.left)/(2*this.zoom),s=(this.top-this.bottom)/(2*this.zoom),o=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let e=o-n,a=o+n,t=i+s,r=i-s;if(this.view!==null&&this.view.enabled){const n=(this.right-this.left)/this.view.fullWidth/this.zoom,s=(this.top-this.bottom)/this.view.fullHeight/this.zoom;e+=n*this.view.offsetX,a=e+n*this.view.width,t-=s*this.view.offsetY,r=t-s*this.view.height}this.projectionMatrix.makeOrthographic(e,a,t,r,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DirectionalLight extends Light{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class AmbientLight extends Light{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class RectAreaLight extends Light{constructor(e,t,n=10,s=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=s}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class SphericalHarmonics3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const{x:s,y:o,z:i}=e,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.282095),t.addScaledVector(n[1],.488603*o),t.addScaledVector(n[2],.488603*i),t.addScaledVector(n[3],.488603*s),t.addScaledVector(n[4],1.092548*(s*o)),t.addScaledVector(n[5],1.092548*(o*i)),t.addScaledVector(n[6],.315392*(3*i*i-1)),t.addScaledVector(n[7],1.092548*(s*i)),t.addScaledVector(n[8],.546274*(s*s-o*o)),t}getIrradianceAt(e,t){const{x:s,y:o,z:i}=e,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.886227),t.addScaledVector(n[1],2*.511664*o),t.addScaledVector(n[2],2*.511664*i),t.addScaledVector(n[3],2*.511664*s),t.addScaledVector(n[4],2*.429043*s*o),t.addScaledVector(n[5],2*.429043*o*i),t.addScaledVector(n[6],.743125*i*i-.247708),t.addScaledVector(n[7],2*.429043*s*i),t.addScaledVector(n[8],.429043*(s*s-o*o)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let s=0;s<9;s++)n[s].fromArray(e,t+s*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let s=0;s<9;s++)n[s].toArray(e,t+s*3);return e}static getBasisAt(e,t){const{x:n,y:s,z:o}=e;t[0]=.282095,t[1]=.488603*s,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*s,t[5]=1.092548*s*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-s*s)}}class LightProbe extends Light{constructor(e=new SphericalHarmonics3,t=1){super(0[0],t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class LoaderUtils{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:t+e)}}_errorMap=new WeakMap;class ImageBitmapLoader extends Loader{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&warn("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&warn("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===0[0]&&(e=""),this.path!==0[0]&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,i=Cache.get(`image-bitmap:${e}`);if(i!==0[0]){if(o.manager.itemStart(e),i.then){i.then(n=>{if(_errorMap.has(i)===!0)s&&s(_errorMap.get(i)),o.manager.itemError(e),o.manager.itemEnd(e);else return t&&t(n),o.manager.itemEnd(e),n});return}return setTimeout(function(){t&&t(i),o.manager.itemEnd(e)},0),i}const 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;const r=fetch(e,a).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(n){return Cache.add(`image-bitmap:${e}`,n),t&&t(n),o.manager.itemEnd(e),n}).catch(function(t){s&&s(t),_errorMap.set(r,t),Cache.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});Cache.add(`image-bitmap:${e}`,r),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ArrayCamera extends PerspectiveCamera{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}_RESERVED_CHARS_RE="\\[\\]\\.:\\/",_reservedRe=new RegExp("["+_RESERVED_CHARS_RE+"]","g"),_wordChar="[^"+_RESERVED_CHARS_RE+"]",_wordCharOrDot="[^"+_RESERVED_CHARS_RE.replace("\\.","")+"]",_directoryRe=/((?:WC+[/:])*)/.source.replace("WC",_wordChar),_nodeRe=/(WCOD+)?/.source.replace("WCOD",_wordCharOrDot),_objectRe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",_wordChar),_propertyRe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",_wordChar),_trackRe=new RegExp("^"+_directoryRe+_nodeRe+_objectRe+_propertyRe+"$"),_supportedObjectNames=["material","materials","bones","map"];class Composite{constructor(e,t,n){const s=n||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const s=this._targetGroup.nCachedObjects_,n=this._bindings[s];n!==0[0]&&n.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=n.length;s!==o;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class PropertyBinding{constructor(e,t,n){this.path=t,this.parsedPath=n||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.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 PropertyBinding.Composite(e,t,n):new PropertyBinding(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_reservedRe,"")}static parseTrackName(e){const n=_trackRe.exec(e);if(n===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const t={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},s=t.nodeName&&t.nodeName.lastIndexOf(".");if(s!==0[0]&&s!==-1){const e=t.nodeName.substring(s+1);_supportedObjectNames.indexOf(e)!==-1&&(t.nodeName=t.nodeName.substring(0,s),t.objectName=e)}if(t.propertyName===null||t.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}static findNode(e,t){if(t===0[0]||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==0[0])return n}if(e.children){const n=function(e){for(let o=0;o<e.length;o++){const s=e[o];if(s.name===t||s.uuid===t)return s;const i=n(s.children);if(i)return i}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}
40_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const n=this.parsedPath,i=n.objectName,a=n.propertyName;let s=n.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,n.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){warn("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let t=n.objectIndex;switch(i){case"materials":if(!e.material){error("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){error("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){error("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let n=0;n<e.length;n++)if(e[n].name===t){t=n;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){error("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){error("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===0[0]){error("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(t!==0[0]){if(e[t]===0[0]){error("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[t]}}const t=e[a];if(t===0[0]){const t=n.nodeName;error("PropertyBinding: Trying to update property for track: "+t+"."+a+" but it wasn't found.",e);return}let r=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?r=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(r=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==0[0]){if(a==="morphTargetInfluences"){if(!e.geometry){error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==0[0]&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=t,this.propertyIndex=s}else t.fromArray!==0[0]&&t.toArray!==0[0]?(o=this.BindingType.HasFromToArray,this.resolvedProperty=t):Array.isArray(t)?(o=this.BindingType.EntireArray,this.resolvedProperty=t):this.propertyName=a;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][r]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=Composite,PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatr
40ixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]],_controlInterpolantsResultBuffer=new Float32Array(1);class InstancedInterleavedBuffer extends InterleavedBuffer{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class Spherical{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=clamp(this.phi,e,Math.PI-e),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=(e*e+t*t+n*n)**.5,this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(clamp(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Matrix2{constructor(e,t,n,s){Matrix2.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==0[0]&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){const o=this.elements;return o[0]=e,o[2]=t,o[1]=n,o[3]=s,this}}class Controls extends EventDispatcher{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===0[0]){warn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function getByteLength(e,t,n,s){const o=getTextureTypeByteLength(s);switch(n){case AlphaFormat:return e*t;case RedFormat:return e*t/o.components*o.byteLength;case RedIntegerFormat:return e*t/o.components*o.byteLength;case RGFormat:return e*t*2/o.components*o.byteLength;case RGIntegerFormat:return e*t*2/o.components*o.byteLength;case RGBFormat:return e*t*3/o.components*o.byteLength;case RGBAFormat:return e*t*4/o.components*o.byteLength;case RGBAIntegerFormat:return e*t*4/o.components*o.byteLength;case RGB_S3TC_DXT1_Format:case RGBA_S3TC_DXT1_Format:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case RGBA_S3TC_DXT3_Format:case RGBA_S3TC_DXT5_Format:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case RGB_PVRTC_2BPPV1_Format:case RGBA_PVRTC_2BPPV1_Format:return Math.max(e,16)*Math.max(t,8)/4;case RGB_PVRTC_4BPPV1_Format:case RGBA_PVRTC_4BPPV1_Format:return Math.max(e,8)*Math.max(t,8)/2;case RGB_ETC1_Format:case RGB_ETC2_Format:case R11_EAC_Format:case SIGNED_R11_EAC_Format:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case RGBA_ETC2_EAC_Format:case RG11_EAC_Format:case SIGNED_RG11_EAC_Format:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case RGBA_ASTC_4x4_Format:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case RGBA_ASTC_5x4_Format:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case RGBA_ASTC_5x5_Format:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case RGBA_ASTC_6x5_Format:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case RGBA_ASTC_6x6_Format:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case RGBA_ASTC_8x5_Format:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case RGBA_ASTC_8x6_Format:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case RGBA_ASTC_8x8_Format:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case RGBA_ASTC_10x5_Format:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case RGBA_ASTC_10x6_Format:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case RGBA_ASTC_10x8_Format:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case RGBA_ASTC_10x10_Format:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case RGBA_ASTC_12x10_Format:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case RGBA_ASTC_12x12_Format:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case RGBA_BPTC_Format:case RGB_BPTC_SIGNED_Format:case RGB_BPTC_UNSIGNED_Format:return Math.ceil(e/4)*Math.ceil(t/4)*16;
40case RED_RGTC1_Format:case SIGNED_RED_RGTC1_Format:return Math.ceil(e/4)*Math.ceil(t/4)*8;case RED_GREEN_RGTC2_Format:case SIGNED_RED_GREEN_RGTC2_Format:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function getTextureTypeByteLength(e){switch(e){case UnsignedByteType:case ByteType:return{byteLength:1,components:1};case UnsignedShortType:case ShortType:case HalfFloatType:return{byteLength:2,components:1};case UnsignedShort4444Type:case UnsignedShort5551Type:return{byteLength:2,components:4};case UnsignedIntType:case IntType:case FloatType:return{byteLength:4,components:1};case UnsignedInt5999Type:case UnsignedInt101111Type:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${e}.`)}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:REVISION}})),typeof window!="undefined"&&(window.__THREE__?warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=REVISION),refreshUniforms=["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"],_lightsCache=new WeakMap;class NodeMaterialObserver{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=refreshUniforms,this.renderId=0}firstInitialization(e){const t=this.renderObjects.has(e);return t===!1&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===0[0]){const{geometry:n,material:o,object:s}=e;if(t={material:this.getMaterialData(o),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){const{width:n,height:s}=e.context;t.bufferWidth=n,t.bufferHeight=s}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const s=e[n];t[n]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const s of this.refreshUniforms){const n=e[s];if(n==null)continue;typeof n=="object"&&n.clone!==0[0]?n.isTexture===!0?t[s]={id:n.id,version:n.version}:t[s]=n.clone():t[s]=n}return t}equals(e,t){const{object:i,material:h,geometry:o}=e,n=this.getRenderObjectData(e);if(n.worldMatrix.equals(i.matrixWorld)!==!0)return n.worldMatrix.copy(i.matrixWorld),!1;const a=n.material;for(const n in a){const t=a[n],e=h[n];if(t.equals!==0[0]){if(t.equals(e)===!1)return t.copy(e),!1}else if(e.isTexture===!0){if(t.id!==e.id||t.version!==e.version)return t.id=e.id,t.version=e.version,!1}else if(t!==e)return a[n]=e,!1}if(a.transmission>0){const{width:t,height:s}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==s)return n.bufferWidth=t,n.bufferHeight=s,!1}const s=n.geometry,r=o.attributes,c=s.attributes,l=Object.keys(c),m=Object.keys(r);if(s.id!==o.id)return s.id=o.id,!1;if(l.length!==m.length)return n.geometry.attributes=this.getAttributesData(r),!1;for(const e of l){const n=c[e],t=r[e];if(t===0[0])return delete c[e],!1;if(n.version!==t.version)return n.version=t.version,!1}const d=o.index,f=s.indexVersion,u=d?d.version:null;if(f!==u)return s.indexVersion=u,!1;
40if(s.drawRange.start!==o.drawRange.start||s.drawRange.count!==o.drawRange.count)return s.drawRange.start=o.drawRange.start,s.drawRange.count=o.drawRange.count,!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==i.morphTargetInfluences[t]&&(n.morphTargetInfluences[t]=i.morphTargetInfluences[t],e=!0);if(e)return!1}if(n.lights)for(let e=0;e<t.length;e++)if(n.lights[e].map!==t[e].map)return!1;return n.center&&n.center.equals(i.center)===!1?(n.center.copy(i.center),!0):(e.bundle!==null&&(n.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(_lightsCache.has(e)){const n=_lightsCache.get(e);if(n.renderId===t)return n.lightsData}const n=this.getLightsData(e.getLights());return _lightsCache.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const s=e.object.static===!0,o=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(s||o)return!1;const i=this.getLights(e.lightsNode,n),a=this.equals(e,i)!==!0;return a}}function cyrb53(e,t=0){let n=3735928559^t,s=1103547991^t;if(e instanceof Array)for(let t=0,o;t<e.length;t++)o=e[t],n=Math.imul(n^o,2654435761),s=Math.imul(s^o,1597334677);else for(let t=0,o;t<e.length;t++)o=e.charCodeAt(t),n=Math.imul(n^o,2654435761),s=Math.imul(s^o,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&s)+(n>>>0)}hashString=e=>cyrb53(e),hashArray=e=>cyrb53(e),hash$1=(...e)=>cyrb53(e),typeFromLength=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),dataFromObject=new WeakMap;function getTypeFromLength(e){return typeFromLength.get(e)}function getValueType(e){if(e==null)return null;const t=typeof e;return e.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":e.isVector2===!0?"vec2":e.isVector3===!0?"vec3":e.isVector4===!0?"vec4":e.isMatrix2===!0?"mat2":e.isMatrix3===!0?"mat3":e.isMatrix4===!0?"mat4":e.isColor===!0?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function getValueFromType(t,...e){const n=t?t.slice(-4):0[0];return e.length===1&&(n==="vec2"?e=[e[0],e[0]]:n==="vec3"?e=[e[0],e[0],e[0]]:n==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new Color(...e):n==="vec2"?new Vector2(...e):n==="vec3"?new Vector3(...e):n==="vec4"?new Vector4(...e):n==="mat2"?new Matrix2(...e):n==="mat3"?new Matrix3(...e):n==="mat4"?new Matrix4(...e):t==="bool"?e[0]:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?base64ToArrayBuffer(e[0]):null}function getDataFromObject(e){let t=dataFromObject.get(e);return t===0[0]&&(t={},dataFromObject.set(e,t)),t}function arrayBufferToBase64(e){let t="";const n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function base64ToArrayBuffer(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}NodeShaderStage={VERTEX:"vertex",FRAGMENT:"fragment"},NodeUpdateType={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},NodeAccess={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},defaultShaderStages=["fragment","vertex"],defaultBuildStages=["setup","analyze","generate"],shaderStages=[...defaultShaderStages,"compute"],vectorComponents=["x","y","z","w"],_parentBuildStage={analyze:"setup",generate:"analyze"},_nodeId=0;class Node extends EventDispatcher{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=NodeUpdateType.NONE,this.updateBeforeType=NodeUpdateType.NONE,this.updateAfterType=NodeUpdateType.NONE,this.uuid=MathUtils.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:_nodeId++})}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,NodeUpdateType.FRAME)}
40onRenderUpdate(e){return this.onUpdate(e,NodeUpdateType.RENDER)}onObjectUpdate(e){return this.onUpdate(e,NodeUpdateType.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const s of Object.getOwnPropertyNames(this)){const n=this[s];if(s.startsWith("_")===!0||e.has(n))continue;if(Array.isArray(n)===!0)for(let e=0;e<n.length;e++){const o=n[e];o&&o.isNode===!0&&t.push({property:s,index:e,childNode:o})}else if(n&&n.isNode===!0)t.push({property:s,childNode:n});else if(n&&Object.getPrototypeOf(n)===Object.prototype)for(const e in n){if(e.startsWith("_")===!0)continue;const o=n[e];o&&o.isNode===!0&&t.push({property:s,index:e,childNode:o})}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);const n=[];for(const{property:s,childNode:o}of this._getChildren(t))n.push(hashString(s.slice(0,-4)),o.getCacheKey(e,t));this._cacheKey=hash$1(hashArray(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let n=0;for(const e of this.getChildren())t["node"+n++]=e;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const n=e.getDataFromNode(this,"any");n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){const t=e.getNodeProperties(this);for(const n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){warn("Abstract function.")}updateAfter(){warn("Abstract function.")}update(){warn("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const a=this.getShared(e);if(this!==a)return a.build(e,t);if(this._beforeNodes!==null){const n=this._beforeNodes;this._beforeNodes=null;for(const s of n)s.build(e,t);this._beforeNodes=n}const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const o=_parentBuildStage[e.buildStage];if(o&&s.buildStages[o]!==!0){const t=e.getBuildStage();e.setBuildStage(o),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const i=e.getBuildStage();if(i==="setup"){this.updateReference(e);const t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){const t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}n=t.outputNode}else if(i==="analyze")this.analyze(e,t);else if(i==="generate"){const s=this.generate.length<2;if(s){const o=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,n===0[0]?s.generated===0[0]?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(warn("Node: Recursion detected.",this),n="/* Recursion detected. */"):s.flowCodes!==0[0]&&e.context.nodeBlock!==0[0]&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,o,t)}else n=this.generate(e,t)||"";n===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(error(`TSL: Invalid generated code, expected a "${t}".`),n=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return this._getChildren()}serialize(e){const n=this.getSerializeChildren(),t={};for(const{property:s,index:o,childNode:i}of n)o!==0[0]?(t[s]===0[0]&&(t[s]=Number.isInteger(o)?[]:{}),t[s][o]=i.toJSON(e.meta).uuid):t[s]=i.toJSON(e.meta).uuid;Object.keys(t).length>0&&(e.inputNodes=t)}deserialize(e){if(e.inputNodes!==0[0]){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const s=[];for(const o of e.inputNodes[n])s.push(t[o]);this[n]=s}else if(typeof e.inputNodes[n]=="object"){const s={};for(const o in e.inputNodes[n]){const i=e.inputNodes[n][o];s[o]=t[i]}this[n]=s}else{const s=e.inputNodes[n];this[n]=t[s]}}}toJSON(e){const{uuid:o,type:i}=this,n=e===0[0]||typeof e=="string";n&&(e={textures:{},images:{},nodes:{}});let t=e.nodes[o];t===0[0]&&(t={uuid:o,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},n!==!0&&(e.nodes[t.uuid]=t),this.serialize(t),delete t.meta);function s(e){const t=[];for(const s in e){const n=e[s];delete n.metadata,t.push(n)}return t}if(n){const n=s(e.textures),o=s(e.images),i=s(e.nodes);n.length>0&&(t.textures=n),o.length>0&&(t.images=o),i.length>0&&(t.nodes=i)}return t}}class ArrayElementNode extends Node{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${s} ]`}}class ConvertNode extends Node{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const n=this.node.getNodeType(e);let t=null;for(const s of this.convertTo.split("|"))(t===null||e.getTypeLength(n)===e.getTypeLength(s))&&(t=s);return t}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,n=this.getNodeType(e),o=s.build(e,n);return e.format(o,n,t)}}class TempNode extends Node{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){const n=e.getBuildStage();if(n==="generate"){const n=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==0[0])return e.format(s.propertyName,n,t);if(n!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,n),a=e.getVarFromNode(this,null,n),i=e.getPropertyName(a);return e.addLineFlowCode(`${i} = ${o}`,this),s.snippet=o,s.propertyName=i,e.format(s.propertyName,n,t)}}return super.build(e,t)}}class JoinNode extends TempNode{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}
40getNodeType(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){const n=this.getNodeType(e),o=e.getTypeLength(n),r=this.nodes,i=e.getComponentType(n),a=[];let s=0;for(const d of r){if(s>=o){error(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let t=d.getNodeType(e),c=e.getTypeLength(t),l;s+c>o&&(error(`TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=o-s,t=e.getTypeFromLength(c)),s+=c,l=d.build(e,t);const u=e.getComponentType(t);if(u!==i){const n=e.getTypeFromLength(c,i);l=e.format(l,t,n)}a.push(l)}const c=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(c,n,t)}}_stringVectorComponents=vectorComponents.join("");class SplitNode extends Node{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(const t of this.components)e=Math.max(vectorComponents.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){const s=this.node,o=e.getTypeLength(s.getNodeType(e));let n=null;if(o>1){let i=null;const r=this.getVectorLength();r>=o&&(i=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=s.build(e,i);this.components.length===o&&this.components===_stringVectorComponents.slice(0,this.components.length)?n=e.format(a,i,t):n=e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else n=s.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class SetNode extends TempNode{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){const{sourceNode:i,components:t,targetNode:o}=this,n=this.getNodeType(e),a=e.getComponentType(o.getNodeType(e)),r=e.getTypeFromLength(t.length,a),c=o.build(e,r),l=i.build(e,n),d=e.getTypeLength(n),s=[];for(let e=0;e<d;e++){const n=vectorComponents[e];n===t[0]?(s.push(c),e+=t.length-1):s.push(l+"."+n)}return`${e.getType(n)}( ${s.join(", ")} )`}}class FlipNode extends TempNode{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:i,sourceNode:a}=this,s=this.getNodeType(e),r=a.build(e),c=e.getVarFromNode(this),t=e.getPropertyName(c);e.addLineFlowCode(t+" = "+r,this);const l=e.getTypeLength(s),n=[];let o=0;for(let e=0;e<l;e++){const s=vectorComponents[e];s===i[o]?(n.push("1.0 - "+(t+"."+s)),o++):n.push(t+"."+s)}return`${e.getType(s)}( ${n.join(", ")} )`}}class InputNode extends Node{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?getValueType(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=getValueType(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=arrayBufferToBase64(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?getValueFromType(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){warn("Abstract function.")}}_regNum=/float|u?int/;class ConstNode extends InputNode{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return _regNum.test(n)&&_regNum.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class MemberNode extends Node{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return!(this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1)&&this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const n=this.getNodeType(e),s=e.getStructTypeNode(n);return s.getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){warn(`TSL: Member "${this.property}" does not exist in struct.`);const t=this.getNodeType(e);return e.generateConst(t)}const t=this.structNode.build(e);return t+"."+this.property}}currentStack=null,NodeElements=new Map;function addMethodChaining(e,t){if(NodeElements.has(e)){warn(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!="function")throw new Error(`THREE.TSL: Node element ${e} is not a function`);NodeElements.set(e,t),e!=="assign"&&(Node.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Node.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}parseSwizzle=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),parseSwizzleAndSort=e=>parseSwizzle(e).split("").sort().join(""),Node.prototype.assign=function(...e){if(this.isStackNode!==!0)return currentStack!==null?currentStack.assign(this,...e):error
40("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;const t=NodeElements.get("assign");return this.addToStack(t(...e))},Node.prototype.toVarIntent=function(){return this},Node.prototype.get=function(e){return new MemberNode(this,e)},proto={};function setProtoSwizzle(e,t,n){proto[e]=proto[t]=proto[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===0[0]&&(t=new SplitNode(this,e),this._cache[e]=t),t},set(t){this[e].assign(nodeObject(t))}};const s=e.toUpperCase(),o=t.toUpperCase(),i=n.toUpperCase();Node.prototype["set"+s]=Node.prototype["set"+o]=Node.prototype["set"+i]=function(t){const n=parseSwizzleAndSort(e);return new SetNode(this,n,nodeObject(t))},Node.prototype["flip"+s]=Node.prototype["flip"+o]=Node.prototype["flip"+i]=function(){const t=parseSwizzleAndSort(e);return new FlipNode(this,t)}}swizzleA=["x","y","z","w"],swizzleB=["r","g","b","a"],swizzleC=["s","t","p","q"];for(let e=0;e<4;e++){let t=swizzleA[e],n=swizzleB[e],s=swizzleC[e];setProtoSwizzle(t,n,s);for(let o=0;o<4;o++){t=swizzleA[e]+swizzleA[o],n=swizzleB[e]+swizzleB[o],s=swizzleC[e]+swizzleC[o],setProtoSwizzle(t,n,s);for(let i=0;i<4;i++){t=swizzleA[e]+swizzleA[o]+swizzleA[i],n=swizzleB[e]+swizzleB[o]+swizzleB[i],s=swizzleC[e]+swizzleC[o]+swizzleC[i],setProtoSwizzle(t,n,s);for(let a=0;a<4;a++)t=swizzleA[e]+swizzleA[o]+swizzleA[i]+swizzleA[a],n=swizzleB[e]+swizzleB[o]+swizzleB[i]+swizzleB[a],s=swizzleC[e]+swizzleC[o]+swizzleC[i]+swizzleC[a],setProtoSwizzle(t,n,s)}}}for(let e=0;e<32;e++)proto[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===0[0]&&(t=new ArrayElementNode(this,new ConstNode(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(nodeObject(t))}};Object.defineProperties(Node.prototype,proto),nodeBuilderFunctionsCacheMap=new WeakMap,ShaderNodeObject=function(e,t=null){const n=getValueType(e);return n==="node"?e:t===null&&(n==="float"||n==="boolean")||n&&n!=="shader"&&n!=="string"?nodeObject(getConstNode(e,t)):n==="shader"?e.isFn?e:Fn(e):e},ShaderNodeObjects=function(e,t=null){for(const n in e)e[n]=nodeObject(e[n],t);return e},ShaderNodeArray=function(e,t=null){const n=e.length;for(let s=0;s<n;s++)e[s]=nodeObject(e[s],t);return e},ShaderNodeProxy=function(e,t=null,n=null,s=null){function c(e){return s!==null?(e=nodeObject(Object.assign(e,s)),s.intent===!0&&(e=e.toVarIntent())):e=nodeObject(e),e}let o,i=t,a,r;function l(t){let n;return i?n=/[a-z]/i.test(i)?i+"()":i:n=e.type,a!==0[0]&&t.length<a?(error(`TSL: "${n}" parameter length is less than minimum required.`),t.concat(new Array(a-t.length).fill(0))):r!==0[0]&&t.length>r?(error(`TSL: "${n}" parameter length exceeds limit.`),t.slice(0,r)):t}return t===null?o=(...t)=>c(new e(...nodeArray(l(t)))):n!==null?(n=nodeObject(n),o=(...s)=>c(new e(t,...nodeArray(l(s)),n))):o=(...n)=>c(new e(t,...nodeArray(l(n)))),o.setParameterLength=(...e)=>(e.length===1?a=r=e[0]:e.length===2&&([a,r]=e),o),o.setName=e=>(i=e,o),o},ShaderNodeImmutable=function(e,...t){return new e(...nodeArray(t))};class ShaderCallNodeInternal extends Node{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:n}=this,o=e.getNodeProperties(t),a=e.getClosestSubBuild(t.subBuilds)||"",i=a||"default";if(o[i])return o[i];const r=e.subBuildFn,c=e.fnCall;e.subBuildFn=a,e.fnCall=this;let s=null;if(t.layout){let o=nodeBuilderFunctionsCacheMap.get(e.constructor);o===0[0]&&(o=new WeakMap,nodeBuilderFunctionsCacheMap.set(e.constructor,o));let i=o.get(t);i===0[0]&&(i=nodeObject(e.buildFunctionNode(t)),o.set(t,i)),e.addInclude(i);const a=n?getLayoutParameters(n):null;s=nodeObject(i.call(a))}else{const i=new Proxy(e,{get:(e,t,n)=>{let s;return Symbol.iterator===t?s=function*(){yield}:s=Reflect.get(e,t,n),s}}),a=n?getProxyParameters(n):null,r=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc,c=r||o.length>1?o(a,i):o(i);s=nodeObject(c)}
40return e.subBuildFn=r,e.fnCall=c,t.once&&(o[i]=s),s}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const 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 s=null;const o=e.getBuildStage(),n=e.getNodeProperties(this),i=e.getSubBuildOutput(this),a=this.getOutputNode(e),r=e.fnCall;if(e.fnCall=this,o==="setup"){const t=e.getSubBuildProperty("initialized",this);if(n[t]!==!0&&(n[t]=!0,n[i]=this.getOutputNode(e),n[i].build(e),this.shaderNode.subBuilds))for(const n of e.chaining){const t=e.getDataFromNode(n,"any");t.subBuilds=t.subBuilds||new Set;for(const e of this.shaderNode.subBuilds)t.subBuilds.add(e)}s=n[i]}else o==="analyze"?a.build(e,t):o==="generate"&&(s=a.build(e,t)||"");return e.fnCall=r,s}}function getLayoutParameters(e){let t;nodeObjects(e);const n=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);return n?t=[...e]:t=e[0],t}function getProxyParameters(e){let t=0;return nodeObjects(e),new Proxy(e,{get:(n,s,o)=>{let i;if(s==="length")return i=e.length,i;if(Symbol.iterator===s)i=function*(){for(const t of e)yield nodeObject(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){const n=e[0];n[s]===0[0]?i=n[t++]:i=Reflect.get(n,s,o)}else e[0]instanceof Node&&(e[s]===0[0]?i=e[t++]:i=Reflect.get(e,s,o));else i=Reflect.get(n,s,o);i=nodeObject(i)}return i}})}class ShaderNodeInternal extends Node{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new ShaderCallNodeInternal(this,e)}setup(){return this.call()}}bools=[!1,!0],uints=[0,1,2,3],ints=[-1,-2],floats=[.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],boolsCacheMap=new Map;for(const e of bools)boolsCacheMap.set(e,new ConstNode(e));uintsCacheMap=new Map;for(const e of uints)uintsCacheMap.set(e,new ConstNode(e,"uint"));intsCacheMap=new Map([...uintsCacheMap].map(e=>new ConstNode(e.value,"int")));for(const e of ints)intsCacheMap.set(e,new ConstNode(e,"int"));floatsCacheMap=new Map([...intsCacheMap].map(e=>new ConstNode(e.value)));for(const e of floats)floatsCacheMap.set(e,new ConstNode(e));for(const e of floats)floatsCacheMap.set(-e,new ConstNode(-e));cacheMaps={bool:boolsCacheMap,uint:uintsCacheMap,ints:intsCacheMap,float:floatsCacheMap},constNodesCacheMap=new Map([...boolsCacheMap,...floatsCacheMap]),getConstNode=(e,t)=>constNodesCacheMap.has(e)?constNodesCacheMap.get(e):e.isNode===!0?e:new ConstNode(e,t),ConvertType=function(e,t=null){return(...n)=>{for(const t of n)if(t===0[0])return error(`TSL: Invalid parameter for the type "${e}".`),new ConstNode(0,e);if((n.length===0||!["bool","float","int","uint"].includes(e)&&n.every(e=>{const t=typeof e;return t!=="object"&&t!=="function"}))&&(n=[getValueFromType(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return nodeObjectIntent(t.get(n[0]));if(n.length===1){const t=getConstNode(n[0],e);return nodeObjectIntent(t.nodeType===e?t:new ConvertNode(t,e))}const s=n.map(e=>getConstNode(e));return nodeObjectIntent(new JoinNode(s,e))}},defined=e=>typeof e=="object"&&e!==null?e.value:e,getConstNodeType=e=>e!=null?e.nodeType||e.convertTo||(typeof e=="string"?e:null):null;function ShaderNode(e,t){return new ShaderNodeInternal(e,t)}nodeObject=(e,t=null)=>ShaderNodeObject(e,t),nodeObjectIntent=(e,t=null)=>nodeObject(e,t).toVarIntent(),nodeObjects=(e,t=null)=>new ShaderNodeObjects(e,t),nodeArray=(e,t=null)=>new ShaderNodeArray(e,t),nodeProxy=(e,t=null,n=null,s=null)=>new ShaderNodeProxy(e,t,n,s),nodeImmutable=(e,...t)=>new ShaderNodeImmutable(e,...t),nodeProxyIntent=(e,t=null,n=null,s={})=>new ShaderNodeProxy(e,t,n,{...s,intent:!0}),fnId=0;class FnNode extends Node{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:error("TSL: Invalid layout type."),t=null)),this.shaderNode=new ShaderNode(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+fnId++,type:t,inputs:[]};for(const t in e){if(t==="return")continue;n.inputs.push({name:t,type:e[t]})}e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...t){const e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent
40()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return error('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function Fn(e,t=null){const n=new FnNode(e,t);return new Proxy(()=>{},{apply(e,t,s){return n.call(...s)},get(e,t,s){return Reflect.get(n,t,s)},set(e,t,s,o){return Reflect.set(n,t,s,o)}})}setCurrentStack=e=>{currentStack=e},getCurrentStack=()=>currentStack,If=(...e)=>currentStack.If(...e);function Stack(e){return currentStack&¤tStack.addToStack(e),e}addMethodChaining("toStack",Stack),color=new ConvertType("color"),float=new ConvertType("float",cacheMaps.float),int=new ConvertType("int",cacheMaps.ints),uint=new ConvertType("uint",cacheMaps.uint),bool=new ConvertType("bool",cacheMaps.bool),vec2=new ConvertType("vec2"),ivec2=new ConvertType("ivec2"),uvec2=new ConvertType("uvec2"),bvec2=new ConvertType("bvec2"),vec3=new ConvertType("vec3"),ivec3=new ConvertType("ivec3"),uvec3=new ConvertType("uvec3"),bvec3=new ConvertType("bvec3"),vec4=new ConvertType("vec4"),ivec4=new ConvertType("ivec4"),uvec4=new ConvertType("uvec4"),bvec4=new ConvertType("bvec4"),mat2=new ConvertType("mat2"),mat3=new ConvertType("mat3"),mat4=new ConvertType("mat4"),addMethodChaining("toColor",color),addMethodChaining("toFloat",float),addMethodChaining("toInt",int),addMethodChaining("toUint",uint),addMethodChaining("toBool",bool),addMethodChaining("toVec2",vec2),addMethodChaining("toIVec2",ivec2),addMethodChaining("toUVec2",uvec2),addMethodChaining("toBVec2",bvec2),addMethodChaining("toVec3",vec3),addMethodChaining("toIVec3",ivec3),addMethodChaining("toUVec3",uvec3),addMethodChaining("toBVec3",bvec3),addMethodChaining("toVec4",vec4),addMethodChaining("toIVec4",ivec4),addMethodChaining("toUVec4",uvec4),addMethodChaining("toBVec4",bvec4),addMethodChaining("toMat2",mat2),addMethodChaining("toMat3",mat3),addMethodChaining("toMat4",mat4),element=nodeProxy(ArrayElementNode).setParameterLength(2),convert=(e,t)=>nodeObject(new ConvertNode(nodeObject(e),t)),addMethodChaining("element",element),addMethodChaining("convert",convert),addMethodChaining("append",e=>(warn("TSL: .append() has been renamed to .toStack()."),Stack(e)));class PropertyNode extends Node{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}customCacheKey(){return hashString(this.type+":"+(this.name||"")+":"+(this.varying?"1":"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)}}property=(e,t)=>new PropertyNode(e,t),varyingProperty=(e,t)=>new PropertyNode(e,t,!0),diffuseColor=nodeImmutable(PropertyNode,"vec4","DiffuseColor"),diffuseContribution=nodeImmutable(PropertyNode,"vec3","DiffuseContribution"),emissive=nodeImmutable(PropertyNode,"vec3","EmissiveColor"),roughness=nodeImmutable(PropertyNode,"float","Roughness"),metalness=nodeImmutable(PropertyNode,"float","Metalness"),clearcoat=nodeImmutable(PropertyNode,"float","Clearcoat"),clearcoatRoughness=nodeImmutable(PropertyNode,"float","ClearcoatRoughness"),sheen=nodeImmutable(PropertyNode,"vec3","Sheen"),sheenRoughness=nodeImmutable(PropertyNode,"float","SheenRoughness"),iridescence=nodeImmutable(PropertyNode,"float","Iridescence"),iridescenceIOR=nodeImmutable(PropertyNode,"float","IridescenceIOR"),iridescenceThickness=nodeImmutable(PropertyNode,"float","IridescenceThickness"),alphaT=nodeImmutable(PropertyNode,"float","AlphaT"),anisotropy=nodeImmutable(PropertyNode,"float","Anisotropy"),anisotropyT=nodeImmutable(PropertyNode,"vec3","AnisotropyT"),anisotropyB=nodeImmutable(PropertyNode,"vec3","AnisotropyB"),specularColor=nodeImmutable(PropertyNode,"color","SpecularColor"),specularColorBlended=nodeImmutable(PropertyNode,"color","SpecularColorBlended"),specularF90=nodeImmutable(PropertyNode,"float","SpecularF90"),shininess=nodeImmutable(PropertyNode,"float","Shininess"),output=nodeImmutable(PropertyNode,"vec4","Output"),dashSize=nodeImmutable(PropertyNode,"float","dashSize"),gapSize=nodeImmutable(PropertyNode,"float","gapSize"),ior=nodeImmutable(PropertyNode,"float","IOR"),transmission=nodeImmutable(PropertyNode,"float","Transmission"),thickness=nodeImmutable(PropertyNode,"float","Thickness"),attenuationDistance=nodeImmutable(PropertyNode,"float","AttenuationDistance"),attenuationColor=nodeImmutable(PropertyNode,"color","AttenuationColor"),dispersion=nodeImmutable(PropertyNode,"float","Dispersion");class UniformGroupNode extends Node{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}
40serialize(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}}uniformGroup=e=>new UniformGroupNode(e),sharedUniformGroup=(e,t=0)=>new UniformGroupNode(e,!0,t),frameGroup=sharedUniformGroup("frame"),renderGroup=sharedUniformGroup("render"),objectGroup=uniformGroup("object");class UniformNode extends InputNode{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=objectGroup}setName(e){return this.name=e,this}label(e){return warn('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(t=>{const n=e(t,this);n!==0[0]&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const o=this.getNodeType(e),i=this.getUniformHash(e);let n=e.getNodeFromHash(i);n===0[0]&&(e.setHashNode(this,i),n=this);const a=n.getInputType(e),c=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.nodeName),r=e.getPropertyName(c);e.context.nodeName!==0[0]&&delete e.context.nodeName;let s=r;if(o==="bool"){const n=e.getDataFromNode(this);let t=n.propertyName;if(t===0[0]){const i=e.getVarFromNode(this,null,"bool");t=e.getPropertyName(i),n.propertyName=t,s=e.format(r,a,o),e.addLineFlowCode(`${t} = ${s}`,this)}s=t}return e.format(s,o,t)}}uniform=(e,t)=>{const n=getConstNodeType(t||e);if(n===e&&(e=getValueFromType(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new UniformNode(e,n)};class ArrayNode extends TempNode{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.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}array=(...e)=>{let t;if(e.length===1){const n=e[0];t=new ArrayNode(null,n.length,n)}else{const n=e[0],s=e[1];t=new ArrayNode(n,s)}return nodeObject(t)},addMethodChaining("toArray",(e,t)=>array(Array(t).fill(e)));class AssignNode extends TempNode{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){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e)),s=vectorComponents.join("").slice(0,n)!==t.components;return s}return!1}setup(e){const{targetNode:t,sourceNode:s}=this,o=t.getScope(),i=e.getDataFromNode(o);i.assign=!0;const n=e.getNodeProperties(this);n.sourceNode=s,n.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:o,sourceNode:a}=e.getNodeProperties(this),l=this.needsSplitAssign(e),s=o.build(e),i=o.getNodeType(e),r=a.build(e,i),d=a.getNodeType(e),c=e.getDataFromNode(this);let n;if(c.initialized===!0)t!=="void"&&(n=s);else if(l){const l=e.getVarFromNode(this,null,i),c=e.getPropertyName(l);e.addLineFlowCode(`${c} = ${r}`,this);const a=o.node,d=a.node.context({assign:!0}),u=d.build(e);for(let t=0;t<a.components.length;t++){const n=a.components[t];e.addLineFlowCode(`${u}.${n} = ${c}[ ${t} ]`,this)}t!=="void"&&(n=s)}else n=`${s} = ${r}`,(t==="void"||d==="void")&&(e.addLineFlowCode(n,this),t!=="void"&&(n=s));return c.initialized=!0,e.format(n,i,t)}}assign=nodeProxy(AssignNode).setParameterLength(2),addMethodChaining("assign",assign);class FunctionCallNode extends TempNode{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const s=[],i=this.functionNode,n=i.getInputs(e),t=this.parameters,o=(t,n)=>{const o=n.type,i=o==="pointer";let s;return i?s="&"+t.build(e):s=t.build(e,o),s};if(Array.isArray(t)){if(t.length>n.length)error("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),t.length=n.length;else if(t.length<n.length)for(error("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");t.length<n.length;)t.push(float(0));for(let e=0;e<t.length;e++)s.push(o(t[e],n[e]))}else for(const e of n){const i=t[e.name];i!==0[0]?s.push(o(i,e)):(error(`TSL: Input '${e.name}' not found in 'Fn()'.`),s.push(o(float(0),e)))}const a=i.build(e,"property");return`${a}( ${s.join(", ")} )`}}call=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?nodeArray(t):nodeObjects(t[0]),new FunctionCallNode(nodeObject(e),t)),addMethodChaining("call",call),_vectorOperators={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class OperatorNode extends TempNode{static get type(){return"OperatorNode"}constructor(t,n,s,...e){if(super(),e.length>0){let o=new OperatorNode(t,n,s);for(let n=0;n<e.length-1;n++)o=new OperatorNode(t,o,e[n]);n=o,s=e[e.length-1]}this.op=t,this.aNode=n,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(_vectorOperators[this.op],t)}getNodeType(e,t=null){const n=this.op,a=this.aNode,i=this.bNode,s=a.getNodeType(e),o=i?i.getNodeType(e):null;if(s==="void"||o==="void")return t||"void";if(n==="%")return s;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(s);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const t=Math.max(e.getTypeLength(s),e.getTypeLength(o));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(s)){{if(o==="float")return s;if(e.isVector(o))return e.getVectorFromMatrix(s);if(e.isMatrix(o))return s}}else if(e.isMatrix(o)){if(s==="float")return o;if(e.isVector(s))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(s)?o:s}generate(e,t){const o=this.op,{aNode:d,bNode:c}=this,i=this.getNodeType(e,t);let n=null,s=null;i!=="void"?(n=d.getNodeType(e),s=c?c.getNodeType(e):null,o==="<"||o===">"||o==="<="||o===">="||o==="=="||o==="!="?e.isVector(n)?s=n:e.isVector(s)?n=s:n!==s&&(n=s="float"):o===">>"||o==="<<"?(n=i,s=e.changeComponentType(s,"uint")):o==="%"?(n=i,s=e.isInteger(n)&&e.isInteger(s)?s:n):e.isMatrix(n)?s==="float"?s="float":e.isVector(s)?s=e.getVectorFromMatrix(n):e.isMatrix(s)||(n=s=i):e.isMatrix(s)?n==="float"?n="float":e.isVector(n)?n=e.getVectorFromMatrix(s):n=s=i:n=s=i):n=s=i;const a=d.build(e,n),r=c?c.build(e,s):null,l=e.getFunctionOperator(o);if(t!=="void"){const c=e.renderer.coordinateSystem===WebGLCoordinateSystem;if(o==="=="||o==="!="||o==="<"||o===">"||o==="<="||o===">=")return c?e.isVector(n)?e.format(`${this.getOperatorMethod(e,t)}( ${a}, ${r} )`,i,t):e.format(`( ${a} ${o} ${r} )`,i,t):e.format(`( ${a} ${o} ${r} )`,i,t);else if(o==="%")return e.isInteger(s)?e.format(`( ${a} % ${r} )`,i,t):e.format(`${this.getOperatorMethod(e,i)}( ${a}, ${r} )`,i,t);else if(o==="!"||o==="~")return e.format(`(${o}${a})`,n,t);else if(l)return e.format(`${l}( ${a}, ${r} )`,i,t);else{if(e.isMatrix(n)&&s==="float")return e.format(`( ${r} ${o} ${a} )`,i,t);if(n==="float"&&e.isMatrix(s))return e.format(`${a} ${o} ${r}`,i,t);let l=`( ${a} ${o} ${r} )`;return!c&&i==="bool"&&e.isVector(n)&&e.isVector(s)&&(l=`all${l}`),e.format(l,i,t)}}else if(n!=="void")return l?e.format(`${l}( ${a}, ${r} )`,i,t):e.isMatrix(n)&&s==="float"?e.format(`${r} ${o} ${a}`,i,t):e.format(`${a} ${o} ${r}`,i,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}add=nodeProxyIntent(OperatorNode,"+").setParameterLength(2,1/0).setName("add"),sub=nodeProxyIntent(OperatorNode,"-").setParameterLength(2,1/0).setName("sub"),mul=nodeProxyIntent(OperatorNode,"*").setParameterLength(2,1/0).setName("mul"),div=nodeProxyIntent(OperatorNode,"/").setParameterLength(2,1/0).setName("div"),mod=nodeProxyIntent(OperatorNode,"%").setParameterLength(2).setName("mod"),equal=nodeProxyIntent(OperatorNode,"==").setParameterLength(2).setName("equal"),notEqual=nodeProxyIntent(OperatorNode,"!=").setParameterLength(2).setName("notEqual"),lessThan=nodeProxyIntent(OperatorNode,"<").setParameterLength(2).setName("lessThan"),greaterThan=nodeProxyIntent(OperatorNode,">").setParameterLength(2).setName("greaterThan"),lessThanEqual=nodeProxyIntent(OperatorNode,"<=").setParameterLength(2).setName("lessThanEqual"),greaterThanEqual=nodeProxyIntent(OperatorNode,">=").setParameterLength(2).setName("greaterThanEqual"),and=nodeProxyIntent(OperatorNode,"&&").setParameterLength(2,1/0).setName("and"),or=nodeProxyIntent(OperatorNode,"||").setParameterLength(2,1/0).setName("or"),not=nodeProxyIntent(OperatorNode,"!").setParameterLength(1).setName("not"),xor=nodeProxyIntent(OperatorNode,"^^").setParameterLength(2).setName("xor"),bitAnd=nodeProxyIntent(OperatorNode,"&").setParameterLength(2).setName("bitAnd"),bitNot=nodeProxyIntent(OperatorNode,"~").setParameterLength(1).setName("bitNot"),bitOr=nodeProxyIntent(OperatorNode,"|").setParameterLength(2).setName("bitOr"),bitXor=nodeProxyIntent(OperatorNode,"^").setParameterLength(2).setName("bitXor"),shiftLeft=nodeProxyIntent(OperatorNode,"<<").setParameterLength(2).setName("shiftLeft"),shiftRight=nodeProxyIntent(OperatorNode,">>").setParameterLength(2).setName("shiftRight"),incrementBefore=Fn(([e])=>(e.addAssign(1),e)),decrementBefore=Fn(([e])=>(e.subAssign(1),e)),increment=Fn(([e])=>{const t=int(e).toConst();return e.addAssign(1),t}),decrement=Fn(([e])=>{const t=int(e).toConst();return e.subAssign(1),t}),addMethodChaining("add",add),addMethodChaining("sub",sub),addMethodChaining("mul",mul),addMethodChaining("div",div),addMethodChaining("mod",mod),addMethodChaining("equal",equal),addMethodChaining("notEqual",notEqual),addMethodChaining("lessThan",lessThan),addMethodChaining("greaterThan",greaterThan),addMethodChaining("lessThanEqual",lessThanEqual),addMethodChaining("greaterThanEqual",greaterThanEqual),addMethodChaining("and",and),addMethodChaining("or",or),addMethodChaining("not",not),addMethodChaining("xor",xor),addMethodChaining("bitAnd",bitAnd),addMethodChaining("bitNot",bitNot),addMethodChaining("bitOr",bitOr),addMethodChaining("bitXor",b
40itXor),addMethodChaining("shiftLeft",shiftLeft),addMethodChaining("shiftRight",shiftRight),addMethodChaining("incrementBefore",incrementBefore),addMethodChaining("decrementBefore",decrementBefore),addMethodChaining("increment",increment),addMethodChaining("decrement",decrement),modInt=(e,t)=>(warn('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),mod(int(e),int(t))),addMethodChaining("modInt",modInt);class MathNode extends TempNode{static get type(){return"MathNode"}constructor(e,t,n=null,s=null){if(super(),(e===MathNode.MAX||e===MathNode.MIN)&&arguments.length>3){let o=new MathNode(e,t,n);for(let t=2;t<arguments.length-1;t++)o=new MathNode(e,o,arguments[t]);t=o,n=arguments[arguments.length-1],s=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=s,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,o=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),i=e.isMatrix(s)?0:e.getTypeLength(s);return o>a&&o>i?t:a>i?n:i>o?s:t}getNodeType(e){const t=this.method;return t===MathNode.LENGTH||t===MathNode.DISTANCE||t===MathNode.DOT?"float":t===MathNode.CROSS?"vec3":t===MathNode.ALL||t===MathNode.ANY?"bool":t===MathNode.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:n,bNode:o,method:s}=this;let t=null;if(s===MathNode.ONE_MINUS)t=sub(1,n);else if(s===MathNode.RECIPROCAL)t=div(1,n);else if(s===MathNode.DIFFERENCE)t=abs(sub(n,o));else if(s===MathNode.TRANSFORM_DIRECTION){let s=n,i=o;e.isMatrix(s.getNodeType(e))?i=vec4(vec3(i),0):s=vec4(vec3(s),0);const a=mul(s,i).xyz;t=normalize2(a)}return t!==null?t:super.setup(e)}generate(e,t){const d=e.getNodeProperties(this);if(d.outputNode)return super.generate(e,t);let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,c=this.cNode,l=e.renderer.coordinateSystem;if(n===MathNode.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);const i=[];return n===MathNode.CROSS?i.push(a.build(e,r),o.build(e,r)):l===WebGLCoordinateSystem&&n===MathNode.STEP?i.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):l===WebGLCoordinateSystem&&(n===MathNode.MIN||n===MathNode.MAX)?i.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):n===MathNode.REFRACT?i.push(a.build(e,s),o.build(e,s),c.build(e,"float")):n===MathNode.MIX?i.push(a.build(e,s),o.build(e,s),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":s)):(l===WebGPUCoordinateSystem&&n===MathNode.ATAN&&o!==null&&(n="atan2"),e.shaderStage!=="fragment"&&(n===MathNode.DFDX||n===MathNode.DFDY)&&(warn(`TSL: '${n}' is not supported in the ${e.shaderStage} stage.`),n="/*"+n+"*/"),i.push(a.build(e,s)),o!==null&&i.push(o.build(e,s)),c!==null&&i.push(c.build(e,s))),e.format(`${e.getMethod(n,r)}( ${i.join(", ")} )`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}MathNode.ALL="all",MathNode.ANY="any",MathNode.RADIANS="radians",MathNode.DEGREES="degrees",MathNode.EXP="exp",MathNode.EXP2="exp2",MathNode.LOG="log",MathNode.LOG2="log2",MathNode.SQRT="sqrt",MathNode.INVERSE_SQRT="inversesqrt",MathNode.FLOOR="floor",MathNode.CEIL="ceil",MathNode.NORMALIZE="normalize",MathNode.FRACT="fract",MathNode.SIN="sin",MathNode.COS="cos",MathNode.TAN="tan",MathNode.ASIN="asin",MathNode.ACOS="acos",MathNode.ATAN="atan",MathNode.ABS="abs",MathNode.SIGN="sign",MathNode.LENGTH="length",MathNode.NEGATE="negate",MathNode.ONE_MINUS="oneMinus",MathNode.DFDX="dFdx",MathNode.DFDY="dFdy",MathNode.ROUND="round",MathNode.RECIPROCAL="reciprocal",MathNode.TRUNC="trunc",MathNode.FWIDTH="fwidth",MathNode.TRANSPOSE="transpose",MathNode.DETERMINANT="determinant",MathNode.INVERSE="inverse",MathNode.EQUALS="equals",MathNode.MIN="min",MathNode.MAX="max",MathNode.STEP="step",MathNode.REFLECT="reflect",MathNode.DISTANCE="distance",MathNode.DIFFERENCE="difference",MathNode.DOT="dot",MathNode.CROSS="cross",MathNode.POW="pow",MathNode.TRANSFORM_DIRECTION="transformDirection",MathNode.MIX="mix",MathNode.CLAMP="clamp",MathNode.REFRACT="refract",MathNode.SMOOTHSTEP="smoothstep",MathNode.FACEFORWARD="faceforward",EPSILON=float(1e-6),PI=float(Math.PI),PI2=float(Math.PI*2),TWO_PI=float(Math.PI*2),HALF_PI=float(Math.PI*.5),all=nodeProxyIntent(MathNode,MathNode.ALL).setParameterLength(1),any=nodeProxyIntent(MathNode,MathNode.ANY).setParameterLength(1),radians=nodeProxyIntent(MathNode,MathNode.RADIA
vendor: 6,078 bytes, line 40
40NS).setParameterLength(1),degrees=nodeProxyIntent(MathNode,MathNode.DEGREES).setParameterLength(1),exp=nodeProxyIntent(MathNode,MathNode.EXP).setParameterLength(1),exp2=nodeProxyIntent(MathNode,MathNode.EXP2).setParameterLength(1),log2=nodeProxyIntent(MathNode,MathNode.LOG).setParameterLength(1),log22=nodeProxyIntent(MathNode,MathNode.LOG2).setParameterLength(1),sqrt=nodeProxyIntent(MathNode,MathNode.SQRT).setParameterLength(1),inverseSqrt=nodeProxyIntent(MathNode,MathNode.INVERSE_SQRT).setParameterLength(1),floor=nodeProxyIntent(MathNode,MathNode.FLOOR).setParameterLength(1),ceil=nodeProxyIntent(MathNode,MathNode.CEIL).setParameterLength(1),normalize2=nodeProxyIntent(MathNode,MathNode.NORMALIZE).setParameterLength(1),fract=nodeProxyIntent(MathNode,MathNode.FRACT).setParameterLength(1),sin=nodeProxyIntent(MathNode,MathNode.SIN).setParameterLength(1),cos=nodeProxyIntent(MathNode,MathNode.COS).setParameterLength(1),tan=nodeProxyIntent(MathNode,MathNode.TAN).setParameterLength(1),asin=nodeProxyIntent(MathNode,MathNode.ASIN).setParameterLength(1),acos=nodeProxyIntent(MathNode,MathNode.ACOS).setParameterLength(1),atan=nodeProxyIntent(MathNode,MathNode.ATAN).setParameterLength(1,2),abs=nodeProxyIntent(MathNode,MathNode.ABS).setParameterLength(1),sign=nodeProxyIntent(MathNode,MathNode.SIGN).setParameterLength(1),length=nodeProxyIntent(MathNode,MathNode.LENGTH).setParameterLength(1),negate=nodeProxyIntent(MathNode,MathNode.NEGATE).setParameterLength(1),oneMinus=nodeProxyIntent(MathNode,MathNode.ONE_MINUS).setParameterLength(1),dFdx=nodeProxyIntent(MathNode,MathNode.DFDX).setParameterLength(1),dFdy=nodeProxyIntent(MathNode,MathNode.DFDY).setParameterLength(1),round=nodeProxyIntent(MathNode,MathNode.ROUND).setParameterLength(1),reciprocal=nodeProxyIntent(MathNode,MathNode.RECIPROCAL).setParameterLength(1),trunc=nodeProxyIntent(MathNode,MathNode.TRUNC).setParameterLength(1),fwidth=nodeProxyIntent(MathNode,MathNode.FWIDTH).setParameterLength(1),transpose=nodeProxyIntent(MathNode,MathNode.TRANSPOSE).setParameterLength(1),determinant=nodeProxyIntent(MathNode,MathNode.DETERMINANT).setParameterLength(1),inverse=nodeProxyIntent(MathNode,MathNode.INVERSE).setParameterLength(1),equals=(e,t)=>(warn('TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),equal(e,t)),min$1=nodeProxyIntent(MathNode,MathNode.MIN).setParameterLength(2,1/0),max$1=nodeProxyIntent(MathNode,MathNode.MAX).setParameterLength(2,1/0),step=nodeProxyIntent(MathNode,MathNode.STEP).setParameterLength(2),reflect=nodeProxyIntent(MathNode,MathNode.REFLECT).setParameterLength(2),distance=nodeProxyIntent(MathNode,MathNode.DISTANCE).setParameterLength(2),difference=nodeProxyIntent(MathNode,MathNode.DIFFERENCE).setParameterLength(2),dot=nodeProxyIntent(MathNode,MathNode.DOT).setParameterLength(2),cross=nodeProxyIntent(MathNode,MathNode.CROSS).setParameterLength(2),pow=nodeProxyIntent(MathNode,MathNode.POW).setParameterLength(2),pow2=e=>mul(e,e),pow3=e=>mul(e,e,e),pow4=e=>mul(e,e,e,e),transformDirection=nodeProxyIntent(MathNode,MathNode.TRANSFORM_DIRECTION).setParameterLength(2),cbrt=e=>mul(sign(e),pow(abs(e),1/3)),lengthSq=e=>dot(e,e),mix=nodeProxyIntent(MathNode,MathNode.MIX).setParameterLength(3),clamp2=(e,t=0,n=1)=>nodeObject(new MathNode(MathNode.CLAMP,nodeObject(e),nodeObject(t),nodeObject(n))),saturate=e=>clamp2(e),refract=nodeProxyIntent(MathNode,MathNode.REFRACT).setParameterLength(3),smoothstep2=nodeProxyIntent(MathNode,MathNode.SMOOTHSTEP).setParameterLength(3),faceForward=nodeProxyIntent(MathNode,MathNode.FACEFORWARD).setParameterLength(3),rand=Fn(([e])=>{const t=12.9898,n=78.233,s=43758.5453,o=dot(e.xy,vec2(t,n)),i=mod(o,PI);return fract(sin(i).mul(s))}),mixElement=(e,t,n)=>mix(t,n,e),smoothstepElement=(e,t,n)=>smoothstep2(t,n,e),stepElement=(e,t)=>step(t,e),atan2=(e,t)=>(warn('TSL: "atan2" is overloaded. Use "atan" instead.'),atan(e,t)),addMethodChaining("all",all),addMethodChaining("any",any),addMethodChaining("equals",equals),addMethodChaining("radians",radians),addMethodChaining("degrees",degrees),addMethodChaining("exp",exp),addMethodChaining("exp2",exp2),addMethodChaining("log",log2),addMethodChaining("log2",log22),addMethodChaining("sqrt",sqrt),addMethodChaining("inverseSqrt",inverseSqrt),addMethodChaining("floor",floor),addMethodChaining("ceil",ceil),addMethodChaining("normalize",normalize2),addMethodChaining("fract",fract),addMethodChaining("sin",sin),addMethodChaining("cos",cos),addMethodChaining("tan",tan),addMethodChaining("asin",asin),addMethodChaining("acos",acos),addMethodChaining("atan",atan),addMethodChaining("abs",abs),addMethodChaining("sign",sign),addMethodChaining("length",length),addMethodChaining("lengthSq",lengthSq),addMethodChaining("negate",negate),addMethodChaining("oneMinus",oneMinus),addMethodChaining("dFdx",dFdx),addMethodChaining("dFdy",dFdy),addMethodChaining("round",round),addMethodChaining("reciprocal",reciprocal),addMethodChaining("trunc",trunc),addMethodChaining("fwidth",fwidth),addMethodChaining("atan2",atan2),addMethodChaining("min",min$1),addMethodChaining("max",max$1),addMethodChaining("step",stepElement),addMethodChaining("reflect",reflect),addMethodChaining("distance",distance),addMethodChaining("dot",dot),addMethodChaining("cross",cross),addMethodChaining("pow",pow),addMethodChaining("pow2",pow2),addMethodChaining("pow3",pow3),addMethodChaining("pow4",pow4),addMethodChaining("transformDirection",transformDirection),addMethodChaining("mix",mixElement),addMethodChaining("clamp",clamp2),addMethodChaining("refract",refract),addMethodChaining("smoothstep",smoothstepElement),addMethodChaining("faceForward",faceForward),addMethodChaining("difference",difference),addMethodChaining("saturate",saturate),addMethodChaining("cbrt",cbrt),addMethodChaining("transpose",transpose),addMethodChaining("determinant",determinant),addMethodChaining("inverse",inverse),addMethodChaining("rand",rand);class ConditionalNode extends Node{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}
40getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===0[0])return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(n!==null){const t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const a=this.condNode,n=this.ifNode.isolate(),t=this.elseNode?this.elseNode.isolate():null,o=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=o,t!==null&&(e.getDataFromNode(t).parentNodeBlock=o);const i=e.context.uniformFlow,s=e.getNodeProperties(this);s.condNode=a,s.ifNode=i?n:n.context({nodeBlock:n}),s.elseNode=t?i?t:t.context({nodeBlock:t}):null}generate(e,t){const s=this.getNodeType(e),a=e.getDataFromNode(this);if(a.nodeProperty!==0[0])return a.nodeProperty;const{condNode:u,ifNode:c,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,r=t!=="void",i=r?property(s).build(e):"";a.nodeProperty=i;const d=u.build(e,"bool"),h=e.context.uniformFlow;if(h&&o!==null){const n=c.build(e,s),i=o.build(e,s),a=e.getTernary(d,n,i);return e.format(a,s,t)}e.addFlowCode(` 41${e.tab}if ( ${d} ) { 42 43`).addFlowTab();let n=c.build(e,s);if(n&&(r?n=i+" = "+n+";":(n="return "+n+";",l===null&&(warn("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),n="// "+n))),e.removeFlowTab().addFlowCode(e.tab+" "+n+` 44 45`+e.tab+"}"),o!==null){e.addFlowCode(` else { 46 47`).addFlowTab();let t=o.build(e,s);t&&(r?t=i+" = "+t+";":(t="return "+t+";",l===null&&(warn("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+" "+t+` 48 49`+e.tab+`} 50 51`)}else e.addFlowCode(` 52 53`);return e.format(i,s,t)}}select=nodeProxy(ConditionalNode).setParameterLength(2,3),addMethodChaining("select",select);class ContextNode extends Node{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const n=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(n),s}}context=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new ContextNode(n,t)},uniformFlow=e=>context(e,{uniformFlow:!0}),setName=(e,t)=>context(e,{nodeName:t});function builtinShadowContext(e,t,n=null){return context(n,{getShadow:({light:n,shadowColorNode:s})=>t===n?s.mul(e):s})}function builtinAOContext(e,t=null){return context(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t!==null?t.mul(e):e})}function label(e,t){return warn('TSL: "label()" has been deprecated. Use "setName()" instead.'),setName(e,t)}addMethodChaining("context",context),addMethodChaining("label",label),addMethodChaining("uniformFlow",uniformFlow),addMethodChaining("setName",setName),addMethodChaining("builtinShadowContext",(e,t,n)=>builtinShadowContext(t,n,e)),addMethodChaining("builtinAOContext",(e,t)=>builtinAOContext(t,e));class VarNode extends Node{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}isIntent(e){const t=e.getDataFromNode(this);return t.forceDeclaration!==!0&&this.intent}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)}isAssign(e){const t=e.getDataFromNode(this);return t.assign}build(...t){const e=t[0];if(this._hasStack(e)===!1&&e.buildStage==="setup"&&(e.context.nodeLoop||e.context.nodeBlock)){let t=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&e.fnCall&&e.fnCall.shaderNode){const n=e.getDataFromNode(this.node.shaderNode);
53if(n.hasLoop){const n=e.getDataFromNode(this);n.forceDeclaration=!0,t=!0}}const n=e.getBaseStack();t?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(e)&&this.isAssign(e)!==!0?this.node.build(...t):super.build(...t)}generate(e){const{node:n,name:m,readOnly:r}=this,{renderer:u}=e,c=u.backend.isWebGPUBackend===!0;let o=!1,i=!1;r&&(o=e.isDeterministic(n),i=c?r:o);const l=this.getNodeType(e);if(l=="void"){this.isIntent(e)!==!0&&error('TSL: ".toVar()" can not be used with void type.');const t=n.build(e);return t}const d=e.getVectorType(l),h=n.build(e,d),a=e.getVarFromNode(this,m,d,0[0],i),t=e.getPropertyName(a);let s=t;if(i)if(c)s=o?`const ${t}`:`let ${t}`;else{const o=n.getArrayCount(e);s=`const ${e.getVar(a.type,t,o)}`}return e.addLineFlowCode(`${s} = ${h}`,this),t}_hasStack(e){const t=e.getDataFromNode(this);return t.stack!==0[0]}}createVar=nodeProxy(VarNode),Var=(e,t=null)=>createVar(e,t).toStack(),Const=(e,t=null)=>createVar(e,t,!0).toStack(),VarIntent=e=>createVar(e).setIntent(!0).toStack(),addMethodChaining("toVar",Var),addMethodChaining("toConst",Const),addMethodChaining("toVarIntent",VarIntent);class SubBuildNode extends Node{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);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const n=this.node.build(e,...t);return e.removeSubBuild(),n}}subBuild=(e,t,n=null)=>nodeObject(new SubBuildNode(nodeObject(e),t,n));class VaryingNode extends Node{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){const n=e.getNodeProperties(this);let t=n.varying;if(t===0[0]){const s=this.name,o=this.getNodeType(e),i=this.interpolationType,a=this.interpolationSampling;n.varying=t=e.getVaryingFromNode(this,s,o,i,a),n.node=subBuild(this.node,"VERTEX")}return t.needsInterpolation||(t.needsInterpolation=e.shaderStage==="fragment"),t}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(NodeShaderStage.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(NodeShaderStage.VERTEX,this.node)}generate(e){const n=e.getSubBuildProperty("property",e.currentStack),t=e.getNodeProperties(this),s=this.setupVarying(e);if(t[n]===0[0]){const i=this.getNodeType(e),o=e.getPropertyName(s,NodeShaderStage.VERTEX);e.flowNodeFromShaderStage(NodeShaderStage.VERTEX,t.node,i,o),t[n]=o}return e.getPropertyName(s)}}varying=nodeProxy(VaryingNode).setParameterLength(1,2),vertexStage=e=>varying(e),addMethodChaining("toVarying",varying),addMethodChaining("toVertexStage",vertexStage),addMethodChaining("varying",(...e)=>(warn("TSL: .varying() has been renamed to .toVarying()."),varying(...e))),addMethodChaining("vertexStage",(...e)=>(warn("TSL: .vertexStage() has been renamed to .toVertexStage()."),varying(...e))),sRGBTransferEOTF=Fn(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),s=e.lessThanEqual(.04045),o=mix(t,n,s);return o}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),sRGBTransferOETF=Fn(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),s=e.lessThanEqual(.0031308),o=mix(t,n,s);return o}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),WORKING_COLOR_SPACE="WorkingColorSpace",OUTPUT_COLOR_SPACE="OutputColorSpace";class ColorSpaceNode extends TempNode{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===WORKING_COLOR_SPACE?ColorManagement.workingColorSpace:t===OUTPUT_COLOR_SPACE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:o}=this,n=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);
53let t=o;return ColorManagement.enabled===!1||n===s||!n||!s?t:(ColorManagement.getTransfer(n)===SRGBTransfer&&(t=vec4(sRGBTransferEOTF(t.rgb),t.a)),ColorManagement.getPrimaries(n)!==ColorManagement.getPrimaries(s)&&(t=vec4(mat3(ColorManagement._getMatrix(new Matrix3,n,s)).mul(t.rgb),t.a)),ColorManagement.getTransfer(s)===SRGBTransfer&&(t=vec4(sRGBTransferOETF(t.rgb),t.a)),t)}}workingToColorSpace=(e,t)=>nodeObject(new ColorSpaceNode(nodeObject(e),WORKING_COLOR_SPACE,t)),colorSpaceToWorking=(e,t)=>nodeObject(new ColorSpaceNode(nodeObject(e),t,WORKING_COLOR_SPACE)),addMethodChaining("workingToColorSpace",workingToColorSpace),addMethodChaining("colorSpaceToWorking",colorSpaceToWorking),ReferenceElementNode$1=class ReferenceElementNode extends ArrayElementNode{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}};class ReferenceBaseNode extends Node{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=NodeUpdateType.OBJECT}setGroup(e){return this.group=e,this}element(e){return new ReferenceElementNode$1(this,nodeObject(e))}setNodeType(e){const t=uniform(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){const{properties:t}=this;let n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}reference$1=(e,t,n)=>new ReferenceBaseNode(e,t,n);class RendererReferenceNode extends ReferenceBaseNode{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(renderGroup)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}rendererReference=(e,t,n=null)=>new RendererReferenceNode(e,t,n);class ToneMappingNode extends TempNode{static get type(){return"ToneMappingNode"}constructor(e,t=toneMappingExposure,n=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return hash$1(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,n=this._toneMapping;if(n===NoToneMapping)return t;let s=null;const o=e.renderer.library.getToneMappingFunction(n);return o!==null?s=vec4(o(t.rgb,this.exposureNode),t.a):(error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),s=t),s}}toneMapping=(e,t,n)=>nodeObject(new ToneMappingNode(e,nodeObject(t),nodeObject(n))),toneMappingExposure=rendererReference("toneMappingExposure","float"),addMethodChaining("toneMapping",(e,t,n)=>toneMapping(t,n,e)),_bufferLib=new WeakMap;function _getBufferAttribute(e,t){let n=_bufferLib.get(e);return n===0[0]&&(n=new InterleavedBuffer(e,t),_bufferLib.set(e,n)),n}class BufferAttributeNode extends InputNode{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=s,this.usage=StaticDrawUsage,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(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===0[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;const i=this.getNodeType(e),s=e.getTypeLength(i),t=this.value,o=this.bufferStride||s,a=this.bufferOffset;let n;t.isInterleavedBuffer===!0?n=t:t.isBufferAttribute===!0?n=_getBufferAttribute(t.array,o):n=_getBufferAttribute(t,o);const r=new InterleavedBufferAttribute(n,s,a);n.setUsage(this.usage),this.attribute=r,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const n=this.getNodeType(e),o=e.getBufferAttributeFromNode(this,n),s=e.getPropertyName(o);let t=null;if(e.shaderStage==="vertex"||e.shaderStage==="compute")this.name=s,t=s;else{const s=varying(this);
53t=s.build(e,n)}return t}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}}function createBufferAttribute(e,t=null,n=0,s=0,o=StaticDrawUsage,i=!1){return t==="mat3"||t===null&&e.itemSize===9?mat3(new BufferAttributeNode(e,"vec3",9,0).setUsage(o).setInstanced(i),new BufferAttributeNode(e,"vec3",9,3).setUsage(o).setInstanced(i),new BufferAttributeNode(e,"vec3",9,6).setUsage(o).setInstanced(i)):t==="mat4"||t===null&&e.itemSize===16?mat4(new BufferAttributeNode(e,"vec4",16,0).setUsage(o).setInstanced(i),new BufferAttributeNode(e,"vec4",16,4).setUsage(o).setInstanced(i),new BufferAttributeNode(e,"vec4",16,8).setUsage(o).setInstanced(i),new BufferAttributeNode(e,"vec4",16,12).setUsage(o).setInstanced(i)):new BufferAttributeNode(e,t,n,s)}bufferAttribute=(e,t=null,n=0,s=0)=>createBufferAttribute(e,t,n,s),instancedBufferAttribute=(e,t=null,n=0,s=0)=>createBufferAttribute(e,t,n,s,StaticDrawUsage,!0),instancedDynamicBufferAttribute=(e,t=null,n=0,s=0)=>createBufferAttribute(e,t,n,s,DynamicDrawUsage,!0),addMethodChaining("toAttribute",e=>bufferAttribute(e.value));class ComputeNode extends Node{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=NodeUpdateType.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 warn('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){const t=this.computeNode.build(e);if(t){const n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const t=this.computeNode.build(e,"void");t!==""&&e.addLineFlowCode(t,this)}else{const s=e.getNodeProperties(this),n=s.outputComputeNode;if(n)return n.build(e,t)}}}computeKernel=(e,t=[64])=>{(t.length===0||t.length>3)&&error("TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let e=0;e<t.length;e++){const n=t[e];(typeof n!="number"||n<=0||!Number.isInteger(n))&&error(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`)}for(;t.length<3;)t.push(1);return nodeObject(new ComputeNode(nodeObject(e),t))}
53,compute=(e,t,n)=>computeKernel(e,n).setCount(t),addMethodChaining("compute",compute),addMethodChaining("computeKernel",computeKernel);class IsolateNode extends Node{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const n=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const o=this.node.build(e,...t);return e.setCache(n),o}setParent(e){return this.parent=e,this}getParent(){return this.parent}}isolate=e=>new IsolateNode(nodeObject(e));function cache(e,t=!0){return warn('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),isolate(e).setParent(t)}addMethodChaining("cache",cache),addMethodChaining("isolate",isolate);class BypassNode extends Node{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){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}bypass=nodeProxy(BypassNode).setParameterLength(2),addMethodChaining("bypass",bypass);class RemapNode extends Node{static get type(){return"RemapNode"}constructor(e,t,n,s=float(0),o=float(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=s,this.outHighNode=o,this.doClamp=!0}setup(){const{node:s,inLowNode:t,inHighNode:o,outLowNode:n,outHighNode:i,doClamp:a}=this;let e=s.sub(t).div(o.sub(t));return a===!0&&(e=e.clamp()),e.mul(i.sub(n)).add(n)}}remap=nodeProxy(RemapNode,null,null,{doClamp:!1}).setParameterLength(3,5),remapClamp=nodeProxy(RemapNode).setParameterLength(3,5),addMethodChaining("remap",remap),addMethodChaining("remapClamp",remapClamp);class ExpressionNode extends Node{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),s=this.snippet;if(n==="void")e.addLineFlowCode(s,this);else return e.format(s,n,t)}}expression=nodeProxy(ExpressionNode).setParameterLength(1,2),Discard=e=>(e?select(e,expression("discard")):expression("discard")).toStack(),addMethodChaining("discard",Discard);class RenderOutputNode extends TempNode{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const s=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||NoToneMapping,n=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||NoColorSpace;return s!==NoToneMapping&&(t=t.toneMapping(s)),n!==NoColorSpace&&n!==ColorManagement.workingColorSpace&&(t=t.workingToColorSpace(n)),t}}renderOutput=(e,t=null,n=null)=>nodeObject(new RenderOutputNode(nodeObject(e),t,n)),addMethodChaining("renderOutput",renderOutput);class DebugNode extends TempNode{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){const n=this.callback,s=this.node.build(e),o="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(o.length);let t="";return t+="// #"+o+`# 54`,t+=e.flow.code.replace(/^\t/mg,"")+` 55`,t+="/* ... */ "+s+` /* ... */ 56`,t+="// #"+i+`# 57`,n!==null?n(e,t):log(t),s}}debug=(e,t=null)=>nodeObject(new DebugNode(nodeObject(e),t)).toStack(),addMethodChaining("debug",debug);class InspectorBase{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class InspectorNode extends Node{static get type(){return"InspectorNode"}constructor(e,t="",n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=NodeUpdateType.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;
57return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==InspectorBase&&warnOnce('TSL: ".toInspector()" is only available with WebGPU.'),t}}function inspector(e,t="",n=null){return e=nodeObject(e),e.before(new InspectorNode(e,t,n))}addMethodChaining("toInspector",inspector);class AttributeNode extends Node{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){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const s=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e),s=e.hasGeometryAttribute(t);if(s===!0){const o=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(o),i=e.getAttribute(t,s);if(e.shaderStage==="vertex")return e.format(i.name,s,n);const a=varying(this);return a.build(e,n)}else return 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}}attribute=(e,t=null)=>new AttributeNode(e,t),uv$1=(e=0)=>attribute("uv"+(e>0?e:""),"vec2");class TextureSizeNode extends Node{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${s} )`,this.getNodeType(e),t)}}textureSize=nodeProxy(TextureSizeNode).setParameterLength(1,2);class MaxMipLevelNode extends UniformNode{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=NodeUpdateType.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const n=this.texture,e=n.images,t=e&&e.length>0?e[0]&&e[0].image||e[0]:n.image;if(t&&t.width!==0[0]){const{width:e,height:n}=t;this.value=Math.log2(Math.max(e,n))}}}maxMipLevel=nodeProxy(MaxMipLevelNode).setParameterLength(1),EmptyTexture$1=new Texture;class TextureNode extends UniformNode{static get type(){return"TextureNode"}constructor(e=EmptyTexture$1,t=null,n=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=NodeUpdateType.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=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===UnsignedIntType?"uvec4":this.value.type===IntType?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return uv$1(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=uniform(this.value.matrix)),this._matrixUniform.mul(vec3(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=uniform(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(int(textureSize(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const s=this.value;if(!s||s.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");const o=Fn(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?NodeUpdateType.OBJECT:NodeUpdateType.NONE,t})();let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),t.uvNode=o,t.levelNode=n,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,s,o,i,a,r,c){const d=this.value;let l;return o?l=e.generateTextureBias(d,t,n,o,i,c):r?l=e.generateTextureGrad(d,t,n,r,i,c):a?l=e.generateTextureCompare(d,t,n,a,i,c):this.sampler===!1?l=e.generateTextureLoad(d,t,n,s,i,c):s?l=e.generateTextureLevel(d,t,n,s,i,c):l=e.generateTexture(d,t,n,i,c),l}generate(e,t){const r=this.value,c=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;const o=e.getDataFromNode(this);let n=o.propertyName;if(n===0[0]){const{uvNode:m,levelNode:a,biasNode:r,compareNode:l,depthNode:d,gradNode:t,offsetNode:u}=c,y=this.generateUV(e,m),h=a?a.build(e,"float"):null,f=r?r.build(e,"float"):null,p=d?d.build(e,"int"):null,g=l?l.build(e,"float"):null,v=t?[t[0].build(e,"vec2"),t[1].build(e,"vec2")]:null,b=u?this.generateOffset(e,u):null,j=e.getVarFromNode(this);n=e.getPropertyName(j);const i=this.generateSnippet(e,s,y,h,f,p,g,v,b);e.addLineFlowCode(`${n} = ${i}`,this),o.snippet=i,o.propertyName=n}let i=n;const a=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(i=colorSpaceToWorking(expression(i,a),r.colorSpace).setup(e).build(e,a)),e.format(i,a,t)}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return warn("TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=nodeObject(e).mul(maxMipLevel(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===NearestFilter||n.magFilter===NearestFilter)&&(warn("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),nodeObject(t)}level(e){const t=this.clone();return t.levelNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(t)}size(e){return textureSize(this,e)}bias(e){const t=this.clone();return t.biasNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(t)}grad(e,t){const n=this.clone();return n.gradNode=[nodeObject(e),nodeObject(t)],n.referenceNode=this.getBase(),nodeObject(n)}depth(e){const t=this.clone();return t.depthNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(t)}offset(e){const t=this.clone();return t.offsetNode=nodeObject(e),t.referenceNode=this.getBase(),nodeObject(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(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const 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}}textureBase=nodeProxy(TextureNode).setParameterLength(1,4).setName("texture"),texture=(e=EmptyTexture$1,t=null,n=null,
57s=null)=>{let o;return e&&e.isTextureNode===!0?(o=nodeObject(e.clone()),o.referenceNode=e.getBase(),t!==null&&(o.uvNode=nodeObject(t)),n!==null&&(o.levelNode=nodeObject(n)),s!==null&&(o.biasNode=nodeObject(s))):o=textureBase(e,t,n,s),o},textureLoad=(...e)=>texture(...e).setSampler(!1);class BufferNode extends UniformNode{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}buffer=(e,t,n)=>new BufferNode(e,t,n);class UniformArrayElementNode extends ArrayElementNode{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,n)}}class UniformArrayNode extends BufferNode{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?getValueType(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=NodeUpdateType.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const t=this.elementType;let e="vec4";return t==="mat2"?e="mat2":/mat/.test(t)===!0?e="mat4":t.charAt(0)==="i"?e="ivec4":t.charAt(0)==="u"&&(e="uvec4"),e}update(){const{array:t,value:e}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let n=0;n<t.length;n++){const s=n*4;e[s]=t[n]}else if(n==="color")for(let n=0;n<t.length;n++){const s=n*4,o=t[n];e[s]=o.r,e[s+1]=o.g,e[s+2]=o.b||0}else if(n==="mat2")for(let n=0;n<t.length;n++){const s=n*4,o=t[n];e[s]=o.elements[0],e[s+1]=o.elements[1],e[s+2]=o.elements[2],e[s+3]=o.elements[3]}else if(n==="mat3")for(let o=0;o<t.length;o++){const n=o*16,s=t[o];e[n]=s.elements[0],e[n+1]=s.elements[1],e[n+2]=s.elements[2],e[n+4]=s.elements[3],e[n+5]=s.elements[4],e[n+6]=s.elements[5],e[n+8]=s.elements[6],e[n+9]=s.elements[7],e[n+10]=s.elements[8],e[n+15]=1}else if(n==="mat4")for(let n=0;n<t.length;n++){const o=n*16,s=t[n];for(let t=0;t<s.elements.length;t++)e[o+t]=s.elements[t]}else for(let n=0;n<t.length;n++){const s=n*4,o=t[n];e[s]=o.x,e[s+1]=o.y,e[s+2]=o.z||0,e[s+3]=o.w||0}}setup(e){const n=this.array.length,s=this.elementType;let t=Float32Array;const o=this.paddedType,i=e.getTypeLength(o);return s.charAt(0)==="i"&&(t=Int32Array),s.charAt(0)==="u"&&(t=Uint32Array),this.value=new t(n*i),this.bufferCount=n,this.bufferType=o,super.setup(e)}element(e){return new UniformArrayElementNode(this,nodeObject(e))}}uniformArray=(e,t)=>new UniformArrayNode(e,t);class BuiltinNode extends Node{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}builtin=nodeProxy(BuiltinNode).setParameterLength(1);class ScreenNode extends Node{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===ScreenNode.DPR?"float":this.scope===ScreenNode.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=NodeUpdateType.NONE;return(this.scope===ScreenNode.SIZE||this.scope===ScreenNode.VIEWPORT||this.scope===ScreenNode.DPR)&&(e=NodeUpdateType.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ScreenNode.VIEWPORT?t!==null?_viewportVec.copy(t.viewport):(e.getViewport(_viewportVec),_viewportVec.multiplyScalar(e.getPixelRatio())):this.scope===ScreenNode.DPR?this._output.value=e.getPixelRatio():t!==null?(_screenSizeVec.width=t.width,_screenSizeVec.height=t.height):e.getDrawingBufferSize(_screenSizeVec)}setup(){const t=this.scope;let e=null;return t===ScreenNode.SIZE?e=uniform(_screenSizeVec||(_screenSizeVec=new Vector2)):t===ScreenNode.VIEWPORT?e=uniform(_viewportVec||(_viewportVec=new Vector4)):t===ScreenNode.DPR?e=uniform(1):e=vec2(screenCoordinate.div(screenSize)),this._output=e,e}generate(e){if(this.scope===ScreenNode.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(screenSize).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ScreenNode.COORDINATE="coordinate",ScreenNode.VIEWPORT="viewport",ScreenNode.SIZE="size",ScreenNode.UV="uv",ScreenNode.DPR="dpr",screenDPR=nodeImmutable(ScreenNode,ScreenNode.DPR),screenUV=nodeImmutable(ScreenNode,ScreenNode.UV),screenSize=nodeImmutable(ScreenNode,ScreenNode.SIZE),screenCoordinate=nodeImmutable(ScreenNode,ScreenNode.COORDINATE),viewport=nodeImmutable(ScreenNode,ScreenNode.VIEWPORT),viewportSize=viewport.zw,viewportCoordinate=screenCoordinate.sub(viewport.xy),cameraIndex=uniform(0,"uint").setName("u_cameraIndex").setGroup(sharedUniformGroup("cameraIndex")).toVarying("v_cameraIndex"),cameraNear=uniform("float").setName("cameraNear").setGroup(renderGroup).onRenderUpd
vendor: 4,509 bytes, line 57
57ate(({camera:e})=>e.near),cameraFar=uniform("float").setName("cameraFar").setGroup(renderGroup).onRenderUpdate(({camera:e})=>e.far),cameraProjectionMatrix=Fn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const n=[];for(const t of e.cameras)n.push(t.projectionMatrix);const s=uniformArray(n).setGroup(renderGroup).setName("cameraProjectionMatrices");t=s.element(e.isMultiViewCamera?builtin("gl_ViewID_OVR"):cameraIndex).toConst("cameraProjectionMatrix")}else t=uniform("mat4").setName("cameraProjectionMatrix").setGroup(renderGroup).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),cameraViewMatrix=Fn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const n=[];for(const t of e.cameras)n.push(t.matrixWorldInverse);const s=uniformArray(n).setGroup(renderGroup).setName("cameraViewMatrices");t=s.element(e.isMultiViewCamera?builtin("gl_ViewID_OVR"):cameraIndex).toConst("cameraViewMatrix")}else t=uniform("mat4").setName("cameraViewMatrix").setGroup(renderGroup).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),cameraPosition=Fn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const n=[];for(let t=0,s=e.cameras.length;t<s;t++)n.push(new Vector3);const s=uniformArray(n).setGroup(renderGroup).setName("cameraPositions").onRenderUpdate(({camera:e},t)=>{const n=e.cameras,s=t.array;for(let e=0,t=n.length;e<t;e++)s[e].setFromMatrixPosition(n[e].matrixWorld)});t=s.element(e.isMultiViewCamera?builtin("gl_ViewID_OVR"):cameraIndex).toConst("cameraPosition")}else t=uniform(new Vector3).setName("cameraPosition").setGroup(renderGroup).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld));return t}).once()(),_sphere2=new Sphere;class Object3DNode extends Node{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=NodeUpdateType.OBJECT,this.uniformNode=new UniformNode(null)}getNodeType(){const e=this.scope;if(e===Object3DNode.WORLD_MATRIX)return"mat4";if(e===Object3DNode.POSITION||e===Object3DNode.VIEW_POSITION||e===Object3DNode.DIRECTION||e===Object3DNode.SCALE)return"vec3";if(e===Object3DNode.RADIUS)return"float"}update(e){const n=this.object3d,t=this.uniformNode,s=this.scope;if(s===Object3DNode.WORLD_MATRIX)t.value=n.matrixWorld;else if(s===Object3DNode.POSITION)t.value=t.value||new Vector3,t.value.setFromMatrixPosition(n.matrixWorld);else if(s===Object3DNode.SCALE)t.value=t.value||new Vector3,t.value.setFromMatrixScale(n.matrixWorld);else if(s===Object3DNode.DIRECTION)t.value=t.value||new Vector3,n.getWorldDirection(t.value);else if(s===Object3DNode.VIEW_POSITION){const s=e.camera;t.value=t.value||new Vector3,t.value.setFromMatrixPosition(n.matrixWorld),t.value.applyMatrix4(s.matrixWorldInverse)}else if(s===Object3DNode.RADIUS){const s=e.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),_sphere2.copy(s.boundingSphere).applyMatrix4(n.matrixWorld),t.value=_sphere2.radius}}generate(e){const t=this.scope;return t===Object3DNode.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Object3DNode.POSITION||t===Object3DNode.VIEW_POSITION||t===Object3DNode.DIRECTION||t===Object3DNode.SCALE?this.uniformNode.nodeType="vec3":t===Object3DNode.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}}Object3DNode.WORLD_MATRIX="worldMatrix",Object3DNode.POSITION="position",Object3DNode.SCALE="scale",Object3DNode.VIEW_POSITION="viewPosition",Object3DNode.DIRECTION="direction",Object3DNode.RADIUS="radius",objectPosition=nodeProxy(Object3DNode,Object3DNode.POSITION).setParameterLength(1);class ModelNode extends Object3DNode{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}modelDirection=nodeImmutable(ModelNode,ModelNode.DIRECTION),modelWorldMatrix=nodeImmutable(ModelNode,ModelNode.WORLD_MATRIX),modelPosition=nodeImmutable(ModelNode,ModelNode.POSITION),modelScale=nodeImmutable(ModelNode,ModelNode.SCALE),modelViewPosition=nodeImmutable(ModelNode,ModelNode.VIEW_POSITION),modelRadius=nodeImmutable(ModelNode,ModelNode.RADIUS),modelNormalMatrix=uniform(new Matrix3).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),modelViewMatrix=Fn(e=>e.context.modelViewMatrix||mediumpModelViewMatrix).once()().toVar("modelViewMatrix"),mediumpModelViewMatrix=cameraViewMatrix.mul(modelWorldMatrix),highpModelViewMatrix=Fn(e=>
57(e.context.isHighPrecisionModelViewMatrix=!0,uniform("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),highpModelNormalViewMatrix=Fn(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return uniform("mat3").onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),positionGeometry=attribute("position","vec3"),positionLocal=positionGeometry.toVarying("positionLocal"),positionPrevious=positionGeometry.toVarying("positionPrevious"),positionWorld=Fn(e=>modelWorldMatrix.mul(positionLocal).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),positionWorldDirection=Fn(()=>{const e=positionLocal.transformDirection(modelWorldMatrix).toVarying("v_positionWorldDirection");return e.normalize().toVar("positionWorldDirection")},"vec3").once(["POSITION"])(),positionView=Fn(e=>e.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),positionViewDirection=Fn(e=>{let t;return e.camera.isOrthographicCamera?t=vec3(0,0,1):t=positionView.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class FrontFacingNode extends Node{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===BackSide?"false":e.getFrontFacing()}}frontFacing=nodeImmutable(FrontFacingNode),faceDirection=float(frontFacing).mul(2).sub(1),directionToFaceDirection=Fn(([e],{material:t})=>{const n=t.side;return n===BackSide?e=e.mul(-1):n===DoubleSide&&(e=e.mul(faceDirection)),e}),normalGeometry=attribute("normal","vec3"),normalLocal=Fn(e=>e.geometry.hasAttribute("normal")===!1?(warn('TSL: Vertex attribute "normal" not found on geometry.'),vec3(0,1,0)):normalGeometry,"vec3").once()().toVar("normalLocal"),normalFlat=positionView.dFdx().cross(positionView.dFdy()).normalize().toVar("normalFlat"),normalViewGeometry=Fn(e=>{let t;return e.material.flatShading===!0?t=normalFlat:t=transformNormalToView(normalLocal).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),normalWorldGeometry=Fn(e=>{let t=normalViewGeometry.transformDirection(cameraViewMatrix);return e.material.flatShading!==!0&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),normalView=Fn(({subBuildFn:e,material:t,context:n})=>{let s;return e==="NORMAL"||e==="VERTEX"?(s=normalViewGeometry,t.flatShading!==!0&&(s=directionToFaceDirection(s))):s=n.setupNormal().context({getUV:null}),s},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),normalWorld=normalView.transformDirection(cameraViewMatrix).toVar("normalWorld"),clearcoatNormalView=Fn(({subBuildFn:e,context:t})=>{let n;return e==="NORMAL"||e==="VERTEX"?n=normalView:n=t.setupClearcoatNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),transformNormal=Fn(([e,t=modelWorldMatrix])=>{const n=mat3(t),s=e.div(vec3(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(s).xyz}),transformNormalToView=Fn(([e],t)=>{const n=t.context.modelNormalViewMatrix;if(n)return n.transformDirection(e);const s=modelNormalMatrix.mul(e);return cameraViewMatrix.transformDirection(s)}),transformedNormalView=Fn(()=>(warn('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),normalView)).once(["NORMAL","VERTEX"])(),transformedNormalWorld=Fn(()=>(warn('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),normalWorld)).once(["NORMAL","VERTEX"])(),transformedClearcoatNormalView=Fn(()=>(warn('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),clearcoatNormalView)).once(["NORMAL","VERTEX"])(),_e1$1=new Euler,_m1$12=new Matrix4,materialRefractionRatio=uniform(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),materialEnvIntensity=uniform(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),materialEnvRotation=uniform(new Matrix4).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(_e1$1.copy(n),_m1$12.makeRotationFromEuler(_e1$1)):_m1$12.identity(),_m1$12}),reflectView=positionViewDirection.negate().reflect(normalView),refractView=positionViewDirection.negate().refract(normalView,materialRefractionRatio),reflectVector=reflectView.transformDirection(cameraViewMatrix).toVar("reflectVector"),refractVector=refractView.transformDirection(cameraViewMatrix).toVar("reflectVector"),EmptyTexture=new CubeTexture;class CubeTextureNode extends TextureNode{static get type(){return"CubeTextureNode"}
57constructor(e,t=null,n=null,s=null){super(e,t,n,s),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===CubeReflectionMapping?reflectVector:e.mapping===CubeRefractionMapping?refractVector:(error('CubeTextureNode: Mapping "%s" not supported.',e.mapping),vec3(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===WebGPUCoordinateSystem?vec3(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===WebGPUCoordinateSystem||!n.isRenderTargetTexture)&&(t=vec3(t.x.negate(),t.yz)),materialEnvRotation.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}cubeTextureBase=nodeProxy(CubeTextureNode).setParameterLength(1,4).setName("cubeTexture"),cubeTexture=(e=EmptyTexture,t=null,n=null,s=null)=>{let o;return e&&e.isCubeTextureNode===!0?(o=nodeObject(e.clone()),o.referenceNode=e,t!==null&&(o.uvNode=nodeObject(t)),n!==null&&(o.levelNode=nodeObject(n)),s!==null&&(o.biasNode=nodeObject(s))):o=cubeTextureBase(e,t,n,s),o};class ReferenceElementNode2 extends ArrayElementNode{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}}class ReferenceNode extends Node{static get type(){return"ReferenceNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=NodeUpdateType.OBJECT}element(e){return new ReferenceElementNode2(this,nodeObject(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return warn('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=buffer(null,e,this.count):Array.isArray(this.getValueFromReference())?t=uniformArray(null,e):e==="texture"?t=texture(null):e==="cubeTexture"?t=cubeTexture(null):t=uniform(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){const{properties:t}=this;let n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}reference=(e,t,n)=>new ReferenceNode(e,t,n),referenceBuffer=(e,t,n,s)=>new ReferenceNode(e,t,s,n);class MaterialReferenceNode extends ReferenceNode{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}}materialReference=(e,t,n=null)=>new MaterialReferenceNode(e,t,n),uv=uv$1(),q0=positionView.dFdx(),q1=positionView.dFdy(),st0=uv.dFdx(),st1=uv.dFdy(),N=normalView,q1perp=q1.cross(N),q0perp=N.cross(q0),T=q1perp.mul(st0.x).add(q0perp.mul(st1.x)),B=q1perp.mul(st0.y).add(q0perp.mul(st1.y)),det=T.dot(T).max(B.dot(B)),scale$1=det.equal(0).select(0,det.inverseSqrt()),tangentViewFrame=T.mul(scale$1).toVar("tangentViewFrame"),bitangentViewFrame=B.mul(scale$1).toVar("bitangentViewFrame"),tangentGeometry=attribute("tangent","vec4"),tangentLocal=tangentGeometry.xyz.toVar("tangentLocal"),tangentView=Fn(({subBuildFn:e,geometry:t,material:n})=>{let s;return e==="VERTEX"||t.hasAttribute("tangent")?s=modelViewMatrix.mul(vec4(tangentLocal,0)).xyz.toVarying("v_tangentView").normalize():s=tangentViewFrame,n.flatShading!==!0&&(s=directionToFaceDirection(s)),s},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),getBitangent=Fn(([e,t],{subBuildFn:n,material:s})=>{let o=e.mul(tangentGeometry.w).xyz;return n==="NORMAL"&&s.flatShading!==!0&&(o=o.toVarying(t)),o}).once(["NORMAL"]),bitangentView=Fn(({subBuildFn:e,geometry:t,material:n})=>{let s;return e==="VERTEX"||t.hasAttribute("tangent")?s=getBitangent(normalView.cross(tangentView),"v_bitangentView").normalize():s=bitangentViewFrame,n.flatShading!==!0&&(s=directionToFaceDirection(s)),s},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),TBNViewMatrix=mat3(tangentView,bitangentView,normalView).toVar("TBNViewMatrix"),bentNormalView=Fn(()=>
57{let e=anisotropyB.cross(positionViewDirection);return e=e.cross(anisotropyB).normalize(),e=mix(e,normalView,anisotropy.mul(roughness.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),directionToColor=e=>nodeObject(e).mul(.5).add(.5),unpackNormal=e=>vec3(e,sqrt(saturate(float(1).sub(dot(e,e)))));class NormalMapNode extends TempNode{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=TangentSpaceNormalMap,this.unpackNormalMode=NoNormalPacking}setup({material:e}){const{normalMapType:s,scaleNode:i,unpackNormalMode:n}=this;let t=this.node.mul(2).sub(1);if(s===TangentSpaceNormalMap?n===NormalRGPacking?t=unpackNormal(t.xy):n===NormalGAPacking?t=unpackNormal(t.yw):n!==NoNormalPacking&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${n}`):n!==NoNormalPacking&&console.error(`THREE.NodeMaterial: Normal map type '${s}' is not compatible with unpack normal mode '${n}'`),i!==null){let n=i;e.flatShading===!0&&(n=directionToFaceDirection(n)),t=vec3(t.xy.mul(n),t.z)}let o=null;return s===ObjectSpaceNormalMap?o=transformNormalToView(t):s===TangentSpaceNormalMap?o=TBNViewMatrix.mul(t).normalize():(error(`NodeMaterial: Unsupported normal map type: ${s}`),o=normalView),o}}normalMap=nodeProxy(NormalMapNode).setParameterLength(1,2),dHdxy_fwd=Fn(({textureNode:e,bumpScale:t})=>{const n=t=>e.isolate().context({getUV:e=>t(e.uvNode||uv$1()),forceUVContext:!0}),s=float(n(e=>e));return vec2(float(n(e=>e.add(e.dFdx()))).sub(s),float(n(e=>e.add(e.dFdy()))).sub(s)).mul(t)}),perturbNormalArb=Fn(e=>{const{surf_pos:t,surf_norm:n,dHdxy:s}=e,o=t.dFdx().normalize(),c=t.dFdy().normalize(),i=n,a=c.cross(i),l=i.cross(o),r=o.dot(a).mul(faceDirection),d=r.sign().mul(s.x.mul(a).add(s.y.mul(l)));return r.abs().mul(n).sub(d).normalize()});class BumpMapNode extends TempNode{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dHdxy_fwd({textureNode:this.textureNode,bumpScale:e});return perturbNormalArb({surf_pos:positionView,surf_norm:normalView,dHdxy:t})}}bumpMap=nodeProxy(BumpMapNode).setParameterLength(1,2),_propertyCache=new Map;class MaterialNode extends Node{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=_propertyCache.get(e);return n===0[0]&&(n=materialReference(e,t),_propertyCache.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){const s=e.context.material,t=this.scope;let n=null;if(t===MaterialNode.COLOR){const e=s.color!==0[0]?this.getColor(t):vec3();s.map&&s.map.isTexture===!0?n=e.mul(this.getTexture("map")):n=e}else if(t===MaterialNode.OPACITY){const e=this.getFloat(t);s.alphaMap&&s.alphaMap.isTexture===!0?n=e.mul(this.getTexture("alpha")):n=e}else if(t===MaterialNode.SPECULAR_STRENGTH)s.specularMap&&s.specularMap.isTexture===!0?n=this.getTexture("specular").r:n=float(1);else if(t===MaterialNode.SPECULAR_INTENSITY){const e=this.getFloat(t);s.specularIntensityMap&&s.specularIntensityMap.isTexture===!0?n=e.mul(this.getTexture(t).a):n=e}else if(t===MaterialNode.SPECULAR_COLOR){const e=this.getColor(t);s.specularColorMap&&s.specularColorMap.isTexture===!0?n=e.mul(this.getTexture(t).rgb):n=e}else if(t===MaterialNode.ROUGHNESS){const e=this.getFloat(t);s.roughnessMap&&s.roughnessMap.isTexture===!0?n=e.mul(this.getTexture(t).g):n=e}else if(t===MaterialNode.METALNESS){const e=this.getFloat(t);s.metalnessMap&&s.metalnessMap.isTexture===!0?n=e.mul(this.getTexture(t).b):n=e}else if(t===MaterialNode.EMISSIVE){const o=this.getFloat("emissiveIntensity"),e=this.getColor(t).mul(o);s.emissiveMap&&s.emissiveMap.isTexture===!0?n=e.mul(this.getTexture(t)):n=e}else if(t===MaterialNode.NORMAL)s.normalMap?(n=normalMap(this.getTexture("normal"),this.getCache("normalScale","vec2")),n.normalMapType=s.normalMapType,(s.normalMap.format==RGFormat||s.normalMap.format==RED_GREEN_RGTC2_Format||s.normalMap.format==RG11_EAC_Format)&&(n.unpackNormalMode=NormalRGPacking)):s.bumpMap?n=bumpMap(this.getTexture("bump").r,this.getFloat("bumpScale")):n=normalView;else if(t===MaterialNode.CLEARCOAT){const e=this.getFloat(t);s.clearcoatMap&&s.clearcoatMap.isTexture===!0?n=e.mul(this.getTexture(t).r):n=e}else if(t===MaterialNode.CLEARCOAT_ROUGHNESS){const e=this.getFloat(t);s.clearcoatRoughnessMap&&s.clearcoatRoughnessMap.isTexture===!0?n=e.mul(this.getTexture(t).r):n=e}else if(t===MaterialNode.CLEARCOAT_NORMAL)s.clearcoatNormalMap?n=normalMap(this.getTexture(t),this.getCache(t+"Scale","vec2")):n=normalView;else if(t===MaterialNode.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s.sheenColorMap&&s.sheenColorMap.isTexture===!0?n=e.mul(this.getTexture("sheenColor").rgb):n=e}else if(t===MaterialNode.SHEEN_ROUGHNESS){const e=this.getFloat(t);s.sheenRoughnessMap&&s.sheenRoughnessMap.isTexture===!0?n=e.mul(this.getTexture(t).a):n=e,n=n.clamp(1e-4,1)}else if(t===MaterialNode.ANISOTROPY)if(s.anisotropyMap&&s.anisotropyMap.isTexture===!0){const e=this.getTexture(t),s=mat2(materialAnisotropyVector.x,materialAnisotropyVector.y,materialAnisotropyVector.y.negate(),materialAnisotropyVector.x);n=s.mul(e.rg.mul(2).sub(vec2(1)).normalize().mul(e.b))}else n=materialAnisotropyVector;else if(t===MaterialNode.IRIDESCENCE_THICKNESS){const e=reference("1","float",s.iridescenceThicknessRange);
vendor: 4,967 bytes, line 57
57if(s.iridescenceThicknessMap){const o=reference("0","float",s.iridescenceThicknessRange);n=e.sub(o).mul(this.getTexture(t).g).add(o)}else n=e}else if(t===MaterialNode.TRANSMISSION){const e=this.getFloat(t);s.transmissionMap?n=e.mul(this.getTexture(t).r):n=e}else if(t===MaterialNode.THICKNESS){const e=this.getFloat(t);s.thicknessMap?n=e.mul(this.getTexture(t).g):n=e}else if(t===MaterialNode.IOR)n=this.getFloat(t);else if(t===MaterialNode.LIGHT_MAP)n=this.getTexture(t).rgb.mul(this.getFloat("lightMapIntensity"));else if(t===MaterialNode.AO)n=this.getTexture(t).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(t===MaterialNode.LINE_DASH_OFFSET)n=s.dashOffset?this.getFloat(t):float(0);else{const s=this.getNodeType(e);n=this.getCache(t,s)}return n}}MaterialNode.ALPHA_TEST="alphaTest",MaterialNode.COLOR="color",MaterialNode.OPACITY="opacity",MaterialNode.SHININESS="shininess",MaterialNode.SPECULAR="specular",MaterialNode.SPECULAR_STRENGTH="specularStrength",MaterialNode.SPECULAR_INTENSITY="specularIntensity",MaterialNode.SPECULAR_COLOR="specularColor",MaterialNode.REFLECTIVITY="reflectivity",MaterialNode.ROUGHNESS="roughness",MaterialNode.METALNESS="metalness",MaterialNode.NORMAL="normal",MaterialNode.CLEARCOAT="clearcoat",MaterialNode.CLEARCOAT_ROUGHNESS="clearcoatRoughness",MaterialNode.CLEARCOAT_NORMAL="clearcoatNormal",MaterialNode.EMISSIVE="emissive",MaterialNode.ROTATION="rotation",MaterialNode.SHEEN="sheen",MaterialNode.SHEEN_ROUGHNESS="sheenRoughness",MaterialNode.ANISOTROPY="anisotropy",MaterialNode.IRIDESCENCE="iridescence",MaterialNode.IRIDESCENCE_IOR="iridescenceIOR",MaterialNode.IRIDESCENCE_THICKNESS="iridescenceThickness",MaterialNode.IOR="ior",MaterialNode.TRANSMISSION="transmission",MaterialNode.THICKNESS="thickness",MaterialNode.ATTENUATION_DISTANCE="attenuationDistance",MaterialNode.ATTENUATION_COLOR="attenuationColor",MaterialNode.LINE_SCALE="scale",MaterialNode.LINE_DASH_SIZE="dashSize",MaterialNode.LINE_GAP_SIZE="gapSize",MaterialNode.LINE_WIDTH="linewidth",MaterialNode.LINE_DASH_OFFSET="dashOffset",MaterialNode.POINT_SIZE="size",MaterialNode.DISPERSION="dispersion",MaterialNode.LIGHT_MAP="light",MaterialNode.AO="ao",materialAlphaTest=nodeImmutable(MaterialNode,MaterialNode.ALPHA_TEST),materialColor=nodeImmutable(MaterialNode,MaterialNode.COLOR),materialShininess=nodeImmutable(MaterialNode,MaterialNode.SHININESS),materialEmissive=nodeImmutable(MaterialNode,MaterialNode.EMISSIVE),materialOpacity=nodeImmutable(MaterialNode,MaterialNode.OPACITY),materialSpecular=nodeImmutable(MaterialNode,MaterialNode.SPECULAR),materialSpecularIntensity=nodeImmutable(MaterialNode,MaterialNode.SPECULAR_INTENSITY),materialSpecularColor=nodeImmutable(MaterialNode,MaterialNode.SPECULAR_COLOR),materialSpecularStrength=nodeImmutable(MaterialNode,MaterialNode.SPECULAR_STRENGTH),materialReflectivity=nodeImmutable(MaterialNode,MaterialNode.REFLECTIVITY),materialRoughness=nodeImmutable(MaterialNode,MaterialNode.ROUGHNESS),materialMetalness=nodeImmutable(MaterialNode,MaterialNode.METALNESS),materialNormal=nodeImmutable(MaterialNode,MaterialNode.NORMAL),materialClearcoat=nodeImmutable(MaterialNode,MaterialNode.CLEARCOAT),materialClearcoatRoughness=nodeImmutable(MaterialNode,MaterialNode.CLEARCOAT_ROUGHNESS),materialClearcoatNormal=nodeImmutable(MaterialNode,MaterialNode.CLEARCOAT_NORMAL),materialRotation=nodeImmutable(MaterialNode,MaterialNode.ROTATION),materialSheen=nodeImmutable(MaterialNode,MaterialNode.SHEEN),materialSheenRoughness=nodeImmutable(MaterialNode,MaterialNode.SHEEN_ROUGHNESS),materialAnisotropy=nodeImmutable(MaterialNode,MaterialNode.ANISOTROPY),materialIridescence=nodeImmutable(MaterialNode,MaterialNode.IRIDESCENCE),materialIridescenceIOR=nodeImmutable(MaterialNode,MaterialNode.IRIDESCENCE_IOR),materialIridescenceThickness=nodeImmutable(MaterialNode,MaterialNode.IRIDESCENCE_THICKNESS),materialTransmission=nodeImmutable(MaterialNode,MaterialNode.TRANSMISSION),materialThickness=nodeImmutable(MaterialNode,MaterialNode.THICKNESS),materialIOR=nodeImmutable(MaterialNode,MaterialNode.IOR),materialAttenuationDistance=nodeImmutable(MaterialNode,MaterialNode.ATTENUATION_DISTANCE),materialAttenuationColor=nodeImmutable(MaterialNode,MaterialNode.ATTENUATION_COLOR),materialLineScale=nodeImmutable(MaterialNode,MaterialNode.LINE_SCALE),materialLineDashSize=nodeImmutable(MaterialNode,MaterialNode.LINE_DASH_SIZE),materialLineGapSize=nodeImmutable(MaterialNode,MaterialNode.LINE_GAP_SIZE),materialLineWidth=nodeImmutable(MaterialNode,MaterialNode.LINE_WIDTH),materialLineDashOffset=nodeImmutable(MaterialNode,MaterialNode.LINE_DASH_OFFSET),materialPointSize=nodeImmutable(MaterialNode,MaterialNode.POINT_SIZE),materialDispersion=nodeImmutable(MaterialNode,MaterialNode.DISPERSION),materialLightMap=nodeImmutable(MaterialNode,MaterialNode.LIGHT_MAP),materialAO=nodeImmutable(MaterialNode,MaterialNode.AO),materialAnisotropyVector=uniform(new Vector2).onReference(function(e){return e.material}
57).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),modelViewProjection=Fn(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class StorageArrayElementNode extends ArrayElementNode{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){const 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;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),s!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}storageElement=nodeProxy(StorageArrayElementNode).setParameterLength(2);class StorageBufferNode extends BufferNode{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let s,o=null;t&&t.isStruct?(s="struct",o=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=getTypeFromLength(e.itemSize),n=e.count):s=t,super(e,s,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=NodeAccess.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===0[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 storageElement(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(NodeAccess.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=bufferAttribute(this.value),this._varying=varying(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);const{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);const{attribute:n,varying:s}=this.getAttributeData(),t=s.build(e);return e.registerTransform(t,n),t}}storage=(e,t=null,n=0)=>new StorageBufferNode(e,t,n);class IndexNode extends Node{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const o=this.getNodeType(e),t=this.scope;let n;if(t===IndexNode.VERTEX)n=e.getVertexIndex();else if(t===IndexNode.INSTANCE)n=e.getInstanceIndex();else if(t===IndexNode.DRAW)n=e.getDrawIndex();else if(t===IndexNode.INVOCATION_LOCAL)n=e.getInvocationLocalIndex();else if(t===IndexNode.INVOCATION_SUBGROUP)n=e.getInvocationSubgroupIndex();else if(t===IndexNode.SUBGROUP)n=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+t);let s;if(e.shaderStage==="vertex"||e.shaderStage==="compute")s=n;else{const t=varying(this);s=t.build(e,o)}return s}}IndexNode.VERTEX="vertex",IndexNode.INSTANCE="instance",IndexNode.SUBGROUP="subgroup",IndexNode.INVOCATION_LOCAL="invocationLocal",IndexNode.INVOCATION_
57SUBGROUP="invocationSubgroup",IndexNode.DRAW="draw",vertexIndex=nodeImmutable(IndexNode,IndexNode.VERTEX),instanceIndex=nodeImmutable(IndexNode,IndexNode.INSTANCE),subgroupIndex=nodeImmutable(IndexNode,IndexNode.SUBGROUP),invocationSubgroupIndex=nodeImmutable(IndexNode,IndexNode.INVOCATION_SUBGROUP),invocationLocalIndex=nodeImmutable(IndexNode,IndexNode.INVOCATION_LOCAL),drawIndex=nodeImmutable(IndexNode,IndexNode.DRAW);class InstanceNode extends Node{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=NodeUpdateType.FRAME,this.buffer=null,this.bufferColor=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){const{instanceMatrix:n,instanceColor:s,isStorageMatrix:a,isStorageColor:r}=this,{count:i}=n;let{instanceMatrixNode:t,instanceColorNode:o}=this;if(t===null){if(a)t=storage(n,"mat4",Math.max(i,1)).element(instanceIndex);else if(i<=1e3)t=buffer(n.array,"mat4",Math.max(i,1)).element(instanceIndex);else{const e=new InstancedInterleavedBuffer(n.array,16,1);this.buffer=e;const s=n.usage===DynamicDrawUsage?instancedDynamicBufferAttribute:instancedBufferAttribute,o=[s(e,"vec4",16,0),s(e,"vec4",16,4),s(e,"vec4",16,8),s(e,"vec4",16,12)];t=mat4(...o)}this.instanceMatrixNode=t}if(s&&o===null){if(r)o=storage(s,"vec3",Math.max(s.count,1)).element(instanceIndex);else{const e=new InstancedBufferAttribute(s.array,3),t=s.usage===DynamicDrawUsage?instancedDynamicBufferAttribute:instancedBufferAttribute;this.bufferColor=e,o=vec3(t(e,"vec3",3,0))}this.instanceColorNode=o}const c=t.mul(positionLocal).xyz;if(positionLocal.assign(c),e.hasGeometryAttribute("normal")){const e=transformNormal(normalLocal,t);normalLocal.assign(e)}this.instanceColorNode!==null&&varyingProperty("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.usage!==DynamicDrawUsage&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.usage!==DynamicDrawUsage&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}}class InstancedMeshNode extends InstanceNode{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:s}=e;super(t,n,s),this.instancedMesh=e}}instancedMesh=nodeProxy(InstancedMeshNode).setParameterLength(1);class BatchNode extends Node{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=instanceIndex:this.batchingIdNode=drawIndex);const d=Fn(([e])=>{const t=int(textureSize(textureLoad(this.batchMesh._indirectTexture),0).x).toConst(),n=int(e).mod(t).toConst(),s=int(e).div(t).toConst();return textureLoad(this.batchMesh._indirectTexture,ivec2(n,s)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),a=d(int(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=int(textureSize(textureLoad(n),0).x).toConst(),c=float(a).mul(4).toInt().toConst(),s=c.mod(r).toConst(),o=c.div(r).toConst(),l=mat4(textureLoad(n,ivec2(s,o)),textureLoad(n,ivec2(s.add(1),o)),textureLoad(n,ivec2(s.add(2),o)),textureLoad(n,ivec2(s.add(3),o))),i=this.batchMesh._colorsTexture;if(i!==null){const e=Fn(([e])=>{const t=int(textureSize(textureLoad(i),0).x).toConst(),n=e,s=n.mod(t).toConst(),o=n.div(t).toConst();return textureLoad(i,ivec2(s,o)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(a);varyingProperty("vec3","vBatchColor").assign(t)}const t=mat3(l);positionLocal.assign(l.mul(positionLocal));const u=normalLocal.div(vec3(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2]))),h=t.mul(u).xyz;normalLocal.assign(h),e.hasGeometryAttribute("tangent")&&tangentLocal.mulAssign(t)}}batch=nodeProxy(BatchNode).setParameterLength(1),_frameId=new WeakMap;class SkinningNode extends Node{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=NodeUpdateType.OBJECT,this.skinIndexNode=attribute("skinIndex","uvec4"),this.skinWeightNode=attribute("skinWeight","vec4"),this.bindMatrixNode=reference("bindMatrix","mat4"),this.bindMatrixInverseNo
57de=reference("bindMatrixInverse","mat4"),this.boneMatricesNode=referenceBuffer("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=positionLocal,this.toPositionNode=positionLocal,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:a}=this,r=e.element(n.x),c=e.element(n.y),l=e.element(n.z),d=e.element(n.w),o=i.mul(t),u=add(r.mul(s.x).mul(o),c.mul(s.y).mul(o),l.mul(s.z).mul(o),d.mul(s.w).mul(o));return a.mul(u).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=normalLocal){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:a}=this,r=e.element(n.x),c=e.element(n.y),l=e.element(n.z),d=e.element(n.w);let o=add(s.x.mul(r),s.y.mul(c),s.z.mul(l),s.w.mul(d));return o=a.mul(o).mul(i),o.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=referenceBuffer("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,positionPrevious)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||getDataFromObject(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&positionPrevious.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();normalLocal.assign(t),e.hasGeometryAttribute("tangent")&&tangentLocal.assign(t)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;if(_frameId.get(t)===e.frameId)return;_frameId.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update()}}skinning=e=>new SkinningNode(e);class LoopNode extends Node{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==0[0])return t;const n={};for(let e=0,o=this.params.length-1;e<o;e++){const t=this.params[e],s=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||"int";n[s]=expression(s,i)}const i=e.addStack(),s=this.params[this.params.length-1](n);t.returnsNode=s.context({nodeLoop:s}),t.stackNode=i;const o=this.params[0];if(o.isNode!==!0&&typeof o.update=="function"){const e=Fn(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){const t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){const t=this.getProperties(e),n=this.params,s=t.stackNode;for(let d=0,m=n.length-1;d<m;d++){const r=n[d];let h=!1,s=null,o=null,l=null,i=null,c=null,a=null;r.isNode?r.getNodeType(e)==="bool"?(h=!0,i="bool",o=r.build(e,i)):(i="int",l=this.getVarName(d),s="0",o=r.build(e,i),c="<"):(i=r.type||"int",l=r.name||this.getVarName(d),s=r.start,o=r.end,c=r.condition,a=r.update,typeof s=="number"?s=e.generateConst(i,s):s&&s.isNode&&(s=s.build(e,i)),typeof o=="number"?o=e.generateConst(i,o):o&&o.isNode&&(o=o.build(e,i)),s!==0[0]&&o===0[0]?(s=s+" - 1",o="0",c=">="):o!==0[0]&&s===0[0]&&(s="0",c="<"),c===0[0]&&(Number(s)>Number(o)?c=">=":c="<"));let u;if(h)u=`while ( ${o} )`;else{const d={start:s,end:o},h=d.start,m=d.end;let n;const r=()=>c.includes("<")?"+=":"-=";if(a!=null)switch(typeof a){case"function":const s=e.flowStagesNode(t.updateNode,"void"),o=s.code.replace(/\t|;/g,"");n=o;break;case"number":n=l+" "+r()+" "+e.generateConst(i,a);break;case"string":n=l+" "+a;break;default:a.isNode?n=l+" "+r()+" "+a.build(e):(error("TSL: 'Loop( { update: ... } )' is not a function, string or number."),n="break /* invalid update */")}else i==="int"||i==="uint"?a=c.includes("<")?"++":"--":a=r()+" 1.",n=l+" "+a;const f=e.getVar(i,l)+" = "+h,p=l+" "+c+" "+m;u=`for ( ${f}; ${p}; ${n} )`}e.addFlowCode((d===0?` 58`:"")+e.tab+u+` { 59 60`).addFlowTab()}const o=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(` 61`+e.tab+o);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?"":e.tab)+`} 62 63`).removeFlowTab();e.addFlowTab()}}Loop=(...e)=>new LoopNode(nodeArray(e,"int")).toStack(),Break=()=>expression("break").toStack(),_morphTextures=new WeakMap,_morphVec4=new Vector4,getMorph=Fn(({bufferMap:e,influence:t,stride:n,width:s,depth:o,offset:i})=>{const a=int(vertexIndex).mul(n).add(i),r=a.div(s),c=a.sub(r.mul(s)),l=textureLoad(e,ivec2(c,r)).depth(o).xyz;return l.mul(t)});function getEntry(e){const s=e.morphAttributes.position!==0[0],o=e.morphAttributes.normal!==0[0],i=e.morphAttributes.color!==0[0],a=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=a!==0[0]?a.length:0;let t=_morphTextures.get(e);if(t===0[0]||t.count!==n){let h=function(){d.dispose(),_morphTextures.delete(e),e.removeEventListener("dispose",h)};t!==0[0]&&t.texture.dispose();const m=e.morphAttributes.position||[],f=e.morphAttributes.normal||[],p=e.morphAttributes.color||[];let c=0;s===!0&&(c=1),o===!0&&(c=2),i===!0&&(c=3);let r=e.attributes.position.count*c,l=1;const u=4096;r>u&&(l=Math.ceil(r/u),r=u);const a=new Float32Array(r*l*4*n),d=new DataArrayTexture(a,r,l,n);d.type=FloatType,d.needsUpdate=!0;const g=c*4;for(let t=0;t<n;t++){const c=m[t],u=f[t],d=p[t],e=r*l*4*t;for(let n=0;n<c.count;n++){const t=n*g;s===!0&&(_morphVec4.fromBufferAttribute(c,n),a[e+t+0]=_morphVec4.x,a[e+t+1]=_morphVec4.y,a[e+t+2]=_morphVec4.z,a[e+t+3]=0),o===!0&&(_morphVec4.fromBufferAttribute(u,n),a[e
63+t+4]=_morphVec4.x,a[e+t+5]=_morphVec4.y,a[e+t+6]=_morphVec4.z,a[e+t+7]=0),i===!0&&(_morphVec4.fromBufferAttribute(d,n),a[e+t+8]=_morphVec4.x,a[e+t+9]=_morphVec4.y,a[e+t+10]=_morphVec4.z,a[e+t+11]=d.itemSize===4?_morphVec4.w:1)}}t={count:n,texture:d,stride:c,size:new Vector2(r,l)},_morphTextures.set(e,t),e.addEventListener("dispose",h)}return t}class MorphNode extends Node{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=uniform(1),this.updateType=NodeUpdateType.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==0[0],s=t.hasAttribute("normal")&&t.morphAttributes.normal!==0[0],o=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,c=o!==0[0]?o.length:0,{texture:i,stride:a,size:l}=getEntry(t);n===!0&&positionLocal.mulAssign(this.morphBaseInfluence),s===!0&&normalLocal.mulAssign(this.morphBaseInfluence);const r=int(l.width);Loop(c,({i:e})=>{const t=float(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==0[0]?t.assign(textureLoad(this.mesh.morphTexture,ivec2(int(e).add(1),int(instanceIndex))).r):t.assign(reference("morphTargetInfluences","float").element(e).toVar()),If(t.notEqual(0),()=>{n===!0&&positionLocal.addAssign(getMorph({bufferMap:i,influence:t,stride:a,width:r,depth:e,offset:int(0)})),s===!0&&normalLocal.addAssign(getMorph({bufferMap:i,influence:t,stride:a,width:r,depth:e,offset:int(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}morphReference=nodeProxy(MorphNode).setParameterLength(1);class LightingNode extends Node{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class AONode extends LightingNode{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class LightingContextNode extends ContextNode{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,s=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=vec3().toVar("directDiffuse"),s=vec3().toVar("directSpecular"),o=vec3().toVar("indirectDiffuse"),i=vec3().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:s,indirectDiffuse:o,indirectSpecular:i},r={radiance:vec3().toVar("radiance"),irradiance:vec3().toVar("irradiance"),iblIrradiance:vec3().toVar("iblIrradiance"),ambientOcclusion:float(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t};return r}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}lightingContext=nodeProxy(LightingContextNode);class IrradianceNode extends LightingNode{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}_size$5=new Vector2;class ViewportTextureNode extends TextureNode{static get type(){return"ViewportTextureNode"}constructor(e=screenUV,t=null,n=null){let s=null;n===null?(s=new FramebufferTexture,s.minFilter=LinearMipmapLinearFilter,n=s):s=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=NodeUpdateType.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let n,t;if(this.referenceNode?(n=this.referenceNode.defaultFramebuffer,t=this.referenceNode._cacheTextures):(n=this.defaultFramebuffer,t=this._cacheTextures),e===null)return n;if(t.has(e)===!1){const s=n.clone();t.set(e,s)}return t.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const s=e.renderer,n=s.getRenderTarget();n===null?s.getDrawingBufferSize(_size$5):_size$5.set(n.width,n.height);const t=this.getTextureForReference(n);(t.image.width!==_size$5.width||t.image.height!==_size$5.height)&&(t.image.width=_size$5.width,t.image.height=_size$5.height,t.needsUpdate=!0);const o=t.generateMipmaps;t.generateMipmaps=this.generateMipmaps,s.copyFramebufferToTexture(t),t.generateMipmaps=o}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}viewportMipTexture=nodeProxy(ViewportTextureNode,null,null,{generateMipmaps:!0}).setParameterLength(0,3),_sharedDepthbuffer=null;class ViewportDepthTextureNode extends ViewportTextureNode{static get type(){return"ViewportDepthTextureNode"}constructor(e=screenUV,t=null){_sharedDepthbuffer===null&&(_sharedDepthbuffer=new DepthTexture),super(e,t,_sharedDepthbuffer)}getTextureForReference(){return _sharedDepthbuffer}}viewportDepthTexture=nodeProxy(ViewportDepthTextureNode).setParameterLength(0,2);class ViewportDepthNode extends Node{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ViewportDepthNode.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:s}=this,n=this.valueNode;let t=null;if(s===ViewportDepthNode.DEPTH_BASE)n!==null&&(t=depthBase().assign(n));else if(s===ViewportDepthNode.DEPTH)e.isPerspectiveCamera?t=viewZToPerspectiveDepth(positionView.z,cameraNear,cameraFar):t=viewZToOrthographicDepth(positionView.z,cameraNear,cameraFar);else if(s===ViewportDepthNode.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const e=perspectiveDepthToViewZ(n,cameraNear,cameraFar);t=viewZToOrthographicDepth(e,cameraNear,cameraFar)}else t=n;else t=viewZToOrthographicDepth(positionView.z,cameraNear,cameraFar);return t}}ViewportDepthNode.DEPTH_BASE="depthBase",ViewportDepthNode.DEPTH="depth",ViewportDepthNode.LINEAR_DEPTH="linearDepth",viewZToOrthographicDepth=(e,t,n)=>e.add(t).div(t.sub(n)),viewZToPerspectiveDepth=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),perspectiveDepthToViewZ=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),viewZToLogarithmicDepth=(e,t,n)=>{t=t.max(1e-6).toVar();const s=log22(e.negate().div(t)),o=log22(n.div(t));return s.div(o)},depthBase=nodeProxy(ViewportDepthNode,ViewportDepthNode.DEPTH_BASE),depth=nodeImmutable(ViewportDepthNode,ViewportDepthNode.DEPTH),linearDepth=nodeProxy(ViewportDepthNode,ViewportDepthNode.LINEAR_DEPTH).setParameterLength(0,1),viewportLinearDepth=linearDepth(viewportDepthTexture()),depth.assign=e=>depthBase(e);class ClippingNode extends Node{static get type(){return"ClippingNode"}constructor(e=ClippingNode.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const s=e.clippingContext,{intersectionPlanes:n,unionPlanes:t}=s;return this.hardwareClipping=e.material.hardwareClipping,this.scope===ClippingNode.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,t):this.scope===ClippingNode.HARDWARE?this.setupHardwareClipping(t,e):this.setupDefault(n,t)}setupAlphaToCoverage(e,t){return Fn(()=>{const n=float().toVar("distanceToPlane"),s=float().toVar("distanceToGradient"),o=float(1).toVar("clipOpacity"),i=t.length;if(this.hardwareClipping===!1&&i>0){const e=uniformArray(t).setGroup(renderGroup);Loop(i,({i:t})=>{const i=e.element(t);n.assign(positionView.dot(i.xyz).negate().add(i.w)),s.assign(n.fwidth().div(2)),o.mulAssign(smoothstep2(s.negate(),s,n)
vendor: 4,899 bytes, line 63
63)})}const a=e.length;if(a>0){const i=uniformArray(e).setGroup(renderGroup),t=float(1).toVar("intersectionClipOpacity");Loop(a,({i:e})=>{const o=i.element(e);n.assign(positionView.dot(o.xyz).negate().add(o.w)),s.assign(n.fwidth().div(2)),t.mulAssign(smoothstep2(s.negate(),s,n).oneMinus())}),o.mulAssign(t.oneMinus())}diffuseColor.a.mulAssign(o),diffuseColor.a.equal(0).discard()})()}setupDefault(e,t){return Fn(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const e=uniformArray(t).setGroup(renderGroup);Loop(n,({i:t})=>{const n=e.element(t);positionView.dot(n.xyz).greaterThan(n.w).discard()})}const s=e.length;if(s>0){const n=uniformArray(e).setGroup(renderGroup),t=bool(!0).toVar("clipped");Loop(s,({i:e})=>{const s=n.element(e);t.assign(positionView.dot(s.xyz).greaterThan(s.w).and(t))}),t.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Fn(()=>{const s=uniformArray(e).setGroup(renderGroup),o=builtin(t.getClipDistance());Loop(n,({i:e})=>{const t=s.element(e),n=positionView.dot(t.xyz).sub(t.w).negate();o.element(e).assign(n)})})()}}ClippingNode.ALPHA_TO_COVERAGE="alphaToCoverage",ClippingNode.DEFAULT="default",ClippingNode.HARDWARE="hardware",clipping=()=>new ClippingNode,clippingAlpha=()=>new ClippingNode(ClippingNode.ALPHA_TO_COVERAGE),hardwareClipping=()=>new ClippingNode(ClippingNode.HARDWARE),ALPHA_HASH_SCALE=.05,hash2D=Fn(([e])=>fract(mul(1e4,sin(mul(17,e.x).add(mul(.1,e.y)))).mul(add(.1,abs(sin(mul(13,e.y).add(e.x))))))),hash3D=Fn(([e])=>hash2D(vec2(hash2D(e.xy),e.z))),getAlphaHashThreshold=Fn(([e])=>{const c=max$1(length(dFdx(e.xyz)),length(dFdy(e.xyz))),o=float(1).div(float(ALPHA_HASH_SCALE).mul(c)).toVar("pixScale"),a=vec2(exp2(floor(log22(o))),exp2(ceil(log22(o)))),r=vec2(hash3D(floor(a.x.mul(e.xyz))),hash3D(floor(a.y.mul(e.xyz)))),s=fract(log22(o)),n=add(mul(s.oneMinus(),r.x),mul(s,r.y)),t=min$1(s,s.oneMinus()),i=vec3(n.mul(n).div(mul(2,t).mul(sub(1,t))),n.sub(mul(.5,t)).div(sub(1,t)),sub(1,sub(1,n).mul(sub(1,n)).div(mul(2,t).mul(sub(1,t))))),l=n.lessThan(t.oneMinus()).select(n.lessThan(t).select(i.x,i.y),i.z);return clamp2(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class VertexColorNode extends AttributeNode{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const n=this.getAttributeName(e),s=e.hasGeometryAttribute(n);let t;return s===!0?t=super.generate(e):t=e.generateConst(this.nodeType,new Vector4(1,1,1,1)),t}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}vertexColor=(e=0)=>new VertexColorNode(e),premultiplyAlpha=Fn(([e])=>vec4(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"});class NodeMaterial extends Material{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,this.contextNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{warn('NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:n}of this._getNodeChildren())e.push(hashString(t.slice(0,-4)),n.getCacheKey());return this.type+hashArray(e)}build(e){this.setup(e)}setupObserver(e){return new NodeMaterialObserver(e)}setup(e){e.context.setupNormal=()=>subBuild(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const n=e.renderer,s=n.getRenderTarget();n.contextNode.isContextNode===!0?e.context={...e.context,...n.contextNode.getFlowContextData()}:error('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:error('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();
63const i=subBuild(this.setupVertex(e),"VERTEX"),a=this.vertexNode||i;e.stack.outputNode=a,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(s!==null?s.depthBuffer===!0&&this.setupDepth(e):n.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){{this.setupDiffuseColor(e),this.setupVariants(e);const a=this.setupLighting(e);o!==null&&e.stack.addToStack(o);const r=vec4(a,diffuseColor.a).max(0);t=this.setupOutput(e,r),output.assign(t);const i=this.outputNode!==null;if(i&&(t=this.outputNode),e.context.getOutput&&(t=e.context.getOutput(t,e)),s!==null){const s=n.getMRT(),e=this.mrtNode;s!==null?(i&&output.assign(t),t=s,e!==null&&(t=s.merge(e))):e!==null&&(t=e)}}}else{let n=this.fragmentNode;n.isOutputStructNode!==!0&&(n=vec4(n)),t=this.setupOutput(e,n)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:n,intersectionPlanes:s}=e.clippingContext;let t=null;if(n.length>0||s.length>0){const n=e.renderer.currentSamples;this.alphaToCoverage&&n>1?t=clippingAlpha():e.stack.addToStack(clipping())}return t}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(hardwareClipping()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:n,camera:s}=e;let t=this.depthNode;if(t===null){const e=n.getMRT();e&&e.has("depth")?t=e.get("depth"):n.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?t=viewZToLogarithmicDepth(positionView.z,cameraNear,cameraFar):t=viewZToOrthographicDepth(positionView.z,cameraNear,cameraFar))}t!==null&&depth.assign(t).toStack()}setupPositionView(){return modelViewMatrix.mul(positionLocal).xyz}setupModelViewProjection(){return cameraProjectionMatrix.mul(positionView)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),modelViewProjection}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&morphReference(t).toStack(),t.isSkinnedMesh===!0&&skinning(t).toStack(),this.displacementMap){const e=materialReference("displacementMap","texture"),t=materialReference("displacementScale","float"),n=materialReference("displacementBias","float");positionLocal.addAssign(normalLocal.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&batch(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&instancedMesh(t).toStack(),this.positionNode!==null&&positionLocal.assign(subBuild(this.positionNode,"POSITION","vec3")),positionLocal}setupDiffuseColor(e){const{object:s,geometry:o}=e;this.maskNode!==null&&bool(this.maskNode).not().discard();let t=this.colorNode?vec4(this.colorNode):materialColor;if(this.vertexColors===!0&&o.hasAttribute("color")&&(t=t.mul(vertexColor())),s.instanceColor){const e=varyingProperty("vec3","vInstanceColor");t=e.mul(t)}if(s.isBatchedMesh&&s._colorsTexture){const e=varyingProperty("vec3","vBatchColor");t=e.mul(t)}diffuseColor.assign(t);const i=this.opacityNode?float(this.opacityNode):materialOpacity;diffuseColor.a.assign(diffuseColor.a.mul(i));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode!==null?float(this.alphaTestNode):materialAlphaTest,this.alphaToCoverage===!0?(diffuseColor.a=smoothstep2(n,n.add(fwidth(diffuseColor.a)),diffuseColor.a),diffuseColor.a.lessThanEqual(0).discard()):diffuseColor.a.lessThanEqual(n).discard()),this.alphaHash===!0&&diffuseColor.a.lessThan(getAlphaHashThreshold(positionLocal)).discard(),e.isOpaque()&&diffuseColor.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?vec3(0):diffuseColor.rgb}setupNormal(){return this.normalNode?vec3(this.normalNode):materialNormal}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?materialReference("envMap","cubeTexture"):materialReference("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new IrradianceNode(materialLightMap)),t}setupLights(e){const n=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&n.push(s);const o=this.setupLightMap(e);o&&o.isLightingNode&&n.push(o);let t=this.aoNode;t===null&&e.material.aoMap&&(t=materialAO),e.context.getAO&&(t=e.context.getAO(t,e)),t&&n.push(new AONode(t));let i=this.lightsNode||e.lightsNode;return n.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...n])),i}setupLightingModel(){}setupLighting(e){const{material:a}=e,{backdropNode:n,backdropAlphaNode:o,emissiveNode:s}=this,r=this.lights===!0||this.lightsNode!==null,i=r?this.setupLights(e):null;let t=this.setupOutgoingLight(e);if(i&&i.getScope().hasLights){const s=this.setupLightingModel(e)||null;t=lightingContext(i,s,n,o)}else n!==null&&(t=vec3(o!==null?mix(t,n,o):n));return(s&&s.isNode===!0||a.emissive&&a.emissive.isColor===!0)&&(emissive.assign(vec3(s||materialEmissive)),t=t.add(emissive)),t}setupFog(e,t){const n=e.fogNode;return n&&(output.assign(t),t=vec4(n.toVar())),t}setupPremultipliedAlpha(e,t){return premultiplyAlpha(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(const t in e){const n=e[t];this[t]===0[0]&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===0[0]&&t[e].get!==0[0]&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const s=e===0[0]||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});const t=Material.prototype.toJSON.call(this,e);t.inputNodes={};for(const{property:n,childNode:s}of this._getNodeChildren())t.inputNodes[n]=s.toJSON(e).uuid;function n(e){const t=[];for(const s in e){const n=e[s];delete n.metadata,t.push(n)}return t}if(s){const s=n(e.textures),o=n(e.images),i=n(e.nodes);s.length>0&&(t.textures=s),o.length>0&&(t.images=o),i.length>0&&(t.nodes=i)}return t}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,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,this.contextNode=e.contextNode,super.copy(e)}}_defaultValues$d=new LineBasicMaterial;class LineBasicNodeMaterial extends NodeMaterial{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(_defaultValues$d),this.setValues(e)}}_defaultValues$c=new LineDashedMaterial;class LineDashedNodeMaterial extends NodeMaterial{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(_defaultValues$c),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?float(this.offsetNode):materialLineDashOffset,n=this.dashScaleNode?float(this.dashScaleNode):materialLineScale,s=this.dashSizeNode?float(this.dashSizeNode):materialLineDashSize,o=this.gapSizeNode?float(this.gapSizeNode):materialLineGapSize;dashSize.assign(s),gapSize.assign(o);const t=varying(attribute("lineDistance").mul(n)),i=e?t.add(e):t;i.mod(dashSize.add(gapSize)).greaterThan(dashSize).discard()}}_defaultValues$a=new MeshNormalMaterial;class MeshNormalNodeMaterial extends NodeMaterial{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(_defaultValues$a),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?float(this.opacityNode):materialOpacity;diffuseColor.assign(colorSpaceToWorking(vec4(directionToColor(normalView),e),SRGBColorSpace))}}equirectUV=Fn(([e=positionWorldDirection])=>{const t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return vec2(t,n)});
vendor: 4,843 bytes, line 63
63class CubeRenderTarget extends WebGLCubeRenderTarget{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const i=t.minFilter,a=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;const r=new BoxGeometry(5,5,5),c=equirectUV(positionWorldDirection),n=new NodeMaterial;n.colorNode=texture(t,c,0),n.side=BackSide,n.blending=NoBlending;const s=new Mesh(r,n),o=new Scene;o.add(s),t.minFilter===LinearMipmapLinearFilter&&(t.minFilter=LinearFilter);const l=new CubeCamera(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,o),e.setMRT(d),t.minFilter=i,t.currentGenerateMipmaps=a,s.geometry.dispose(),s.material.dispose(),this}}_cache$1=new WeakMap;class CubeMapNode extends TempNode{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=cubeTexture(null);const t=new CubeTexture;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=NodeUpdateType.RENDER}updateBefore(e){const{renderer:n,material:s}=e,t=this.envNode;if(t.isTextureNode||t.isMaterialReferenceNode){const e=t.isTextureNode?t.value:s[t.property];if(e&&e.isTexture){const t=e.mapping;if(t===EquirectangularReflectionMapping||t===EquirectangularRefractionMapping){if(_cache$1.has(e)){const t=_cache$1.get(e);mapTextureMapping(t,e.mapping),this._cubeTexture=t}else{const t=e.image;if(isEquirectangularMapReady$1(t)){const s=new CubeRenderTarget(t.height);s.fromEquirectangularTexture(n,e),mapTextureMapping(s.texture,e.mapping),this._cubeTexture=s.texture,_cache$1.set(e,s.texture),e.addEventListener("dispose",onTextureDispose)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function isEquirectangularMapReady$1(e){return e!=null&&e.height>0}function onTextureDispose(e){const t=e.target;t.removeEventListener("dispose",onTextureDispose);const n=_cache$1.get(t);n!==0[0]&&(_cache$1.delete(t),n.dispose())}function mapTextureMapping(e,t){t===EquirectangularReflectionMapping?e.mapping=CubeReflectionMapping:t===EquirectangularRefractionMapping&&(e.mapping=CubeRefractionMapping)}cubeMapNode=nodeProxy(CubeMapNode).setParameterLength(1);class BasicEnvironmentNode extends LightingNode{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cubeMapNode(this.envNode)}}class BasicLightMapNode extends LightingNode{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=float(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class LightingModel{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class BasicLightingModel extends LightingModel{constructor(){super()}indirect({context:e}){const s=e.ambientOcclusion,t=e.reflectedLight,n=e.irradianceLightMap;t.indirectDiffuse.assign(vec4(0)),n?t.indirectDiffuse.addAssign(n):t.indirectDiffuse.addAssign(vec4(1,1,1,0)),t.indirectDiffuse.mulAssign(s),t.indirectDiffuse.mulAssign(diffuseColor.rgb)}finish(e){const{material:s,context:o}=e,t=o.outgoingLight,n=e.context.environment;if(n)switch(s.combine){case MultiplyOperation:t.rgb.assign(mix(t.rgb,t.rgb.mul(n.rgb),materialSpecularStrength.mul(materialReflectivity)));break;case MixOperation:t.rgb.assign(mix(t.rgb,n.rgb,materialSpecularStrength.mul(materialReflectivity)));break;case AddOperation:t.rgb.addAssign(n.rgb.mul(materialSpecularStrength.mul(materialReflectivity)));break;default:warn("BasicLightingModel: Unsupported .combine value:",s.combine);break}}}_defaultValues$9=new MeshBasicMaterial;class MeshBasicNodeMaterial extends NodeMaterial{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_defaultValues$9),this.setValues(e)}setupNormal(){return directionToFaceDirection(normalViewGeometry)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new BasicEnvironmentNode(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new BasicLightMapNode(materialLightMap)),t}setupOutgoingLight(){return diffuseColor.rgb}setupLightingModel(){return new BasicLightingModel}}F_Schlick=Fn(({f0:e,f90:t,dotVH:n})=>{const s=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(s.oneMinus()).add(t.mul(s))}),BRDF_Lambert=Fn(e=>e.diffuseColor.mul(1/Math.PI)),G_BlinnPhong_Implicit=()=>float(.25),D_BlinnPhong=Fn(({dotNH:e})=>shininess.mul(float(.5)).add(1).mul(float(1/Math.PI)).mul(e.pow(shinine
63ss))),BRDF_BlinnPhong=Fn(({lightDirection:e})=>{const t=e.add(positionViewDirection).normalize(),n=normalView.dot(t).clamp(),s=positionViewDirection.dot(t).clamp(),o=F_Schlick({f0:specularColor,f90:1,dotVH:s}),i=G_BlinnPhong_Implicit(),a=D_BlinnPhong({dotNH:n});return o.mul(i).mul(a)});class PhongLightingModel extends BasicLightingModel{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=normalView.dot(e).clamp(),s=o.mul(t);n.directDiffuse.addAssign(s.mul(BRDF_Lambert({diffuseColor:diffuseColor.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(BRDF_BlinnPhong({lightDirection:e})).mul(materialSpecularStrength))}indirect(e){const{ambientOcclusion:n,irradiance:s,reflectedLight:t}=e.context;t.indirectDiffuse.addAssign(s.mul(BRDF_Lambert({diffuseColor}))),t.indirectDiffuse.mulAssign(n)}}_defaultValues$8=new MeshLambertMaterial;class MeshLambertNodeMaterial extends NodeMaterial{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_defaultValues$8),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new BasicEnvironmentNode(t):null}setupLightingModel(){return new PhongLightingModel(!1)}}_defaultValues$7=new MeshPhongMaterial;class MeshPhongNodeMaterial extends NodeMaterial{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(_defaultValues$7),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new BasicEnvironmentNode(t):null}setupLightingModel(){return new PhongLightingModel}setupVariants(){const e=(this.shininessNode?float(this.shininessNode):materialShininess).max(1e-4);shininess.assign(e);const t=this.specularNode||materialSpecular;specularColor.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}getGeometryRoughness=Fn(e=>{if(e.geometry.hasAttribute("normal")===!1)return float(0);const t=normalViewGeometry.dFdx().abs().max(normalViewGeometry.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),getRoughness=Fn(e=>{const{roughness:n}=e,s=getGeometryRoughness();let t=n.max(.0525);return t=t.add(s),t=t.min(1),t}),V_GGX_SmithCorrelated=Fn(({alpha:e,dotNL:t,dotNV:n})=>{const s=e.pow2(),o=t.mul(s.add(s.oneMinus().mul(n.pow2())).sqrt()),i=n.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return div(.5,o.add(i).max(EPSILON))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),V_GGX_SmithCorrelated_Anisotropic=Fn(({alphaT:e,alphaB:t,dotTV:n,dotBV:s,dotTL:o,dotBL:i,dotNV:a,dotNL:r})=>{const c=r.mul(vec3(e.mul(n),t.mul(s),a).length()),l=a.mul(vec3(e.mul(o),t.mul(i),r).length()),d=div(.5,c.add(l));return d}).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"}]}),D_GGX=Fn(({alpha:e,dotNH:t})=>{const n=e.pow2(),s=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(s.pow2()).mul(1/Math.PI)}
63).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),RECIPROCAL_PI=float(1/Math.PI),D_GGX_Anisotropic=Fn(({alphaT:e,alphaB:t,dotNH:n,dotTH:s,dotBH:o})=>{const i=e.mul(t),a=vec3(t.mul(s),e.mul(o),i.mul(n)),r=a.dot(a),c=i.div(r);return RECIPROCAL_PI.mul(i.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"}]}),BRDF_GGX=Fn(({lightDirection:e,f0:t,f90:n,roughness:s,f:o,normalView:i=normalView,USE_IRIDESCENCE:a,USE_ANISOTROPY:r})=>{const c=s.pow2(),l=e.add(positionViewDirection).normalize(),m=i.dot(e).clamp(),f=i.dot(positionViewDirection).clamp(),p=i.dot(l).clamp(),g=positionViewDirection.dot(l).clamp();let d=F_Schlick({f0:t,f90:n,dotVH:g}),u,h;if(defined(a)&&(d=iridescence.mix(d,o)),defined(r)){const t=anisotropyT.dot(e),n=anisotropyT.dot(positionViewDirection),s=anisotropyT.dot(l),o=anisotropyB.dot(e),i=anisotropyB.dot(positionViewDirection),a=anisotropyB.dot(l);u=V_GGX_SmithCorrelated_Anisotropic({alphaT,alphaB:c,dotTV:n,dotBV:i,dotTL:t,dotBL:o,dotNV:f,dotNL:m}),h=D_GGX_Anisotropic({alphaT,alphaB:c,dotNH:p,dotTH:s,dotBH:a})}else u=V_GGX_SmithCorrelated({alpha:c,dotNL:m,dotNV:f}),h=D_GGX({alpha:c,dotNH:p});return d.mul(u).mul(h)}),DATA=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,
vendor: 3,436 bytes, line 63
6314942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),lut=null,DFGLUT=Fn(({roughness:e,dotNV:t})=>{lut===null&&(lut=new DataTexture(DATA,16,16,RGFormat,HalfFloatType),lut.name="DFG_LUT",lut.minFilter=LinearFilter,lut.magFilter=LinearFilter,lut.wrapS=ClampToEdgeWrapping,lut.wrapT=ClampToEdgeWrapping,lut.generateMipmaps=!1,lut.needsUpdate=!0);const n=vec2(e,t);return texture(lut,n).rg}),BRDF_GGX_Multiscatter=Fn(({lightDirection:e,f0:t,f90:n,roughness:s,f:o,USE_IRIDESCENCE:i,USE_ANISOTROPY:a})=>{const v=BRDF_GGX({lightDirection:e,f0:t,f90:n,roughness:s,f:o,USE_IRIDESCENCE:i,USE_ANISOTROPY:a}),b=normalView.dot(e).clamp(),h=normalView.dot(positionViewDirection).clamp(),r=DFGLUT({roughness:s,dotNV:h}),c=DFGLUT({roughness:s,dotNV:b}),m=t.mul(r.x).add(n.mul(r.y)),f=t.mul(c.x).add(n.mul(c.y)),p=r.x.add(r.y),g=c.x.add(c.y),d=float(1).sub(p),u=float(1).sub(g),l=t.add(t.oneMinus().mul(.047619)),j=m.mul(f).mul(l).div(float(1).sub(d.mul(u).mul(l).mul(l)).add(EPSILON)),y=d.mul(u),_=j.mul(y);return v.add(_)}),EnvironmentBRDF=Fn(e=>{const{dotNV:n,specularColor:s,specularF90:o,roughness:i}=e,t=DFGLUT({dotNV:n,roughness:i});return s.mul(t.x).add(o.mul(t.y))}),Schlick_to_F0=Fn(({f:e,f90:t,dotVH:n})=>{const s=n.oneMinus().saturate(),o=s.mul(s),i=s.mul(o,o).clamp(0,.9999);return e.sub(vec3(t).mul(i)).div(i.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),D_Charlie=Fn(({roughness:e,dotNH:t})=>{const s=e.pow2(),n=float(1).div(s),o=t.pow2(),i=o.oneMinus().max(.0078125);return float(2).add(n).mul(i.pow(n.mul(.5))).div(2*Math.PI)}
vendor: 4,544 bytes, line 63
63).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),V_Neubelt=Fn(({dotNV:e,dotNL:t})=>float(1).div(float(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),BRDF_Sheen=Fn(({lightDirection:e})=>{const t=e.add(positionViewDirection).normalize(),n=normalView.dot(e).clamp(),s=normalView.dot(positionViewDirection).clamp(),o=normalView.dot(t).clamp(),i=D_Charlie({roughness:sheenRoughness,dotNH:o}),a=V_Neubelt({dotNV:s,dotNL:n});return sheen.mul(i).mul(a)}),LTC_Uv=Fn(({N:e,V:t,roughness:n})=>{const s=64,i=(s-1)/s,a=.5/s,r=e.dot(t).saturate(),o=vec2(n,r.oneMinus().sqrt());return o.assign(o.mul(i).add(a)),o}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),LTC_ClippedSphereFormFactor=Fn(({f:e})=>{const t=e.length();return max$1(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),LTC_EdgeVectorFormFactor=Fn(({v1:e,v2:t})=>{const n=e.dot(t),s=n.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),a=s.add(4.1616724).mul(s).add(3.417594).toVar(),o=i.div(a),r=n.greaterThan(0).select(o,max$1(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(r)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),LTC_Evaluate=Fn(({N:e,V:t,P:n,mInv:s,p0:o,p1:i,p2:a,p3:r})=>{const l=i.sub(o).toVar(),d=r.sub(o).toVar(),u=l.cross(d),c=vec3().toVar();return If(u.dot(n.sub(o)).greaterThanEqual(0),()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),g=e.cross(u).negate(),d=s.mul(mat3(u,g,e).transpose()).toVar(),h=d.mul(o.sub(n)).normalize().toVar(),m=d.mul(i.sub(n)).normalize().toVar(),f=d.mul(a.sub(n)).normalize().toVar(),p=d.mul(r.sub(n)).normalize().toVar(),l=vec3(0).toVar();l.addAssign(LTC_EdgeVectorFormFactor({v1:h,v2:m})),l.addAssign(LTC_EdgeVectorFormFactor({v1:m,v2:f})),l.addAssign(LTC_EdgeVectorFormFactor({v1:f,v2:p})),l.addAssign(LTC_EdgeVectorFormFactor({v1:p,v2:h})),c.assign(vec3(LTC_ClippedSphereFormFactor({f:l})))}),c}).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"}]}),bC=1/6,w0=e=>mul(bC,mul(e,mul(e,e.negate().add(3)).sub(3)).add(1)),w1=e=>mul(bC,mul(e,mul(e,mul(3,e).sub(6))).add(4)),w2=e=>mul(bC,mul(e,mul(e,mul(-3,e).add(3)).add(3)).add(1)),w3=e=>mul(bC,pow(e,3)),g0=e=>w0(e).add(w1(e)),g1=e=>w2(e).add(w3(e)),h0=e=>add(-1,w1(e).div(w0(e).add(w1(e)))),h1=e=>add(1,w3(e).div(w2(e).add(w3(e)))),bicubic=(e,t,n)=>{const h=e.uvNode,u=mul(h,t.zw).add(.5),s=floor(u),o=fract(u),r=g0(o.x),c=g1(o.x),l=h0(o.x),d=h1(o.x),i=h0(o.y),a=h1(o.y),m=vec2(s.x.add(l),s.y.add(i)).sub(.5).mul(t.xy),f=vec2(s.x.add(d),s.y.add(i)).sub(.5).mul(t.xy),p=vec2(s.x.add(l),s.y.add(a)).sub(.5).mul(t.xy),g=vec2(s.x.add(d),s.y.add(a)).sub(.5).mul(t.xy),v=g0(o.y).mul(add(r.mul(e.sample(m).level(n)),c.mul(e.sample(f).level(n)))),b=g1(o.y).mul(add(r.mul(e.sample(p).level(n)),c.mul(e.sample(g).level(n))));return v.add(b)},textureBicubicLevel=Fn(([e,t])=>{const n=vec2(e.size(int(t))),s=vec2(e.size(int(t.add(1)))),o=div(1,n),i=div(1,s),a=bicubic(e,vec4(o,n),floor(t)),r=bicubic(e,vec4(i,s),ceil(t));return fract(t).mix(a,r)}),getVolumeTransmissionRay=Fn(([e,t,n,s,o])=>{const i=vec3(refract(t.negate(),normalize2(e),div(1,s))),a=vec3(length(o[0].xyz),length(o[1].xyz),length(o[2].xyz));return normalize2(i).mul(n.mul(a))}).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"}]}),applyIorToRoughness=Fn(([e,t])=>e.mul(clamp2(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),viewportBackSideTexture=viewportMipTexture(),viewportFrontSideTexture=viewportMipTexture(),getTransmissionSample=Fn(([e,t,n],{material:s})=>{const o=s.side===BackSide?viewportBackSideTexture:viewportFrontSideTexture,i=o.sample(e),a=log22(screenSize.x).mul(applyIorToRoughness(t,n));return textureBicubicLevel(i,a)}),volumeAttenuation=Fn(([e,t,n])=>(If(n.notEqual(0),()=>{const s=log2(t).negate().div(n),o=exp(s.negate().mul(e));return o}
vendor: 12,219 bytes, line 63
63),vec3(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),getIBLVolumeRefraction=Fn(([e,t,n,s,o,i,a,r,c,l,d,u,h,m,f])=>{let p,g;if(f){p=vec4().toVar(),g=vec3().toVar();const o=d.sub(1).mul(f.mul(.025)),i=vec3(d.sub(o),d,d.add(o));Loop({start:0,end:3},({i:o})=>{const f=i.element(o),v=getVolumeTransmissionRay(e,t,u,f,r),y=a.add(v),b=l.mul(c.mul(vec4(y,1))),d=vec2(b.xy.div(b.w)).toVar();d.addAssign(1),d.divAssign(2),d.assign(vec2(d.x,d.y.oneMinus()));const j=getTransmissionSample(d,n,f);p.element(o).assign(j.element(o)),p.a.addAssign(j.a),g.element(o).assign(s.element(o).mul(volumeAttenuation(length(v),h,m).element(o)))}),p.a.divAssign(3)}else{const i=getVolumeTransmissionRay(e,t,u,d,r),v=a.add(i),f=l.mul(c.mul(vec4(v,1))),o=vec2(f.xy.div(f.w)).toVar();o.addAssign(1),o.divAssign(2),o.assign(vec2(o.x,o.y.oneMinus())),p=getTransmissionSample(o,n,d),g=s.mul(volumeAttenuation(length(i),h,m))}const v=g.rgb.mul(p.rgb),b=e.dot(t).clamp(),j=vec3(EnvironmentBRDF({dotNV:b,specularColor:o,specularF90:i,roughness:n})),y=g.r.add(g.g,g.b).div(3);return vec4(j.oneMinus().mul(v),p.a.oneMinus().mul(y).oneMinus())}),XYZ_TO_REC709=mat3(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Fresnel0ToIor=e=>{const t=e.sqrt();return vec3(1).add(t).div(vec3(1).sub(t))},IorToFresnel0=(e,t)=>e.sub(t).div(e.add(t)).pow2(),evalSensitivity=(e,t)=>{const s=e.mul(2*Math.PI*1e-9),i=vec3(54856e-17,44201e-17,52481e-17),a=vec3(1681e3,1795300,2208400),o=vec3(43278e5,93046e5,66121e5),r=float(9747e-17*(2*Math.PI*45282e5)**.5).mul(s.mul(2239900).add(t.x).cos()).mul(s.pow2().mul(-45282e5).exp());let n=i.mul(o.mul(2*Math.PI).sqrt()).mul(a.mul(s).add(t).cos()).mul(s.pow2().negate().mul(o).exp());n=vec3(n.x.add(r),n.y,n.z).div(.10685e-6);const c=XYZ_TO_REC709.mul(n);return c},evalIridescence=Fn(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:s,baseF0:o})=>{const i=mix(e,t,smoothstep2(0,.03,s)),y=e.div(i).pow2().mul(n.pow2().oneMinus()),f=y.oneMinus();If(f.lessThan(0),()=>vec3(1));const d=f.sqrt(),v=IorToFresnel0(i,e),r=F_Schlick({f0:v,f90:1,dotVH:n}),u=r.oneMinus(),C=i.lessThan(e).select(Math.PI,0),x=float(Math.PI).sub(C),a=Fresnel0ToIor(o.clamp(0,.9999)),w=IorToFresnel0(a,i.toVec3()),l=F_Schlick({f0:w,f90:1,dotVH:d}),g=vec3(a.x.lessThan(i).select(Math.PI,0),a.y.lessThan(i).select(Math.PI,0),a.z.lessThan(i).select(Math.PI,0)),b=i.mul(s,d,2),j=vec3(x).add(g),c=r.mul(l).clamp(1e-5,.9999),_=c.sqrt(),p=u.pow2().mul(l).div(vec3(1).sub(c)),O=r.add(p),m=O.toVar(),h=p.sub(u).toVar();return Loop({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{h.mulAssign(_);const t=evalSensitivity(float(e).mul(b),float(e).mul(j)).mul(2);m.addAssign(h.mul(t))}),m.max(vec3(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"}]}),IBLSheenBRDF=Fn(({normal:e,viewDir:t,roughness:n})=>{const i=e.dot(t).saturate(),s=n.mul(n),o=n.add(.1).reciprocal(),a=float(-1.9362).add(n.mul(1.0678)).add(s.mul(.4573)).sub(o.mul(.8469)),r=float(-.6014).add(n.mul(.5538)).sub(s.mul(.467)).sub(o.mul(.1255)),c=a.mul(i).add(r).exp();return c.saturate()}),clearcoatF0=vec3(.04),clearcoatF90=float(1);class PhysicalLightingModel extends LightingModel{constructor(e=!1,t=!1,n=!1,s=!1,o=!1,i=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=s,this.transmission=o,this.dispersion=i,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=vec3().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=vec3().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=vec3().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=vec3().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=vec3().toVar("sheenSpecularIndirect")),this.iridescence===!0){const e=normalView.dot(positionViewDirection).clamp(),t=evalIridescence({outsideIOR:float(1),eta2:iridescenceIOR,cosTheta1:e,thinFilmThickness:iridescenceThickness,baseF0:specularColor}),n=evalIridescence({outsideIOR:float(1),eta2:iridescenceIOR,cosTheta1:e,thinFilmThickness:iridescenceThickness,baseF0:diffuseColor.rgb});this.iridescenceFresnel=mix(t,n,metalness),this.iridescenceF0Dielectric=Schlick_to_F0({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=Schlick_to_F0({f:n,f90:1,dotVH:e}),this.iridescenceF0=mix(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,metalness)}if(this.transmission===!0){const n=positionWorld,s=cameraPosition.sub(positionWorld).normalize(),o=normalWorld,t=e.context;t.backdrop=getIBLVolumeRefraction(o,s,roughness,diffuseContribution,specularColorBlended,specularF90,n,modelWorldMatrix,cameraViewMatrix,cameraProjectionMatrix,ior,thickness,attenuationColor,attenuationDistance,this.dispersion?dispersion:null),t.backdropAlpha=transmission,diffuseColor.a.mulAssign(mix(1,t.backdrop.a,transmission))}super.start(e)}computeMultiscattering(e,t,n,s,o=null){const d=normalView.dot(positionViewDirection).clamp(),i=DFGLUT({roughness,dotNV:d}),a=o?iridescence.mix(s,o):s,r=a.mul(i.x).add(n.mul(i.y)),u=i.x.add(i.y),c=u.oneMinus(),l=a.add(a.oneMinus().mul(.047619)),h=r.mul(l).div(c.mul(l).oneMinus());e.addAssign(r),t.addAssign(h.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=normalView.dot(e).clamp(),s=o.mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(s.mul(BRDF_Sheen({lightDirection:e})));const t=IBLSheenBRDF({normal:normalView,viewDir:positionViewDirection,roughness:sheenRoughness}),n=IBLSheenBRDF({normal:normalView,viewDir:e,roughness:sheenRoughness}),o=sheen.r.max(sheen.g).max(sheen.b).mul(t.max(n)).oneMinus();s.mulAssign(o)}if(this.clearcoat===!0){const n=clearcoatNormalView.dot(e).clamp(),s=n.mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(BRDF_GGX({lightDirection:e,f0:clearcoatF0,f90:clearcoatF90,roughness:clearcoatRoughness,normalView:clearcoatNormalView})))}n.directDiffuse.addAssign(s.mul(BRDF_Lambert({diffuseColor:diffuseContribution}))),n.directSpecular.addAssign(s.mul(BRDF_GGX_Multiscatter({lightDirection:e,f0:specularColorBlended,f90:1,roughness,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:s,reflectedLight:o,ltc_1:i,ltc_2:a}){const d=t.add(n).sub(s),u=t.sub(n).sub(s),h=t.sub(n).add(s),m=t.add(n).add(s),c=normalView,l=positionViewDirection,f=positionView.toVar(),p=LTC_Uv({N:c,V:l,roughness}),r=i.sample(p).toVar(),g=a.sample(p).toVar(),v=mat3(vec3(r.x,0,r.y),vec3(0,1,0),vec3(r.z,0,r.w)).toVar(),b=specularColorBlended.mul(g.x).add(specularColorBlended.oneMinus().mul(g.y)).toVar();o.directSpecular.addAssign(e.mul(b).mul(LTC_Evaluate({N:c,V:l,P:f,mInv:v,p0:d,p1:u,p2:h,p3:m}))),o.directDiffuse.addAssign(e.mul(diffuseContribution).mul(LTC_Evaluate({N:c,V:l,P:f,mInv:mat3(1,0,0,0,1,0,0,0,1),p0:d,p1:u,p2:h,p3:m})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:n,reflectedLight:s}=e.context,t=n.mul(BRDF_Lambert({diffuseColor:diffuseContribution})).toVar();if(this.sheen===!0){const e=IBLSheenBRDF({normal:normalView,viewDir:positionViewDirection,roughness:sheenRoughness}),n=sheen.r.max(sheen.g).max(sheen.b).mul(e).oneMinus();t.mulAssign(n)}s.indirectDiffuse.addAssign(t)}indirectSpecular(e){const{radiance:d,iblIrradiance:i,reflectedLight:o}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(i.mul(sheen,IBLSheenBRDF({normal:normalView,viewDir:positionViewDirection,roughness:sheenRoughness}))),this.clearcoat===!0){const e=clearcoatNormalView.dot(positionViewDirection).clamp(),t=EnvironmentBRDF({dotNV:e,specularColor:clearcoatF0,specularF90:clearcoatF90,roughness:clearcoatRoughness});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const t=vec3().toVar("singleScatteringDielectric"),n=vec3().toVar("multiScatteringDielectric"),a=vec3().toVar("singleScatteringMetallic"),s=vec3().toVar("multiScatteringMetallic");this.computeMultiscattering(t,n,specularF90,specularColor,this.iridescenceF0Dielectric),this.computeMultiscattering(a,s,specularF90,diffuseColor.rgb,this.iridescenceF0Metallic);const u=mix(t,a,metalness),h=mix(n,s,metalness),m=t.add(n),f=diffuseContribution.mul(m.oneMinus()),r=i.mul(1/Math.PI),c=d.mul(u).add(h.mul(r)).toVar(),l=f.mul(r).toVar();if(this.sheen===!0){const t=IBLSheenBRDF({normal:normalView,viewDir:positionViewDirection,roughness:sheenRoughness}),e=sheen.r.max(sheen.g).max(sheen.b).mul(t).oneMinus();c.mulAssign(e),l.mulAssign(e)}o.indirectSpecular.addAssign(c),o.indirectDiffuse.addAssign(l)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,s=normalView.dot(positionViewDirection).clamp(),o=s.add(t),i=roughness.mul(-16).oneMinus().negate().exp2(),a=t.sub(o.pow(i).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}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const e=clearcoatNormalView.dot(positionViewDirection).clamp(),n=F_Schlick({dotVH:e,f0:clearcoatF0,f90:clearcoatF90}),s=t.mul(clearcoat.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(clearcoat));t.assign(s)}if(this.sheen===!0){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}cubeUV_r0=float(1),cubeUV_m0=float(-2),cubeUV_r1=float(.8),cubeUV_m1=float(-1),cubeUV_r4=float(.4),cubeUV_m4=float(2),cubeUV_r5=float(.305),cubeUV_m5=float(3),cubeUV_r6=float(.21),cubeUV_m6=float(4),cubeUV_minMipLevel=float(4),cubeUV_minTileSize=float(16),getFace=Fn(([e])=>{const t=vec3(abs(e)).toVar(),n=float(-1).toVar();return If(t.x.greaterThan(t.z),()=>{If(t.x.greaterThan(t.y),()=>{n.assign(select(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(select(e.y.greaterThan(0),1,4))})}).Else(()=>{If(t.z.greaterThan(t.y),()=>{n.assign(select(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(select(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),getUV=Fn(([e,t])=>{const n=vec2().toVar();return If(t.equal(0),()=>{n.assign(vec2(e.z,e.y).div(abs(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(vec2(e.x.negate(),e.z.negate()).div(abs(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(vec2(e.x.negate(),e.y).div(abs(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(vec2(e.z.negate(),e.y).div(abs(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(vec2(e.x.negate(),e.z).div(abs(e.y)))}).Else(()=>{n.assign(vec2(e.x,e.y).div(abs(e.z)))}),mul(.5,n.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),roughnessToMip=Fn(([e])=>{const t=float(0).toVar();return If(e.greaterThanEqual(cubeUV_r1),()=>{t.assign(cubeUV_r0.sub(e).mul(cubeUV_m1.sub(cubeUV_m0)).div(cubeUV_r0.sub(cubeUV_r1)).add(cubeUV_m0))}).ElseIf(e.greaterThanEqual(cubeUV_r4),()=>{t.assign(cubeUV_r1.sub(e).mul(cubeUV_m4.sub(cubeUV_m1)).div(cubeUV_r1.sub(cubeUV_r4)).add(cubeUV_m1))}).ElseIf(e.greaterThanEqual(cubeUV_r5),()=>{t.assign(cubeUV_r4.sub(e).mul(cubeUV_m5.sub(cubeUV_m4)).div(cubeUV_r4.sub(cubeUV_r5)).add(cubeUV_m4))}).ElseIf(e.greaterThanEqual(cubeUV_r6),()=>{t.assign(cubeUV_r5.sub(e).mul(cubeUV_m6.sub(cubeUV_m5)).div(cubeUV_r5.sub(cubeUV_r6)).add(cubeUV_m5))}).Else(()=>{t.assign(float(-2).mul(log22(mul(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),getDirection=Fn(([e,t])=>{const s=e.toVar();s.assign(mul(2,s).sub(1));const n=vec3(s,1).toVar();return If(t.equal(0),()=>{n.assign(n.zyx)}).ElseIf(t.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{n.x.mulAssign(-1)}
vendor: 4,454 bytes, line 63
63).ElseIf(t.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),textureCubeUV=Fn(([e,t,n,s,o,i])=>{const u=float(n),r=vec3(t),c=clamp2(roughnessToMip(u),cubeUV_m0,i),l=fract(c),d=floor(c),a=vec3(bilinearCubeUV(e,r,d,s,o,i)).toVar();return If(l.notEqual(0),()=>{const t=vec3(bilinearCubeUV(e,r,d.add(1),s,o,i)).toVar();a.assign(mix(a,t,l))}),a}),bilinearCubeUV=Fn(([e,t,n,s,o,i])=>{const r=float(n).toVar(),d=vec3(t),c=float(getFace(d)).toVar(),u=float(max$1(cubeUV_minMipLevel.sub(r),0)).toVar();r.assign(max$1(r,cubeUV_minMipLevel));const l=float(exp2(r)).toVar(),a=vec2(getUV(d,c).mul(l.sub(2)).add(1)).toVar();return If(c.greaterThan(2),()=>{a.y.addAssign(l),c.subAssign(3)}),a.x.addAssign(c.mul(l)),a.x.addAssign(u.mul(mul(3,cubeUV_minTileSize))),a.y.addAssign(mul(4,exp2(i).sub(l))),a.x.mulAssign(s),a.y.mulAssign(o),e.sample(a).grad(vec2(),vec2())}),getSample=Fn(({envMap:e,mipInt:t,outputDirection:n,theta:s,axis:o,CUBEUV_TEXEL_WIDTH:i,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:r})=>{const c=cos(s),l=n.mul(c).add(o.cross(n).mul(sin(s))).add(o.mul(o.dot(n).mul(c.oneMinus())));return bilinearCubeUV(e,l,t,i,a,r)}),blur=Fn(({n:e,latitudinal:t,poleAxis:n,outputDirection:s,weights:o,samples:i,dTheta:a,mipInt:r,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:u})=>{const h=vec3(select(t,n,cross(n,s))).toVar();If(h.equal(vec3(0)),()=>{h.assign(vec3(s.z,0,s.x.negate()))}),h.assign(normalize2(h));const m=vec3().toVar();return m.addAssign(o.element(0).mul(getSample({theta:0,axis:h,outputDirection:s,mipInt:r,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:u}))),Loop({start:int(1),end:e},({i:e})=>{If(e.greaterThanEqual(i),()=>{Break()});const t=float(a.mul(float(e))).toVar();m.addAssign(o.element(e).mul(getSample({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:r,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:u}))),m.addAssign(o.element(e).mul(getSample({theta:t,axis:h,outputDirection:s,mipInt:r,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:u})))}),vec4(m,1)}),radicalInverse_VdC=Fn(([e])=>{const t=uint(e).toVar();return t.assign(t.shiftLeft(uint(16)).bitOr(t.shiftRight(uint(16)))),t.assign(t.bitAnd(uint(1431655765)).shiftLeft(uint(1)).bitOr(t.bitAnd(uint(2863311530)).shiftRight(uint(1)))),t.assign(t.bitAnd(uint(858993459)).shiftLeft(uint(2)).bitOr(t.bitAnd(uint(3435973836)).shiftRight(uint(2)))),t.assign(t.bitAnd(uint(252645135)).shiftLeft(uint(4)).bitOr(t.bitAnd(uint(4042322160)).shiftRight(uint(4)))),t.assign(t.bitAnd(uint(16711935)).shiftLeft(uint(8)).bitOr(t.bitAnd(uint(4278255360)).shiftRight(uint(8)))),float(t).mul(.23283064365386963e-9)}),hammersley=Fn(([e,t])=>vec2(float(e).div(float(t)),radicalInverse_VdC(e))),importanceSampleGGX_VNDF=Fn(([e,t,n])=>{const r=vec3(t).toVar(),l=float(n),a=l.mul(l).toVar(),s=normalize2(vec3(a.mul(r.x),a.mul(r.y),r.z)).toVar(),d=s.x.mul(s.x).add(s.y.mul(s.y)),u=select(d.greaterThan(0),vec3(s.y.negate(),s.x,0).div(sqrt(d)),vec3(1,0,0)).toVar(),p=cross(s,u).toVar(),h=sqrt(e.x),m=mul(2,3.14159265359).mul(e.y),o=h.mul(cos(m)).toVar(),i=h.mul(sin(m)).toVar(),f=mul(.5,s.z.add(1));i.assign(f.oneMinus().mul(sqrt(o.mul(o).oneMinus())).add(f.mul(i)));const c=u.mul(o).add(p.mul(i)).add(s.mul(sqrt(max$1(0,o.mul(o).add(i.mul(i)).oneMinus()))));return normalize2(vec3(a.mul(c.x),a.mul(c.y),max$1(0,c.z)))}),ggxConvolution=Fn(({roughness:e,mipInt:t,envMap:n,N_immutable:s,GGX_SAMPLES:o,CUBEUV_TEXEL_WIDTH:i,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:r})=>{const c=vec3(s).toVar(),l=vec3(0).toVar(),d=float(0).toVar();return If(e.lessThan(.001),()=>{l.assign(bilinearCubeUV(n,c,t,i,a,r))}).Else(()=>{const u=select(abs(c.z).lessThan(.999),vec3(0,0,1),vec3(1,0,0)),s=normalize2(cross(u,c)).toVar(),h=cross(c,s).toVar();Loop({start:uint(0),end:o},({i:u})=>{const v=hammersley(u,o),m=importanceSampleGGX_VNDF(v,vec3(0,0,1),e),p=normalize2(s.mul(m.x).add(h.mul(m.y)).add(c.mul(m.z))),g=normalize2(p.mul(dot(c,p).mul(2)).sub(c)),f=max$1(dot(c,g),0);If(f.greaterThan(0),()=>{const e=bilinearCubeUV(n,g,t,i,a,r);l.addAssign(e.mul(f)),d.addAssign(f)})}),If(d.greaterThan(0),()=>{l.assign(l.div(d))})}),vec4(l,1)}),LOD_MIN=4,EXTRA_LOD_SIGMA=[.125,.215,.35,.446,.526,.582],MAX_SAMPLES=20,GGX_SAMPLES=512,_flatCamera=new Orthogra
63phicCamera(-1,1,1,-1,0,1),_cubeCamera=new PerspectiveCamera(90,1),_clearColor$2=new Color,_oldTarget=null,_oldActiveCubeFace=0,_oldActiveMipmapLevel=0,_origin=new Vector3,_uniformsMap=new WeakMap,_faceLib=[3,1,5,0,4,2],_direction=getDirection(uv$1(),attribute("faceIndex")).normalize(),_outputDirection=vec3(_direction.x,_direction.y,_direction.z);class PMREMGenerator{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,s=100,o={}){const{size:r=256,position:c=_origin,renderTarget:a=null}=o;if(this._setSize(r),this._hasInitialized===!1){warn('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const i=a||this._allocateTarget();return o.renderTarget=i,this.fromSceneAsync(e,t,n,s,o),i}_oldTarget=this._renderer.getRenderTarget(),_oldActiveCubeFace=this._renderer.getActiveCubeFace(),_oldActiveMipmapLevel=this._renderer.getActiveMipmapLevel();const i=a||this._allocateTarget();return i.depthBuffer=!0,this._init(i),this._sceneToCubeUV(e,n,s,i,c),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}async fromSceneAsync(e,t=0,n=.1,s=100,o={}){return warnOnce('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,n,s,o)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){warn('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return warnOnce('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){warn("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return warnOnce('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=_getCubemapMaterial(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_getEquirectMaterial(),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===CubeReflectionMapping||e.mapping===CubeRefractionMapping?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=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(_oldTarget,_oldActiveCubeFace,_oldActiveMipmapLevel),e.scissorTest=!1,_setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),_oldTarget=this._renderer.getRenderTarget(),_oldActiveCubeFace=this._renderer.getActiveCubeFace(),_oldActiveMipmapLevel=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){const e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=_createRenderTarget(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_createRenderTarget(e.width,e.height);const{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=_createPlanes(t),this._blurMaterial=_getBlurShader(t,e.width,e.height),this._ggxMaterial=_getGGXShader(t,e.width,e.height))}}async _compileMaterial(e){const t=new Mesh(new BufferGeometry,e);await this._renderer.compile(t,_flatCamera)}_sceneToCubeUV(e,t,n,s,o){const i=_cubeCamera;i.near=t,i.far=n;const c=[1,1,1,1,-1,1],l=[1,-1,1,-1,1,-1],a=this._renderer,m=a.autoClear;a.getClearColor(_clearColor$2),a.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new Mesh(new BoxGeometry,new MeshBasicMaterial({name:"PMREM.Backgroun
63d",side:BackSide,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,h=u.material;let d=!1;const r=e.background;r?r.isColor&&(h.color.copy(r),e.background=null,d=!0):(h.color.copy(_clearColor$2),d=!0),a.setRenderTarget(s),a.clear(),d&&a.render(u,i);for(let t=0;t<6;t++){const r=t%3;r===0?(i.up.set(0,c[t],0),i.position.set(o.x,o.y,o.z),i.lookAt(o.x+l[t],o.y,o.z)):r===1?(i.up.set(0,0,c[t]),i.position.set(o.x,o.y,o.z),i.lookAt(o.x,o.y+l[t],o.z)):(i.up.set(0,c[t],0),i.position.set(o.x,o.y,o.z),i.lookAt(o.x,o.y,o.z+l[t]));const n=this._cubeSize;_setViewport(s,r*n,t>2?n:0,n,n),a.render(e,i)}a.autoClear=m,e.background=r}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===CubeReflectionMapping||e.mapping===CubeRefractionMapping;s?this._cubemapMaterial===null&&(this._cubemapMaterial=_getCubemapMaterial(e)):this._equirectMaterial===null&&(this._equirectMaterial=_getEquirectMaterial(e));const o=s?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const i=this._lodMeshes[0];i.material=o;const a=this._cubeSize;_setViewport(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(i,_flatCamera)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let t=1;t<s;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,i=this._pingPongRenderTarget,u=this._ggxMaterial,c=this._lodMeshes[n];c.material=u;const o=_uniformsMap.get(u),l=n/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),g=(l*l-d*d)**.5,f=0+l*1.25,p=g*f,{_lodMax:a}=this,s=this._sizeLods[n],h=3*s*(n>a-LOD_MIN?n-a+LOD_MIN:0),m=4*(this._cubeSize-s);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=p,o.mipInt.value=a-t,_setViewport(i,h,m,3*s,2*s),r.setRenderTarget(i),r.render(c,_flatCamera),i.texture.frame=(i.texture.frame||0)+1,o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=a-n,_setViewport(e,h,m,3*s,2*s),r.setRenderTarget(e),r.render(c,_flatCamera)}_blur(e,t,n,s,o){const i=this._pingPongRenderTarget;this._halfBlur(e,i,t,n,s,"latitudinal",o),this._halfBlur(i,e,n,n,s,"longitudinal",o)}_halfBlur(e,t,n,s,o,i,a){const g=this._renderer,v=this._blurMaterial;i!=="latitudinal"&&i!=="longitudinal"&&error("blur direction must be either latitudinal or longitudinal!");const j=3,m=this._lodMeshes[s];m.material=v;const r=_uniformsMap.get(v),b=this._sizeLods[n]-1,p=isFinite(o)?Math.PI/(2*b):2*Math.PI/(2*MAX_SAMPLES-1),f=o/p,l=isFinite(o)?1+Math.floor(j*f):MAX_SAMPLES;l>MAX_SAMPLES&&warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${l} samples when the maximum is set to ${MAX_SAMPLES}`);const c=[];let h=0;for(let e=0;e<MAX_SAMPLES;++e){const n=e/f,t=Math.exp(-n*n/2);c.push(t),e===0?h+=t:e<l&&(h+=2*t)}for(let e=0;e<c.length;e++)c[e]=c[e]/h;e.texture.frame=(e.texture.frame||0)+1,r.envMap.value=e.texture,r.samples.value=l,r.weights.array=c,r.latitudinal.value=i==="latitudinal"?1:0,a&&(r.poleAxis.value=a);const{_lodMax:u}=this;r.dTheta.value=p,r.mipInt.value=u-n;const d=this._sizeLods[s],y=3*d*(s>u-LOD_MIN?s-u+LOD_MIN:0),_=4*(this._cubeSize-d);_setViewport(t,y,_,3*d,2*d),g.setRenderTarget(t),g.render(m,_flatCamera)}}function _createPlanes(e){const n=[],s=[],o=[];let t=e;const i=e-LOD_MIN+1+EXTRA_LOD_SIGMA.length;for(let l=0;l<i;l++){const m=2**t;n.push(m);let g=1/m;l>e-LOD_MIN?g=EXTRA_LOD_SIGMA[l-e+LOD_MIN-1]:l===0&&(g=0),s.push(g);const v=1/(m-2),r=-v,c=1+v,_=[r,r,c,r,c,c,r,r,c,c,r,c],u=6,a=6,h=3,f=2,p=1,b=new Float32Array(h*a*u),j=new Float32Array(f*a*u),y=new Float32Array(p*a*u);for(let s=0;s<u;s++){const t=s%3*2/3-1,n=s>2?0:-1,o=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],e=_faceLib[s];b.set(o,h*a*e),j.set(_,f*a*e);const i=[e,e,e,e,e,e];y.set(i,p*a*e)}const d=new BufferGeometry;d.setAttribute("position",new BufferAttribute(b,h)),d.setAttribute("uv",new BufferAttribute(j,f)),d.setAttribute("faceIndex",new BufferAttribute(y,p)),o.push(new Mesh(d,null)),t>LOD_MIN&&t--}return{lodMeshes:o,sizeLods:n,sigmas:s}}function _createRenderTarget(e,t){const s={magFilter:LinearFilter,minFilter:LinearFilter,generateMipmaps:!1,type:HalfFloatType,format:RGBAFormat,colorSpace:LinearSRGBColorSpace},n=new RenderTarget(e,t,s);return n.texture.mapping=CubeUVReflectionMapping,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function _setViewport(e,t,n,s,o){e.viewport.set(t,n,s,o),e.scissor.set(t,n,s,o)}
63function _getMaterial(e){const t=new NodeMaterial;return t.depthTest=!1,t.depthWrite=!1,t.blending=NoBlending,t.name=`PMREM_${e}`,t}function _getBlurShader(e,t,n){const l=uniformArray(new Array(MAX_SAMPLES).fill(0)),p=uniform(new Vector3(0,1,0)),f=uniform(0),r=float(MAX_SAMPLES),o=uniform(0),c=uniform(1),a=texture(),d=uniform(0),u=float(1/t),h=float(1/n),m=float(e),i={n:r,latitudinal:o,weights:l,poleAxis:p,outputDirection:_outputDirection,dTheta:f,samples:c,envMap:a,mipInt:d,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:m},s=_getMaterial("blur");return s.fragmentNode=blur({...i,latitudinal:o.equal(1)}),_uniformsMap.set(s,i),s}function _getGGXShader(e,t,n){const i=texture(),a=uniform(0),r=uniform(0),c=float(1/t),l=float(1/n),d=float(e),o={envMap:i,roughness:a,mipInt:r,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:l,CUBEUV_MAX_MIP:d},s=_getMaterial("ggx");return s.fragmentNode=ggxConvolution({...o,N_immutable:_outputDirection,GGX_SAMPLES:uint(GGX_SAMPLES)}),_uniformsMap.set(s,o),s}function _getCubemapMaterial(e){const t=_getMaterial("cubemap");return t.fragmentNode=cubeTexture(e,_outputDirection),t}function _getEquirectMaterial(e){const t=_getMaterial("equirect");return t.fragmentNode=texture(e,equirectUV(_outputDirection),0),t}_cache2=new WeakMap;function _generateCubeUVSize(e){const t=Math.log2(e)-2,n=1/e,s=1/(3*Math.max(2**t,7*16));return{texelWidth:s,texelHeight:n,maxMip:t}}function _getPMREMFromTexture(e,t,n){const o=_getCache(t);let s=o.get(e);const i=s!==0[0]?s.pmremVersion:-1;if(i!==e.pmremVersion){const t=e.image;if(e.isCubeTexture)if(isCubeMapReady(t))s=n.fromCubemap(e,s);else return null;else if(isEquirectangularMapReady(t))s=n.fromEquirectangular(e,s);else return null;s.pmremVersion=e.pmremVersion,o.set(e,s)}return s.texture}function _getCache(e){let t=_cache2.get(e);return t===0[0]&&(t=new WeakMap,_cache2.set(e,t)),t}class PMREMNode extends TempNode{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;const s=new Texture;s.isRenderTargetTexture=!0,this._texture=texture(s),this._width=uniform(0),this._height=uniform(0),this._maxMip=uniform(0),this.updateBeforeType=NodeUpdateType.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=_generateCubeUVSize(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;const s=t?t.pmremVersion:-1,n=this._value;s!==n.pmremVersion&&(n.isPMREMTexture===!0?t=n:t=_getPMREMFromTexture(n,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new PMREMGenerator(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=materialEnvRotation.mul(vec3(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),textureCubeUV(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function isCubeMapReady(e){if(e==null)return!1;let t=0;const n=6;for(let s=0;s<n;s++)e[s]!==0[0]&&t++;return t===n}function isEquirectangularMapReady(e){return e!=null&&e.height>0}pmremTexture=nodeProxy(PMREMNode).setParameterLength(1,3),_envNodeCache=new WeakMap;class EnvironmentNode extends LightingNode{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:n}=e;let t=this.envNode;if(t.isTextureNode||t.isMaterialReferenceNode){const s=t.isTextureNode?t.value:n[t.property];let e=_envNodeCache.get(s);e===0[0]&&(e=pmremTexture(s),_envNodeCache.set(s,e)),t=e}const o=n.useAnisotropy===!0||n.anisotropy>0,i=o?bentNormalView:normalView,a=t.context(createRadianceContext(roughness,i)).mul(materialEnvIntensity),r=t.context(createIrradianceContext(normalWorld)).mul(Math.PI).mul(materialEnvIntensity),c=isolate(a),l=isolate(r);
vendor: 6,160 bytes, line 63
63e.context.radiance.addAssign(c),e.context.iblIrradiance.addAssign(l);const s=e.context.lightingModel.clearcoatRadiance;if(s){const e=t.context(createRadianceContext(clearcoatRoughness,clearcoatNormalView)).mul(materialEnvIntensity),n=isolate(e);s.addAssign(n)}}}createRadianceContext=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=positionViewDirection.negate().reflect(t),n=pow4(e).mix(n,t).normalize(),n=n.transformDirection(cameraViewMatrix)),n),getTextureLevel:()=>e}},createIrradianceContext=e=>({getUV:()=>e,getTextureLevel:()=>float(1)}),_defaultValues$6=new MeshStandardMaterial;class MeshStandardNodeMaterial extends NodeMaterial{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(_defaultValues$6),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new EnvironmentNode(t):null}setupLightingModel(){return new PhysicalLightingModel}setupSpecular(){const e=mix(vec3(.04),diffuseColor.rgb,metalness);specularColor.assign(vec3(.04)),specularColorBlended.assign(e),specularF90.assign(1)}setupVariants(){const t=this.metalnessNode?float(this.metalnessNode):materialMetalness;metalness.assign(t);let e=this.roughnessNode?float(this.roughnessNode):materialRoughness;e=getRoughness({roughness:e}),roughness.assign(e),this.setupSpecular(),diffuseContribution.assign(diffuseColor.rgb.mul(t.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}_defaultValues$5=new MeshPhysicalMaterial;class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial{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(_defaultValues$5),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(){const e=this.iorNode?float(this.iorNode):materialIOR;ior.assign(e),specularColor.assign(min$1(pow2(ior.sub(1).div(ior.add(1))).mul(materialSpecularColor),vec3(1)).mul(materialSpecularIntensity)),specularColorBlended.assign(mix(specularColor,diffuseColor.rgb,metalness)),specularF90.assign(mix(materialSpecularIntensity,1,metalness))}setupLightingModel(){return new PhysicalLightingModel(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?float(this.clearcoatNode):materialClearcoat,t=this.clearcoatRoughnessNode?float(this.clearcoatRoughnessNode):materialClearcoatRoughness;clearcoat.assign(e),clearcoatRoughness.assign(getRoughness({roughness:t}))}if(this.useSheen){const e=this.sheenNode?vec3(this.sheenNode):materialSheen,t=this.sheenRoughnessNode?float(this.sheenRoughnessNode):materialSheenRoughness;sheen.assign(e),sheenRoughness.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?float(this.iridescenceNode):materialIridescence,t=this.iridescenceIORNode?float(this.iridescenceIORNode):materialIridescenceIOR,n=this.iridescenceThicknessNode?float(this.iridescenceThicknessNode):materialIridescenceThickness;iridescence.assign(e),iridescenceIOR.assign(t),iridescenceThickness.assign(n)}if(this.useAnisotropy){const e=(this.anisotropyNode?vec2(this.anisotropyNode):materialAnisotropy).toVar();anisotropy.assign(e.length()),If(anisotropy.equal(0),()=>{e.assign(vec2(1,0))}).Else(()=>{e.divAssign(vec2(anisotropy)),anisotropy.assign(anisotropy.saturate())}),alphaT.assign(anisotropy.pow2().mix(roughness.pow2(),1)),anisotropyT.assign(TBNViewMatrix[0].mul(e.x).add(TBNViewMatrix[1].mul(e.y))),anisotropyB.assign(TBNViewMatrix[1].mul(e.x).sub(TBNViewMatrix[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?float(this.transmissionNode):materialTransmission,t=this.thicknessNode?float(this.thicknessNode):materialThickness,n=this.attenuationDistanceNode?float(this.attenuationDistanceNode):materialAttenuationDistance,s=this.attenuationColorNode?vec3(this.attenuationColorNode):materialAttenuationColor;if(transmission.assign(e),thickness.assign(t),attenuationDistance.assign(n),attenuationColor.assign(s),this.useDispersion){const e=this.dispersionNode?float(this.dispersionNode):materialDispersion;dispersion.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?vec3(this.clearcoatNormalNode):materialClearcoatNormal}setup(e){e.context.setupClearcoatNormal=()=>subBuild(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.dis
63persionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}getGradientIrradiance=Fn(({normal:e,lightDirection:t,builder:n})=>{const i=e.dot(t),s=vec2(i.mul(.5).add(.5),0);if(n.material.gradientMap){const e=materialReference("gradientMap","texture").context({getUV:()=>s});return vec3(e.r)}const o=s.fwidth().mul(.5);return mix(vec3(.7),vec3(1),smoothstep2(float(.7).sub(o.x),float(.7).add(o.x),s.x))});class ToonLightingModel extends LightingModel{direct({lightDirection:e,lightColor:t,reflectedLight:n},s){const o=getGradientIrradiance({normal:normalGeometry,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(o.mul(BRDF_Lambert({diffuseColor:diffuseColor.rgb})))}indirect(e){const{ambientOcclusion:n,irradiance:s,reflectedLight:t}=e.context;t.indirectDiffuse.addAssign(s.mul(BRDF_Lambert({diffuseColor}))),t.indirectDiffuse.mulAssign(n)}}_defaultValues$4=new MeshToonMaterial;class MeshToonNodeMaterial extends NodeMaterial{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_defaultValues$4),this.setValues(e)}setupLightingModel(){return new ToonLightingModel}}matcapUV=Fn(()=>{const e=vec3(positionViewDirection.z,0,positionViewDirection.x.negate()).normalize(),t=positionViewDirection.cross(e);return vec2(e.dot(normalView),t.dot(normalView)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),_defaultValues$3=new MeshMatcapMaterial;class MeshMatcapNodeMaterial extends NodeMaterial{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(_defaultValues$3),this.setValues(e)}setupVariants(e){const n=matcapUV;let t;e.material.matcap?t=materialReference("matcap","texture").context({getUV:()=>n}):t=vec3(mix(.2,.8,n.y)),diffuseColor.rgb.mulAssign(t.rgb)}}class RotateNode extends TempNode{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:n,positionNode:s}=this,o=this.getNodeType(e);if(o==="vec2"){const e=n.cos(),t=n.sin(),o=mat2(e,t,t.negate(),e);return o.mul(s)}const t=n,i=mat4(vec4(1,0,0,0),vec4(0,cos(t.x),sin(t.x).negate(),0),vec4(0,sin(t.x),cos(t.x),0),vec4(0,0,0,1)),a=mat4(vec4(cos(t.y),0,sin(t.y),0),vec4(0,1,0,0),vec4(sin(t.y).negate(),0,cos(t.y),0),vec4(0,0,0,1)),r=mat4(vec4(cos(t.z),sin(t.z).negate(),0,0),vec4(sin(t.z),cos(t.z),0,0),vec4(0,0,1,0),vec4(0,0,0,1));return i.mul(a).mul(r).mul(vec4(s,1)).xyz}}rotate=nodeProxy(RotateNode).setParameterLength(2),_defaultValues$2=new SpriteMaterial;class SpriteNodeMaterial extends NodeMaterial{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(_defaultValues$2),this.setValues(e)}setupPositionView(e){const{object:s,camera:a}=e,{positionNode:r,rotationNode:c,scaleNode:i,sizeAttenuation:l}=this,o=modelViewMatrix.mul(vec3(r||0));let t=vec2(modelWorldMatrix[0].xyz.length(),modelWorldMatrix[1].xyz.length());i!==null&&(t=t.mul(vec2(i))),a.isPerspectiveCamera&&l===!1&&(t=t.mul(o.z.negate()));let n=positionGeometry.xy;if(s.center&&s.center.isVector2===!0){const e=reference$1("center","vec2",s);n=n.sub(e.sub(.5))}n=n.mul(t);const d=float(c||materialRotation),u=rotate(n,d);return vec4(o.xy.add(u),o.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)}}_defaultValues$1=new PointsMaterial,_size$4=new Vector2;class PointsNodeMaterial extends SpriteNodeMaterial{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(_defaultValues$1),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return modelViewMatrix.mul(vec3(e||positionLocal)).xyz}setupVertexSprite(e){const{material:r,camera:c}=e,{rotationNode:o,scaleNode:i,sizeNode:a,sizeAttenuation:l}=this;let s=super.setupVertex(e);if(r.isNodeMaterial!==!0)return s;let n=a!==null?vec2(a):materialPointSize;n=n.mul(screenDPR),c.isPerspectiveCamera&&l===!0&&(n=n.mul(scale.div(positionView.z.negate()))),i&&i.isNode&&(n=n.mul(ve
63c2(i)));let t=positionGeometry.xy;if(o&&o.isNode){const e=float(o);t=rotate(t,e)}return t=t.mul(n),t=t.div(viewportSize.div(2)),t=t.mul(s.w),s=s.add(vec4(t,0,0)),s}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)}}scale=uniform(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(_size$4);this.value=.5*t.y});class ShadowMaskModel extends LightingModel{constructor(){super(),this.shadowNode=float(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){diffuseColor.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(diffuseColor.rgb)}}_defaultValues=new ShadowMaterial;class ShadowNodeMaterial extends NodeMaterial{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(_defaultValues),this.setValues(e)}setupLightingModel(){return new ShadowMaskModel}}scatteringDensity=property("vec3"),linearDepthRay=property("vec3"),outgoingRayLight=property("vec3");class Animation{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){const 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.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};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()}}class ChainMap{constructor(){this.weakMaps={}}_getWeakMap(e){const n=e.length;let t=this.weakMaps[n];return t===0[0]&&(t=new WeakMap,this.weakMaps[n]=t),t}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===0[0])return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){const s=e[t];n.has(s)===!1&&n.set(s,new WeakMap),n=n.get(s)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===0[0])return!1;return t.delete(e[e.length-1])}}_id$a=0;function getKeys(e){const n=Object.keys(e);let t=Object.getPrototypeOf(e);for(;t;){const e=Object.getOwnPropertyDescriptors(t);for(const t in e)if(e[t]!==0[0]){const s=e[t];s&&typeof s.get=="function"&&n.push(t)}t=Object.getPrototypeOf(t)}return n}class RenderObject{constructor(e,t,n,s,o,i,a,r,c,l){this.id=_id$a++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=s,this.material=o,this.scene=i,this.camera=a,this.lightsNode=r,this.context=c,this.geometry=s.geometry,this.version=o.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=l,this.clippingContextCacheKey=l!==null?l.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{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&&(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(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(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;const s=this.getNodeBuilderState().nodeAttributes,o=this.geometry,e=[],t=new Set,n={};for(const a of s){let i;if(a.node&&a.node.attribute?i=a.node.attribute:(i=o.getAttribute(a.name),n[a.name]=i.version),i===0[0])continue;e.push(i);const r=i.isInterleavedBufferAttribute?i.data:i;t.add(r)}return this.attributes=e,this.attributesId=n,this.vertexBuffers=Array.from(t.values()),e}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:f,geometry:c,group:i,drawRange:r}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),h=this.getIndex(),m=h!==null;let a=1;if(c.isInstancedBufferGeometry===!0?a=c.instanceCount:e.count!==0[0]&&(a=Math.max(0,e.count)),a===0)return null;if(n.instanceCount=a,e.isBatchedMesh===!0)return n;let o=1;f.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(o=2);let t=r.start*o,s=(r.start+r.count)*o;i!==null&&(t=Math.max(t,i.start*o),s=Math.min(s,(i.start+i.count)*o));const l=c.attributes.position;let d=1/0;m?d=h.count:l!=null&&(d=l.count),t=Math.max(t,0),s=Math.min(s,d);const u=s-t;return u<0||u===1/0?null:(n.vertexCount=u,n.firstVertex=t,n)}getGeometryCacheKey(){const{geometry:t}=this;let e="";for(const s of Object.keys(t.attributes).sort()){const n=t.attributes[s];e+=s+",",n.data&&(e+=n.data.stride+","),n.offset&&(e+=n.offset+","),n.itemSize&&(e+=n.itemSize+","),n.normalized&&(e+="n,")}for(const n of Object.keys(t.morphAttributes).sort()){const s=t.morphAttributes[n];e+="morph-"+n+",";for(let t=0,n=s.length;t<n;t++){const o=s[t];e+=o.id+","}}return t.index&&(e+="index,"),e}getMaterialCacheKey(){const{object:e,material:n,renderer:s}=this;let t=n.customProgramCacheKey();for(const i of getKeys(n)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(i))continue;const e=n[i];let o;if(e!==null){const t=typeof e;t==="number"?o=e!==0?"1":"0":t==="object"?(o="{",e.isTexture&&(o+=e.mapping,s.backend.isWebGPUBackend===!0&&(o+=e.magFilter,o+=e.minFilter,o+=e.wrapS,o+=e.wrapT,o+=e.wrapR)),o+="}"):o=String(e)}else o=String(e);t+=o+","}return t+=this.clippingContextCacheKey+",",e.geometry&&(t+=this.getGeometryCacheKey()),e.skeleton&&(t+=e.skeleton.bones.length+","),e.isBatchedMesh&&(t+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(t+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(t+=e.uuid+","),t+=this.context.
63id+",",t+=e.receiveShadow+",",hashString(t)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const n=this.geometry.getAttribute(t);if(n===0[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=hash$1(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=hash$1(e,1)),e=hash$1(e,this.camera.id,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}_chainKeys$5=[];class RenderObjects{constructor(e,t,n,s,o,i){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=s,this.bindings=o,this.info=i,this.chainMaps={}}get(e,t,n,s,o,i,a,r){const l=this.getChainMap(r);_chainKeys$5[0]=e,_chainKeys$5[1]=t,_chainKeys$5[2]=i,_chainKeys$5[3]=o;let c=l.get(_chainKeys$5);return c===0[0]?(c=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,s,o,i,a,r),l.set(_chainKeys$5,c)):(c.updateClipping(a),c.needsGeometryUpdate&&c.setGeometry(e.geometry),(c.version!==t.version||c.needsUpdate)&&(c.initialCacheKey!==c.getCacheKey()?(c.dispose(),c=this.get(e,t,n,s,o,i,a,r)):c.version=t.version)),_chainKeys$5.length=0,c}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new ChainMap)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,s,o,i,a,r,c,l,d){const h=this.getChainMap(d),u=new RenderObject(e,t,n,s,o,i,a,r,c,l);return u.onDispose=()=>{this.pipelines.delete(u),this.bindings.deleteForRender(u),this.nodes.delete(u),h.delete(u.getChainArray())},u}}class DataMap{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===0[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}}AttributeType={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},GPU_CHUNK_BYTES=16,BlendColorFactor=211,OneMinusBlendColorFactor=212;class Attributes extends DataMap{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===0[0])t===AttributeType.VERTEX?this.backend.createAttribute(e):t===AttributeType.INDEX?this.backend.createIndexAttribute(e):t===AttributeType.STORAGE?this.backend.createStorageAttribute(e):t===AttributeType.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(n.version<t.version||t.usage===DynamicDrawUsage)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function getWireframeVersion(e){return e.index!==null?e.index.version:e.attributes.position.version}function getWireframeIndex(e){const t=[],n=e.index,o=e.attributes.position;if(n!==null){const e=n.array;for(let n=0,a=e.length;n<a;n+=3){const s=e[n+0],o=e[n+1],i=e[n+2];t.push(s,o,o,i,i,s)}}else{const e=o.array;for(let n=0,a=e.length/3-1;n<a;n+=3){const s=n+0,o=n+1,i=n+2;t.push(s,o,o,i,i,s)}}const s=new(arrayNeedsUint32(t)?Uint32BufferAttribute:Uint16BufferAttribute)(t,1);return s.version=getWireframeVersion(e),s}class Geometries extends DataMap{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,s=this.get(t);s.initialized=!0,this.info.memory.geometries++;const n=()=>{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();s!==null&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const o=this.wireframes.get(t);o!==0[0]&&this.attributes.delete(o),t.removeEventListener("dispose",n),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",n),this._geometryDisposeListeners.set(t,n)}updateAttributes(e){const s=e.getAttributes();for(const e of s)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,AttributeType.STORAGE):this.updateAttribute(e,AttributeType.VERTEX);const t=this.getIndex(e);t!==null&&this.updateAttribute(t,AttributeType.INDEX);const n=e.geometry.indirect;n!==null&&this.updateAttribute(n,AttributeType.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===0[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}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:s}=e;let n=t.index;if(s.wireframe===!0){const s=this.wireframes;let e=s.get(t);e===0[0]?(e=getWireframeIndex(t),s.set(t,e)):e.version!==getWireframeVersion(t)&&(this.attributes.delete(e),e=getWireframeIndex(t),s.set(t,e)),n=e}return n}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Info{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):error("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}}class Pipeline{constructor(e){this.cacheKey=e,this.usedTimes=0}}class RenderPipeline extends Pipeline{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class ComputePipeline extends Pipeline{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}_id$9=0;class ProgrammableStage{constructor(e,t,n,s=null,o=null){this.id=_id$9++,this.code=e,this.stage=t,this.name=n,this.transforms=s,this.attributes=o,this.usedTimes=0}}class Pipelines extends DataMap{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){const{backend:s}=this,n=this.get(e);if(this._needsComputeUpdate(e)){const o=n.pipeline;o&&(o.usedTimes--,o.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let i=this.programs.compute.get(a.computeShader);i===0[0]&&(o&&o.computeProgram.usedTimes===0&&this._releaseProgram(o.computeProgram),i=new ProgrammableStage(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,i),s.createProgram(i));const c=this._getComputeCacheKey(e,i);let r=this.caches.get(c);r===0[0]&&(o&&o.usedTimes===0&&this._releasePipeline(o),r=this._getComputePipeline(e,i,c,t)),r.usedTimes++,i.usedTimes++,n.version=e.version,n.pipeline=r}return n.pipeline}getForRender(e,t=null){const{backend:s}=this,n=this.get(e);
63if(this._needsRenderUpdate(e)){const o=n.pipeline;o&&(o.usedTimes--,o.vertexProgram.usedTimes--,o.fragmentProgram.usedTimes--);const r=e.getNodeBuilderState(),l=e.material?e.material.name:"";let i=this.programs.vertex.get(r.vertexShader);i===0[0]&&(o&&o.vertexProgram.usedTimes===0&&this._releaseProgram(o.vertexProgram),i=new ProgrammableStage(r.vertexShader,"vertex",l),this.programs.vertex.set(r.vertexShader,i),s.createProgram(i));let a=this.programs.fragment.get(r.fragmentShader);a===0[0]&&(o&&o.fragmentProgram.usedTimes===0&&this._releaseProgram(o.fragmentProgram),a=new ProgrammableStage(r.fragmentShader,"fragment",l),this.programs.fragment.set(r.fragmentShader,a),s.createProgram(a));const d=this._getRenderCacheKey(e,i,a);let c=this.caches.get(d);c===0[0]?(o&&o.usedTimes===0&&this._releasePipeline(o),c=this._getRenderPipeline(e,i,a,d,t)):e.pipeline=c,c.usedTimes++,i.usedTimes++,a.usedTimes++,n.pipeline=c}return n.pipeline}delete(e){const 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,s){n=n||this._getComputeCacheKey(e,t);let o=this.caches.get(n);return o===0[0]&&(o=new ComputePipeline(n,t),this.caches.set(n,o),this.backend.createComputePipeline(o,s)),o}_getRenderPipeline(e,t,n,s,o){s=s||this._getRenderCacheKey(e,t,n);let i=this.caches.get(s);return i===0[0]&&(i=new RenderPipeline(s,t,n),this.caches.set(s,i),e.pipeline=i,this.backend.createRenderPipeline(e,o)),i}_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){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===0[0]||t.version!==e.version}_needsRenderUpdate(e){const t=this.get(e);return t.pipeline===0[0]||this.backend.needsRenderUpdate(e)}}class Bindings extends DataMap{constructor(e,t,n,s,o,i){super(),this.backend=e,this.textures=n,this.pipelines=o,this.attributes=s,this.nodes=t,this.info=i,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const n=this.get(e);n.bindGroup===0[0]&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const n=this.get(e);n.bindGroup===0[0]&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t)this.backend.deleteBindGroupData(e),this.delete(e)}deleteForRender(e){const t=e.getBindings();for(const e of t)this.backend.deleteBindGroupData(e),this.delete(e)}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){const e=t.attribute,n=e.isIndirectStorageBufferAttribute?AttributeType.INDIRECT:AttributeType.STORAGE;this.attributes.update(e,n)}}_update(e,t){const{backend:i}=this;let s=!1,n=!0,o=0,a=0;for(const t of e.bindings){const r=this.nodes.updateGroup(t);if(r===!1)continue;if(t.isStorageBuffer){const e=t.attribute,n=e.isIndirectStorageBufferAttribute?AttributeType.INDIRECT:AttributeType.STORAGE;this.attributes.update(e,n)}if(t.isUniformBuffer){const e=t.update();e&&i.updateBinding(t)}else if(t.isSampledTexture){{const c=t.update(),e=t.texture,r=this.textures.get(e);c&&(this.textures.updateTexture(e),t.generation!==r.generation&&(t.generation=r.generation,s=!0,n=!1));const l=i.get(e);if(l.externalTexture!==0[0]||r.isDefaultTexture?n=!1:(o=o*10+e.id,a+=e.version),e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!0){const n=this.get(e);t.store===!0?n.needsMipmap=!0:this.textures.needsMipmaps(e)&&n.needsMipmap===!0&&(this.backend.generateMipmaps(e),n.needsMipmap=!1)}}}
63else if(t.isSampler){const e=t.update();if(e){const e=this.textures.updateSampler(t.texture);t.samplerKey!==e&&(t.samplerKey=e,s=!0,n=!1)}}}s===!0&&this.backend.updateBindings(e,t,n?o:0,a)}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function needsDoublePass(e){const t=e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode;return t&&e.side===DoubleSide&&e.forceSinglePass===!1}class RenderList{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,s,o,i,a){let r=this.renderItems[this.renderItemsIndex];return r===0[0]?(r={id:e.id,object:e,geometry:t,material:n,groupOrder:s,renderOrder:e.renderOrder,z:o,group:i,clippingContext:a},this.renderItems[this.renderItemsIndex]=r):(r.id=e.id,r.object=e,r.geometry=t,r.material=n,r.groupOrder=s,r.renderOrder=e.renderOrder,r.z=o,r.group=i,r.clippingContext=a),this.renderItemsIndex++,r}push(e,t,n,s,o,i,a){const r=this.getNextRenderItem(e,t,n,s,o,i,a);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(needsDoublePass(n)&&this.transparentDoublePass.push(r),this.transparent.push(r)):this.opaque.push(r)}unshift(e,t,n,s,o,i,a){const r=this.getNextRenderItem(e,t,n,s,o,i,a);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(needsDoublePass(n)&&this.transparentDoublePass.unshift(r),this.transparent.unshift(r)):this.opaque.unshift(r)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||painterSortStable),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||reversePainterSortStable),this.transparent.length>1&&this.transparent.sort(t||reversePainterSortStable)}finish(){this.lightsNode.setLights(this.lightsArray);for(let t=this.renderItemsIndex,n=this.renderItems.length;t<n;t++){const e=this.renderItems[t];if(e.id===null)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.groupOrder=null,e.renderOrder=null,e.z=null,e.group=null,e.clippingContext=null}}}_chainKeys$4=[];class RenderLists{constructor(e){this.lighting=e,this.lists=new ChainMap}get(e,t){const s=this.lists;_chainKeys$4[0]=e,_chainKeys$4[1]=t;let n=s.get(_chainKeys$4);return n===0[0]&&(n=new RenderList(this.lighting,e,t),s.set(_chainKeys$4,n)),_chainKeys$4.length=0,n}dispose(){this.lists=new ChainMap}}_id$8=0;class RenderContext{constructor(){this.id=_id$8++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Vector4,this.scissor=!1,this.scissorValue=new Vector4,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return getCacheKey(this)}}function getCacheKey(e){const{textures:n,activeCubeFace:s,activeMipmapLevel:o}=e,t=[s,o];for(const e of n)t.push(e.id);return hashArray(t)}_chainKeys$3=[],_defaultScene=new Scene,_defaultCamera=new Camera;class RenderContexts{constructor(){this.chainMaps={}}get(e,t,n=null,s=null){_chainKeys$3[0]=e,_chainKeys$3[1]=t,s!==null&&(_chainKeys$3[2]=s);let i;if(n===null)i="default";else{const e=n.texture.format,t=n.textures.length;i=`${t}:${e}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const a=this._getChainMap(i);let o=a.get(_chainKeys$3);return o===0[0]&&(o=new RenderContext,a.set(_chainKeys$3,o)),_chainKeys$3.length=0,n!==null&&(o.sampleCount=n.samples===0?1:n.samples),o}getForClear(e=null){return this.get(_defaultScene,_defaultCamera,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new ChainMap)}dispose(){this.chainMaps={}}}_size$3=new Vector3;class Textures extends DataMap{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const s=this.get(e),a=e.samples===0?1:e.samples,c=s.depthTextureMips||(s.depthTextureMips={}),i=e.textures,o=this.getSize(i[0]),l=o.width>>t,d=o.height>>t;let n=e.depthTexture||c[t];const h=e.depthBuffer===!0||e.stencilBuffer===!0;let r=!1;n===0[0]&&h&&(n=new DepthTexture,n.format=e.stencilBuffer?DepthStencilFormat:DepthFormat,n.type=e.stencilBuffer?UnsignedInt248Type:UnsignedIntType,n.image.width=l,n.image.height=d,n.image.depth=o.depth,n.renderTarget=e,n.isArrayTexture=e.multiview===!0&&o.depth>1,c[t]=n),(s.width!==o.width||o.height!==s.height)&&(r=!0,n&&(n.needsUpdate=!0,n.image.width=l,n.image.height=d,n.image.depth=n.isArrayTexture?n.image.depth:1)),s.width=o.width,s.height=o.height,s.textures=i,s.depthTexture=n||null,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==a&&(r=!0,n&&(n.needsUpdate=!0),s.sampleCount=a);
63const u={sampleCount:a};if(e.isXRRenderTarget!==!0){for(let e=0;e<i.length;e++){const t=i[e];r&&(t.needsUpdate=!0),this.updateTexture(t,u)}n&&this.updateTexture(n,u)}s.initialized!==!0&&(s.initialized=!0,s.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",s.onDispose))}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const o=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(o&&n.initialized===!0&&s.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=UnsignedByteType}const{width:i,height:a,depth:r}=this.getSize(e);if(t.width=i,t.height=a,t.depth=r,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,i,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,o||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createTexture(e,t),n.generation=e.version;else if(e.version>0){const o=e.image;if(o===0[0])warn("Renderer: Texture marked for update but image is undefined.");else if(o.complete===!1)warn("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const n=[];for(const t of e.images)n.push(t);t.images=n}else t.image=o;(n.isDefaultTexture===0[0]||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t);const i=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!i&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&ColorManagement.enabled===!0&&ColorManagement.getTransfer(e.colorSpace)!==SRGBTransfer&&warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=_size$3){let n=e.images?e.images[0]:e.image;return n?(n.image!==0[0]&&(n=n.image),typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame!="undefined"&&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 s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,n)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),n=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e<n.length;e++)this._destroyTexture(n[e]);s&&this._destroyTexture(s),this.delete(e),this.backend.delete(e)}}_destroyTexture(e){if(this.has(e)===!0){const t=this.get(e);e.removeEventListener("dispose",t.onDispose);const n=t.isDefaultTexture;this.backend.destroyTexture(e,n),this.delete(e),this.info.memory.textures--}}}class Color4 extends Color{constructor(e,t,n,s=1){super(e,t,n),this.a=s}set(e,t,n,s=1){return this.a=s,super.set(e,t,n)}copy(e){return e.a!==0[0]&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class ParameterNode extends PropertyNode{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const s=this.getNodeType(e),o=e.getStructTypeNode(s);let n;return o!==null?n=o.getMemberType(e,t):(error(`TSL: Member "${t}" not found in struct "${s}".`),n="float"),n}getHash(){return this.uuid}generate(){return this.name}}class StackNode extends Node{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput?this.outputNode.getElementType(e):"void"}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=this.nodes.length){return e.isNode!==!0?(error("TSL: Invalid node added to stack."),this):(this.nodes.splice(t,0,e),this)}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const n=new ShaderNode(t);return this._currentCond=select(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){const s=new ShaderNode(t),n=select(e,s);return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new ShaderNode(e),this}Switch(e){return this._expressionNode=nodeObject(e),this}Case(...e){const t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(nodeObject(e[n])));else error("TSL: Invalid parameter length. Case() requires at least two parameters.");const o=e[e.length-1],i=new ShaderNode(o);let n=t[0];for(let e=1;e<t.length;e++)n=n.or(t[e]);const s=select(n,i);return this._currentCond===null?(this._currentCond=s,this.addToStack(this._currentCond)):(this._currentCond.elseNode=s,this._currentCond=s,this)}Default(e){return this.Else(e),this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const s of this.getChildren()){if(s.isVarNode&&s.isIntent(e)&&s.isAssign(e)!==!0)continue;t["node"+n++]=s}return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...s){const a=getCurrentStack(),t=e.buildStage;setCurrentStack(this),e.setActiveStack(this);const o=n=>{if(this._currentNode=n,n.isVarNode&&n.isIntent(e)&&n.isAssign(e)!==!0)return;if(t==="setup")n.build(e);else if(t==="analyze")n.build(e,this);else if(t==="generate"){const s=e.getDataFromNode(n,"any").stages,t=s&&s[e.shaderStage];if(n.isVarNode&&t&&t.length===1&&t[0]&&t[0].isStackNode)return;n.build(e,"void")}},i=[...this.nodes];for(const e of i)o(e);this._currentNode=null;const r=this.nodes.filter(e=>i.indexOf(e)===-1);for(const e of r)o(e);let n;return this.hasOutput?n=this.outputNode.build(e,...s):n=super.build(e,...s),setCurrentStack(a),e.removeActiveStack(this),n}}stack=nodeProxy(StackNode).setParameterLength(0,1);class BitcastNode extends TempNode{static get type(){return"BitcastNode"}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){const n=this.getNodeType(e);let t="";if(this.inputType!==null){const n=this.valueNode.getNodeType(e),s=e.getTypeLength(n);t=s===1?this.inputType:e.changeComponentType(n,this.inputType)}else t=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(n,t)}( ${this.valueNode.build(e,t)} )`}}bitcast=nodeProxyIntent(BitcastNode).setParameterLength(2),floatBitsToUint=e=>new BitcastNode(e,"uint","float"),registeredBitcountFunctions={};class BitcountNode extends MathNode{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n==="int"?t.assign(bitcast(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return uint;case"int":return int;case"uvec2":return uvec2;case"uvec3":return uvec3;case"uvec4":return uvec4;case"ivec2":return ivec2;case"ivec3":return ivec3;case"ivec4":return ivec4}}_createTrailingZerosBaseLayout(e,t){const n=this._returnDataNode(t),s=Fn(([e])=>{const s=uint(0);this._resolveElementType(e,s,t);const o=float(s.bitAnd(negate(s))),i=floatBitsToUint(o),a=i.shiftRight(23).sub(127);return n(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]});return s}_createLeadingZerosBaseLayout(e,t){const n=this._returnDataNode(t),s=Fn(([e])=>{If(e.equal(uint(0)),()=>uint(32));const s=uint(0),o=uint(0);return this._resolveElementType(e,s,t),If(s.shiftRight(16).equal(0),()=>{o.addAssign(16),s.shiftLeftAssign(16)}),If(s.shiftRight(24).equal(0),()=>{o.addAssign(8),s.shiftLeftAssign(8)}),If(s.shiftRight(28).equal(0),()=>{o.addAssign(4),s.shiftLeftAssign(4)}),If(s.shiftRight(30).equal(0),()=>{o.addAssign(2),s.shiftLeftAssign(2)}),If(s.shiftRight(31).equal(0),()=>{o.addAssign(1)}),n(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]});return s}_createOneBitsBaseLayout(e,t){const n=this._returnDataNode(t),s=Fn(([e])=>{const s=uint(0);this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight(uint(1)).bitAnd(uint(1431655765)))),s.assign(s.bitAnd(uint(858993459)).add(s.shiftRight(uint(2)).bitAnd(uint(858993459))));const o=s.add(s.shiftRight(uint(4))).bitAnd(uint(252645135)).mul(uint(16843009)).shiftRight(uint(24));return n(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]});return s}_createMainLayout(e,t,n,s){const o=this._returnDataNode(t),i=Fn(([e])=>{if(n===1)return o(s(e));const t=o(0),i=["x","y","z","w"];for(let o=0;o<n;o++){const a=i[o];t[a].assign(s(e[a]))}return t}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]});return i}setup(e){const{method:a,aNode:c}=this,{renderer:l}=e;if(l.backend.isWebGPUBackend)return super.setup(e);const s=this.getInputType(e),o=e.getElementType(s),d=e.getTypeLength(s),n=`${a}_base_${o}`,r=`${a}_${s}`;let t=registeredBitcountFunctions[n];if(t===0[0]){switch(a){case BitcountNode.COUNT_LEADING_ZEROS:{t=this._createLeadingZerosBaseLayout(n,o);break}case BitcountNode.COUNT_TRAILING_ZEROS:{t=this._createTrailingZerosBaseLayout(n,o);break}case BitcountNode.COUNT_ONE_BITS:{t=this._createOneBitsBaseLayout(n,o);break}}registeredBitcountFunctions[n]=t}let i=registeredBitcountFunctions[r];i===0[0]&&(i=this._createMainLayout(r,s,d,t),registeredBitcountFunctions[r]=i);const u=Fn(()=>i(c));return u()}}
vendor: 6,928 bytes, line 63
63BitcountNode.COUNT_TRAILING_ZEROS="countTrailingZeros",BitcountNode.COUNT_LEADING_ZEROS="countLeadingZeros",BitcountNode.COUNT_ONE_BITS="countOneBits",_reflectorPlane=new Plane,_normal=new Vector3,_reflectorWorldPosition=new Vector3,_cameraWorldPosition=new Vector3,_rotationMatrix=new Matrix4,_lookAtPosition=new Vector3(0,0,-1),clipPlane=new Vector4,_view=new Vector3,_target2=new Vector3,_q=new Vector4,_size$2=new Vector2,_defaultRT=new RenderTarget,_defaultUV=screenUV.flipX(),_defaultRT.depthTexture=new DepthTexture(1,1),_camera=new OrthographicCamera(-1,1,1,-1,0,1);class QuadGeometry extends BufferGeometry{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Float32BufferAttribute(t,2))}}_geometry=new QuadGeometry;class QuadMesh extends Mesh{constructor(e=null){super(_geometry,e),this.camera=_camera,this.isQuadMesh=!0}async renderAsync(e){warnOnce('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,_camera)}render(e){e.render(this,_camera)}}interleavedGradientNoise=Fn(([e])=>fract(float(52.9829189).mul(fract(dot(e,vec2(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),vogelDiskSample=Fn(([e,t,n])=>{const o=float(2.399963229728653),i=sqrt(float(e).add(.5).div(float(t))),s=float(e).mul(o).add(n);return vec2(cos(s),sin(s)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class EventNode extends Node{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===EventNode.OBJECT?this.updateType=NodeUpdateType.OBJECT:e===EventNode.MATERIAL?this.updateType=NodeUpdateType.RENDER:e===EventNode.BEFORE_OBJECT?this.updateBeforeType=NodeUpdateType.OBJECT:e===EventNode.BEFORE_MATERIAL&&(this.updateBeforeType=NodeUpdateType.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}EventNode.OBJECT="object",EventNode.MATERIAL="material",EventNode.BEFORE_OBJECT="beforeObject",EventNode.BEFORE_MATERIAL="beforeMaterial",_e1=new Euler,_m12=new Matrix4;class SceneNode extends Node{static get type(){return"SceneNode"}constructor(e=SceneNode.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let s;return t===SceneNode.BACKGROUND_BLURRINESS?s=reference("backgroundBlurriness","float",n):t===SceneNode.BACKGROUND_INTENSITY?s=reference("backgroundIntensity","float",n):t===SceneNode.BACKGROUND_ROTATION?s=uniform("mat4").setName("backgroundRotation").setGroup(renderGroup).onRenderUpdate(()=>{const e=n.background;return e!==null&&e.isTexture&&e.mapping!==UVMapping?(_e1.copy(n.backgroundRotation),_e1.x*=-1,_e1.y*=-1,_e1.z*=-1,_m12.makeRotationFromEuler(_e1)):_m12.identity(),_m12}):error("SceneNode: Unknown scope:",t),s}}SceneNode.BACKGROUND_BLURRINESS="backgroundBlurriness",SceneNode.BACKGROUND_INTENSITY="backgroundIntensity",SceneNode.BACKGROUND_ROTATION="backgroundRotation",backgroundBlurriness=nodeImmutable(SceneNode,SceneNode.BACKGROUND_BLURRINESS),backgroundIntensity=nodeImmutable(SceneNode,SceneNode.BACKGROUND_INTENSITY),backgroundRotation=nodeImmutable(SceneNode,SceneNode.BACKGROUND_ROTATION),normal=Fn(({texture:e,uv:t})=>{const s=1e-4,n=vec3().toVar();return If(t.x.lessThan(s),()=>{n.assign(vec3(1,0,0))}).ElseIf(t.y.lessThan(s),()=>{n.assign(vec3(0,1,0))}).ElseIf(t.z.lessThan(s),()=>{n.assign(vec3(0,0,1))}).ElseIf(t.x.greaterThan(1-s),()=>{n.assign(vec3(-1,0,0))}).ElseIf(t.y.greaterThan(1-s),()=>{n.assign(vec3(0,-1,0))}).ElseIf(t.z.greaterThan(1-s),()=>{n.assign(vec3(0,0,-1))}).Else(()=>{const s=.01,o=e.sample(t.add(vec3(-s,0,0))).r.sub(e.sample(t.add(vec3(s,0,0))).r),i=e.sample(t.add(vec3(0,-s,0))).r.sub(e.sample(t.add(vec3(0,s,0))).r),a=e.sample(t.add(vec3(0,0,-s))).r.sub(e.sample(t.add(vec3(0,0,s))).r);n.assign(vec3(o,i,a))}),n.normalize()});class Texture3DNode extends TextureNode{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return vec3(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(int(textureSize(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return normal({texture:this,uv:e})}}texture3D=nodeProxy(Texture3DNode).setParameterLength(1,3),_objectData=new WeakMap,_size=new Vector2;class PassTextureNode extends TextureNode{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)}}class PassMultipleTextureNode extends PassTextureNode{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(){const 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.offsetNode=this.offsetNode,e}}class PassNode extends TempNode{static get type(){return"PassNode"}constructor(e,t,n,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const o=new DepthTexture;o.isRenderTargetTexture=!0,o.name="depth";const i=new RenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:HalfFloatType,...s});i.texture.name="output",i.depthTexture=o,this.renderTarget=i,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:i.texture,depth:o},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=uniform(0),this._cameraFar=uniform(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=NodeUpdateType.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return warn("PassNode: .setResolution() is deprecated. Use .setRe
63solutionScale() instead."),this.setResolutionScale(e)}getResolution(){return warn("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}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];if(t===0[0]){const n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===0[0]&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==0[0]){const n=this._textures[e],s=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[s]=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===0[0]&&(t=new PassMultipleTextureNode(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===0[0]&&(this._textureNodes[e]===0[0]&&this.getTextureNode(e),t=new PassMultipleTextureNode(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===0[0]){const n=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=perspectiveDepthToViewZ(this.getTextureNode(e),n,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===0[0]){const n=this._cameraNear,s=this._cameraFar,o=this.getViewZNode(e);this._linearDepthNodes[e]=t=viewZToOrthographicDepth(o,n,s)}return t}async compileAsync(e){const 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===0[0]?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===PassNode.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s}=this;let n,i;const o=t.getOutputRenderTarget();o&&o.isXRRenderTarget===!0?(i=1,n=t.xr.getCamera(),t.xr.updateCamera(n),_size.set(o.width,o.height)):(n=this.camera,i=t.getPixelRatio(),t.getSize(_size)),this._pixelRatio=i,this.setSize(_size.width,_size.height);const r=t.getRenderTarget(),a=t.getMRT(),c=t.autoClear,l=t.transparent,d=t.opaque,u=n.layers.mask,h=t.contextNode,m=s.overrideMaterial;this._cameraNear.value=n.near,this._cameraFar.value=n.far,this._layers!==null&&(n.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(s.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:context({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const f=s.name;s.name=this.name?this.name:s.name,t.render(s,n),s.name=f,s.overrideMaterial=m,t.setRenderTarget(r),t.setMRT(a),t.autoClear=c,t.transparent=l,t.opaque=d,t.contextNode=h,n.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),s=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,s),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Vector4),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,s),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Vector4),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,s),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}PassNode.COLOR="color",PassNode.DEPTH="depth",linearToneMapping=Fn(([e,t])=>
vendor: 4,700 bytes, lines 63-64
63e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),reinhardToneMapping=Fn(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cineonToneMapping=Fn(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);const n=e.mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),RRTAndODTFit=Fn(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),acesFilmicToneMapping=Fn(([e,t])=>{const n=mat3(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=mat3(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=RRTAndODTFit(e),e=s.mul(e),e.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),LINEAR_REC2020_TO_LINEAR_SRGB=mat3(vec3(1.6605,-.1246,-.0182),vec3(-.5876,1.1329,-.1006),vec3(-.0728,-.0083,1.1187)),LINEAR_SRGB_TO_LINEAR_REC2020=mat3(vec3(.6274,.0691,.0164),vec3(.3293,.9195,.088),vec3(.0433,.0113,.8956)),agxDefaultContrastApprox=Fn(([e])=>{const t=vec3(e).toVar(),n=vec3(t.mul(t)).toVar(),s=vec3(n.mul(n)).toVar();return float(15.5).mul(s.mul(n)).sub(mul(40.14,s.mul(t))).add(mul(31.96,s).sub(mul(6.868,n.mul(t))).add(mul(.4298,n).add(mul(.1191,t).sub(.00232))))}),agxToneMapping=Fn(([e,t])=>{const n=vec3(e).toVar(),o=mat3(vec3(.856627153315983,.137318972929847,.11189821299995),vec3(.0951212405381588,.761241990602591,.0767994186031903),vec3(.0482516061458583,.101439036467562,.811302368396859)),i=mat3(vec3(1.1271005818144368,-.1413297634984383,-.14132976349843826),vec3(-.11060664309660323,1.157823702216272,-.11060664309660294),vec3(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=float(-12.47393),a=float(4.026069);return n.mulAssign(t),n.assign(LINEAR_SRGB_TO_LINEAR_REC2020.mul(n)),n.assign(o.mul(n)),n.assign(max$1(n,.1e-9)),n.assign(log22(n)),n.assign(n.sub(s).div(a.sub(s))),n.assign(clamp2(n,0,1)),n.assign(agxDefaultContrastApprox(n)),n.assign(i.mul(n)),n.assign(pow(max$1(vec3(0),n),vec3(2.2))),n.assign(LINEAR_REC2020_TO_LINEAR_SRGB.mul(n)),n.assign(clamp2(n,0,1)),n}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),neutralToneMapping=Fn(([e,t])=>{const o=float(.8-.04),r=float(.15);e=e.mul(t);const n=min$1(e.r,min$1(e.g,e.b)),c=select(n.lessThan(.08),n.sub(mul(6.25,n.mul(n))),.04);e.subAssign(c);const s=max$1(e.r,max$1(e.g,e.b));If(s.lessThan(o),()=>e);const i=sub(1,o),a=sub(1,i.mul(i).div(s.add(i.sub(o))));e.mulAssign(a.div(s));const l=sub(1,div(1,r.mul(s.sub(a)).add(1)));return mix(e,vec3(a),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class CodeNode extends Node{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){const n=this.getIncludes(e);for(const t of n)t.build(e);const t=e.getCodeFromNode(this,this.getNodeType(e));return t.code=this.code,t.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}}class FunctionNode extends CodeNode{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e),s=e.getStructTypeNode(n);return s.getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const n=e.getDataFromNode(this);let t=n.nodeFunction;return t===0[0]&&(t=e.parser.parseFunction(this.code),n.nodeFunction=t),t}generate(e,t){super.generate(e);const o=this.getNodeFunction(e),i=o.name,a=o.type,n=e.getCodeFromNode(this,a);i!==""&&(n.name=i);const s=e.getPropertyName(n),r=this.getNodeFunction(e).getCode(s);return n.code=r+` 64`,t==="property"?s:e.format(`${s}()`,a,t)}}class Resources extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const s=t(...n);return this.set(e,s),s}}}ScriptableNodeResources=new Resources;function getViewZNode(e){let t;const n=e.context.getViewZ;return n!==0[0]&&(t=n(this)),(t||positionView.z).negate()}rangeFogFactor=Fn(([e,t],n)=>{const s=getViewZNode(n);
64return smoothstep2(e,t,s)}),densityFogFactor=Fn(([e],t)=>{const n=getViewZNode(t);return e.mul(e,n,n).negate().exp().oneMinus()}),fog=Fn(([e,t])=>vec4(t.toFloat().mix(output.rgb,e.toVec3()),output.a));class BarrierNode extends Node{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier 65`):e.addLineFlowCode(`${t}Barrier()`,this)}}barrier=nodeProxy(BarrierNode);class AtomicFunctionNode extends Node{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){const t=e.getNodeProperties(this),n=t.parents,c=this.method,o=this.getNodeType(e),i=this.getInputType(e),l=this.pointerNode,a=this.valueNode,s=[];s.push(`&${l.build(e,i)}`),a!==null&&s.push(a.build(e,i));const r=`${e.getMethod(c,o)}( ${s.join(", ")} )`,d=!!n&&n.length===1&&n[0].isStackNode===!0;if(d)e.addLineFlowCode(r,this);else return t.constNode===0[0]&&(t.constNode=expression(r,o).toConst()),t.constNode.build(e)}}AtomicFunctionNode.ATOMIC_LOAD="atomicLoad",AtomicFunctionNode.ATOMIC_STORE="atomicStore",AtomicFunctionNode.ATOMIC_ADD="atomicAdd",AtomicFunctionNode.ATOMIC_SUB="atomicSub",AtomicFunctionNode.ATOMIC_MAX="atomicMax",AtomicFunctionNode.ATOMIC_MIN="atomicMin",AtomicFunctionNode.ATOMIC_AND="atomicAnd",AtomicFunctionNode.ATOMIC_OR="atomicOr",AtomicFunctionNode.ATOMIC_XOR="atomicXor",atomicNode=nodeProxy(AtomicFunctionNode);class SubgroupFunctionNode extends TempNode{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n);return s>o?t:n}getNodeType(e){const t=this.method;return t===SubgroupFunctionNode.SUBGROUP_ELECT?"bool":t===SubgroupFunctionNode.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,o=this.getNodeType(e),r=this.getInputType(e),a=this.aNode,i=this.bNode,s=[];if(n===SubgroupFunctionNode.SUBGROUP_BROADCAST||n===SubgroupFunctionNode.SUBGROUP_SHUFFLE||n===SubgroupFunctionNode.QUAD_BROADCAST){const t=i.getNodeType(e);
65s.push(a.build(e,o),i.build(e,t==="float"?"int":o))}else n===SubgroupFunctionNode.SUBGROUP_SHUFFLE_XOR||n===SubgroupFunctionNode.SUBGROUP_SHUFFLE_DOWN||n===SubgroupFunctionNode.SUBGROUP_SHUFFLE_UP?s.push(a.build(e,o),i.build(e,"uint")):(a!==null&&s.push(a.build(e,r)),i!==null&&s.push(i.build(e,r)));const c=s.length===0?"()":`( ${s.join(", ")} )`;return e.format(`${e.getMethod(n,o)}${c}`,o,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}SubgroupFunctionNode.SUBGROUP_ELECT="subgroupElect",SubgroupFunctionNode.SUBGROUP_BALLOT="subgroupBallot",SubgroupFunctionNode.SUBGROUP_ADD="subgroupAdd",SubgroupFunctionNode.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",SubgroupFunctionNode.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",SubgroupFunctionNode.SUBGROUP_MUL="subgroupMul",SubgroupFunctionNode.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",SubgroupFunctionNode.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",SubgroupFunctionNode.SUBGROUP_AND="subgroupAnd",SubgroupFunctionNode.SUBGROUP_OR="subgroupOr",SubgroupFunctionNode.SUBGROUP_XOR="subgroupXor",SubgroupFunctionNode.SUBGROUP_MIN="subgroupMin",SubgroupFunctionNode.SUBGROUP_MAX="subgroupMax",SubgroupFunctionNode.SUBGROUP_ALL="subgroupAll",SubgroupFunctionNode.SUBGROUP_ANY="subgroupAny",SubgroupFunctionNode.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",SubgroupFunctionNode.QUAD_SWAP_X="quadSwapX",SubgroupFunctionNode.QUAD_SWAP_Y="quadSwapY",SubgroupFunctionNode.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",SubgroupFunctionNode.SUBGROUP_BROADCAST="subgroupBroadcast",SubgroupFunctionNode.SUBGROUP_SHUFFLE="subgroupShuffle",SubgroupFunctionNode.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",SubgroupFunctionNode.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",SubgroupFunctionNode.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",SubgroupFunctionNode.QUAD_BROADCAST="quadBroadcast";function getLightData(e){uniformsLib=uniformsLib||new WeakMap;let t=uniformsLib.get(e);return t===0[0]&&uniformsLib.set(e,t={}),t}function lightShadowMatrix(e){const t=getLightData(e);return t.shadowMatrix||(t.shadowMatrix=uniform("mat4").setGroup(renderGroup).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function lightProjectionUV(e,t=positionWorld){const n=lightShadowMatrix(e).mul(t),s=n.xyz.div(n.w);return s}function lightPosition(e){const t=getLightData(e);return t.position||(t.position=uniform(new Vector3).setGroup(renderGroup).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld)))}function lightTargetPosition(e){const t=getLightData(e);return t.targetPosition||(t.targetPosition=uniform(new Vector3).setGroup(renderGroup).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld)))}function lightViewPosition(e){const t=getLightData(e);return t.viewPosition||(t.viewPosition=uniform(new Vector3).setGroup(renderGroup).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new Vector3,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}lightTargetDirection=e=>cameraViewMatrix.transformDirection(lightPosition(e).sub(lightTargetPosition(e))),sortLights=e=>e.sort((e,t)=>e.id-t.id),getLightNodeById=(e,t)=>{for(const n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},_lightsNodeRef=new WeakMap,_hashData=[];class LightsNode extends Node{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=property("vec3","totalDiffuse"),this.totalSpecularNode=property("vec3","totalSpecular"),this.outgoingLightNode=property("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n<e.length;n++){const t=e[n];if(_hashData.push(t.id),_hashData.push(t.castShadow?1:0),t.isSpotLight===!0){const e=t.map!==null?t.map.id:-1,n=t.colorNode?t.colorNode.getCacheKey():-1;_hashData.push(e,n)}}const t=hashArray(_hashData);return _hashData.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const e of this._lightNodes)t.push(e.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,s=sortLights(this._lights),o=e.renderer.library;for(const e of s)if(e.isNode)t.push(nodeObject(e));else{let s=null;if(n!==null&&(s=getLightNodeById(e.id,n)),s===null){const s=o.getLightNodeClass(e.constructor);if(s===null){warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let n=null;_lightsNodeRef.has(e)?n=_lightsNodeRef.get(e):(n=new s(e),_lightsNodeRef.set(e,n)),t.push(n)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.direct({...n,lightNode:t,reflectedLight:o},e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.directRectArea({...n,lightNode:t,reflectedLight:o},e)}setupLights(e,t){for(const n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const i=e.lightsNode;e.lightsNode=this;let t=this.outgoingLightNode;const n=e.context,s=n.lightingModel,o=e.getNodeProperties(this);if(s){const{totalDiffuseNode:r,totalSpecularNode:c}=this;n.outgoingLight=t;const d=e.addStack();o.nodes=d.nodes,s.start(e);const{backdrop:a,backdropAlpha:l}=n,{directDiffuse:u,directSpecular:h,indirectDiffuse:m,indirectSpecular:f}=n.reflectedLight;let i=u.add(m);a!==null&&(l!==null?i=vec3(l.mix(i,a)):i=vec3(a)),r.assign(i),c.assign(h.add(f)),t.assign(r.add(c)),s.finish(e),t=t.bypass(e.removeStack())}else o.nodes=[];return e.lightsNode=i,t}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class ShadowBaseNode extends Node{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=NodeUpdateType.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){shadowPositionWorld.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||positionWorld)}}shadowPositionWorld=property("vec3","shadowPositionWorld");function saveRendererState(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace
65=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Color),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function resetRendererState(e,t){return t=saveRendererState(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function restoreRendererState(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function saveSceneState(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function resetSceneState(e,t){return t=saveSceneState(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function restoreSceneState(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function resetRendererAndSceneState(e,t,n){return n=resetRendererState(e,n),n=resetSceneState(t,n),n}function restoreRendererAndSceneState(e,t,n){restoreRendererState(e,n),restoreSceneState(t,n)}shadowMaterialLib=new WeakMap,BasicShadowFilter=Fn(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let s=texture(e,t.xy).setName("t_basic");return e.isArrayTexture&&(s=s.depth(n)),s.compare(t.z)}),PCFShadowFilter=Fn(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:s})=>{const o=(t,n)=>{let o=texture(e,t);return e.isArrayTexture&&(o=o.depth(s)),o.compare(n)},r=reference("mapSize","vec2",n).setGroup(renderGroup),c=reference("radius","float",n).setGroup(renderGroup),l=vec2(1).div(r),i=c.mul(l.x),a=interleavedGradientNoise(screenCoordinate.xy).mul(6.28318530718);return add(o(t.xy.add(vogelDiskSample(0,5,a).mul(i)),t.z),o(t.xy.add(vogelDiskSample(1,5,a).mul(i)),t.z),o(t.xy.add(vogelDiskSample(2,5,a).mul(i)),t.z),o(t.xy.add(vogelDiskSample(3,5,a).mul(i)),t.z),o(t.xy.add(vogelDiskSample(4,5,a).mul(i)),t.z)).mul(1/5)}),PCFSoftShadowFilter=Fn(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:s})=>{const i=(t,n)=>{let o=texture(e,t);return e.isArrayTexture&&(o=o.depth(s)),o.compare(n)},d=reference("mapSize","vec2",n).setGroup(renderGroup),l=vec2(1).div(d),a=l.x,r=l.y,o=t.xy,c=fract(o.mul(d).add(.5));return o.subAssign(c.mul(l)),add(i(o,t.z),i(o.add(vec2(a,0)),t.z),i(o.add(vec2(0,r)),t.z),i(o.add(l),t.z),mix(i(o.add(vec2(a.negate(),0)),t.z),i(o.add(vec2(a.mul(2),0)),t.z),c.x),mix(i(o.add(vec2(a.negate(),r)),t.z),i(o.add(vec2(a.mul(2),r)),t.z),c.x),mix(i(o.add(vec2(0,r.negate())),t.z),i(o.add(vec2(0,r.mul(2))),t.z),c.y),mix(i(o.add(vec2(a,r.negate())),t.z),i(o.add(vec2(a,r.mul(2))),t.z),c.y),mix(mix(i(o.add(vec2(a.negate(),r.negate())),t.z),i(o.add(vec2(a.mul(2),r.negate())),t.z),c.x),mix(i(o.add(vec2(a.negate(),r.mul(2))),t.z),i(o.add(vec2(a.mul(2),r.mul(2))),t.z),c.x),c.y)).mul(1/9)}),VSMShadowFilter=Fn(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let s=texture(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(n)),s=s.rg;const i=s.x,a=max$1(1e-7,s.y.mul(s.y)),r=step(t.z,i);If(r.equal(1),()=>float(1));const c=t.z.sub(i);let o=a.div(a.add(c.mul(c)));return o=clamp2(sub(o,.3).div(.65)),max$1(r,o)}),linearDistance=Fn(([e,t,n])=>{let s=positionWorld.sub(e).length();return s=s.sub(t).div(n.sub(t)),s=s.saturate(),s}),linearShadowDistance=e=>{const t=e.shadow.camera,n=reference("near","float",t).setGroup(renderGroup),s=reference("far","float",t).setGroup(renderGroup),o=objectPosition(e);return linearDistance(o,n,s)},getShadowMaterial=e=>{let t=shadowMaterialLib.get(e);if(t===0[0]){const n=e.isPointLight?linearShadowDistance(e):null;t=new NodeMaterial,t.colorNode=vec4(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,shadowMaterialLib.set(e,t)}return t},disposeShadowMaterial=e=>{const t=shadowMaterialLib.get(e);t!==0[0]&&(t.dispose(),shadowMaterialLib.delete(e))},_shadowRenderObjectLibrary=new ChainMap,_shadowRenderObjectKeys=[],getShadowRenderObjectFunction=(e,t,n,s)=>{_shadowRenderObjectKeys[0]=e,_shadowRenderObjectKeys[1]=t;let o=_shadowRenderObjectLibrary.get(_shadowRenderObjectKeys);return(o===0[0]||o.shadowType!==n||o.useVelocity!==s)&&(o=(o,i,a,r,c,l,...d)=>{(o.castShadow===!0||o.receiveShadow&&n===VSMShadowMap)&&(s&&(getDataFromObject(o).useVelocity=!0),o.onBeforeShadow(e,o,a,t.camera,r,i.overrideMaterial,l),e.renderObject(o,i,a,r,c,l,...d),o.onAfterShadow(e,o,a,t.camera,r,i.overrideMaterial,l))},o.shadowType=n,o.useVelocity=s,_shadowRenderObjectLibrary.set(_shadowRenderObjectKeys,o)),_shadowRenderObjectKeys[0]=null,_shadowRenderObjectKeys[1]=null,o}
vendor: 3,074 bytes, line 65
65,VSMPassVertical=Fn(({samples:e,radius:t,size:n,shadowPass:s,depthLayer:o})=>{const i=float(0).toVar("meanVertical"),a=float(0).toVar("squareMeanVertical"),r=e.lessThanEqual(float(1)).select(float(0),float(2).div(e.sub(1))),c=e.lessThanEqual(float(1)).select(float(0),float(-1));Loop({start:int(0),end:int(e),type:"int",condition:"<"},({i:e})=>{const d=c.add(float(e).mul(r));let l=s.sample(add(screenCoordinate.xy,vec2(0,d).mul(t)).div(n));s.value.isArrayTexture&&(l=l.depth(o)),l=l.x,i.addAssign(l),a.addAssign(l.mul(l))}),i.divAssign(e),a.divAssign(e);const l=sqrt(a.sub(i.mul(i)).max(0));return vec2(i,l)}),VSMPassHorizontal=Fn(({samples:e,radius:t,size:n,shadowPass:s,depthLayer:o})=>{const i=float(0).toVar("meanHorizontal"),a=float(0).toVar("squareMeanHorizontal"),r=e.lessThanEqual(float(1)).select(float(0),float(2).div(e.sub(1))),c=e.lessThanEqual(float(1)).select(float(0),float(-1));Loop({start:int(0),end:int(e),type:"int",condition:"<"},({i:e})=>{const d=c.add(float(e).mul(r));let l=s.sample(add(screenCoordinate.xy,vec2(d,0).mul(t)).div(n));s.value.isArrayTexture&&(l=l.depth(o)),i.addAssign(l.x),a.addAssign(add(l.y.mul(l.y),l.x.mul(l.x)))}),i.divAssign(e),a.divAssign(e);const l=sqrt(a.sub(i.mul(i)).max(0));return vec2(i,l)}),_shadowFilterLib=[BasicShadowFilter,PCFShadowFilter,PCFSoftShadowFilter,VSMShadowFilter],_quadMesh=new QuadMesh;class ShadowNode extends ShadowBaseNode{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._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:s,shadow:o,depthLayer:i}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),r=t({depthTexture:n,shadowCoord:s,shadow:o,depthLayer:i});return a.select(r,float(1))}setupShadowCoord(e,t){const{shadow:o}=this,{renderer:i}=e,a=reference("bias","float",o).setGroup(renderGroup);let n=t,s;if(o.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)n=n.xyz.div(n.w),s=n.z,i.coordinateSystem===WebGPUCoordinateSystem&&(s=s.mul(2).sub(1));else{const e=n.w;n=n.xy.div(e);const t=reference("near","float",o.camera).setGroup(renderGroup),i=reference("far","float",o.camera).setGroup(renderGroup);s=viewZToLogarithmicDepth(e.negate(),t,i)}return n=vec3(n.x,n.y.oneMinus(),s.add(a)),n}getShadowFilterFn(e){return _shadowFilterLib[e]}setupRenderTarget(e,t){const n=new DepthTexture(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=LessCompare;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=n,{shadowMap:s,depthTexture:n}}setupShadow(e){const{renderer:l,camera:v}=e,{light:p,shadow:t}=this,r=l.shadowMap.type,{depthTexture:o,shadowMap:n}=this.setupRenderTarget(t,e);
vendor: 7,513 bytes, line 65
65if(t.camera.coordinateSystem=v.coordinateSystem,t.camera.updateProjectionMatrix(),r===VSMShadowMap&&t.isPointLightShadow!==!0){o.compareFunction=null,n.depth>1?(n._vsmShadowMapVertical||(n._vsmShadowMapVertical=e.createRenderTarget(t.mapSize.width,t.mapSize.height,{format:RGFormat,type:HalfFloatType,depth:n.depth,depthBuffer:!1}),n._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=n._vsmShadowMapVertical,n._vsmShadowMapHorizontal||(n._vsmShadowMapHorizontal=e.createRenderTarget(t.mapSize.width,t.mapSize.height,{format:RGFormat,type:HalfFloatType,depth:n.depth,depthBuffer:!1}),n._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=n._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(t.mapSize.width,t.mapSize.height,{format:RGFormat,type:HalfFloatType,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(t.mapSize.width,t.mapSize.height,{format:RGFormat,type:HalfFloatType,depthBuffer:!1}));let i=texture(o);o.isArrayTexture&&(i=i.depth(this.depthLayer));let a=texture(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(a=a.depth(this.depthLayer));const r=reference("blurSamples","float",t).setGroup(renderGroup),c=reference("radius","float",t).setGroup(renderGroup),l=reference("mapSize","vec2",t).setGroup(renderGroup);let s=this.vsmMaterialVertical||(this.vsmMaterialVertical=new NodeMaterial);s.fragmentNode=VSMPassVertical({samples:r,radius:c,size:l,shadowPass:i,depthLayer:this.depthLayer}).context(e.getSharedContext()),s.name="VSMVertical",s=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new NodeMaterial),s.fragmentNode=VSMPassHorizontal({samples:r,radius:c,size:l,shadowPass:a,depthLayer:this.depthLayer}).context(e.getSharedContext()),s.name="VSMHorizontal"}const h=reference("intensity","float",t).setGroup(renderGroup),d=reference("normalBias","float",t).setGroup(renderGroup),u=lightShadowMatrix(p).mul(shadowPositionWorld.add(normalWorld.mul(d))),i=this.setupShadowCoord(e,u),c=t.filterNode||this.getShadowFilterFn(l.shadowMap.type)||null;if(c===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const m=r===VSMShadowMap&&t.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,f=this.setupShadowFilter(e,{filterFn:c,shadowTexture:n.texture,depthTexture:m,shadowCoord:i,shadow:t,depthLayer:this.depthLayer});let s;n.texture.isCubeTexture?s=cubeTexture(n.texture,i.xyz):(s=texture(n.texture,i),o.isArrayTexture&&(s=s.depth(this.depthLayer)));const g=mix(1,f.rgb.mix(s,1),h.mul(s.a)).toVar();this.shadowMap=n,this.shadow.map=n;const a=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return g.toInspector(`${a} / Color`,()=>this.shadowMap.texture.isCubeTexture?cubeTexture(this.shadowMap.texture):texture(this.shadowMap.texture)).toInspector(`${a} / Depth`,()=>this.shadowMap.texture.isCubeTexture?cubeTexture(this.shadowMap.texture).r.oneMinus():textureLoad(this.shadowMap.depthTexture,uv$1().mul(textureSize(texture(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled===!1)return;return Fn(()=>{const n=e.renderer.shadowMap.type;this._currentShadowType!==n&&(this._reset(),this._node=null);let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e),this._currentShadowType=n),e.material.shadowNode&&warn('NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:o,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),o.setSize(t.mapSize.width,t.mapSize.height,o.depth);const a=n.name;n.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,i.render(n,t.camera),n.name=a}updateShadow(e){const{shadowMap:o,light:r,shadow:n}=this,{renderer:t,scene:s,camera:c}=e,i=t.shadowMap.type,l=o.depthTexture.version;this._depthVersionCached=l;const d=n.camera.layers.mask;(n.camera.layers.mask&4294967294)===0&&(n.camera.layers.mask=c.layers.mask);const u=t.getRenderObjectFunction(),a=t.getMRT(),h=!!a&&a.has("velocity");_rendererState=resetRendererAndSceneState(t,s,_rendererState),s.overrideMaterial=getShadowMaterial(r),t.setRenderObjectFunction(getShadowRenderObjectFunction(t,n,i,h)),t.setClearColor(0,0),t.setRenderTarget(o),this.renderShadow(e),t.setRenderObjectFunction(u),i===VSMShadowMap&&n.isPointLightShadow!==!0&&this.vsmPass(t),n.camera.layers.mask=d,restoreRendererAndSceneState(t,s,_rendererState)}vsmPass(e){const{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),_quadMesh.material=this.vsmMaterialVertical,_quadMesh.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),_quadMesh.material=this.vsmMaterialHorizontal,_quadMesh.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,disposeShadowMaterial(this.light),this.shadowMap&&(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)}updateBefore(e){const{shadow:t}=this;let 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))}}shadow=(e,t)=>new ShadowNode(e,t),_clearColor$1=new Color,_projScreenMatrix$12=new Matrix4,_lightPositionWorld2=new Vector3,_lookTarget2=new Vector3,_cubeDirectionsWebGPU=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,-1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)],_cubeUpsWebGPU=[new Vector3(0,-1,0),new Vector3(0,-1,0),new Vector3(0,0,-1),new Vector3(0,0,1),new Vector3(0,-1,0),new Vector3(0,-1,0)],_cubeDirectionsWebGL=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,1,0),new Vector3(0,-1,0),new Vector3(0,0,1),new Vector3(0,0,-1)],_cubeUpsWebGL=[new Vector3(0,-1,0),new Vector3(0,-1,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,-1,0),new Vector3(0,-1,0)],BasicPointShadowFilter=Fn(({depthTexture:e,bd3D:t,dp:n})=>cubeTexture(e,t).compare(n)),PointShadowFilter=Fn(({depthTexture:e,bd3D:t,dp:n,shadow:s})=>{const f=reference("radius","float",s).setGroup(renderGroup),p=reference("mapSize","vec2",s).setGroup(renderGroup),i=f.div(p.x),c=abs(t),o=normalize2(cross(t,c.x.greaterThan(c.z).select(vec3(0,1,0),vec3(1,0,0)))),a=cross(t,o),r=interleavedGradientNoise(screenCoordinate.xy).mul(6.28318530718),l=vogelDiskSample(0,5,r),d=vogelDiskSample(1,5,r),u=vogelDiskSample(2,5,r),h=vogelDiskSample(3,5,r),m=vogelDiskSample(4,5,r);return cubeTexture(e,t.add(o.mul(l.x).add(a.mul(l.y)).mul(i))).compare(n).add(cubeTexture(e,t.add(o.mul(d.x).add(a.mul(d.y)).mul(i))).compare(n)).add(cubeTexture(e,t.add(o.mul(u.x).add(a.mul(u.y)).mul(i))).compare(n)).add(cubeTexture(e,t.add(o.mul(h.x).add(a.mul(h.y)).mul(i))).compare(n)).add(cubeTexture(e,t.add(o.mul(m.x).add(a.mul(m.y)).mul(i))).compare(n)).mul(1/5)}),pointShadowFilter=Fn(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:s})=>{const a=n.xyz.toVar(),o=a.length(),i=uniform("float").setGroup(renderGroup).onRenderUpd
vendor: 5,360 bytes, line 65
65ate(()=>s.camera.near),r=uniform("float").setGroup(renderGroup).onRenderUpdate(()=>s.camera.far),l=reference("bias","float",s).setGroup(renderGroup),c=float(1).toVar();return If(o.sub(r).lessThanEqual(0).and(o.sub(i).greaterThanEqual(0)),()=>{const n=o.sub(i).div(r.sub(i)).toVar();n.addAssign(l);const d=a.normalize();c.assign(e({depthTexture:t,bd3D:d,dp:n,shadow:s}))}),c});class PointShadowNode extends ShadowNode{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===BasicShadowMap?BasicPointShadowFilter:PointShadowFilter}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:s,shadow:o}){return pointShadowFilter({filterFn:t,depthTexture:n,shadowCoord:s,shadow:o})}setupRenderTarget(e,t){const n=new CubeDepthTexture(e.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=LessCompare;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=n,{shadowMap:s,depthTexture:n}}renderShadow(e){const{shadow:s,shadowMap:r,light:o}=this,{renderer:n,scene:i}=e,t=s.camera,c=s.matrix,a=n.coordinateSystem===WebGPUCoordinateSystem,l=a?_cubeDirectionsWebGPU:_cubeDirectionsWebGL,d=a?_cubeUpsWebGPU:_cubeUpsWebGL;r.setSize(s.mapSize.width,s.mapSize.width);const u=n.autoClear,h=n.getClearColor(_clearColor$1),m=n.getClearAlpha();n.autoClear=!1,n.setClearColor(s.clearColor,s.clearAlpha);for(let e=0;e<6;e++){n.setRenderTarget(r,e),n.clear();const a=o.distance||t.far;a!==t.far&&(t.far=a,t.updateProjectionMatrix()),_lightPositionWorld2.setFromMatrixPosition(o.matrixWorld),t.position.copy(_lightPositionWorld2),_lookTarget2.copy(t.position),_lookTarget2.add(l[e]),t.up.copy(d[e]),t.lookAt(_lookTarget2),t.updateMatrixWorld(),c.makeTranslation(-_lightPositionWorld2.x,-_lightPositionWorld2.y,-_lightPositionWorld2.z),_projScreenMatrix$12.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),s._frustum.setFromProjectionMatrix(_projScreenMatrix$12,t.coordinateSystem,t.reversedDepth);const u=i.name;i.name=`Point Light Shadow [ ${o.name||"ID: "+o.id} ] - Face ${e+1}`,n.render(i,t),i.name=u}n.autoClear=u,n.setClearColor(h,m)}}pointShadow=(e,t)=>new PointShadowNode(e,t);class AnalyticLightNode extends LightingNode{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Color,this.colorNode=e&&e.colorNode||uniform(this.color).setGroup(renderGroup),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=NodeUpdateType.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return lightViewPosition(this.light).sub(e.context.positionView||positionView)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return shadow(this.light)}setupShadow(e){const{renderer:n}=e;if(n.shadowMap.enabled===!1)return;let t=this.shadowColorNode;if(t===null){const n=this.light.shadow.shadowNode;let e;n!==0[0]?e=nodeObject(n):e=this.setupShadowNode(),this.shadowNode=e,this.shadowColorNode=t=this.colorNode.mul(e),this.baseColorNode=this.colorNode}e.context.getShadow&&(t=e.context.getShadow(this,e)),this.colorNode=t}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);const t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}getDistanceAttenuation=Fn(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{const s=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)}),directPointLight=({color:e,lightVector:t,cutoffDistance:n,decayExponent:s})=>{const o=t.normalize(),i=t.length(),a=getDistanceAttenuation({lightDistance:i,cutoffDistance:n,decayExponent:s}),r=e.mul(a);return{lightDirection:o,lightColor:r}};class PointLightNode extends AnalyticLightNode{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=uniform(0).setGroup(renderGroup),this.decayExponentNode=uniform(2).setGroup(renderGroup)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return pointShadow(this.light)}setupDirect(e){return directPointLight({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}shapeCircle=Fn(([e=uv$1()],{renderer:t,material:n})=>{const s=lengthSq(e.mul(2).sub(1));let o;if(n.alphaToCoverage&&t.currentSamples>0){const e=float(s.fwidth()).toVar();o=smoothstep2(e.oneMinus(),e.add(1),s).oneMinus()}else o=select(s.greaterThan(1),0,1);return o}
65),getShIrradianceAt=Fn(([e,t])=>{const{x:s,y:o,z:i}=e;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(2*.511664).mul(o)),n=n.add(t.element(2).mul(2*.511664).mul(i)),n=n.add(t.element(3).mul(2*.511664).mul(s)),n=n.add(t.element(4).mul(2*.429043).mul(s).mul(o)),n=n.add(t.element(5).mul(2*.429043).mul(o).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(2*.429043).mul(s).mul(i)),n=n.add(t.element(8).mul(.429043).mul(mul(s,s).sub(mul(o,o)))),n}),_clearColor=new Color4;class Background extends DataMap{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const s=this.renderer,o=this.nodes.getBackgroundNode(e)||e.background;let i=!1;if(o===null)s._clearColor.getRGB(_clearColor),_clearColor.a=s._clearColor.a;else if(o.isColor===!0)o.getRGB(_clearColor),_clearColor.a=1,i=!0;else if(o.isNode===!0){const i=this.get(e),a=o;_clearColor.copy(s._clearColor);let n=i.backgroundMesh;if(n===0[0]){let s=function(){o.removeEventListener("dispose",s),n.material.dispose(),n.geometry.dispose()};const r=vec4(a).mul(backgroundIntensity).context({getUV:()=>backgroundRotation.mul(normalWorldGeometry),getTextureLevel:()=>backgroundBlurriness}
65),c=cameraProjectionMatrix.element(3).element(3).equal(1),l=div(1,cameraProjectionMatrix.element(1).element(1)).mul(3),d=c.select(positionLocal.mul(l),positionLocal);let t=cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(d,0)));t=t.setZ(t.w);const e=new NodeMaterial;e.name="Background.material",e.side=BackSide,e.depthTest=!1,e.depthWrite=!1,e.allowOverride=!1,e.fog=!1,e.lights=!1,e.vertexNode=t,e.colorNode=r,i.backgroundMeshNode=r,i.backgroundMesh=n=new Mesh(new SphereGeometry(1,32,32),e),n.frustumCulled=!1,n.name="Background.mesh",o.addEventListener("dispose",s)}const r=a.getCacheKey();i.backgroundCacheKey!==r&&(i.backgroundMeshNode.node=vec4(a).mul(backgroundIntensity),i.backgroundMeshNode.needsUpdate=!0,n.material.needsUpdate=!0,i.backgroundCacheKey=r),t.unshift(n,n.geometry,n.material,0,0,null,null)}else error("Renderer: Unsupported background configuration.",o);const a=s.xr.getEnvironmentBlendMode();if(a==="additive"?_clearColor.set(0,0,0,1):a==="alpha-blend"&&_clearColor.set(0,0,0,0),s.autoClear===!0||i===!0){const e=n.clearColorValue;e.r=_clearColor.r,e.g=_clearColor.g,e.b=_clearColor.b,e.a=_clearColor.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=s._clearDepth,n.stencilClearValue=s._clearStencil,n.clearColor=s.autoClearColor===!0,n.clearDepth=s.autoClearDepth===!0,n.clearStencil=s.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}_id$7=0;class BindGroup{constructor(e="",t=[],n=0,s=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=s,this.id=_id$7++}}class NodeBuilderState{constructor(e,t,n,s,o,i,a,r,c,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=l,this.nodeAttributes=s,this.bindings=o,this.updateNodes=i,this.updateBeforeNodes=a,this.updateAfterNodes=r,this.observer=c,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){const n=t.bindings[0].groupNode.shared;if(n!==!0){const n=new BindGroup(t.name,[],t.index,t.bindingsReference);e.push(n);for(const e of t.bindings)n.bindings.push(e.clone())}else e.push(t)}return e}}class NodeAttribute{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class NodeUniform{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}}class NodeVar{constructor(e,t,n=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=s}}class NodeVarying extends NodeVar{constructor(e,t,n=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=s}}class NodeCode{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}_id$6=0;class NodeCache{constructor(e=null){this.id=_id$6++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===0[0]&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class StructType{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Uniform2{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}}class NumberUniform extends Uniform2{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Vector2Uniform extends Uniform2{constructor(e,t=new Vector2){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Vector3Uniform extends Uniform2{constructor(e,t=new Vector3){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Vector4Uniform extends Uniform2{constructor(e,t=new Vector4){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class ColorUniform extends Uniform2{constructor(e,t=new Color){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Matrix2Uniform extends Uniform2{constructor(e,t=new Matrix2){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class Matrix3Uniform extends Uniform2{constructor(e,t=new Matrix3){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class Matrix4Uniform extends Uniform2{constructor(e,t=new Matrix4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class NumberNodeUniform extends NumberUniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vector2NodeUniform extends Vector2Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vector3NodeUniform extends Vector3Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vector4NodeUniform extends Vector4Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ColorNodeUniform extends ColorUniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}
65class Matrix2NodeUniform extends Matrix2Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Matrix3NodeUniform extends Matrix3Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Matrix4NodeUniform extends Matrix4Uniform{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}_id$5=0,sharedNodeData=new WeakMap,rendererCache=new WeakMap,typeFromArray=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),toFloat=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e),e+(e%1?"":".0"));class NodeBuilder{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=stack(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new NodeCache,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:_id$5++})}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===NormalBlending&&e.alphaToCoverage===!1}getBindGroupsCache(){let e=rendererCache.get(this.renderer);return e===0[0]&&(e=new ChainMap,rendererCache.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new RenderTarget(e,t,n)}createCubeRenderTarget(e,t){return new CubeRenderTarget(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const i=this.getBindGroupsCache(),n=[];let o=!0;for(const e of t)n.push(e),o=o&&e.groupNode.shared!==!0;let s;return o?(s=i.get(n),s===0[0]&&(s=new BindGroup(e,n,this.bindingsIndexes[e].group,n),i.set(n,s))):s=new BindGroup(e,n,this.bindingsIndexes[e].group,n),s}getBindGroupArray(e,t){const s=this.bindings[t];let n=s[e];return n===0[0]&&(this.bindingsIndexes[e]===0[0]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=n=[]),n}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const e of shaderStages)for(const s in n[e]){const o=n[e][s],i=t[s]||(t[s]=[]);i.push(...o)}e=[];for(const n in t){const s=t[n],o=this._getBindGroup(n,s);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType();t!==NodeUpdateType.NONE&&this.updateNodes.push(e)}for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==NodeUpdateType.NONE&&this.updateBeforeNodes.push(e),n!==NodeUpdateType.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===LinearFilter||e.magFilter===LinearMipmapNearestFilter||e.magFilter===NearestMipmapLinearFilter||e.magFilter===LinearMipmapLinearFilter||e.minFilter===LinearFilter||e.minFilter===LinearMipmapNearestFilter||e.minFilter===NearestMipmapLinearFilter||e.minFilter===LinearMipmapLinearFilter}addChain(e){this.chaining.push(e)}removeChain(e){const t=this.chaining.pop();if(t!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){const t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){const e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);
65return n.cache===0[0]&&(n.cache=new NodeCache(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){warn("Abstract function.")}getInstanceIndex(){warn("Abstract function.")}getDrawIndex(){warn("Abstract function.")}getFrontFacing(){warn("Abstract function.")}getFragCoord(){warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===0[0]?1:t.usageCount+1,t.usageCount}generateTexture(){warn("Abstract function.")}generateTextureLod(){warn("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,n=null){let s=this.generateArrayDeclaration(e,t)+"( ";for(let o=0;o<t;o++){const i=n?n[o]:null;i!==null?s+=i.build(this,e):s+=this.generateConst(e),o<t-1&&(s+=", ")}return s+=" )",s}generateStruct(e,t,n=null){const s=[];for(const i of t){const{name:e,type:o}=i;n&&n[e]&&n[e].isNode?s.push(n[e].build(this,o)):s.push(this.generateConst(o))}return e+"( "+s.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new Color:e==="vec2"||e==="uvec2"||e==="ivec2"?t=new Vector2:e==="vec3"||e==="uvec3"||e==="ivec3"?t=new Vector3:(e==="vec4"||e==="uvec4"||e==="ivec4")&&(t=new Vector4)),e==="float")return toFloat(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}
65( ${toFloat(t.r)}, ${toFloat(t.g)}, ${toFloat(t.b)} )`;const s=this.getTypeLength(e),o=this.getComponentType(e),n=e=>this.generateConst(o,e);if(s===2)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)} )`;if(s===3)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)} )`;if(s===4&&e!=="mat2")return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)}, ${n(t.w)} )`;if(s>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(n).join(", ")} )`;if(s>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)!==0[0]}getAttribute(e,t){const s=this.attributes;for(const t of s)if(t.name===e)return t;const n=new NodeAttribute(e,t);return this.registerDeclaration(n),s.push(n),n}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){const t=e.type;if(e.isDataTexture){if(t===IntType)return"int";if(t===UnsignedIntType)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;const 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=getTypeFromLength(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),s+n}getTypeFromArray(e){return typeFromArray.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,o=e.itemSize,i=e.normalized;let n;return!(e instanceof Float16BufferAttribute)&&i!==!0&&(n=this.getTypeFromArray(s)),this.getTypeFromLength(o,n)}getTypeLength(e){const 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){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=stack(this.stack);const e=getCurrentStack();return this.stacks.push(e),setCurrentStack(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,setCurrentStack(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let s=n.getData(e);s===0[0]&&(s={},n.setData(e,s)),s[t]===0[0]&&(s[t]={});let o=s[t];const a=s.any?s.any.subBuilds:null,i=this.getClosestSubBuild(a);return i&&(o.subBuildsCache===0[0]&&(o.subBuildsCache={}),o=o.subBuildsCache[i]||(o.subBuildsCache[i]={}),o.subBuilds=a),o}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const s=this.getDataFromNode(e,"vertex");let n=s.bufferAttribute;if(n===0[0]){const o=this.uniforms.index++;n=new NodeAttribute("nodeAttribute"+o,t,e),this.bufferAttributes.push(n),s.bufferAttribute=n}return n}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}
vendor: 4,166 bytes, lines 65-66
65getStructTypeFromNode(e,t,n=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let o=i.structType;if(o===0[0]){const a=this.structs.index++;n===null&&(n="StructType"+a),o=new StructType(n,t),this.structs[s].push(o),this.types[s][n]=e,i.structType=o}return o}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,s=null){const i=this.getDataFromNode(e,n,this.globalCache);let o=i.uniform;if(o===0[0]){const a=this.uniforms.index++;o=new NodeUniform(s||"nodeUniform"+a,t,e),this.uniforms[n].push(o),this.registerDeclaration(o),i.uniform=o}return o}getVarFromNode(e,t=null,n=e.getNodeType(this),s=this.shaderStage,o=!1){const a=this.getDataFromNode(e,s),r=this.getSubBuildProperty("variable",a.subBuilds);let i=a[r];if(i===0[0]){const c=o?"_const":"_var",l=this.vars[s]||(this.vars[s]=[]),d=this.vars[c]||(this.vars[c]=0);t===null&&(t=(o?"nodeConst":"nodeVar")+d,this.vars[c]++),r!=="variable"&&(t=this.getSubBuildProperty(t,a.subBuilds));const u=e.getArrayCount(this);i=new NodeVar(t,n,o,u),o||l.push(i),this.registerDeclaration(i),a[r]=i}return i}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(e.values!==null)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,n=e.getNodeType(this),s=null,o=null){const a=this.getDataFromNode(e,"any"),r=this.getSubBuildProperty("varying",a.subBuilds);let i=a[r];if(i===0[0]){const e=this.varyings,c=e.length;t===null&&(t="nodeVarying"+c),r!=="varying"&&(t=this.getSubBuildProperty(t,a.subBuilds)),i=new NodeVarying(t,n,s,o),e.push(i),this.registerDeclaration(i),a[r]=i}return i}registerDeclaration(e){const s=this.shaderStage,o=this.declarations[s]||(this.declarations[s]={}),n=this.getPropertyName(e);let i=1,t=n;for(;o[t]!==0[0];)t=n+"_"+i++;i>1&&(e.name=t,warn(`TSL: Declaration name '${n}' of '${e.type}' already in use. Renamed to '${t}'.`)),o[t]=e}getCodeFromNode(e,t,n=this.shaderStage){const o=this.getDataFromNode(e);let s=o.code;if(s===0[0]){const e=this.codes[n]||(this.codes[n]=[]),i=e.length;s=new NodeCode("nodeCode"+i,t),e.push(s),o.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:o,flowCodeBlock:i}=this.getDataFromNode(e);let s=!0,n=t;for(;n;){if(i.get(n)===!0){s=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(s)for(const e of o)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){const s=this.getDataFromNode(e),o=s.flowCodes||(s.flowCodes=[]),i=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);o.push(t),i.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+`; 66`),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){const n=e.getNodeType(this),t=this.flowChildNode(e,n);return this.flowsData.set(e,t),t}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new FunctionNode,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)n[e.name]=new ParameterNode(e.type,e.name);e.layout=null;const s=e.call(n),o=this.flowStagesNode(s,t.type);return e.layout=t,o}flowBuildStage(e,t,n=null){const s=this.getBuildStage();this.setBuildStage(t);const o=e.build(this,n);return this.setBuildStage(s),o}flowStagesNode(e,t=null){const s=this.flow,o=this.vars,i=this.declarations,a=this.cache,r=this.buildStage,c=this.stack,n={code:""};this.flow=n,this.vars={},this.declarations={}
66,this.cache=new NodeCache,this.stack=stack();for(const s of defaultBuildStages)this.setBuildStage(s),n.result=e.build(this,t);return n.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=o,this.declarations=i,this.cache=a,this.stack=c,this.setBuildStage(r),n}getFunctionOperator(){return null}buildFunctionCode(){warn("Abstract function.")}flowChildNode(e,t=null){const s=this.flow,n={code:""};return this.flow=n,n.result=e.build(this,t),this.flow=s,n}flowNodeFromShaderStage(e,t,n=null,s=null){const a=this.tab,r=this.cache,c=this.shaderStage,l=this.context;this.setShaderStage(e);const i={...this.context};delete i.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=i;let o=null;if(this.buildStage==="generate"){const i=this.flowChildNode(t,n);s!==null&&(i.code+=`${this.tab+s} = ${i.result}; 67`),this.flowCode[e]=this.flowCode[e]+i.code,o=i}else o=t.build(this);return this.setShaderStage(c),this.cache=r,this.tab=a,this.context=l,o}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){warn("Abstract function.")}getVaryings(){warn("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==0[0])for(const e of n)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==0[0])for(const e of t)n+=e.code+` 68`;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(){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;const n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const s=t[e];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 s;return n?s=e?n+"_"+e:n:s=e,s}build(){const{object:t,material:e,renderer:n}=this;if(e!==null){let t=n.library.fromMaterial(e);t===null&&(error(`NodeMaterial: Material "${e.type}" is not compatible.`),t=new NodeMaterial),t.build(this)}else this.addFlow("compute",t);for(const e of defaultBuildStages){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of shaderStages){this.setShaderStage(t);const n=this.flowNodes[t];for(const t of n)e==="generate"?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=sharedNodeData.get(e);return t===0[0]&&(t={}),t}getNodeUniform(e,t){const s=this.getSharedDataFromNode(e);let n=s.cache;if(n===0[0]){if(t==="float"||t==="int"||t==="uint")n=new NumberNodeUniform(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")n=new Vector2NodeUniform(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")n=new Vector3NodeUniform(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")n=new Vector4NodeUniform(e);else if(t==="color")n=new ColorNodeUniform(e);else if(t==="mat2")n=new Matrix2NodeUniform(e);else if(t==="mat3")n=new Matrix3NodeUniform(e);else if(t==="mat4")n=new Matrix4NodeUniform(e);else throw new Error(`Uniform "${t}" not implemented.`);s.cache=n}return n}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const o=this.getTypeLength(t),s=this.getTypeLength(n);return o===16&&s===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:o===9&&s===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:o>4?e:s>4||s===0?e:o===s?`${this.getType(n)}( ${e} )`:o>s?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),n)):s===4&&o>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:o===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(o===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${REVISION} - Node System 69`}}class NodeFrame{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===0[0]&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===NodeUpdateType.FRAME){{const t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){const n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}}else if(t===NodeUpdateType.RENDER){{const t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){const n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}}else t===NodeUpdateType.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===NodeUpdateType.FRAME){const t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===NodeUpdateType.RENDER){const t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===NodeUpdateType.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===NodeUpdateType.FRAME){const t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===NodeUpdateType.RENDER){const t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===NodeUpdateType.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===0[0]&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}
vendor: 4,687 bytes, line 69
69class NodeFunctionInput{constructor(e,t,n=null,s="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=s,this.isConst=o}}NodeFunctionInput.isNodeFunctionInput=!0;class DirectionalLightNode extends AnalyticLightNode{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode,t=lightTargetDirection(this.light);return{lightDirection:t,lightColor:e}}}_matrix41=new Matrix4,_matrix42=new Matrix4,_ltcLib=null;class RectAreaLightNode extends AnalyticLightNode{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=uniform(new Vector3).setGroup(renderGroup),this.halfWidth=uniform(new Vector3).setGroup(renderGroup),this.updateType=NodeUpdateType.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;_matrix42.identity(),_matrix41.copy(t.matrixWorld),_matrix41.premultiply(n),_matrix42.extractRotation(_matrix41),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(_matrix42),this.halfHeight.value.applyMatrix4(_matrix42)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=texture(_ltcLib.LTC_FLOAT_1),n=texture(_ltcLib.LTC_FLOAT_2)):(t=texture(_ltcLib.LTC_HALF_1),n=texture(_ltcLib.LTC_HALF_2));const{colorNode:s,light:o}=this,i=lightViewPosition(o);return{lightColor:s,lightPosition:i,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){_ltcLib=e}}class SpotLightNode extends AnalyticLightNode{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=uniform(0).setGroup(renderGroup),this.penumbraCosNode=uniform(0).setGroup(renderGroup),this.cutoffDistanceNode=uniform(0).setGroup(renderGroup),this.decayExponentNode=uniform(0).setGroup(renderGroup),this.colorNode=uniform(this.color).setGroup(renderGroup)}update(e){super.update(e);const{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){const{coneCosNode:n,penumbraCosNode:s}=this;return smoothstep2(n,s,t)}getLightCoord(e){const n=e.getNodeProperties(this);let t=n.projectionUV;return t===0[0]&&(t=lightProjectionUV(this.light,e.context.positionWorld),n.projectionUV=t),t}setupDirect(e){const{colorNode:u,cutoffDistanceNode:m,decayExponentNode:h,light:t}=this,i=this.getLightVector(e),a=i.normalize(),r=a.dot(lightTargetDirection(t)),c=this.getSpotAttenuation(e,r),l=i.length(),d=getDistanceAttenuation({lightDistance:l,cutoffDistance:m,decayExponent:h});let s=u.mul(c).mul(d),o,n;if(t.colorNode?(n=this.getLightCoord(e),o=t.colorNode(n)):t.map&&(n=this.getLightCoord(e),o=texture(t.map,n.xy).onRenderUpdate(()=>t.map)),o){const e=n.mul(2).sub(1).abs().lessThan(1).all();s=e.select(s.mul(o),s)}return{lightColor:s,lightDirection:a}}}class IESSpotLightNode extends SpotLightNode{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let s=null;if(n&&n.isTexture===!0){const e=t.acos().mul(1/Math.PI);s=texture(n,vec2(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}sdBox=Fn(([e,t])=>{const n=e.abs().sub(t);return length(max$1(n,0)).add(min$1(max$1(n.x,n.y),0))});class ProjectorLightNode extends SpotLightNode{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const n=float(0),s=this.penumbraCosNode,t=lightShadowMatrix(this.light).mul(e.context.positionWorld||positionWorld);return If(t.w.greaterThan(0),()=>{const e=t.xyz.div(t.w),o=sdBox(e.xy.sub(vec2(.5)),vec2(.5)),i=div(-1,sub(1,acos(s)).sub(1));n.assign(saturate(o.mul(-2).mul(i)))}),n}}class AmbientLightNode extends AnalyticLightNode{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class HemisphereLightNode extends AnalyticLightNode{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=lightPosition(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=uniform(new Color).setGroup(renderGroup)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:s}=this,o=normalWorld.dot(s),i=o.mul(.5).add(.5),a=mix(n,t,i);
69e.context.irradiance.addAssign(a)}}class LightProbeNode extends AnalyticLightNode{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new Vector3);this.lightProbe=uniformArray(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=getShIrradianceAt(normalWorld,this.lightProbe);e.context.irradiance.addAssign(t)}}class NodeParser{parseFunction(){warn("Abstract function.")}}class NodeFunction{constructor(e,t,n="",s=""){this.type=e,this.inputs=t,this.name=n,this.precision=s}getCode(){warn("Abstract function.")}}NodeFunction.isNodeFunction=!0,declarationRegexp$1=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,propertiesRegexp$1=/[a-z_0-9]+/ig,pragmaMain="#pragma main",parse$1=e=>{e=e.trim();const n=e.indexOf(pragmaMain),s=n!==-1?e.slice(n+pragmaMain.length):e,t=s.match(declarationRegexp$1);if(t!==null&&t.length===5){const a=t[4],i=[];let r=null;for(;(r=propertiesRegexp$1.exec(a))!==null;)i.push(r);const c=[];let o=0;for(;o<i.length;){const n=i[o][0]==="const";n===!0&&o++;let e=i[o][0];e==="in"||e==="out"||e==="inout"?o++:e="";const s=i[o++][0];let t=Number.parseInt(i[o][0]);Number.isNaN(t)===!1?o++:t=null;const a=i[o++][0];c.push(new NodeFunctionInput(s,a,t,e,n))}const l=s.substring(t[0].length),d=t[3]!==0[0]?t[3]:"",u=t[2],h=t[1]!==0[0]?t[1]:"",m=n!==-1?e.slice(0,n):"";return{type:u,inputs:c,name:d,precision:h,inputsCode:a,blockCode:l,headerCode:m}}throw new Error("FunctionNode: Function is not a GLSL code.")};class GLSLNodeFunction extends NodeFunction{constructor(e){const{type:t,inputs:n,name:s,precision:o,inputsCode:i,blockCode:a,headerCode:r}=parse$1(e);super(t,n,s,o),this.inputsCode=i,this.blockCode=a,this.headerCode=r}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:i,inputsCode:a,headerCode:r,precision:o}=this;let s=`${i} ${e} ( ${a.trim()} )`;o!==""&&(s=`${o} ${s}`),t=r+s+n}else t="";return t}}class GLSLNodeParser extends NodeParser{parseFunction(e){return new GLSLNodeFunction(e)}}_outputNodeMap=new WeakMap,_chainKeys$2=[],_cacheKeyValues=[];class Nodes extends DataMap{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new NodeFrame,this.nodeBuilderCache=new Map,this.callHashCache=new ChainMap,this.groupsData=new ChainMap,this.cacheLib={}}updateGroup(e){const t=e.groupNode,s=t.name;if(s===objectGroup.name)return!0;if(s===renderGroup.name){const t=this.get(e),n=this.nodeFrame.renderId;return t.renderId!==n&&(t.renderId=n,!0)}if(s===frameGroup.name){const t=this.get(e),n=this.nodeFrame.frameId;return t.frameId!==n&&(t.frameId=n,!0)}_chainKeys$2[0]=t,_chainKeys$2[1]=e;let n=this.groupsData.get(_chainKeys$2);return n===0[0]&&this.groupsData.set(_chainKeys$2,n={}),_chainKeys$2.length=0,n.version!==t.version&&(n.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const n=this.get(e);let t=n.nodeBuilderState;if(t===0[0]){const{nodeBuilderCache:s}=this,o=this.getForRenderCacheKey(e);if(t=s.get(o),t===0[0]){const i=t=>{const n=this.backend.createNodeBuilder(e.object,this.renderer);return n.scene=e.scene,n.material=t,n.camera=e.camera,n.context.material=t,n.lightsNode=e.lightsNode,n.environmentNode=this.getEnvironmentNode(e.scene),n.fogNode=this.getFogNode(e.scene),n.clippingContext=e.clippingContext,!!this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&n.enableMultiview(),n};let n=i(e.material);try{n.build()}catch(e){n=i(new NodeMaterial),n.build(),error("TSL: "+e)}t=this._createNodeBuilderState(n),s.set(o,t)}t.usedTimes++,n.nodeBuilderState=t}return t}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const n=this.get(e);let t=n.nodeBuilderState;if(t===0[0]){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),t=this._createNodeBuilderState(s),n.nodeBuilderState=t}return t}_createNodeBuilderState(e){return new NodeBuilderState(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}
vendor: 1,036 bytes, line 69
69getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){_chainKeys$2[0]=e,_chainKeys$2[1]=t;const s=this.renderer.info.calls,n=this.callHashCache.get(_chainKeys$2)||{};if(n.callId!==s){const o=this.getEnvironmentNode(e),i=this.getFogNode(e);t&&_cacheKeyValues.push(t.getCacheKey(!0)),o&&_cacheKeyValues.push(o.getCacheKey()),i&&_cacheKeyValues.push(i.getCacheKey()),_cacheKeyValues.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),_cacheKeyValues.push(this.renderer.shadowMap.enabled?1:0),_cacheKeyValues.push(this.renderer.shadowMap.type),n.callId=s,n.cacheKey=hashArray(_cacheKeyValues),this.callHashCache.set(_chainKeys$2,n),_cacheKeyValues.length=0}return _chainKeys$2.length=0,n.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}
69updateBackground(e){const n=this.get(e),t=e.background;if(t){{const s=e.backgroundBlurriness===0&&n.backgroundBlurriness>0||e.backgroundBlurriness>0&&n.backgroundBlurriness===0;if(n.background!==t||s){const o=this.getCacheNode("background",t,()=>{if(t.isCubeTexture===!0||t.mapping===EquirectangularReflectionMapping||t.mapping===EquirectangularRefractionMapping||t.mapping===CubeUVReflectionMapping){if(e.backgroundBlurriness>0||t.mapping===CubeUVReflectionMapping)return pmremTexture(t);let n;return t.isCubeTexture===!0?n=cubeTexture(t):n=texture(t),cubeMapNode(n)}else if(t.isTexture===!0)return texture(t,screenUV.flipY()).setUpdateMatrix(!0);else t.isColor!==!0&&error("WebGPUNodes: Unsupported background configuration.",t)},s);n.backgroundNode=o,n.background=t,n.backgroundBlurriness=e.backgroundBlurriness}}}else n.backgroundNode&&(delete n.backgroundNode,delete n.background)}getCacheNode(e,t,n,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let o=i.get(t);return(o===0[0]||s)&&(o=n(),i.set(t,o)),o}updateFog(e){const n=this.get(e),t=e.fog;if(t){if(n.fog!==t){const e=this.getCacheNode("fog",t,()=>{if(t.isFogExp2){const e=reference("color","color",t).setGroup(renderGroup),n=reference("density","float",t).setGroup(renderGroup);return fog(e,densityFogFactor(n))}if(t.isFog){const e=reference("color","color",t).setGroup(renderGroup),n=reference("near","float",t).setGroup(renderGroup),s=reference("far","float",t).setGroup(renderGroup);return fog(e,rangeFogFactor(n,s))}error("Renderer: Unsupported fog configuration.",t)});n.fogNode=e,n.fog=t}}else delete n.fogNode,delete n.fog}updateEnvironment(e){const n=this.get(e),t=e.environment;if(t){if(n.environment!==t){const e=this.getCacheNode("environment",t,()=>{if(t.isCubeTexture===!0)return cubeTexture(t);if(t.isTexture===!0)return texture(t);error("Nodes: Unsupported environment configuration.",t)});n.environmentNode=e,n.environment=t}}else n.environmentNode&&(delete n.environmentNode,delete n.environment)}getNodeFrame(e=this.renderer,t=null,n=null,s=null,o=null){const i=this.nodeFrame;return i.renderer=e,i.scene=t,i.object=n,i.camera=s,i.material=o,i}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){const t=_outputNodeMap.get(e);return t!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),s=e.isArrayTexture?texture3D(e,vec3(screenUV,builtin("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):texture(e,screenUV).renderOutput(t.toneMapping,t.currentColorSpace);return _outputNodeMap.set(e,n),s}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const e of n.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const e of n.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e),n=e.getMonitor();return n.needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new NodeFrame,this.nodeBuilderCache=new Map,this.cacheLib={}}}_plane=new Plane;class ClippingContext{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Matrix3,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){const s=e.length;for(let o=0;o<s;o++){_plane.copy(e[o]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const i=t[n+o],a=_plane.normal;i.x=-a.x,i.y=-a.y,i.z=-a.z,i.w=_plane.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let i=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const a=t.clippingPlanes,o=a.length;let n,s;if(this.clipIntersection?(n=this.intersectionPlanes,s=e.intersectionPlanes.length):(n=this.unionPlanes,s=e.unionPlanes.length),n.length!==s+o){n.length=s+o;for(let e=0;e<o;e++)n[s+e]=new Vector4;i=!0}this.projectPlanes(a,n,s),i&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}
69getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===0[0]&&(t=new ClippingContext(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class RenderBundle{constructor(e,t){this.bundleGroup=e,this.camera=t}}_chainKeys$1=[];class RenderBundles{constructor(){this.bundles=new ChainMap}get(e,t){const s=this.bundles;_chainKeys$1[0]=e,_chainKeys$1[1]=t;let n=s.get(_chainKeys$1);return n===0[0]&&(n=new RenderBundle(e,t),s.set(_chainKeys$1,n)),_chainKeys$1.length=0,n}dispose(){this.bundles=new ChainMap}}class NodeLibrary{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const n in e)t[n]=e[n]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);n.set(t,e)}}_defaultLights=new LightsNode,_chainKeys=[];class Lighting extends ChainMap{constructor(){super()}createNode(e=[]){return(new LightsNode).setLights(e)}getNode(e,t){if(e.isQuadMesh)return _defaultLights;_chainKeys[0]=e,_chainKeys[1]=t;let n=this.get(_chainKeys);return n===0[0]&&(n=this.createNode(),this.set(_chainKeys,n)),_chainKeys.length=0,n}}class XRRenderTarget extends RenderTarget{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}_cameraLPos=new Vector3,_cameraRPos=new Vector3;class XRManager extends EventDispatcher{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new PerspectiveCamera,this._cameraL.viewport=new Vector4,this._cameraR=new PerspectiveCamera,this._cameraR.viewport=new Vector4,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new ArrayCamera,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding!="undefined",this._frameBufferTargets=null,this._createXRLayer=createXRLayer.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new Vector2,this._onSessionEvent=onSessionEvent.bind(this),this._onSessionEnd=onSessionEnd.bind(this),this._onInputSourcesChange=onInputSourcesChange.bind(this),this._onAnimationFrame=onAnimationFrame.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){const t=this._getController(e);return t.getTargetRaySpace()}getControllerGrip(e){const t=this._getController(e);return t.getGripSpace()}getHand(e){const t=this._getController(e);return t.getHandSpace()}getFoveation(){if(this._glProjLayer===null&&this._glBaseLayer===null)return;return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==0[0]&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&warn("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&warn("XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,s,o,i,a,r={}){const h=new PlaneGeometry(e,t),d=new XRRenderTarget(o,i,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(o,i,r.stencil?UnsignedInt248Type:UnsignedIntType,0[0],0[0],0[0],0[0],0[0],0[0],r.stencil?DepthStencilFormat:DepthFormat),stencilBuffer:r.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});d._autoAllocateDepthBuffer=!0;const l=new MeshBasicMaterial({color:16777215,side:FrontSide});l.map=d.texture,l.map.offset.y=1,l.map.repeat.y=-1;const u=new Mesh(h,l);u.position.copy(n),u.quaternion.copy(s);const c={type:"quad",width:e,height:t,translation:n,quaternion:s,pixelwidth:o,pixelheight:i,plane:u,material:l,rendercall:a,renderTarget:d};if(this._layers.push(c),this._session!==null){c.plane.material=new MeshBasicMaterial({color:16777215,side:FrontSide}),c.plane.material.blending=CustomBlending,c.plane.material.blendEquation=AddEquation,c.plane.material.blendSrc=ZeroFactor,c.plane.material.blendDst=ZeroFactor,c.xrlayer=this._createXRLayer(c);const e=this._session.renderState.layers;e.unshift(c.xrlayer),this._session.updateRenderState({layers:e})}else d.isXRRenderTarget=!1;return u}createCylinderLayer(e,t,n,s,o,i,a,r,c={}){const m=new CylinderGeometry(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new XRRenderTarget(i,a,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(i,a,c.stencil?UnsignedInt248Type:UnsignedIntType,0[0],0[0],0[0],0[0],0[0],0[0],c.stencil?DepthStencilFormat:DepthFormat),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;const d=new MeshBasicMaterial({color:16777215,side:BackSide});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;const h=new Mesh(m,d);h.position.copy(s),h.quaternion.copy(o);
69const l={type:"cylinder",radius:e,centralAngle:t,aspectratio:n,translation:s,quaternion:o,pixelwidth:i,pixelheight:a,plane:h,material:d,rendercall:r,renderTarget:u};if(this._layers.push(l),this._session!==null){l.plane.material=new MeshBasicMaterial({color:16777215,side:BackSide}),l.plane.material.blending=CustomBlending,l.plane.material.blendEquation=AddEquation,l.plane.material.blendSrc=ZeroFactor,l.plane.material.blendDst=ZeroFactor,l.xrlayer=this._createXRLayer(l);const e=this._session.renderState.layers;e.unshift(l.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return h}renderLayers(){const n=new Vector3,s=new Quaternion,e=this._renderer,o=this.isPresenting,i=e.getOutputRenderTarget(),a=e._frameBufferTarget;this.isPresenting=!1;const t=new Vector2;e.getSize(t);const r=e._quad;for(const t of this._layers)if(t.renderTarget.isXRRenderTarget=this._session!==null,t.renderTarget._hasExternalTextures=t.renderTarget.isXRRenderTarget,t.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){t.xrlayer.transform=new XRRigidTransform(t.plane.getWorldPosition(n),t.plane.getWorldQuaternion(s));const i=this._glBinding.getSubImage(t.xrlayer,this._xrFrame);e.backend.setXRRenderTargetTextures(t.renderTarget,i.colorTexture,0[0]),e._setXRLayerSize(t.renderTarget.width,t.renderTarget.height),e.setOutputRenderTarget(t.renderTarget),e.setRenderTarget(null),e._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:o,quad:a}=this._frameBufferTargets.get(t.renderTarget)||{frameBufferTarget:null,quad:null};o?(e._frameBufferTarget=o,e._quad=a):(e._quad=new QuadMesh(new NodeMaterial),this._frameBufferTargets.set(t.renderTarget,{frameBufferTarget:e._getFrameBufferTarget(),quad:e._quad})),t.rendercall(),e._frameBufferTarget=null}else e.setRenderTarget(t.renderTarget),t.rendercall();e.setRenderTarget(null),e.setOutputRenderTarget(i),e._frameBufferTarget=a,e._setXRLayerSize(t.x,t.y),e._quad=r,this.isPresenting=o}getSession(){return this._session}async setSession(e){const t=this._renderer,s=t.backend;this._gl=t.getContext();const n=this._gl,o=n.getContextAttributes();if(this._session=e,e!==null){if(s.isWebGPUBackend===!0)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await s.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let i=null,a=null,r=null;t.depth&&(r=t.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,i=t.stencil?DepthStencilFormat:DepthFormat,a=t.stencil?UnsignedInt248Type:UnsignedIntType);const c={colorFormat:n.RGBA8,depthFormat:r,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(c.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const s=this._glBinding.createProjectionLayer(c),l=[s];this._glProjLayer=s,t.setPixelRatio(1),t._setXRLayerSize(s.textureWidth,s.textureHeight);const d=this._useMultiview?2:1,u=new DepthTexture(s.textureWidth,s.textureHeight,a,0[0],0[0],0[0],0[0],0[0],0[0],i,d);if(this._xrRenderTarget=new XRRenderTarget(s.textureWidth,s.textureHeight,{format:RGBAFormat,type:UnsignedByteType,colorSpace:t.outputColorSpace,depthTexture:u,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:s.ignoreDepthValues===!1,resolveStencilBuffer:s.ignoreDepthValues===!1,depth:this._useMultiview?2
69:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const e of this._layers)e.plane.material=new MeshBasicMaterial({color:16777215,side:e.type==="cylinder"?BackSide:FrontSide}),e.plane.material.blending=CustomBlending,e.plane.material.blendEquation=AddEquation,e.plane.material.blendSrc=ZeroFactor,e.plane.material.blendDst=ZeroFactor,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{const o={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},s=new XRWebGLLayer(e,n,o);this._glBaseLayer=s,e.updateRenderState({baseLayer:s}),t.setPixelRatio(1),t._setXRLayerSize(s.framebufferWidth,s.framebufferHeight),this._xrRenderTarget=new XRRenderTarget(s.framebufferWidth,s.framebufferHeight,{format:RGBAFormat,type:UnsignedByteType,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:s.ignoreDepthValues===!1,resolveStencilBuffer:s.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){const a=this._session;if(a===null)return;const r=e.near,c=e.far,t=this._cameraXR,n=this._cameraL,s=this._cameraR;t.near=s.near=n.near=r,t.far=s.far=n.far=c,t.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==t.near||this._currentDepthFar!==t.far)&&(a.updateRenderState({depthNear:t.near,depthFar:t.far}),this._currentDepthNear=t.near,this._currentDepthFar=t.far),t.layers.mask=e.layers.mask|6,n.layers.mask=t.layers.mask&3,s.layers.mask=t.layers.mask&5;const o=e.parent,i=t.cameras;updateCamera(t,o);for(let e=0;e<i.length;e++)updateCamera(i[e],o);i.length===2?setProjectionFromUnion(t,n,s):t.projectionMatrix.copy(n.projectionMatrix),updateUserCamera(e,t,o)}_getController(e){let t=this._controllers[e];return t===0[0]&&(t=new WebXRController,this._controllers[e]=t),t}}function setProjectionFromUnion(e,t,n){_cameraLPos.setFromMatrixPosition(t.matrixWorld),_cameraRPos.setFromMatrixPosition(n.matrixWorld);const d=_cameraLPos.distanceTo(_cameraRPos),s=t.projectionMatrix.elements,l=n.projectionMatrix.elements,i=s[14]/(s[10]-1),a=s[14]/(s[10]+1),p=(s[9]+1)/s[5],h=(s[9]-1)/s[5],c=(s[8]-1)/s[0],u=(l[8]+1)/l[0],f=i*c,m=i*u,o=d/(-c+u),r=o*-c;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(r),e.translateZ(o),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),s[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=i+o,n=a+o,s=f-r,c=m+(d-r),l=p*a/n*t,u=h*a/n*t;e.projectionMatrix.makePerspective(s,c,l,u,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function updateCamera(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function updateUserCamera(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=RAD2DEG*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function onSessionEvent(e){const n=this._controllerInputSources.indexOf(e.inputSource);if(n===-1)return;const t=this._controllers[n];if(t!==0[0]){const n=this.getReferenceSpace();t.update(e.inputSource,e.frame,n),t.dispatchEvent({type:e.type,data:e.inputSource})}}function onSessionEnd(){const e=this._session,t=this._renderer;e.removeEventListener("select",this._onSessionEvent),e.removeEventListener("selectstart",this._onSessionEvent),e.removeEventListener("selectend",this._onSessionEvent),e.removeEventListener("squeeze",this._onSessionEvent),e.removeEventListener("squeezestart",this._onSessionEvent),e.removeEventListener("squeezeend",this._onSessionEvent),e.removeEventListener("end",this._onSessionEnd),e.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){const t=this._controllerInputSources[e];if(t===null)continue;this._controllerInputSources[e]=null,this._controllers[e].disconnect(t)}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(const e of this._layers)e.renderTarget=new XRRenderTarget(e.pixelwidth,e.pixelheight,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(e.pixelwidth,e.pixelheight,e.stencilBuffer?UnsignedInt248Type:UnsignedIntType,0[0],0[0],0[0],0[0],0[0],0[0],e.stencilBuffer?DepthStencilFormat:DepthFormat),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function onInputSourcesChange(e){const n=this._controllers,t=this._controllerInputSources;for(let s=0;s<e.removed.length;s++){const i=e.removed[s],o=t.indexOf(i);o>=0&&(t[o]=null,n[o].disconnect(i))}for(let i=0;i<e.added.length;i++){const o=e.added[i];let s=t.indexOf(o);if(s===-1){for(let e=0;e<n.length;e++){if(e>=t.length){t.push(o),s=e;break}if(t[e]===null){t[e]=o,s=e;break}}if(s===-1)break}const a=n[s];a&&a.connect(o)}}function createXRLayer(e){return e.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space
69:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function onAnimationFrame(e,t){if(t===0[0])return;const n=this._cameraXR,s=this._renderer,o=s.backend,i=this._glBaseLayer,a=this.getReferenceSpace(),r=t.getViewerPose(a);if(this._xrFrame=t,r!==null){const e=r.views;this._glBaseLayer!==null&&o.setXRTarget(i.framebuffer);let t=!1;e.length!==n.cameras.length&&(n.cameras.length=0,t=!0);for(let a=0;a<e.length;a++){const c=e[a];let r;if(this._supportsLayers===!0){const e=this._glBinding.getViewSubImage(this._glProjLayer,c);r=e.viewport,a===0&&o.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?0[0]:e.depthStencilTexture)}else r=i.getViewport(c);let s=this._cameras[a];s===0[0]&&(s=new PerspectiveCamera,s.layers.enable(a),s.viewport=new Vector4,this._cameras[a]=s),s.matrix.fromArray(c.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(c.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(r.x,r.y,r.width,r.height),a===0&&(n.matrix.copy(s.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),t===!0&&n.cameras.push(s)}s.setOutputRenderTarget(this._xrRenderTarget)}for(let e=0;e<this._controllers.length;e++){const n=this._controllerInputSources[e],s=this._controllers[e];n!==null&&s!==0[0]&&s.update(n,t,a)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:t}),this._xrFrame=null}class CanvasTarget extends EventDispatcher{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Vector4(0,0,this._width,this._height),this._scissor=new Vector4(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new FramebufferTexture,this.depthTexture=new DepthTexture}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){if(this._pixelRatio===e)return;this._pixelRatio=e,this.setSize(this._width,this._height,!1)}setDrawingBufferSize(e,t,n){if(this.xr&&this.xr.isPresenting)return;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._dispatchResize()}setSize(e,t,n=!0){if(this.xr&&this.xr.isPresenting)return;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._dispatchResize()}getScissor(e){const 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,s){const o=this._scissor;e.isVector4?o.copy(e):o.set(e,t,n,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,s,o=0,i=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,n,s),a.minDepth=o,a.maxDepth=i}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}}_scene=new Scene,_drawingBufferSize=new Vector2,_screen=new Vector4,_frustum=new Frustum,_frustumArray=new FrustumArray,_projScreenMatrix2=new Matrix4,_vector4=new Vector4;class Renderer{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:n=!1,alpha:s=!0,depth:o=!0,stencil:i=!1,antialias:a=!1,samples:r=0,getFallback:c=null,outputBufferType:l=HalfFloatType,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=n,this.outputColorSpace
69=SRGBColorSpace,this.toneMapping=NoToneMapping,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=i,this.info=new Info,this.contextNode=context(),this.library=new NodeLibrary,this.lighting=new Lighting,this._samples=r||a===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new CanvasTarget(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new InspectorBase,this._inspector.setRenderer(this),this._getFallback=c,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new QuadMesh(new NodeMaterial),this._quad.name="Output Color Transform",this._quad.material.name="outputColorTransform",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const u=this.alpha===!0?0:1;this._clearColor=new Color4(0,0,0,u),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._outputBufferType=l,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:PCFShadowMap},this.xr=new XRManager(this,d),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,n)=>{await this.compileAsync(e,t);const o=this._renderLists.get(e,t),s=this._renderContexts.get(e,t,this._renderTarget,this._mrt),i=e.overrideMaterial||n.material,a=this._objects.get(n,i,e,t,o.lightsNode,s,s.clippingContext),{fragmentShader:r,vertexShader:c}=a.getNodeBuilderState();return{fragmentShader:r,vertexShader:c}}}}
69async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new Nodes(this,n),this._animation=new Animation(this,this._nodes,this.info),this._attributes=new Attributes(n),this._background=new Background(this,this._nodes),this._geometries=new Geometries(this._attributes,this.info),this._textures=new Textures(this,n,this.info),this._pipelines=new Pipelines(n,this._nodes),this._bindings=new Bindings(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new RenderObjects(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new RenderLists(this.lighting),this._bundles=new RenderBundles,this._renderContexts=new RenderContexts,this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,g=r.renderId,p=this._currentRenderContext,m=this._currentRenderObjectFunction,h=this._compilationPromises,i=e.isScene===!0?e:_scene;n===null&&(n=e);const a=this._renderTarget,s=this._renderContexts.get(n,t,a,this._mrt),f=this._activeMipmapLevel,c=[];this._currentRenderContext=s,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=c,r.renderId++,r.update(
69),s.depth=this.depth,s.stencil=this.stencil,s.clippingContext||(s.clippingContext=new ClippingContext),s.clippingContext.updateGlobal(i,t),i.onBeforeRender(this,e,t,a);const o=this._renderLists.get(e,t);if(o.begin(),this._projectObject(e,t,0,o,s.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&o.pushLight(e)}),o.finish(),a!==null){this._textures.updateRenderTarget(a,f);const e=this._textures.get(a);s.textures=e.textures,s.depthTexture=e.depthTexture}else s.textures=null,s.depthTexture=null;this._background.update(i,o,s);const l=o.opaque,d=o.transparent,v=o.transparentDoublePass,u=o.lightsNode;this.opaque===!0&&l.length>0&&this._renderObjects(l,t,i,u),this.transparent===!0&&d.length>0&&this._renderTransparents(d,v,t,i,u),r.renderId=g,this._currentRenderContext=p,this._currentRenderObjectFunction=m,this._compilationPromises=h,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(c)}async renderAsync(e,t){warnOnce('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){error("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=highpModelViewMatrix,t.modelNormalViewMatrix=highpModelNormalViewMatrix):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===highpModelViewMatrix&&e.modelNormalViewMatrix===highpModelNormalViewMatrix}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return warnOnce('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: 70 71Message: ${e.message}`;e.reason&&(t+=` 72Reason: ${e.reason}`),error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:a,camera:r,renderList:l}=e,o=this._currentRenderContext,i=this._bundles.get(a,r),s=this.backend.get(i);s.renderContexts===0[0]&&(s.renderContexts=new Set);const c=a.version!==s.version,d=s.renderContexts.has(o)===!1||c;if(s.renderContexts.add(o),d){this.backend.beginBundle(o),(s.renderObjects===0[0]||c)&&(s.renderObjects=[]),this._currentRenderBundle=i;const{transparentDoublePass:u,transparent:e,opaque:d}=l;this.opaque===!0&&d.length>0&&this._renderObjects(d,r,t,n),this.transparent===!0&&e.length>0&&this._renderTransparents(e,u,r,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,i),s.version=a.version}else{const{renderObjects:e}=s;for(let n=0,s=e.length;n<s;n++){const t=e[n];this._nodes.needsRefresh(t)&&(this._nodes.updateBefore(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t),this._nodes.updateAfter(t))}}this.backend.addBundle(o,i)}render(e,t){if(this._initialized===!1)throw new Error('Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_getFrameBufferTarget(){const{currentToneMapping:r,currentColorSpace:c}=this,l=r!==NoToneMapping,d=c!==ColorManagement.workingColorSpace;if(l===!1&&d===!1)return null;const{width:s,height:o}=this.getDrawingBufferSize(_drawingBufferSize),{depth:i,stencil:a}=this;let e=this._frameBufferTarget;e===null&&(e=new RenderTarget(s,o,{depthBuffer:i,stencilBuffer:a,type:this._outputBufferType,format:RGBAFormat,colorSpace:ColorManagement.workingColorSpace,generateMipmaps:!1,minFilter:LinearFilter,magFilter:LinearFilter,samples:this.samples}),e.isPostProcessingRenderTarget=!0,this._frameBufferTarget=e);const t=this.getOutputRenderTarget();e.depthBuffer=i,e.stencilBuffer=a,t!==null?e.setSize(t.width,t.height,t.depth):e.setSize(s,o,1);const n=this._canvasTarget;return e.viewport.copy(n._viewport),e.scissor.copy(n._scissor),e.viewport.multiplyScalar(n._pixelRatio),e.scissor.multiplyScalar(n._pixelRatio),e.scissorTest=n._scissorTest,e.multiview=t!==null&&t.multiview,e.resolveDepthBuffer=t===null||t.resolveDepthBuffer,e._autoAllocateDepthBuffer=t!==null&&t._autoAllocateDepthBuffer,e}
72_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;const h=n?this._getFrameBufferTarget():null,f=this._nodes.nodeFrame,k=f.renderId,E=this._currentRenderContext,w=this._currentRenderObjectFunction,r=e.isScene===!0?e:_scene,g=this._renderTarget||this._outputRenderTarget,v=this._activeCubeFace,i=this._activeMipmapLevel;let o;h!==null?(o=h,this.setRenderTarget(o)):o=g;const s=this._renderContexts.get(e,t,o,this._mrt);this._currentRenderContext=s,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,f.renderId=this.info.calls,this.backend.updateTimeStampUID(s),this.inspector.beginRender(this.backend.getTimestampUID(s),e,t,o);const p=this.coordinateSystem,l=this.xr;if(t.coordinateSystem!==p&&l.isPresenting===!1&&(t.coordinateSystem=p,t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.coordinateSystem=p,e.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),l.enabled===!0&&l.isPresenting===!0&&(l.cameraAutoUpdate===!0&&l.updateCamera(t),t=l.getCamera());const d=this._canvasTarget;let c=d._viewport,b=d._scissor,u=d._pixelRatio;o!==null&&(c=o.viewport,b=o.scissor,u=1),this.getDrawingBufferSize(_drawingBufferSize),_screen.set(0,0,_drawingBufferSize.width,_drawingBufferSize.height);const O=c.minDepth===0[0]?0:c.minDepth,x=c.maxDepth===0[0]?1:c.maxDepth;s.viewportValue.copy(c).multiplyScalar(u).floor(),s.viewportValue.width>>=i,s.viewportValue.height>>=i,s.viewportValue.minDepth=O,s.viewportValue.maxDepth=x,s.viewport=s.viewportValue.equals(_screen)===!1,s.scissorValue.copy(b).multiplyScalar(u).floor(),s.scissor=d._scissorTest&&s.scissorValue.equals(_screen)===!1,s.scissorValue.width>>=i,s.scissorValue.height>>=i,s.clippingContext||(s.clippingContext=new ClippingContext),s.clippingContext.updateGlobal(r,t),r.onBeforeRender(this,e,t,o);const C=t.isArrayCamera?_frustumArray:_frustum;t.isArrayCamera||(_projScreenMatrix2.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),C.setFromProjectionMatrix(_projScreenMatrix2,t.coordinateSystem,t.reversedDepth));const a=this._renderLists.get(e,t);if(a.begin(),this._projectObject(e,t,0,a,s.clippingContext),a.finish(),this.sortObjects===!0&&a.sort(this._opaqueSort,this._transparentSort),o!==null){this._textures.updateRenderTarget(o,i);const e=this._textures.get(o);s.textures=e.textures,s.depthTexture=e.depthTexture,s.width=e.width,s.height=e.height,s.renderTarget=o,s.depth=o.depthBuffer,s.stencil=o.stencilBuffer}else s.textures=null,s.depthTexture=null,s.width=_drawingBufferSize.width,s.height=_drawingBufferSize.height,s.depth=this.depth,s.stencil=this.stencil;s.width>>=i,s.height>>=i,s.activeCubeFace=v,s.activeMipmapLevel=i,s.occlusionQueryCount=a.occlusionQueryCount,s.scissorValue.max(_vector4.set(0,0,0,0)),s.scissorValue.x+s.scissorValue.width>s.width&&(s.scissorValue.width=Math.max(s.width-s.scissorValue.x,0)),s.scissorValue.y+s.scissorValue.height>s.height&&(s.scissorValue.height=Math.max(s.height-s.scissorValue.y,0)),this._background.update(r,a,s),s.camera=t,this.backend.beginRender(s);const{bundles:j,lightsNode:m,transparentDoublePass:A,transparent:y,opaque:_}=a;return j.length>0&&this._renderBundles(j,r,m),this.opaque===!0&&_.length>0&&this._renderObjects(_,t,r,m),this.transparent===!0&&y.length>0&&this._renderTransparents(y,A,t,r,m),this.backend.finishRender(s),f.renderId=k,this._currentRenderContext=E,this._currentRenderObjectFunction=w,h!==null&&(this.setRenderTarget(g,v,i),this._renderOutput(o)),r.onAfterRender(this,e,t,o),this.inspector.finishRender(this.backend.getTimestampUID(s)),s}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const n=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=s}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)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){if(this.xr&&this.xr.isPresenting)return;this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){if(this.xr&&this.xr.isPresenting)return;this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,s){this._canvasTarget.setScissor(e,t,n,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,s,o=0,i=1){this._canvasTarget.setViewport(e,t,n,s,o,i)}getClearColor(e){return e.copy(this._clearColor)}
72setClearColor(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){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw new Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');const o=this._renderTarget||this._getFrameBufferTarget();let s=null;if(o!==null){this._textures.updateRenderTarget(o);const e=this._textures.get(o);s=this._renderContexts.getForClear(o),s.textures=e.textures,s.depthTexture=e.depthTexture,s.width=e.width,s.height=e.height,s.renderTarget=o,s.depth=o.depthBuffer,s.stencil=o.stencilBuffer,s.clearColorValue=this.backend.getClearColor(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,s),o!==null&&this._renderTarget===null&&this._renderOutput(o)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){warnOnce('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,n)}async clearColorAsync(){warnOnce('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){warnOnce('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){warnOnce('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==NoToneMapping,t=this.currentColorSpace!==ColorManagement.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:NoToneMapping}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ColorManagement.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._geometries.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}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_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 warn("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const n=this._nodes.nodeFrame,c=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const s=this.backend,o=this._pipelines,i=this._bindings,r=this._nodes,a=Array.isArray(e)?e:[e];if(a[0]===0[0]||a[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const n of a){if(o.has(n)===!1){const e=()=>{n.removeEventListener("dispose",e),o.delete(n),i.deleteForCompute(n),r.delete(n)};n.addEventListener("dispose",e);const t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}r.updateForCompute(n),i.updateForCompute(n);const c=i.getForCompute(n),l=o.getForCompute(n,c);s.compute(e,n,c,l,t)}s.finishCompute(e),n.renderId=c,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return warnOnce('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){warnOnce('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}
72copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=_vector4.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=_vector4.copy(t).floor();else{error("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=_vector4.set(0,0,e.image.width,e.image.height);let s=this._currentRenderContext,n;s!==null?n=s.renderTarget:(n=this._renderTarget||this._getFrameBufferTarget(),n!==null&&(this._textures.updateRenderTarget(n),s=this._textures.get(n))),this._textures.updateTexture(e,{renderTarget:n}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,s=null,o=0,i=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,s,o,i),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,s,o,i=0,a=0){return this.backend.copyTextureToBuffer(e.textures[i],t,n,s,o,a)}_projectObject(e,t,n,s,o){if(e.visible===!1)return;const a=e.layers.test(t.layers);if(a)if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(o=o.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){{const i=t.isArrayCamera?_frustumArray:_frustum;if(!e.frustumCulled||i.intersectsSprite(e,t)){this.sortObjects===!0&&_vector4.setFromMatrixPosition(e.matrixWorld).applyMatrix4(_projScreenMatrix2);const{geometry:i,material:t}=e;t.visible&&s.push(e,i,t,n,_vector4.z,null,o)}}}else if(e.isLineLoop)error("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const i=t.isArrayCamera?_frustumArray:_frustum;if(!e.frustumCulled||i.intersectsObject(e,t)){const{geometry:t,material:i}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),_vector4.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(_projScreenMatrix2)),Array.isArray(i)){const a=t.groups;for(let r=0,d=a.length;r<d;r++){const l=a[r],c=i[l.materialIndex];c&&c.visible&&s.push(e,t,c,n,_vector4.z,l,o)}}else i.visible&&s.push(e,t,i,n,_vector4.z,null,o)}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==0[0]){const n=s;s=this._renderLists.get(e,t),s.begin(),n.pushBundle({bundleGroup:e,camera:t,renderList:s}),s.finish()}const i=e.children;for(let e=0,a=i.length;e<a;e++)this._projectObject(i[e],t,n,s,o)}_renderBundles(e,t,n){for(const s of e)this._renderBundle(s,t,n)}_renderTransparents(e,t,n,s,o){if(t.length>0){for(const{material:e}of t)e.side=BackSide;this._renderObjects(t,n,s,o,"backSide");for(const{material:e}of t)e.side=FrontSide;this._renderObjects(e,n,s,o);for(const{material:e}of t)e.side=DoubleSide}else this._renderObjects(e,n,s,o)}_renderObjects(e,t,n,s,o=null){for(let i=0,a=e.length;i<a;i++){const{object:r,geometry:c,material:l,group:d,clippingContext:u}=e[i];this._currentRenderObjectFunction(r,n,t,c,l,d,s,u,o)}}_getShadowNodes(e){const n=e.version;let t=this._cacheShadowNodes.get(e);if(t===0[0]||t.version!==n){const o=e.map!==null,i=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode;let s=null,r=null,c=null;if(o||i||a){let n,t;a?(n=e.castShadowNode.rgb,t=e.castShadowNode.a):(n=vec3(0),t=float(1)),o&&(t=t.mul(reference("map","texture",e).a)),i&&(t=t.mul(e.colorNode.a)),r=vec4(n,t)}e.depthNode&&e.depthNode.isNode&&(c=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),t={version:n,colorNode:r,depthNode:c,positionNode:s},this._cacheShadowNodes.set(e,t)}return t}renderObject(e,t,n,s,o,i,a,r=null,c=null){let l=!1,d,u,h,m;if(e.onBeforeRender(this,t,n,s,o,i),o.allowOverride===!0&&t.overrideMaterial!==null){const e=t.overrideMaterial;if(l=!0,d=t.overrideMaterial.colorNode,u=t.overrideMaterial.depthNode,h=t.overrideMaterial.positionNode,m=t.overrideMaterial.side,o.positionNode&&o.positionNode.isNode&&(e.positionNode=o.positionNode),e.alphaTest=o.alphaTest,e.alphaMap=o.alphaMap,e.transparent=o.transparent||o.transmission>0||o.transmissionNode&&o.transmissionNode.isNode||o.backdropNode&&o.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:n,positionNode:s}=this._getShadowNodes(o);e.side=o.shadowSide===null?o.side:o.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),s!==null&&(e.positionNode=s)}o=e}o.transparent===!0&&o.side===DoubleSide&&o.forceSinglePass===!1?(o.side=BackSide,this._handleObjectFunction(e,o,t,n,a,i,r,"backSide"),o.side=FrontSide,this._handleObjectFunction(e,o,t,n,a,i,r,c),o.side=DoubleSide):this._handleObjectFunction(e,o,t,n,a,i,r,c),l&&(t.overrideMaterial.colorNode=d,t.overrideMaterial.depthNode=u,t.overrideMaterial.positionNode=h,t.overrideMaterial.side=m),e.onAfterRender(this,t,n,s,o,i)}_renderObjectDirect(e,t,n,s,o,i,a,r){const c=this._objects.get(e,t,n,s,o,this._currentRenderContext,a,r);c.drawRange=e.geometry.drawRange,c.group=i;const l=this._nodes.needsRefresh(c);if(l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._currentRenderBundle!==null){const e=this.backend.get(this._currentRenderBundle);e.renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c)}_createObjectPipeline(e,t,n,s,o,i,a,r){const c=this._objects.get(e,t,n,s,o,this._currentRenderContext,a,r);c.drawRange=e.geometry.drawRange,c.group=i,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class Binding{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function getFloatLength(e){return e+(GPU_CHUNK_BYTES-e%GPU_CHUNK_BYTES)%GPU_CHUNK_BYTES}class Buffer2 extends Binding{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return getFloatLength(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class UniformBuffer extends Buffer2{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}_id$4=0;class NodeUniformBuffer extends UniformBuffer{constructor(e,t){super("UniformBuffer_"+_id$4++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}}class UniformsGroup2 extends UniformBuffer{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const 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){const t=this.byteLength;
72e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const t=this.bytesPerElement;let e=0;for(let n=0,c=this.uniforms.length;n<c;n++){const s=this.uniforms[n],l=s.boundary,i=s.itemSize*t,a=e%GPU_CHUNK_BYTES,r=a%l,o=a+r;e+=r,o!==0&&GPU_CHUNK_BYTES-o<i&&(e+=GPU_CHUNK_BYTES-o),s.offset=e/t,e+=i}return Math.ceil(e/GPU_CHUNK_BYTES)*GPU_CHUNK_BYTES}update(){let e=!1;for(const t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);error("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let n=!1;const s=this.values,o=e.getValue(),t=e.offset,i=e.getType();if(s[t]!==o){const e=this._getBufferForType(i);e[t]=s[t]=o,n=!0}return n}updateVector2(e){let o=!1;const n=this.values,s=e.getValue(),t=e.offset,i=e.getType();if(n[t+0]!==s.x||n[t+1]!==s.y){const e=this._getBufferForType(i);e[t+0]=n[t+0]=s.x,e[t+1]=n[t+1]=s.y,o=!0}return o}updateVector3(e){let o=!1;const n=this.values,s=e.getValue(),t=e.offset,i=e.getType();if(n[t+0]!==s.x||n[t+1]!==s.y||n[t+2]!==s.z){const e=this._getBufferForType(i);e[t+0]=n[t+0]=s.x,e[t+1]=n[t+1]=s.y,e[t+2]=n[t+2]=s.z,o=!0}return o}updateVector4(e){let o=!1;const n=this.values,s=e.getValue(),t=e.offset,i=e.getType();if(n[t+0]!==s.x||n[t+1]!==s.y||n[t+2]!==s.z||n[t+4]!==s.w){const e=this._getBufferForType(i);e[t+0]=n[t+0]=s.x,e[t+1]=n[t+1]=s.y,e[t+2]=n[t+2]=s.z,e[t+3]=n[t+3]=s.w,o=!0}return o}updateColor(e){let o=!1;const n=this.values,s=e.getValue(),t=e.offset;if(n[t+0]!==s.r||n[t+1]!==s.g||n[t+2]!==s.b){const e=this.buffer;e[t+0]=n[t+0]=s.r,e[t+1]=n[t+1]=s.g,e[t+2]=n[t+2]=s.b,o=!0}return o}updateMatrix3(e){let o=!1;const n=this.values,s=e.getValue().elements,t=e.offset;if(n[t+0]!==s[0]||n[t+1]!==s[1]||n[t+2]!==s[2]||n[t+4]!==s[3]||n[t+5]!==s[4]||n[t+6]!==s[5]||n[t+8]!==s[6]||n[t+9]!==s[7]||n[t+10]!==s[8]){const e=this.buffer;e[t+0]=n[t+0]=s[0],e[t+1]=n[t+1]=s[1],e[t+2]=n[t+2]=s[2],e[t+4]=n[t+4]=s[3],e[t+5]=n[t+5]=s[4],e[t+6]=n[t+6]=s[5],e[t+8]=n[t+8]=s[6],e[t+9]=n[t+9]=s[7],e[t+10]=n[t+10]=s[8],o=!0}return o}updateMatrix4(e){let s=!1;const o=this.values,t=e.getValue().elements,n=e.offset;if(arraysEqual(o,t,n)===!1){const e=this.buffer;e.set(t,n),setArray(o,t,n),s=!0}return s}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}}function setArray(e,t,n){for(let s=0,o=t.length;s<o;s++)e[n+s]=t[s]}function arraysEqual(e,t,n){for(let s=0,o=t.length;s<o;s++)if(e[n+s]!==t[s])return!1;return!0}_id$3=0;class NodeUniformsGroup extends UniformsGroup2{constructor(e,t){super(e),this.id=_id$3++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class Sampler extends Binding{constructor(e,t){super(e),this._texture=null,this._onTextureDispose=()=>{this.generation=null,this.version=0},this.texture=t,this.version=t?t.version:0,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){if(this._texture===e)return;this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose)}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}clone(){const e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=0},e.texture=this.texture,e}}_id$22=0;class SampledTexture extends Sampler{constructor(e,t){super(e,t),this.id=_id$22++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class NodeSampledTexture extends SampledTexture{constructor(e,t,n,s=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=s}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update(
72)}}class NodeSampledCubeTexture extends NodeSampledTexture{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledCubeTexture=!0}}class NodeSampledTexture3D extends NodeSampledTexture{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledTexture3D=!0}}glslPolyfills={bitcast_int_uint:new CodeNode("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new CodeNode("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},glslMethods={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},precisionLib={low:"lowp",medium:"mediump",high:"highp"},supports$1={swizzleAssign:!0,storageBuffer:!1},interpolationTypeMap={perspective:"smooth",linear:"noperspective"},interpolationModeMap={centroid:"centroid"},defaultPrecisions=` 73precision highp float; 74precision highp int; 75precision highp sampler2D; 76precision highp sampler3D; 77precision highp samplerCube; 78precision highp sampler2DArray; 79 80precision highp usampler2D; 81precision highp usampler3D; 82precision highp usamplerCube; 83precision highp usampler2DArray; 84 85precision highp isampler2D; 86precision highp isampler3D; 87precision highp isamplerCube; 88precision highp isampler2DArray; 89 90precision lowp sampler2DShadow; 91precision lowp sampler2DArrayShadow; 92precision lowp samplerCubeShadow; 93`;class GLSLNodeBuilder extends NodeBuilder{constructor(e,t){super(e,t,new GLSLNodeParser),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==NoColorSpace}_include(e){const t=glslPolyfills[e];return t.build(this),this.addInclude(t),t}getMethod(e){return glslPolyfills[e]!==0[0]&&this._include(e),glslMethods[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(this.getType(e.type)+" "+e.name);const o=`${this.getType(t.type)} ${t.name}( ${s.join(", ")} ) { 94 95 ${n.vars} 96 97${n.code} 98 return ${n.result}; 99 100}`;return o}setupPBO(e){const t=e.value;if(t.pbo===0[0]){const l=t.array,a=t.count*t.itemSize,{itemSize:e}=t,n=t.array.constructor.name.toLowerCase().includes("int");let s=n?RedIntegerFormat:RedFormat;e===2?s=n?RGIntegerFormat:RGFormat:e===3?s=n?RGBIntegerFormat:RGBFormat:e===4&&(s=n?RGBAIntegerFormat:RGBAFormat);const u={Float32Array:FloatType,Uint8Array:UnsignedByteType,Uint16Array:UnsignedShortType,Uint32Array:UnsignedIntType,Int8Array:ByteType,Int16Array:ShortType,Int32Array:IntType,Uint8ClampedArray:UnsignedByteType},o=2**Math.ceil(Math.log2((a/e)**.5));let i=Math.ceil(a/e/o);o*i*e<a&&i++;const h=o*i*e,d=new l.constructor(h);d.set(l,0),t.array=d;const r=new DataTexture(t.array,o,i,s,u[t.array.constructor.name]||FloatType);r.needsUpdate=!0,r.isPBOTexture=!0;const c=new TextureNode(r,null,null);c.setPrecision("high"),t.pboNode=c,t.pbo=c.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:s,indexNode:o}=e,t=s.value;if(this.renderer.backend.has(t)){const e=this.renderer.backend.get(t);e.pbo=t.pbo}const c=this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName),i=this.getPropertyName(c);this.increaseUsage(o);const a=o.build(this,"uint"),r=this.getDataFromNode(e);let n=r.propertyName;if(n===0[0]){const d=this.getVarFromNode(e);n=this.getPropertyName(d);const l=this.getDataFromNode(s);let o=l.propertySizeName;o===0[0]&&(o=n+"Size",this.getVarFromNode(s,o,"uint"),this.addLineFlowCode(`${o} = uint( textureSize( ${i}, 0 ).x )`,e),l.propertySizeName=o);const{itemSize:u}=t,h="."+vectorComponents.join("").slice(0,u),m=`ivec2(${a} % ${o}, ${a} / ${o})`,f=this.generateTextureLoad(null,i,m,"0",null,null);let c="vec4";t.pbo.type===UnsignedIntType?c="uvec4":t.pbo.type===IntType&&(c="ivec4"),this.addLineFlowCode(`${n} = ${c}(${f})${h}`,e),r.propertyName=n}return n}generateTextureLoad(e,t,n,s,o,i){s===null&&(s="0");let a;return o?i?a=`texelFetchOffset( ${t}, ivec3( ${n}, ${o} ), ${s}, ${i} )`:a=`texelFetch( ${t}, ivec3( ${n}, ${o} ), ${s} )`:i?a=`texelFetchOffset( ${t}, ${n}, ${s}, ${i} )`:a=`texelFetch( ${t}, ${n}, ${s} )`,e!==null&&e.isDepthTexture&&(a+=".x"),a}generateTexture(e,t,n,s,o){return s&&(n=`vec3( ${n}, ${s} )`),e.isDepthTexture?o?`textureOffset( ${t}, ${n}, ${o} ).x`:`texture( ${t}, ${n} ).x`:o?`textureOffset( ${t}, ${n}, ${o} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,s,o){return o?`textureLodOffset( ${t}, ${n}, ${s}, ${o} )`:`textureLod( ${t}, ${n}, ${s} )`}generateTextureBias(e,t,n,s,o){return o?`textureOffset( ${t}, ${n}, ${o}, ${s} )`:`texture( ${t}, ${n}, ${s} )`}generateTextureGrad(e,t,n,s,o){return o?`textureGradOffset( ${t}, ${n}, ${s[0]}, ${s[1]}, ${o} )`:`textureGrad( ${t}, ${n}, ${s[0]}, ${s[1]} )`}generateTextureCompare(e,t,n,s,o,i,a=this.shaderStage){if(a==="fragment")return e.isCubeTexture?`texture( ${t}, vec4( ${n}, ${s} ) )`:o?i?`textureOffset( ${t}, vec4( ${n}, ${o}, ${s} ), ${i} )`:`texture( ${t}, vec4( ${n}, ${o}, ${s} ) )`:i?`textureOffset( ${t}, vec3( ${n}, ${s} ), ${i} )`:`texture( ${t}, vec3( ${n}, ${s} ) )`;error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}getVars(e){const t=[],n=this.vars[e];if(n!==0[0])for(const e of n)t.push(`${this.getVar(e.type,e.name,e.count)};`);return t.join(` 101 `)}getUniforms(e){const o=this.uniforms[e],s=[],t={};for(const n of o){let i=null,a=!1;if(n.type==="texture"||n.type==="texture3D"){const e=n.node.value;let t="";(e.isDataTexture===!0||e.isData3DTexture===!0)&&(e.type===UnsignedIntType?t="u":e.type===IntType&&(t="i")),n.type==="texture3D"&&e.isArrayTexture===!1?i=`${t}sampler3D ${n.name};`:e.compareFunction?e.isArrayTexture===!0?i=`sampler2DArrayShadow ${n.name};`:i=`sampler2DShadow ${n.name};`:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?i=`${t}sampler2DArray ${n.name};`:i=`${t}sampler2D ${n.name};`}else if(n.type==="cubeTexture")i=`samplerCube ${n.name};`;else if(n.type==="cubeDepthTexture")i=`samplerCubeShadow ${n.name};`;else if(n.type==="buffer"){const e=n.node,s=this.getType(e.bufferType),t=e.bufferCount,o=t>0?t:"";i=`${e.name} { 102 ${s} ${n.name}[${o}]; 103}; 104`}else{const t=this.getVectorType(n.type);i=`${t} ${this.getPropertyName(n,e)};`,a=!0}const r=n.node.precision;if(r!==null&&(i=precisionLib[r]+" "+i),a){i=" "+i;const e=n.groupNode.name,s=t[e]||(t[e]=[]);s.push(i)}else i="uniform "+i,s.push(i)}let n="";for(const s in t){const o=t[s];n+=this._getGLSLUniformStruct(e+"_"+s,o.join(` 105`))+` 106`}return n+=s.join(` 107`),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);
107if(/^[iu]/.test(t)&&e.gpuType!==IntType){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const s=n.array;(s instanceof Uint32Array||s instanceof Int32Array)===!1&&(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const e=this.getAttributesArray();let n=0;for(const s of e)t+=`layout( location = ${n++} ) in ${s.type} ${s.name}; 108`}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(` 109`)}getStructs(e){const n=[],s=this.structs[e],t=[];for(const e of s)if(e.output)for(const n of e.members)t.push(`layout( location = ${n.index} ) out ${n.type} ${n.name};`);else{let t="struct "+e.name+` { 110`;t+=this.getStructMembers(e),t+=` 111}; 112`,n.push(t)}return t.length===0&&t.push("layout( location = 0 ) out vec4 fragColor;"),` 113`+t.join(` 114`)+` 115 116`+n.join(` 117`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const s of n){e==="compute"&&(s.needsInterpolation=!0);const o=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const e=interpolationTypeMap[s.interpolationType]||s.interpolationType,n=interpolationModeMap[s.interpolationSampling]||"";t+=`${e} ${n} out ${o} ${s.name}; 118`}else{const e=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${e}out ${o} ${s.name}; 119`}else t+=`${o} ${s.name}; 120`}else if(e==="fragment")for(const e of n)if(e.needsInterpolation){const n=this.getType(e.type);if(e.interpolationType){const s=interpolationTypeMap[e.interpolationType]||e.interpolationType,o=interpolationModeMap[e.interpolationSampling]||"";t+=`${s} ${o} in ${n} ${e.name}; 121`}else{const s=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${s}in ${n} ${e.name}; 122`}}for(const n of this.builtins[e])t+=`${n}; 123`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){const e=this.object.workgroupSize,t=e.reduce((e,t)=>e*t,1);return`uint( gl_InstanceID ) % ${t}u`}getSubgroupSize(){error("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){error("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){error("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){const e=this.renderer.backend.extensions;return e.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){const s=this.extensions[n]||(this.extensions[n]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const t=this.renderer.backend.extensions,n=this.object.isBatchedMesh;n&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==0[0])for(const{name:e,behavior:s}of n.values())t.push(`#extension ${e} : ${s}`);return t.join(` 124`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=supports$1[e];if(t===0[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!==0[0]){const e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}supports$1[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} ]`)}
124enableMultiview(){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(){const e=this.transforms;let t="";for(let n=0;n<e.length;n++){const s=e[n],o=this.getPropertyName(s.attributeNode);o&&(t+=`${s.varyingName} = ${o}; 125 `)}return t}_getGLSLUniformStruct(e,t){return` 126layout( std140 ) uniform ${e} { 127${t} 128};`}_getGLSLVertexCode(e){return`#version 300 es 129 130${this.getSignature()} 131 132// extensions 133${e.extensions} 134 135// precision 136${defaultPrecisions} 137 138// uniforms 139${e.uniforms} 140 141// varyings 142${e.varyings} 143 144// attributes 145${e.attributes} 146 147// codes 148${e.codes} 149 150void main() { 151 152 // vars 153 ${e.vars} 154 155 // transforms 156 ${e.transforms} 157 158 // flow 159 ${e.flow} 160 161 gl_PointSize = 1.0; 162 163} 164`}_getGLSLFragmentCode(e){return`#version 300 es 165 166${this.getSignature()} 167 168// extensions 169${e.extensions} 170 171// precision 172${defaultPrecisions} 173 174// structs 175${e.structs} 176 177// uniforms 178${e.uniforms} 179 180// varyings 181${e.varyings} 182 183// codes 184${e.codes} 185 186void main() { 187 188 // vars 189 ${e.vars} 190 191 // flow 192 ${e.flow} 193 194} 195`}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let n=`// code 196 197`;n+=this.flowCode[t];const o=this.flowNodes[t],i=o[o.length-1];for(const e of o){const s=this.getFlowData(e),a=e.name;a&&(n.length>0&&(n+=` 198`),n+=` // flow -> ${a} 199 `),n+=`${s.code} 200 `,e===i&&t!=="compute"&&(n+=`// result 201 `,t==="vertex"?(n+="gl_Position = ",n+=`${s.result};`):t==="fragment"&&(e.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${s.result};`)))}const s=e[t];s.extensions=this.getExtensions(t),s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.vars=this.getVars(t),s.structs=this.getStructs(t),s.codes=this.getCodes(t),s.transforms=this.getTransforms(t),s.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,s=null){const i=super.getUniformFromNode(e,t,n,s),a=this.getDataFromNode(e,n,this.globalCache);let o=a.uniformGPU;if(o===0[0]){const s=e.groupNode,c=s.name,r=this.getBindGroupArray(c,n);if(t==="texture")o=new NodeSampledTexture(i.name,i.node,s),r.push(o);else if(t==="cubeTexture"||t==="cubeDepthTexture")o=new NodeSampledCubeTexture(i.name,i.node,s),r.push(o);else if(t==="texture3D")o=new NodeSampledTexture3D(i.name,i.node,s),r.push(o);else if(t==="buffer"){i.name=`buffer${e.id}`;const n=this.getSharedDataFromNode(e);let t=n.buffer;t===0[0]&&(e.name=`NodeBuffer_${e.id}`,t=new NodeUniformBuffer(e,s),t.name=e.name,n.buffer=t),r.push(t),o=t}else{const a=this.uniformGroups[n]||(this.uniformGroups[n]={});let e=a[c];e===0[0]&&(e=new NodeUniformsGroup(n+"_"+c,s),a[c]=e,r.push(e)),o=this.getNodeUniform(i,t),e.addUniform(o)}a.uniformGPU=o}return i}}_vector22=null,_color4=null;class Backend{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[TimestampQuery.RENDER]:null,[TimestampQuery.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(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const n=this.get(e),s=this.renderer.info.frame;let t;e.isComputeNode===!0?t="c:"+this.renderer.info.compute.frameCalls:t="r:"+this.renderer.info.render.frameCalls,n.timestampUID=t+":"+e.id+":f"+s}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?TimestampQuery.COMPUTE:TimestampQuery.RENDER,n=this.timestampQueryPool[t];return n}getTimestamp(e){const t=this._getQueryPool(e);return t.getTimestamp(e)}hasTimestamp(e){const t=this._getQueryPool(e);return t.hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){warnOnce("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return _vector22=_vector22||new Vector2,this.renderer.getDrawingBufferSize(_vector22)}setScissorTest(){}getClearColor(){const e=this.renderer;return _color4=_color4||new Color4,e.getClearColor(_color4),_color4.getRGB(_color4),_color4}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==0[0]?this.parameters.canvas:createCanvasElement(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${REVISION} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===0[0]&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}_id$12=0;class DualAttributeData{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}}class WebGLAttributeUtils{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:n}=r,s=e.array,l=e.usage||n.STATIC_DRAW,d=e.isInterleavedBufferAttribute?e.data:e,i=r.get(d);let a=i.bufferGPU;a===0[0]&&(a=this._createBuffer(n,t,s,l),i.bufferGPU=a,i.bufferType=t,i.version=d.version);let o;if(s instanceof Float32Array)o=n.FLOAT;else if(typeof Float16Array!="undefined"&&s instanceof Float16Array)o=n.HALF_FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?o=n.HALF_FLOAT:o=n.UNSIGNED_SHORT;else if(s instanceof Int16Array)o=n.SHORT;else if(s instanceof Uint32Array)o=n.UNSIGNED_INT;else if(s instanceof Int32Array)o=n.INT;else if(s instanceof Int8Array)o=n.BYTE;else if(s instanceof Uint8Array)o=n.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)o=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let c={bufferGPU:a,bufferType:t,type:o,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:o===n.INT||o===n.UNSIGNED_INT||e.gpuType===IntType,id:_id$12++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(n,t,s,l);c=new DualAttributeData(c,e)}r.set(e,c)}updateAttribute(e){const r=this.backend,{gl:t}=r,s=e.array,o=e.isInterleavedBufferAttribute?e.data:e,i=r.get(o),n=i.bufferType,a=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(t.bindBuffer(n,i.bufferGPU),a.length===0)t.bufferSubData(n,0,s);else{for(let e=0,i=a.length;e<i;e++){const o=a[e];t.bufferSubData(n,o.start*s.BYTES_PER_ELEMENT,s,o.start,o.count)}o.clearUpdateRanges()}t.bindBuffer(n,null),i.version=o.version}destroyAttribute(e){const t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const s=t.get(e);n.deleteBuffer(s.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){const n=this.backend,{gl:t}=n,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:c}=n.get(r),o=e.array,i=o.byteLength;t.bindBuffer(t.COPY_READ_BUFFER,c);const s=t.createBuffer();t.bindBuffer(t.COPY_WRITE_BUFFER,s),t.bufferData(t.COPY_WRITE_BUFFER,i,t.STREAM_READ),t.copyBufferSubData(t.COPY_READ_BUFFER,t.COPY_WRITE_BUFFER,0,0,i),await n.utils._clientWaitAsync();const a=new e.array.constructor(o.length);return t.bindBuffer(t.COPY_WRITE_BUFFER,s),t.getBufferSubData(t.COPY_WRITE_BUFFER,0,a),t.deleteBuffer(s),t.bindBuffer(t.COPY_READ_BUFFER,null),t.bindBuffer(t.COPY_WRITE_BUFFER,null),a.buffer}_createBuffer(e,t,n,s){const o=e.createBuffer();return e.bindBuffer(t,o),e.bufferData(t,n,s),e.bindBuffer(t,null),o}}class WebGLState{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;equationToGL={[AddEquation]:e.FUNC_ADD,[SubtractEquation]:e.FUNC_SUBTRACT,[ReverseSubtractEquation]:e.FUNC_REVERSE_SUBTRACT},factorToGL={[ZeroFactor]:e.ZERO,[OneFactor]:e.ONE,[SrcColorFactor]:e.SRC_COLOR,[SrcAlphaFactor]:e.SRC_ALPHA,[SrcAlphaSaturateFactor]:e.SRC_ALPHA_SATURATE,[DstColorFactor]:e.DST_COLOR,[DstAlphaFactor]:e.DST_ALPHA,[OneMinusSrcColorFactor]:e.ONE_MINUS_SRC_COLOR,[OneMinusSrcAlphaFactor]:e.ONE_MINUS_SRC_ALPHA,[OneMinusDstColorFactor]:e.ONE_MINUS_DST_COLOR,[OneMinusDstAlphaFactor]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=(new Vector4).fromArray(t),this.currentViewport=(new Vector4).fromArray(n),this._tempVec4=new Vector4}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==CullFaceNone?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===CullFaceBack?t.cullFace(t.BACK):e===CullFaceFront?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e){const t=this.gl,n=this.backend.drawBuffersIndexedExt;if(!n)return;for(let s=1;s<e.length;s++)n.blendFuncSeparateiOES(s,t.ONE,t.ZERO,t.ONE,t.ZERO)}setBlending(e,t,n,s,o,i,a,r){const{gl:c}=this;if(e===NoBlending){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==CustomBlending){if(e!==this.currentBlending||r!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==AddEquation||this.currentBlendEquationAlpha!==AddEquation)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=AddEquation,this.currentBlendEquationAlpha=AddEquation),r)switch(e){case NormalBlending:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case AdditiveBlending:c.blendFunc(c.ONE,c.ONE);break;case SubtractiveBlending:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case MultiplyBlending:c.blendFuncSeparate(c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA,c.ZERO,c.ONE);break;default:error("WebGLState: Invalid blending: ",e);break}else switch(e){case NormalBlending:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case AdditiveBlending:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE,c.ONE,c.ONE);break;case SubtractiveBlending:error("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case MultiplyBlending:error("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:error("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=r}return}o=o||t,i=i||n,a=a||s,(t!==this.currentBlendEquation||o!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(equationToGL[t],equationToGL[o]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=o),(n!==this.currentBlendSrc||s!==this.currentBlendDst||i!==this.currentBlendSrcAlpha||a!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(factorToGL[n],factorToGL[s],factorToGL[i],factorToGL[a]),this.currentBlendSrc=n,this.currentBlendDst=s,this.currentBlendSrcAlpha=i,this.currentBlendDstAlpha=a),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case NeverDepth:t.depthFunc(t.NEVER);break;case AlwaysDepth:t.depthFunc(t.ALWAYS);break;case LessDepth:t.depthFunc(t.LESS);break;case LessEqualDepth:t.depthFunc(t.LEQUAL);break;case EqualDepth:t.depthFunc(t.EQUAL);break;case GreaterEqualDepth:t.depthFunc(t.GEQUAL);break;case GreaterDepth:t.depthFunc(t.GREATER);break;case NotEqualDepth:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,s){const o=this._tempVec4.set(e,t,n,s);if(this.currentScissor.equals(o)===!1){const{gl:e}=this;e.scissor(o.x,o.y,o.z,o.w),this.currentScissor.copy(o)}}viewport(e,t,n,s){const o=this._tempVec4.set(e,t,n,s);if(this.currentViewport.equals(o)===!1){const{gl:e}=this;e.viewport(o.x,o.y,o.z,o.w),this.currentViewport.copy(o)}}setScissorTest(e){const t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){const{gl:s}=this;e.side===DoubleSide?this.disable(s.CULL_FACE):this.enable(s.CULL_FACE);let o=e.side===BackSide;t&&(o=!o),this.setFlipSided(o),e.blending===NormalBlending&&e.transparent===!1?this.setBlending(NoBlending):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const i=e.stencilWrite;if(this.setStencilTest(i),i&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){const e=
20112288;for(let t=0;t<8;t++)t<n?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,n){const{gl:s}=this;e?(this.enable(s.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(s.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(s.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){const n=this.gl;return(this.currentVAO!==e||this.currentIndex!==t)&&(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0)}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:n,currentBoundFramebuffers:s}=this;return s[e]!==t&&(n.bindFramebuffer(e,t),s[e]=t,e===n.DRAW_FRAMEBUFFER&&(s[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(s[n.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){const{gl:s}=this;let n=[],o=!1;if(e.textures!==null){{n=this.currentDrawbuffers.get(t),n===0[0]&&(n=[],this.currentDrawbuffers.set(t,n));const i=e.textures;if(n.length!==i.length||n[0]!==s.COLOR_ATTACHMENT0){for(let e=0,t=i.length;e<t;e++)n[e]=s.COLOR_ATTACHMENT0+e;n.length=i.length,o=!0}}}else n[0]!==s.BACK&&(n[0]=s.BACK,o=!0);o&&s.drawBuffers(n)}activeTexture(e){const{gl:t,currentTextureSlot:n,maxTextures:s}=this;e===0[0]&&(e=t.TEXTURE0+s-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){const{gl:o,currentTextureSlot:i,currentBoundTextures:a,maxTextures:r}=this;n===0[0]&&(i===null?n=o.TEXTURE0+r-1:n=i);let s=a[n];s===0[0]&&(s={type:0[0],texture:0[0]},a[n]=s),(s.type!==e||s.texture!==t)&&(i!==n&&(o.activeTexture(n),this.currentTextureSlot=n),o.bindTexture(e,t),s.type=e,s.texture=t)}bindBufferBase(e,t,n){const{gl:o}=this,s=`${e}-${t}`;return this.currentBoundBufferBases[s]!==n&&(o.bindBufferBase(e,t,n),this.currentBoundBufferBases[s]=n,!0)}unbindTexture(){const{gl:t,currentTextureSlot:n,currentBoundTextures:s}=this,e=s[n];e!==0[0]&&e.type!==0[0]&&(t.bindTexture(e.type,null),e.type=0[0],e.texture=0[0])}}class WebGLUtils{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=NoColorSpace){const{gl:s,extensions:i}=this;let n;const o=ColorManagement.getTransfer(t);if(e===UnsignedByteType)return s.UNSIGNED_BYTE;if(e===UnsignedShort4444Type)return s.UNSIGNED_SHORT_4_4_4_4;if(e===UnsignedShort5551Type)return s.UNSIGNED_SHORT_5_5_5_1;if(e===UnsignedInt5999Type)return s.UNSIGNED_INT_5_9_9_9_REV;if(e===UnsignedInt101111Type)return s.UNSIGNED_INT_10F_11F_11F_REV;if(e===ByteType)return s.BYTE;if(e===ShortType)return s.SHORT;if(e===UnsignedShortType)return s.UNSIGNED_SHORT;if(e===IntType)return s.INT;if(e===UnsignedIntType)return s.UNSIGNED_INT;if(e===FloatType)return s.FLOAT;if(e===HalfFloatType)return s.HALF_FLOAT;if(e===AlphaFormat)return s.ALPHA;if(e===RGBFormat)return s.RGB;if(e===RGBAFormat)return s.RGBA;if(e===DepthFormat)return s.DEPTH_COMPONENT;if(e===DepthStencilFormat)return s.DEPTH_STENCIL;if(e===RedFormat)return s.RED;if(e===RedIntegerFormat)return s.RED_INTEGER;if(e===RGFormat)return s.RG;if(e===RGIntegerFormat)return s.RG_INTEGER;if(e===RGBAIntegerFormat)return s.RGBA_INTEGER;if(e===RGB_S3TC_DXT1_Format||e===RGBA_S3TC_DXT1_Format||e===RGBA_S3TC_DXT3_Format||e===RGBA_S3TC_DXT5_Format)if(o===SRGBTransfer)if(n=i.get("WEBGL_compressed_texture_s3tc_srgb"),n!==null){{if(e===RGB_S3TC_DXT1_Format)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT1_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT3_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===RGBA_S3TC_DXT5_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}}else return null;else if(n=i.get("WEBGL_compressed_texture_s3tc"),n!==null){{if(e===RGB_S3TC_DXT1_Format)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT1_Format)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT3_Format)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===RGBA_S3TC_DXT5_Format)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}}else return null;if(e===RGB_PVRTC_4BPPV1_Format||e===RGB_PVRTC_2BPPV1_Format||e===RGBA_PVRTC_4BPPV1_Format||e===RGBA_PVRTC_2BPPV1_Format)if(n=i.get("WEBGL_compressed_texture_pvrtc"),n!==null){{if(e===RGB_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===RGB_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===RGBA_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===RGBA_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}}else return null;if(e===RGB_ETC1_Format||e===RGB_ETC2_Format||e===RGBA_ETC2_EAC_Format||e===R11_EAC_Format||e===SIGNED_R11_EAC_Format||e===RG11_EAC_Format||e===SIGNED_RG11_EAC_Format)if(n=i.get("WEBGL_compressed_texture_etc"),n!==null){{if(e===RGB_ETC1_Format||e===RGB_ETC2_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(e===RGBA_ETC2_EAC_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC;
201if(e===R11_EAC_Format)return n.COMPRESSED_R11_EAC;if(e===SIGNED_R11_EAC_Format)return n.COMPRESSED_SIGNED_R11_EAC;if(e===RG11_EAC_Format)return n.COMPRESSED_RG11_EAC;if(e===SIGNED_RG11_EAC_Format)return n.COMPRESSED_SIGNED_RG11_EAC}}else return null;if(e===RGBA_ASTC_4x4_Format||e===RGBA_ASTC_5x4_Format||e===RGBA_ASTC_5x5_Format||e===RGBA_ASTC_6x5_Format||e===RGBA_ASTC_6x6_Format||e===RGBA_ASTC_8x5_Format||e===RGBA_ASTC_8x6_Format||e===RGBA_ASTC_8x8_Format||e===RGBA_ASTC_10x5_Format||e===RGBA_ASTC_10x6_Format||e===RGBA_ASTC_10x8_Format||e===RGBA_ASTC_10x10_Format||e===RGBA_ASTC_12x10_Format||e===RGBA_ASTC_12x12_Format)if(n=i.get("WEBGL_compressed_texture_astc"),n!==null){{if(e===RGBA_ASTC_4x4_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===RGBA_ASTC_5x4_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===RGBA_ASTC_5x5_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===RGBA_ASTC_6x5_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===RGBA_ASTC_6x6_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===RGBA_ASTC_8x5_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===RGBA_ASTC_8x6_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===RGBA_ASTC_8x8_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===RGBA_ASTC_10x5_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===RGBA_ASTC_10x6_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===RGBA_ASTC_10x8_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===RGBA_ASTC_10x10_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===RGBA_ASTC_12x10_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===RGBA_ASTC_12x12_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}}else return null;if(e===RGBA_BPTC_Format)if(n=i.get("EXT_texture_compression_bptc"),n!==null){if(e===RGBA_BPTC_Format)return o===SRGBTransfer?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===RED_RGTC1_Format||e===SIGNED_RED_RGTC1_Format||e===RED_GREEN_RGTC2_Format||e===SIGNED_RED_GREEN_RGTC2_Format)if(n=i.get("EXT_texture_compression_rgtc"),n!==null){{if(e===RED_RGTC1_Format)return n.COMPRESSED_RED_RGTC1_EXT;if(e===SIGNED_RED_RGTC1_Format)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===RED_GREEN_RGTC2_Format)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===SIGNED_RED_GREEN_RGTC2_Format)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}}else return null;return e===UnsignedInt248Type?s.UNSIGNED_INT_24_8:s[e]!==0[0]?s[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,s)=>{function o(){const i=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(i===e.WAIT_FAILED){e.deleteSync(t),s();return}if(i===e.TIMEOUT_EXPIRED){requestAnimationFrame(o);return}e.deleteSync(t),n()}o()})}}initialized=!1;class WebGLTextureUtils{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,initialized===!1&&(this._init(),initialized=!0)}_init(){const e=this.gl;wrappingToGL={[RepeatWrapping]:e.REPEAT,[ClampToEdgeWrapping]:e.CLAMP_TO_EDGE,[MirroredRepeatWrapping]:e.MIRRORED_REPEAT},filterToGL={[NearestFilter]:e.NEAREST,[NearestMipmapNearestFilter]:e.NEAREST_MIPMAP_NEAREST,[NearestMipmapLinearFilter]:e.NEAREST_MIPMAP_LINEAR,[LinearFilter]:e.LINEAR,[LinearMipmapNearestFilter]:e.LINEAR_MIPMAP_NEAREST,[
vendor: 7,898 bytes, line 201
201LinearMipmapLinearFilter]:e.LINEAR_MIPMAP_LINEAR},compareToGL={[NeverCompare]:e.NEVER,[AlwaysCompare]:e.ALWAYS,[LessCompare]:e.LESS,[LessEqualCompare]:e.LEQUAL,[EqualCompare]:e.EQUAL,[GreaterEqualCompare]:e.GEQUAL,[GreaterCompare]:e.GREATER,[NotEqualCompare]:e.NOTEQUAL}}getGLTextureType(e){const{gl:n}=this;let t;return e.isCubeTexture===!0?t=n.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t=n.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t=n.TEXTURE_3D:t=n.TEXTURE_2D,t}getInternalFormat(e,t,n,s,o=!1){const{gl:i,extensions:r}=this;if(e!==null){if(i[e]!==0[0])return i[e];warn("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let a=t;if(t===i.RED&&(n===i.FLOAT&&(a=i.R32F),n===i.HALF_FLOAT&&(a=i.R16F),n===i.UNSIGNED_BYTE&&(a=i.R8),n===i.UNSIGNED_SHORT&&(a=i.R16),n===i.UNSIGNED_INT&&(a=i.R32UI),n===i.BYTE&&(a=i.R8I),n===i.SHORT&&(a=i.R16I),n===i.INT&&(a=i.R32I)),t===i.RED_INTEGER&&(n===i.UNSIGNED_BYTE&&(a=i.R8UI),n===i.UNSIGNED_SHORT&&(a=i.R16UI),n===i.UNSIGNED_INT&&(a=i.R32UI),n===i.BYTE&&(a=i.R8I),n===i.SHORT&&(a=i.R16I),n===i.INT&&(a=i.R32I)),t===i.RG&&(n===i.FLOAT&&(a=i.RG32F),n===i.HALF_FLOAT&&(a=i.RG16F),n===i.UNSIGNED_BYTE&&(a=i.RG8),n===i.UNSIGNED_SHORT&&(a=i.RG16),n===i.UNSIGNED_INT&&(a=i.RG32UI),n===i.BYTE&&(a=i.RG8I),n===i.SHORT&&(a=i.RG16I),n===i.INT&&(a=i.RG32I)),t===i.RG_INTEGER&&(n===i.UNSIGNED_BYTE&&(a=i.RG8UI),n===i.UNSIGNED_SHORT&&(a=i.RG16UI),n===i.UNSIGNED_INT&&(a=i.RG32UI),n===i.BYTE&&(a=i.RG8I),n===i.SHORT&&(a=i.RG16I),n===i.INT&&(a=i.RG32I)),t===i.RGB){const e=o?LinearTransfer:ColorManagement.getTransfer(s);n===i.FLOAT&&(a=i.RGB32F),n===i.HALF_FLOAT&&(a=i.RGB16F),n===i.UNSIGNED_BYTE&&(a=i.RGB8),n===i.UNSIGNED_SHORT&&(a=i.RGB16),n===i.UNSIGNED_INT&&(a=i.RGB32UI),n===i.BYTE&&(a=i.RGB8I),n===i.SHORT&&(a=i.RGB16I),n===i.INT&&(a=i.RGB32I),n===i.UNSIGNED_BYTE&&(a=e===SRGBTransfer?i.SRGB8:i.RGB8),n===i.UNSIGNED_SHORT_5_6_5&&(a=i.RGB565),n===i.UNSIGNED_SHORT_5_5_5_1&&(a=i.RGB5_A1),n===i.UNSIGNED_SHORT_4_4_4_4&&(a=i.RGB4),n===i.UNSIGNED_INT_5_9_9_9_REV&&(a=i.RGB9_E5),n===i.UNSIGNED_INT_10F_11F_11F_REV&&(a=i.R11F_G11F_B10F)}if(t===i.RGB_INTEGER&&(n===i.UNSIGNED_BYTE&&(a=i.RGB8UI),n===i.UNSIGNED_SHORT&&(a=i.RGB16UI),n===i.UNSIGNED_INT&&(a=i.RGB32UI),n===i.BYTE&&(a=i.RGB8I),n===i.SHORT&&(a=i.RGB16I),n===i.INT&&(a=i.RGB32I)),t===i.RGBA){const e=o?LinearTransfer:ColorManagement.getTransfer(s);n===i.FLOAT&&(a=i.RGBA32F),n===i.HALF_FLOAT&&(a=i.RGBA16F),n===i.UNSIGNED_BYTE&&(a=i.RGBA8),n===i.UNSIGNED_SHORT&&(a=i.RGBA16),n===i.UNSIGNED_INT&&(a=i.RGBA32UI),n===i.BYTE&&(a=i.RGBA8I),n===i.SHORT&&(a=i.RGBA16I),n===i.INT&&(a=i.RGBA32I),n===i.UNSIGNED_BYTE&&(a=e===SRGBTransfer?i.SRGB8_ALPHA8:i.RGBA8),n===i.UNSIGNED_SHORT_4_4_4_4&&(a=i.RGBA4),n===i.UNSIGNED_SHORT_5_5_5_1&&(a=i.RGB5_A1)}return t===i.RGBA_INTEGER&&(n===i.UNSIGNED_BYTE&&(a=i.RGBA8UI),n===i.UNSIGNED_SHORT&&(a=i.RGBA16UI),n===i.UNSIGNED_INT&&(a=i.RGBA32UI),n===i.BYTE&&(a=i.RGBA8I),n===i.SHORT&&(a=i.RGBA16I),n===i.INT&&(a=i.RGBA32I)),t===i.DEPTH_COMPONENT&&(n===i.UNSIGNED_SHORT&&(a=i.DEPTH_COMPONENT16),n===i.UNSIGNED_INT&&(a=i.DEPTH_COMPONENT24),n===i.FLOAT&&(a=i.DEPTH_COMPONENT32F)),t===i.DEPTH_STENCIL&&n===i.UNSIGNED_INT_24_8&&(a=i.DEPTH24_STENCIL8),(a===i.R16F||a===i.R32F||a===i.RG16F||a===i.RG32F||a===i.RGBA16F||a===i.RGBA32F)&&r.get("EXT_color_buffer_float"),a}setTextureParameters(e,t){const{gl:n,extensions:s,backend:o}=this,i=ColorManagement.getPrimaries(ColorManagement.workingColorSpace),a=t.colorSpace===NoColorSpace?null:ColorManagement.getPrimaries(t.colorSpace),r=t.colorSpace===NoColorSpace||i===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,r),n.texParameteri(e,n.TEXTURE_WRAP_S,wrappingToGL[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,wrappingToGL[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,wrappingToGL[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,filterToGL[t.magFilter]);const c=t.mipmaps!==0[0]&&t.mipmaps.length>0,l=t.minFilter===LinearFilter&&c?LinearMipmapLinearFilter:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,filterToGL[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,compareToGL[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===NearestFilter)return;if(t.minFilter!==NearestMipmapLinearFilter&&t.minFilter!==LinearMipmapLinearFilter)return;if(t.type===FloatType&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const i=s.get("EXT_texture_filter_anisotropic");n.texParameterf(e,i.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,o.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:o,defaultTextures:i}=this,n=this.getGLTextureType(e);let s=i[n];s===0[0]&&(s=t.createTexture(),o.state.bindTexture(n,s),t.texParameteri(n,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),i[n]=s),o.set(e,{textureGPU:s,glTextureType:n})}createTexture(e,t){const{gl:n,backend:s}=this,{levels:a,width:r,height:c,depth:l}=t,d=s.utils.convert(e.format,e.colorSpace),u=s.utils.convert(e.type),o=this.getInternalFormat(e.internalFormat,d,u,e.colorSpace,e.isVideoTexture),h=n.createTexture(),i=this.getGLTextureType(e);s.state.bindTexture(i,h),this.setTextureParameters(i,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,a,o,r,c,l):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,a,o,r,c,l):e.isVideoTexture||n.texStorage2D(i,a,o,r,c),s.set(e,{textureGPU:h,glTextureType:i,glFormat:d,glType:u,glInternalFormat:o})}copyBufferToTexture(e,t){const{gl:n,backend:s}=this,{textureGPU:i,glTextureType:o,glFormat:a,glType:r}=s.get(t),{width:c,height:l}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(o,i),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,c,l,a,r,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:a,height:r}=t,{textureGPU:c,glTextureType:i,glFormat:s,glType:o,glInternalFormat:l}=this.backend.get(e);if(e.isRenderTargetTexture||c===0[0])return;if(this.backend.state.bindTexture(i,c),this.setTextureParameters(i,e),e.isCompressedTexture){const i=e.mipmaps,a=t.image;for(let r=0;r<i.length;r++){const t=i[r];e.isCompressedArrayTexture?e.format!==n.RGBA?s!==null?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,r,0,0,0,t.width,t.height,a.depth,s,t.data):warn("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texSubImage3D(n.TEXTURE_2D_ARRAY,r,0,0,0,t.width,t.height,a.depth,s,o,t.data):s!==null?n.compressedTexSubImage2D(n.TEXTURE_2D,r,0,0,t.width,t.height,s,t.data):warn("WebGLBackend: Unsupported compressed texture format")}}else if(e.isCubeTexture){const c=t.images,i=e.mipmaps;for(let e=0;e<6;e++){const t=getImage(c[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,a,r,s,o,t);for(let t=0;t<i.length;t++){const r=i[t],a=getImage(r.images[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,a.width,a.height,s,o,a)}}}else if(e.isDataArrayTexture||e.isArrayTexture){const i=t.image;if(e.layerUpdates.size>0){const t=getByteLength(i.width,i.height,e.format,e.type);for(const a of e.layerUpdates){const r=i.data.subarray(a*t/i.data.BYTES_PER_ELEMENT,(a+1)*t/i.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,a,i.width,i.height,1,s,o,r)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,s,o,i.data)}else if(e.isData3DTexture){const e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,o,e.data)}
201else if(e.isVideoTexture)e.update(),n.texImage2D(i,0,l,s,o,t.image);else{const c=e.mipmaps;if(c.length>0)for(let e=0,a=c.length;e<a;e++){const t=c[e],r=getImage(t);n.texSubImage2D(i,e,0,0,t.width,t.height,s,o,r)}else{const e=getImage(t.image);n.texSubImage2D(i,0,0,0,a,r,s,o,e)}}}generateMipmaps(e){const{gl:s,backend:t}=this,{textureGPU:o,glTextureType:n}=t.get(e);t.state.bindTexture(n,o),s.generateMipmap(n)}deallocateRenderBuffers(e){const{gl:t,backend:n}=this;if(e){const s=n.get(e);if(s.renderBufferStorageSetup=0[0],s.framebuffers){for(const e in s.framebuffers)t.deleteFramebuffer(s.framebuffers[e]);delete s.framebuffers}if(s.depthRenderbuffer&&(t.deleteRenderbuffer(s.depthRenderbuffer),delete s.depthRenderbuffer),s.stencilRenderbuffer&&(t.deleteRenderbuffer(s.stencilRenderbuffer),delete s.stencilRenderbuffer),s.msaaFrameBuffer&&(t.deleteFramebuffer(s.msaaFrameBuffer),delete s.msaaFrameBuffer),s.msaaRenderbuffers){for(let e=0;e<s.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(s.msaaRenderbuffers[e]);delete s.msaaRenderbuffers}}}destroyTexture(e,t=!1){const{gl:s,backend:n}=this,{textureGPU:o,renderTarget:i}=n.get(e);this.deallocateRenderBuffers(i),t===!1&&s.deleteTexture(o),n.delete(e)}copyTextureToTexture(e,t,n=null,s=null,o=0,i=0){const{gl:a,backend:b}=this,{state:h}=this.backend,{textureGPU:w,glTextureType:v,glType:_,glFormat:j}=b.get(t);h.bindTexture(v,w);let c,l,m,p,g,y,d,u,f;const r=e.isCompressedTexture?e.mipmaps[i]:e.image;if(n!==null)c=n.max.x-n.min.x,l=n.max.y-n.min.y,m=n.isBox3?n.max.z-n.min.z:1,p=n.min.x,g=n.min.y,y=n.isBox3?n.min.z:0;else{const t=2**-o;c=Math.floor(r.width*t),l=Math.floor(r.height*t),e.isDataArrayTexture||e.isArrayTexture?m=r.depth:e.isData3DTexture?m=Math.floor(r.depth*t):m=1,p=0,g=0,y=0}s!==null?(d=s.x,u=s.y,f=s.z):(d=0,u=0,f=0),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(a.UNPACK_ALIGNMENT,t.unpackAlignment);const C=a.getParameter(a.UNPACK_ROW_LENGTH),E=a.getParameter(a.UNPACK_IMAGE_HEIGHT),k=a.getParameter(a.UNPACK_SKIP_PIXELS),A=a.getParameter(a.UNPACK_SKIP_ROWS),S=a.getParameter(a.UNPACK_SKIP_IMAGES);a.pixelStorei(a.UNPACK_ROW_LENGTH,r.width),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,r.height),a.pixelStorei(a.UNPACK_SKIP_PIXELS,p),a.pixelStorei(a.UNPACK_SKIP_ROWS,g),a.pixelStorei(a.UNPACK_SKIP_IMAGES,y);const x=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,O=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){const n=b.get(e),s=b.get(t),r=b.get(n.renderTarget),v=b.get(s.renderTarget),j=r.framebuffers[n.cacheKey],_=v.framebuffers[s.cacheKey];h.bindFramebuffer(a.READ_FRAMEBUFFER,j),h.bindFramebuffer(a.DRAW_FRAMEBUFFER,_);for(let e=0;e<m;e++)x&&(a.framebufferTextureLayer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,n.textureGPU,o,y+e),a.framebufferTextureLayer(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,w,i,f+e)),a.blitFramebuffer(p,g,c,l,d,u,c,l,a.DEPTH_BUFFER_BIT,a.NEAREST);h.bindFramebuffer(a.READ_FRAMEBUFFER,null),h.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)}else if(o!==0||e.isRenderTargetTexture||b.has(e)){const t=b.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=a.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=a.createFramebuffer()),h.bindFramebuffer(a.READ_FRAMEBUFFER,this._srcFramebuffer),h.bindFramebuffer(a.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<m;e++)x?a.framebufferTextureLayer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,t.textureGPU,o,y+e):a.framebufferTexture2D(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,t.textureGPU,o),O?a.framebufferTextureLayer(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,w,i,f+e):a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,w,i),o!==0?a.blitFramebuffer(p,g,c,l,d,u,c,l,a.COLOR_BUFFER_BIT,a.NEAREST):O?a.copyTexSubImage3D(v,i,d,u,f+e,p,g,c,l):a.copyTexSubImage2D(v,i,d,u,p,g,c,l);h.bindFramebuffer(a.READ_FRAMEBUFFER,null),h.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)}else O?e.isDataTexture||e.isData3DTexture?a.texSubImage3D(v,i,d,u,f,c,l,m,j,_,r.data):t.isCompressedArrayTexture?a.compressedTexSubImage3D(v,i,d,u,f,c,l,m,j,r.data):a.texSubImage3D(v,i,d,u,f,c,l,m,j,_,r):e.isDataTexture?a.texSubImage2D(a.TEXTURE_2D,i,d,u,c,l,j,_,r.data):e.isCompressedTexture?a.compressedTexSubImage2D(a.TEXTURE_2D,i,d,u,r.width,r.height,j,r.data):a.texSubImage2D(a.TEXTURE_2D,i,d,u,c,l,j,_,r);a.pixelStorei(a.UNPACK_ROW_LENGTH,C),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,E),a.pixelStorei(a.UNPACK_SKIP_PIXELS,k),a.pixelStorei(a.UNPACK_SKIP_ROWS,A),a.pixelStorei(a.UNPACK_SKIP_IMAGES,S),i===0&&t.generateMipmaps&&a.generateMipmap(v),h.unbindTexture()}copyFramebufferToTexture(e,t,n){const{gl:s}=this,{state:o}=this.backend,{textureGPU:c}=this.backend.get(e),{x:a,y:l,z:r,w:i}=n,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){const h=a!==0||l!==0;let n,u;if(e.isDepthTexture===!0?(n=s.DEPTH_BUFFER_BIT,u=s.DEPTH_ATTACHMENT,t.stencil&&(n|=s.STENCIL_BUFFER_BIT)):(n=s.COLOR_BUFFER_BIT,u=s.COLOR_ATTACHMENT0),h){const u=this.backend.get(t.renderTarget),h=u.framebuffers[t.getCacheKey()],m=u.msaaFrameBuffer;o.bindFramebuffer(s.DRAW_FRAMEBUFFER,h),o.bindFramebuffer(s.READ_FRAMEBUFFER,m);const e=d-l-i;s.blitFramebuffer(a,e,a+r,e+i,a,e,a+r,e+i,n,s.NEAREST),o.bindFramebuffer(s.READ_FRAMEBUFFER,h),o.bindTexture(s.TEXTURE_2D,c),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,e,r,i),o.unbindTexture()}else{const e=s.createFramebuffer();o.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,u,s.TEXTURE_2D,c,0),s.blitFramebuffer(0,0,r,i,0,0,r,i,n,s.NEAREST),s.deleteFramebuffer(e)}}else o.bindTexture(s.TEXTURE_2D,c),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,d-i-l,r,i),o.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,s=!1){const{gl:o}=this,c=t.renderTarget,{depthTexture:r,depthBuffer:l,stencilBuffer:d,width:i,height:a}=c;
vendor: 1,675 bytes, line 201
201if(o.bindRenderbuffer(o.RENDERBUFFER,e),l&&!d){let t=o.DEPTH_COMPONENT24;if(s===!0){const e=this.extensions.get("WEBGL_multisampled_render_to_texture");e.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,c.samples,t,i,a)}else n>0?(r&&r.isDepthTexture&&r.type===o.FLOAT&&(t=o.DEPTH_COMPONENT32F),o.renderbufferStorageMultisample(o.RENDERBUFFER,n,t,i,a)):o.renderbufferStorage(o.RENDERBUFFER,t,i,a);o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,e)}else l&&d&&(n>0?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH24_STENCIL8,i,a):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,i,a),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,e));o.bindRenderbuffer(o.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,s,o,i){const{backend:c,gl:a}=this,{textureGPU:b,glFormat:u,glType:r}=this.backend.get(e),h=a.createFramebuffer();c.state.bindFramebuffer(a.READ_FRAMEBUFFER,h);const p=e.isCubeTexture?a.TEXTURE_CUBE_MAP_POSITIVE_X+i:a.TEXTURE_2D;a.framebufferTexture2D(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,p,b,0);const m=this._getTypedArrayType(r),v=this._getBytesPerTexel(r,u),g=s*o,l=g*v,f=a.createBuffer();a.bindBuffer(a.PIXEL_PACK_BUFFER,f),a.bufferData(a.PIXEL_PACK_BUFFER,l,a.STREAM_READ),a.readPixels(t,n,s,o,u,r,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),await c.utils._clientWaitAsync();const d=new m(l/m.BYTES_PER_ELEMENT);return a.bindBuffer(a.PIXEL_PACK_BUFFER,f),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,d),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),c.state.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.deleteFramebuffer(h),d}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;
201if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(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){const{gl:n}=this;let s=0;if(e===n.UNSIGNED_BYTE&&(s=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)&&(s=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(s=4),t===n.RGBA)return s*4;if(t===n.RGB)return s*3;if(t===n.ALPHA)return s}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function getImage(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas?e:e.data}class WebGLExtensions{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===0[0]&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class WebGLCapabilities{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const t=this.backend.gl,e=this.backend.extensions;if(e.has("EXT_texture_filter_anisotropic")===!0){const n=e.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}GLFeatureName={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",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class WebGLBufferRenderer{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){const{gl:n,mode:s,object:o,type:i,info:a,index:r}=this;r!==0?n.drawElements(s,t,i,e):n.drawArrays(s,e,t),a.update(o,t,1)}renderInstances(e,t,n){const{gl:s,mode:o,type:i,index:a,object:r,info:c}=this;if(n===0)return;a!==0?s.drawElementsInstanced(o,t,i,e,n):s.drawArraysInstanced(o,e,t,n),c.update(r,t,n)}renderMultiDraw(e,t,n){const{extensions:i,mode:o,object:a,info:r}=this;if(n===0)return;const s=i.get("WEBGL_multi_draw");if(s===null)for(let s=0;s<n;s++)this.render(e[s],t[s]);else{this.index!==0?s.multiDrawElementsWEBGL(o,t,0,this.type,e,0,n):s.multiDrawArraysWEBGL(o,e,0,t,0,n);let i=0;for(let e=0;e<n;e++)i+=t[e];r.update(a,i,1)}}renderMultiDrawInstances(e,t,n,s){const{extensions:a,mode:i,object:r,info:c}=this;if(n===0)return;const o=a.get("WEBGL_multi_draw");if(o===null)for(let o=0;o<n;o++)this.renderInstances(e[o],t[o],s[o]);else{this.index!==0?o.multiDrawElementsInstancedWEBGL(i,t,0,this.type,e,0,s,0,n):o.multiDrawArraysInstancedWE
201BGL(i,e,0,t,0,s,0,n);let a=0;for(let e=0;e<n;e++)a+=t[e]*s[e];c.update(r,a,1)}}}class TimestampQueryPool{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===0[0]&&(warn(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class WebGLTimestampQueryPool extends TimestampQueryPool{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){warn("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return warnOnce(`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;const 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;const t=this.queryOffsets.get(e);if(t==null)return;if(this.activeQuery!==null)return;const n=this.queries[t];if(!n)return;try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null)return;if(this.activeQuery!==t)return;try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const n=new Map;for(const[t,e]of this.queryOffsets){const s=this.queryStates.get(e);if(s==="ended"){const s=this.queries[e];n.set(t,this.resolveQuery(s))}}if(n.size===0)return this.lastValue;const t={},e=[];for(const[o,a]of n){const r=o.match(/^(.*):f(\d+)$/),s=parseInt(r[2]);e.includes(s)===!1&&e.push(s),t[s]===0[0]&&(t[s]=0);const i=await a;this.timestamps.set(o,i),t[s]+=i}const s=t[e[e.length-1]];return this.lastValue=s,this.frames=e,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return 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,s=!1;const a=()=>{n&&(clearTimeout(n),n=null)},o=e=>{s||(s=!0,a(),t(e))},i=()=>{if(this.isDisposed){o(this.lastValue);return}try{const s=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(s){o(this.lastValue);return}const a=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE);if(!a){n=setTimeout(i,1);return}const r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){error("Error checking query:",e),t(this.lastValue)}};i()})}dispose(){if(this.isDisposed)return;if(this.isDisposed=!0,!this.trackTimestamp)return;for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}class WebGLBackend extends Backend{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"&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,s={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},o=t.context!==0[0]?t.context:e.domElement.getContext("webgl2",s);function n(t){t.preventDefault();const n={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=o,this.extensions=new WebGLExtensions(this),this.capabilities=new WebGLCapabilities(this),this.attributeUtils=new WebGLAttributeUtils(this),this.textureUtils=new WebGLTextureUtils(this),this.bufferRenderer=new WebGLBufferRenderer(this),this.state=new WebGLState(this),this.utils=new WebGLUtils(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"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed")}get coordinateSystem(){return WebGLCoordinateSystem}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async makeXRCompatible(){const e=this.gl.getContextAttributes();e.xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),n!==null){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&warn("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 WebGLTimestampQueryPool(this.gl,e,2048));const n=this.timestampQueryPool[e],s=n.allocateQueriesForContext(t);s!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;const n=this.timestampQueryPool[e];n.endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:s}=this,t=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:t}=this.getDrawingBufferSize();s.viewport(0,0,e,t)}if(e.scissor){const{x:n,y:o,width:i,height:t}=e.scissorValue;s.scissor(n,e.height-t-o,i,t)}this.initTimestampQuery(TimestampQuery.RENDER,this.getTimestampUID(e)),t.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const n=e.occlusionQueryCount;n>0&&(t.currentOcclusionQueries=t.occlusionQueries,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,t.lastOcclusionObject=null,t.occlusionQueries=new Array(n),t.occlusionQueryObjects=new Array(n),t.occlusionQueryIndex=0)}finishRender(e){const{gl:s,state:o}=this,i=this.get(e),t=i.previousContext;o.resetVertexState();const a=e.occlusionQueryCount;a>0&&(a>i.occlusionQueryIndex&&s.endQuery(s.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const n=e.textures;if(n!==null)for(let e=0;e<n.length;e++){const t=n[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=t,this._resolveRenderTarget(e),t!==null)if(this._setFramebuffer(t),t.viewport)this.updateViewport(t);else{const{width:e,height:t}=this.getDrawingBufferSize();o.viewport(0,0,e,t)}this.prepareTimestampBuffer(TimestampQuery.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){const n=this.get(e),{currentOcclusionQueries:t,currentOcclusionQueryObjects:s}=n;if(t&&s){const o=new WeakSet,{gl:e}=this;n.currentOcclusionQueryObjects=null,n.currentOcclusionQueries=null;const i=()=>{let a=0;for(let n=0;n<t.length;n++){const i=t[n];if(i===null)continue;e.getQueryParameter(i,e.QUERY_RESULT_AVAILABLE)&&(e.getQueryParameter(i,e.QUERY_RESULT)===0&&o.add(s[n]),t[n]=null,e.deleteQuery(i),a++)}a<t.length?requestAnimationFrame(i):n.occluded=o};i()}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){const{state:n}=this,{x:s,y:o,width:i,height:t}=e.viewportValue;n.viewport(s,e.height-t-o,i,t)}setScissorTest(e){const t=this.state;t.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,s=null,o=!0,i=!0){const{gl:a,renderer:c}=this;if(s===null){const e=this.getClearColor();s={textures:null,clearColorValue:e}}let r=0;if(e&&(r|=a.COLOR_BUFFER_BIT),t&&(r|=a.DEPTH_BUFFER_BIT),n&&(r|=a.STENCIL_BUFFER_BIT),r!==0){let l;s.clearColorValue?l=s.clearColorValue:l=this.getClearColor();const d=c.getClearDepth(),u=c.getClearStencil();if(t&&this.state.setDepthMask(!0),s.textures===null)a.clearColor(l.r,l.g,l.b,l.a),a.clear(r);else{if(o&&this._setFramebuffer(s),e)for(let e=0;e<s.textures.length;
201e++)e===0?a.clearBufferfv(a.COLOR,e,[l.r,l.g,l.b,l.a]):a.clearBufferfv(a.COLOR,e,[0,0,0,1]);t&&n?a.clearBufferfi(a.DEPTH_STENCIL,0,d,u):t?a.clearBufferfv(a.DEPTH,0,[d]):n&&a.clearBufferiv(a.STENCIL,0,[u]),o&&i&&this._resolveRenderTarget(s)}}}beginCompute(e){const{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(TimestampQuery.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,s,o=null){const{state:a,gl:i}=this;this.discard===!1&&(a.enable(i.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:u,transformBuffers:r,attributes:c}=this.get(s),l=this._getVaoKey(c),d=this.vaoCache[l];d===0[0]?this.vaoCache[l]=this._createVao(c):a.setVertexState(d),a.useProgram(u),this._bindUniforms(n);const h=this._getTransformFeedback(r);i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,h),i.beginTransformFeedback(i.POINTS),o=o!==null?o:t.count,Array.isArray(o)?(warnOnce("WebGLBackend.compute(): The count parameter must be a single number, not an array."),o=o[0]):o&&typeof o=="object"&&o.isIndirectStorageBufferAttribute&&(warnOnce("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),o=t.count),c[0].isStorageInstancedBufferAttribute?i.drawArraysInstanced(i.POINTS,0,1,o):i.drawArrays(i.POINTS,0,o),i.endTransformFeedback(),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null);for(let t=0;t<r.length;t++){const e=r[t];e.pbo&&this.has(e.pbo)&&this.textureUtils.copyBufferToTexture(e.transformBuffer,e.pbo),e.switchBuffers()}}finishCompute(e){const{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(TimestampQuery.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:w,material:m,context:l,hardwareClippingPlanes:_}=e,{programGPU:y}=this.get(w),{gl:n,state:i}=this,a=this.get(l),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());const b=t.isMesh&&t.matrixWorld.determinant()<0;i.setMaterial(m,b,_),l.textures!==null&&l.textures.length>1&&i.setMRTBlending(l.textures),i.useProgram(y);const h=e.getAttributes(),f=this.get(h);let o=f.vaoGPU;if(o===0[0]){const e=this._getVaoKey(h);o=this.vaoCache[e],o===0[0]&&(o=this._createVao(h),this.vaoCache[e]=o,f.vaoGPU=o)}const r=e.getIndex(),j=r!==null?this.get(r).bufferGPU:null;i.setVertexState(o,j);const c=a.lastOcclusionObject;if(c!==t&&c!==0[0]){if(c!==null&&c.occlusionTest===!0&&(n.endQuery(n.ANY_SAMPLES_PASSED),a.occlusionQueryIndex++),t.occlusionTest===!0){const e=n.createQuery();n.beginQuery(n.ANY_SAMPLES_PASSED,e),a.occlusionQueries[a.occlusionQueryIndex]=e,a.occlusionQueryObjects[a.occlusionQueryIndex]=t}a.lastOcclusionObject=t}const s=this.bufferRenderer;t.isPoints?s.mode=n.POINTS:t.isLineSegments?s.mode=n.LINES:t.isLine?s.mode=n.LINE_STRIP:t.isLineLoop?s.mode=n.LINE_LOOP:m.wireframe===!0?(i.setLineWidth(m.wireframeLinewidth*this.renderer.getPixelRatio()),s.mode=n.LINES):s.mode=n.TRIANGLES;const{vertexCount:g,instanceCount:p}=u;let{firstVertex:d}=u;if(s.object=t,r!==null){d*=r.array.BYTES_PER_ELEMENT;const e=this.get(r);s.index=r.count,s.type=e.type}else s.index=0;const v=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(warnOnce("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),s.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?s.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):warnOnce("WebGLBackend: WEBGL_multi_draw not supported."):p>1?s.renderInstances(d,g,p):s.render(d,g)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const o=this.get(e.camera),s=e.camera.cameras,d=e.getBindingGroup("cameraIndex").bindings[0];if(o.indexesGPU===0[0]||o.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let o=0,a=s.length;o<a;o++){const i=n.createBuffer();e[0]=o,n.bindBuffer(n.UNIFORM_BUFFER,i),n.bufferData(n.UNIFORM_BUFFER,e,n.STATIC_DRAW),t.push(i)}o.indexesGPU=t}const u=this.get(d),a=this.renderer.getPixelRatio(),c=this._currentContext.renderTarget,l=this._isRenderCameraDepthArray(this._currentContext),r=this._currentContext.activeCubeFace;if(l){const e=this.get(c.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:t}=c;for(let e=0,n=s.length;e<n;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=r,this._currentContext.activeCubeFace=r}}for(let c=0,h=s.length;c<h;c++){const d=s[c];if(t.layers.test(d.layers)){l&&(this.renderer._activeCubeFace=c,this._currentContext.activeCubeFace=c,this._setFramebuffer(this._currentContext));const t=d.viewport;if(t!==0[0]){const s=t.x*a,o=t.y*a,r=t.width*a,n=t.height*a;i.viewport(Math.floor(s),Math.floor(e.context.height-n-o),Math.floor(r),Math.floor(n))}i.bindBufferBase(n.UNIFORM_BUFFER,u.index,o.indexesGPU[c]),v()}this._currentContext.activeCubeFace=r,this.renderer._activeCubeFace=r}}else v()}
201needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,s,o,i){return this.textureUtils.copyTextureToBuffer(e,t,n,s,o,i)}updateSampler(){return""}createNodeBuilder(e,t){return new GLSLNodeBuilder(e,t)}createProgram(e){const t=this.gl,{stage:s,code:o}=e,n=s==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(n,o),t.compileShader(n),this.set(e,{shaderGPU:n})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,o=e.pipeline,{fragmentProgram:r,vertexProgram:c}=o,s=n.createProgram(),i=this.get(r).shaderGPU,a=this.get(c).shaderGPU;if(n.attachShader(s,i),n.attachShader(s,a),n.linkProgram(s),this.set(o,{programGPU:s,fragmentShader:i,vertexShader:a}),t!==null&&this.parallel){const i=new Promise(t=>{const a=this.parallel,i=()=>{n.getProgramParameter(s,a.COMPLETION_STATUS_KHR)?(this._completeCompile(e,o),t()):requestAnimationFrame(i)};i()});t.push(i);return}this._completeCompile(e,o)}_handleSource(e,t){const n=e.split(` 202`),s=[],o=Math.max(t-6,0),i=Math.min(t+6,n.length);for(let e=o;e<i;e++){const a=e+1;s.push(`${a===t?">":" "} ${a}: ${n[e]}`)}return s.join(` 203`)}
vendor: 4,349 bytes, lines 203-213
203_getShaderErrors(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),a=e.getShaderInfoLog(t)||"",s=a.trim();if(i&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const i=parseInt(o[1]);return n.toUpperCase()+` 204 205`+s+` 206 207`+this._handleSource(e.getShaderSource(t),i)}return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e)||"",o=i.trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,n,t);else{const i=this._getShaderErrors(s,n,"vertex"),a=this._getShaderErrors(s,t,"fragment");error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+` 208 209`+"Program Info Log: "+o+` 210`+i+` 211`+a)}else o!==""&&warn("WebGLProgram: Program Info Log:",o)}}_completeCompile(e,t){const{state:o,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:r}=i;s.getProgramParameter(n,s.LINK_STATUS)===!1&&this._logProgramError(n,a,r),o.useProgram(n);const c=e.getBindings();this._setupBindings(c,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:f,gl:n}=this,a={stage:"fragment",code:`#version 300 es 212precision highp float; 213void main() {}`};this.createProgram(a);const{computeProgram:i}=e,s=n.createProgram(),r=this.get(a).shaderGPU,c=this.get(i).shaderGPU,l=i.transforms,d=[],o=[];for(let e=0;e<l.length;e++){const t=l[e];d.push(t.varyingName),o.push(t.attributeNode)}n.attachShader(s,r),n.attachShader(s,c),n.transformFeedbackVaryings(s,d,n.SEPARATE_ATTRIBS),n.linkProgram(s),n.getProgramParameter(s,n.LINK_STATUS)===!1&&this._logProgramError(s,r,c),f.useProgram(s),this._setupBindings(t,s);const u=i.attributes,h=[],m=[];for(let e=0;e<u.length;e++){const t=u[e].node.attribute;h.push(t),this.has(t)||this.attributeUtils.createAttribute(t,n.ARRAY_BUFFER)}for(let e=0;e<o.length;e++){const t=o[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,n.ARRAY_BUFFER);const s=this.get(t);m.push(s)}this.set(e,{programGPU:s,transformBuffers:m,attributes:h})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let e=0,n=0;for(const s of t){this.set(s,{textures:n,uniformBuffers:e});for(const t of s.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,n=this.get(e);let s=n.uniformBuffers,o=n.textures;for(const n of e.bindings){const i=this.get(n);if(n.isUniformsGroup||n.isUniformBuffer){const e=n.buffer;let{bufferGPU:o}=this.get(e);o===0[0]?(o=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,o),t.bufferData(t.UNIFORM_BUFFER,e.byteLength,t.DYNAMIC_DRAW),this.set(e,{bufferGPU:o})):t.bindBuffer(t.UNIFORM_BUFFER,o);const a=n.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,o),a.length===0)t.bufferData(t.UNIFORM_BUFFER,e,t.DYNAMIC_DRAW);else{const n=isTypedArray(e),s=n?1:e.BYTES_PER_ELEMENT;for(let o=0,c=a.length;o<c;o++){const i=a[o],r=i.start*s,l=i.count*s,d=r*(n?e.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,d,e,r,l)}}i.index=s++,i.bufferGPU=o,this.set(n,i)}else if(n.isSampledTexture){const{textureGPU:e,glTextureType:t}=this.get(n.texture);i.index=o++,i.textureGPU=e,i.glTextureType=t,this.set(n,i)}}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const o=this.get(e),i=o.bufferGPU,n=e.buffer,s=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,i),s.length===0)t.bufferData(t.UNIFORM_BUFFER,n,t.DYNAMIC_DRAW);else{const e=isTypedArray(n),o=e?1:n.BYTES_PER_ELEMENT;for(let i=0,c=s.length;i<c;i++){const a=s[i],r=a.start*o,l=a.count*o,d=r*(e?n.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,d,n,r,l)}}}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(GLFeatureName).filter(t=>GLFeatureName[t]===e),n=this.extensions;for(let e=0;e<t.length;e++)if(n.has(t[e]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}
213copyTextureToTexture(e,t,n=null,s=null,o=0,i=0){this.textureUtils.copyTextureToTexture(e,t,n,s,o,i)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}_setFramebuffer(e){const{gl:t,state:n}=this;let s=null;if(e.textures!==null){const i=e.renderTarget,o=this.get(i),{samples:r,depthBuffer:y,stencilBuffer:l}=i,v=i.isWebGLCubeRenderTarget===!0,j=i.isRenderTarget3D===!0,b=i.depth>1,p=i.isXRRenderTarget===!0,g=p===!0&&i._hasExternalTextures===!0;let h=o.msaaFrameBuffer,m=o.depthRenderbuffer;const u=this.extensions.get("WEBGL_multisampled_render_to_texture"),f=this.extensions.get("OVR_multiview2"),c=this._useMultisampledExtension(i),d=getCacheKey(e);let a;if(v?(o.cubeFramebuffers||(o.cubeFramebuffers={}),a=o.cubeFramebuffers[d]):p&&g===!1?a=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),a=o.framebuffers[d]),a===0[0]){a=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,a);const h=e.textures,m=[];if(v){o.cubeFramebuffers[d]=a;const{textureGPU:e}=this.get(h[0]),n=this.renderer._activeCubeFace,s=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,s)}else{o.framebuffers[d]=a;for(let s=0;s<h.length;s++){const a=h[s],n=this.get(a);n.renderTarget=e.renderTarget,n.cacheKey=d;const o=t.COLOR_ATTACHMENT0+s;if(i.multiview)f.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,o,n.textureGPU,0,r,0,2);else if(j||b){const e=this.renderer._activeCubeFace,s=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,o,n.textureGPU,s,e)}else if(c)u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,t.TEXTURE_2D,n.textureGPU,0,r);else{const e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,n.textureGPU,e)}}}const s=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){const n=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(n,e,0,c),o.xrDepthRenderbuffer=n,m.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,n)}else if(e.depthTexture!==null){m.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const n=this.get(e.depthTexture);if(n.renderTarget=e.renderTarget,n.cacheKey=d,i.multiview)f.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,r,0,2);else if(g&&c)u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,r);else if(e.depthTexture.isArrayTexture){const e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,s,n.textureGPU,0,e)}else if(e.depthTexture.isCubeTexture){const e=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}o.depthInvalidationArray=m}else{const s=this._isRenderCameraDepthArray(e);if(s){n.bindFramebuffer(t.FRAMEBUFFER,a);const s=this.renderer._activeCubeFace,o=this.get(e.depthTexture),i=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,i,o.textureGPU,0,s)}if((p||c||i.multiview)&&i._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,a);const d=this.get(e.textures[0]);i.multiview?f.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,d.textureGPU,0,r,0,2):c?u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,d.textureGPU,0,r):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,d.textureGPU,0);const s=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){const e=o.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{const n=this.get(e.depthTexture);i.multiview?f.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,r,0,2):c?u.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,r):t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}}}if(r>0&&c===!1&&!i.multiview){if(h===0[0]){const i=[];h=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,h);const s=[],a=e.textures;for(let n=0;n<a.length;n++){s[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,s[n]),i.push(t.COLOR_ATTACHMENT0+n);const o=e.textures[n],c=this.get(o);t.renderbufferStorageMultisample(t.RENDERBUFFER,r,c.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,s[n])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),o.msaaFrameBuffer=h,o.msaaRenderbuffers=s,y&&m===0[0]){m=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(m,e,r),o.depthRenderbuffer=m;const n=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;i.push(n)}o.invalidationArray=i}s=o.msaaFrameBuffer}else s=a;n.drawBuffers(e,a)}n.bindFramebuffer(t.FRAMEBUFFER,s)}_getVaoKey(e){let t="";for(let n=0;n<e.length;n++){const s=this.get(e[n]);t+=":"+s.id}return t}_createVao(e){const{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let s=0;s<e.length;s++){const n=e[s],o=this.get(n);t.bindBuffer(t.ARRAY_BUFFER,o.bufferGPU),t.enableVertexAttribArray(s);let i,a;n.isInterleavedBufferAttribute===!0?(i=n.data.stride*o.bytesPerElement,a=n.offset*o.bytesPerElement):(i=0,a=0),o.isInteger?t.vertexAttribIPointer(s,n.itemSize,o.type,i,a):t.vertexAttribPointer(s,n.itemSize,o.type,n.normalized,i,a),n.isInstancedBufferAttribute&&!n.isInterleavedBufferAttribute?t.vertexAttribDivisor(s,n.meshPerAttribute):n.isInterleavedBufferAttribute&&n.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(s,n.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let s="";for(let t=0;t<e.length;t++)s+=":"+e[t].id;let n=this.transformFeedbackCache[s];if(n!==0[0])return n;const{gl:t}=this;
213n=t.createTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,n);for(let n=0;n<e.length;n++){const s=e[n];t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,n,s.transformBuffer)}return t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[s]=n,n}_setupBindings(e,t){const n=this.gl;for(const s of e)for(const e of s.bindings){const i=this.get(e),o=i.index;if(e.isUniformsGroup||e.isUniformBuffer){const s=n.getUniformBlockIndex(t,e.name);n.uniformBlockBinding(t,s,o)}else if(e.isSampledTexture){const s=n.getUniformLocation(t,e.name);n.uniform1i(s,o)}}}_bindUniforms(e){const{gl:t,state:n}=this;for(const s of e)for(const e of s.bindings){const o=this.get(e),i=o.index;e.isUniformsGroup||e.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,i,o.bufferGPU):e.isSampledTexture&&n.bindTexture(o.glTextureType,o.textureGPU,t.TEXTURE0+i)}}_resolveRenderTarget(e){const{gl:t,state:s}=this,n=e.renderTarget;if(e.textures!==null&&n){const o=this.get(n);if(n.samples>0&&this._useMultisampledExtension(n)===!1){const l=o.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;n.resolveDepthBuffer&&(n.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),n.stencilBuffer&&n.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const d=o.msaaFrameBuffer,c=o.msaaRenderbuffers,i=e.textures,r=i.length>1;if(s.bindFramebuffer(t.READ_FRAMEBUFFER,d),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,l),r)for(let e=0;e<i.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let n=0;n<i.length;n++){if(r){const{textureGPU:e}=this.get(i[n]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c[n]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){const{x:n,y:r,width:i,height:o}=e.scissorValue,s=e.height-o-r;t.blitFramebuffer(n,s,n+i,s+o,n,s,n+i,s+o,a,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,a,t.NEAREST)}if(r)for(let e=0;e<i.length;e++){const{textureGPU:n}=this.get(i[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,n,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,o.invalidationArray)}else if(n.resolveDepthBuffer===!1&&o.framebuffers){const n=o.framebuffers[e.getCacheKey()];s.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,o.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0||e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}GPUPrimitiveTopology={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},GPUShaderStage=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},GPUCompareFunction={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},GPUStoreOp={Store:"store"},GPULoadOp={Load:"load",Clear:"clear"},GPUFrontFace={CCW:"ccw",CW:"cw"},GPUCullMode={None:"none",Back:"back"},GPUIndexFormat={Uint16:"uint16",Uint32:"uint32"},GPUTextureFormat={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"},GPUAddressMode={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},GPUFilterMode={Linear:"linear",Nearest:"nearest"},GPUBlendFactor={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"},GPUBlendOperation={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},GPUColorWriteFlags={None:0,All:15},GPUStencilOperation={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},GPUBufferBindingType={Storage:"storage",ReadOnlyStorage:"read-only-storage"},GPUStorageTextureAccess={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},GPUSamplerBindingType={NonFiltering:"non-filtering",Comparison:"comparison"},GPUTextureSampleType={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},GPUTextureDimension={TwoD:"2d",ThreeD:"3d"},GPUTextureViewDimension={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},GPUTextureAspect={All:"all"},GPUInputStepMode={Vertex:"vertex",Instance:"instance"},GPUFeatureName={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"},GPUFeatureMap={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class NodeSampler extends Sampler{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update(
213)}}class StorageBuffer extends Buffer2{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}_id=0;class NodeStorageBuffer extends StorageBuffer{constructor(e,t){super("StorageBuffer_"+_id++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:NodeAccess.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class WebGPUTexturePassUtils extends DataMap{constructor(e){super(),this.device=e;const t=` 214struct VarysStruct { 215 @builtin( position ) Position: vec4<f32>, 216 @location( 0 ) vTex : vec2<f32> 217}; 218 219@vertex 220fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { 221 222 var Varys : VarysStruct; 223 224 var pos = array< vec2<f32>, 4 >( 225 vec2<f32>( -1.0, 1.0 ), 226 vec2<f32>( 1.0, 1.0 ), 227 vec2<f32>( -1.0, -1.0 ), 228 vec2<f32>( 1.0, -1.0 ) 229 ); 230 231 var tex = array< vec2<f32>, 4 >( 232 vec2<f32>( 0.0, 0.0 ), 233 vec2<f32>( 1.0, 0.0 ), 234 vec2<f32>( 0.0, 1.0 ), 235 vec2<f32>( 1.0, 1.0 ) 236 ); 237 238 Varys.vTex = tex[ vertexIndex ]; 239 Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 ); 240 241 return Varys; 242 243} 244`,n=` 245@group( 0 ) @binding( 0 ) 246var imgSampler : sampler; 247 248@group( 0 ) @binding( 1 ) 249var img : texture_2d<f32>; 250 251@fragment 252fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> { 253 254 return textureSample( img, imgSampler, vTex ); 255 256} 257`,s=` 258@group( 0 ) @binding( 0 ) 259var imgSampler : sampler; 260 261@group( 0 ) @binding( 1 ) 262var img : texture_2d<f32>; 263 264@fragment 265fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> { 266 267 return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); 268 269} 270`;this.mipmapSampler=e.createSampler({minFilter:GPUFilterMode.Linear}),this.flipYSampler=e.createSampler({minFilter:GPUFilterMode.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:s})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===0[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:GPUPrimitiveTopology.TriangleStrip,stripIndexFormat:GPUIndexFormat.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===0[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:GPUPrimitiveTopology.TriangleStrip,stripIndexFormat:GPUIndexFormat.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const s=t.format,{width:l,height:d}=t.size,u=this.getTransferPipeline(s),h=this.getFlipYPipeline(s),o=this.device.createTexture({size:{width:l,height:d,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),i=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:GPUTextureViewDimension.TwoD,baseArrayLayer:n}),a=o.createView({baseMipLevel:0,mipLevelCount:1,dimension:GPUTextureViewDimension.TwoD,baseArrayLayer:0}),r=this.device.createCommandEncoder({}),c=(e,t,n)=>{const o=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),s=r.beginRenderPass({colorAttachments:[{view:n,loadOp:GPULoadOp.Clear,storeOp:GPUStoreOp.Store,clearValue:[0,0,0,0]}]});s.setPipeline(e),s.setBindGroup(0,i),s.draw(4,1,0,0),s.end()};c(u,i,a),c(h,a,i),this.device.queue.submit([r.finish()]),o.destroy()}generateMipmaps(e,t,n=0,s=null){const o=this.get(e);o.layers===0[0]&&(o.layers=[]);const i=o.layers[n]||this._mipmapCreateBundles(e,t,n),a=s||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(a,i),s===null&&this.device.queue.submit([a.finish()]),o.layers[n]=i}
270_mipmapCreateBundles(e,t,n){const s=this.getTransferPipeline(t.format),a=s.getBindGroupLayout(0);let o=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:GPUTextureViewDimension.TwoD,baseArrayLayer:n});const i=[];for(let c=1;c<t.mipLevelCount;c++){const d=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:o}]}),l=e.createView({baseMipLevel:c,mipLevelCount:1,dimension:GPUTextureViewDimension.TwoD,baseArrayLayer:n}),u={colorAttachments:[{view:l,loadOp:GPULoadOp.Clear,storeOp:GPUStoreOp.Store,clearValue:[0,0,0,0]}]},r=this.device.createRenderBundleEncoder({colorFormats:[t.format]});r.setPipeline(s),r.setBindGroup(0,d),r.draw(4,1,0,0),i.push({renderBundles:[r.finish()],passDescriptor:u}),o=l}return i}_mipmapRunBundles(e,t){const n=t.length;for(let s=0;s<n;s++){const o=t[s],i=e.beginRenderPass(o.passDescriptor);i.executeBundles(o.renderBundles),i.end()}}}_compareToWebGPU={[NeverCompare]:"never",[LessCompare]:"less",[EqualCompare]:"equal",[LessEqualCompare]:"less-equal",[GreaterCompare]:"greater",[GreaterEqualCompare]:"greater-equal",[AlwaysCompare]:"always",[NotEqualCompare]:"not-equal"},_flipMap=[0,1,3,2,4,5];class WebGPUTextureUtils{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){const o=this.backend,s=e.minFilter+"-"+e.magFilter+"-"+e.wrapS+"-"+e.wrapT+"-"+(e.wrapR||"0")+"-"+e.anisotropy+"-"+(e.compareFunction||0);let t=this._samplerCache.get(s);if(t===0[0]){const n={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};n.magFilter===GPUFilterMode.Linear&&n.minFilter===GPUFilterMode.Linear&&n.mipmapFilter===GPUFilterMode.Linear&&(n.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(n.compare=_compareToWebGPU[e.compareFunction]);const i=o.device.createSampler(n);t={sampler:i,usedTimes:0},this._samplerCache.set(s,t)}const n=o.get(e);if(n.sampler!==t.sampler){if(n.sampler!==0[0]){const e=this._samplerCache.get(n.samplerKey);e.usedTimes--,e.usedTimes===0&&this._samplerCache.delete(n.samplerKey)}n.samplerKey=s,n.sampler=t.sampler,t.usedTimes++}
270return s}createDefaultTexture(e){let t;const n=getFormat(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(n):t=this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){const s=this.backend,n=s.get(e);if(n.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){n.texture=e.sourceTexture,n.initialized=!0;return}t.needsMipmaps===0[0]&&(t.needsMipmaps=!1),t.levels===0[0]&&(t.levels=1),t.depth===0[0]&&(t.depth=1);const{width:f,height:m,depth:l,levels:c}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const r=this._getDimension(e),i=e.internalFormat||t.format||getFormat(e,s.device);n.format=i;const{samples:d,primarySamples:u,isMSAA:h}=s.utils.getTextureSampleData(e);let a=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(a|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&i!==GPUTextureFormat.RGB9E5UFloat&&(a|=GPUTextureUsage.RENDER_ATTACHMENT);const o={label:e.name,size:{width:f,height:m,depthOrArrayLayers:l},mipLevelCount:c,sampleCount:u,dimension:r,format:i,usage:a};if(i===0[0]){warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(o.textureBindingViewDimension=GPUTextureViewDimension.Cube),n.texture=s.device.createTexture(o),h){const e=Object.assign({},o);e.label=e.label+"-msaa",e.sampleCount=d,e.mipLevelCount=1,n.msaaTexture=s.device.createTexture(e)}n.initialized=!0,n.textureDescriptorGPU=o}destroyTexture(e,t=!1){const s=this.backend,n=s.get(e);n.texture!==0[0]&&t===!1&&n.texture.destroy(),n.msaaTexture!==0[0]&&n.msaaTexture.destroy(),s.delete(e)}generateMipmaps(e,t=null){const n=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(n.texture,n.textureDescriptorGPU,e,t);else{const s=e.image.depth||1;for(let e=0;e<s;e++)this._generateMipmaps(n.texture,n.textureDescriptorGPU,e,t)}}getColorBuffer(){const e=this.backend,r=e.renderer.getCanvasTarget(),{width:s,height:o}=e.getDrawingBufferSize(),a=e.renderer.currentSamples,t=r.colorTexture,i=e.get(t);if(t.width===s&&t.height===o&&t.samples===a)return i.texture;let n=i.texture;return n&&n.destroy(),n=e.device.createTexture({label:"colorBuffer",size:{width:s,height:o,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),t.source.width=s,t.source.height=o,t.samples=a,i.texture=n,n}getDepthBuffer(e=!0,t=!1){const s=this.backend,d=s.renderer.getCanvasTarget(),{width:o,height:i}=s.getDrawingBufferSize(),c=s.renderer.currentSamples,n=d.depthTexture;if(n.width===o&&n.height===i&&n.samples===c&&n.depth===e&&n.stencil===t)return s.get(n).texture;const l=s.get(n).texture;let a,r;if(t?(a=DepthStencilFormat,r=UnsignedInt248Type):e&&(a=DepthFormat,r=UnsignedIntType),l!==0[0]){if(n.image.width===o&&n.image.height===i&&n.format===a&&n.type===r&&n.samples===c)return l;this.destroyTexture(n)}return n.name="depthBuffer",n.format=a,n.type=r,n.image.width=o,n.image.height=i,n.samples=c,this.createTexture(n,{width:o,height:i}),s.get(n).texture}updateTexture(e,t){const n=this.backend.get(e),o=e.mipmaps,{textureDescriptorGPU:s}=n;if(e.isRenderTargetTexture||s===0[0])return;if(e.isDataTexture)if(o.length>0)for(let t=0,i=o.length;t<i;t++){const a=o[t];this._copyBufferToTexture(a,n.texture,s,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,n.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let o=0;o<t.image.depth;o++)this._copyBufferToTexture(t.image,n.texture,s,o,e.flipY,o);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,s);else if(o.length>0)for(let t=0,i=o.length;t<i;t++){const a=o[t];this._copyImageToTexture(a,n.texture,s,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,n.texture,s,0,e.flipY,e.premultiplyAlpha);n.version=e.version}async copyTextureToBuffer(e,t,n,s,o,i){const r=this.backend.device,l=this.backend.get(e),m=l.texture,d=l.textureDescriptorGPU.format,u=this._getBytesPerTexel(d);let a=s*u;a=Math.ceil(a/256)*256;const c=r.createBuffer({size:(o-1)*a+s*u,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),h=r.createCommandEncoder();h.copyTextureToBuffer({texture:m,origin:{x:t,y:n,z:i}},{buffer:c,bytesPerRow:a},{width:s,height:o});const f=this._getTypedArrayType(d);r.queue.submit([h.finish()]),await c.mapAsync(GPUMapMode.READ);const p=c.getMappedRange();return new f(p)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===0[0]){const n=new Texture;n.minFilter=NearestFilter,n.magFilter=NearestFilter,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===0[0]){const n=new CubeTexture;n.minFilter=NearestFilter,n.magFilter=NearestFilter,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){const o=e.images,s=e.mipmaps;for(let i=0;i<6;i++){const r=o[i],a=e.flipY===!0?_flipMap[i]:i;r.isDataTexture?this._copyBufferToTexture(r.image,t,n,a,e.flipY):this._copyImageToTexture(r,t,n,a,e.flipY,e.premultiplyAlpha);for(let o=0;o<s.length;o++){const c=s[o],r=c.images[i];r.isDataTexture?this._copyBufferToTexture(r.image,t,n,a,e.flipY,0,o+1):this._copyImageToTexture(r,t,n,a,e.flipY,e.premultiplyAlpha,o+1)}}}_copyImageToTexture(e,t,n,s,o,i,a=0){const r=this.backend.device,c=a>0?e.width:n.size.width,l=a>0?e.height:n.size.height;try{r.queue.copyExternalImageToTexture({source:e,flipY:o},{texture:t,mipLevel:a,origin:{x:0,y:0,z:s},premultipliedAlpha:i},{width:c,height:l,depthOrArrayLayers:1})}catch{}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new WebGPUTexturePassUtils(this.backend.device)),e}_generateMipmaps(e,t,n=0,s=null){this._getPassUtils().generateMipmaps(e,t,n,s)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,s,o,i=0,a=0){const c=this.backend.device,l=e.data,r=this._getBytesPerTexel(n.format),d=e.width*r;c.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:s}},l,{offset:e.width*e.height*r*i,bytesPerRow:d},{width:e.width,height:e.height,depthOrArrayLayers:1}),o===!0&&this._flipY(t,n,s)}_copyCompressedBufferToTexture(e,t,n){const o=this.backend.device,s=this._getBlockData(n.format),i=n.size.depthOrArrayLayers>1;for(let a=0;a<e.length;a++){const r=e[a],l=r.width,c=r.height,u=i?n.size.depthOrArrayLayers:1,d=Math.ceil(l/s.width)*s.byteLength,h=d*Math.ceil(c/s.height);for(let e=0;e<u;e++)o.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:e}},r.data,{offset:e*h,bytesPerRow:d,rowsPerImage:Math.ceil(c/s.height)},{width:Math.ceil(l/s.width)*s.width,height:Math.ceil(c/s.height)*s.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===GPUTextureFormat.BC1RGBAUnorm||e===GPUTextureFormat.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===GPUTextureFormat.BC2RGBAUnorm||e===GPUTextureFormat.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.BC3RGBAUnorm||e===GPUTextureFormat.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.BC4RUnorm||e===GPUTextureFormat.BC4RSnorm)return{byteLength:8,width:4,height:4};
270if(e===GPUTextureFormat.BC5RGUnorm||e===GPUTextureFormat.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.BC6HRGBUFloat||e===GPUTextureFormat.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.BC7RGBAUnorm||e===GPUTextureFormat.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.ETC2RGB8Unorm||e===GPUTextureFormat.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===GPUTextureFormat.ETC2RGB8A1Unorm||e===GPUTextureFormat.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===GPUTextureFormat.ETC2RGBA8Unorm||e===GPUTextureFormat.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===GPUTextureFormat.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===GPUTextureFormat.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.ASTC4x4Unorm||e===GPUTextureFormat.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===GPUTextureFormat.ASTC5x4Unorm||e===GPUTextureFormat.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===GPUTextureFormat.ASTC5x5Unorm||e===GPUTextureFormat.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===GPUTextureFormat.ASTC6x5Unorm||e===GPUTextureFormat.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===GPUTextureFormat.ASTC6x6Unorm||e===GPUTextureFormat.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===GPUTextureFormat.ASTC8x5Unorm||e===GPUTextureFormat.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===GPUTextureFormat.ASTC8x6Unorm||e===GPUTextureFormat.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===GPUTextureFormat.ASTC8x8Unorm||e===GPUTextureFormat.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===GPUTextureFormat.ASTC10x5Unorm||e===GPUTextureFormat.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===GPUTextureFormat.ASTC10x6Unorm||e===GPUTextureFormat.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===GPUTextureFormat.ASTC10x8Unorm||e===GPUTextureFormat.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===GPUTextureFormat.ASTC10x10Unorm||e===GPUTextureFormat.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===GPUTextureFormat.ASTC12x10Unorm||e===GPUTextureFormat.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===GPUTextureFormat.ASTC12x12Unorm||e===GPUTextureFormat.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=GPUAddressMode.ClampToEdge;return e===RepeatWrapping?t=GPUAddressMode.Repeat:e===MirroredRepeatWrapping&&(t=GPUAddressMode.MirrorRepeat),t}_convertFilterMode(e){let t=GPUFilterMode.Linear;return(e===NearestFilter||e===NearestMipmapNearestFilter||e===NearestMipmapLinearFilter)&&(t=GPUFilterMode.Nearest),t}_getBytesPerTexel(e){if(e===GPUTextureFormat.R8Unorm||e===GPUTextureFormat.R8Snorm||e===GPUTextureFormat.R8Uint||e===GPUTextureFormat.R8Sint)return 1;if(e===GPUTextureFormat.R16Uint||e===GPUTextureFormat.R16Sint||e===GPUTextureFormat.R16Float||e===GPUTextureFormat.RG8Unorm||e===GPUTextureFormat.RG8Snorm||e===GPUTextureFormat.RG8Uint||e===GPUTextureFormat.RG8Sint)return 2;if(e===GPUTextureFormat.R32Uint||e===GPUTextureFormat.R32Sint||e===GPUTextureFormat.R32Float||e===GPUTextureFormat.RG16Uint||e===GPUTextureFormat.RG16Sint||e===GPUTextureFormat.RG16Float||e===GPUTextureFormat.RGBA8Unorm||e===GPUTextureFormat.RGBA8UnormSRGB||e===GPUTextureFormat.RGBA8Snorm||e===GPUTextureFormat.RGBA8Uint||e===GPUTextureFormat.RGBA8Sint||e===GPUTextureFormat.BGRA8Unorm||e===GPUTextureFormat.BGRA8UnormSRGB||e===GPUTextureFormat.RGB9E5UFloat||e===GPUTextureFormat.RGB10A2Unorm||e===GPUTextureFormat.RG11B10UFloat||e===GPUTextureFormat.Depth32Float||e===GPUTextureFormat.Depth24Plus||e===GPUTextureFormat.Depth24PlusStencil8||e===GPUTextureFormat.Depth32FloatStencil8)return 4;if(e===GPUTextureFormat.RG32Uint||e===GPUTextureFormat.RG32Sint||e===GPUTextureFormat.RG32Float||e===GPUTextureFormat.RGBA16Uint||e===GPUTextureFormat.RGBA16Sint||e===GPUTextureFormat.RGBA16Float)return 8;if(e===GPUTextureFormat.RGBA32Uint||e===GPUTextureFormat.RGBA32Sint||e===GPUTextureFormat.RGBA32Float)return 16}_getTypedArrayType(e){if(e===GPUTextureFormat.R8Uint)return Uint8Array;
270if(e===GPUTextureFormat.R8Sint)return Int8Array;if(e===GPUTextureFormat.R8Unorm)return Uint8Array;if(e===GPUTextureFormat.R8Snorm)return Int8Array;if(e===GPUTextureFormat.RG8Uint)return Uint8Array;if(e===GPUTextureFormat.RG8Sint)return Int8Array;if(e===GPUTextureFormat.RG8Unorm)return Uint8Array;if(e===GPUTextureFormat.RG8Snorm)return Int8Array;if(e===GPUTextureFormat.RGBA8Uint)return Uint8Array;if(e===GPUTextureFormat.RGBA8Sint)return Int8Array;if(e===GPUTextureFormat.RGBA8Unorm||e===GPUTextureFormat.RGBA8UnormSRGB)return Uint8Array;if(e===GPUTextureFormat.RGBA8Snorm)return Int8Array;if(e===GPUTextureFormat.R16Uint)return Uint16Array;if(e===GPUTextureFormat.R16Sint)return Int16Array;if(e===GPUTextureFormat.RG16Uint)return Uint16Array;if(e===GPUTextureFormat.RG16Sint)return Int16Array;if(e===GPUTextureFormat.RGBA16Uint)return Uint16Array;if(e===GPUTextureFormat.RGBA16Sint)return Int16Array;if(e===GPUTextureFormat.R16Float)return Uint16Array;if(e===GPUTextureFormat.RG16Float)return Uint16Array;if(e===GPUTextureFormat.RGBA16Float)return Uint16Array;if(e===GPUTextureFormat.R32Uint)return Uint32Array;if(e===GPUTextureFormat.R32Sint)return Int32Array;if(e===GPUTextureFormat.R32Float)return Float32Array;if(e===GPUTextureFormat.RG32Uint)return Uint32Array;if(e===GPUTextureFormat.RG32Sint)return Int32Array;if(e===GPUTextureFormat.RG32Float)return Float32Array;if(e===GPUTextureFormat.RGBA32Uint)return Uint32Array;if(e===GPUTextureFormat.RGBA32Sint)return Int32Array;if(e===GPUTextureFormat.RGBA32Float)return Float32Array;if(e===GPUTextureFormat.BGRA8Unorm||e===GPUTextureFormat.BGRA8UnormSRGB)return Uint8Array;
270if(e===GPUTextureFormat.RGB10A2Unorm)return Uint32Array;if(e===GPUTextureFormat.RGB9E5UFloat)return Uint32Array;if(e===GPUTextureFormat.RG11B10UFloat)return Uint32Array;if(e===GPUTextureFormat.Depth32Float)return Float32Array;if(e===GPUTextureFormat.Depth24Plus)return Uint32Array;if(e===GPUTextureFormat.Depth24PlusStencil8)return Uint32Array;if(e===GPUTextureFormat.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=GPUTextureDimension.ThreeD:t=GPUTextureDimension.TwoD,t}}function getFormat(e,t=null){const i=e.format,o=e.type,a=e.colorSpace,s=ColorManagement.getTransfer(a);let n;if(e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(i){case RGB_S3TC_DXT1_Format:case RGBA_S3TC_DXT1_Format:n=s===SRGBTransfer?GPUTextureFormat.BC1RGBAUnormSRGB:GPUTextureFormat.BC1RGBAUnorm;break;case RGBA_S3TC_DXT3_Format:n=s===SRGBTransfer?GPUTextureFormat.BC2RGBAUnormSRGB:GPUTextureFormat.BC2RGBAUnorm;break;case RGBA_S3TC_DXT5_Format:n=s===SRGBTransfer?GPUTextureFormat.BC3RGBAUnormSRGB:GPUTextureFormat.BC3RGBAUnorm;break;case RED_RGTC1_Format:n=GPUTextureFormat.BC4RUnorm;break;case SIGNED_RED_RGTC1_Format:n=GPUTextureFormat.BC4RSnorm;break;case RED_GREEN_RGTC2_Format:n=GPUTextureFormat.BC5RGUnorm;break;case SIGNED_RED_GREEN_RGTC2_Format:n=GPUTextureFormat.BC5RGSnorm;break;case RGBA_BPTC_Format:n=s===SRGBTransfer?GPUTextureFormat.BC7RGBAUnormSRGB:GPUTextureFormat.BC7RGBAUnorm;break;case RGB_ETC2_Format:case RGB_ETC1_Format:n=s===SRGBTransfer?GPUTextureFormat.ETC2RGB8UnormSRGB:GPUTextureFormat.ETC2RGB8Unorm;break;case RGBA_ETC2_EAC_Format:n=s===SRGBTransfer?GPUTextureFormat.ETC2RGBA8UnormSRGB:GPUTextureFormat.ETC2RGBA8Unorm;break;case R11_EAC_Format:n=GPUTextureFormat.EACR11Unorm;break;case SIGNED_R11_EAC_Format:n=GPUTextureFormat.EACR11Snorm;break;case RG11_EAC_Format:n=GPUTextureFormat.EACRG11Unorm;break;case SIGNED_RG11_EAC_Format:n=GPUTextureFormat.EACRG11Snorm;break;case RGBA_ASTC_4x4_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC4x4UnormSRGB:GPUTextureFormat.ASTC4x4Unorm;break;case RGBA_ASTC_5x4_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC5x4UnormSRGB:GPUTextureFormat.ASTC5x4Unorm;break;case RGBA_ASTC_5x5_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC5x5UnormSRGB:GPUTextureFormat.ASTC5x5Unorm;break;case RGBA_ASTC_6x5_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC6x5UnormSRGB:GPUTextureFormat.ASTC6x5Unorm;break;case RGBA_ASTC_6x6_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC6x6UnormSRGB:GPUTextureFormat.ASTC6x6Unorm;break;case RGBA_ASTC_8x5_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC8x5UnormSRGB:GPUTextureFormat.ASTC8x5Unorm;break;case RGBA_ASTC_8x6_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC8x6UnormSRGB:GPUTextureFormat.ASTC8x6Unorm;break;case RGBA_ASTC_8x8_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC8x8UnormSRGB:GPUTextureFormat.ASTC8x8Unorm;break;case RGBA_ASTC_10x5_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC10x5UnormSRGB:GPUTextureFormat.ASTC10x5Unorm;break;case RGBA_ASTC_10x6_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC10x6UnormSRGB:GPUTextureFormat.ASTC10x6Unorm;break;case RGBA_ASTC_10x8_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC10x8UnormSRGB:GPUTextureFormat.ASTC10x8Unorm;break;case RGBA_ASTC_10x10_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC10x10UnormSRGB:GPUTextureFormat.ASTC10x10Unorm;break;case RGBA_ASTC_12x10_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC12x10UnormSRGB:GPUTextureFormat.ASTC12x10Unorm;break;case RGBA_ASTC_12x12_Format:n=s===SRGBTransfer?GPUTextureFormat.ASTC12x12UnormSRGB:GPUTextureFormat.ASTC12x12Unorm;break;case RGBAFormat:n=s===SRGBTransfer?GPUTextureFormat.RGBA8UnormSRGB:GPUTextureFormat.RGBA8Unorm;break;default:error("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case RGBAFormat:switch(o){case ByteType:n=GPUTextureFormat.RGBA8Snorm;break;case ShortType:n=GPUTextureFormat.RGBA16Sint;break;case UnsignedShortType:n=GPUTextureFormat.RGBA16Uint;break;case UnsignedIntType:n=GPUTextureFormat.RGBA32Uint;break;case IntType:n=GPUTextureFormat.RGBA32Sint;break;case UnsignedByteType:n=s===SRGBTransfer?GPUTextureFormat.RGBA8UnormSRGB:GPUTextureFormat.RGBA8Unorm;break;case HalfFloatType:n=GPUTextureFormat.RGBA16Float;break;case FloatType:n=GPUTextureFormat.RGBA32Float;break;default:error("WebGPURenderer: Unsupported texture type with RGBAFormat.",o)}break;case RGBFormat:switch(o){case UnsignedInt5999Type:n=GPUTextureFormat.RGB9E5UFloat;break;case UnsignedInt101111Type:n=GPUTextureFormat.RG11B10UFloat;break;default:error("WebGPURenderer: Unsupported texture type with RGBFormat.",o)}break;case RedFormat:switch(o){case ByteType:n=GPUTextureFormat.R8Snorm;break;case ShortType:n=GPUTextureFormat.R16Sint;break;case UnsignedShortType:n=GPUTextureFormat.R16Uint;break;case UnsignedIntType:n=GPUTextureFormat.R32Uint;break;case IntType:n=GPUTextureFormat.R32Sint;break;case UnsignedByteType:n=GPUTextureFormat.R8Unorm;break;case HalfFloatType:n=GPUTextureFormat.R16Float;break;case FloatType:n=GPUTextureFormat.R32Float;break;default:error("WebGPURenderer: Unsupported texture type with RedFormat.",o)}break;case RGFormat:switch(o){case ByteType:n=GPUTextureFormat.RG8Snorm;break;case ShortType:n=GPUTextureFormat.RG16Sint;break;case UnsignedShortType:n=GPUTextureFormat.RG16Uint;break;case UnsignedIntType:n=GPUTextureFormat.RG32Uint;break;case IntType:n=GPUTextureFormat.RG32Sint;break;case UnsignedByteType:n=GPUTextureFormat.RG8Unorm;break;case HalfFloatType:n=GPUTextureFormat.RG16Float;break;case FloatType:n=GPUTextureFormat.RG32Float;break;default:error("WebGPURenderer: Unsupported texture type with RGFormat.",o)}break;case DepthFormat:switch(o){case UnsignedShortType:n=GPUTextureFormat.Depth16Unorm;break;case UnsignedIntType:n=GPUTextureFormat.Depth24Plus;break;case FloatType:n=GPUTextureFormat.Depth32Float;break;default:error("WebGPURenderer: Unsupported texture type with DepthFormat.",o)}break;case DepthStencilFormat:switch(o){case UnsignedInt248Type:n=GPUTextureFormat.Depth24PlusStencil8;break;case FloatType:t&&t.features.has(GPUFeatureName.Depth32FloatStencil8)===!1&&error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),n=GPUTextureFormat.Depth32FloatStencil8;break;default:error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",o)}break;case RedIntegerFormat:switch(o){case IntType:n=GPUTextureFormat.R32Sint;break;case UnsignedIntType:n=GPUTextureFormat.R32Uint;break;default:error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",o)}break;case RGIntegerFormat:switch(o){case IntType:n=GPUTextureFormat.RG32Sint;break;case UnsignedIntType:n=GPUTextureFormat.RG32Uint;break;default:error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",o)}break;case RGBAIntegerFormat:switch(o){case IntType:n=GPUTextureFormat.RGBA32Sint;break;case UnsignedIntType:n=GPUTextureFormat.RGBA32Uint;break;default:error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",o)}break;default:error("WebGPURenderer: Unsupported texture format.",i)}return n}declarationRegexp=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[->]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,propertiesRegexp=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,wgslTypeLib$1={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>
270":"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"},parse=e=>{e=e.trim();const t=e.match(declarationRegexp);if(t!==null&&t.length===4){const i=t[2],n=[];let s=null;for(;(s=propertiesRegexp.exec(i))!==null;)n.push({name:s[1],type:s[2]});const a=[];for(let t=0;t<n.length;t++){const{name:o,type:s}=n[t];let e=s;e.startsWith("ptr")?e="pointer":(e.startsWith("texture")&&(e=s.split("<")[0]),e=wgslTypeLib$1[e]),a.push(new NodeFunctionInput(e,o))}const r=e.substring(t[0].length),o=t[3]||"void",c=t[1]!==0[0]?t[1]:"",l=wgslTypeLib$1[o]||o;return{type:l,inputs:a,name:c,inputsCode:i,blockCode:r,outputType:o}}throw new Error("FunctionNode: Function is not a WGSL code.")};class WGSLNodeFunction extends NodeFunction{constructor(e){const{type:t,inputs:n,name:s,inputsCode:o,blockCode:i,outputType:a}=parse(e);super(t,n,s),this.inputsCode=o,this.blockCode=i,this.outputType=a}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class WGSLNodeParser extends NodeParser{parseFunction(e){return new WGSLNodeFunction(e)}}accessNames={[NodeAccess.READ_ONLY]:"read",[NodeAccess.WRITE_ONLY]:"write",[NodeAccess.READ_WRITE]:"read_write"},wrapNames={[RepeatWrapping]:"repeat",[ClampToEdgeWrapping]:"clamp",[MirroredRepeatWrapping]:"mirror"},gpuShaderStageLib={vertex:GPUShaderStage.VERTEX,fragment:GPUShaderStage.FRAGMENT,compute:GPUShaderStage.COMPUTE},supports={instance:!0,swizzleAssign:!1,storageBuffer:!0},wgslFnOpLib={"^^":"tsl_xor"},wgslTypeLib={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},wgslCodeCache={},wgslPolyfill={tsl_xor:new CodeNode("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new CodeNode("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new CodeNode("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new CodeNode("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new CodeNode("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new CodeNode("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new CodeNode("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new CodeNode("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new CodeNode("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new CodeNode("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new CodeNode("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 CodeNode("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new CodeNode(` 271fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { 272 273 let res = vec2f( iRes ); 274 275 let uvScaled = coord * res; 276 let uvWrapping = ( ( uvScaled % res ) + res ) % res; 277 278 // https://www.shadertoy.com/view/WtyXRy 279 280 let uv = uvWrapping - 0.5; 281 let iuv = floor( uv ); 282 let f = fract( uv ); 283 284 let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); 285 let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); 286 let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); 287 let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); 288 289 return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); 290 291} 292`)},wgslMethods={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<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},diagnostics="",(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(diagnostics+=`diagnostic( off, derivative_uniformity ); 293`);class WGSLNodeBuilder extends NodeBuilder{constructor(e,t){super(e,t,new WGSLNodeParser),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,s,o,i=this.shaderStage){return i==="fragment"?s?o?`textureSample( ${t}, ${t}_sampler, ${n}, ${s}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:o?`textureSample( ${t}, ${t}_sampler, ${n}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",s)}generateTextureSampleLevel(e,t,n,s,o,i){return this.isUnfilterable(e)===!1?i?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,i,s):this.generateTextureLod(e,t,n,o,i,s)}generateWrapFunction(e){const t=`tsl_coord_${wrapNames[e.wrapS]}S_${wrapNames[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`;let n=wgslCodeCache[t];if(n===0[0]){const o=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let s=`fn ${t}( coord : ${i} ) -> ${i} { 294 295 return ${i}( 296`;const a=(e,t)=>{e===RepeatWrapping?(o.push(wgslPolyfill.repeatWrapping_float),s+=` tsl_repeatWrapping_float( coord.${t} )`):e===ClampToEdgeWrapping?(o.push(wgslPolyfill.clampWrapping_float),s+=` tsl_
296clampWrapping_float( coord.${t} )`):e===MirroredRepeatWrapping?(o.push(wgslPolyfill.mirrorWrapping_float),s+=` tsl_mirrorWrapping_float( coord.${t} )`):(s+=` coord.${t}`,warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),s+=`, 297`,a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(s+=`, 298`,a(e.wrapR,"z")),s+=` 299 ); 300 301} 302`,wgslCodeCache[t]=n=new CodeNode(s,o)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);s.dimensionsSnippet===0[0]&&(s.dimensionsSnippet={});let o=s.dimensionsSnippet[n];if(s.dimensionsSnippet[n]===0[0]){let i,a;const{primarySamples:r}=this.renderer.backend.utils.getTextureSampleData(e),c=r>1;e.is3DTexture||e.isData3DTexture?a="vec3<u32>":a="vec2<u32>",c||e.isStorageTexture?i=t:i=`${t}${n?`, u32( ${n} )`:""}`,o=new VarNode(new ExpressionNode(`textureDimensions( ${i} )`,a)),s.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new VarNode(new ExpressionNode(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new VarNode(new ExpressionNode("6u","u32")))}return o.build(this)}generateFilteredTexture(e,t,n,s,o="0u"){this._include("biquadraticTexture");const a=this.generateWrapFunction(e),i=this.generateTextureDimension(e,t,o);return s&&(n=`${n} + vec2<f32>(${s}) / ${i}`),`tsl_biquadraticTexture( ${t}, ${a}( ${n} ), ${i}, u32( ${o} ) )`}generateTextureLod(e,t,n,s,o,i="0u"){const c=this.generateWrapFunction(e),r=this.generateTextureDimension(e,t,i),a=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";o&&(n=`${n} + ${a}<f32>(${o}) / ${a}<f32>( ${r} )`);const l=`${a}<u32>( ${c}( ${n} ) * ${a}<f32>( ${r} ) )`;return this.generateTextureLoad(e,t,l,i,s,null)}generateTextureLoad(e,t,n,s,o,i){s===null&&(s="0u"),i&&(n=`${n} + ${i}`);let a;return o?a=`textureLoad( ${t}, ${n}, ${o}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${n}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,n,s,o){let i;return s?i=`textureStore( ${t}, ${n}, ${s}, ${o} )`:i=`textureStore( ${t}, ${n}, ${o} )`,i}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===FloatType||this.isSampleCompare(e)===!1&&e.minFilter===NearestFilter&&e.magFilter===NearestFilter||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,s,o,i=this.shaderStage){let a=null;return this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,s,o,"0",i):a=this._generateTextureSample(e,t,n,s,o,i),a}generateTextureGrad(e,t,n,s,o,i,a=this.shaderStage){if(a==="fragment")return i?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]}, ${i} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]} )`;error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,s,o,i,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?i?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s} )`:i?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s} )`;error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,s,o,i){return this.isUnfilterable(e)===!1?i?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,i,s):this.generateTextureLod(e,t,n,o,i,s)}generateTextureBias(e,t,n,s,o,i,a=this.shaderStage){if(a==="fragment")return i?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s}, ${i} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s} )`;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){const n=e.name,t=e.type;return t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"?n:t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"?this.isCu
302stomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=wgslFnOpLib[e];return t!==0[0]?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),NodeAccess.READ_WRITE):NodeAccess.READ_ONLY:e.access}getStorageAccess(e,t){return accessNames[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,s=null){const o=super.getUniformFromNode(e,t,n,s),i=this.getDataFromNode(e,n,this.globalCache);if(i.uniformGPU===0[0]){let r;const a=e.groupNode,c=a.name,l=this.getBindGroupArray(c,n);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let s=null;const i=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?s=new NodeSampledTexture3D(o.name,o.node,a,i):s=new NodeSampledTexture(o.name,o.node,a,i):t==="cubeTexture"||t==="cubeDepthTexture"?s=new NodeSampledCubeTexture(o.name,o.node,a,i):t==="texture3D"&&(s=new NodeSampledTexture3D(o.name,o.node,a,i)),s.store=e.isStorageTextureNode===!0,s.mipLevel=s.store?e.mipLevel:0,s.setVisibility(gpuShaderStageLib[n]),this.isUnfilterable(e.value)===!1&&s.store===!1){const e=new NodeSampler(`${o.name}_sampler`,o.node,a);e.setVisibility(gpuShaderStageLib[n]),l.push(e,s),r=[e,s]}else l.push(s),r=[s]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const c=this.getSharedDataFromNode(e);let i=c.buffer;if(i===0[0]){const n=t==="buffer"?NodeUniformBuffer:NodeStorageBuffer;i=new n(e,a),c.buffer=i}i.setVisibility(i.getVisibility()|gpuShaderStageLib[n]),l.push(i),r=i,o.name=s||"NodeBuffer_"+o.id}else{const s=this.uniformGroups[n]||(this.uniformGroups[n]={});let e=s[c];e===0[0]&&(e=new NodeUniformsGroup(c,a),e.setVisibility(gpuShaderStageLib[n]),s[c]=e,l.push(e)),r=this.getNodeUniform(o,t),e.addUniform(r)}i.uniformGPU=r}return o}getBuiltin(e,t,n,s=this.shaderStage){const o=this.builtins[s]||(this.builtins[s]=new Map);return o.has(e)===!1&&o.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==0[0]&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const n=e.layout,t=this.flowShaderNode(e),o=[];for(const e of n.inputs)o.push(e.name+" : "+this.getType(e.type));let s=`fn ${n.name}( ${o.join(", ")} ) -> ${this.getType(n.type)} { 303${t.vars} 304${t.code} 305`;return t.result&&(s+=` return ${t.result}; 306`),s+=` 307} 308`,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<f32>")+".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){const n=this.directives[t]||(this.directives[t]=new Set);n.add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==0[0])for(const e of n)t.push(`enable ${e};`);return t.join(` 309`)}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<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==0[0])for(const{name:e,property:s,type:o}of n.values())t.push(`@builtin( ${e} ) ${s} : ${o}`);return t.join(`, 310 `)}getScopedArray(e,t,n,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:e,scope:n,bufferType:s,bufferCount:o}of this.scopedArrays.values()){const i=this.getType(s);t.push(`var<${n}> ${e}: array< ${i}, ${o} >;`)}return t.join(` 311`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const e=this.getBuiltins("attribute");e&&t.push(e);const n=this.getAttributesArray();for(let e=0,o=n.length;e<o;e++){const s=n[e],i=s.name,a=this.getType(s.type);t.push(`@location( ${e} ) ${i} : ${a}`)}}return t.join(`, 312 `)}getStructMembers(e){const t=[];for(const n of e.members){const o=e.output?"@location( "+n.index+" ) ":"";let s=this.getType(n.type);n.atomic&&(s="atomic< "+s+" >"),t.push(` ${o+n.name} : ${s}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, 313`)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const e=[];for(const s of n){let t=`struct ${s.name} { 314`;t+=this.getStructMembers(s),t+=` 315};`,e.push(t)}t=` 316`+e.join(` 317 318`)+` 319`}return t}getVar(e,t,n=null){let s=`var ${t} : `;return n!==null?s+=this.generateArrayDeclaration(e,n):s+=this.getType(e),s}getVars(e){const t=[],n=this.vars[e];if(n!==0[0])for(const e of n)t.push(` ${this.getVar(e.type,e.name,e.count)};`);return` 320${t.join(` 321`)} 322`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const n=this.varyings,s=this.vars[e];for(let i=0;i<n.length;i++){const o=n[i];if(o.needsInterpolation){let e=`@location( ${i} )`;if(o.interpolationType){const t=o.interpolationSampling!==null?`, ${o.interpolationSampling} )`:" )";e+=` @interpolate( ${o.interpolationType}${t}`}
322else/^(int|uint|ivec|uvec)/.test(o.type)&&(e+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${e} ${o.name} : ${this.getType(o.type)}`)}else e==="vertex"&&s.includes(o)===!1&&s.push(o)}}const n=this.getBuiltins(e);n&&t.push(n);const s=t.join(`, 323 `);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+s):s}isCustomStruct(e){const n=e.value,t=e.node,s=(n.isBufferAttribute||n.isInstancedBufferAttribute)&&t.structTypeNode!==null,o=t.value&&t.value.array&&typeof t.value.itemSize=="number"&&t.value.array.length>t.value.itemSize;return s&&!o}getUniforms(e){const i=this.uniforms[e],t=[],s=[],o=[],n={};for(const o of i){const r=o.groupNode.name,a=this.bindingsIndexes[r];if(o.type==="texture"||o.type==="cubeTexture"||o.type==="cubeDepthTexture"||o.type==="storageTexture"||o.type==="texture3D"){const n=o.node.value;this.isUnfilterable(n)===!1&&o.node.isStorageTextureNode!==!0&&(this.isSampleCompare(n)?t.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${o.name}_sampler : sampler_comparison;`):t.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${o.name}_sampler : sampler;`));let s,i="";const{primarySamples:r}=this.renderer.backend.utils.getTextureSampleData(n);if(r>1&&(i="_multisampled"),n.isCubeTexture===!0&&n.isDepthTexture===!0)s="texture_depth_cube";else if(n.isCubeTexture===!0)s="texture_cube<f32>";else if(n.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&n.compareFunction===null?s=`texture${i}_2d<f32>`:s=`texture_depth${i}_2d${n.isArrayTexture===!0?"_array":""}`;else if(o.node.isStorageTextureNode===!0){const t=getFormat(n),i=this.getStorageAccess(o.node,e),a=o.node.value.is3DTexture,r=o.node.value.isArrayTexture,c=a?"3d":`2d${r?"_array":""}`;s=`texture_storage_${c}<${t}, ${i}>`}else if(n.isArrayTexture===!0||n.isDataArrayTexture===!0||n.isCompressedArrayTexture===!0)s="texture_2d_array<f32>";else if(n.is3DTexture===!0||n.isData3DTexture===!0)s="texture_3d<f32>";else{const e=this.getComponentTypeFromTexture(n).charAt(0);s=`texture${i}_2d<${e}32>`}t.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${o.name} : ${s};`)}else if(o.type==="buffer"||o.type==="storageBuffer"||o.type==="indirectStorageBuffer"){const t=o.node,n=this.getType(t.getNodeType(this)),i=t.bufferCount,c=i>0&&o.type==="buffer"?", "+i:"",r=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(o))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${r}> ${o.name} : ${n};`);else{const e=t.isAtomic?`atomic<${n}>`:`${n}`,i=` value : array< ${e}${c} >`;s.push(this._getWGSLStructBinding(o.name,i,r,a.binding++,a.group))}}else{const t=this.getType(this.getVectorType(o.type)),e=o.groupNode.name,s=n[e]||(n[e]={index:a.binding++,id:a.group,snippets:[]});s.snippets.push(` ${o.name} : ${t}`)}}for(const t in n){const e=n[t];o.push(this._getWGSLStructBinding(t,e.snippets.join(`, 324`),"uniform",e.index,e.id))}const a=[...t,...s,...o].join(` 325`);return a}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const 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 s=`// code 326 327`;s+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],i=a.outputNode,r=i!==0[0]&&i.isOutputStructNode===!0;for(const c of o){const e=this.getFlowData(c),l=c.name;if(l&&(s.length>0&&(s+=` 328`),s+=` // flow -> ${l} 329`),s+=`${e.code} 330 `,c===a&&t!=="compute")if(s+=`// result 331 332 `,t==="vertex")s+=`varyings.Vertex = ${e.result};`;else if(t==="fragment")if(r)n.returnType=i.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",s+=`return ${e.result};`;else{let t=" @location(0) color: vec4<f32>";const o=this.getBuiltins("output");o&&(t+=`, 333 `+o),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",t),n.structs+=` 334var<private> output : OutputStruct;`,s+=`output.color = ${e.result}; 335 336 return output;`}}n.flow=s}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const 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===0[0]&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){const t=this.getType(e);return`bitcast<${t}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}
336getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return wgslTypeLib[e]||e}isAvailable(e){let t=supports[e];return t===0[0]&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),supports[e]=t),t}_getWGSLMethod(e){return wgslPolyfill[e]!==0[0]&&this._include(e),wgslMethods[e]}_include(e){const t=wgslPolyfill[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} 337// directives 338${e.directives} 339 340// structs 341${e.structs} 342 343// uniforms 344${e.uniforms} 345 346// varyings 347${e.varyings} 348var<private> varyings : VaryingsStruct; 349 350// codes 351${e.codes} 352 353@vertex 354fn main( ${e.attributes} ) -> VaryingsStruct { 355 356 // vars 357 ${e.vars} 358 359 // flow 360 ${e.flow} 361 362 return varyings; 363 364} 365`}_getWGSLFragmentCode(e){return`${this.getSignature()} 366// global 367${diagnostics} 368 369// structs 370${e.structs} 371 372// uniforms 373${e.uniforms} 374 375// codes 376${e.codes} 377 378@fragment 379fn main( ${e.varyings} ) -> ${e.returnType} { 380 381 // vars 382 ${e.vars} 383 384 // flow 385 ${e.flow} 386 387} 388`}_getWGSLComputeCode(e,t){const[n,s,o]=t;
388return`${this.getSignature()} 389// directives 390${e.directives} 391 392// system 393var<private> instanceIndex : u32; 394 395// locals 396${e.scopedArrays} 397 398// structs 399${e.structs} 400 401// uniforms 402${e.uniforms} 403 404// codes 405${e.codes} 406 407@compute @workgroup_size( ${n}, ${s}, ${o} ) 408fn main( ${e.attributes} ) { 409 410 // system 411 instanceIndex = globalId.x 412 + globalId.y * ( ${n} * numWorkgroups.x ) 413 + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y ); 414 415 // vars 416 ${e.vars} 417 418 // flow 419 ${e.flow} 420 421} 422`}_getWGSLStruct(e,t){return` 423struct ${e} { 424${t} 425};`}_getWGSLStructBinding(e,t,n,s=0,o=0){const i=e+"Struct",a=this._getWGSLStruct(i,t);return`${a} 426@binding( ${s} ) @group( ${o} ) 427var<${n}> ${e} : ${i};`}}class WebGPUUtils{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=GPUTextureFormat.Depth24PlusStencil8:e.depth&&(t=GPUTextureFormat.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){const e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,s=n?1:t;return{samples:t,primarySamples:s,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return GPUPrimitiveTopology.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return GPUPrimitiveTopology.LineList;if(e.isLine)return GPUPrimitiveTopology.LineStrip;if(e.isMesh)return GPUPrimitiveTopology.TriangleList}getSampleCount(e){return e>=4?4:1}
427getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const t=this.backend.parameters,e=t.outputType;if(e===0[0])return navigator.gpu.getPreferredCanvasFormat();if(e===UnsignedByteType)return GPUTextureFormat.BGRA8Unorm;if(e===HalfFloatType)return GPUTextureFormat.RGBA16Float;throw new Error("Unsupported output buffer type.")}}typedArraysToVertexFormatPrefix=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"&&typedArraysToVertexFormatPrefix.set(Float16Array,["float16"]),typedAttributeToVertexFormatPrefix=new Map([[Float16BufferAttribute,["float16"]]]),typeArraysToVertexFormatPrefixForItemSize1=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class WebGPUAttributeUtils{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),i=this.backend,o=i.get(n);let s=o.buffer;if(s===0[0]){const c=i.device;let a=n.array;if(e.normalized===!1)if(a.constructor===Int16Array||a.constructor===Int8Array)a=new Int32Array(a);else if((a.constructor===Uint16Array||a.constructor===Uint8Array)&&(a=new Uint32Array(a),t&GPUBufferUsage.INDEX))for(let e=0;e<a.length;e++)a[e]===65535&&(a[e]=4294967295);if(n.array=a,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){a=new a.constructor(n.count*4);for(let e=0;e<n.count;e++)a.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=a,o._force3to4BytesAlignment=!0}const r=a.byteLength,l=r+(4-r%4)%4;s=c.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new a.constructor(s.getMappedRange()).set(a),s.unmap(),o.buffer=s}}updateAttribute(e){const t=this._getBufferAttribute(e),s=this.backend,i=s.device,a=s.get(t),r=s.get(t).buffer;let n=t.array;if(a._force3to4BytesAlignment===!0){n=new n.constructor(t.count*4);for(let e=0;e<t.count;e++)n.set(t.array.subarray(e*3,e*3+3),e*4);t.array=n}const o=t.updateRanges;if(o.length===0)i.queue.writeBuffer(r,0,n,0);else{const s=isTypedArray(n),e=s?1:n.BYTES_PER_ELEMENT;for(let l=0,u=o.length;l<u;l++){const t=o[l];let c,d;if(a._force3to4BytesAlignment===!0){const n=Math.floor(t.start/3),s=Math.ceil(t.count/3);c=n*4*e,d=s*4*e}else c=t.start*e,d=t.count*e;const h=c*(s?n.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(r,h,n,c,d)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const n=e.getAttributes(),t=new Map;for(let s=0;s<n.length;s++){const e=n[s],i=e.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(e);let o=t.get(a);if(o===0[0]){let n,s;e.isInterleavedBufferAttribute===!0?(n=e.data.stride*i,s=e.data.isInstancedInterleavedBuffer?GPUInputStepMode.Instance:GPUInputStepMode.Vertex):(n=e.itemSize*i,s=e.isInstancedBufferAttribute?GPUInputStepMode.Instance:GPUInputStepMode.Vertex),e.normalized===!1&&(e.array.constructor===Int16Array||e.array.constructor===Uint16Array)&&(n=4),o={arrayStride:n,attributes:[],stepMode:s},t.set(a,o)}const r=this._getVertexFormat(e),c=e.isInterleavedBufferAttribute===!0?e.offset*i:0;o.attributes.push({shaderLocation:s,offset:c,format:r})}return Array.from(t.values())}destroyAttribute(e){const t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){const s=this.backend,n=s.device,r=s.get(this._getBufferAttribute(e)),o=r.buffer,i=o.size,t=n.createBuffer({label:`${e.name}_readback`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=n.createCommandEncoder({label:`readback_encoder_${e.name}`});a.copyBufferToBuffer(o,0,t,0,i);const c=a.finish();n.queue.submit([c]),await t.mapAsync(GPUMapMode.READ);const l=t.getMappedRange(),d=new e.array.constructor(l.slice(0));return t.unmap(),d.buffer}_getVertexFormat(e){const{itemSize:s,normalized:o}=e,t=e.array.constructor,i=e.constructor;let n;if(s===1)n=typeArraysToVertexFormatPrefixForItemSize1.get(t);else{const a=typedAttributeToVertexFormatPrefix.get(i)||typedArraysToVertexFormatPrefix.get(t),e=a[o?1:0];if(e){const i=t.BYTES_PER_ELEMENT*s,a=Math.floor((i+3)/4)*4,o=a/t.BYTES_PER_ELEMENT;if(o%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${e}x${o}`}}return n||error("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class BindGroupLayout{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class WebGPUBindingUtils{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const o=this.backend,a=o.device,n=o.get(e);if(n.layout)return n.layout.layoutGPU;const i=this._createLayoutEntries(e),s=JSON.stringify(i);let t=this._bindGroupLayoutCache.get(s);return t===0[0]&&(t=new BindGroupLayout(a.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(s,t)),t.usedTimes++,n.layout=t,n.layoutKey=s,t.layoutGPU}createBindings(e,t,n,s=0){const{backend:a}=this,o=a.get(e),r=this.createBindingsLayout(e);let i;n>0&&(o.groups===0[0]&&(o.groups=[],o.versions=[]),o.versions[n]===s&&(i=o.groups[n])),i===0[0]&&(i=this.createBindGroup(e,r),n>0&&(o.groups[n]=i,o.versions[n]=s)),o.group=i}updateBinding(e){const s=this.backend,o=s.device,t=e.buffer,i=s.get(e).buffer,n=e.updateRanges;if(n.length===0)o.queue.writeBuffer(i,0,t,0);else{const s=isTypedArray(t),a=s?1:t.BYTES_PER_ELEMENT;for(let e=0,l=n.length;e<l;e++){const r=n[e],c=r.start*a,d=r.count*a,u=c*(s?t.BYTES_PER_ELEMENT:1);o.queue.writeBuffer(i,u,t,c,d)}e.clearUpdateRanges()}}createBindGroupIndex(e,t){const i=this.backend,n=i.device,a=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0],o=n.createBuffer({label:"bindingCameraIndex_"+s,size:16,usage:a});n.queue.writeBuffer(o,0,e,0);const r=[{binding:0,resource:{buffer:o}}];return n.createBindGroup({label:"bindGroupCameraIndex_"+s,layout:t,entries:r})}createBindGroup(e,t){const n=this.backend,i=n.device;let s=0;const o=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=n.get(t);if(e.buffer===0[0]){const s=t.byteLength,o=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=[];t.visibility&GPUShaderStage.VERTEX&&n.push("vertex"),t.visibility&GPUShaderStage.FRAGMENT&&n.push("fragment"),t.visibility&GPUShaderStage.COMPUTE&&n.push("compute");const a=`(${n.join(",")})`,r=i.createBuffer({label:`bindingBuffer${t.id}_${t.name}_${a}`,size:s,usage:o});e.buffer=r}o.push({binding:s,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=n.get(t);if(e.buffer===0[0]){const s=t.attribute;e.buffer=n.get(s).buffer}o.push({binding:s,resource:{buffer:e.buffer}})}else if(t.isSampledTexture){const e=n.get(t.texture);let a;if(e.externalTexture!==0[0])a=i.importExternalTexture({source:e.externalTexture});else{const s=t.store?1:e.texture.mipLevelCount,o=t.store?t.mipLevel:0;let n=`view-${e.texture.width}-${e.texture.height}`;if(e.texture.depthOrArrayLayers>1&&(n+=`-${e.texture.depthOrArrayLayers}`),n+=`-${s}-${o}`,a=e[n],a===0[0]){const r=GPUTextureAspect.All;let i;t.isSampledCubeTexture?i=GPUTextureViewDimension.Cube:t.isSampledTexture3D?i=GPUTextureViewDimension.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?i=GPUTextureViewDimension.TwoDArray:i=GPUTextureViewDimension.TwoD,a=e[n]=e.texture.createView({aspect:r,dimension:i,mipLevelCount:s,baseMipLevel:o})}}o.push({binding:s,resource:a})}else if(t.isSampler){const e=n.get(t.texture);o.push({binding:s,resource:e.sampler})}s++}return i.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:o})}_createLayoutEntries(e){const t=[];let n=0;for(const s of e.bindings){const i=this.backend,o={binding:n,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const e={};s.isStorageBuffer&&(s.visibility&GPUShaderStage.COMPUTE?s.access===NodeAccess.READ_WRITE||s.access===NodeAccess.WRITE_ONLY?e.type=GPUBufferBindingType.Storage:e.type=GPUBufferBindingType.ReadOnlyStorage:e.type=GPUBufferBindingType.ReadOnlyStorage),o.buffer=e}else if(s.isSampledTexture&&s.store){const e={};e.format=this.backend.get(s.texture).texture.format;const t=s.access;t===NodeAccess.READ_WRITE?e.access=GPUStorageTextureAccess.ReadWrite:t===NodeAccess.WRITE_ONLY?e.access=GPUStorageTextureAccess.WriteOnly:e.access=GPUStorageTextureAccess.ReadOnly,s.texture.isArrayTexture?e.viewDimension=GPUTextureViewDimension.TwoDArray:s.texture.is3DTexture&&(e.viewDimension=GPUTextureViewDimension.ThreeD),o.storageTexture=e}else if(s.isSampledTexture){const e={},{primarySamples:t}=i.utils.getTextureSampleData(s.texture);if(t>1&&(e.multisampled=!0,s.texture.isDepthTexture||(e.sampleType=GPUTextureSampleType.UnfilterableFloat)),s.texture.isDepthTexture)i.compatibilityMode&&s.texture.compareFunction===null?e.sampleType=GPUTextureSampleType.UnfilterableFloat:e.sampleType=GPUTextureSampleType.Depth;else if(s.texture.isDataTexture||s.texture.isDataArrayTexture||s.texture.isData3DTexture){const t=s.texture.type;t===IntType?e.sampleType=GPUTextureSampleType.SInt:t===UnsignedIntType?e.sampleType=GPUTextureSampleType.UInt:t===FloatType&&(this.backend.hasFeature("float32-filterable")?e.sampleType=GPUTextureSampleType.Float:e.sampleType=GPUTextureSampleType.UnfilterableFloat)}s.isSampledCubeTexture?e.viewDimension=GPUTextureViewDimension.Cube:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?e.viewDimension=GPUTextureViewDimension.TwoDArray:s.isSampledTexture3D&&(e.viewDimension=GPUTextureViewDimension.ThreeD),o.texture=e}else if(s.isSampler){const e={};s.texture.isDepthTexture&&(s.texture.compareFunction!==null?e.type=GPUSamplerBindingType.Comparison:i.compatibilityMode&&(e.type=GPUSamplerBindingType.NonFiltering)),o.sampler=e}else error(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(o),n++}return t}deleteBindGroupData(e){const{backend:n}=this,t=n.get(e);t.layout&&(t.layout.usedTimes--,t.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(t.layoutKey),t.layout=0[0],t.layoutKey=0[0])}dispose(){this._bindGroupLayoutCache.clear()}}class WebGPUPipelineUtils{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){const n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}
427_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:x,material:n,geometry:C,pipeline:v}=e,{vertexProgram:k,fragmentProgram:E}=v,o=this.backend,i=o.device,l=o.utils,r=o.get(v),f=[];for(const t of e.getBindings()){const n=o.get(t),{layoutGPU:s}=n.layout;f.push(s)}const b=o.attributeUtils.createShaderVertexBuffers(e);let c;n.blending!==NoBlending&&(n.blending!==NormalBlending||n.transparent!==!1)&&(c=this._getBlending(n));let g={};n.stencilWrite===!0&&(g={compare:this._getStencilCompare(n),failOp:this._getStencilOperation(n.stencilFail),depthFailOp:this._getStencilOperation(n.stencilZFail),passOp:this._getStencilOperation(n.stencilZPass)});const u=this._getColorWriteMask(n),a=[];if(e.context.textures!==null){const t=e.context.textures;for(let e=0;e<t.length;e++){const n=l.getTextureFormatGPU(t[e]);e===0?a.push({format:n,blend:c,writeMask:u}):a.push({format:n,writeMask:u})}}else{const t=l.getCurrentColorFormat(e.context);a.push({format:t,blend:c,writeMask:u})}const O=o.get(k).module,j=o.get(E).module,y=this._getPrimitiveState(x,C,n),_=this._getDepthCompare(n),w=l.getCurrentDepthStencilFormat(e.context),h=this._getSampleCount(e.context),d={label:`renderPipeline_${n.name||n.type}_${n.id}`,vertex:Object.assign({},O,{buffers:b}),fragment:Object.assign({},j,{targets:a}),primitive:y,multisample:{count:h,alphaToCoverageEnabled:n.alphaToCoverage&&h>1},layout:i.createPipelineLayout({bindGroupLayouts:f})},s={},p=e.context.depth,m=e.context.stencil;if((p===!0||m===!0)&&(p===!0&&(s.format=w,s.depthWriteEnabled=n.depthWrite,s.depthCompare=_),m===!0&&(s.stencilFront=g,s.stencilBack={},s.stencilReadMask=n.stencilFuncMask,s.stencilWriteMask=n.stencilWriteMask),n.polygonOffset===!0&&(s.depthBias=n.polygonOffsetUnits,s.depthBiasSlopeScale=n.polygonOffsetFactor,s.depthBiasClamp=0),d.depthStencil=s),i.pushErrorScope("validation"),t===null)r.pipeline=i.createRenderPipeline(d),i.popErrorScope().then(e=>{e!==null&&(r.error=!0,error(e.message))});else{const e=new Promise(async e=>{try{r.pipeline=await i.createRenderPipelineAsync(d)}catch{}const t=await i.popErrorScope();t!==null&&(r.error=!0,error(t.message)),e()});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const s=this.backend,{utils:n,device:o}=s,i=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormats(e),r=this._getSampleCount(e),c={label:t,colorFormats:a,depthStencilFormat:i,sampleCount:r};return o.createRenderBundleEncoder(c)}createComputePipeline(e,t){const n=this.backend,s=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(const e of t){const s=n.get(e),{layoutGPU:i}=s.layout;o.push(i)}a.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n;const s=e.blending,o=e.blendSrc,i=e.blendDst,a=e.blendEquation;if(s===CustomBlending){const s=e.blendSrcAlpha!==null?e.blendSrcAlpha:o,r=e.blendDstAlpha!==null?e.blendDstAlpha:i,c=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(i),operation:this._getBlendOperation(a)},n={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(r),operation:this._getBlendOperation(c)}}else{const i=e.premultipliedAlpha,o=(e,s,o,i)=>{t={srcFactor:e,dstFactor:s,operation:GPUBlendOperation.Add},n={srcFactor:o,dstFactor:i,operation:GPUBlendOperation.Add}};if(i)switch(s){case NormalBlending:o(GPUBlendFactor.One,GPUBlendFactor.OneMinusSrcAlpha,GPUBlendFactor.One,GPUBlendFactor.OneMinusSrcAlpha);break;case AdditiveBlending:o(GPUBlendFactor.One,GPUBlendFactor.One,GPUBlendFactor.One,GPUBlendFactor.One);break;case SubtractiveBlending:o(GPUBlendFactor.Zero,GPUBlendFactor.OneMinusSrc,GPUBlendFactor.Zero,GPUBlendFactor.One);break;case MultiplyBlending:o(GPUBlendFactor.Dst,GPUBlendFactor.OneMinusSrcAlpha,GPUBlendFactor.Zero,GPUBlendFactor.One);break}else switch(s){case NormalBlending:o(GPUBlendFactor.SrcAlpha,GPUBlendFactor.OneMinusSrcAlpha,GPUBlendFactor.One,GPUBlendFactor.OneMinusSrcAlpha);break;case AdditiveBlending:o(GPUBlendFactor.SrcAlpha,GPUBlendFactor.One,GPUBlendFactor.One,GPUBlendFactor.One);break;case SubtractiveBlending:error("WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case MultiplyBlending:error("WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==0[0]&&n!==0[0])return{color:t,alpha:n};error("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case ZeroFactor:t=GPUBlendFactor.Zero;break;case OneFactor:t=GPUBlendFactor.One;break;case SrcColorFactor:t=GPUBlendFactor.Src;break;case OneMinusSrcColorFactor:t=GPUBlendFactor.OneMinusSrc;break;case SrcAlphaFactor:t=GPUBlendFactor.SrcAlpha;break;case OneMinusSrcAlphaFactor:t=GPUBlendFactor.OneMinusSrcAlpha;break;case DstColorFactor:t=GPUBlendFactor.Dst;break;case OneMinusDstColorFactor:t=GPUBlendFactor.OneMinusDst;break;case DstAlphaFactor:t=GPUBlendFactor.DstAlpha;break;case OneMinusDstAlphaFactor:t=GPUBlendFactor.OneMinusDstAlpha;break;case SrcAlphaSaturateFactor:t=GPUBlendFactor.SrcAlphaSaturated;break;case BlendColorFactor:t=GPUBlendFactor.Constant;break;case OneMinusBlendColorFactor:t=GPUBlendFactor.OneMinusConstant;break;default:error("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case NeverStencilFunc:t=GPUCompareFunction.Never;break;case AlwaysStencilFunc:t=GPUCompareFunction.Always;break;case LessStencilFunc:t=GPUCompareFunction.Less;break;case LessEqualStencilFunc:t=GPUCompareFunction.LessEqual;break;case EqualStencilFunc:t=GPUCompareFunction.Equal;break;case GreaterEqualStencilFunc:t=GPUCompareFunction.GreaterEqual;break;case GreaterStencilFunc:t=GPUCompareFunction.Greater;break;case NotEqualStencilFunc:t=GPUCompareFunction.NotEqual;break;default:error("WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case KeepStencilOp:t=GPUStencilOperation.Keep;break;case ZeroStencilOp:t=GPUStencilOperation.Zero;break;case ReplaceStencilOp:t=GPUStencilOperation.Replace;break;case InvertStencilOp:t=GPUStencilOperation.Invert;break;case IncrementStencilOp:t=GPUStencilOperation.IncrementClamp;break;case DecrementStencilOp:t=GPUStencilOperation.DecrementClamp;break;case IncrementWrapStencilOp:t=GPUStencilOperation.IncrementWrap;break;case DecrementWrapStencilOp:t=GPUStencilOperation.DecrementWrap;break;default:error("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case AddEquation:t=GPUBlendOperation.Add;break;case SubtractEquation:t=GPUBlendOperation.Subtract;break;case ReverseSubtractEquation:t=GPUBlendOperation.ReverseSubtract;break;case MinEquation:t=GPUBlendOperation.Min;break;case MaxEquation:t=GPUBlendOperation.Max;break;default:error("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const s={},i=this.backend.utils;
427s.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GPUIndexFormat.Uint16:GPUIndexFormat.Uint32);let o=n.side===BackSide;return e.isMesh&&e.matrixWorld.determinant()<0&&(o=!o),s.frontFace=o===!0?GPUFrontFace.CW:GPUFrontFace.CCW,s.cullMode=n.side===DoubleSide?GPUCullMode.None:GPUCullMode.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?GPUColorWriteFlags.All:GPUColorWriteFlags.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=GPUCompareFunction.Always;else{const n=e.depthFunc;switch(n){case NeverDepth:t=GPUCompareFunction.Never;break;case AlwaysDepth:t=GPUCompareFunction.Always;break;case LessDepth:t=GPUCompareFunction.Less;break;case LessEqualDepth:t=GPUCompareFunction.LessEqual;break;case EqualDepth:t=GPUCompareFunction.Equal;break;case GreaterEqualDepth:t=GPUCompareFunction.GreaterEqual;break;case GreaterDepth:t=GPUCompareFunction.Greater;break;case NotEqualDepth:t=GPUCompareFunction.NotEqual;break;default:error("WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class WebGPUTimestampQueryPool extends TimestampQueryPool{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}`});const s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return warnOnce(`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;const 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{const e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const r=new Map(this.queryOffsets),o=this.currentQueryIndex,n=o*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,o,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const c=s.finish();if(this.device.queue.submit([c]),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;const i=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),t={},e=[];for(const[s,o]of r){const c=s.match(/^(.*):f(\d+)$/),n=parseInt(c[2]);e.includes(n)===!1&&e.push(n),t[n]===0[0]&&(t[n]=0);const l=i[o],d=i[o+1],a=Number(d-l)/1e6;this.timestamps.set(s,a),t[n]+=a}const a=t[e[e.length-1]];return this.resultBuffer.unmap(),this.lastValue=a,this.frames=e,a}catch(e){return error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(this.isDisposed)return;if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){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}}class WebGPUBackend extends Backend{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===0[0]||e.alpha,this.parameters.compatibilityMode=e.compatibilityMode!==0[0]&&e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===0[0]?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new WebGPUUtils(this),this.attributeUtils=new WebGPUAttributeUtils(this),this.bindingUtils=new WebGPUBindingUtils(this),this.pipelineUtils=new WebGPUPipelineUtils(this),this.textureUtils=new WebGPUTextureUtils(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===0[0]){const o={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":0[0]},e=typeof navigator!="undefined"?await navigator.gpu.requestAdapter(o):null;if(e===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(GPUFeatureName),s=[];for(const t of i)e.features.has(t)&&s.push(t);const a={requiredFeatures:s,requiredLimits:t.requiredLimits};n=await e.requestDevice(a)}else n=t.device;n.lost.then(t=>{if(t.reason==="destroyed")return;const n={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(GPUFeatureName.TimestampQuery),this.updateSize()}get context(){const t=this.renderer.getCanvasTarget(),n=this.get(t);let e=n.context;if(e===0[0]){const s=this.parameters;t.isDefaultCanvasTarget===!0&&s.context!==0[0]?e=s.context:e=t.domElement.getContext("webgpu"),"setAttribute"in t.domElement&&t.domElement.setAttribute("data-engine",`three.js r${REVISION} webgpu`);const o=s.alpha?"premultiplied":"opaque",i=s.outputType===HalfFloatType?"extended":"standard";e.configure({device:this.device,format:this.utils.getPreferredCanvasF
427ormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:o,toneMapping:{mode:i}}),n.context=e}return e}get coordinateSystem(){return WebGPUCoordinateSystem}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const t=this.renderer,i=t.getCanvasTarget(),n=this.get(i),s=t.currentSamples;let e=n.descriptor;if(e===0[0]||n.samples!==s){e={colorAttachments:[{view:null}]},(t.depth===!0||t.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const o=e.colorAttachments[0];s>0?o.view=this.textureUtils.getColorBuffer().createView():o.resolveTarget=0[0],n.descriptor=e,n.samples=s}const o=e.colorAttachments[0];return s>0?o.resolveTarget=this.context.getCurrentTexture().createView():o.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const s=e.renderTarget,n=this.get(s);let i=n.descriptors;(i===0[0]||n.width!==s.width||n.height!==s.height||n.samples!==s.samples)&&(i={},n.descriptors=i);const r=e.getCacheKey();let o=i[r];if(o===0[0]){const t=e.textures,a=[];let c;const l=this._isRenderCameraDepthArray(e);for(let n=0;n<t.length;n++){const i=this.get(t[n]),o={label:`colorAttachment_${n}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:GPUTextureViewDimension.TwoD};if(s.isRenderTarget3D)c=e.activeCubeFace,o.baseArrayLayer=0,o.dimension=GPUTextureViewDimension.ThreeD,o.depthOrArrayLayers=t[n].image.depth;else if(s.isRenderTarget&&t[n].image.depth>1)if(l===!0){const t=e.camera.cameras;for(let e=0;e<t.length;e++){const n={...o,baseArrayLayer:e,arrayLayerCount:1,dimension:GPUTextureViewDimension.TwoD},s=i.texture.createView(n);a.push({view:s,resolveTarget:0[0],depthSlice:0[0]})}}else o.dimension=GPUTextureViewDimension.TwoDArray,o.depthOrArrayLayers=t[n].image.depth;if(l!==!0){const n=i.texture.createView(o);let e,t;i.msaaTexture!==0[0]?(e=i.msaaTexture.createView(),t=n):(e=n,t=0[0]),a.push({view:e,resolveTarget:t,depthSlice:c})}}if(o={textureViews:a},e.depth){const n=this.get(e.depthTexture),t={};(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(t.dimension=GPUTextureViewDimension.TwoD,t.arrayLayerCount=1,t.baseArrayLayer=e.activeCubeFace),o.depthStencilView=n.texture.createView(t)}i[r]=o,n.width=s.width,n.height=s.height,n.samples=s.samples,n.activeMipmapLevel=e.activeMipmapLevel,n.activeCubeFace=e.activeCubeFace}const a={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){const n=o.textureViews[e];let s={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(s=t.clearValue),a.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||GPULoadOp.Load,storeOp:t.storeOp||GPUStoreOp.Store,clearValue:s})}return o.depthStencilView&&(a.depthStencilAttachment={view:o.depthStencilView}),a}beginRender(e){const t=this.get(e),a=this.device,o=e.occlusionQueryCount;let i;o>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=a.createQuerySet({type:"occlusion",count:o,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(o),t.lastOcclusionObject=null);let n;e.textures===null?n=this._getDefaultRenderPassDescriptor():n=this._getRenderPassDescriptor(e,{loadOp:GPULoadOp.Load}),this.initTimestampQuery(TimestampQuery.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=i;const s=n.depthStencilAttachment;if(e.textures!==null){const t=n.colorAttachments;for(let n=0;n<t.length;n++){const s=t[n];e.clearColor?(s.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},s.loadOp=GPULoadOp.Clear):s.loadOp=GPULoadOp.Load,s.storeOp=GPUStoreOp.Store}}else{const t=n.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=GPULoadOp.Clear):t.loadOp=GPULoadOp.Load,t.storeOp=GPUStoreOp.Store}e.depth&&(e.clearDepth?(s.depthClearValue=e.clearDepthValue,s.depthLoadOp=GPULoadOp.Clear):s.depthLoadOp=GPULoadOp.Load,s.depthStoreOp=GPUStoreOp.Store),e.stencil&&(e.clearStencil?(s.stencilClearValue=e.clearStencilValue,s.stencilLoadOp=GPULoadOp.Clear):s.stencilLoadOp=GPULoadOp.Load,s.stencilStoreOp=GPUStoreOp.Store);const r=a.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const s=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==s.length?this._createDepthLayerDescriptors(e,t,n,s):this._updateDepthLayerDescriptors(e,t,s),t.bundleEncoders=[],t.bundleSets=[];for(let n=0;n<s.length;n++){const o=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+n),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(o),t.bundleSets.push(i)}t.currentPass=null}else{const s=r.beginRenderPass(n);t.currentPass=s,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}
427t.descriptor=n,t.encoder=r,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,s){const o=n.depthStencilAttachment;t.layerDescriptors=[];const i=this.get(e.depthTexture);i.viewCache||(i.viewCache=[]);for(let r=0;r<s.length;r++){const a={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[r].view}]};if(n.depthStencilAttachment){const t=r;i.viewCache[t]||(i.viewCache[t]=i.texture.createView({dimension:GPUTextureViewDimension.TwoD,baseArrayLayer:r,arrayLayerCount:1})),a.depthStencilAttachment={view:i.viewCache[t],depthLoadOp:o.depthLoadOp||GPULoadOp.Clear,depthStoreOp:o.depthStoreOp||GPUStoreOp.Store,depthClearValue:o.depthClearValue||1},e.stencil&&(a.depthStencilAttachment.stencilLoadOp=o.stencilLoadOp,a.depthStencilAttachment.stencilStoreOp=o.stencilStoreOp,a.depthStencilAttachment.stencilClearValue=o.stencilClearValue)}else a.depthStencilAttachment={...o};t.layerDescriptors.push(a)}}_updateDepthLayerDescriptors(e,t,n){for(let s=0;s<n.length;s++){const o=t.layerDescriptors[s];if(o.depthStencilAttachment){const t=o.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=GPULoadOp.Clear):t.depthLoadOp=GPULoadOp.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=GPULoadOp.Clear):t.stencilLoadOp=GPULoadOp.Load)}}}finishRender(e){const t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){{const n=[];for(let e=0;e<t.bundleEncoders.length;e++){const s=t.bundleEncoders[e];n.push(s.finish())}for(let o=0;o<t.layerDescriptors.length;o++)if(o<n.length){const a=t.layerDescriptors[o],i=s.beginRenderPass(a);if(e.viewport){const{x:t,y:n,width:s,height:o,minDepth:a,maxDepth:r}=e.viewportValue;i.setViewport(t,n,s,o,a,r)}if(e.scissor){const{x:t,y:n,width:s,height:o}=e.scissorValue;i.setScissorRect(t,n,s,o)}i.executeBundles([n[o]]),i.end()}}}else t.currentPass&&t.currentPass.end();if(n>0){const s=n*8;let o=this.occludedResolveCache.get(s);o===0[0]&&(o=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,o));const i=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,o,0),t.encoder.copyBufferToBuffer(o,0,i,0,s),t.occlusionQueryBuffer=i,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const t=e.textures;for(let e=0;e<t.length;e++){const n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:s}=t;if(n&&s){const e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);const o=n.getMappedRange(),i=new BigUint64Array(o);for(let t=0;t<s.length;t++)i[t]===BigInt(0)&&e.add(s[t]);n.destroy(),t.occluded=e}}updateViewport(e){const{currentPass:t}=this.get(e),{x:n,y:s,width:o,height:i,minDepth:a,maxDepth:r}=e.viewportValue;t.setViewport(n,s,o,i,a,r)}updateScissor(e){const{currentPass:t}=this.get(e),{x:n,y:s,width:o,height:i}=e.scissorValue;t.setScissorRect(n,s,o,i)}getClearColor(){const e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,s=null){const d=this.device,i=this.renderer;let c=[],o,l,a,r;if(e){const e=this.getClearColor();l={r:e.r,g:e.g,b:e.b,a:e.a}}if(s===null){a=i.depth,r=i.stencil;const t=this._getDefaultRenderPassDescriptor();if(e){c=t.colorAttachments;const e=c[0];e.clearValue=l,e.loadOp=GPULoadOp.Clear,e.storeOp=GPUStoreOp.Store}(a||r)&&(o=t.depthStencilAttachment)}else{a=s.depth,r=s.stencil;const d={loadOp:e?GPULoadOp.Clear:GPULoadOp.Load,clearValue:e?l:0[0]};a&&(d.depthLoadOp=t?GPULoadOp.Clear:GPULoadOp.Load,d.depthClearValue=t?i.getClearDepth():0[0],d.depthStoreOp=GPUStoreOp.Store),r&&(d.stencilLoadOp=n?GPULoadOp.Clear:GPULoadOp.Load,d.stencilClearValue=n?i.getClearStencil():0[0],d.stencilStoreOp=GPUStoreOp.Store);const u=this._getRenderPassDescriptor(s,d);c=u.colorAttachments,o=u.depthStencilAttachment}a&&o&&(t?(o.depthLoadOp=GPULoadOp.Clear,o.depthClearValue=i.getClearDepth(),o.depthStoreOp=GPUStoreOp.Store):(o.depthLoadOp=GPULoadOp.Load,o.depthStoreOp=GPUStoreOp.Store)),r&&o&&(n?(o.stencilLoadOp=GPULoadOp.Clear,o.stencilClearValue=i.getClearStencil(),o.stencilStoreOp=GPUStoreOp.Store):(o.stencilLoadOp=GPULoadOp.Load,o.stencilStoreOp=GPUStoreOp.Store));const u=d.createCommandEncoder({label:"clear"}),h=u.beginRenderPass({colorAttachments:c,depthStencilAttachment:o});h.end(),d.queue.submit([u.finish()])}beginCompute(e){const t=this.get(e),n={label:"computeGroup_"+e.id};this.initTimestampQuery(TimestampQuery.COMPUTE,this.getTimestampUID(e),n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,s,o=null){const i=this.get(t),{passEncoderGPU:a}=this.get(e),r=this.get(s).pipeline;this.pipelineUtils.setPipeline(a,r);for(let e=0,t=n.length;e<t;e++){const s=n[e],o=this.get(s);a.setBindGroup(e,o.group)}if(o===null&&(o=t.count),o&&typeof o=="object"&&o.isIndirectStorageBufferAttribute){const e=this.get(o).buffer;a.dispatchWorkgroupsIndirect(e,0);return}if(typeof o=="number"){const e=o;if(i.dispatchSize===0[0]||i.count!==e){i.dispatchSize=[0,1,1],i.count=e;const s=t.workgroupSize;let r=s[0];for(let e=1;e<s.length;e++)r*=s[e];const n=Math.ceil(e/r),a=this.device.limits.maxComputeWorkgroupsPerDimension;o=[n,1,1],n>a&&(o[0]=Math.min(n,a),o[1]=Math.ceil(n/a)),i.dispatchSize=o}o=i.dispatchSize}a.dispatchWorkgroups(o[0],o[1]||1,o[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:s,material:i,context:a,pipeline:m}=e,u=e.getBindings(),n=this.get(a),l=this.get(m),d=l.pipeline;if(l.error===!0)return;const o=e.getIndex(),c=o!==null,r=e.getDrawParameters();if(r===null)return;const f=(t,s)=>{this.pipelineUtils.setPipeline(t,d),s.pipeline=d;const r=s.bindingGroups;for(let n=0,s=u.length;n<s;n++){const e=u[n],o=this.get(e);r[e.index]!==e.id&&(t.setBindGroup(e.index,o.group),r[e.index]=e.id)}if(c===!0&&s.index!==o){const e=this.get(o).buffer,n=o.array instanceof Uint16Array?GPUIndexFormat.Uint16:GPUIndexFormat.Uint32;t.setIndexBuffer(e,n),s.index=o}const l=e.getVertexBuffers();for(let e=0,o=l.length;e<o;e++){const n=l[e];
427if(s.attributes[e]!==n){const o=this.get(n).buffer;t.setVertexBuffer(e,o),s.attributes[e]=n}}a.stencil===!0&&i.stencilWrite===!0&&n.currentStencilRef!==i.stencilRef&&(t.setStencilReference(i.stencilRef),n.currentStencilRef=i.stencilRef)},h=(n,i)=>{if(f(n,i),s.isBatchedMesh===!0){const a=s._multiDrawStarts,e=s._multiDrawCounts,r=s._multiDrawCount,i=s._multiDrawInstances;i!==null&&warnOnce("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let l=0;l<r;l++){const d=i?i[l]:1,u=d>1?0:l;c===!0?n.drawIndexed(e[l],d,a[l]/o.array.BYTES_PER_ELEMENT,0,u):n.draw(e[l],d,a[l],u),t.update(s,e[l],d)}}else if(c===!0){const{vertexCount:o,instanceCount:i,firstVertex:c}=r,a=e.getIndirect();if(a!==null){const o=this.get(a).buffer,t=e.getIndirectOffset(),s=Array.isArray(t)?t:[t];for(let e=0;e<s.length;e++)n.drawIndexedIndirect(o,s[e])}else n.drawIndexed(o,i,c,0,0);t.update(s,o,i)}else{const{vertexCount:o,instanceCount:i,firstVertex:c}=r,a=e.getIndirect();if(a!==null){const o=this.get(a).buffer,t=e.getIndirectOffset(),s=Array.isArray(t)?t:[t];for(let e=0;e<s.length;e++)n.drawIndirect(o,s[e])}else n.draw(o,i,c,0);t.update(s,o,i)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){{const t=this.get(e.camera),i=e.camera.cameras,o=e.getBindingGroup("cameraIndex");if(t.indexesGPU===0[0]||t.indexesGPU.length!==i.length){const s=this.get(o),e=[],n=new Uint32Array([0,0,0,0]);for(let t=0,o=i.length;t<o;t++){n[0]=t;const{layoutGPU:a}=s.layout,r=this.bindingUtils.createBindGroupIndex(n,a);e.push(r)}t.indexesGPU=e}const r=this.renderer.getPixelRatio();for(let e=0,l=i.length;e<l;e++){const c=i[e];if(s.layers.test(c.layers)){const s=c.viewport;let i=n.currentPass,l=n.currentSets;if(n.bundleEncoders){const t=n.bundleEncoders[e],s=n.bundleSets[e];i=t,l=s}s&&i.setViewport(Math.floor(s.x*r),Math.floor(s.y*r),Math.floor(s.width*r),Math.floor(s.height*r),a.viewportValue.minDepth,a.viewportValue.maxDepth),o&&t.indexesGPU&&(i.setBindGroup(o.index,t.indexesGPU[e]),l.bindingGroups[o.index]=o.id),h(i,l)}}}}else if(n.currentPass){if(n.occlusionQuerySet!==0[0]){const e=n.lastOcclusionObject;e!==s&&(e!==null&&e.occlusionTest===!0&&(n.currentPass.endOcclusionQuery(),n.occlusionQueryIndex++),s.occlusionTest===!0&&(n.currentPass.beginOcclusionQuery(n.occlusionQueryIndex),n.occlusionQueryObjects[n.occlusionQueryIndex]=s),n.lastOcclusionObject=s)}h(n.currentPass,n.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:d,material:n}=e,s=this.utils,o=s.getSampleCountRenderContext(e.context),i=s.getCurrentColorSpace(e.context),a=s.getCurrentColorFormat(e.context),r=s.getCurrentDepthStencilFormat(e.context),c=s.getPrimitiveTopology(d,n);let l=!1;return(t.material!==n||t.materialVersion!==n.version||t.transparent!==n.transparent||t.blending!==n.blending||t.premultipliedAlpha!==n.premultipliedAlpha||t.blendSrc!==n.blendSrc||t.blendDst!==n.blendDst||t.blendEquation!==n.blendEquation||t.blendSrcAlpha!==n.blendSrcAlpha||t.blendDstAlpha!==n.blendDstAlpha||t.blendEquationAlpha!==n.blendEquationAlpha||t.colorWrite!==n.colorWrite||t.depthWrite!==n.depthWrite||t.depthTest!==n.depthTest||t.depthFunc!==n.depthFunc||t.stencilWrite!==n.stencilWrite||t.stencilFunc!==n.stencilFunc||t.stencilFail!==n.stencilFail||t.stencilZFail!==n.stencilZFail||t.stencilZPass!==n.stencilZPass||t.stencilFuncMask!==n.stencilFuncMask||t.stencilWriteMask!==n.stencilWriteMask||t.side!==n.side||t.alphaToCoverage!==n.alphaToCoverage||t.sampleCount!==o||t.colorSpace!==i||t.colorFormat!==a||t.depthStencilFormat!==r||t.primitiveTopology!==c||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=n,t.materialVersion=n.version,t.transparent=n.transparent,t.blending=n.blending,t.premultipliedAlpha=n.premultipliedAlpha,t.blendSrc=n.blendSrc,t.blendDst=n.blendDst,t.blendEquation=n.blendEquation,t.blendSrcAlpha=n.blendSrcAlpha,t.blendDstAlpha=n.blendDstAlpha,t.blendEquationAlpha=n.blendEquationAlpha,t.colorWrite=n.colorWrite,t.depthWrite=n.depthWrite,t.depthTest=n.depthTest,t.depthFunc=n.depthFunc,t.stencilWrite=n.stencilWrite,t.stencilFunc=n.stencilFunc,t.stencilFail=n.stencilFail,t.stencilZFail=n.stencilZFail,t.stencilZPass=n.stencilZPass,t.stencilFuncMask=n.stencilFuncMask,t.stencilWriteMask=n.stencilWriteMask,t.side=n.side,t.alphaToCoverage=n.alphaToCoverage,t.sampleC
427ount=o,t.colorSpace=i,t.colorFormat=a,t.depthStencilFormat=r,t.primitiveTopology=c,t.clippingContextCacheKey=e.clippingContextCacheKey,l=!0),l}getRenderCacheKey(e){const{object:o,material:t}=e,n=this.utils,s=e.context,i=o.isMesh&&o.matrixWorld.determinant()<0;return[t.transparent,t.blending,t.premultipliedAlpha,t.blendSrc,t.blendDst,t.blendEquation,t.blendSrcAlpha,t.blendDstAlpha,t.blendEquationAlpha,t.colorWrite,t.depthWrite,t.depthTest,t.depthFunc,t.stencilWrite,t.stencilFunc,t.stencilFail,t.stencilZFail,t.stencilZPass,t.stencilFuncMask,t.stencilWriteMask,t.side,i,n.getSampleCountRenderContext(s),n.getCurrentColorSpace(s),n.getCurrentColorFormat(s),n.getCurrentDepthStencilFormat(s),n.getPrimitiveTopology(o,t),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,s,o,i){return this.textureUtils.copyTextureToBuffer(e,t,n,s,o,i)}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new WebGPUTimestampQueryPool(this.device,e,2048));const s=this.timestampQueryPool[e],o=s.allocateQueriesForContext(t);n.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:o,endOfPassWriteIndex:o+1}}createNodeBuilder(e,t){return new WGSLNodeBuilder(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass,o=s.finish();this.get(t).bundleGPU=o,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){const n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,s){this.bindingUtils.createBindings(e,t,n,s)}updateBindings(e,t,n,s){this.bindingUtils.createBindings(e,t,n,s)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}getMaxAnisotropy(){return 16}hasFeature(e){return GPUFeatureMap[e]!==0[0]&&(e=GPUFeatureMap[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,s=null,o=0,i=0){let u=0,h=0,m=0,a=0,r=0,f=0,c=e.image.width,l=e.image.height,d=1;n!==null&&(n.isBox3===!0?(a=n.min.x,r=n.min.y,f=n.min.z,c=n.max.x-n.min.x,l=n.max.y-n.min.y,d=n.max.z-n.min.z):(a=n.min.x,r=n.min.y,c=n.max.x-n.min.x,l=n.max.y-n.min.y,d=1)),s!==null&&(u=s.x,h=s.y,m=s.z||0);const p=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),g=this.get(e).texture,v=this.get(t).texture;p.copyTextureToTexture({texture:g,mipLevel:o,origin:{x:a,y:r,z:f}},{texture:v,mipLevel:i,origin:{x:u,y:h,z:m}},[c,l,d]),this.device.queue.submit([p.finish()]),i===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){const s=this.get(t);let o=null;t.renderTarget?e.isDepthTexture?o=this.get(t.depthTexture).texture:o=this.get(t.textures[0]).texture:e.isDepthTexture?o=this.textureUtils.getDepthBuffer(t.depth,t.stencil):o=this.context.getCurrentTexture();const a=this.get(e).texture;if(o.format!==a.format){error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",o.format,a.format);return}let i;if(s.currentPass?(s.currentPass.end(),i=s.encoder):i=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),i.copyTextureToTexture({texture:o,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,i),s.currentPass){const{descriptor:e}=s;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=GPULoadOp.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=GPULoadOp.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=GPULoadOp.Load),s.currentPass=i.beginRenderPass(e),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}
427else this.device.queue.submit([i.finish()])}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(const e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(const e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===0[0]&&this.device!==null&&this.device.destroy()}}class IESSpotLight extends SpotLight{constructor(e,t,n,s,o,i){super(e,t,n,s,o,i),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class ProjectorLight extends SpotLight{constructor(e,t,n,s,o,i){super(e,t,n,s,o,i),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class StandardNodeLibrary extends NodeLibrary{constructor(){super(),this.addMaterial(MeshPhongNodeMaterial,"MeshPhongMaterial"),this.addMaterial(MeshStandardNodeMaterial,"MeshStandardMaterial"),this.addMaterial(MeshPhysicalNodeMaterial,"MeshPhysicalMaterial"),this.addMaterial(MeshToonNodeMaterial,"MeshToonMaterial"),this.addMaterial(MeshBasicNodeMaterial,"MeshBasicMaterial"),this.addMaterial(MeshLambertNodeMaterial,"MeshLambertMaterial"),this.addMaterial(MeshNormalNodeMaterial,"MeshNormalMaterial"),this.addMaterial(MeshMatcapNodeMaterial,"MeshMatcapMaterial"),this.addMaterial(LineBasicNodeMaterial,"LineBasicMaterial"),this.addMaterial(LineDashedNodeMaterial,"LineDashedMaterial"),this.addMaterial(PointsNodeMaterial,"PointsMaterial"),this.addMaterial(SpriteNodeMaterial,"SpriteMaterial"),this.addMaterial(ShadowNodeMaterial,"ShadowMaterial"),this.addLight(PointLightNode,PointLight),this.addLight(DirectionalLightNode,DirectionalLight),this.addLight(RectAreaLightNode,RectAreaLight),this.addLight(SpotLightNode,SpotLight),this.addLight(AmbientLightNode,AmbientLight),this.addLight(HemisphereLightNode,HemisphereLight),this.addLight(LightProbeNode,LightProbe),this.addLight(IESSpotLightNode,IESSpotLight),this.addLight(ProjectorLightNode,ProjectorLight),this.addToneMapping(linearToneMapping,LinearToneMapping),this.addToneMapping(reinhardToneMapping,ReinhardToneMapping),this.addToneMapping(cineonToneMapping,CineonToneMapping),this.addToneMapping(acesFilmicToneMapping,ACESFilmicToneMapping),this.addToneMapping(agxToneMapping,AgXToneMapping),this.addToneMapping(neutralToneMapping,NeutralToneMapping)}}class WebGPURenderer extends Renderer{constructor(e={}){let t;e.forceWebGL?t=WebGLBackend:(t=WebGPUBackend,e.getFallback=()=>(warn("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new WebGLBackend(e)));const n=new t(e);super(n,e),this.library=new StandardNodeLibrary,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}alphahash_fragment=`#ifdef USE_ALPHAHASH 428 if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; 429#endif`,alphahash_pars_fragment=`#ifdef USE_ALPHAHASH 430 const float ALPHA_HASH_SCALE = 0.05; 431 float hash2D( vec2 value ) { 432 return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); 433 } 434 float hash3D( vec3 value ) { 435 return hash2D( vec2( hash2D( value.xy ), value.z ) ); 436 } 437 float getAlphaHashThreshold( vec3 position ) { 438 float maxDeriv = max( 439 length( dFdx( position.xyz ) ), 440 length( dFdy( position.xyz ) ) 441 ); 442 float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); 443 vec2 pixScales = vec2( 444 exp2( floor( log2( pixScale ) ) ), 445 exp2( ceil( log2( pixScale ) ) ) 446 ); 447 vec2 alpha = vec2( 448 hash3D( floor( pixScales.x * position.xyz ) ), 449 hash3D( floor( pixScales.y * position.xyz ) ) 450 ); 451 float lerpFactor = fract( log2( pixScale ) ); 452 float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; 453 float a = min( lerpFactor, 1.0 - lerpFactor ); 454 vec3 cases = vec3( 455 x * x / ( 2.0 * a * ( 1.0 - a ) ), 456 ( x - 0.5 * a ) / ( 1.0 - a ), 457 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) 458 ); 459 float threshold = ( x < ( 1.0 - a ) ) 460 ? ( ( x < a ) ? cases.x : cases.y ) 461 : cases.z; 462 return clamp( threshold , 1.0e-6, 1.0 ); 463 } 464#endif`,alphamap_fragment=`#ifdef USE_ALPHAMAP 465 diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; 466#endif`,alphamap_pars_fragment=`#ifdef USE_ALPHAMAP 467 uniform sampler2D alphaMap; 468#endif`,alphatest_fragment=`#ifdef USE_ALPHATEST 469 #ifdef ALPHA_TO_COVERAGE 470 diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); 471 if ( diffuseColor.a == 0.0 ) discard; 472 #else 473 if ( diffuseColor.a < alphaTest ) discard; 474 #endif 475#endif`,alphatest_pars_fragment=`#ifdef USE_ALPHATEST 476 uniform float alphaTest; 477#endif`,aomap_fragment=`#ifdef USE_AOMAP 478 float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; 479 reflectedLight.indirectDiffuse *= ambientOcclusion; 480 #if defined( USE_CLEARCOAT ) 481 clearcoatSpecularIndirect *= ambientOcclusion; 482 #endif 483 #if defined( USE_SHEEN ) 484 sheenSpecularIndirect *= ambientOcclusion; 485 #endif 486 #if defined( USE_ENVMAP ) && defined( STANDARD )
487 float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); 488 reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); 489 #endif 490#endif`,aomap_pars_fragment=`#ifdef USE_AOMAP 491 uniform sampler2D aoMap; 492 uniform float aoMapIntensity; 493#endif`,batching_pars_vertex=`#ifdef USE_BATCHING 494 #if ! defined( GL_ANGLE_multi_draw ) 495 #define gl_DrawID _gl_DrawID 496 uniform int _gl_DrawID; 497 #endif 498 uniform highp sampler2D batchingTexture; 499 uniform highp usampler2D batchingIdTexture; 500 mat4 getBatchingMatrix( const in float i ) { 501 int size = textureSize( batchingTexture, 0 ).x; 502 int j = int( i ) * 4; 503 int x = j % size; 504 int y = j / size; 505 vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); 506 vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); 507 vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); 508 vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); 509 return mat4( v1, v2, v3, v4 ); 510 } 511 float getIndirectIndex( const in int i ) { 512 int size = textureSize( batchingIdTexture, 0 ).x; 513 int x = i % size; 514 int y = i / size; 515 return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); 516 } 517#endif 518#ifdef USE_BATCHING_COLOR 519 uniform sampler2D batchingColorTexture; 520 vec3 getBatchingColor( const in float i ) { 521 int size = textureSize( batchingColorTexture, 0 ).x; 522 int j = int( i ); 523 int x = j % size; 524 int y = j / size; 525 return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb; 526 } 527#endif`,batching_vertex=`#ifdef USE_BATCHING 528 mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); 529#endif`,begin_vertex=`vec3 transformed = vec3( position ); 530#ifdef USE_ALPHAHASH 531 vPosition = vec3( position ); 532#endif`,beginnormal_vertex=`vec3 objectNormal = vec3( normal ); 533#ifdef USE_TANGENT 534 vec3 objectTangent = vec3( tangent.xyz ); 535#endif`,bsdfs=`float G_BlinnPhong_Implicit( ) { 536 return 0.25; 537} 538float D_BlinnPhong( const in float shininess, const in float dotNH ) { 539 return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); 540} 541vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { 542 vec3 halfDir = normalize( lightDir + viewDir ); 543 float dotNH = saturate( dot( normal, halfDir ) ); 544 float dotVH = saturate( dot( viewDir, halfDir ) ); 545 vec3 F = F_Schlick( specularColor, 1.0, dotVH ); 546 float G = G_BlinnPhong_Implicit( ); 547 float D = D_BlinnPhong( shininess, dotNH ); 548 return F * ( G * D ); 549} // validated`,iridescence_fragment=`#ifdef USE_IRIDESCENCE 550 const mat3 XYZ_TO_REC709 = mat3( 551 3.2404542, -0.9692660, 0.0556434, 552 -1.5371385, 1.8760108, -0.2040259, 553 -0.4985314, 0.0415560, 1.0572252 554 ); 555 vec3 Fresnel0ToIor( vec3 fresnel0 ) { 556 vec3 sqrtF0 = sqrt( fresnel0 ); 557 return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); 558 } 559 vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { 560 return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); 561 } 562 float IorToFresnel0( float transmittedIor, float incidentIor ) { 563 return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); 564 } 565 vec3 evalSensitivity( float OPD, vec3 shift ) { 566 float phase = 2.0 * PI * OPD * 1.0e-9; 567 vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); 568 vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); 569 vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); 570 vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); 571 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 ) ); 572 xyz /= 1.0685e-7; 573 vec3 rgb = XYZ_TO_REC709 * xyz; 574 return rgb; 575 } 576 vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { 577 vec3 I; 578 float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); 579 float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); 580 float cosTheta2Sq = 1.0 - sinTheta2Sq; 581 if ( cosTheta2Sq < 0.0 ) { 582 return vec3( 1.0 ); 583 } 584 float cosTheta2 = sqrt( cosTheta2Sq ); 585 float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
586 float R12 = F_Schlick( R0, 1.0, cosTheta1 ); 587 float T121 = 1.0 - R12; 588 float phi12 = 0.0; 589 if ( iridescenceIOR < outsideIOR ) phi12 = PI; 590 float phi21 = PI - phi12; 591 vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); 592 vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); 593 vec3 phi23 = vec3( 0.0 ); 594 if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; 595 if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; 596 if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; 597 float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; 598 vec3 phi = vec3( phi21 ) + phi23; 599 vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); 600 vec3 r123 = sqrt( R123 ); 601 vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); 602 vec3 C0 = R12 + Rs; 603 I = C0; 604 vec3 Cm = Rs - T121; 605 for ( int m = 1; m <= 2; ++ m ) { 606 Cm *= r123; 607 vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); 608 I += Cm * Sm; 609 } 610 return max( I, vec3( 0.0 ) ); 611 } 612#endif`,bumpmap_pars_fragment=`#ifdef USE_BUMPMAP 613 uniform sampler2D bumpMap; 614 uniform float bumpScale; 615 vec2 dHdxy_fwd() { 616 vec2 dSTdx = dFdx( vBumpMapUv ); 617 vec2 dSTdy = dFdy( vBumpMapUv ); 618 float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; 619 float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; 620 float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; 621 return vec2( dBx, dBy ); 622 } 623 vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { 624 vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); 625 vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); 626 vec3 vN = surf_norm; 627 vec3 R1 = cross( vSigmaY, vN ); 628 vec3 R2 = cross( vN, vSigmaX ); 629 float fDet = dot( vSigmaX, R1 ) * faceDirection; 630 vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 631 return normalize( abs( fDet ) * surf_norm - vGrad ); 632 } 633#endif`,clipping_planes_fragment=`#if NUM_CLIPPING_PLANES > 0 634 vec4 plane; 635 #ifdef ALPHA_TO_COVERAGE 636 float distanceToPlane, distanceGradient; 637 float clipOpacity = 1.0; 638 #pragma unroll_loop_start 639 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 640 plane = clippingPlanes[ i ]; 641 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 642 distanceGradient = fwidth( distanceToPlane ) / 2.0; 643 clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 644 if ( clipOpacity == 0.0 ) discard; 645 } 646 #pragma unroll_loop_end 647 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 648 float unionClipOpacity = 1.0; 649 #pragma unroll_loop_start 650 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 651 plane = clippingPlanes[ i ]; 652 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 653 distanceGradient = fwidth( distanceToPlane ) / 2.0; 654 unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 655 } 656 #pragma unroll_loop_end 657 clipOpacity *= 1.0 - unionClipOpacity; 658 #endif 659 diffuseColor.a *= clipOpacity; 660 if ( diffuseColor.a == 0.0 ) discard; 661 #else 662 #pragma unroll_loop_start 663 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 664 plane = clippingPlanes[ i ]; 665 if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; 666 } 667 #pragma unroll_loop_end 668 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 669 bool clipped = true; 670 #pragma unroll_loop_start 671 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 672 plane = clippingPlanes[ i ]; 673 clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; 674 } 675 #pragma unroll_loop_end 676 if ( clipped ) discard; 677 #endif 678 #endif 679#endif`,clipping_planes_pars_fragment=`#if NUM_CLIPPING_PLANES > 0 680 varying vec3 vClipPosition; 681 uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 682#endif`,clipping_planes_pars_vertex=`#if NUM_CLIPPING_PLANES > 0 683 varying vec3 vClipPosition; 684#endif`,clipping_planes_vertex=`#if NUM_CLIPPING_PLANES > 0 685 vClipPosition = - mvPosition.xyz; 686#endif`,color_fragment=`#if defined( USE_COLOR_ALPHA ) 687 diffuseColor *= vColor; 688#elif defined( USE_COLOR ) 689 diffuseColor.rgb *= vColor; 690#endif`,color_pars_fragment=`#if defined( USE_COLOR_ALPHA ) 691 varying vec4 vColor; 692#elif defined( USE_COLOR ) 693 varying vec3 vColor; 694#endif`,color_pars_vertex=`#if defined( USE_COLOR_ALPHA ) 695 varying vec4 vColor; 696#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 697 varying vec3 vColor; 698#endif`,color_vertex=`#if defined( USE_COLOR_ALPHA ) 699 vColor = vec4( 1.0 ); 700#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 701 vColor = vec3( 1.0 ); 702#endif 703#ifdef USE_COLOR 704 vColor *= color; 705#endif 706#ifdef USE_INSTANCING_COLOR 707 vColor.xyz *= instanceColor.xyz; 708#endif 709#ifdef USE_BATCHING_COLOR 710 vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); 711 vColor.xyz *= batchingColor.xyz; 712#endif`,common=`#define PI 3.141592653589793 713#define PI2 6.283185307179586 714#define PI_HALF 1.5707963267948966 715#define RECIPROCAL_PI 0.3183098861837907 716#define RECIPROCAL_PI2 0.15915494309189535 717#define EPSILON 1e-6 718#ifndef saturate 719#define saturate( a ) clamp( a, 0.0, 1.0 ) 720#endif 721#define whiteComplement( a ) ( 1.0 - saturate( a ) ) 722float pow2( const in float x ) { return x*x; } 723vec3 pow2( const in vec3 x ) { return x*x; } 724float pow3( const in float x ) { return x*x*x; } 725float pow4( const in float x ) { float x2 = x*x; return x2*x2; } 726float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } 727float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } 728highp float rand( const in vec2 uv ) { 729 const highp float a = 12.9898, b = 78.233, c = 43758.5453; 730 highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); 731 return fract( sin( sn ) * c ); 732} 733#ifdef HIGH_PRECISION 734 float precisionSafeLength( vec3 v ) { return length( v ); } 735#else 736 float precisionSafeLength( vec3 v ) { 737 float maxComponent = max3( abs( v ) ); 738 return length( v / maxComponent ) * maxComponent; 739 } 740#endif 741struct IncidentLight { 742 vec3 color; 743 vec3 direction; 744 bool visible; 745}; 746struct ReflectedLight { 747 vec3 directDiffuse; 748 vec3 directSpecular; 749 vec3 indirectDiffuse; 750 vec3 indirectSpecular; 751}; 752#ifdef USE_ALPHAHASH 753 varying vec3 vPosition; 754#endif 755vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 756 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 757} 758vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { 759 return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz
vendor: 5,594 bytes, lines 759-909
759 ); 760} 761bool isPerspectiveMatrix( mat4 m ) { 762 return m[ 2 ][ 3 ] == - 1.0; 763} 764vec2 equirectUv( in vec3 dir ) { 765 float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; 766 float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 767 return vec2( u, v ); 768} 769vec3 BRDF_Lambert( const in vec3 diffuseColor ) { 770 return RECIPROCAL_PI * diffuseColor; 771} 772vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { 773 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 774 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 775} 776float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { 777 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 778 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 779} // validated`,cube_uv_reflection_fragment=`#ifdef ENVMAP_TYPE_CUBE_UV 780 #define cubeUV_minMipLevel 4.0 781 #define cubeUV_minTileSize 16.0 782 float getFace( vec3 direction ) { 783 vec3 absDirection = abs( direction ); 784 float face = - 1.0; 785 if ( absDirection.x > absDirection.z ) { 786 if ( absDirection.x > absDirection.y ) 787 face = direction.x > 0.0 ? 0.0 : 3.0; 788 else 789 face = direction.y > 0.0 ? 1.0 : 4.0; 790 } else { 791 if ( absDirection.z > absDirection.y ) 792 face = direction.z > 0.0 ? 2.0 : 5.0; 793 else 794 face = direction.y > 0.0 ? 1.0 : 4.0; 795 } 796 return face; 797 } 798 vec2 getUV( vec3 direction, float face ) { 799 vec2 uv; 800 if ( face == 0.0 ) { 801 uv = vec2( direction.z, direction.y ) / abs( direction.x ); 802 } else if ( face == 1.0 ) { 803 uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); 804 } else if ( face == 2.0 ) { 805 uv = vec2( - direction.x, direction.y ) / abs( direction.z ); 806 } else if ( face == 3.0 ) { 807 uv = vec2( - direction.z, direction.y ) / abs( direction.x ); 808 } else if ( face == 4.0 ) { 809 uv = vec2( - direction.x, direction.z ) / abs( direction.y ); 810 } else { 811 uv = vec2( direction.x, direction.y ) / abs( direction.z ); 812 } 813 return 0.5 * ( uv + 1.0 ); 814 } 815 vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { 816 float face = getFace( direction ); 817 float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); 818 mipInt = max( mipInt, cubeUV_minMipLevel ); 819 float faceSize = exp2( mipInt ); 820 highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; 821 if ( face > 2.0 ) { 822 uv.y += faceSize; 823 face -= 3.0; 824 } 825 uv.x += face * faceSize; 826 uv.x += filterInt * 3.0 * cubeUV_minTileSize; 827 uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); 828 uv.x *= CUBEUV_TEXEL_WIDTH; 829 uv.y *= CUBEUV_TEXEL_HEIGHT; 830 #ifdef texture2DGradEXT 831 return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; 832 #else 833 return texture2D( envMap, uv ).rgb; 834 #endif 835 } 836 #define cubeUV_r0 1.0 837 #define cubeUV_m0 - 2.0 838 #define cubeUV_r1 0.8 839 #define cubeUV_m1 - 1.0 840 #define cubeUV_r4 0.4 841 #define cubeUV_m4 2.0 842 #define cubeUV_r5 0.305 843 #define cubeUV_m5 3.0 844 #define cubeUV_r6 0.21 845 #define cubeUV_m6 4.0 846 float roughnessToMip( float roughness ) { 847 float mip = 0.0; 848 if ( roughness >= cubeUV_r1 ) { 849 mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; 850 } else if ( roughness >= cubeUV_r4 ) { 851 mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; 852 } else if ( roughness >= cubeUV_r5 ) { 853 mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; 854 } else if ( roughness >= cubeUV_r6 ) { 855 mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; 856 } else { 857 mip = - 2.0 * log2( 1.16 * roughness ); } 858 return mip; 859 } 860 vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { 861 float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); 862 float mipF = fract( mip ); 863 float mipInt = floor( mip ); 864 vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); 865 if ( mipF == 0.0 ) { 866 return vec4( color0, 1.0 ); 867 } else { 868 vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); 869 return vec4( mix( color0, color1, mipF ), 1.0 ); 870 } 871 } 872#endif`,defaultnormal_vertex=`vec3 transformedNormal = objectNormal; 873#ifdef USE_TANGENT 874 vec3 transformedTangent = objectTangent; 875#endif 876#ifdef USE_BATCHING 877 mat3 bm = mat3( batchingMatrix ); 878 transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); 879 transformedNormal = bm * transformedNormal; 880 #ifdef USE_TANGENT 881 transformedTangent = bm * transformedTangent; 882 #endif 883#endif 884#ifdef USE_INSTANCING 885 mat3 im = mat3( instanceMatrix ); 886 transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); 887 transformedNormal = im * transformedNormal; 888 #ifdef USE_TANGENT 889 transformedTangent = im * transformedTangent; 890 #endif 891#endif 892transformedNormal = normalMatrix * transformedNormal; 893#ifdef FLIP_SIDED 894 transformedNormal = - transformedNormal; 895#endif 896#ifdef USE_TANGENT 897 transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; 898 #ifdef FLIP_SIDED 899 transformedTangent = - transformedTangent; 900 #endif 901#endif`,displacementmap_pars_vertex=`#ifdef USE_DISPLACEMENTMAP 902 uniform sampler2D displacementMap; 903 uniform float displacementScale; 904 uniform float displacementBias; 905#endif`,displacementmap_vertex=`#ifdef USE_DISPLACEMENTMAP 906 transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); 907#endif`,emissivemap_fragment=`#ifdef USE_EMISSIVEMAP 908 vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); 909
909#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE 910 emissiveColor = sRGBTransferEOTF( emissiveColor ); 911 #endif 912 totalEmissiveRadiance *= emissiveColor.rgb; 913#endif`,emissivemap_pars_fragment=`#ifdef USE_EMISSIVEMAP 914 uniform sampler2D emissiveMap; 915#endif`,colorspace_fragment="gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment=`vec4 LinearTransferOETF( in vec4 value ) { 916 return value; 917} 918vec4 sRGBTransferEOTF( in vec4 value ) { 919 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 ); 920} 921vec4 sRGBTransferOETF( in vec4 value ) { 922 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 ); 923}`,envmap_fragment=`#ifdef USE_ENVMAP 924 #ifdef ENV_WORLDPOS 925 vec3 cameraToFrag; 926 if ( isOrthographic ) { 927 cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 928 } else { 929 cameraToFrag = normalize( vWorldPosition - cameraPosition ); 930 } 931 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 932 #ifdef ENVMAP_MODE_REFLECTION 933 vec3 reflectVec = reflect( cameraToFrag, worldNormal ); 934 #else 935 vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); 936 #endif 937 #else 938 vec3 reflectVec = vReflect; 939 #endif 940 #ifdef ENVMAP_TYPE_CUBE 941 vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); 942 #else 943 vec4 envColor = vec4( 0.0 ); 944 #endif 945 #ifdef ENVMAP_BLENDING_MULTIPLY 946 outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 947 #elif defined( ENVMAP_BLENDING_MIX ) 948 outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 949 #elif defined( ENVMAP_BLENDING_ADD ) 950 outgoingLight += envColor.xyz * specularStrength * reflectivity; 951 #endif 952#endif`,envmap_common_pars_fragment=`#ifdef USE_ENVMAP 953 uniform float envMapIntensity; 954 uniform float flipEnvMap; 955 uniform mat3 envMapRotation; 956 #ifdef ENVMAP_TYPE_CUBE 957 uniform samplerCube envMap; 958 #else 959 uniform sampler2D envMap; 960 #endif 961#endif`,envmap_pars_fragment=`#ifdef USE_ENVMAP 962 uniform float reflectivity; 963 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 964 #define ENV_WORLDPOS 965 #endif 966 #ifdef ENV_WORLDPOS 967 varying vec3 vWorldPosition; 968 uniform float refractionRatio; 969 #else 970 varying vec3 vReflect; 971 #endif 972#endif`,envmap_pars_vertex=`#ifdef USE_ENVMAP 973 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 974 #define ENV_WORLDPOS 975 #endif 976 #ifdef ENV_WORLDPOS 977 978 varying vec3 vWorldPosition; 979 #else 980 varying vec3 vReflect; 981 uniform float refractionRatio; 982 #endif 983#endif`,envmap_vertex=`#ifdef USE_ENVMAP 984 #ifdef ENV_WORLDPOS 985 vWorldPosition = worldPosition.xyz; 986 #else 987 vec3 cameraToVertex; 988 if ( isOrthographic ) { 989 cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 990 } else {
991 cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 992 } 993 vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 994 #ifdef ENVMAP_MODE_REFLECTION 995 vReflect = reflect( cameraToVertex, worldNormal ); 996 #else 997 vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 998 #endif 999 #endif 1000#endif`,fog_vertex=`#ifdef USE_FOG 1001 vFogDepth = - mvPosition.z; 1002#endif`,fog_pars_vertex=`#ifdef USE_FOG 1003 varying float vFogDepth; 1004#endif`,fog_fragment=`#ifdef USE_FOG 1005 #ifdef FOG_EXP2 1006 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); 1007 #else 1008 float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); 1009 #endif 1010 gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 1011#endif`,fog_pars_fragment=`#ifdef USE_FOG 1012 uniform vec3 fogColor; 1013 varying float vFogDepth; 1014 #ifdef FOG_EXP2 1015 uniform float fogDensity; 1016 #else 1017 uniform float fogNear; 1018 uniform float fogFar; 1019 #endif 1020#endif`,gradientmap_pars_fragment=`#ifdef USE_GRADIENTMAP 1021 uniform sampler2D gradientMap; 1022#endif 1023vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 1024 float dotNL = dot( normal, lightDirection ); 1025 vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 1026 #ifdef USE_GRADIENTMAP 1027 return vec3( texture2D( gradientMap, coord ).r ); 1028 #else 1029 vec2 fw = fwidth( coord ) * 0.5; 1030 return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); 1031 #endif 1032}`,lightmap_pars_fragment=`#ifdef USE_LIGHTMAP 1033 uniform sampler2D lightMap; 1034 uniform float lightMapIntensity; 1035#endif`,lights_lambert_fragment=`LambertMaterial material; 1036material.diffuseColor = diffuseColor.rgb; 1037material.specularStrength = specularStrength;`,lights_lambert_pars_fragment=`varying vec3 vViewPosition; 1038struct LambertMaterial { 1039 vec3 diffuseColor; 1040 float specularStrength; 1041}; 1042void 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 ) { 1043 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1044 vec3 irradiance = dotNL * directLight.color; 1045 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1046} 1047void 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 ) { 1048 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1049} 1050#define RE_Direct RE_Direct_Lambert 1051#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin=`uniform bool receiveShadow; 1052uniform vec3 ambientLightColor; 1053#if defined( USE_LIGHT_PROBES ) 1054 uniform vec3 lightProbe[ 9 ]; 1055#endif 1056vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { 1057 float x = normal.x, y = normal.y, z = normal.z; 1058 vec3 result = shCoefficients[ 0 ] * 0.886227; 1059 result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; 1060 result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; 1061 result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; 1062 result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; 1063 result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; 1064 result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); 1065 result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; 1066 result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); 1067 return result; 1068} 1069vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { 1070 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 1071 vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); 1072 return irradiance; 1073} 1074vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { 1075 vec3 irradiance = ambientLightColor; 1076 return irradiance; 1077} 1078float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { 1079 float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); 1080 if ( cutoffDistance > 0.0 ) { 1081 distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); 1082 } 1083 return distanceFalloff; 1084} 1085float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { 1086 return smoothstep( coneCosine, penumbraCosine, angleCosine ); 1087} 1088#if NUM_DIR_LIGHTS > 0 1089 struct DirectionalLight { 1090 vec3 direction; 1091 vec3 color; 1092 }; 1093 uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; 1094 void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { 1095 light.color = directionalLight.color; 1096 light.direction = directionalLight.direction; 1097 light.visible = true; 1098 } 1099#endif 1100#if NUM_POINT_LIGHTS > 0 1101 struct PointLight { 1102 vec3 position; 1103 vec3 color; 1104 float distance; 1105 float decay; 1106 }; 1107 uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; 1108 void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { 1109 vec3 lVector = pointLight.position - geometryPosition; 1110 light.direction = normalize( lVector ); 1111 float lightDistance = length( lVector ); 1112 light.color = pointLight.color; 1113 light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); 1114 light.visible = ( light.color != vec3( 0.0 ) ); 1115 } 1116#endif
1117#if NUM_SPOT_LIGHTS > 0 1118 struct SpotLight { 1119 vec3 position; 1120 vec3 direction; 1121 vec3 color; 1122 float distance; 1123 float decay; 1124 float coneCos; 1125 float penumbraCos; 1126 }; 1127 uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; 1128 void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { 1129 vec3 lVector = spotLight.position - geometryPosition; 1130 light.direction = normalize( lVector ); 1131 float angleCos = dot( light.direction, spotLight.direction ); 1132 float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); 1133 if ( spotAttenuation > 0.0 ) { 1134 float lightDistance = length( lVector ); 1135 light.color = spotLight.color * spotAttenuation; 1136 light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); 1137 light.visible = ( light.color != vec3( 0.0 ) ); 1138 } else { 1139 light.color = vec3( 0.0 ); 1140 light.visible = false; 1141 } 1142 } 1143#endif 1144#if NUM_RECT_AREA_LIGHTS > 0 1145 struct RectAreaLight { 1146 vec3 color; 1147 vec3 position; 1148 vec3 halfWidth; 1149 vec3 halfHeight; 1150 }; 1151 uniform sampler2D ltc_1; uniform sampler2D ltc_2; 1152 uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; 1153#endif 1154#if NUM_HEMI_LIGHTS > 0 1155 struct HemisphereLight { 1156 vec3 direction; 1157 vec3 skyColor; 1158 vec3 groundColor; 1159 }; 1160 uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; 1161 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { 1162 float dotNL = dot( normal, hemiLight.direction ); 1163 float hemiDiffuseWeight = 0.5 * dotNL + 0.5; 1164 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); 1165 return irradiance; 1166 } 1167#endif`,envmap_physical_pars_fragment=`#ifdef USE_ENVMAP 1168 vec3 getIBLIrradiance( const in vec3 normal ) { 1169 #ifdef ENVMAP_TYPE_CUBE_UV 1170 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 1171 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); 1172 return PI * envMapColor.rgb * envMapIntensity; 1173 #else 1174 return vec3( 0.0 ); 1175 #endif 1176 } 1177 vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { 1178 #ifdef ENVMAP_TYPE_CUBE_UV 1179 vec3 reflectVec = reflect( - viewDir, normal ); 1180 reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); 1181 reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); 1182 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); 1183 return envMapColor.rgb * envMapIntensity; 1184 #else 1185 return vec3( 0.0 ); 1186 #endif 1187 } 1188 #ifdef USE_ANISOTROPY 1189 vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { 1190 #ifdef ENVMAP_TYPE_CUBE_UV 1191 vec3 bentNormal = cross( bitangent, viewDir ); 1192 bentNormal = normalize( cross( bentNormal, bitangent ) ); 1193 bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); 1194 return getIBLRadiance( viewDir, bentNormal, roughness ); 1195 #else 1196 return vec3( 0.0 ); 1197 #endif 1198 } 1199 #endif 1200#endif`,lights_toon_fragment=`ToonMaterial material; 1201material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment=`varying vec3 vViewPosition; 1202struct ToonMaterial { 1203 vec3 diffuseColor; 1204}; 1205void 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 ) { 1206 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; 1207 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1208} 1209void 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 ) { 1210 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1211} 1212#define RE_Direct RE_Direct_Toon 1213#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment=`BlinnPhongMaterial material; 1214material.diffuseColor = diffuseColor.rgb; 1215material.specularColor = specular; 1216material.specularShininess = shininess; 1217material.specularStrength = specularStrength;`,lights_phong_pars_fragment=`varying vec3 vViewPosition; 1218struct BlinnPhongMaterial { 1219 vec3 diffuseColor; 1220 vec3 specularColor; 1221 float specularShininess; 1222 float specularStrength; 1223}; 1224void 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 ) {
1225 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1226 vec3 irradiance = dotNL * directLight.color; 1227 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1228 reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; 1229} 1230void 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 ) { 1231 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1232} 1233#define RE_Direct RE_Direct_BlinnPhong 1234#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment=`PhysicalMaterial material; 1235material.diffuseColor = diffuseColor.rgb; 1236material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); 1237material.metalness = metalnessFactor; 1238vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); 1239float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); 1240material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; 1241material.roughness = min( material.roughness, 1.0 ); 1242#ifdef IOR 1243 material.ior = ior; 1244 #ifdef USE_SPECULAR 1245 float specularIntensityFactor = specularIntensity; 1246 vec3 specularColorFactor = specularColor; 1247 #ifdef USE_SPECULAR_COLORMAP 1248 specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; 1249 #endif 1250 #ifdef USE_SPECULAR_INTENSITYMAP 1251 specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; 1252 #endif 1253 material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); 1254 #else 1255 float specularIntensityFactor = 1.0; 1256 vec3 specularColorFactor = vec3( 1.0 ); 1257 material.specularF90 = 1.0; 1258 #endif 1259 material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; 1260 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 1261#else 1262 material.specularColor = vec3( 0.04 ); 1263 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 1264 material.specularF90 = 1.0; 1265#endif 1266#ifdef USE_CLEARCOAT 1267 material.clearcoat = clearcoat; 1268 material.clearcoatRoughness = clearcoatRoughness; 1269 material.clearcoatF0 = vec3( 0.04 ); 1270 material.clearcoatF90 = 1.0; 1271 #ifdef USE_CLEARCOATMAP 1272 material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; 1273 #endif 1274 #ifdef USE_CLEARCOAT_ROUGHNESSMAP 1275 material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; 1276 #endif 1277 material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); 1278 material.clearcoatRoughness += geometryRoughness; 1279 material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); 1280#endif 1281#ifdef USE_DISPERSION 1282 material.dispersion = dispersion; 1283#endif 1284#ifdef USE_IRIDESCENCE 1285 material.iridescence = iridescence; 1286 material.iridescenceIOR = iridescenceIOR; 1287 #ifdef USE_IRIDESCENCEMAP 1288 material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; 1289 #endif 1290 #ifdef USE_IRIDESCENCE_THICKNESSMAP 1291 material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; 1292 #else 1293 material.iridescenceThickness = iridescenceThicknessMaximum; 1294 #endif 1295#endif 1296#ifdef USE_SHEEN 1297 material.sheenColor = sheenColor; 1298 #ifdef USE_SHEEN_COLORMAP 1299 material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; 1300 #endif 1301 material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); 1302 #ifdef USE_SHEEN_ROUGHNESSMAP 1303 material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; 1304 #endif 1305#endif 1306#ifdef USE_ANISOTROPY 1307 #ifdef USE_ANISOTROPYMAP 1308 mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); 1309 vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; 1310 vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; 1311 #else 1312 vec2 anisotropyV = anisotropyVector; 1313 #endif 1314 material.anisotropy = length( anisotropyV ); 1315 if( material.anisotropy == 0.0 ) { 1316 anisotropyV = vec2( 1.0, 0.0 ); 1317 } else { 1318 anisotropyV /= material.anisotropy; 1319 material.anisotropy = saturate( material.anisotropy ); 1320 } 1321 material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1322 material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; 1323 material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; 1324#endif`,lights_physical_pars_fragment
vendor: 17,312 bytes, lines 1324-1672
1324=`uniform sampler2D dfgLUT; 1325struct PhysicalMaterial { 1326 vec3 diffuseColor; 1327 vec3 diffuseContribution; 1328 vec3 specularColor; 1329 vec3 specularColorBlended; 1330 float roughness; 1331 float metalness; 1332 float specularF90; 1333 float dispersion; 1334 #ifdef USE_CLEARCOAT 1335 float clearcoat; 1336 float clearcoatRoughness; 1337 vec3 clearcoatF0; 1338 float clearcoatF90; 1339 #endif 1340 #ifdef USE_IRIDESCENCE 1341 float iridescence; 1342 float iridescenceIOR; 1343 float iridescenceThickness; 1344 vec3 iridescenceFresnel; 1345 vec3 iridescenceF0; 1346 vec3 iridescenceFresnelDielectric; 1347 vec3 iridescenceFresnelMetallic; 1348 #endif 1349 #ifdef USE_SHEEN 1350 vec3 sheenColor; 1351 float sheenRoughness; 1352 #endif 1353 #ifdef IOR 1354 float ior; 1355 #endif 1356 #ifdef USE_TRANSMISSION 1357 float transmission; 1358 float transmissionAlpha; 1359 float thickness; 1360 float attenuationDistance; 1361 vec3 attenuationColor; 1362 #endif 1363 #ifdef USE_ANISOTROPY 1364 float anisotropy; 1365 float alphaT; 1366 vec3 anisotropyT; 1367 vec3 anisotropyB; 1368 #endif 1369}; 1370vec3 clearcoatSpecularDirect = vec3( 0.0 ); 1371vec3 clearcoatSpecularIndirect = vec3( 0.0 ); 1372vec3 sheenSpecularDirect = vec3( 0.0 ); 1373vec3 sheenSpecularIndirect = vec3(0.0 ); 1374vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { 1375 float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); 1376 float x2 = x * x; 1377 float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); 1378 return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); 1379} 1380float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { 1381 float a2 = pow2( alpha ); 1382 float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); 1383 float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); 1384 return 0.5 / max( gv + gl, EPSILON ); 1385} 1386float D_GGX( const in float alpha, const in float dotNH ) { 1387 float a2 = pow2( alpha ); 1388 float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; 1389 return RECIPROCAL_PI * a2 / pow2( denom ); 1390} 1391#ifdef USE_ANISOTROPY 1392 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 ) { 1393 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); 1394 float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); 1395 float v = 0.5 / ( gv + gl ); 1396 return v; 1397 } 1398 float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { 1399 float a2 = alphaT * alphaB; 1400 highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); 1401 highp float v2 = dot( v, v ); 1402 float w2 = a2 / v2; 1403 return RECIPROCAL_PI * a2 * pow2 ( w2 ); 1404 } 1405#endif 1406#ifdef USE_CLEARCOAT 1407 vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { 1408 vec3 f0 = material.clearcoatF0; 1409 float f90 = material.clearcoatF90; 1410 float roughness = material.clearcoatRoughness; 1411 float alpha = pow2( roughness ); 1412 vec3 halfDir = normalize( lightDir + viewDir ); 1413 float dotNL = saturate( dot( normal, lightDir ) ); 1414 float dotNV = saturate( dot( normal, viewDir ) ); 1415 float dotNH = saturate( dot( normal, halfDir ) ); 1416 float dotVH = saturate( dot( viewDir, halfDir ) ); 1417 vec3 F = F_Schlick( f0, f90, dotVH ); 1418 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1419 float D = D_GGX( alpha, dotNH ); 1420 return F * ( V * D ); 1421 } 1422#endif 1423vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1424 vec3 f0 = material.specularColorBlended; 1425 float f90 = material.specularF90; 1426 float roughness = material.roughness; 1427 float alpha = pow2( roughness ); 1428 vec3 halfDir = normalize( lightDir + viewDir ); 1429 float dotNL = saturate( dot( normal, lightDir ) ); 1430 float dotNV = saturate( dot( normal, viewDir ) ); 1431 float dotNH = saturate( dot( normal, halfDir ) ); 1432 float dotVH = saturate( dot( viewDir, halfDir ) ); 1433 vec3 F = F_Schlick( f0, f90, dotVH ); 1434 #ifdef USE_IRIDESCENCE 1435 F = mix( F, material.iridescenceFresnel, material.iridescence ); 1436 #endif 1437 #ifdef USE_ANISOTROPY 1438 float dotTL = dot( material.anisotropyT, lightDir ); 1439 float dotTV = dot( material.anisotropyT, viewDir ); 1440 float dotTH = dot( material.anisotropyT, halfDir ); 1441 float dotBL = dot( material.anisotropyB, lightDir ); 1442 float dotBV = dot( material.anisotropyB, viewDir ); 1443 float dotBH = dot( material.anisotropyB, halfDir ); 1444 float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); 1445 float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); 1446 #else 1447 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1448 float D = D_GGX( alpha, dotNH ); 1449 #endif 1450 return F * ( V * D ); 1451} 1452vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { 1453 const float LUT_SIZE = 64.0; 1454 const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; 1455 const float LUT_BIAS = 0.5 / LUT_SIZE; 1456 float dotNV = saturate( dot( N, V ) ); 1457 vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); 1458 uv = uv * LUT_SCALE + LUT_BIAS; 1459 return uv; 1460} 1461float LTC_ClippedSphereFormFactor( const in vec3 f ) { 1462 float l = length( f ); 1463 return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); 1464} 1465vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { 1466 float x = dot( v1, v2 ); 1467 float y = abs( x ); 1468 float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; 1469 float b = 3.4175940 + ( 4.1616724 + y ) * y; 1470 float v = a / b; 1471 float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; 1472 return cross( v1, v2 ) * theta_sintheta; 1473} 1474vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { 1475 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; 1476 vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; 1477 vec3 lightNormal = cross( v1, v2 ); 1478 if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); 1479 vec3 T1, T2; 1480 T1 = normalize( V - N * dot( V, N ) ); 1481 T2 = - cross( N, T1 ); 1482 mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); 1483 vec3 coords[ 4 ]; 1484 coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); 1485 coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); 1486 coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); 1487 coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); 1488 coords[ 0 ] = normalize( coords[ 0 ] ); 1489 coords[ 1 ] = normalize( coords[ 1 ] ); 1490 coords[ 2 ] = normalize( coords[ 2 ] ); 1491 coords[ 3 ] = normalize( coords[ 3 ] ); 1492 vec3 vectorFormFactor = vec3( 0.0 ); 1493 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); 1494 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); 1495 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); 1496 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); 1497 float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); 1498 return vec3( result ); 1499} 1500#if defined( USE_SHEEN ) 1501float D_Charlie( float roughness, float dotNH ) { 1502 float alpha = pow2( roughness ); 1503 float invAlpha = 1.0 / alpha; 1504 float cos2h = dotNH * dotNH; 1505 float sin2h = max( 1.0 - cos2h, 0.0078125 ); 1506 return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); 1507} 1508float V_Neubelt( float dotNV, float dotNL ) { 1509 return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); 1510} 1511vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { 1512 vec3 halfDir = normalize( lightDir + viewDir ); 1513 float dotNL = saturate( dot( normal, lightDir ) ); 1514 float dotNV = saturate( dot( normal, viewDir ) ); 1515 float dotNH = saturate( dot( normal, halfDir ) ); 1516 float D = D_Charlie( sheenRoughness, dotNH ); 1517 float V = V_Neubelt( dotNV, dotNL ); 1518 return sheenColor * ( D * V ); 1519} 1520#endif 1521float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { 1522 float dotNV = saturate( dot( normal, viewDir ) ); 1523 float r2 = roughness * roughness; 1524 float rInv = 1.0 / ( roughness + 0.1 ); 1525 float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; 1526 float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; 1527 float DG = exp( a * dotNV + b ); 1528 return saturate( DG ); 1529} 1530vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { 1531 float dotNV = saturate( dot( normal, viewDir ) ); 1532 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1533 return specularColor * fab.x + specularF90 * fab.y; 1534} 1535#ifdef USE_IRIDESCENCE 1536void 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 ) { 1537#else 1538void 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 ) { 1539#endif 1540 float dotNV = saturate( dot( normal, viewDir ) ); 1541 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1542 #ifdef USE_IRIDESCENCE 1543 vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); 1544 #else 1545 vec3 Fr = specularColor; 1546 #endif 1547 vec3 FssEss = Fr * fab.x + specularF90 * fab.y; 1548 float Ess = fab.x + fab.y; 1549 float Ems = 1.0 - Ess; 1550 vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); 1551 singleScatter += FssEss; 1552 multiScatter += Fms * Ems; 1553} 1554vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1555 vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); 1556 float dotNL = saturate( dot( normal, lightDir ) ); 1557 float dotNV = saturate( dot( normal, viewDir ) ); 1558 vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; 1559 vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; 1560 vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; 1561 vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; 1562 float Ess_V = dfgV.x + dfgV.y; 1563 float Ess_L = dfgL.x + dfgL.y; 1564 float Ems_V = 1.0 - Ess_V; 1565 float Ems_L = 1.0 - Ess_L; 1566 vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; 1567 vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); 1568 float compensationFactor = Ems_V * Ems_L; 1569 vec3 multiScatter = Fms * compensationFactor; 1570 return singleScatter + multiScatter; 1571} 1572#if NUM_RECT_AREA_LIGHTS > 0 1573 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 ) { 1574 vec3 normal = geometryNormal; 1575 vec3 viewDir = geometryViewDir; 1576 vec3 position = geometryPosition; 1577 vec3 lightPos = rectAreaLight.position; 1578 vec3 halfWidth = rectAreaLight.halfWidth; 1579 vec3 halfHeight = rectAreaLight.halfHeight; 1580 vec3 lightColor = rectAreaLight.color; 1581 float roughness = material.roughness; 1582 vec3 rectCoords[ 4 ]; 1583 rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; 1584 rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; 1585 rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; 1586 vec2 uv = LTC_Uv( normal, viewDir, roughness ); 1587 vec4 t1 = texture2D( ltc_1, uv ); 1588 vec4 t2 = texture2D( ltc_2, uv ); 1589 mat3 mInv = mat3( 1590 vec3( t1.x, 0, t1.y ), 1591 vec3( 0, 1, 0 ), 1592 vec3( t1.z, 0, t1.w ) 1593 ); 1594 vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y ); 1595 reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); 1596 reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); 1597 } 1598#endif 1599void 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 ) { 1600 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1601 vec3 irradiance = dotNL * directLight.color; 1602 #ifdef USE_CLEARCOAT 1603 float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); 1604 vec3 ccIrradiance = dotNLcc * directLight.color; 1605 clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); 1606 #endif 1607 #ifdef USE_SHEEN 1608 1609 sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); 1610 1611 float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1612 float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); 1613 1614 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); 1615 1616 irradiance *= sheenEnergyComp; 1617 1618 #endif 1619 reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); 1620 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); 1621} 1622void 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 ) { 1623 vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); 1624 #ifdef USE_SHEEN 1625 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1626 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1627 diffuse *= sheenEnergyComp; 1628 #endif 1629 reflectedLight.indirectDiffuse += diffuse; 1630} 1631void 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) { 1632 #ifdef USE_CLEARCOAT 1633 clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); 1634 #endif 1635 #ifdef USE_SHEEN 1636 sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; 1637 #endif 1638 vec3 singleScatteringDielectric = vec3( 0.0 ); 1639 vec3 multiScatteringDielectric = vec3( 0.0 ); 1640 vec3 singleScatteringMetallic = vec3( 0.0 ); 1641 vec3 multiScatteringMetallic = vec3( 0.0 ); 1642 #ifdef USE_IRIDESCENCE 1643 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1644 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1645 #else 1646 computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1647 computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1648 #endif 1649 vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); 1650 vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); 1651 vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; 1652 vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); 1653 vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; 1654 vec3 indirectSpecular = radiance * singleScattering; 1655 indirectSpecular += multiScattering * cosineWeightedIrradiance; 1656 vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; 1657 #ifdef USE_SHEEN 1658 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1659 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1660 indirectSpecular *= sheenEnergyComp; 1661 indirectDiffuse *= sheenEnergyComp; 1662 #endif 1663 reflectedLight.indirectSpecular += indirectSpecular; 1664 reflectedLight.indirectDiffuse += indirectDiffuse; 1665} 1666#define RE_Direct RE_Direct_Physical 1667#define RE_Direct_RectArea RE_Direct_RectArea_Physical 1668#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical 1669#define RE_IndirectSpecular RE_IndirectSpecular_Physical 1670float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { 1671 return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); 1672}`,
1672lights_fragment_begin=` 1673vec3 geometryPosition = - vViewPosition; 1674vec3 geometryNormal = normal; 1675vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); 1676vec3 geometryClearcoatNormal = vec3( 0.0 ); 1677#ifdef USE_CLEARCOAT 1678 geometryClearcoatNormal = clearcoatNormal; 1679#endif 1680#ifdef USE_IRIDESCENCE 1681 float dotNVi = saturate( dot( normal, geometryViewDir ) ); 1682 if ( material.iridescenceThickness == 0.0 ) { 1683 material.iridescence = 0.0; 1684 } else { 1685 material.iridescence = saturate( material.iridescence ); 1686 } 1687 if ( material.iridescence > 0.0 ) { 1688 material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); 1689 material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); 1690 material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); 1691 material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); 1692 } 1693#endif 1694IncidentLight directLight; 1695#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) 1696 PointLight pointLight; 1697 #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 1698 PointLightShadow pointLightShadow; 1699 #endif 1700 #pragma unroll_loop_start 1701 for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 1702 pointLight = pointLights[ i ]; 1703 getPointLightInfo( pointLight, geometryPosition, directLight ); 1704 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 1705 pointLightShadow = pointLightShadows[ i ]; 1706 directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; 1707 #endif 1708 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1709 } 1710 #pragma unroll_loop_end 1711#endif 1712#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) 1713 SpotLight spotLight; 1714 vec4 spotColor; 1715 vec3 spotLightCoord; 1716 bool inSpotLightMap; 1717 #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 1718 SpotLightShadow spotLightShadow; 1719 #endif 1720 #pragma unroll_loop_start 1721 for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 1722 spotLight = spotLights[ i ]; 1723 getSpotLightInfo( spotLight, geometryPosition, directLight ); 1724 #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1725 #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX 1726 #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1727 #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS 1728 #else 1729 #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1730 #endif 1731 #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) 1732 spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; 1733 inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); 1734 spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); 1735 directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; 1736 #endif 1737 #undef SPOT_LIGHT_MAP_INDEX 1738 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1739 spotLightShadow = spotLightShadows[ i ]; 1740 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 1741 #endif 1742 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1743 } 1744 #pragma unroll_loop_end 1745#endif 1746#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) 1747 DirectionalLight directionalLight; 1748 #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 1749 DirectionalLightShadow directionalLightShadow; 1750 #endif 1751 #pragma unroll_loop_start 1752 for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 1753 directionalLight = directionalLights[ i ]; 1754 getDirectionalLightInfo( directionalLight, directLight ); 1755 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) 1756 directionalLightShadow = directionalLightShadows[ i ]; 1757 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1758 #endif 1759 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1760 } 1761 #pragma unroll_loop_end 1762#endif 1763#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) 1764 RectAreaLight rectAreaLight; 1765 #pragma unroll_loop_start 1766 for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { 1767 rectAreaLight = rectAreaLights[ i ]; 1768 RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1769 } 1770 #pragma unroll_loop_end 1771#endif 1772#if defined( RE_IndirectDiffuse ) 1773 vec3 iblIrradiance = vec3( 0.0 ); 1774 vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); 1775 #if defined( USE_LIGHT_PROBES ) 1776 irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); 1777 #endif 1778 #if ( NUM_HEMI_LIGHTS > 0 ) 1779 #pragma unroll_loop_start 1780 for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { 1781 irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); 1782 } 1783 #pragma unroll_loop_end 1784 #endif 1785#endif 1786#if defined( RE_IndirectSpecular ) 1787 vec3 radiance = vec3( 0.0 ); 1788 vec3 clearcoatRadiance = vec3( 0.0 ); 1789#endif`,lights_fragment_maps=`#if defined( RE_IndirectDiffuse ) 1790 #ifdef USE_LIGHTMAP 1791 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 1792 vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 1793 irradiance += lightMapIrradiance; 1794 #endif 1795 #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) 1796 iblIrradiance += getIBLIrradiance( geometryNormal ); 1797 #endif 1798#endif 1799#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 1800 #ifdef USE_ANISOTROPY 1801 radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); 1802 #else 1803 radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); 1804 #endif 1805 #ifdef USE_CLEARCOAT 1806 clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); 1807 #endif 1808#endif`,lights_fragment_end=`#if defined( RE_IndirectDiffuse ) 1809 RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1810#endif 1811#if defined( RE_IndirectSpecular ) 1812 RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1813#endif`,logdepthbuf_fragment=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1814 gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; 1815#endif`,logdepthbuf_pars_fragment=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1816 uniform float logDepthBufFC; 1817 varying float vFragDepth; 1818 varying float vIsPerspective; 1819#endif`,logdepthbuf_pars_vertex=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1820 varying float vFragDepth; 1821 varying float vIsPerspective; 1822#endif`,logdepthbuf_vertex=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1823 vFragDepth = 1.0 + gl_Position.w; 1824 vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); 1825#endif`,map_fragment=`#ifdef USE_MAP 1826 vec4 sampledDiffuseColor = texture2D( map, vMapUv ); 1827 #ifdef DECODE_VIDEO_TEXTURE 1828 sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); 1829 #endif 1830 diffuseColor *= sampledDiffuseColor; 1831#endif`,map_pars_fragment=`#ifdef USE_MAP 1832 uniform sampler2D map; 1833#endif`,map_particle_fragment=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1834 #if defined( USE_POINTS_UV ) 1835 vec2 uv = vUv; 1836 #else 1837 vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 1838 #endif 1839#endif 1840#ifdef USE_MAP 1841 diffuseColor *= texture2D( map, uv ); 1842#endif 1843#ifdef USE_ALPHAMAP 1844 diffuseColor.a *= texture2D( alphaMap, uv ).g; 1845#endif`,map_particle_pars_fragment=`#if defined( USE_POINTS_UV ) 1846 varying vec2 vUv; 1847#else 1848 #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1849 uniform mat3 uvTransform; 1850 #endif 1851#endif 1852#ifdef USE_MAP 1853 uniform sampler2D map; 1854#endif 1855#ifdef USE_ALPHAMAP 1856 uniform sampler2D alphaMap; 1857#endif`,metalnessmap_fragment=`float metalnessFactor = metalness; 1858#ifdef USE_METALNESSMAP 1859 vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); 1860 metalnessFactor *= texelMetalness.b; 1861#endif`,metalnessmap_pars_fragment=`#ifdef USE_METALNESSMAP 1862 uniform sampler2D metalnessMap; 1863#endif`,morphinstance_vertex=`#ifdef USE_INSTANCING_MORPH 1864 float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1865 float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; 1866 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1867 morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; 1868 } 1869#endif`,morphcolor_vertex=`#if defined( USE_MORPHCOLORS ) 1870 vColor *= morphTargetBaseInfluence; 1871 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1872 #if defined( USE_COLOR_ALPHA ) 1873 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; 1874 #elif defined( USE_COLOR ) 1875 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; 1876 #endif 1877 } 1878#endif`,morphnormal_vertex=`#ifdef USE_MORPHNORMALS 1879 objectNormal *= morphTargetBaseInfluence; 1880 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1881 if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; 1882 } 1883#endif`,morphtarget_pars_vertex=`#ifdef USE_MORPHTARGETS 1884 #ifndef USE_INSTANCING_MORPH 1885 uniform float morphTargetBaseInfluence; 1886 uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1887 #endif 1888 uniform sampler2DArray morphTargetsTexture; 1889 uniform ivec2 morphTargetsTextureSize; 1890 vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { 1891 int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; 1892 int y = texelIndex / morphTargetsTextureSize.x; 1893 int x = texelIndex - y * morphTargetsTextureSize.x; 1894 ivec3 morphUV = ivec3( x, y, morphTargetIndex ); 1895 return texelFetch( morphTargetsTexture, morphUV, 0 ); 1896 } 1897#endif`,morphtarget_vertex=`#ifdef USE_MORPHTARGETS 1898 transformed *= morphTargetBaseInfluence; 1899 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1900 if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; 1901 } 1902#endif`,normal_fragment_begin=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; 1903#ifdef FLAT_SHADED 1904 vec3 fdx = dFdx( vViewPosition ); 1905 vec3 fdy = dFdy( vViewPosition ); 1906 vec3 normal = normalize( cross( fdx, fdy ) ); 1907#else 1908 vec3 normal = normalize( vNormal ); 1909 #ifdef DOUBLE_SIDED 1910 normal *= faceDirection; 1911 #endif 1912#endif 1913#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) 1914 #ifdef USE_TANGENT 1915 mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1916 #else 1917 mat3 tbn = getTangentFrame( - vViewPosition, normal, 1918 #if defined( USE_NORMALMAP ) 1919 vNormalMapUv 1920 #elif defined( USE_CLEARCOAT_NORMALMAP ) 1921 vClearcoatNormalMapUv 1922 #else 1923 vUv 1924 #endif 1925 ); 1926 #endif 1927 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1928 tbn[0] *= faceDirection; 1929 tbn[1] *= faceDirection; 1930 #endif 1931#endif 1932#ifdef USE_CLEARCOAT_NORMALMAP 1933 #ifdef USE_TANGENT 1934 mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1935 #else 1936 mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); 1937 #endif 1938 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1939 tbn2[0] *= faceDirection; 1940 tbn2[1] *= faceDirection; 1941 #endif 1942#endif 1943vec3 nonPerturbedNormal = normal;`,normal_fragment_maps=`#ifdef USE_NORMALMAP_OBJECTSPACE 1944 normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1945 #ifdef FLIP_SIDED 1946 normal = - normal; 1947 #endif 1948 #ifdef DOUBLE_SIDED 1949 normal = normal * faceDirection; 1950 #endif 1951 normal = normalize( normalMatrix * normal ); 1952#elif defined( USE_NORMALMAP_TANGENTSPACE ) 1953 vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1954 mapN.xy *= normalScale; 1955 normal = normalize( tbn * mapN ); 1956#elif defined( USE_BUMPMAP )
1957 normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); 1958#endif`,normal_pars_fragment=`#ifndef FLAT_SHADED 1959 varying vec3 vNormal; 1960 #ifdef USE_TANGENT 1961 varying vec3 vTangent; 1962 varying vec3 vBitangent; 1963 #endif 1964#endif`,normal_pars_vertex=`#ifndef FLAT_SHADED 1965 varying vec3 vNormal; 1966 #ifdef USE_TANGENT 1967 varying vec3 vTangent; 1968 varying vec3 vBitangent; 1969 #endif 1970#endif`,normal_vertex=`#ifndef FLAT_SHADED 1971 vNormal = normalize( transformedNormal ); 1972 #ifdef USE_TANGENT 1973 vTangent = normalize( transformedTangent ); 1974 vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); 1975 #endif 1976#endif`,normalmap_pars_fragment=`#ifdef USE_NORMALMAP 1977 uniform sampler2D normalMap; 1978 uniform vec2 normalScale; 1979#endif 1980#ifdef USE_NORMALMAP_OBJECTSPACE 1981 uniform mat3 normalMatrix; 1982#endif 1983#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) 1984 mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { 1985 vec3 q0 = dFdx( eye_pos.xyz ); 1986 vec3 q1 = dFdy( eye_pos.xyz ); 1987 vec2 st0 = dFdx( uv.st ); 1988 vec2 st1 = dFdy( uv.st ); 1989 vec3 N = surf_norm; 1990 vec3 q1perp = cross( q1, N ); 1991 vec3 q0perp = cross( N, q0 ); 1992 vec3 T = q1perp * st0.x + q0perp * st1.x; 1993 vec3 B = q1perp * st0.y + q0perp * st1.y; 1994 float det = max( dot( T, T ), dot( B, B ) ); 1995 float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); 1996 return mat3( T * scale, B * scale, N ); 1997 } 1998#endif`,clearcoat_normal_fragment_begin=`#ifdef USE_CLEARCOAT 1999 vec3 clearcoatNormal = nonPerturbedNormal; 2000#endif`,clearcoat_normal_fragment_maps=`#ifdef USE_CLEARCOAT_NORMALMAP 2001 vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; 2002 clearcoatMapN.xy *= clearcoatNormalScale; 2003 clearcoatNormal = normalize( tbn2 * clearcoatMapN ); 2004#endif`,clearcoat_pars_fragment=`#ifdef USE_CLEARCOATMAP 2005 uniform sampler2D clearcoatMap; 2006#endif 2007#ifdef USE_CLEARCOAT_NORMALMAP 2008 uniform sampler2D clearcoatNormalMap; 2009 uniform vec2 clearcoatNormalScale; 2010#endif 2011#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2012 uniform sampler2D clearcoatRoughnessMap; 2013#endif`,iridescence_pars_fragment=`#ifdef USE_IRIDESCENCEMAP 2014 uniform sampler2D iridescenceMap; 2015#endif 2016#ifdef USE_IRIDESCENCE_THICKNESSMAP 2017 uniform sampler2D iridescenceThicknessMap; 2018#endif`,opaque_fragment=`#ifdef OPAQUE 2019diffuseColor.a = 1.0; 2020#endif 2021#ifdef USE_TRANSMISSION 2022diffuseColor.a *= material.transmissionAlpha; 2023#endif 2024gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing=`vec3 packNormalToRGB( const in vec3 normal ) { 2025 return normalize( normal ) * 0.5 + 0.5; 2026} 2027vec3 unpackRGBToNormal( const in vec3 rgb ) { 2028 return 2.0 * rgb.xyz - 1.0; 2029} 2030const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; 2031const float Inv255 = 1. / 255.; 2032const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); 2033const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); 2034const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); 2035const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); 2036vec4 packDepthToRGBA( const in float v ) { 2037 if( v <= 0.0 ) 2038 return vec4( 0., 0., 0., 0. ); 2039 if( v >= 1.0 ) 2040 return vec4( 1., 1., 1., 1. ); 2041 float vuf; 2042 float af = modf( v * PackFactors.a, vuf ); 2043 float bf = modf( vuf * ShiftRight8, vuf ); 2044 float gf = modf( vuf * ShiftRight8, vuf ); 2045 return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); 2046} 2047vec3 packDepthToRGB( const in float v ) { 2048 if( v <= 0.0 ) 2049 return vec3( 0., 0., 0. ); 2050 if( v >= 1.0 ) 2051 return vec3( 1., 1., 1. ); 2052 float vuf; 2053 float bf = modf( v * PackFactors.b, vuf ); 2054 float gf = modf( vuf * ShiftRight8, vuf ); 2055 return vec3( vuf * Inv255, gf * PackUpscale, bf ); 2056} 2057vec2 packDepthToRG( const in float v ) { 2058 if( v <= 0.0 ) 2059 return vec2( 0., 0. ); 2060 if( v >= 1.0 ) 2061 return vec2( 1., 1. ); 2062 float vuf; 2063 float gf = modf( v * 256., vuf ); 2064 return vec2( vuf * Inv255, gf ); 2065} 2066float unpackRGBAToDepth( const in vec4 v ) { 2067 return dot( v, UnpackFactors4 ); 2068} 2069float unpackRGBToDepth( const in vec3 v ) { 2070 return dot( v, UnpackFactors3 ); 2071} 2072float unpackRGToDepth( const in vec2 v ) { 2073 return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; 2074} 2075vec4 pack2HalfToRGBA( const in vec2 v ) {
2076 vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); 2077 return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); 2078} 2079vec2 unpackRGBATo2Half( const in vec4 v ) { 2080 return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); 2081} 2082float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { 2083 return ( viewZ + near ) / ( near - far ); 2084} 2085float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { 2086 return depth * ( near - far ) - near; 2087} 2088float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { 2089 return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); 2090} 2091float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { 2092 return ( near * far ) / ( ( far - near ) * depth - far ); 2093}`,premultiplied_alpha_fragment=`#ifdef PREMULTIPLIED_ALPHA 2094 gl_FragColor.rgb *= gl_FragColor.a; 2095#endif`,project_vertex=`vec4 mvPosition = vec4( transformed, 1.0 ); 2096#ifdef USE_BATCHING 2097 mvPosition = batchingMatrix * mvPosition; 2098#endif 2099#ifdef USE_INSTANCING 2100 mvPosition = instanceMatrix * mvPosition; 2101#endif 2102mvPosition = modelViewMatrix * mvPosition; 2103gl_Position = projectionMatrix * mvPosition;`,dithering_fragment=`#ifdef DITHERING 2104 gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 2105#endif`,dithering_pars_fragment=`#ifdef DITHERING 2106 vec3 dithering( vec3 color ) { 2107 float grid_position = rand( gl_FragCoord.xy ); 2108 vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 2109 dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 2110 return color + dither_shift_RGB; 2111 } 2112#endif`,roughnessmap_fragment=`float roughnessFactor = roughness; 2113#ifdef USE_ROUGHNESSMAP 2114 vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); 2115 roughnessFactor *= texelRoughness.g; 2116#endif`,roughnessmap_pars_fragment=`#ifdef USE_ROUGHNESSMAP 2117 uniform sampler2D roughnessMap; 2118#endif`,shadowmap_pars_fragment=`#if NUM_SPOT_LIGHT_COORDS > 0 2119 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 2120#endif 2121#if NUM_SPOT_LIGHT_MAPS > 0 2122 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; 2123#endif 2124#ifdef USE_SHADOWMAP 2125 #if NUM_DIR_LIGHT_SHADOWS > 0 2126 #if defined( SHADOWMAP_TYPE_PCF ) 2127 uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 2128 #else 2129 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 2130 #endif 2131 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 2132 struct DirectionalLightShadow { 2133 float shadowIntensity; 2134 float shadowBias; 2135 float shadowNormalBias; 2136 float shadowRadius; 2137 vec2 shadowMapSize; 2138 }; 2139 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 2140 #endif 2141 #if NUM_SPOT_LIGHT_SHADOWS > 0 2142 #if defined( SHADOWMAP_TYPE_PCF ) 2143 uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 2144 #else 2145 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 2146 #endif 2147 struct SpotLightShadow { 2148 float shadowIntensity; 2149 float shadowBias; 2150 float shadowNormalBias; 2151 float shadowRadius; 2152 vec2 shadowMapSize; 2153 }; 2154 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 2155 #endif 2156 #if NUM_POINT_LIGHT_SHADOWS > 0 2157 #if defined( SHADOWMAP_TYPE_PCF ) 2158 uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 2159 #elif defined( SHADOWMAP_TYPE_BASIC ) 2160 uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 2161 #endif 2162 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 2163 struct PointLightShadow { 2164 float shadowIntensity; 2165 float shadowBias; 2166 float shadowNormalBias; 2167 float shadowRadius; 2168 vec2 shadowMapSize; 2169 float shadowCameraNear; 2170 float shadowCameraFar; 2171 }; 2172 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 2173 #endif 2174 #if defined( SHADOWMAP_TYPE_PCF ) 2175 float interleavedGradientNoise( vec2 position ) { 2176 return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); 2177 } 2178 vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { 2179 const float goldenAngle = 2.399963229728653; 2180 float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); 2181 float theta = float( sampleIndex ) * goldenAngle + phi; 2182 return vec2( cos( theta ), sin( theta ) ) * r; 2183 } 2184 #endif 2185 #if defined( SHADOWMAP_TYPE_PCF ) 2186 float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 2187 float shadow = 1.0; 2188 shadowCoord.xyz /= shadowCoord.w; 2189 shadowCoord.z += shadowBias; 2190 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 2191 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 2192 if ( frustumTest ) { 2193 vec2 texelSize = vec2( 1.0 ) / shadowMapSize; 2194 float radius = shadowRadius * texelSize.x; 2195 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; 2196 shadow = ( 2197 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + 2198 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + 2199 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + 2200 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + 2201 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) 2202 ) * 0.2; 2203 } 2204 return mix( 1.0, shadow, shadowIntensity ); 2205 } 2206 #elif defined( SHADOWMAP_TYPE_VSM ) 2207 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 2208 float shadow = 1.0; 2209 shadowCoord.xyz /= shadowCoord.w; 2210 shadowCoord.z += shadowBias; 2211 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 2212 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 2213 if ( frustumTest ) { 2214 vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; 2215 float mean = distribution.x; 2216 float variance = distribution.y * distribution.y; 2217 #ifdef USE_REVERSED_DEPTH_BUFFER 2218 float hard_shadow = step( mean, shadowCoord.z ); 2219 #else 2220 float hard_shadow = step( shadowCoord.z, mean ); 2221 #endif 2222 if ( hard_shadow == 1.0 ) { 2223 shadow = 1.0; 2224 } else { 2225 variance = max( variance, 0.0000001 ); 2226 float d = shadowCoord.z - mean; 2227 float p_max = variance / ( variance + d * d ); 2228 p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); 2229 shadow = max( hard_shadow, p_max ); 2230 } 2231 } 2232 return mix( 1.0, shadow, shadowIntensity ); 2233 } 2234 #else 2235 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 2236 float shadow = 1.0; 2237 shadowCoord.xyz /= shadowCoord.w; 2238 shadowCoord.z += shadowBias; 2239 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 2240 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 2241 if ( frustumTest ) { 2242 float depth = texture2D( shadowMap, shadowCoord.xy ).r; 2243 #ifdef USE_REVERSED_DEPTH_BUFFER 2244 shadow = step( depth, shadowCoord.z ); 2245 #else 2246 shadow = step( shadowCoord.z, depth ); 2247 #endif 2248 } 2249 return mix( 1.0, shadow, shadowIntensity ); 2250 } 2251 #endif 2252 #if NUM_POINT_LIGHT_SHADOWS > 0 2253 #if defined( SHADOWMAP_TYPE_PCF ) 2254 float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 2255 float shadow = 1.0; 2256 vec3 lightToPosition = shadowCoord.xyz; 2257 vec3 bd3D = normalize( lightToPosition ); 2258 vec3 absVec = abs( lightToPosition ); 2259 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 2260 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 2261 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 2262 dp += shadowBias; 2263 float texelSize = shadowRadius / shadowMapSize.x; 2264 vec3 absDir = abs( bd3D ); 2265 vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); 2266 tangent = normalize( cross( bd3D, tangent ) ); 2267 vec3 bitangent = cross( bd3D, tangent ); 2268 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; 2269 shadow = ( 2270 texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) + 2271 texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) + 2272 texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) + 2273 texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) + 2274 texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) ) 2275 ) * 0.2; 2276 } 2277 return mix( 1.0, shadow, shadowIntensity ); 2278 } 2279 #elif defined( SHADOWMAP_TYPE_BASIC ) 2280 float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 2281 float shadow = 1.0; 2282 vec3 lightToPosition = shadowCoord.xyz; 2283 vec3 bd3D = normalize( lightToPosition ); 2284 vec3 absVec = abs( lightToPosition ); 2285 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 2286 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 2287 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 2288 dp += shadowBias; 2289 float depth = textureCube( shadowMap, bd3D ).r; 2290 #ifdef USE_REVERSED_DEPTH_BUFFER 2291 shadow = step( depth, dp ); 2292 #else 2293 shadow = step( dp, depth ); 2294 #endif 2295 } 2296 return mix( 1.0, shadow, shadowIntensity ); 2297 } 2298 #endif 2299 #endif
2300#endif`,shadowmap_pars_vertex=`#if NUM_SPOT_LIGHT_COORDS > 0 2301 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; 2302 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 2303#endif 2304#ifdef USE_SHADOWMAP 2305 #if NUM_DIR_LIGHT_SHADOWS > 0 2306 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; 2307 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 2308 struct DirectionalLightShadow { 2309 float shadowIntensity; 2310 float shadowBias; 2311 float shadowNormalBias; 2312 float shadowRadius; 2313 vec2 shadowMapSize; 2314 }; 2315 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 2316 #endif 2317 #if NUM_SPOT_LIGHT_SHADOWS > 0 2318 struct SpotLightShadow { 2319 float shadowIntensity; 2320 float shadowBias; 2321 float shadowNormalBias; 2322 float shadowRadius; 2323 vec2 shadowMapSize; 2324 }; 2325 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 2326 #endif 2327 #if NUM_POINT_LIGHT_SHADOWS > 0 2328 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; 2329 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 2330 struct PointLightShadow { 2331 float shadowIntensity; 2332 float shadowBias; 2333 float shadowNormalBias; 2334 float shadowRadius; 2335 vec2 shadowMapSize; 2336 float shadowCameraNear; 2337 float shadowCameraFar; 2338 }; 2339 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 2340 #endif 2341#endif`,shadowmap_vertex=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) 2342 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 2343 vec4 shadowWorldPosition; 2344#endif 2345#if defined( USE_SHADOWMAP ) 2346 #if NUM_DIR_LIGHT_SHADOWS > 0 2347 #pragma unroll_loop_start 2348 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 2349 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); 2350 vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; 2351 } 2352 #pragma unroll_loop_end 2353 #endif 2354 #if NUM_POINT_LIGHT_SHADOWS > 0 2355 #pragma unroll_loop_start 2356 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 2357 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); 2358 vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; 2359 } 2360 #pragma unroll_loop_end 2361 #endif 2362#endif 2363#if NUM_SPOT_LIGHT_COORDS > 0 2364 #pragma unroll_loop_start 2365 for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { 2366 shadowWorldPosition = worldPosition; 2367 #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 2368 shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; 2369 #endif 2370 vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; 2371 } 2372 #pragma unroll_loop_end 2373#endif`,shadowmask_pars_fragment=`float getShadowMask() { 2374 float shadow = 1.0; 2375 #ifdef USE_SHADOWMAP 2376 #if NUM_DIR_LIGHT_SHADOWS > 0 2377 DirectionalLightShadow directionalLight; 2378 #pragma unroll_loop_start 2379 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 2380 directionalLight = directionalLightShadows[ i ]; 2381 shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 2382 } 2383 #pragma unroll_loop_end 2384 #endif 2385 #if NUM_SPOT_LIGHT_SHADOWS > 0 2386 SpotLightShadow spotLight; 2387 #pragma unroll_loop_start 2388 for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { 2389 spotLight = spotLightShadows[ i ]; 2390 shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 2391 } 2392 #pragma unroll_loop_end 2393 #endif 2394 #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 2395 PointLightShadow pointLight; 2396 #pragma unroll_loop_start 2397 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 2398 pointLight = pointLightShadows[ i ]; 2399 shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 2400 } 2401 #pragma unroll_loop_end 2402 #endif 2403 #endif 2404 return shadow; 2405}`,skinbase_vertex=`#ifdef USE_SKINNING 2406 mat4 boneMatX = getBoneMatrix( skinIndex.x ); 2407 mat4 boneMatY = getBoneMatrix( skinIndex.y ); 2408 mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 2409 mat4 boneMatW = getBoneMatrix( skinIndex.w ); 2410#endif`,skinning_pars_vertex=`#ifdef USE_SKINNING 2411 uniform mat4 bindMatrix; 2412 uniform mat4 bindMatrixInverse; 2413 uniform highp sampler2D boneTexture; 2414 mat4 getBoneMatrix( const in float i ) { 2415 int size = textureSize( boneTexture, 0 ).x; 2416 int j = int( i ) * 4; 2417 int x = j % size; 2418 int y = j / size; 2419 vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); 2420 vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); 2421 vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); 2422 vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); 2423 return mat4( v1, v2, v3, v4 ); 2424 } 2425#endif`,skinning_vertex=`#ifdef USE_SKINNING 2426 vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 2427 vec4 skinned = vec4( 0.0 ); 2428 skinned += boneMatX * skinVertex * skinWeight.x; 2429 skinned += boneMatY * skinVertex * skinWeight.y; 2430 skinned += boneMatZ * skinVertex * skinWeight.z; 2431 skinned += boneMatW * skinVertex * skinWeight.w; 2432 transformed = ( bindMatrixInverse * skinned ).xyz; 2433#endif`,skinnormal_vertex=`#ifdef USE_SKINNING 2434 mat4 skinMatrix = mat4( 0.0 ); 2435 skinMatrix += skinWeight.x * boneMatX; 2436 skinMatrix += skinWeight.y * boneMatY; 2437 skinMatrix += skinWeight.z * boneMatZ; 2438 skinMatrix += skinWeight.w * boneMatW; 2439 skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 2440 objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 2441 #ifdef USE_TANGENT 2442 objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; 2443 #endif 2444#endif`,specularmap_fragment=`float specularStrength; 2445#ifdef USE_SPECULARMAP 2446 vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); 2447 specularStrength = texelSpecular.r; 2448#else 2449 specularStrength = 1.0; 2450#endif`,specularmap_pars_fragment=`#ifdef USE_SPECULARMAP 2451 uniform sampler2D specularMap; 2452#endif`,tonemapping_fragment=`#if defined( TONE_MAPPING ) 2453 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 2454#endif`,tonemapping_pars_fragment=`#ifndef saturate 2455#define saturate( a ) clamp( a, 0.0, 1.0 ) 2456#endif 2457uniform float toneMappingExposure; 2458vec3 LinearToneMapping( vec3 color ) { 2459 return saturate( toneMappingExposure * color ); 2460} 2461vec3 ReinhardToneMapping( vec3 color ) { 2462 color *= toneMappingExposure; 2463 return saturate( color / ( vec3( 1.0 ) + color ) ); 2464} 2465vec3 CineonToneMapping( vec3 color ) { 2466 color *= toneMappingExposure; 2467 color = max( vec3( 0.0 ), color - 0.004 ); 2468 return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); 2469} 2470vec3 RRTAndODTFit( vec3 v ) { 2471 vec3 a = v * ( v + 0.0245786 ) - 0.000090537; 2472 vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; 2473 return a / b; 2474} 2475vec3 ACESFilmicToneMapping( vec3 color ) { 2476 const mat3 ACESInputMat = mat3( 2477 vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), 2478 vec3( 0.04823, 0.01566, 0.83777 ) 2479 ); 2480 const mat3 ACESOutputMat = mat3( 2481 vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), 2482 vec3( -0.07367, -0.00605, 1.07602 ) 2483 ); 2484 color *= toneMappingExposure / 0.6; 2485 color = ACESInputMat * color; 2486 color = RRTAndODTFit( color ); 2487 color = ACESOutputMat * color; 2488 return saturate( color ); 2489} 2490const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( 2491 vec3( 1.6605, - 0.1246, - 0.0182 ), 2492 vec3( - 0.5876, 1.1329, - 0.1006 ), 2493 vec3( - 0.0728, - 0.0083, 1.1187 ) 2494); 2495const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( 2496 vec3( 0.6274, 0.0691, 0.0164 ), 2497 vec3( 0.3293, 0.9195, 0.0880 ), 2498 vec3( 0.0433, 0.0113, 0.8956 ) 2499); 2500vec3 agxDefaultContrastApprox( vec3 x ) { 2501 vec3 x2 = x * x; 2502 vec3 x4 = x2 * x2; 2503 return + 15.5 * x4 * x2 2504 - 40.14 * x4 * x 2505 + 31.96 * x4 2506 - 6.868 * x2 * x 2507 + 0.4298 * x2 2508 + 0.1191 * x 2509 - 0.00232; 2510} 2511vec3 AgXToneMapping( vec3 color ) { 2512 const mat3 AgXInsetMatrix = mat3( 2513 vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), 2514 vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), 2515 vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) 2516 );
2517 const mat3 AgXOutsetMatrix = mat3( 2518 vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), 2519 vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), 2520 vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) 2521 ); 2522 const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; 2523 color *= toneMappingExposure; 2524 color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; 2525 color = AgXInsetMatrix * color; 2526 color = max( color, 1e-10 ); color = log2( color ); 2527 color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); 2528 color = clamp( color, 0.0, 1.0 ); 2529 color = agxDefaultContrastApprox( color ); 2530 color = AgXOutsetMatrix * color; 2531 color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); 2532 color = LINEAR_REC2020_TO_LINEAR_SRGB * color; 2533 color = clamp( color, 0.0, 1.0 ); 2534 return color; 2535} 2536vec3 NeutralToneMapping( vec3 color ) { 2537 const float StartCompression = 0.8 - 0.04; 2538 const float Desaturation = 0.15; 2539 color *= toneMappingExposure; 2540 float x = min( color.r, min( color.g, color.b ) ); 2541 float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; 2542 color -= offset; 2543 float peak = max( color.r, max( color.g, color.b ) ); 2544 if ( peak < StartCompression ) return color; 2545 float d = 1. - StartCompression; 2546 float newPeak = 1. - d * d / ( peak + d - StartCompression ); 2547 color *= newPeak / peak; 2548 float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); 2549 return mix( color, vec3( newPeak ), g ); 2550} 2551vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment=`#ifdef USE_TRANSMISSION 2552 material.transmission = transmission; 2553 material.transmissionAlpha = 1.0; 2554 material.thickness = thickness; 2555 material.attenuationDistance = attenuationDistance; 2556 material.attenuationColor = attenuationColor; 2557 #ifdef USE_TRANSMISSIONMAP 2558 material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; 2559 #endif 2560 #ifdef USE_THICKNESSMAP 2561 material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; 2562 #endif 2563 vec3 pos = vWorldPosition; 2564 vec3 v = normalize( cameraPosition - pos ); 2565 vec3 n = inverseTransformDirection( normal, viewMatrix ); 2566 vec4 transmitted = getIBLVolumeRefraction( 2567 n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, 2568 pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, 2569 material.attenuationColor, material.attenuationDistance ); 2570 material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); 2571 totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); 2572#endif`,transmission_pars_fragment=`#ifdef USE_TRANSMISSION 2573 uniform float transmission; 2574 uniform float thickness; 2575 uniform float attenuationDistance; 2576 uniform vec3 attenuationColor; 2577 #ifdef USE_TRANSMISSIONMAP 2578 uniform sampler2D transmissionMap; 2579 #endif 2580 #ifdef USE_THICKNESSMAP 2581 uniform sampler2D thicknessMap; 2582 #endif 2583 uniform vec2 transmissionSamplerSize; 2584 uniform sampler2D transmissionSamplerMap; 2585 uniform mat4 modelMatrix; 2586 uniform mat4 projectionMatrix; 2587 varying vec3 vWorldPosition; 2588 float w0( float a ) { 2589 return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); 2590 } 2591 float w1( float a ) { 2592 return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); 2593 } 2594 float w2( float a ){ 2595 return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); 2596 } 2597 float w3( float a ) { 2598 return ( 1.0 / 6.0 ) * ( a * a * a ); 2599 } 2600 float g0( float a ) { 2601 return w0( a ) + w1( a ); 2602 } 2603 float g1( float a ) { 2604 return w2( a ) + w3( a ); 2605 } 2606 float h0( float a ) { 2607 return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); 2608 } 2609 float h1( float a ) { 2610 return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); 2611 } 2612 vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { 2613 uv = uv * texelSize.zw + 0.5; 2614 vec2 iuv = floor( uv ); 2615 vec2 fuv = fract( uv ); 2616 float g0x = g0( fuv.x ); 2617 float g1x = g1( fuv.x ); 2618 float h0x = h0( fuv.x ); 2619 float h1x = h1( fuv.x ); 2620 float h0y = h0( fuv.y ); 2621 float h1y = h1( fuv.y ); 2622 vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2623 vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2624 vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2625 vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2626 return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + 2627 g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); 2628 } 2629 vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { 2630 vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); 2631 vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); 2632 vec2 fLodSizeInv = 1.0 / fLodSize; 2633 vec2 cLodSizeInv = 1.0 / cLodSize; 2634 vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); 2635 vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); 2636 return mix( fSample, cSample, fract( lod ) ); 2637 } 2638 vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { 2639 vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); 2640 vec3 modelScale; 2641 modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); 2642 modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); 2643 modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); 2644 return normalize( refractionVector ) * thickness * modelScale; 2645 } 2646 float applyIorToRoughness( const in float roughness, const in float ior ) { 2647 return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); 2648 } 2649 vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { 2650 float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); 2651 return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); 2652 } 2653 vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { 2654 if ( isinf( attenuationDistance ) ) { 2655 return vec3( 1.0 ); 2656 } else { 2657 vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; 2658 vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; 2659 } 2660 } 2661 vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, 2662 const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, 2663 const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, 2664 const in vec3 attenuationColor, const in float attenuationDistance ) { 2665 vec4 transmittedLight; 2666 vec3 transmittance; 2667 #ifdef USE_DISPERSION 2668 float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; 2669 vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); 2670 for ( int i = 0; i < 3; i ++ ) { 2671 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); 2672 vec3 refractedRayExit = position + transmissionRay; 2673 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2674 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2675 refractionCoords += 1.0; 2676 refractionCoords /= 2.0; 2677 vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); 2678 transmittedLight[ i ] = transmissionSample[ i ]; 2679 transmittedLight.a += transmissionSample.a; 2680 transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; 2681 } 2682 transmittedLight.a /= 3.0; 2683 #else 2684 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); 2685 vec3 refractedRayExit = position + transmissionRay; 2686 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2687 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2688 refractionCoords += 1.0; 2689 refractionCoords /= 2.0; 2690 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); 2691 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); 2692 #endif
vendor: 7,469 bytes, lines 2692-2942
2692 2693 vec3 attenuatedColor = transmittance * transmittedLight.rgb; 2694 vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); 2695 float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; 2696 return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); 2697 } 2698#endif`,uv_pars_fragment=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2699 varying vec2 vUv; 2700#endif 2701#ifdef USE_MAP 2702 varying vec2 vMapUv; 2703#endif 2704#ifdef USE_ALPHAMAP 2705 varying vec2 vAlphaMapUv; 2706#endif 2707#ifdef USE_LIGHTMAP 2708 varying vec2 vLightMapUv; 2709#endif 2710#ifdef USE_AOMAP 2711 varying vec2 vAoMapUv; 2712#endif 2713#ifdef USE_BUMPMAP 2714 varying vec2 vBumpMapUv; 2715#endif 2716#ifdef USE_NORMALMAP 2717 varying vec2 vNormalMapUv; 2718#endif 2719#ifdef USE_EMISSIVEMAP 2720 varying vec2 vEmissiveMapUv; 2721#endif 2722#ifdef USE_METALNESSMAP 2723 varying vec2 vMetalnessMapUv; 2724#endif 2725#ifdef USE_ROUGHNESSMAP 2726 varying vec2 vRoughnessMapUv; 2727#endif 2728#ifdef USE_ANISOTROPYMAP 2729 varying vec2 vAnisotropyMapUv; 2730#endif 2731#ifdef USE_CLEARCOATMAP 2732 varying vec2 vClearcoatMapUv; 2733#endif 2734#ifdef USE_CLEARCOAT_NORMALMAP 2735 varying vec2 vClearcoatNormalMapUv; 2736#endif 2737#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2738 varying vec2 vClearcoatRoughnessMapUv; 2739#endif 2740#ifdef USE_IRIDESCENCEMAP 2741 varying vec2 vIridescenceMapUv; 2742#endif 2743#ifdef USE_IRIDESCENCE_THICKNESSMAP 2744 varying vec2 vIridescenceThicknessMapUv; 2745#endif 2746#ifdef USE_SHEEN_COLORMAP 2747 varying vec2 vSheenColorMapUv; 2748#endif 2749#ifdef USE_SHEEN_ROUGHNESSMAP 2750 varying vec2 vSheenRoughnessMapUv; 2751#endif 2752#ifdef USE_SPECULARMAP 2753 varying vec2 vSpecularMapUv; 2754#endif 2755#ifdef USE_SPECULAR_COLORMAP 2756 varying vec2 vSpecularColorMapUv; 2757#endif 2758#ifdef USE_SPECULAR_INTENSITYMAP 2759 varying vec2 vSpecularIntensityMapUv; 2760#endif 2761#ifdef USE_TRANSMISSIONMAP 2762 uniform mat3 transmissionMapTransform; 2763 varying vec2 vTransmissionMapUv; 2764#endif 2765#ifdef USE_THICKNESSMAP 2766 uniform mat3 thicknessMapTransform; 2767 varying vec2 vThicknessMapUv; 2768#endif`,uv_pars_vertex=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2769 varying vec2 vUv; 2770#endif 2771#ifdef USE_MAP 2772 uniform mat3 mapTransform; 2773 varying vec2 vMapUv; 2774#endif 2775#ifdef USE_ALPHAMAP 2776 uniform mat3 alphaMapTransform; 2777 varying vec2 vAlphaMapUv; 2778#endif 2779#ifdef USE_LIGHTMAP 2780 uniform mat3 lightMapTransform; 2781 varying vec2 vLightMapUv; 2782#endif 2783#ifdef USE_AOMAP 2784 uniform mat3 aoMapTransform; 2785 varying vec2 vAoMapUv; 2786#endif 2787#ifdef USE_BUMPMAP 2788 uniform mat3 bumpMapTransform; 2789 varying vec2 vBumpMapUv; 2790#endif 2791#ifdef USE_NORMALMAP 2792 uniform mat3 normalMapTransform; 2793 varying vec2 vNormalMapUv; 2794#endif 2795#ifdef USE_DISPLACEMENTMAP 2796 uniform mat3 displacementMapTransform; 2797 varying vec2 vDisplacementMapUv; 2798#endif 2799#ifdef USE_EMISSIVEMAP 2800 uniform mat3 emissiveMapTransform; 2801 varying vec2 vEmissiveMapUv; 2802#endif 2803#ifdef USE_METALNESSMAP 2804 uniform mat3 metalnessMapTransform; 2805 varying vec2 vMetalnessMapUv; 2806#endif 2807#ifdef USE_ROUGHNESSMAP 2808 uniform mat3 roughnessMapTransform; 2809 varying vec2 vRoughnessMapUv; 2810#endif 2811#ifdef USE_ANISOTROPYMAP 2812 uniform mat3 anisotropyMapTransform; 2813 varying vec2 vAnisotropyMapUv; 2814#endif 2815#ifdef USE_CLEARCOATMAP 2816 uniform mat3 clearcoatMapTransform; 2817 varying vec2 vClearcoatMapUv; 2818#endif 2819#ifdef USE_CLEARCOAT_NORMALMAP 2820 uniform mat3 clearcoatNormalMapTransform; 2821 varying vec2 vClearcoatNormalMapUv; 2822#endif 2823#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2824 uniform mat3 clearcoatRoughnessMapTransform; 2825 varying vec2 vClearcoatRoughnessMapUv; 2826#endif 2827#ifdef USE_SHEEN_COLORMAP 2828 uniform mat3 sheenColorMapTransform; 2829 varying vec2 vSheenColorMapUv; 2830#endif 2831#ifdef USE_SHEEN_ROUGHNESSMAP 2832 uniform mat3 sheenRoughnessMapTransform; 2833 varying vec2 vSheenRoughnessMapUv; 2834#endif 2835#ifdef USE_IRIDESCENCEMAP 2836 uniform mat3 iridescenceMapTransform; 2837 varying vec2 vIridescenceMapUv; 2838#endif 2839#ifdef USE_IRIDESCENCE_THICKNESSMAP 2840 uniform mat3 iridescenceThicknessMapTransform; 2841 varying vec2 vIridescenceThicknessMapUv; 2842#endif 2843#ifdef USE_SPECULARMAP 2844 uniform mat3 specularMapTransform; 2845 varying vec2 vSpecularMapUv; 2846#endif 2847#ifdef USE_SPECULAR_COLORMAP 2848 uniform mat3 specularColorMapTransform; 2849 varying vec2 vSpecularColorMapUv; 2850#endif 2851#ifdef USE_SPECULAR_INTENSITYMAP 2852 uniform mat3 specularIntensityMapTransform; 2853 varying vec2 vSpecularIntensityMapUv; 2854#endif 2855#ifdef USE_TRANSMISSIONMAP 2856 uniform mat3 transmissionMapTransform; 2857 varying vec2 vTransmissionMapUv; 2858#endif 2859#ifdef USE_THICKNESSMAP 2860 uniform mat3 thicknessMapTransform; 2861 varying vec2 vThicknessMapUv; 2862#endif`,uv_vertex=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2863 vUv = vec3( uv, 1 ).xy; 2864#endif 2865#ifdef USE_MAP 2866 vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; 2867#endif 2868#ifdef USE_ALPHAMAP 2869 vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; 2870#endif 2871#ifdef USE_LIGHTMAP 2872 vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; 2873#endif 2874#ifdef USE_AOMAP 2875 vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; 2876#endif 2877#ifdef USE_BUMPMAP 2878 vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; 2879#endif 2880#ifdef USE_NORMALMAP 2881 vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; 2882#endif 2883#ifdef USE_DISPLACEMENTMAP 2884 vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; 2885#endif 2886#ifdef USE_EMISSIVEMAP 2887 vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; 2888#endif 2889#ifdef USE_METALNESSMAP 2890 vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; 2891#endif 2892#ifdef USE_ROUGHNESSMAP 2893 vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; 2894#endif 2895#ifdef USE_ANISOTROPYMAP 2896 vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; 2897#endif 2898#ifdef USE_CLEARCOATMAP 2899 vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; 2900#endif 2901#ifdef USE_CLEARCOAT_NORMALMAP 2902 vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; 2903#endif 2904#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2905 vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; 2906#endif 2907#ifdef USE_IRIDESCENCEMAP 2908 vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; 2909#endif 2910#ifdef USE_IRIDESCENCE_THICKNESSMAP 2911 vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; 2912#endif 2913#ifdef USE_SHEEN_COLORMAP 2914 vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; 2915#endif 2916#ifdef USE_SHEEN_ROUGHNESSMAP 2917 vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; 2918#endif 2919#ifdef USE_SPECULARMAP 2920 vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; 2921#endif 2922#ifdef USE_SPECULAR_COLORMAP 2923 vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; 2924#endif 2925#ifdef USE_SPECULAR_INTENSITYMAP 2926 vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; 2927#endif 2928#ifdef USE_TRANSMISSIONMAP 2929 vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; 2930#endif 2931#ifdef USE_THICKNESSMAP 2932 vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; 2933#endif`,worldpos_vertex=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 2934 vec4 worldPosition = vec4( transformed, 1.0 ); 2935 #ifdef USE_BATCHING 2936 worldPosition = batchingMatrix * worldPosition; 2937 #endif 2938 #ifdef USE_INSTANCING 2939 worldPosition = instanceMatrix * worldPosition; 2940 #endif 2941 worldPosition = modelMatrix * worldPosition; 2942#endif`
2942,vertex$h=`varying vec2 vUv; 2943uniform mat3 uvTransform; 2944void main() { 2945 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 2946 gl_Position = vec4( position.xy, 1.0, 1.0 ); 2947}`,fragment$h=`uniform sampler2D t2D; 2948uniform float backgroundIntensity; 2949varying vec2 vUv; 2950void main() { 2951 vec4 texColor = texture2D( t2D, vUv ); 2952 #ifdef DECODE_VIDEO_TEXTURE 2953 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 ); 2954 #endif 2955 texColor.rgb *= backgroundIntensity; 2956 gl_FragColor = texColor; 2957 #include <tonemapping_fragment> 2958 #include <colorspace_fragment> 2959}`,vertex$g=`varying vec3 vWorldDirection; 2960#include <common> 2961void main() { 2962 vWorldDirection = transformDirection( position, modelMatrix ); 2963 #include <begin_vertex> 2964 #include <project_vertex> 2965 gl_Position.z = gl_Position.w; 2966}`,fragment$g=`#ifdef ENVMAP_TYPE_CUBE 2967 uniform samplerCube envMap; 2968#elif defined( ENVMAP_TYPE_CUBE_UV ) 2969 uniform sampler2D envMap; 2970#endif 2971uniform float flipEnvMap; 2972uniform float backgroundBlurriness; 2973uniform float backgroundIntensity; 2974uniform mat3 backgroundRotation; 2975varying vec3 vWorldDirection; 2976#include <cube_uv_reflection_fragment> 2977void main() { 2978 #ifdef ENVMAP_TYPE_CUBE 2979 vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); 2980 #elif defined( ENVMAP_TYPE_CUBE_UV ) 2981 vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); 2982 #else 2983 vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 2984 #endif 2985 texColor.rgb *= backgroundIntensity; 2986 gl_FragColor = texColor; 2987 #include <tonemapping_fragment> 2988 #include <colorspace_fragment> 2989}`,vertex$f=`varying vec3 vWorldDirection; 2990#include <common> 2991void main() { 2992 vWorldDirection = transformDirection( position, modelMatrix ); 2993 #include <begin_vertex> 2994 #include <project_vertex> 2995 gl_Position.z = gl_Position.w; 2996}`,fragment$f=`uniform samplerCube tCube; 2997uniform float tFlip; 2998uniform float opacity; 2999varying vec3 vWorldDirection; 3000void main() { 3001 vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 3002 gl_FragColor = texColor; 3003 gl_FragColor.a *= opacity; 3004 #include <tonemapping_fragment> 3005 #include <colorspace_fragment> 3006}`,vertex$e=`#include <common> 3007#include <batching_pars_vertex> 3008#include <uv_pars_vertex> 3009#include <displacementmap_pars_vertex> 3010#include <morphtarget_pars_vertex> 3011#include <skinning_pars_vertex> 3012#include <logdepthbuf_pars_vertex> 3013#include <clipping_planes_pars_vertex> 3014varying vec2 vHighPrecisionZW; 3015void main() { 3016 #include <uv_vertex> 3017 #include <batching_vertex> 3018 #include <skinbase_vertex> 3019 #include <morphinstance_vertex> 3020 #ifdef USE_DISPLACEMENTMAP 3021 #include <beginnormal_vertex> 3022 #include <morphnormal_vertex> 3023 #include <skinnormal_vertex> 3024 #endif 3025 #include <begin_vertex> 3026 #include <morphtarget_vertex> 3027 #include <skinning_vertex> 3028 #include <displacementmap_vertex> 3029 #include <project_vertex> 3030 #include <logdepthbuf_vertex> 3031 #include <clipping_planes_vertex> 3032 vHighPrecisionZW = gl_Position.zw; 3033}`,fragment$e=`#if DEPTH_PACKING == 3200 3034 uniform float opacity; 3035#endif 3036#include <common> 3037#include <packing> 3038#include <uv_pars_fragment> 3039#include <map_pars_fragment> 3040#include <alphamap_pars_fragment> 3041#include <alphatest_pars_fragment> 3042#include <alphahash_pars_fragment> 3043#include <logdepthbuf_pars_fragment> 3044#include <clipping_planes_pars_fragment> 3045varying vec2 vHighPrecisionZW; 3046void main() { 3047 vec4 diffuseColor = vec4( 1.0 ); 3048 #include <clipping_planes_fragment> 3049 #if DEPTH_PACKING == 3200 3050 diffuseColor.a = opacity; 3051 #endif 3052 #include <map_fragment> 3053 #include <alphamap_fragment> 3054 #include <alphatest_fragment> 3055 #include <alphahash_fragment> 3056 #include <logdepthbuf_fragment> 3057 #ifdef USE_REVERSED_DEPTH_BUFFER 3058 float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; 3059 #else 3060 float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; 3061 #endif 3062 #if DEPTH_PACKING == 3200 3063 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); 3064 #elif DEPTH_PACKING == 3201 3065 gl_FragColor = packDepthToRGBA( fragCoordZ ); 3066 #elif DEPTH_PACKING == 3202 3067 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); 3068 #elif DEPTH_PACKING == 3203 3069 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); 3070 #endif 3071}`,vertex$d=`#define DISTANCE 3072varying vec3 vWorldPosition; 3073#include <common> 3074#include <batching_pars_vertex> 3075#include <uv_pars_vertex> 3076#include <displacementmap_pars_vertex> 3077#include <morphtarget_pars_vertex> 3078#include <skinning_pars_vertex> 3079#include <clipping_planes_pars_vertex> 3080void main() { 3081 #include <uv_vertex> 3082 #include <batching_vertex> 3083 #include <skinbase_vertex> 3084 #include <morphinstance_vertex> 3085 #ifdef USE_DISPLACEMENTMAP 3086 #include <beginnormal_vertex> 3087 #include <morphnormal_vertex> 3088 #include <skinnormal_vertex> 3089 #endif 3090 #include <begin_vertex> 3091 #include <morphtarget_vertex> 3092 #include <skinning_vertex> 3093 #include <displacementmap_vertex> 3094 #include <project_vertex> 3095 #include <worldpos_vertex> 3096 #include <clipping_planes_vertex> 3097 vWorldPosition = worldPosition.xyz; 3098}`,fragment$d=`#define DISTANCE 3099uniform vec3 referencePosition; 3100uniform float nearDistance; 3101uniform float farDistance; 3102varying vec3 vWorldPosition; 3103#include <common> 3104#include <uv_pars_fragment> 3105#include <map_pars_fragment> 3106#include <alphamap_pars_fragment> 3107#include <alphatest_pars_fragment> 3108#include <alphahash_pars_fragment> 3109#include <clipping_planes_pars_fragment> 3110void main () { 3111 vec4 diffuseColor = vec4( 1.0 ); 3112 #include <clipping_planes_fragment> 3113 #include <map_fragment> 3114 #include <alphamap_fragment> 3115 #include <alphatest_fragment> 3116 #include <alphahash_fragment> 3117 float dist = length( vWorldPosition - referencePosition ); 3118 dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 3119 dist = saturate( dist ); 3120 gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); 3121}`,vertex$c=`varying vec3 vWorldDirection; 3122#include <common> 3123void main() { 3124 vWorldDirection = transformDirection( position, modelMatrix ); 3125 #include <begin_vertex> 3126 #include <project_vertex> 3127}`,fragment$c=`uniform sampler2D tEquirect; 3128varying vec3 vWorldDirection; 3129#include <common> 3130void main() { 3131 vec3 direction = normalize( vWorldDirection ); 3132 vec2 sampleUV = equirectUv( direction ); 3133 gl_FragColor = texture2D( tEquirect, sampleUV ); 3134 #include <tonemapping_fragment> 3135 #include <colorspace_fragment> 3136}`,vertex$b=`uniform float scale; 3137attribute float lineDistance; 3138varying float vLineDistance; 3139#include <common> 3140#include <uv_pars_vertex> 3141#include <color_pars_vertex> 3142#include <fog_pars_vertex> 3143#include <morphtarget_pars_vertex> 3144#include <logdepthbuf_pars_vertex> 3145#include <clipping_planes_pars_vertex> 3146void main() { 3147 vLineDistance = scale * lineDistance; 3148 #include <uv_vertex> 3149 #include <color_vertex> 3150 #include <morphinstance_vertex> 3151 #include <morphcolor_vertex> 3152 #include <begin_vertex> 3153 #include <morphtarget_vertex> 3154 #include <project_vertex> 3155 #include <logdepthbuf_vertex> 3156 #include <clipping_planes_vertex> 3157 #include <fog_vertex> 3158}`,fragment$b=`uniform vec3 diffuse; 3159uniform float opacity; 3160uniform float dashSize; 3161uniform float totalSize; 3162varying float vLineDistance; 3163#include <common> 3164#include <color_pars_fragment> 3165#include <uv_pars_fragment> 3166#include <map_pars_fragment> 3167#include <fog_pars_fragment> 3168#include <logdepthbuf_pars_fragment> 3169#include <clipping_planes_pars_fragment> 3170void main() { 3171 vec4 diffuseColor = vec4( diffuse, opacity ); 3172 #include <clipping_planes_fragment> 3173 if ( mod( vLineDistance, totalSize ) > dashSize ) { 3174 discard; 3175 } 3176 vec3 outgoingLight = vec3( 0.0 ); 3177 #include <logdepthbuf_fragment> 3178 #include <map_fragment> 3179 #include <color_fragment> 3180 outgoingLight = diffuseColor.rgb; 3181 #include <opaque_fragment> 3182 #include <tonemapping_fragment> 3183 #include <colorspace_fragment> 3184 #include <fog_fragment> 3185 #include <premultiplied_alpha_fragment> 3186}`,vertex$a=`#include <common> 3187#include <batching_pars_vertex> 3188#include <uv_pars_vertex> 3189#include <envmap_pars_vertex> 3190#include <color_pars_vertex> 3191#include <fog_pars_vertex> 3192#include <morphtarget_pars_vertex> 3193#include <skinning_pars_vertex> 3194#include <logdepthbuf_pars_vertex> 3195#include <clipping_planes_pars_vertex> 3196void main() { 3197 #include <uv_vertex> 3198 #include <color_vertex> 3199 #include <morphinstance_vertex> 3200 #include <morphcolor_vertex> 3201 #include <batching_vertex> 3202 #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) 3203 #include <beginnormal_vertex> 3204 #include <morphnormal_vertex> 3205 #include <skinbase_vertex> 3206 #include <skinnormal_vertex> 3207 #include <defaultnormal_vertex> 3208 #endif 3209 #include <begin_vertex> 3210 #include <morphtarget_vertex> 3211 #include <skinning_vertex> 3212 #include <project_vertex> 3213 #include <logdepthbuf_vertex> 3214 #include <clipping_planes_vertex> 3215 #include <worldpos_vertex> 3216 #include <envmap_vertex> 3217 #include <fog_vertex> 3218}`,fragment$a=`uniform vec3 diffuse; 3219uniform float opacity; 3220#ifndef FLAT_SHADED 3221 varying vec3 vNormal; 3222#endif 3223#include <common> 3224#include <dithering_pars_fragment> 3225#include <color_pars_fragment> 3226#include <uv_pars_fragment> 3227#include <map_pars_fragment> 3228#include <alphamap_pars_fragment> 3229#include <alphatest_pars_fragment> 3230#include <alphahash_pars_fragment> 3231#include <aomap_pars_fragment> 3232#include <lightmap_pars_fragment> 3233#include <envmap_common_pars_fragment> 3234#include <envmap_pars_fragment> 3235#include <fog_pars_fragment> 3236#include <specularmap_pars_fragment> 3237#include <logdepthbuf_pars_fragment> 3238#include <clipping_planes_pars_fragment> 3239void main() { 3240 vec4 diffuseColor = vec4( diffuse, opacity ); 3241 #include <clipping_planes_fragment> 3242 #include <logdepthbuf_fragment> 3243 #include <map_fragment> 3244 #include <color_fragment> 3245 #include <alphamap_fragment> 3246 #include <alphatest_fragment> 3247 #include <alphahash_fragment> 3248 #include <specularmap_fragment> 3249 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3250 #ifdef USE_LIGHTMAP 3251 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 3252 reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; 3253 #else 3254 reflectedLight.indirectDiffuse += vec3( 1.0 ); 3255 #endif 3256 #include <aomap_fragment> 3257 reflectedLight.indirectDiffuse *= diffuseColor.rgb; 3258 vec3 outgoingLight = reflectedLight.indirectDiffuse; 3259 #include <envmap_fragment> 3260 #include <opaque_fragment> 3261 #include <tonemapping_fragment> 3262 #include <colorspace_fragment> 3263 #include <fog_fragment> 3264 #include <premultiplied_alpha_fragment> 3265 #include <dithering_fragment> 3266}`,vertex$9=`#define LAMBERT 3267varying vec3 vViewPosition; 3268#include <common> 3269#include <batching_pars_vertex> 3270#include <uv_pars_vertex> 3271#include <displacementmap_pars_vertex> 3272#include <envmap_pars_vertex> 3273#include <color_pars_vertex> 3274#include <fog_pars_vertex> 3275#include <normal_pars_vertex> 3276#include <morphtarget_pars_vertex> 3277#include <skinning_pars_vertex> 3278#include <shadowmap_pars_vertex> 3279#include <logdepthbuf_pars_vertex> 3280#include <clipping_planes_pars_vertex> 3281void main() { 3282 #include <uv_vertex> 3283 #include <color_vertex> 3284 #include <morphinstance_vertex> 3285 #include <morphcolor_vertex> 3286 #include <batching_vertex> 3287 #include <beginnormal_vertex> 3288 #include <morphnormal_vertex> 3289 #include <skinbase_vertex> 3290 #include <skinnormal_vertex> 3291 #include <defaultnormal_vertex> 3292 #include <normal_vertex> 3293 #include <begin_vertex> 3294 #include <morphtarget_vertex> 3295 #include <skinning_vertex> 3296 #include <displacementmap_vertex> 3297 #include <project_vertex> 3298 #include <logdepthbuf_vertex> 3299 #include <clipping_planes_vertex> 3300 vViewPosition = - mvPosition.xyz; 3301 #include <worldpos_vertex> 3302 #include <envmap_vertex> 3303 #include <shadowmap_vertex> 3304 #include <fog_vertex> 3305}`,fragment$9=`#define LAMBERT 3306uniform vec3 diffuse; 3307uniform vec3 emissive; 3308uniform float opacity; 3309#include <common> 3310#include <dithering_pars_fragment> 3311#include <color_pars_fragment> 3312#include <uv_pars_fragment> 3313#include <map_pars_fragment> 3314#include <alphamap_pars_fragment> 3315#include <alphatest_pars_fragment> 3316#include <alphahash_pars_fragment> 3317#include <aomap_pars_fragment> 3318#include <lightmap_pars_fragment> 3319#include <emissivemap_pars_fragment> 3320#include <envmap_common_pars_fragment> 3321#include <envmap_pars_fragment> 3322#include <fog_pars_fragment> 3323#include <bsdfs> 3324#include <lights_pars_begin> 3325#include <normal_pars_fragment> 3326#include <lights_lambert_pars_fragment> 3327#include <shadowmap_pars_fragment> 3328#include <bumpmap_pars_fragment> 3329#include <normalmap_pars_fragment> 3330#include <specularmap_pars_fragment> 3331#include <logdepthbuf_pars_fragment> 3332#include <clipping_planes_pars_fragment> 3333void main() { 3334 vec4 diffuseColor = vec4( diffuse, opacity ); 3335 #include <clipping_planes_fragment> 3336 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3337 vec3 totalEmissiveRadiance = emissive; 3338 #include <logdepthbuf_fragment> 3339 #include <map_fragment> 3340 #include <color_fragment> 3341 #include <alphamap_fragment> 3342 #include <alphatest_fragment> 3343 #include <alphahash_fragment> 3344 #include <specularmap_fragment> 3345 #include <normal_fragment_begin> 3346 #include <normal_fragment_maps> 3347 #include <emissivemap_fragment> 3348 #include <lights_lambert_fragment> 3349 #include <lights_fragment_begin> 3350 #include <lights_fragment_maps> 3351 #include <lights_fragment_end> 3352 #include <aomap_fragment> 3353 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3354 #include <envmap_fragment> 3355 #include <opaque_fragment> 3356 #include <tonemapping_fragment> 3357 #include <colorspace_fragment> 3358 #include <fog_fragment> 3359 #include <premultiplied_alpha_fragment> 3360 #include <dithering_fragment> 3361}`,vertex$8=`#define MATCAP 3362varying vec3 vViewPosition; 3363#include <common> 3364#include <batching_pars_vertex> 3365#include <uv_pars_vertex> 3366#include <color_pars_vertex> 3367#include <displacementmap_pars_vertex> 3368#include <fog_pars_vertex> 3369#include <normal_pars_vertex> 3370#include <morphtarget_pars_vertex> 3371#include <skinning_pars_vertex> 3372#include <logdepthbuf_pars_vertex> 3373#include <clipping_planes_pars_vertex> 3374void main() { 3375 #include <uv_vertex> 3376 #include <color_vertex> 3377 #include <morphinstance_vertex> 3378 #include <morphcolor_vertex> 3379 #include <batching_vertex> 3380 #include <beginnormal_vertex> 3381 #include <morphnormal_vertex> 3382 #include <skinbase_vertex> 3383 #include <skinnormal_vertex> 3384 #include <defaultnormal_vertex> 3385 #include <normal_vertex> 3386 #include <begin_vertex> 3387 #include <morphtarget_vertex> 3388 #include <skinning_vertex> 3389 #include <displacementmap_vertex> 3390 #include <project_vertex> 3391 #include <logdepthbuf_vertex> 3392 #include <clipping_planes_vertex> 3393 #include <fog_vertex> 3394 vViewPosition = - mvPosition.xyz; 3395}`,fragment$8=`#define MATCAP 3396uniform vec3 diffuse; 3397uniform float opacity; 3398uniform sampler2D matcap; 3399varying vec3 vViewPosition; 3400#include <common> 3401#include <dithering_pars_fragment> 3402#include <color_pars_fragment> 3403#include <uv_pars_fragment> 3404#include <map_pars_fragment> 3405#include <alphamap_pars_fragment> 3406#include <alphatest_pars_fragment> 3407#include <alphahash_pars_fragment> 3408#include <fog_pars_fragment> 3409#include <normal_pars_fragment> 3410#include <bumpmap_pars_fragment> 3411#include <normalmap_pars_fragment> 3412#include <logdepthbuf_pars_fragment> 3413#include <clipping_planes_pars_fragment> 3414void main() { 3415 vec4 diffuseColor = vec4( diffuse, opacity ); 3416 #include <clipping_planes_fragment> 3417 #include <logdepthbuf_fragment> 3418 #include <map_fragment> 3419 #include <color_fragment> 3420 #include <alphamap_fragment> 3421 #include <alphatest_fragment> 3422 #include <alphahash_fragment> 3423 #include <normal_fragment_begin> 3424 #include <normal_fragment_maps> 3425 vec3 viewDir = normalize( vViewPosition ); 3426 vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); 3427 vec3 y = cross( viewDir, x ); 3428 vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; 3429 #ifdef USE_MATCAP
3430 vec4 matcapColor = texture2D( matcap, uv ); 3431 #else 3432 vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); 3433 #endif 3434 vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; 3435 #include <opaque_fragment> 3436 #include <tonemapping_fragment> 3437 #include <colorspace_fragment> 3438 #include <fog_fragment> 3439 #include <premultiplied_alpha_fragment> 3440 #include <dithering_fragment> 3441}`,vertex$7=`#define NORMAL 3442#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3443 varying vec3 vViewPosition; 3444#endif 3445#include <common> 3446#include <batching_pars_vertex> 3447#include <uv_pars_vertex> 3448#include <displacementmap_pars_vertex> 3449#include <normal_pars_vertex> 3450#include <morphtarget_pars_vertex> 3451#include <skinning_pars_vertex> 3452#include <logdepthbuf_pars_vertex> 3453#include <clipping_planes_pars_vertex> 3454void main() { 3455 #include <uv_vertex> 3456 #include <batching_vertex> 3457 #include <beginnormal_vertex> 3458 #include <morphinstance_vertex> 3459 #include <morphnormal_vertex> 3460 #include <skinbase_vertex> 3461 #include <skinnormal_vertex> 3462 #include <defaultnormal_vertex> 3463 #include <normal_vertex> 3464 #include <begin_vertex> 3465 #include <morphtarget_vertex> 3466 #include <skinning_vertex> 3467 #include <displacementmap_vertex> 3468 #include <project_vertex> 3469 #include <logdepthbuf_vertex> 3470 #include <clipping_planes_vertex> 3471#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3472 vViewPosition = - mvPosition.xyz; 3473#endif 3474}`,fragment$7=`#define NORMAL 3475uniform float opacity; 3476#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3477 varying vec3 vViewPosition; 3478#endif 3479#include <uv_pars_fragment> 3480#include <normal_pars_fragment> 3481#include <bumpmap_pars_fragment> 3482#include <normalmap_pars_fragment> 3483#include <logdepthbuf_pars_fragment> 3484#include <clipping_planes_pars_fragment> 3485void main() { 3486 vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); 3487 #include <clipping_planes_fragment> 3488 #include <logdepthbuf_fragment> 3489 #include <normal_fragment_begin> 3490 #include <normal_fragment_maps> 3491 gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); 3492 #ifdef OPAQUE 3493 gl_FragColor.a = 1.0; 3494 #endif 3495}`,vertex$6=`#define PHONG 3496varying vec3 vViewPosition; 3497#include <common> 3498#include <batching_pars_vertex> 3499#include <uv_pars_vertex> 3500#include <displacementmap_pars_vertex> 3501#include <envmap_pars_vertex> 3502#include <color_pars_vertex> 3503#include <fog_pars_vertex> 3504#include <normal_pars_vertex> 3505#include <morphtarget_pars_vertex> 3506#include <skinning_pars_vertex> 3507#include <shadowmap_pars_vertex> 3508#include <logdepthbuf_pars_vertex> 3509#include <clipping_planes_pars_vertex> 3510void main() { 3511 #include <uv_vertex> 3512 #include <color_vertex> 3513 #include <morphcolor_vertex> 3514 #include <batching_vertex> 3515 #include <beginnormal_vertex> 3516 #include <morphinstance_vertex> 3517 #include <morphnormal_vertex> 3518 #include <skinbase_vertex> 3519 #include <skinnormal_vertex> 3520 #include <defaultnormal_vertex> 3521 #include <normal_vertex> 3522 #include <begin_vertex> 3523 #include <morphtarget_vertex> 3524 #include <skinning_vertex> 3525 #include <displacementmap_vertex> 3526 #include <project_vertex> 3527 #include <logdepthbuf_vertex> 3528 #include <clipping_planes_vertex> 3529 vViewPosition = - mvPosition.xyz; 3530 #include <worldpos_vertex> 3531 #include <envmap_vertex> 3532 #include <shadowmap_vertex> 3533 #include <fog_vertex> 3534}`,fragment$6=`#define PHONG 3535uniform vec3 diffuse; 3536uniform vec3 emissive; 3537uniform vec3 specular; 3538uniform float shininess; 3539uniform float opacity; 3540#include <common> 3541#include <dithering_pars_fragment> 3542#include <color_pars_fragment> 3543#include <uv_pars_fragment> 3544#include <map_pars_fragment> 3545#include <alphamap_pars_fragment> 3546#include <alphatest_pars_fragment> 3547#include <alphahash_pars_fragment> 3548#include <aomap_pars_fragment> 3549#include <lightmap_pars_fragment> 3550#include <emissivemap_pars_fragment> 3551#include <envmap_common_pars_fragment> 3552#include <envmap_pars_fragment> 3553#include <fog_pars_fragment> 3554#include <bsdfs> 3555#include <lights_pars_begin> 3556#include <normal_pars_fragment> 3557#include <lights_phong_pars_fragment> 3558#include <shadowmap_pars_fragment> 3559#include <bumpmap_pars_fragment> 3560#include <normalmap_pars_fragment> 3561#include <specularmap_pars_fragment> 3562#include <logdepthbuf_pars_fragment> 3563#include <clipping_planes_pars_fragment> 3564void main() { 3565 vec4 diffuseColor = vec4( diffuse, opacity ); 3566 #include <clipping_planes_fragment> 3567 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3568 vec3 totalEmissiveRadiance = emissive; 3569 #include <logdepthbuf_fragment> 3570 #include <map_fragment> 3571 #include <color_fragment> 3572 #include <alphamap_fragment> 3573 #include <alphatest_fragment> 3574 #include <alphahash_fragment> 3575 #include <specularmap_fragment> 3576 #include <normal_fragment_begin> 3577 #include <normal_fragment_maps> 3578 #include <emissivemap_fragment> 3579 #include <lights_phong_fragment> 3580 #include <lights_fragment_begin> 3581 #include <lights_fragment_maps> 3582 #include <lights_fragment_end> 3583 #include <aomap_fragment> 3584 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; 3585 #include <envmap_fragment> 3586 #include <opaque_fragment> 3587 #include <tonemapping_fragment> 3588 #include <colorspace_fragment> 3589 #include <fog_fragment> 3590 #include <premultiplied_alpha_fragment> 3591 #include <dithering_fragment> 3592}`,vertex$5=`#define STANDARD 3593varying vec3 vViewPosition; 3594#ifdef USE_TRANSMISSION 3595 varying vec3 vWorldPosition; 3596#endif 3597#include <common> 3598#include <batching_pars_vertex> 3599#include <uv_pars_vertex> 3600#include <displacementmap_pars_vertex> 3601#include <color_pars_vertex> 3602#include <fog_pars_vertex> 3603#include <normal_pars_vertex> 3604#include <morphtarget_pars_vertex> 3605#include <skinning_pars_vertex> 3606#include <shadowmap_pars_vertex> 3607#include <logdepthbuf_pars_vertex> 3608#include <clipping_planes_pars_vertex> 3609void main() { 3610 #include <uv_vertex> 3611 #include <color_vertex> 3612 #include <morphinstance_vertex> 3613 #include <morphcolor_vertex> 3614 #include <batching_vertex> 3615 #include <beginnormal_vertex> 3616 #include <morphnormal_vertex> 3617 #include <skinbase_vertex> 3618 #include <skinnormal_vertex> 3619 #include <defaultnormal_vertex> 3620 #include <normal_vertex> 3621 #include <begin_vertex> 3622 #include <morphtarget_vertex> 3623 #include <skinning_vertex> 3624 #include <displacementmap_vertex> 3625 #include <project_vertex> 3626 #include <logdepthbuf_vertex> 3627 #include <clipping_planes_vertex> 3628 vViewPosition = - mvPosition.xyz; 3629 #include <worldpos_vertex> 3630 #include <shadowmap_vertex> 3631 #include <fog_vertex> 3632#ifdef USE_TRANSMISSION 3633 vWorldPosition = worldPosition.xyz; 3634#endif 3635}`,fragment$5=`#define STANDARD 3636#ifdef PHYSICAL 3637 #define IOR 3638 #define USE_SPECULAR 3639#endif 3640uniform vec3 diffuse; 3641uniform vec3 emissive; 3642uniform float roughness; 3643uniform float metalness; 3644uniform float opacity; 3645#ifdef IOR 3646 uniform float ior; 3647#endif 3648#ifdef USE_SPECULAR 3649 uniform float specularIntensity; 3650 uniform vec3 specularColor; 3651 #ifdef USE_SPECULAR_COLORMAP 3652 uniform sampler2D specularColorMap; 3653 #endif 3654 #ifdef USE_SPECULAR_INTENSITYMAP 3655 uniform sampler2D specularIntensityMap; 3656 #endif 3657#endif 3658#ifdef USE_CLEARCOAT 3659 uniform float clearcoat; 3660 uniform float clearcoatRoughness; 3661#endif 3662#ifdef USE_DISPERSION 3663 uniform float dispersion; 3664#endif
3665#ifdef USE_IRIDESCENCE 3666 uniform float iridescence; 3667 uniform float iridescenceIOR; 3668 uniform float iridescenceThicknessMinimum; 3669 uniform float iridescenceThicknessMaximum; 3670#endif 3671#ifdef USE_SHEEN 3672 uniform vec3 sheenColor; 3673 uniform float sheenRoughness; 3674 #ifdef USE_SHEEN_COLORMAP 3675 uniform sampler2D sheenColorMap; 3676 #endif 3677 #ifdef USE_SHEEN_ROUGHNESSMAP 3678 uniform sampler2D sheenRoughnessMap; 3679 #endif 3680#endif 3681#ifdef USE_ANISOTROPY 3682 uniform vec2 anisotropyVector; 3683 #ifdef USE_ANISOTROPYMAP 3684 uniform sampler2D anisotropyMap; 3685 #endif 3686#endif 3687varying vec3 vViewPosition; 3688#include <common> 3689#include <dithering_pars_fragment> 3690#include <color_pars_fragment> 3691#include <uv_pars_fragment> 3692#include <map_pars_fragment> 3693#include <alphamap_pars_fragment> 3694#include <alphatest_pars_fragment> 3695#include <alphahash_pars_fragment> 3696#include <aomap_pars_fragment> 3697#include <lightmap_pars_fragment> 3698#include <emissivemap_pars_fragment> 3699#include <iridescence_fragment> 3700#include <cube_uv_reflection_fragment> 3701#include <envmap_common_pars_fragment> 3702#include <envmap_physical_pars_fragment> 3703#include <fog_pars_fragment> 3704#include <lights_pars_begin> 3705#include <normal_pars_fragment> 3706#include <lights_physical_pars_fragment> 3707#include <transmission_pars_fragment> 3708#include <shadowmap_pars_fragment> 3709#include <bumpmap_pars_fragment> 3710#include <normalmap_pars_fragment> 3711#include <clearcoat_pars_fragment> 3712#include <iridescence_pars_fragment> 3713#include <roughnessmap_pars_fragment> 3714#include <metalnessmap_pars_fragment> 3715#include <logdepthbuf_pars_fragment> 3716#include <clipping_planes_pars_fragment> 3717void main() { 3718 vec4 diffuseColor = vec4( diffuse, opacity ); 3719 #include <clipping_planes_fragment> 3720 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3721 vec3 totalEmissiveRadiance = emissive; 3722 #include <logdepthbuf_fragment> 3723 #include <map_fragment> 3724 #include <color_fragment> 3725 #include <alphamap_fragment> 3726 #include <alphatest_fragment> 3727 #include <alphahash_fragment> 3728 #include <roughnessmap_fragment> 3729 #include <metalnessmap_fragment> 3730 #include <normal_fragment_begin> 3731 #include <normal_fragment_maps> 3732 #include <clearcoat_normal_fragment_begin> 3733 #include <clearcoat_normal_fragment_maps> 3734 #include <emissivemap_fragment> 3735 #include <lights_physical_fragment> 3736 #include <lights_fragment_begin> 3737 #include <lights_fragment_maps> 3738 #include <lights_fragment_end> 3739 #include <aomap_fragment> 3740 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; 3741 vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; 3742 #include <transmission_fragment> 3743 vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; 3744 #ifdef USE_SHEEN 3745 3746 outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; 3747 3748 #endif 3749 #ifdef USE_CLEARCOAT 3750 float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); 3751 vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); 3752 outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; 3753 #endif 3754 #include <opaque_fragment> 3755 #include <tonemapping_fragment> 3756 #include <colorspace_fragment> 3757 #include <fog_fragment> 3758 #include <premultiplied_alpha_fragment> 3759 #include <dithering_fragment> 3760}`,vertex$4=`#define TOON 3761varying vec3 vViewPosition; 3762#include <common> 3763#include <batching_pars_vertex> 3764#include <uv_pars_vertex> 3765#include <displacementmap_pars_vertex> 3766#include <color_pars_vertex> 3767#include <fog_pars_vertex> 3768#include <normal_pars_vertex> 3769#include <morphtarget_pars_vertex> 3770#include <skinning_pars_vertex> 3771#include <shadowmap_pars_vertex> 3772#include <logdepthbuf_pars_vertex> 3773#include <clipping_planes_pars_vertex> 3774void main() { 3775 #include <uv_vertex> 3776 #include <color_vertex> 3777 #include <morphinstance_vertex> 3778 #include <morphcolor_vertex> 3779 #include <batching_vertex> 3780 #include <beginnormal_vertex> 3781 #include <morphnormal_vertex> 3782 #include <skinbase_vertex> 3783 #include <skinnormal_vertex> 3784 #include <defaultnormal_vertex> 3785 #include <normal_vertex> 3786 #include <begin_vertex> 3787 #include <morphtarget_vertex> 3788 #include <skinning_vertex> 3789 #include <displacementmap_vertex> 3790 #include <project_vertex> 3791 #include <logdepthbuf_vertex> 3792 #include <clipping_planes_vertex> 3793 vViewPosition = - mvPosition.xyz; 3794 #include <worldpos_vertex> 3795 #include <shadowmap_vertex> 3796 #include <fog_vertex> 3797}`,fragment$4=`#define TOON 3798uniform vec3 diffuse; 3799uniform vec3 emissive; 3800uniform float opacity; 3801#include <common> 3802#include <dithering_pars_fragment> 3803#include <color_pars_fragment> 3804#include <uv_pars_fragment> 3805#include <map_pars_fragment> 3806#include <alphamap_pars_fragment> 3807#include <alphatest_pars_fragment> 3808#include <alphahash_pars_fragment> 3809#include <aomap_pars_fragment> 3810#include <lightmap_pars_fragment> 3811#include <emissivemap_pars_fragment> 3812#include <gradientmap_pars_fragment> 3813#include <fog_pars_fragment> 3814#include <bsdfs> 3815#include <lights_pars_begin> 3816#include <normal_pars_fragment> 3817#include <lights_toon_pars_fragment> 3818#include <shadowmap_pars_fragment> 3819#include <bumpmap_pars_fragment> 3820#include <normalmap_pars_fragment> 3821#include <logdepthbuf_pars_fragment> 3822#include <clipping_planes_pars_fragment> 3823void main() { 3824 vec4 diffuseColor = vec4( diffuse, opacity ); 3825 #include <clipping_planes_fragment> 3826 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3827 vec3 totalEmissiveRadiance = emissive; 3828 #include <logdepthbuf_fragment> 3829 #include <map_fragment> 3830 #include <color_fragment> 3831 #include <alphamap_fragment> 3832 #include <alphatest_fragment> 3833 #include <alphahash_fragment> 3834 #include <normal_fragment_begin> 3835 #include <normal_fragment_maps> 3836 #include <emissivemap_fragment> 3837 #include <lights_toon_fragment> 3838 #include <lights_fragment_begin> 3839 #include <lights_fragment_maps> 3840 #include <lights_fragment_end> 3841 #include <aomap_fragment> 3842 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3843 #include <opaque_fragment> 3844 #include <tonemapping_fragment> 3845 #include <colorspace_fragment> 3846 #include <fog_fragment> 3847 #include <premultiplied_alpha_fragment> 3848 #include <dithering_fragment> 3849}`,vertex$3=`uniform float size; 3850uniform float scale; 3851#include <common> 3852#include <color_pars_vertex> 3853#include <fog_pars_vertex> 3854#include <morphtarget_pars_vertex> 3855#include <logdepthbuf_pars_vertex> 3856#include <clipping_planes_pars_vertex> 3857#ifdef USE_POINTS_UV 3858 varying vec2 vUv; 3859 uniform mat3 uvTransform; 3860#endif 3861void main() { 3862 #ifdef USE_POINTS_UV 3863 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 3864 #endif 3865 #include <color_vertex> 3866 #include <morphinstance_vertex> 3867 #include <morphcolor_vertex> 3868 #include <begin_vertex> 3869 #include <morphtarget_vertex> 3870 #include <project_vertex> 3871 gl_PointSize = size; 3872 #ifdef USE_SIZEATTENUATION 3873 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3874 if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); 3875 #endif 3876 #include <logdepthbuf_vertex> 3877 #include <clipping_planes_vertex> 3878 #include <worldpos_vertex> 3879 #include <fog_vertex> 3880}`,fragment$3=`uniform vec3 diffuse; 3881uniform float opacity; 3882#include <common> 3883#include <color_pars_fragment> 3884#include <map_particle_pars_fragment> 3885#include <alphatest_pars_fragment> 3886#include <alphahash_pars_fragment> 3887#include <fog_pars_fragment> 3888#include <logdepthbuf_pars_fragment> 3889#include <clipping_planes_pars_fragment> 3890void main() { 3891 vec4 diffuseColor = vec4( diffuse, opacity ); 3892 #include <clipping_planes_fragment> 3893 vec3 outgoingLight = vec3( 0.0 ); 3894 #include <logdepthbuf_fragment> 3895 #include <map_particle_fragment> 3896 #include <color_fragment> 3897 #include <alphatest_fragment> 3898 #include <alphahash_fragment> 3899 outgoingLight = diffuseColor.rgb; 3900 #include <opaque_fragment> 3901 #include <tonemapping_fragment> 3902 #include <colorspace_fragment> 3903 #include <fog_fragment> 3904 #include <premultiplied_alpha_fragment> 3905}`,vertex$2=`#include <common> 3906#include <batching_pars_vertex> 3907#include <fog_pars_vertex> 3908#include <morphtarget_pars_vertex> 3909#include <skinning_pars_vertex> 3910#include <logdepthbuf_pars_vertex> 3911#include <shadowmap_pars_vertex> 3912void main() { 3913 #include <batching_vertex> 3914 #include <beginnormal_vertex> 3915 #include <morphinstance_vertex> 3916 #include <morphnormal_vertex> 3917 #include <skinbase_vertex> 3918 #include <skinnormal_vertex> 3919 #include <defaultnormal_vertex> 3920 #include <begin_vertex> 3921 #include <morphtarget_vertex> 3922 #include <skinning_vertex> 3923 #include <project_vertex> 3924 #include <logdepthbuf_vertex> 3925 #include <worldpos_vertex> 3926 #include <shadowmap_vertex> 3927 #include <fog_vertex> 3928}`,fragment$2=`uniform vec3 color; 3929uniform float opacity; 3930#include <common> 3931#include <fog_pars_fragment> 3932#include <bsdfs> 3933#include <lights_pars_begin> 3934#include <logdepthbuf_pars_fragment> 3935#include <shadowmap_pars_fragment> 3936#include <shadowmask_pars_fragment> 3937void main() { 3938 #include <logdepthbuf_fragment> 3939 gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 3940 #include <tonemapping_fragment> 3941 #include <colorspace_fragment> 3942 #include <fog_fragment> 3943}`,vertex$1=`uniform float rotation; 3944uniform vec2 center; 3945#include <common> 3946#include <uv_pars_vertex> 3947#include <fog_pars_vertex> 3948#include <logdepthbuf_pars_vertex> 3949#include <clipping_planes_pars_vertex> 3950void main() { 3951 #include <uv_vertex> 3952 vec4 mvPosition = modelViewMatrix[ 3 ]; 3953 vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); 3954 #ifndef USE_SIZEATTENUATION 3955 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3956 if ( isPerspective ) scale *= - mvPosition.z; 3957 #endif 3958 vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; 3959 vec2 rotatedPosition; 3960 rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; 3961 rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; 3962 mvPosition.xy += rotatedPosition; 3963 gl_Position = projectionMatrix * mvPosition; 3964 #include <logdepthbuf_vertex> 3965 #include <clipping_planes_vertex> 3966 #include <fog_vertex> 3967}`,fragment$1=`uniform vec3 diffuse; 3968uniform float opacity; 3969#include <common> 3970#include <uv_pars_fragment> 3971#include <map_pars_fragment> 3972#include <alphamap_pars_fragment> 3973#include <alphatest_pars_fragment> 3974#include <alphahash_pars_fragment> 3975#include <fog_pars_fragment> 3976#include <logdepthbuf_pars_fragment> 3977#include <clipping_planes_pars_fragment> 3978void main() { 3979 vec4 diffuseColor = vec4( diffuse, opacity ); 3980 #include <clipping_planes_fragment> 3981 vec3 outgoingLight = vec3( 0.0 ); 3982 #include <logdepthbuf_fragment> 3983 #include <map_fragment> 3984 #include <alphamap_fragment> 3985 #include <alphatest_fragment> 3986 #include <alphahash_fragment> 3987 outgoingLight = diffuseColor.rgb; 3988 #include <opaque_fragment> 3989 #include <tonemapping_fragment> 3990 #include <colorspace_fragment> 3991 #include <fog_fragment> 3992}`,ShaderChunk={alphahash_fragment,alphahash_pars_fragment,alphamap_fragment,alphamap_pars_fragment,alphatest_fragment,alphatest_pars_fragment,aomap_fragment,aomap_pars_fragment,batching_pars_vertex,batching_vertex,begin_vertex,beginnormal_vertex,bsdfs,iridescence_fragment,bumpmap_pars_fragment,clipping_planes_fragment,clipping_planes_pars_fragment,clipping_planes_pars_vertex,clipping_planes_vertex,color_fragment,color_pars_fragment,color_pars_vertex,color_vertex,common,cube_uv_reflection_fragment,defaultnormal_vertex,displacementmap_pars_vertex,displacementmap_vertex,emissivemap_fragment,emissivemap_pars_fragment,colorspace_fragment,colorspace_pars_fragment,envmap_fragment,envmap_common_pars_fragment,envmap_pars_fragment,envmap_pars_vertex,envmap_physical_pars_fragment,envmap_vertex,fog_vertex,fog_pars_vertex,fog_fragment,fog_pars_fragment,gradientmap_pars_fragment,lightmap_pars_fragment,lights_lambert_fragment,lights_lambert_pars_fragment,lights_pars_begin,lights_toon_fragment,lights_toon_pars_fragment,lights_phong_fragment,lights_phong_pars_fragment,lights_physical_fragment,lights_physical_pars_fragment,lights_fragment_begin,lights_fragment_maps,lights_fragment_end,logdepthbuf_fragment,logdepthbuf_pars_fragment,logdepthbuf_pars_vertex,logdepthbuf_vertex,map_fragment,map_pars_fragment,map_particle_fragment,map_particle_pars_fragment,metalnessmap_fragment,metalnessmap_pars_fragment,morphinstance_vertex,morphcolor_vertex,morphnormal_vertex,morphtarget_pars_vertex,morphtarget_vertex,normal_fragment_begin,normal_fragment_maps,normal_pars_fragment,normal_pars_vertex,normal_vertex,normalmap_pars_fragment,clearcoat_normal_fragment_begin,clearcoat_normal_fragment_maps,clearcoat_pars_fragment,iridescence_pars_fragment,opaque_fragment,packing,premultiplied_alpha_fragment,project_vertex,dithering_fragment,dithering_pars_fragment,roughnessmap_fragment,roughnessmap_pars_fragment,shadowmap_pars_fragment,shadowmap_pars_vertex,shadowmap_vertex,shadowmask_pars_fragment,skinbase_vertex,skinning_pars_vertex,skinning_vertex,skinnormal_vertex,specularmap_fragment,specularmap_pars_fragment,tonemapping_fragment,tonemapping_pars_fragment,transmission_fragment,transmission_pars_fragment,uv_pars_fragment,uv_pars_vertex,uv_vertex,worldpos_vertex,background_vert:vertex$h,background_frag:fragment$h,backgroundCube_vert:vertex$g,backgroundCube_frag:fragment$g,cube_vert:vertex$f,cube_frag:fragment$f,depth_vert:vertex$e,depth_frag:fragment$e,distance_vert:vertex$d,distance_frag:fragment$d,equirect_vert:vertex$c,equirect_frag:fragment$c,linedashed_vert:vertex$b,linedashed_frag:fragment$b,meshbasic_vert:vertex$a,meshbasic_frag:fragment$a,meshlambert_vert:vertex$9,meshlambert_frag:fragment$9,meshmatcap_vert:vertex$8,meshmatcap_frag:fragment$8,meshnormal_vert:vertex$7,meshnormal_frag:fragment$7,meshphong_vert:vertex$6,meshphong_frag:fragment$6,meshphysical_vert:vertex$5,meshphysical_frag:fragment$5,meshtoon_vert:vertex$4,meshtoon_frag:fragment$4,points_vert:vertex$3,points_frag:fragment$3,shadow_vert:vertex$2,shadow_frag:fragment$2,sprite_vert:vertex$1,sprite_frag:fragment$1},UniformsLib={common:{diffuse:{value:new Color(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Matrix3}},envmap:{envMap:{value:null},envMapRotation:{value:new Matrix3},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Matrix3},normalScale:{value:new Vector2(1,1)}}
vendor: 4,187 bytes, line 3992
3992,displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(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 Color(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}}},ShaderLib={basic:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.fog]),vertexShader:ShaderChunk.meshbasic_vert,fragmentShader:ShaderChunk.meshbasic_frag},lambert:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshlambert_vert,fragmentShader:ShaderChunk.meshlambert_frag},phong:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:ShaderChunk.meshphong_vert,fragmentShader:ShaderChunk.meshphong_frag},standard:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.roughnessmap,UniformsLib.metalnessmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},toon:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.gradientmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshtoon_vert,fragmentShader:ShaderChunk.meshtoon_frag},matcap:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,{matc
vendor: 5,764 bytes, line 3992
3992ap:{value:null}}]),vertexShader:ShaderChunk.meshmatcap_vert,fragmentShader:ShaderChunk.meshmatcap_frag},points:{uniforms:mergeUniforms([UniformsLib.points,UniformsLib.fog]),vertexShader:ShaderChunk.points_vert,fragmentShader:ShaderChunk.points_frag},dashed:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ShaderChunk.linedashed_vert,fragmentShader:ShaderChunk.linedashed_frag},depth:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap]),vertexShader:ShaderChunk.depth_vert,fragmentShader:ShaderChunk.depth_frag},normal:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.meshnormal_vert,fragmentShader:ShaderChunk.meshnormal_frag},sprite:{uniforms:mergeUniforms([UniformsLib.sprite,UniformsLib.fog]),vertexShader:ShaderChunk.sprite_vert,fragmentShader:ShaderChunk.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ShaderChunk.background_vert,fragmentShader:ShaderChunk.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Matrix3}},vertexShader:ShaderChunk.backgroundCube_vert,fragmentShader:ShaderChunk.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ShaderChunk.cube_vert,fragmentShader:ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ShaderChunk.equirect_vert,fragmentShader:ShaderChunk.equirect_frag},distance:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap,{referencePosition:{value:new Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ShaderChunk.distance_vert,fragmentShader:ShaderChunk.distance_frag},shadow:{uniforms:mergeUniforms([UniformsLib.lights,UniformsLib.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:ShaderChunk.shadow_vert,fragmentShader:ShaderChunk.shadow_frag}},ShaderLib.physical={uniforms:mergeUniforms([ShaderLib.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Matrix3},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Matrix3},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Matrix3},sheen:{value:0},sheenColor:{value:new Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Matrix3},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new Color(0)},specularColor:{value:new Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Matrix3},anisotropyVector:{value:new Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Matrix3}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},toneMappingMap={[LinearToneMapping]:"LINEAR_TONE_MAPPING",[ReinhardToneMapping]:"REINHARD_TONE_MAPPING",[CineonToneMapping]:"CINEON_TONE_MAPPING",[ACESFilmicToneMapping]:"ACES_FILMIC_TONE_MAPPING",[AgXToneMapping]:"AGX_TONE_MAPPING",[NeutralToneMapping]:"NEUTRAL_TONE_MAPPING",[CustomToneMapping]:"CUSTOM_TONE_MAPPING"},mat4array=new Float32Array(16),mat3array=new Float32Array(9),mat2array=new Float32Array(4),toneMappingFunctions={[LinearToneMapping]:"Linear",[ReinhardToneMapping]:"Reinhard",[CineonToneMapping]:"Cineon",[ACESFilmicToneMapping]:"ACESFilmic",[AgXToneMapping]:"AgX",[NeutralToneMapping]:"Neutral",[CustomToneMapping]:"Custom"},shaderChunkMap=new Map,shadowMapTypeDefines={[PCFShadowMap]:"SHADOWMAP_TYPE_PCF",[VSMShadowMap]:"SHADOWMAP_TYPE_VSM"},envMapTypeDefines={[CubeReflectionMapping]:"ENVMAP_TYPE_CUBE",[CubeRefractionMapping]:"ENVMAP_TYPE_CUBE",[CubeUVReflectionMapping]:"ENVMAP_TYPE_CUBE_UV"},envMapModeDefines={[CubeRefractionMapping]:"ENVMAP_MODE_REFRACTION"},envMapBlendingDefines={[MultiplyOperation]:"ENVMAP_BLENDING_MULTIPLY",[MixOperation]:"ENVMAP_BLENDING_MIX",[AddOperation]:"ENVMAP_BLENDING_ADD"},reversedFuncs={[NeverDepth]:AlwaysDepth,[LessDepth]:GreaterDepth,[EqualDepth]:NotEqualDepth,[LessEqualDepth]:GreaterEqualDepth,[AlwaysDepth]:NeverDepth,[GreaterDepth]:LessDepth,[NotEqualDepth]:EqualDepth,[GreaterEqualDepth]:LessEqualDepth},DATA2=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10
vendor: 24,758 bytes, line 3992
3992751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),_changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"},_ray2=new Ray,_plane2=new Plane,_TILT_LIMIT=Math.cos(70*MathUtils.DEG2RAD),_v=new Vector3,_twoPI=2*Math.PI,_STATE={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_EPS=1e-6;class OrbitControls extends Controls{constructor(e,t=null){super(e,t),this.state=_STATE.NONE,this.target=new Vector3,this.cursor=new Vector3,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:MOUSE.ROTATE,MIDDLE:MOUSE.DOLLY,RIGHT:MOUSE.PAN},this.touches={ONE:TOUCH.ROTATE,TWO:TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Vector3,this._lastQuaternion=new Quaternion,this._lastTargetPosition=new Vector3,this._quat=(new Quaternion).setFromUnitVectors(e.up,new Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Spherical,this._sphericalDelta=new Spherical,this._scale=1,this._panOffset=new Vector3,this._rotateStart=new Vector2,this._rotateEnd=new Vector2,this._rotateDelta=new Vector2,this._panStart=new Vector2,this._panEnd=new Vector2,this._panDelta=new Vector2,this._dollyStart=new Vector2,this._dollyEnd=new Vector2,this._dollyDelta=new Vector2,this._dollyDirection=new Vector3,this._mouse=new Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=onPointerMove.bind(this),this._onPointerDown=onPointerDown.bind(this),this._onPointerUp=onPointerUp.bind(this),this._onContextMenu=onContextMenu.bind(this),this._onMouseWheel=onMouseWheel.bind(this),this._onKeyDown=onKeyDown.bind(this),this._onTouchStart=onTouchStart.bind(this),this._onTouchMove=onTouchMove.bind(this),this._onMouseDown=onMouseDown.bind(this),this._onMouseMove=onMouseMove.bind(this),this._interceptControlDown=interceptControlDown.bind(this),this._interceptControlUp=interceptControlUp.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});const t=this.domElement.getRootNode();t.addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();const e=this.domElement.getRootNode();e.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(_changeEvent),this.update(),this.state=_STATE.NONE}update(e=null){const o=this.object.position;_v.copy(o).sub(this.target),_v.applyQuaternion(this._quat),this._spherical.setFromVector3(_v),this.autoRotate&&this.state===_STATE.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 t=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(t)&&isFinite(n)&&(t<-Math.PI?t+=_twoPI:t>Math.PI&&(t-=_twoPI),n<-Math.PI?n+=_twoPI:n>Math.PI&&(n-=_twoPI),t<=n?this._spherical.theta=Math.max(t,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(t+n)/2?Math.max(t,this._spherical.theta):Math.min(n,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{const e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=e!=this._spherical.radius}if(_v.setFromSpherical(this._spherical),_v.applyQuaternion(this._quatInverse),o.copy(this.target).add(_v),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 e=null;if(this.object.isPerspectiveCamera){const t=_v.length();e=this._clampDistance(t*this._scale);const n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),s=!!n}else if(this.object.isOrthographicCamera){const t=new Vector3(this._mouse.x,this._mouse.y,0);t.unproject(this.object);const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=o!==this.object.zoom;const n=new Vector3(this._mouse.x,this._mouse.y,0);n.unproject(this.object),this.object.position.sub(n).add(t),this.object.updateMatrixWorld(),e=_v.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(_ray2.origin.copy(this.object.position),_ray2.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_ray2.direction))<_TILT_LIMIT?this.object.lookAt(this.target):(_plane2.setFromNormalAndCoplanarPoint(this.object.up,this.target),_ray2.intersectPlane(_plane2,this.target))))}else if(this.object.isOrthographicCamera){const e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,!!(s||this._lastPosition.distanceToSquared(this.object.position)>_EPS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_EPS||this._lastTargetPosition.distanceToSquared(this.target)>_EPS)&&(this.dispatchEvent(_changeEvent),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(e){return e!==null?_twoPI/60*this.autoRotateSpeed*e:_twoPI/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return.95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_v.setFromMatrixColumn(t,0),_v.multiplyScalar(-e),this._panOffset.add(_v)}_panUp(e,t){this.screenSpacePanning===!0?_v.setFromMatrixColumn(t,1):(_v.setFromMatrixColumn(t,0),_v.crossVectors(this.object.up,_v)),_v.multiplyScalar(e),this._panOffset.add(_v)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const o=this.object.position;_v.copy(o).sub(this.target);let s=_v.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;const n=this.domElement.getBoundingClientRect(),s=e-n.left,o=t-n.top,i=n.width,a=n.height;this._mouse.x=s/i*2-1,this._mouse.y=-(o/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);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*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(_twoPI*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(-_twoPI*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(_twoPI*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(-_twoPI*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{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=(n*n+s*s)**.5;this._dollyStart.set(0,o)}_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{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateEnd.set(n,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*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{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}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){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=(n*n+s*s)**.5;this._dollyEnd.set(0,o),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const i=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(i,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<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===0[0]&&(t=new Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const n=e.deltaMode,t={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:t.deltaY*=16;break;case 2:t.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(t.deltaY*=10),t}}function onPointerDown(e){if(this.enabled===!1)return;if(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(e))return;this._addPointer(e),e.pointerType==="touch"?this._onTouchStart(e):this._onMouseDown(e)}function onPointerMove(e){if(this.enabled===!1)return;e.pointerType==="touch"?this._onTouchMove(e):this._onMouseMove(e)}function onPointerUp(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(_endEvent),this.state=_STATE.NONE;break;case 1:const t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function onMouseDown(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=_STATE.DOLLY;break;case MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=_STATE.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=_STATE.ROTATE}break;case MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=_STATE.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=_STATE.PAN}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onMouseMove(e){switch(this.state){case _STATE.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case _STATE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case _STATE.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function onMouseWheel(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==_STATE.NONE)return;e.preventDefault(),this.dispatchEvent(_startEvent),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(_endEvent)}function onKeyDown(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function onTouchStart(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=_STATE.TOUCH_ROTATE;break;case TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=_STATE.TOUCH_PAN;break;default:this.state=_STATE.NONE}break;case 2:switch(this.touches.TWO){case TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=_STATE.TOUCH_DOLLY_PAN;break;case TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=_STATE.TOUCH_DOLLY_ROTATE;break;default:this.state=_STATE.NONE}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onTouchMove(e){switch(this._trackPointer(e),this.state){case _STATE.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case _STATE.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case _STATE.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case _STATE.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=_STATE.NONE}}function onContextMenu(e){if(this.enabled===!1)return;e.preventDefault()}function interceptControlDown(e){if(e.key==="Control"){this._controlActive=!0;const e=this.domElement.getRootNode();e.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}function interceptControlUp(e){if(e.key==="Control"){this._controlActive=!1;const e=this.domElement.getRootNode();e.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}MeshoptDecoder=function(){var e,t,s,o,i,a,c,d="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q:Odkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq;w8Wqdbk;esezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9Uc;WFbGgocjdaocjd6EhDaicefhocbhqdnindndndnaeaq9nmbaDaeaq9RaqaDfae6Egkcsfglcl4cifcd4hxalc9WGgmTmecbhPawcjdfhsaohzinaraz9Rax6mvarazaxfgo9RcK6mvczhlcbhHinalgic9WfgOawcj;cbffhldndndndndnazaOco4fRbbaHcoG4ciGPlbedibkal9cb83ibalcwf9cb83ibxikalaoRblaoRbbgOco4gAaAciSgAE86bbawcj;cbfaifglcGfaoclfaAfgARbbaOcl4ciGgCaCciSgCE86bbalcVfaAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc7faAaCfgARbbaOciGgOaOciSgOE86bbalctfaAaOfgARbbaoRbegOco4gCaCciSgCE86bbalc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc93faAaCfgARbbaOciGgOaOciSgOE86bbalc94faAaOfgARbbaoRbdgOco4gCaCciSgCE86bbalc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc97faAaCfgARbbaOciGgOaOciSgOE86bbalc98faAaOfgORbbaoRbigoco4gAaAciSgAE86bbalc99faOaAfgORbbaocl4ciGgAaAciSgAE86bbalc9:faOaAfgORbbaocd4ciGgAaAciSgAE86bbalcufaOaAfglRbbaociGgoaociSgoE86bbalaofhoxdkalaoRbwaoRbbgOcl4gAaAcsSgAE86bbawcj;cbfaifglcGfaocwfaAfgARbbaOcsGgOaOcsSgOE86bbalcVfaAaOfgORbbaoRbegAcl4gCaCcsSgCE86bbalc7faOaCfgORbbaAcsGgAaAcsSgAE86bbalctfaOaAfgORbbaoRbdgAcl4gCaCcsSgCE86bbalc91faOaCfgORbbaAcsGgAaAcsSgAE86bbalc4faOaAfgORbbaoRbigAcl4gCaCcsSgCE86bbalc93faOaCfgORbbaAcsGgAaAcsSgAE86bbalc94faOaAfgORbbaoRblgAcl4gCaCcsSgCE86bbalc95faOaCfgORbbaAcsGgAaAcsSgAE86bbalc96faOaAfgORbbaoRbvgAcl4gCaCcsSgCE86bbalc97faOaCfgORbbaAcsGgAaAcsSgAE86bbalc98faOaAfgORbbaoRbogAcl4gCaCcsSgCE86bbalc99faOaCfgORbbaAcsGgAaAcsSgAE86bbalc9:faOaAfgORbbaoRbrgocl4gAaAcsSgAE86bbalcufaOaAfglRbbaocsGgoaocsSgoE86bbalaofhoxekalao8Pbb83bbalcwfaocwf8Pbb83bbaoczfhokdnaiam9pmbaHcdfhHaiczfhlarao9RcL0mekkaiam6mvaoTmvdnakTmbawaPfRbbhHawcj;cbfhlashiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkkascefhsaohzaPcefgPad9hmbxikkcbc99arao9Radcaadca0ESEhoxlkaoaxad2fhCdnakmbadhlinaoTmlarao9Rax6mlaoaxfhoalcufglmbkaChoxekcbhmawcjdfhAinarao9Rax6miawamfRbbhH
3992awcj;cbfhlaAhiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkaAcefhAaoaxfhoamcefgmad9hmbkaChokabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqaombkc9:hoxekc9:hokavcj;ebf8Kjjjjbaok;cseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;oiliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabaiavcefciGfcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavciGfgkcd7cetfaD87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavcufciGfcetfaD87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohvxekcjjjj94hvkabakcetfav87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklzNbb",m
vendor: 11,850 bytes, line 3992
3992="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q:6dkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq:p9sqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:N8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhlaicefhodnaeTmbadTmbalc;WFbGglcjdalcjd6EhwcbhDinawaeaD9RaDawfae6Egqcsfglc9WGgkci2hxakcethmalcl4cifcd4hPabaDad2fhsakc;ab6hzcbhHincbhOaohAdndninaraA9RaP6meavcj;cbfaOak2fhCaAaPfhocbhidnazmbarao9Rc;Gb6mbcbhlinaCalfhidndndndndnaAalco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklbaoczfhokdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklzaoczfhokdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklaaoczfhokdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaoclfaYpQbfaXc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaocwfaYpQbfaXc:q:yjjbfRbbfhoxekaiaopbbbpkl8Waoczfhokalc;abfhialcjefak0meaihlarao9Rc;Fb0mbkkdnaiak9pmbaici4hlinarao9RcK6miaCaifhXdndndndndnaAaico4fRbbalcoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpkbbxikaXaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaXaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaXaopbbbpkbbaoczfhokalcdfhlaiczfgiak6mbkkaoTmeaohAaOcefgOclSmdxbkkc9:hoxlkdnakTmbavcjdfaHfhiavaHfpbdbhYcbhXinaiavcj;cbfaXfglpblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLalakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEalamfpblbg3cep9Ta3aQp9op9Hp9rg3alaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfhiaXczfgXak6mbkkaHclfgHad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfgDae6mbkkcbc99arao9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk::seHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:wPliuo97eue978Jjjjjbca9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskdnalTmbcbhvabhdinadczfgxaxpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiaeciGgvcitgdfcbcaad9R;8kbaiabalcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaialciGgecdtgdVcbc;abad9R;8kbaiabavcdtfgvad;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkavaiad;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb",
3992h=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),u=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};i=r(WebAssembly.validate(h)?m:d),a=WebAssembly.instantiate(i,{}).then(function(t){e=t.instance,e.exports.__wasm_call_ctors()});function r(e){for(var s,o,n=new Uint8Array(e.length),t=0;t<e.length;++t)s=e.charCodeAt(t),n[t]=s>96?s-97:s>64?s-39:s+4;for(o=0,t=0;t<e.length;++t)n[o++]=n[t]<60?u[n[t]]:(n[t]-60)*64+n[++t];return n.buffer.slice(0,o)}function n(e,t,n,s,o,i,a){var l,c=e.exports.sbrk,d=s+3&~3,r=c(d*o),u=c(i.length),h=new Uint8Array(e.exports.memory.buffer);if(h.set(i,u),l=t(r,s,o,u,i.length),l==0&&a&&a(r,d,o),n.set(h.subarray(r,r+s*o)),c(r-c(0)),l!=0)throw new Error("Malformed buffer data: "+l)}s={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},o={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},t=[],c=0;function f(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function p(e){for(var a="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+l.name+";"+n.toString()+l.toString(),r=new Blob([a],{type:"text/javascript"}),o=URL.createObjectURL(r),s=t.length;s<e;++s)t[s]=f(o);for(s=e;s<t.length;++s)t[s].object.postMessage({});t.length=e,URL.revokeObjectURL(o)}function g(e,n,s,o,i){for(var a=t[0],r=1;r<t.length;++r)t[r].pending<a.pending&&(a=t[r]);return new Promise(function(t,r){var l=new Uint8Array(s),d=++c;a.pending+=e,a.requests[d]={resolve:t,reject:r},a.object.postMessage({id:d,count:e,size:n,source:l,mode:o,filter:i},[l.buffer])})}function l(e){var t=e.data;if(!t.id)return self.close();self.ready.then(function(e){try{var s=new Uint8Array(t.count*t.size);n(e,e.exports[t.mode],s,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:s},[s.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}})}return{ready:a,supported:!0,useWorkers:function(e){p(e)},decodeVertexBuffer:function(t,o,i,a,r){n(e,e.exports.meshopt_decodeVertexBuffer,t,o,i,a,e.exports[s[r]])},decodeIndexBuffer:function(t,s,o,i){n(e,e.exports.meshopt_decodeIndexBuffer,t,s,o,i)},decodeIndexSequence:function(t,s,o,i){n(e,e.exports.meshopt_decodeIndexSequence,t,s,o,i)},decodeGltfBuffer:function(t,i,a,r,c,l){n(e,e.exports[o[c]],t,i,a,r,e.exports[s[l]])},decodeGltfBufferAsync:function(i,r,c,l,d){return t.length>0?g(i,r,c,o[l],s[d]):a.then(function(){var t=new Uint8Array(i*r);return n(e,e.exports[o[l]],t,i,r,c,e.exports[s[d]]),t})}}}();function toTrianglesDrawMode(e,t){if(t===TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===TriangleFanDrawMode||t===TriangleStripDrawMode){let n=e.getIndex();if(n===null){const t=[],s=e.getAttribute("position");if(s!==0[0]){for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}const o=n.count-2,s=[];if(t===TriangleFanDrawMode)for(let e=1;e<=o;e++)s.push(n.getX(0)),s.push(n.getX(e)),s.push(n.getX(e+1));else for(let e=0;e<o;e++)e%2===0?(s.push(n.getX(e)),s.push(n.getX(e+1)),s.push(n.getX(e+2))):(s.push(n.getX(e+2)),s.push(n.getX(e+1)),s.push(n.getX(e)));s.length/3!==o&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=e.clone();return i.setIndex(s),i.clearGroups(),i}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new GLTFMaterialsClearcoatExtension(e)}),this.register(function(e){return new GLTFMaterialsDispersionExtension(e)}),this.register(function(e){return new GLTFTextureBasisUExtension(e)}),this.register(function(e){return new GLTFTextureWebPExtension(e)}),this.register(function(e){return new GLTFTextureAVIFExtension(e)}),this.register(function(e){return new GLTFMaterialsSheenExtension(e)}),this.register(function(e){return new GLTFMaterialsTransmissionExtension(e)}),this.register(function(e){return new GLTFMaterialsVolumeExtension(e)}
vendor: 11,881 bytes, line 3992
3992),this.register(function(e){return new GLTFMaterialsIorExtension(e)}),this.register(function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)}),this.register(function(e){return new GLTFMaterialsSpecularExtension(e)}),this.register(function(e){return new GLTFMaterialsIridescenceExtension(e)}),this.register(function(e){return new GLTFMaterialsAnisotropyExtension(e)}),this.register(function(e){return new GLTFMaterialsBumpExtension(e)}),this.register(function(e){return new GLTFLightsExtension(e)}),this.register(function(e){return new GLTFMeshoptCompression(e)}),this.register(function(e){return new GLTFMeshGpuInstancing(e)})}load(e,t,n,s){const i=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const t=LoaderUtils.extractUrlBase(e);a=LoaderUtils.resolveURL(t,this.path)}else a=LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const r=function(t){s?s(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},r)}catch(e){r(e)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let o;const i={},r={},c=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer){const t=c.decode(new Uint8Array(e,0,4));if(t===BINARY_EXTENSION_HEADER_MAGIC){try{i[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){s&&s(e);return}o=JSON.parse(i[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e))}else o=e;if(o.asset===0[0]||o.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new GLTFParser(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](a);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[e.name]=e,i[e.name]=!0}if(o.extensionsUsed)for(let t=0;t<o.extensionsUsed.length;++t){const e=o.extensionsUsed[t],n=o.extensionsRequired||[];switch(e){case EXTENSIONS.KHR_MATERIALS_UNLIT:i[e]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:i[e]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:i[e]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:i[e]=new GLTFMeshQuantizationExtension;break;default:n.indexOf(e)>=0&&r[e]===0[0]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}a.setExtensions(i),a.setPlugins(r),a.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,o){n.parse(e,t,s,o)})}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}EXTENSIONS={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"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,o=e.length;s<o;s++){const n=e[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==0[0]&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const o=this.parser,a="light:"+e;let s=o.cache.get(a);if(s)return s;const r=o.json,l=r.extensions&&r.extensions[this.name]||{},d=l.lights||[],t=d[e];let n;const i=new Color(16777215);t.color!==0[0]&&i.setRGB(t.color[0],t.color[1],t.color[2],LinearSRGBColorSpace);const c=t.range!==0[0]?t.range:0;switch(t.type){case"directional":n=new DirectionalLight(i),n.target.position.set(0,0,-1),n.add(n.target);break;case"point":n=new PointLight(i),n.distance=c;break;case"spot":n=new SpotLight(i),n.distance=c,t.spot=t.spot||{},t.spot.innerConeAngle=t.spot.innerConeAngle!==0[0]?t.spot.innerConeAngle:0,t.spot.outerConeAngle=t.spot.outerConeAngle!==0[0]?t.spot.outerConeAngle:Math.PI/4,n.angle=t.spot.outerConeAngle,n.penumbra=1-t.spot.innerConeAngle/t.spot.outerConeAngle,n.target.position.set(0,0,-1),n.add(n.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+t.type)}return n.position.set(0,0,0),assignExtrasToUserData(n,t),t.intensity!==0[0]&&(n.intensity=t.intensity),n.name=o.createUniqueName(t.name||"light_"+e),s=Promise.resolve(n),o.cache.add(a,s),s}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){const o=this,n=this.parser,i=n.json,s=i.nodes[e],a=s.extensions&&s.extensions[this.name]||{},t=a.light;return t===0[0]?null:this._loadLight(t).then(function(e){return n._getNodeRef(o.cache,t,e)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],LinearSRGBColorSpace),e.opacity=t[3]}s.baseColorTexture!==0[0]&&o.push(n.assignTexture(e,"map",s.baseColorTexture,SRGBColorSpace))}return Promise.all(o)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const o=this.parser,n=o.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name].emissiveStrength;return s!==0[0]&&(t.emissiveIntensity=s),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],n=i.extensions[this.name];if(n.clearcoatFactor!==0[0]&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==0[0]&&o.push(s.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==0[0]&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==0[0]&&o.push(s.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==0[0]&&(o.push(s.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==0[0])){const e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Vector2(e,e)}return Promise.all(o)}}class GLTFMaterialsDispersionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,n=o.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.dispersion=s.dispersion!==0[0]?s.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,o=s.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const i=[],n=o.extensions[this.name];return n.iridescenceFactor!==0[0]&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==0[0]&&i.push(s.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==0[0]&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===0[0]&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==0[0]&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==0[0]&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==0[0]&&i.push(s.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,o=s.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const n=o.extensions[this.name];if(n.sheenColorFactor!==0[0]){const e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==0[0]&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==0[0]&&i.push(s.assignTexture(t,"sheenColorMap",n.sheenColorTexture,SRGBColorSpace)),n.sheenRoughnessTexture!==0[0]&&i.push(s.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],n=s.extensions[this.name];return n.transmissionFactor!==0[0]&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==0[0]&&i.push(o.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const a=[],n=s.extensions[this.name];t.thickness=n.thicknessFactor!==0[0]?n.thicknessFactor:0,n.thicknessTexture!==0[0]&&a.push(i.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const o=n.attenuationColor||[1,1,1];return t.attenuationColor=(new Color).setRGB(o[0],o[1],o[2],LinearSRGBColorSpace),Promise.all(a)}}
3992class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,n=o.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.ior=s.ior!==0[0]?s.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,o=s.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const i=[],n=o.extensions[this.name];t.specularIntensity=n.specularFactor!==0[0]?n.specularFactor:1,n.specularTexture!==0[0]&&i.push(s.assignTexture(t,"specularIntensityMap",n.specularTexture));const a=n.specularColorFactor||[1,1,1];return t.specularColor=(new Color).setRGB(a[0],a[1],a[2],LinearSRGBColorSpace),n.specularColorTexture!==0[0]&&i.push(s.assignTexture(t,"specularColorMap",n.specularColorTexture,SRGBColorSpace)),Promise.all(i)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],n=s.extensions[this.name];return t.bumpScale=n.bumpFactor!==0[0]?n.bumpFactor:1,n.bumpTexture!==0[0]&&i.push(o.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser,t=n.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],n=s.extensions[this.name];return n.anisotropyStrength!==0[0]&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==0[0]&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==0[0]&&i.push(o.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP}loadTexture(e){const s=this.name,t=this.parser,o=t.json,n=o.textures[e];if(!n.extensions||!n.extensions[s])return null;const i=n.extensions[s],a=o.images[i.source];let r=t.textureLoader;if(a.uri){const e=t.options.manager.getHandler(a.uri);e!==null&&(r=e)}return t.loadTextureImage(e,i.source,r)}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF}loadTexture(e){const s=this.name,t=this.parser,o=t.json,n=o.textures[e];if(!n.extensions||!n.extensions[s])return null;const i=n.extensions[s],a=o.images[i.source];let r=t.textureLoader;if(a.uri){const e=t.options.manager.getHandler(a.uri);e!==null&&(r=e)}return t.loadTextureImage(e,i.source,r)}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],o=this.parser.getDependency("buffer",e.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 o.then(function(t){const a=e.byteOffset||0,r=e.byteLength||0,n=e.count,o=e.byteStride,i=new Uint8Array(t,a,r);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(n,o,i,e.mode,e.filter).then(function(e){return e.buffer}):s.ready.then(function(){const t=new ArrayBuffer(n*o);return s.decodeGltfBuffer(new Uint8Array(t),n,o,i,e.mode,e.filter),t})})}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const o=this.parser.json,n=o.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===0[0])return null;const a=o.meshes[n.mesh];for(const e of a.primitives)if(e.mode!==WEBGL_CONSTANTS.TRIANGLES&&e.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&e.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&e.mode!==0[0])return null;const r=n.extensions[this.name],i=r.attributes,s=[],t={};for(const e in i)s.push(this.parser.getDependency("accessor",i[e]).then(n=>
vendor: 23,079 bytes, line 3992
3992(t[e]=n,t[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{const n=e.pop(),i=n.isGroup?n.children:[n],o=e[0].count,s=[];for(const n of i){const l=new Matrix4,a=new Vector3,r=new Quaternion,c=new Vector3(1,1,1),e=new InstancedMesh(n.geometry,n.material,o);for(let n=0;n<o;n++)t.TRANSLATION&&a.fromBufferAttribute(t.TRANSLATION,n),t.ROTATION&&r.fromBufferAttribute(t.ROTATION,n),t.SCALE&&c.fromBufferAttribute(t.SCALE,n),e.setMatrixAt(n,l.compose(a,r,c));for(const s in t)if(s==="_COLOR_0"){const n=t[s];e.instanceColor=new InstancedBufferAttribute(n.array,n.itemSize,n.normalized)}else s!=="TRANSLATION"&&s!=="ROTATION"&&s!=="SCALE"&&n.geometry.setAttribute(s,t[s]);Object3D.prototype.copy.call(e,n),this.parser.assignFinalMaterial(e),s.push(e)}return n.isGroup?(n.clear(),n.add(...s),n):s[0]}))}}BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let t=0;for(;t<i;){const n=o.getUint32(t,!0);t+=4;const i=o.getUint32(t,!0);if(t+=4,i===BINARY_EXTENSION_CHUNK_TYPES.JSON){const o=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+t,n);this.content=s.decode(o)}else if(i===BINARY_EXTENSION_CHUNK_TYPES.BIN){const s=BINARY_EXTENSION_HEADER_LENGTH+t;this.body=e.slice(s,s+n)}t+=n}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const a=this.json,r=this.dracoLoader,c=e.extensions[this.name].bufferView,n=e.extensions[this.name].attributes,s={},o={},i={};for(const e in n){const t=ATTRIBUTES[e]||e.toLowerCase();s[t]=n[e]}for(const t in e.attributes){const s=ATTRIBUTES[t]||t.toLowerCase();if(n[t]!==0[0]){const n=a.accessors[e.attributes[t]],r=WEBGL_COMPONENT_TYPES[n.componentType];i[s]=r.name,o[s]=n.normalized===!0}}return t.getDependency("bufferView",c).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const s=e.attributes[t],n=o[t];n!==0[0]&&(s.normalized=n)}t(e)},s,i,LinearSRGBColorSpace,n)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===0[0]||t.texCoord===e.channel)&&t.offset===0[0]&&t.rotation===0[0]&&t.scale===0[0]?e:(e=e.clone(),t.texCoord!==0[0]&&(e.channel=t.texCoord),t.offset!==0[0]&&e.offset.fromArray(t.offset),t.rotation!==0[0]&&(e.rotation=t.rotation),t.scale!==0[0]&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const n=this.resultBuffer,s=this.sampleValues,t=this.valueSize,o=e*t*3+t;for(let e=0;e!==t;e++)n[e]=s[o+e];return n}interpolate_(e,t,n,s){const h=this.resultBuffer,a=this.sampleValues,o=this.valueSize,g=o*2,d=o*3,l=s-t,i=(n-t)/l,r=i*i,u=r*i,c=e*d,m=c-d,f=-2*u+3*r,p=u-r,v=1-f,b=p-r+i;for(let e=0;e!==o;e++){const t=a[m+e+o],n=a[m+e+g]*l,s=a[c+e+o],i=a[c+e]*l;h[e]=v*t+b*n+f*s+p*i}return h}}_quaternion=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,s){const o=super.interpolate_(e,t,n,s);return _quaternion.fromArray(o).normalize().toArray(o),o}}WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:NearestFilter,9729:LinearFilter,9984:NearestMipmapNearestFilter,9985:LinearMipmapNearestFilter,9986:NearestMipmapLinearFilter,9987:LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:ClampToEdgeWrapping,33648:MirroredRepeatWrapping,10497:RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:0[0],LINEAR:InterpolateLinear,STEP:InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(e){return e.DefaultMaterial===0[0]&&(e.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:FrontSide})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,n){for(const s in n.extensions)e[s]===0[0]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=n.extensions[s])}function assignExtrasToUserData(e,t){t.extras!==0[0]&&(typeof t.extras=="object"?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function addMorphTargets(e,t,n){let s=!1,o=!1,i=!1;for(let e=0,a=t.length;e<a;e++){const n=t[e];if(n.POSITION!==0[0]&&(s=!0),n.NORMAL!==0[0]&&(o=!0),n.COLOR_0!==0[0]&&(i=!0),s&&o&&i)break}if(!s&&!o&&!i)return Promise.resolve(e);const a=[],r=[],c=[];for(let d=0,u=t.length;d<u;d++){const l=t[d];if(s){const t=l.POSITION!==0[0]?n.getDependency("accessor",l.POSITION):e.attributes.position;a.push(t)}if(o){const t=l.NORMAL!==0[0]?n.getDependency("accessor",l.NORMAL):e.attributes.normal;r.push(t)}if(i){const t=l.COLOR_0!==0[0]?n.getDependency("accessor",l.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(a),Promise.all(r),Promise.all(c)]).then(function(t){const n=t[0],a=t[1],r=t[2];return s&&(e.morphAttributes.position=n),o&&(e.morphAttributes.normal=a),i&&(e.morphAttributes.color=r),e.morphTargetsRelative=!0,e})}function updateMorphTargets(e,t){if(e.updateMorphTargets(),t.weights!==0[0])for(let n=0,s=t.weights.length;n<s;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,s=n.length;t<s;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const n=e.extensions&&e.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?t="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):t=e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,e.targets!==0[0])for(let n=0,s=e.targets.length;n<s;n++)t+=":"+createAttributesKey(e.targets[n]);return t}function createAttributesKey(e){let n="";const t=Object.keys(e).sort();for(let s=0,o=t.length;s<o;s++)n+=t[s]+":"+e[t[s]]+";";return n}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data:image\/jpeg/)===0?"image/jpeg":e.search(/\.webp($|\?)/i)>0||e.search(/^data:image\/webp/)===0?"image/webp":e.search(/\.ktx2($|\?)/i)>0||e.search(/^data:image\/ktx2/)===0?"image/ktx2":"image/png"}_identityMatrix2=new Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,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,o=-1,s=!1,i=-1;if(typeof navigator!="undefined"){const e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;const t=e.match(/Version\/(\d+)/);o=n&&t?parseInt(t[1],10):-1,s=e.indexOf("Firefox")>-1,i=s?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap=="undefined"||n&&o<17||s&&i<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){const i={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:n,userData:{}};return addUnknownExtensionsToUserData(o,i,s),assignExtrasToUserData(i,s),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const s=t[n].joints;for(let t=0,n=s.length;t<n;t++)e[s[t]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const t=e[s];t.mesh!==0[0]&&(this._addNodeRef(this.meshCache,t.mesh),t.skin!==0[0]&&(n[t.mesh].isSkinnedMesh=!0)),t.camera!==0[0]&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){if(t===0[0])return;e.refs[t]===0[0]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),o=(e,t)=>{const n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(const[n,s]of e.children.entries())o(s,t.children[n])};return o(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&n.push(o)}return n}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(t,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===0[0]&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(e,o){n.load(LoaderUtils.resolveURL(t.uri,s.path),e,0[0],function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)})}loadAccessor(e){const s=this,o=this.json,t=this.json.accessors[e];if(t.bufferView===0[0]&&t.sparse===0[0]){const e=WEBGL_TYPE_SIZES[t.type],n=WEBGL_COMPONENT_TYPES[t.componentType],s=t.normalized===!0,o=new n(t.count*e);return Promise.resolve(new BufferAttribute(o,e,s))}const n=[];return t.bufferView!==0[0]?n.push(this.getDependency("bufferView",t.bufferView)):n.push(null),t.sparse!==0[0]&&(n.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(n).then(function(e){const l=e[0],n=WEBGL_TYPE_SIZES[t.type],r=WEBGL_COMPONENT_TYPES[t.componentType],d=r.BYTES_PER_ELEMENT,m=d*n,u=t.byteOffset||0,a=t.bufferView!==0[0]?o.bufferViews[t.bufferView].byteStride:0[0],h=t.normalized===!0;let c,i;if(a&&a!==m){const o=Math.floor(u/a),m="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+o+":"+t.count;let e=s.cache.get(m);e||(c=new r(l,o*a,t.count*a/d),e=new InterleavedBuffer(c,a/d),s.cache.add(m,e)),i=new InterleavedBufferAttribute(e,n,u%a/d,h)}else l===null?c=new r(t.count*n):c=new r(l,u,t.count*n),i=new BufferAttribute(c,n,h);if(t.sparse!==0[0]){const a=WEBGL_TYPE_SIZES.SCALAR,c=WEBGL_COMPONENT_TYPES[t.sparse.indices.componentType],d=t.sparse.indices.byteOffset||0,u=t.sparse.values.byteOffset||0,o=new c(e[1],d,t.sparse.count*a),s=new r(e[2],u,t.sparse.count*n);l!==null&&(i=new BufferAttribute(i.array.slice(),i.itemSize,i.normalized)),i.normalized=!1;for(let e=0,a=o.length;e<a;e++){const t=o[e];if(i.setX(t,s[e*n]),n>=2&&i.setY(t,s[e*n+1]),n>=3&&i.setZ(t,s[e*n+2]),n>=4&&i.setW(t,s[e*n+3]),n>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}i.normalized=h}return i})}loadTexture(e){const t=this.json,i=this.options,a=t.textures[e],n=a.source,s=t.images[n];let o=this.textureLoader;if(s.uri){const e=i.manager.getHandler(s.uri);e!==null&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,n){const c=this,o=this.json,i=o.textures[e],s=o.images[t],a=(s.uri||s.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const r=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=i.name||s.name||"",t.name===""&&typeof s.uri=="string"&&s.uri.startsWith("data:image/")===!1&&(t.name=s.uri);const a=o.samplers||{},n=a[i.sampler]||{};return t.magFilter=WEBGL_FILTERS[n.magFilter]||LinearFilter,t.minFilter=WEBGL_FILTERS[n.minFilter]||LinearMipmapLinearFilter,t.wrapS=WEBGL_WRAPPINGS[n.wrapS]||RepeatWrapping,t.wrapT=WEBGL_WRAPPINGS[n.wrapT]||RepeatWrapping,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==NearestFilter&&t.minFilter!==LinearFilter,c.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=r,r}loadImageSource(e,t){const r=this,c=this.json,l=this.options;if(this.sourceCache[e]!==0[0])return this.sourceCache[e].then(e=>e.clone());const n=c.images[e],o=self.URL||self.webkitURL;let s=n.uri||"",i=!1;if(n.bufferView!==0[0])s=r.getDependency("bufferView",n.bufferView).then(function(e){i=!0;const t=new Blob([e],{type:n.mimeType});return s=o.createObjectURL(t),s});else if(n.uri===0[0])throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const a=Promise.resolve(s).then(function(e){return new Promise(function(n,s){let o=n;t.isImageBitmapLoader===!0&&(o=function(e){const t=new Texture(e);t.needsUpdate=!0,n(t)}),t.load(LoaderUtils.resolveURL(e,l.path),o,0[0],s)})}).then(function(e){return i===!0&&o.revokeObjectURL(s),assignExtrasToUserData(e,n),e.userData.mimeType=n.mimeType||getImageURIMimeType(n.uri),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e});return this.sourceCache[e]=a,a}assignTexture(e,t,n,s){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==0[0]&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const e=n.extensions!==0[0]?n.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:0[0];if(e){const t=o.associations.get(i);i=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),o.associations.set(i,t)}}return s!==0[0]&&(i.colorSpace=s),e[t]=i,i})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const s=n.attributes.tangent===0[0],o=n.attributes.color!==0[0],i=n.attributes.normal===0[0];if(e.isPoints){const n="PointsMaterial:"+t.uuid;let e=this.cache.get(n);e||(e=new PointsMaterial,Material.prototype.copy.call(e,t),e.color.copy(t.color),e.map=t.map,e.sizeAttenuation=!1,this.cache.add(n,e)),t=e}else if(e.isLine){const n="LineBasicMaterial:"+t.uuid;let e=this.cache.get(n);e||(e=new LineBasicMaterial,Material.prototype.copy.call(e,t),e.color.copy(t.color),e.map=t.map,this.cache.add(n,e)),t=e}if(s||o||i){let n="ClonedMaterial:"+t.uuid+":";s&&(n+="derivative-tangents:"),o&&(n+="vertex-colors:"),i&&(n+="flat-shading:");let e=this.cache.get(n);e||(e=t.clone(),o&&(e.vertexColors=!0),i&&(e.flatShading=!0),s&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(n,e),this.associations.set(e,this.associations.get(t))),t=e}e.material=t}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const o=this,c=this.json,a=this.extensions,t=c.materials[e];let i;const n={},l=t.extensions||{},s=[];if(l[EXTENSIONS.KHR_MATERIALS_UNLIT]){const e=a[EXTENSIONS.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),s.push(e.extendParams(n,t,o))}else{const a=t.pbrMetallicRoughness||{};if(n.color=new Color(1,1,1),n.opacity=1,Array.isArray(a.baseColorFactor)){const e=a.baseColorFactor;n.color.setRGB(e[0],e[1],e[2],LinearSRGBColorSpace),n.opacity=e[3]}a.baseColorTexture!==0[0]&&s.push(o.assignTexture(n,"map",a.baseColorTexture,SRGBColorSpace)),n.metalness=a.metallicFactor!==0[0]?a.metallicFactor:1,n.roughness=a.roughnessFactor!==0[0]?a.roughnessFactor:1,a.metallicRoughnessTexture!==0[0]&&(s.push(o.assignTexture(n,"metalnessMap",a.metallicRoughnessTexture)),s.push(o.assignTexture(n,"roughnessMap",a.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),s.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,n)})))}t.doubleSided===!0&&(n.side=DoubleSide);const r=t.alphaMode||ALPHA_MODES.OPAQUE;if(r===ALPHA_MODES.BLEND?(n.transparent=!0,n.depthWrite=!1):(n.transparent=!1,r===ALPHA_MODES.MASK&&(n.alphaTest=t.alphaCutoff!==0[0]?t.alphaCutoff:.5)),t.normalTexture!==0[0]&&i!==MeshBasicMaterial&&(s.push(o.assignTexture(n,"normalMap",t.normalTexture)),n.normalScale=new Vector2(1,1),t.normalTexture.scale!==0[0])){const e=t.normalTexture.scale;n.normalScale.set(e,e)}if(t.occlusionTexture!==0[0]&&i!==MeshBasicMaterial&&(s.push(o.assignTexture(n,"aoMap",t.occlusionTexture)),t.occlusionTexture.strength!==0[0]&&(n.aoMapIntensity=t.occlusionTexture.strength)),t.emissiveFactor!==0[0]&&i!==MeshBasicMaterial){const e=t.emissiveFactor;n.emissive=(new Color).setRGB(e[0],e[1],e[2],LinearSRGBColorSpace)}return t.emissiveTexture!==0[0]&&i!==MeshBasicMaterial&&s.push(o.assignTexture(n,"emissiveMap",t.emissiveTexture,SRGBColorSpace)),Promise.all(s).then(function(){const s=new i(n);return t.name&&(s.name=t.name),assignExtrasToUserData(s,t),o.associations.set(s,{materials:e}),t.extensions&&addUnknownExtensionsToUserData(a,s,t),s})}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,o=this.extensions,s=this.primitiveCache;function i(e){return o[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return addPrimitiveAttributes(n,e,t)})}const n=[];for(let a=0,l=e.length;a<l;a++){const o=e[a],r=createPrimitiveKey(o),c=s[r];if(c)n.push(c.promise);else{let e;o.extensions&&o.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?e=i(o):e=addPrimitiveAttributes(new BufferGeometry,o,t),s[r]={primitive:o,promise:e},n.push(e)}}return Promise.all(n)}loadMesh(e){const n=this,a=this.json,o=this.extensions,t=a.meshes[e],s=t.primitives,i=[];for(let e=0,t=s.length;e<t;e++){const n=s[e].material===0[0]?createDefaultMaterial(this.cache):this.getDependency("material",s[e].material);i.push(n)}return i.push(n.loadGeometries(s)),Promise.all(i).then(function(i){const l=i.slice(0,i.length-1),c=i[i.length-1],a=[];for(let h=0,m=c.length;h<m;h++){const d=c[h],r=s[h];let i;const u=l[h];if(r.mode===WEBGL_CONSTANTS.TRIANGLES||r.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||r.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||r.mode===0[0])i=t.isSkinnedMesh===!0?new SkinnedMesh(d,u):new Mesh(d,u),i.isSkinnedMesh===!0&&i.normalizeSkinWeights(),r.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?i.geometry=toTrianglesDrawMode(i.geometry,TriangleStripDrawMode):r.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(i.geometry=toTrianglesDrawMode(i.geometry,TriangleFanDrawMode));else if(r.mode===WEBGL_CONSTANTS.LINES)i=new LineSegments(d,u);else if(r.mode===WEBGL_CONSTANTS.LINE_STRIP)i=new Line(d,u);else if(r.mode===WEBGL_CONSTANTS.LINE_LOOP)i=new LineLoop(d,u);else if(r.mode===WEBGL_CONSTANTS.POINTS)i=new Points(d,u);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+r.mode);Object.keys(i.geometry.morphAttributes).length>0&&updateMorphTargets(i,t),i.name=n.createUniqueName(t.name||"mesh_"+e),assignExtrasToUserData(i,t),r.extensions&&addUnknownExtensionsToUserData(o,i,r),n.assignFinalMaterial(i),a.push(i)}for(let t=0,s=a.length;t<s;t++)n.associations.set(a[t],{meshes:e,primitives:t});if(a.length===1)return t.extensions&&addUnknownExtensionsToUserData(o,a[0],t),a[0];const r=new Group;t.extensions&&addUnknownExtensionsToUserData(o,r,t),n.associations.set(r,{meshes:e});for(let e=0,t=a.length;e<t;e++)r.add(a[e]);return r})}loadCamera(e){let s;const n=this.json.cameras[e],t=n[n.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?s=new PerspectiveCamera(MathUtils.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):n.type==="orthographic"&&(s=new Orthogra
3992phicCamera(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),n.name&&(s.name=this.createUniqueName(n.name)),assignExtrasToUserData(s,n),Promise.resolve(s)}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,s=t.joints.length;e<s;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices!==0[0]?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(e){const n=e.pop(),s=e,o=[],i=[];for(let e=0,r=s.length;e<r;e++){const a=s[e];if(a){o.push(a);const t=new Matrix4;n!==null&&t.fromArray(n.array,e*16),i.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Skeleton(o,i)})}loadAnimation(e){const r=this.json,c=this,t=r.animations[e],l=t.name?t.name:"animation_"+e,n=[],s=[],o=[],i=[],a=[];for(let r=0,d=t.channels.length;r<d;r++){const l=t.channels[r],e=t.samplers[l.sampler],c=l.target,u=c.node,h=t.parameters!==0[0]?t.parameters[e.input]:e.input,m=t.parameters!==0[0]?t.parameters[e.output]:e.output;if(c.node===0[0])continue;n.push(this.getDependency("node",u)),s.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",m)),i.push(e),a.push(c)}return Promise.all([Promise.all(n),Promise.all(s),Promise.all(o),Promise.all(i),Promise.all(a)]).then(function(e){const n=e[0],i=e[1],a=e[2],r=e[3],d=e[4],s=[];for(let e=0,l=n.length;e<l;e++){const t=n[e],u=i[e],h=a[e],m=r[e],f=d[e];if(t===0[0])continue;t.updateMatrix&&t.updateMatrix();const o=c._createAnimationTracks(t,u,h,m,f);if(o)for(let e=0;e<o.length;e++)s.push(o[e])}const o=new AnimationClip(l,0[0],s);return assignExtrasToUserData(o,t),o})}createNodeMesh(e){const s=this.json,n=this,t=s.nodes[e];return t.mesh===0[0]?null:n.getDependency("mesh",t.mesh).then(function(e){const s=n._getNodeRef(n.meshCache,t.mesh,e);return t.weights!==0[0]&&s.traverse(function(e){if(!e.isMesh)return;for(let n=0,s=t.weights.length;n<s;n++)e.morphTargetInfluences[n]=t.weights[n]}),s})}loadNode(e){const i=this.json,t=this,n=i.nodes[e],a=t._loadNodeShallow(e),s=[],o=n.children||[];for(let e=0,n=o.length;e<n;e++)s.push(t.getDependency("node",o[e]));const r=n.skin===0[0]?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([a,Promise.all(s),r]).then(function(e){const t=e[0],n=e[1],s=e[2];s!==null&&t.traverse(function(e){if(!e.isSkinnedMesh)return;e.bind(s,_identityMatrix2)});for(let e=0,s=n.length;e<s;e++)t.add(n[e]);return t})}_loadNodeShallow(e){const i=this.json,a=this.extensions,n=this;if(this.nodeCache[e]!==0[0])return this.nodeCache[e];const t=i.nodes[e],r=t.name?n.createUniqueName(t.name):"",s=[],o=n._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return o&&s.push(o),t.camera!==0[0]&&s.push(n.getDependency("camera",t.camera).then(function(e){return n._getNodeRef(n.cameraCache,t.camera,e)})),n._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){s.push(e)}),this.nodeCache[e]=Promise.all(s).then(function(s){let o;if(t.isBone===!0?o=new Bone:s.length>1?o=new Group:s.length===1?o=s[0]:o=new Object3D,o!==s[0])for(let e=0,t=s.length;e<t;e++)o.add(s[e]);if(t.name&&(o.userData.name=t.name,o.name=r),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(a,o,t),t.matrix!==0[0]){const e=new Matrix4;e.fromArray(t.matrix),o.applyMatrix4(e)}else t.translation!==0[0]&&o.position.fromArray(t.translation),t.rotation!==0[0]&&o.quaternion.fromArray(t.rotation),t.scale!==0[0]&&o.scale.fromArray(t.scale);if(n.associations.has(o)){if(t.mesh!==0[0]&&n.meshCache.refs[t.mesh]>1){const e=n.associations.get(o);n.associations.set(o,{...e})}}else n.associations.set(o,{});return n.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){const a=this.extensions,t=this.json.scenes[e],s=this,n=new Group;t.name&&(n.name=s.createUniqueName(t.name)),assignExtrasToUserData(n,t),t.extensions&&addUnknownExtensionsToUserData(a,n,t);const o=t.nodes||[],i=[];for(let e=0,t=o.length;e<t;e++)i.push(s.getDependency("node",o[e]));return Promise.all(i).then(function(e){for(let t=0,s=e.length;t<s;t++)n.add(e[t]);const t=e=>{const t=new Map;for(const[e,n]of s.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,n);return e.traverse(e=>{const n=s.associations.get(e);n!=null&&t.set(e,n)}),t};return s.associations=t(n),n})}_createAnimationTracks(e,t,n,s,o){const r=[],c=e.name?e.name:e.uuid,a=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(c);let i;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:i=NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:i=QuaternionKeyframeTrack;break;case PATH_PROPERTIES.translation:case PATH_PROPERTIES.scale:i=VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:i=NumberKeyframeTrack;break;case 2:case 3:default:i=VectorKeyframeTrack;break}break}const l=s.interpolation!==0[0]?INTERPOLATION[s.interpolation]:InterpolateLinear,d=this._getArrayFromAccessor(n);for(let e=0,c=a.length;e<c;e++){const n=new i(a[e]+"."+PATH_PROPERTIES[o.path],t.array,d,l);
3992s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(n),r.push(n)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=getNormalizedComponentScale(t.constructor),e=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)e[s]=t[s]*n;t=e}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const n=this instanceof QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new n(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(e,t,n){const a=t.attributes,s=new Box3;if(a.POSITION!==0[0]){const e=n.json.accessors[a.POSITION],t=e.min,o=e.max;if(t!==0[0]&&o!==0[0]){if(s.set(new Vector3(t[0],t[1],t[2]),new Vector3(o[0],o[1],o[2])),e.normalized){const t=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=t.targets;if(o!==0[0]){const t=new Vector3,e=new Vector3;for(let s=0,a=o.length;s<a;s++){const i=o[s];if(i.POSITION!==0[0]){const s=n.json.accessors[i.POSITION],o=s.min,a=s.max;if(o!==0[0]&&a!==0[0]){if(e.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),s.normalized){const t=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[s.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(t)}e.boundingBox=s;const i=new Sphere;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=i}function addPrimitiveAttributes(e,t,n){const s=t.attributes,o=[];function i(t,s){return n.getDependency("accessor",t).then(function(t){e.setAttribute(s,t)})}for(const t in s){const n=ATTRIBUTES[t]||t.toLowerCase();if(n in e.attributes)continue;o.push(i(s[t],n))}if(t.indices!==0[0]&&!e.index){const s=n.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});o.push(s)}return ColorManagement.workingColorSpace!==LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),computeBounds(e,t,n),Promise.all(o).then(function(){return t.targets!==0[0]?addMorphTargets(e,t.targets,n):e})}class HDRLoader extends DataTextureLoader{constructor(e){super(e),this.type=HalfFloatType}parse(e){const r=1,w=2,n=3,h=4,t=function(e,t){switch(e){case r:throw new Error("THREE.HDRLoader: Read Error: "+(t||""));case w:throw new Error("THREE.HDRLoader: Write Error: "+(t||""));case n:throw new Error("THREE.HDRLoader: Bad File Format: "+(t||""));default:case h:throw new Error("THREE.HDRLoader: Memory Error: "+(t||""))}},g=1,c=2,l=4,_=` 3993`,p=function(e,t,n){const a=128;t=t||1024;let s=e.pos,i=-1,r=0,c="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+a)));for(;0>(i=o.indexOf(_))&&r<t&&s<e.byteLength;)c+=o,r+=o.length,s+=a,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+a)));return-1<i&&(n!==!1&&(e.pos+=r+i+1),c+o.slice(0,i))},y=function(e){const a=/^#\?(\S+)/,d=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,u=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,h=/^\s*FORMAT=(\S+)\s*$/,m=/^\s*-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let o,i;for((e.pos>=e.byteLength||!(o=p(e)))&&t(r,"no header found"),(i=o.match(a))||t(n,"bad initial token"),s.valid|=g,s.programtype=i[1],s.string+=o+` 3994`;!0;){if(o=p(e),o===!1)break;if(s.string+=o+` 3995`,o.charAt(0)==="#"){s.comments+=o+` 3996`;continue}if((i=o.match(d))&&(s.gamma=parseFloat(i[1])),(i=o.match(u))&&(s.exposure=parseFloat(i[1])),(i=o.match(h))&&(s.valid|=c,s.format=i[1]),(i=o.match(m))&&(s.valid|=l,s.height=parseInt(i[1],10),s.width=parseInt(i[2],10)),s.valid&c&&s.valid&l)break}return s.valid&c||t(n,"missing format specifier"),s.valid&l||t(n,"missing image size specifier"),s},j=function(e,s,o){const a=s;if(a<8||a>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);a!==(e[2]<<8|e[3])&&t(n,"wrong scanline width");const l=new Uint8Array(4*s*o);l.length||t(h,"unable to allocate buffer space");let u=0,i=0;const m=4*a,c=new Uint8Array(4),d=new Uint8Array(m);let f=o;for(;f>0&&i<e.byteLength;){i+4>
vendor: 2,839 bytes, line 3996
3996e.byteLength&&t(r),c[0]=e[i++],c[1]=e[i++],c[2]=e[i++],c[3]=e[i++],(c[0]!=2||c[1]!=2||(c[2]<<8|c[3])!=a)&&t(n,"bad rgbe scanline format");let o=0,s;for(;o<m&&i<e.byteLength;){s=e[i++];const a=s>128;if(a&&(s-=128),(s===0||o+s>m)&&t(n,"bad scanline data"),a){const t=e[i++];for(let e=0;e<s;e++)d[o++]=t}else d.set(e.subarray(i,i+s),o),o+=s,i+=s}const h=a;for(let t=0;t<h;t++){let e=0;l[u]=d[t+e],e+=a,l[u+1]=d[t+e],e+=a,l[u+2]=d[t+e],e+=a,l[u+3]=d[t+e],u+=4}f--}return l},b=function(e,t,n,s){const i=e[t+3],o=2**(i-128)/255;n[s+0]=e[t+0]*o,n[s+1]=e[t+1]*o,n[s+2]=e[t+2]*o,n[s+3]=1},v=function(e,t,n,s){const i=e[t+3],o=2**(i-128)/255;n[s+0]=DataUtils.toHalfFloat(Math.min(e[t+0]*o,65504)),n[s+1]=DataUtils.toHalfFloat(Math.min(e[t+1]*o,65504)),n[s+2]=DataUtils.toHalfFloat(Math.min(e[t+2]*o,65504)),n[s+3]=DataUtils.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;const i=y(a),{width:f,height:m}=i,o=j(a.subarray(a.pos),f,m);let u,d,s;switch(this.type){case FloatType:s=o.length/4;const e=new Float32Array(s*4);for(let t=0;t<s;t++)b(o,t*4,e,t*4);u=e,d=FloatType;break;case HalfFloatType:s=o.length/4;const t=new Uint16Array(s*4);for(let e=0;e<s;e++)v(o,e*4,t,e*4);u=t,d=HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:f,height:m,data:u,header:i.string,gamma:i.gamma,exposure:i.exposure,type:d}}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(e,n){switch(e.type){case FloatType:case HalfFloatType:e.colorSpace=LinearSRGBColorSpace,e.minFilter=LinearFilter,e.magFilter=LinearFilter,e.generateMipmaps=!1,e.flipY=!0;break}t&&t(e,n)}return super.load(e,o,n,s)}}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:s}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,s)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{const s=this._getIdleWorker();s!==-1?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=n,this.workers[s].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}t=0,n=2,u=1,y=2,S=0,E=1,X=10,it=0,ht=9,gt=15,xt=16,dt=22,Ft=37,Et=43,te=76,ae=83,ue=97,ye=100,de=103,Ae=109,We=122,He=123,qe=131,Je=132,Qe=133,Ze=134,en=137,nn=138,sn=139,an=140,r
vendor: 5,148 bytes, line 3996
3996n=141,on=142,cn=145,Un=146,pn=148,xn=152,yn=153,bn=154,mn=155,dn=156,Dn=157,wn=158,Vn=165,Cn=166,ri=1000054e3,oi=1000054001,ci=1000054004,Ui=1000054005,_i=1000066e3,yi=1000066004;class Ci{constructor(e,t,n,s){this._dataView=0[0],this._littleEndian=0[0],this._offset=0[0],this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const s=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+s,n)}}Fi=new Uint8Array([0]),Oi=[171,75,84,88,32,50,48,187,13,10,26,10];function Si(e){return(new TextDecoder).decode(e)}function Mi(e){const o=new Uint8Array(e.buffer,e.byteOffset,Oi.length);if(o[0]!==Oi[0]||o[1]!==Oi[1]||o[2]!==Oi[2]||o[3]!==Oi[3]||o[4]!==Oi[4]||o[5]!==Oi[5]||o[6]!==Oi[6]||o[7]!==Oi[7]||o[8]!==Oi[8]||o[9]!==Oi[9]||o[10]!==Oi[10]||o[11]!==Oi[11])throw new Error("Missing KTX 2.0 identifier.");const n={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},p=17*Uint32Array.BYTES_PER_ELEMENT,s=new Ci(e,Oi.length,p,!0);n.vkFormat=s._nextUint32(),n.typeSize=s._nextUint32(),n.pixelWidth=s._nextUint32(),n.pixelHeight=s._nextUint32(),n.pixelDepth=s._nextUint32(),n.layerCount=s._nextUint32(),n.faceCount=s._nextUint32(),n.levelCount=s._nextUint32(),n.supercompressionScheme=s._nextUint32();const S=s._nextUint32(),x=s._nextUint32(),M=s._nextUint32(),h=s._nextUint32(),g=s._nextUint64(),d=s._nextUint64(),F=3*Math.max(n.levelCount,1)*8,r=new Ci(e,Oi.length+p,F,!0);for(let t=0,s=Math.max(n.levelCount,1);t<s;t++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+r._nextUint64(),r._nextUint64()),uncompressedByteLength:r._nextUint64()});const t=new Ci(e,S,x,!0);t._skip(4);const _=t._nextUint16(),A=t._nextUint16(),y=t._nextUint16(),E=t._nextUint16(),b={vendorId:_,descriptorType:A,versionNumber:y,colorModel:t._nextUint8(),colorPrimaries:t._nextUint8(),transferFunction:t._nextUint8(),flags:t._nextUint8(),texelBlockDimension:[t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8()],bytesPlane:[t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8()],samples:[]},C=(E/4-6)/4;for(let n=0;n<C;n++){const e={bitOffset:t._nextUint16(),bitLength:t._nextUint8(),channelType:t._nextUint8(),samplePosition:[t._nextUint8(),t._nextUint8(),t._nextUint8(),t._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&e.channelType?(e.sampleLower=t._nextInt32(),e.sampleUpper=t._nextInt32()):(e.sampleLower=t._nextUint32(),e.sampleUpper=t._nextUint32()),b.samples[n]=e}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(b);const a=new Ci(e,M,h,!0);for(;a._offset<h;){const e=a._nextUint32(),s=a._scan(e),t=Si(s);if(n.keyValue[t]=a._nextUint8Array(e-s.byteLength-1),t.match(/^ktx/i)){const e=Si(n.keyValue[t]);n.keyValue[t]=e.substring(0,e.lastIndexOf("\x00"))}a._skip(e%4?4-e%4:0)}if(d<=0)return n;const i=new Ci(e,g,d,!0),w=i._nextUint16(),O=i._nextUint16(),l=i._nextUint32(),j=i._nextUint32(),v=i._nextUint32(),k=i._nextUint32(),c=[];for(let e=0,t=Math.max(n.levelCount,1);e<t;e++)c.push({imageFlags:i._nextUint32(),rgbSliceByteOffset:i._nextUint32(),rgbSliceByteLength:i._nextUint32(),alphaSliceByteOffset:i._nextUint32(),alphaSliceByteLength:i._nextUint32()});const f=g+i._offset,m=f+l,u=m+j,T=u+v,z=new Uint8Array(e.buffer,e.byteOffset+f,l),D=new Uint8Array(e.buffer,e.byteOffset+m,j),N=new Uint8Array(e.buffer,e.byteOffset+u,v),L=new Uint8Array(e.buffer,e.byteOffset+T,k);return n.globalData={endpointCount:w,selectorCount:O,imageDescs:c,endpointsData:z,selectorsData:D,tablesData:N,extendedData:L},n}g={env:{emscripten_notify_memory_growth:function(){B2=new Uint8Array(I.exports.memory.buffer)}}};class Q{init(){return A||(A=typeof fetch!="undefined"?fetch("data:application/wasm;base64,"+C).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,g)).then(this._init):WebAssembly.instantiate(Buffer.from(C,"base64"),g).then(this._init),A)}_init(e){I=e.instance,g.env.emscripten_notify_memory_growth(0)}
3996decode(e,t=0){if(!I)throw new Error("ZSTDDecoder: Await .init() before decoding.");const o=e.byteLength,n=I.exports.malloc(o);B2.set(e,n),t=t||Number(I.exports.ZSTD_findDecompressedSize(n,o));const s=I.exports.malloc(t),i=I.exports.ZSTD_decompress(s,t,n,o),a=B2.slice(s,s+i);return I.exports.free(n),I.exports.free(s),a}}C
vendor: 38,980 bytes, line 3996
3996="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",
3996DisplayP3ColorSpace
3996="display-p3",LinearDisplayP3ColorSpace="display-p3-linear",ExtendedSRGBColorSpaceImpl={...ColorManagement.spaces[SRGBColorSpace],outputColorSpaceConfig:{drawingBufferColorSpace:SRGBColorSpace,toneMappingMode:"extended"}},_taskCache=new WeakMap,_activeLoaders=0;class KTX2Loader extends Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER!="undefined"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},typeof navigator!="undefined"&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const t=new FileLoader(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const n=t.loadAsync("basis_transcoder.js"),e=new FileLoader(this.manager);e.setPath(this.transcoderPath),e.setResponseType("arraybuffer"),e.setWithCredentials(this.withCredentials);const s=e.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([n,s]).then(([e,t])=>{const n=KTX2Loader.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _EngineType = "+JSON.stringify(KTX2Loader.EngineType),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(` 3997`);this.workerSourceURL=URL.createObjectURL(new Blob([s])),this.transcoderBinary=t,this.workerPool.setWorkerCreator(()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e})}),_activeLoaders>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_activeLoaders++}return this.transcoderPending}load(e,t,n,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const o=new FileLoader(this.manager);o.setPath(this.path),o.setCrossOrigin(this.crossOrigin),o.setWithCredentials(this.withCredentials),o.setRequestHeader(this.requestHeader),o.setResponseType("arraybuffer"),o.load(e,e=>{this.parse(e,t,s)},n,s)}parse(e,t,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(_taskCache.has(e)){const s=_taskCache.get(e);
vendor: 6,072 bytes, line 3997
3997return s.promise.then(t).catch(n)}this._createTexture(e).then(e=>t?t(e):null).catch(n)}_createTextureFrom(e,t){const{type:c,error:l,data:{faces:s,width:a,height:r,format:o,type:i,dfdFlags:d}}=e;if(c==="error")return Promise.reject(l);let n;if(t.faceCount===6)n=new CompressedCubeTexture(s,o,i);else{const e=s[0].mipmaps;n=t.layerCount>1?new CompressedArrayTexture(e,a,r,t.layerCount,o,i):new CompressedTexture(e,a,r,o,i)}return n.minFilter=s[0].mipmaps.length===1?LinearFilter:LinearMipmapLinearFilter,n.magFilter=LinearFilter,n.generateMipmaps=!1,n.needsUpdate=!0,n.colorSpace=parseColorSpace(t),n.premultiplyAlpha=!!(d&u),n}async _createTexture(e,t={}){const n=Mi(new Uint8Array(e)),o=n.vkFormat===_i&&n.dataFormatDescriptor[0].colorModel===167,i=n.vkFormat===it||o&&!this.workerConfig.astcHDRSupported;if(!i)return createRawTexture(n);const a=t,s=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:a},[e])).then(e=>this._createTextureFrom(e.data,n));return _taskCache.set(e,{promise:s}),s}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),_activeLoaders--}}KTX2Loader.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},KTX2Loader.EngineFormat={RGBAFormat,RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format,RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format,RGB_ETC1_Format,RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format},KTX2Loader.EngineType={UnsignedByteType,HalfFloatType,FloatType},KTX2Loader.BasisWorker=function(){let a,r,o;const t=_EngineFormat,s=_EngineType,n=_TranscoderFormat,e=_BasisFormat;self.addEventListener("message",function(e){const t=e.data;switch(t.type){case"init":a=t.config,l(t.transcoderBinary);break;case"transcode":r.then(()=>{try{const{faces:e,buffers:n,width:s,height:o,hasAlpha:i,format:a,type:r,dfdFlags:c}=d(t.buffer);self.postMessage({type:"transcode",id:t.id,data:{faces:e,width:s,height:o,hasAlpha:i,format:a,type:r,dfdFlags:c}},n)}catch(e){console.error(e),self.postMessage({type:"error",id:t.id,error:e.message})}});break}});function l(e){r=new Promise(t=>{o={wasmBinary:e,onRuntimeInitialized:t},BASIS(o)}).then(()=>{o.initializeBasis(),o.KTX2File===0[0]&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function d(t){const n=new o.KTX2File(new Uint8Array(t));function i(){n.close(),n.delete()}if(!n.isValid())throw i(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let a;if(n.isUASTC())a=e.UASTC;else if(n.isETC1S())a=e.ETC1S;else if(n.isHDR())a=e.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const r=n.getWidth(),c=n.getHeight(),b=n.getLayers()||1,l=n.getLevels(),j=n.getFaces(),u=n.getHasAlpha(),y=n.getDFDFlags(),{transcoderFormat:f,engineFormat:p,engineType:d}=h(a,r,c,u);if(!r||!c||!l)throw i(),new Error("THREE.KTX2Loader: Invalid texture");if(!n.startTranscoding())throw i(),new Error("THREE.KTX2Loader: .startTranscoding failed");const g=[],v=[];for(let e=0;e<j;e++){const t=[];for(let o=0;o<l;o++){const c=[];let a,r;for(let t=0;t<b;t++){const u=n.getImageLevelInfo(o,t,e);e===0&&o===0&&t===0&&(u.origWidth%4!==0||u.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),l>1?(a=u.origWidth,r=u.origHeight):(a=u.width,r=u.height);let h=new Uint8Array(n.getImageTranscodedSizeInBytes(o,t,0,f));const m=n.transcodeImage(h,o,t,e,f,0,-1,-1);if(d===s.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!m)throw i(),new Error("THREE.KTX2Loader: .transcodeImage failed.");c.push(h)}const u=m(c);t.push({data:u,width:a,height:r}),v.push(u.buffer)}g.push({mipmaps:t,width:r,height:c,format:p,type:d})}return i(),{faces:g,buffers:v,width:r,height:c,hasAlpha:u,dfdFlags:y,format:p,type:d}}const i=[{if:"astcSupported",basisFormat:[e.UASTC],transcoderFormat:[n.ASTC_4x4,n.ASTC_4x4],engineFormat:[t.RGBA_ASTC_4x4_Format,t.RGBA_ASTC_4x4_Format],engineType:[s.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.BC7_M5,n.BC7_M5],engineFormat:[t.RGBA_BPTC_Format,t.RGBA_BPTC_Format],engineType:[s.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.BC1,n.BC3],engineFormat:[t.RGBA_S3TC_DXT1_Format,t.RGBA_S3TC_DXT5_Format],engineType:[s.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.ETC1,n.ETC2],engineFormat:[t.RGB_ETC2_Format,t.RGBA_ETC2_EAC_Format],engineType:[s.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.ETC1],engineFormat:[t.RGB_ETC1_Format],engineType:[s.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.PVRTC1_4_RGB,n.PVRTC1_4_RGBA],engineFormat:[t.RGB_PVRTC_4BPPV1_Format,t.RGBA_PVRTC_4BPPV1_Format],engineType:[s.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[e.UASTC_HDR],transcoderFormat:[n.BC6H],engineFormat:[t.RGB_BPTC_UNSIGNED_Format],engineType:[s.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[e.ETC1S,e.UASTC],transcoderFormat:[n.RGBA32,n.RGBA32],engineFormat:[t.RGBAFormat,t.RGBAFormat],engineType:[s.UnsignedByteType,s.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[e.UASTC_HDR],transcoderFormat:[n.RGBA_HALF],engineFormat:[t.RGBAFormat],engineType:[s.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],u={[e.ETC1S]:i.filter(t=>t.basisFormat.includes(e.ETC1S)).sort((e,t)=>
3997e.priorityETC1S-t.priorityETC1S),[e.UASTC]:i.filter(t=>t.basisFormat.includes(e.UASTC)).sort((e,t)=>e.priorityUASTC-t.priorityUASTC),[e.UASTC_HDR]:i.filter(t=>t.basisFormat.includes(e.UASTC_HDR)).sort((e,t)=>e.priorityHDR-t.priorityHDR)};function h(e,t,n,s){const o=u[e];for(let r=0;r<o.length;r++){const i=o[r];if(i.if&&!a[i.if])continue;if(!i.basisFormat.includes(e))continue;if(s&&i.transcoderFormat.length<2)continue;if(i.needsPowerOfTwo&&!(c(t)&&c(n)))continue;const l=i.transcoderFormat[s?1:0],d=i.engineFormat[s?1:0],u=i.engineType[0];return{transcoderFormat:l,engineFormat:d,engineType:u}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function c(e){return e<=2||(e&e-1)===0&&e!==0}function m(e){if(e.length===1)return e[0];let t=0;for(let n=0;n<e.length;n++){const s=e[n];t+=s.byteLength}const n=new Uint8Array(t);let s=0;for(let t=0;t<e.length;t++){const o=e[t];n.set(o,s),s+=o.byteLength}return n}},UNCOMPRESSED_FORMATS=new Set([RGBAFormat,RGBFormat,RGFormat,RedFormat]),FORMAT_MAP={[Ae]:RGBAFormat,[de]:RGFormat,[ye]:RedFormat,[ue]:RGBAFormat,[ae]:RGFormat,[te]:RedFormat,[Et]:RGBAFormat,[Ft]:RGBAFormat,[dt]:RGFormat,[xt]:RGFormat,[gt]:RedFormat,[ht]:RedFormat,[He]:RGBFormat,[We]:RGBFormat,[xn]:RGBA_ETC2_EAC_Format,[pn]:RGB_ETC2_Format,[yn]:R11_EAC_Format,[bn]:SIGNED_R11_EAC_Format,[mn]:RG11_EAC_Format,[dn]:SIGNED_RG11_EAC_Format,[_i]:RGBA_ASTC_4x4_Format,[wn]:RGBA_ASTC_4x4_Format,[Dn]:RGBA_ASTC_4x4_Format,[yi]:RGBA_ASTC_6x6_Format,[Cn]:RGBA_ASTC_6x6_Format,[Vn]:RGBA_ASTC_6x6_Format,[Ze]:RGBA_S3TC_DXT1_Format,[Qe]:RGBA_S3TC_DXT1_Format,[Je]:RGB_S3TC_DXT1_Format,[qe]:RGB_S3TC_DXT1_Format,[nn]:RGBA_S3TC_DXT3_Format,[en]:RGBA_S3TC_DXT3_Format,[an]:SIGNED_RED_RGTC1_Format,[sn]:RED_RGTC1_Format,[on]:SIGNED_RED_GREEN_RGTC2_Format,[rn]:RED_GREEN_RGTC2_Format,[Un]:RGBA_BPTC_Format,[cn]:RGBA_BPTC_Format,[Ui]:RGBA_PVRTC_4BPPV1_Format,[oi]:RGBA_PVRTC_4BPPV1_Format,[ci]:RGBA_PVRTC_2BPPV1_Format,[ri]:RGBA_PVRTC_2BPPV1_Format},TYPE_MAP={[Ae]:FloatType,[de]:FloatType,[ye]:FloatType,[ue]:HalfFloatType,[ae]:HalfFloatType,[te]:HalfFloatType,[Et]:UnsignedByteType,[Ft]:UnsignedByteType,[dt]:UnsignedByteType,[xt]:UnsignedByteType,[gt]:UnsignedByteType,[ht]:UnsignedByteType,[He]:UnsignedInt5999Type,[We]:UnsignedInt101111Type,[xn]:UnsignedByteType,[pn]:UnsignedByteType,[yn]:UnsignedByteType,[yn]:UnsignedByteType,[mn]:UnsignedByteType,[mn]:UnsignedByteType,[_i]:HalfFloatType,[wn]:UnsignedByteType,[Dn]:UnsignedByteType,[yi]:HalfFloatType,[Cn]:UnsignedByteType,[Vn]:UnsignedByteType,[Ze]:UnsignedByteType,[Qe]:UnsignedByteType,[Je]:UnsignedByteType,[qe]:UnsignedByteType,[nn]:UnsignedByteType,[en]:UnsignedByteType,[an]:UnsignedByteType,[sn]:UnsignedByteType,[on]:UnsignedByteType,[rn]:UnsignedByteType,[Un]:UnsignedByteType,[cn]:UnsignedByteType,[Ui]:UnsignedByteType,[oi]:UnsignedByteType,[ci]:UnsignedByteType,[ri]:UnsignedByteType};async function createRawTexture(e){const{vkFormat:o}=e;if(FORMAT_MAP[o]===0[0])throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+o);TYPE_MAP[o]===0[0]&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+o);let a;e.supercompressionScheme===n&&(_zstd||(_zstd=new Promise(async e=>{const t=new Q;await t.init(),e(t)})),a=await _zstd);const i=[];for(let r=0;r<e.levels.length;r++){const d=Math.max(1,e.pixelWidth>>r),u=Math.max(1,e.pixelHeight>>r),h=e.pixelDepth?Math.max(1,e.pixelDepth>>r):0,l=e.levels[r];let s;if(e.supercompressionScheme===t)s=l.levelData;else if(e.supercompressionScheme===n)s=a.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let c;TYPE_MAP[o]===FloatType?c=new Float32Array(s.buffer,s.byteOffset,s.byteLength/Float32Array.BYTES_PER_ELEMENT):TYPE_MAP[o]===HalfFloatType?c=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/Uint16Array.BYTES_PER_ELEMENT):TYPE_MAP[o]===UnsignedInt5999Type||TYPE_MAP[o]===UnsignedInt101111Type?c=new Uint32Array(s.buffer,s.byteOffset,s.byteLength/Uint32Array.BYTES_PER_ELEMENT):c=s,i.push({data:c,width:d,height:u,depth:h})}const r=e.levelCount===0||i.length>1;let s;if(UNCOMPRESSED_FORMATS.has(FORMAT_MAP[o]))s=e.pixelDepth===0?new DataTexture(i[0].data,e.pixelWidth,e.pixelHeight):new Data3DTexture(i[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth),s.minFilter=r?NearestMipmapNearestFilter:NearestFilter,s.magFilter=NearestFilter,s.generateMipmaps=e.levelCount===0;else{if(e.pixelDepth>
39970)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new CompressedTexture(i,e.pixelWidth,e.pixelHeight),s.minFilter=r?LinearMipmapLinearFilter:LinearFilter,s.magFilter=LinearFilter}return s.mipmaps=i,s.type=TYPE_MAP[o],s.format=FORMAT_MAP[o],s.colorSpace=parseColorSpace(e),s.needsUpdate=!0,Promise.resolve(s)}function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return t.colorPrimaries===E?t.transferFunction===y?SRGBColorSpace:LinearSRGBColorSpace:t.colorPrimaries===X?t.transferFunction===y?DisplayP3ColorSpace:LinearDisplayP3ColorSpace:t.colorPrimaries===S?NoColorSpace:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),NoColorSpace)}document.querySelectorAll(".scene").forEach(e=>{e.addEventListener("click",async()=>{loadScene(e)},{once:!0})}),loadScene=async e=>{const a=e.parentNode,s=JSON.parse(atob(a.dataset.config||"")),h=a.querySelector("picture"),f=a.querySelector(".media-overlay"),l=1280,c=720,m=s?.camera?.position?.x||0,g=s?.camera?.position?.y||0,p=s?.camera?.position?.z||0,_=s?.camera?.distance||1,r=new Scene,t=new WebGPURenderer({antialias:!0,alpha:!0});t.setPixelRatio(window.devicePixelRatio),t.setSize(l,c,!1),t.setAnimationLoop(y),t.toneMapping=s?.tonemap==="aces"?ACESFilmicToneMapping:s?.tonemap==="agx"?AgXToneMapping:LinearToneMapping,t.toneMappingExposure=s?.tonemap==="aces"?1.25:1,await t.init();const o=new PerspectiveCamera(30,l/c,.1,10);o.position.x=m,o.position.y=g,o.position.z=p;const n=new OrbitControls(o,t.domElement);n.autoRotateSpeed=1,n.enableDamping=!0,n.dampingFactor=.1,n.update();const i=new LoadingManager;i.onStart=()=>{},i.onProgress=(e,t,n)=>{const s=Math.round(t/n*100)},i.onLoad=()=>{},i.onError=e=>{console.error(`error loading ${e}`)};const u=new KTX2Loader(i).setTranscoderPath("/static/scripts/three/libs/basis/").detectSupport(t);b(),v(),t.domElement.removeAttribute("data-engine"),t.domElement.classList.add("media-3d-canvas"),t.domElement.style.cssText=s?.style,a.prepend(t.domElement),a.addEventListener("mousedown",d),a.addEventListener("touchstart",d);async function v(){if(s?.environment){const t=s.environment,e=await(new HDRLoader).loadAsync(t);e.mapping=EquirectangularReflectionMapping,r.environment=e;return}const e=new AmbientLight(16777215);e.intensity=2.5,r.add(e)}async function b(){const m=new GLTFLoader(i).setCrossOrigin("anonymous").setKTX2Loader(u).setMeshoptDecoder(MeshoptDecoder),a=await m.loadAsync(s.gltf),l=(new Box3).setFromObject(a.scene),c=l.getSize(new Vector3),p=l.getCenter(new Vector3),g=Math.max(c.x,c.y,c.z),d=g/(2*Math.atan(Math.PI*o.fov/360)),v=d/o.aspect,e=_*Math.max(d,v),b=n.target.clone().sub(o.position).normalize().multiplyScalar(e);n.minDistance=e/10,n.maxDistance=e*2,n.target.copy(p),o.near=e/50,o.far=e*50,o.updateProjectionMatrix(),o.position.copy(n.target).sub(b),n.update(),r.add(a.scene),u.dispose(),window.requestAnimationFrame(()=>{t.domElement.classList.add("media-visible"),h.classList.add("media-poster-hidden"),f.classList.add("media-poster-hidden")}),setTimeout(()=>{n.autoRotate=!0},500),a.scene.traverse(e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)}),j(a.scene)}async function j(e){const n=s.materials?.shadow_catcher;if(n===0[0])return;const a=5,o=(new Box3).setFromObject(e),i=o.max.x*a,r=o.min.y,c=await(new TextureLoader).loadAsync(n.alpha),t=new Mesh(new PlaneGeometry(i,i,1,1),new MeshBasicMaterial({color:0,alphaMap:c,toneMapped:!1,transparent:!0}));t.rotation.x=-Math.PI/2,t.rotation.z=-Math.PI/2,t.renderOrder=1,t.position.y=r,e.add(t)}function y(){n.update(),t.render(r,o)}function d(){n.autoRotate=!1}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.